summaryrefslogtreecommitdiff
path: root/cleopatre/buildroot/toolchain
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/buildroot/toolchain')
-rw-r--r--cleopatre/buildroot/toolchain/Config.in34
-rw-r--r--cleopatre/buildroot/toolchain/Config.in.276
-rw-r--r--cleopatre/buildroot/toolchain/Makefile.in49
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/001-debian.patch142
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/100-uclibc-conf.patch608
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/210-cflags.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/600-arm-textrel.patch63
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/100-uclibc-conf.patch749
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/210-cflags.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-001_ld_makefile_patch.patch52
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-120_mips_xgot_multigot_workaround.patch39
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/sh-flags-off-by-one.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15/100-uclibc-conf.patch692
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15/210-cflags.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15/600-arm-textrel.patch63
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.15/700-nios2-2.15.patch38957
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/100-uclibc-conf.patch586
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch218
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch52
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.1/sh-flags-off-by-one.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch52
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/sh-flags-off-by-one.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-makeinfo-version.patch16
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/320-mips-elf-reloc-regression.patch68
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-makeinfo-version.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-makeinfo-version.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-001_ld_makefile_patch.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-012_check_ldrunpath_length.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/100-uclibc-conf.patch139
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/300-001_ld_makefile_patch.patch50
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/300-006_better_file_error.patch43
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/300-012_check_ldrunpath_length.patch47
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.17/400-mips-ELF_MAXPAGESIZE-4K.patch26
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/100-makeinfo-version.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-001_ld_makefile_patch.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-012_check_ldrunpath_length.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18/100-makeinfo-version.patch32
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18/110-arm-eabi-conf.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18/300-001_ld_makefile_patch.patch24
-rw-r--r--cleopatre/buildroot/toolchain/binutils/2.18/300-012_check_ldrunpath_length.patch21
-rw-r--r--cleopatre/buildroot/toolchain/binutils/Config.in41
-rw-r--r--cleopatre/buildroot/toolchain/binutils/binutils.mk193
-rwxr-xr-xcleopatre/buildroot/toolchain/br2_autoreconf699
-rw-r--r--cleopatre/buildroot/toolchain/ccache/Config.in9
-rw-r--r--cleopatre/buildroot/toolchain/ccache/Config.in.27
-rw-r--r--cleopatre/buildroot/toolchain/ccache/ccache.mk201
-rwxr-xr-xcleopatre/buildroot/toolchain/dependencies/check-host-lzma.sh13
-rwxr-xr-xcleopatre/buildroot/toolchain/dependencies/check-host-sed.sh32
-rw-r--r--cleopatre/buildroot/toolchain/dependencies/dependencies.mk35
-rwxr-xr-xcleopatre/buildroot/toolchain/dependencies/dependencies.sh303
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/Config.in10
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt.mk52
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt.nios2.conditional47
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/.cvsignore3
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Entries17
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Repository1
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Root1
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/LICENSE.TXT340
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/Makefile.in81
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/README62
-rwxr-xr-xcleopatre/buildroot/toolchain/elf2flt/elf2flt/config.guess1418
-rwxr-xr-xcleopatre/buildroot/toolchain/elf2flt/elf2flt/config.sub1577
-rwxr-xr-xcleopatre/buildroot/toolchain/elf2flt/elf2flt/configure4719
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure.in134
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/cygwin-elf.h2171
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/e1-elf2flt.ld161
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.c2152
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.ld179
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/flat.h111
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/flthdr.c382
-rwxr-xr-xcleopatre/buildroot/toolchain/elf2flt/elf2flt/install-sh251
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/ld-elf2flt.in219
-rwxr-xr-xcleopatre/buildroot/toolchain/elf2flt/elf2flt/maketarball.sh12
-rw-r--r--cleopatre/buildroot/toolchain/elf2flt/elf2flt/stubs.c6
-rw-r--r--cleopatre/buildroot/toolchain/external-toolchain/Config.in105
-rw-r--r--cleopatre/buildroot/toolchain/external-toolchain/ext-tool.mk56
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/100-uclibc-conf.patch470
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/200-uclibc-locale.patch3255
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/300-libstdc++-pic.patch51
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch65
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch42
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch119
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch22
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/700-pr15068-fix.patch44
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/71_all_sh-pr16665-fix.patch43
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/73_all_sh-pr20617.patch28
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/800-arm-bigendian.patch68
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/810-mips-xgot.patch6
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/900-nios2.patch14377
-rw-r--r--cleopatre/buildroot/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional270
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/100-uclibc-conf.patch553
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/200-uclibc-locale.patch3237
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/300-libstdc++-pic.patch45
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/402-libbackend_dep_gcov-iov.h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/602-sdk-libstdc++-includes.patch22
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.0.4/800-arm-bigendian.patch67
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/100-uclibc-conf.patch544
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/110-arm-eabi.patch27
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/200-uclibc-locale.patch3239
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/300-libstdc++-pic.patch50
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/402-libbackend_dep_gcov-iov.h.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/740-sh-pr24836.patch25
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/800-arm-bigendian.patch127
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/801-arm-bootstrap-libgcc.patch63
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.1.2/910-soft-float.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/103-uclibc-conf-noupstream.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/200-uclibc-locale.patch2790
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/203-uclibc-locale-no__x.patch213
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/204-uclibc-locale-wchar_fix.patch48
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/205-uclibc-locale-update.patch347
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/300-libstdc++-pic.patch50
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/306-libstdc++-namespace.patch36
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/402-libbackend_dep_gcov-iov.h.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/800-arm-bigendian.patch67
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.0/904-flatten-switch-stmt-00.patch153
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/103-uclibc-conf-noupstream.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/104-gnuhurd-uclibc-conf.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/200-uclibc-locale.patch2790
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/203-uclibc-locale-no__x.patch213
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/204-uclibc-locale-wchar_fix.patch48
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/205-uclibc-locale-update.patch347
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/300-libstdc++-pic.patch50
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/306-libstdc++-namespace.patch36
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/307-locale_facets.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/402-libbackend_dep_gcov-iov.h.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/800-arm-bigendian.patch67
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/904-flatten-switch-stmt-00.patch153
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/910-soft-float.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.1/920-soft-float.patch21
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/103-uclibc-conf-noupstream.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/104-gnuhurd-uclibc-conf.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/200-uclibc-locale.patch2790
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/203-uclibc-locale-no__x.patch213
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/204-uclibc-locale-wchar_fix.patch48
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/205-uclibc-locale-update.patch347
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/300-libstdc++-pic.patch50
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/306-libstdc++-namespace.patch36
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/307-locale_facets.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/402-libbackend_dep_gcov-iov.h.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/800-arm-bigendian.patch67
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/904-flatten-switch-stmt-00.patch153
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/910-soft-float.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.3/920-soft-float.patch21
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/100-uclibc-conf.patch200
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/103-uclibc-conf-noupstream.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/104-gnuhurd-uclibc-conf.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/200-uclibc-locale.patch2790
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/203-uclibc-locale-no__x.patch213
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/204-uclibc-locale-wchar_fix.patch48
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/205-uclibc-locale-update.patch347
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/300-libstdc++-pic.patch50
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/302-c99-snprintf.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/303-c99-complex-ugly-hack.patch12
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/304-index_macro.patch24
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/306-libstdc++-namespace.patch36
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/307-locale_facets.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/402-libbackend_dep_gcov-iov.h.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/800-arm-bigendian.patch67
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/904-flatten-switch-stmt-00.patch153
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/910-soft-float.patch26
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.2.4/920-soft-float.patch21
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/100-uclibc-conf.patch33
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/104-gnuhurd-uclibc-conf.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/301-missing-execinfo_h.patch11
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/302-c99-snprintf.patch13
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/305-libmudflap-susv3-legacy.patch49
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/810-arm-softfloat-libgcc.patch29
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/993-arm_insn-opinit-RTX_CODE-fixup.patch41
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/995-short-enums.diff42
-rw-r--r--cleopatre/buildroot/toolchain/gcc/4.3.1/998-gcc-4.3.0-fix-header.00.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gcc/Config.in163
-rw-r--r--cleopatre/buildroot/toolchain/gcc/Config.in.214
-rw-r--r--cleopatre/buildroot/toolchain/gcc/Makefile.in107
-rw-r--r--cleopatre/buildroot/toolchain/gcc/ext_source/Atmel/avr32/4.2.2-avr32-2.1.5/903-avr32-fix-removal-of-redundant-cast-operations.patch16
-rw-r--r--cleopatre/buildroot/toolchain/gcc/gcc-uclibc-3.x.mk509
-rw-r--r--cleopatre/buildroot/toolchain/gcc/gcc-uclibc-4.x.mk530
-rw-r--r--cleopatre/buildroot/toolchain/gcc/i386-gcc-soft-float.patch61
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.2.1/100-uclibc-conf.patch290
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.2.1/200-uclibc-readline-conf.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.2.1/400-mips-coredump.patch-2.4.23-2928
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.2.1/500-thread-timeout.patch34
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/100-uclibc-conf.patch280
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/200-uclibc-readline-conf.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/400-mips-coredump.patch-2.4.23-2928
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/500-thread-timeout.patch34
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/600-debian_10.selected-frame.patch552
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/620-debian_static-thread-db.patch156
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/630-debian_24.tracepoint-segv.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/640-debian_dwarf2-frame-signal-unwinder.patch120
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/650-debian_vsyscall-gdb-support.patch245
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/660-debian_dwarf-cfa-restore.patch23
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/680-debian_sim-destdir.patch53
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/690-debian_member-field-symtab.patch35
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/700-debian_cp-pass-by-reference.patch464
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/710-debian_thread-db-multiple-libraries.patch593
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/720-debian_static-threads-test.patch36
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/730-debian_gdb-fix-tracefork-check.patch225
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/740-debian_make-cv-type-crash.patch132
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/750-debian_sparc-singlestep.patch37
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/760-debian_vsyscall-bfd-close-result.patch20
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/770-debian_vfork-done-spelling.patch31
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/780-debian_gdbserver-rdynamic.patch675
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/790-debian_dwarf2-cfi-warning.patch39
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/800-debian_linux-use-underscore-exit.patch22
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/810-debian_bfd-no-kylix-crash.patch47
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.3/820-debian_disable-linux-fork-messages.patch46
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.4/100-uclibc-conf.patch78
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.4/200-uclibc-readline-conf.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.4/400-mips-coredump.patch-2.4.23-2928
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.4/500-thread-timeout.patch34
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.4/600-fix-compile-flag-mismatch.patch87
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.5/100-uclibc-conf.patch78
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.5/200-uclibc-readline-conf.patch15
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.5/400-mips-coredump.patch-2.4.23-2928
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.5/500-thread-timeout.patch33
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.5/600-fix-compile-flag-mismatch.patch64
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.6/100-uclibc-conf.patch82
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.6/600-fix-compile-flag-mismatch.patch69
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.6/700-nios2-6.6.patch7978
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.7.1/600-fix-compile-flag-mismatch.patch31
-rw-r--r--cleopatre/buildroot/toolchain/gdb/6.8/600-fix-compile-flag-mismatch.patch31
-rw-r--r--cleopatre/buildroot/toolchain/gdb/Config.in70
-rw-r--r--cleopatre/buildroot/toolchain/gdb/Config.in.254
-rw-r--r--cleopatre/buildroot/toolchain/gdb/gdb.mk255
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/100-uclibc-conf.patch94
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/200-uclibc-readline-conf.patch16
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-coredump.patch-2.4.23-2930
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-nptl-support.patch143
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/500-thread-timeout.patch34
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/680-debian_sim-destdir.patch14
-rw-r--r--cleopatre/buildroot/toolchain/gdb/snapshot/690-debian_member-field-symtab.patch20
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/Config.in138
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.20.4-ipmisensors-20070314-1214.patch1914
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.21.5-007-ipmisensors-20070314-1214.patch1914
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.1-007-ipmisensors-20070314-1214.patch1914
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.9-007-ipmisensors-20070314-1214.patch1914
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-new.makefile91
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old-versions.makefile103
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old.makefile87
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/kernel-headers.mk48
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.20.4-dwmw2-combined.01.diff460
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-001-add-linkage-header.patch18
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-006-wait-for-async-scanned-block-devices.patch55
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.23-nios2nommu.patch26567
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.25.9-export-linux-aout.patch24
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11-nios2nommu.patch.conditional13527
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0-mips-nptl.patch75
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0.patch18
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-arm-eabi.patch166
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-config-base-small.patch30
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-i2c_msg.patch12
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-mips-nptl.patch90
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.8-cleanup.patch8153
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.9-nios2nommu.patch.conditional12925
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-001-lzma-vmlinuz.00.patch27017
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-002-lzma-vmlinuz.01.patch54
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-001-lzma-vmlinuz.00.patch26856
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-002-lzma-vmlinuz.01.patch54
-rw-r--r--cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-003-lzma-vmlinuz.patch44
-rw-r--r--cleopatre/buildroot/toolchain/mklibs/Config.in5
-rw-r--r--cleopatre/buildroot/toolchain/mklibs/mklibs.mk49
-rw-r--r--cleopatre/buildroot/toolchain/mklibs/mklibs.py597
-rwxr-xr-xcleopatre/buildroot/toolchain/patch-kernel.sh55
-rw-r--r--cleopatre/buildroot/toolchain/sstrip/Config.in9
-rw-r--r--cleopatre/buildroot/toolchain/sstrip/sstrip.c468
-rw-r--r--cleopatre/buildroot/toolchain/sstrip/sstrip.mk70
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/Config.in85
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-001-libext.patch13
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-002-rm-whitespace.patch77
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-arch.patch.avr327650
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-string-ops.patch.powerpc56
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.config179
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-001-fix-mmap.patch91
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-arch.patch.avr323546
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-conditional-sched_affinity.patch53
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-filter-gnu99-from-assembly-flags.patch12
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-fget_putc.diff396
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-gethostent_r-failure-retval.patch12
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-internal_function-definition.patch51
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-sa_onstack.patch.avr3231
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-linuxthreads.patch145
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-rm-whitespace.patch86
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-wchar.config215
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29.config219
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uClibc-snapshot.config201
-rw-r--r--cleopatre/buildroot/toolchain/uClibc/uclibc.mk625
-rwxr-xr-xcleopatre/buildroot/toolchain/wget-show-external-deps.sh6
405 files changed, 262410 insertions, 0 deletions
diff --git a/cleopatre/buildroot/toolchain/Config.in b/cleopatre/buildroot/toolchain/Config.in
new file mode 100644
index 0000000000..7401578709
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/Config.in
@@ -0,0 +1,34 @@
+menu "Toolchain"
+choice
+ prompt "Toolchain type"
+ default BR2_TOOLCHAIN_BUILDROOT if !BR2_avr32
+ default BR2_TOOLCHAIN_EXTERNAL_SOURCE if BR2_avr32
+ help
+ Select whether to use the toolchain provided by buildroot
+ or an external toolchain.
+
+ Some vendors provide toolchains in binary form, some in
+ source form.
+
+config BR2_TOOLCHAIN_BUILDROOT
+ bool "Buildroot toolchain"
+ depends on !BR2_avr32
+
+config BR2_TOOLCHAIN_EXTERNAL
+ bool "External binary toolchain"
+
+config BR2_TOOLCHAIN_EXTERNAL_SOURCE
+ bool "External source toolchain"
+endchoice
+
+config BR2_TOOLCHAIN_SOURCE
+ bool
+ default y if BR2_TOOLCHAIN_BUILDROOT || BR2_TOOLCHAIN_EXTERNAL_SOURCE
+ default n if BR2_TOOLCHAIN_EXTERNAL
+
+source "target/device/Config.in.toolchain"
+
+source "toolchain/Config.in.2"
+source "toolchain/external-toolchain/Config.in"
+
+endmenu
diff --git a/cleopatre/buildroot/toolchain/Config.in.2 b/cleopatre/buildroot/toolchain/Config.in.2
new file mode 100644
index 0000000000..d00faab400
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/Config.in.2
@@ -0,0 +1,76 @@
+#
+
+source "toolchain/kernel-headers/Config.in"
+
+if BR2_TOOLCHAIN_SOURCE
+source "toolchain/uClibc/Config.in"
+source "toolchain/binutils/Config.in"
+source "toolchain/gcc/Config.in"
+source "toolchain/ccache/Config.in"
+source "toolchain/gdb/Config.in"
+
+comment "Common Toolchain Options"
+
+source "toolchain/elf2flt/Config.in"
+source "toolchain/mklibs/Config.in"
+source "toolchain/sstrip/Config.in"
+
+config BR2_ENABLE_MULTILIB
+ bool "Enable multilib support?"
+ help
+ Build libraries to support different ABIs.
+
+config BR2_LARGEFILE
+ bool "Enable large file (files > 2 GB) support?"
+ depends on !BR2_cris
+ help
+ Enable large file (files > 2 GB) support
+
+config BR2_INET_IPV6
+ bool "Enable IPv6"
+ help
+ Enable IPv6.
+
+config BR2_INET_RPC
+ bool "Enable RPC"
+ help
+ Enable RPC. RPC support is needed for nfs.
+
+config BR2_USE_WCHAR
+ bool "Enable WCHAR support"
+ help
+ Enable WCHAR. WCHAR support is needed for several packages
+
+config BR2_SOFT_FLOAT
+ bool "Use software floating point by default"
+ depends on BR2_arm || BR2_armeb || BR2_avr32 || BR2_mips || BR2_mipsel || BR2_powerpc || BR2_nios2
+ help
+ If your target CPU does not have a Floating Point Unit (FPU) or a
+ kernel FPU emulator, but you still wish to support floating point
+ functions, then everything will need to be compiled with soft
+ floating point support (-msoft-float).
+
+ Most people will answer N.
+
+#config BR2_SOFT_FLOAT_FP
+# bool "Use softfp"
+
+config BR2_TARGET_OPTIMIZATION
+ string "Target Optimizations"
+ default "-Os -pipe"
+ help
+ Optimizations to use when building for the target host.
+
+config BR2_CROSS_TOOLCHAIN_TARGET_UTILS
+ bool "Include target utils in cross toolchain"
+ default y
+ help
+ When using buildroot to build a deployable cross toolchain,
+ it is handy to include certain target apps with that toolchain
+ as a convenience.
+ Examples include ldd, gdbserver, and strace.
+
+ Answer Y if you want these apps (if built) copied into the
+ cross toolchain dir under <arch>-linux-uclibc/target_utils/.
+
+endif
diff --git a/cleopatre/buildroot/toolchain/Makefile.in b/cleopatre/buildroot/toolchain/Makefile.in
new file mode 100644
index 0000000000..bdabde9adb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/Makefile.in
@@ -0,0 +1,49 @@
+ifeq ($(BR2_PTHREADS_NONE),y)
+THREADS:=--disable-threads
+else
+THREADS:=--enable-threads
+endif
+
+ifeq ($(BR2_ENABLE_MULTILIB),y)
+MULTILIB:=--enable-multilib
+else
+MULTILIB:=--disable-multilib
+endif
+
+ifeq ($(BR2_ENABLE_OPENMP),y)
+OPENMP:=--enable-openmp
+else
+OPENMP:=--disable-openmp
+endif
+
+
+ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
+BR2_SYSROOT_PREFIX=# nothing, straight into /usr
+BR2_SYSROOT_STAGING_DESTDIR=DESTDIR=$(STAGING_DIR)/
+BR2_SYSROOT_TARGET_DESTDIR=DESTDIR=$(TARGET_DIR)/
+BR2_CONFIGURE_DEVEL_SYSROOT=--with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/
+BR2_CONFIGURE_STAGING_SYSROOT=--with-sysroot=$(STAGING_DIR)
+BR2_CONFIGURE_BUILD_TOOLS=--with-build-time-tools=$(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin
+BR2_SYSROOT=--sysroot=$(STAGING_DIR)/
+BR2_ISYSROOT=-isysroot $(STAGING_DIR)
+else
+BR2_SYSROOT_PREFIX=$(STAGING_DIR)
+BR2_SYSROOT_STAGING_DESTDIR=# nothing
+BR2_SYSROOT_TARGET_DESTDIR=# nothing
+BR2_CONFIGURE_DEVEL_SYSROOT=--with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/
+BR2_CONFIGURE_STAGING_SYSROOT=# nothing
+BR2_CONFIGURE_BUILD_TOOLS=# nothing
+BR2_SYSROOT=# nothing
+BR2_ISYSROOT=#nothing
+endif
+
+# FIXME -- this is temporary
+OPTIMIZE_FOR_CPU=$(ARCH)
+
+# late binding check to see if the target cc supports -fwhole-program
+CFLAGS_WHOLE_PROGRAM = $(call cc-option,-fwhole-program,)
+CFLAGS_COMBINE = $(call cc-option,-combine,)
+
+# gcc has a bunch of needed stuff....
+include toolchain/gcc/Makefile.in
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/001-debian.patch b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/001-debian.patch
new file mode 100644
index 0000000000..780823542a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/001-debian.patch
@@ -0,0 +1,142 @@
+diff -urN binutils-2.14.90.0.8-dist/bfd/elf64-alpha.c binutils-2.14.90.0.8/bfd/elf64-alpha.c
+--- binutils-2.14.90.0.8-dist/bfd/elf64-alpha.c 2004-01-14 15:07:43.000000000 -0600
++++ binutils-2.14.90.0.8/bfd/elf64-alpha.c 2004-02-11 03:42:05.000000000 -0600
+@@ -4144,9 +4144,12 @@
+
+ loc = srel->contents;
+ loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+- bfd_elf64_swap_reloca_out (abfd, &outrel, loc);
+- BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
+- <= srel->_cooked_size);
++ if (loc)
++ {
++ bfd_elf64_swap_reloca_out (abfd, &outrel, loc);
++ BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
++ <= srel->_cooked_size);
++ }
+ }
+
+ /* Relocate an Alpha ELF section for a relocatable link.
+diff -urN binutils-2.14.90.0.8-dist/bfd/opncls.c binutils-2.14.90.0.8/bfd/opncls.c
+--- binutils-2.14.90.0.8-dist/bfd/opncls.c 2004-01-14 15:07:43.000000000 -0600
++++ binutils-2.14.90.0.8/bfd/opncls.c 2004-02-11 03:42:01.000000000 -0600
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+diff -urN binutils-2.14.90.0.8-dist/gprof/gprof.texi binutils-2.14.90.0.8/gprof/gprof.texi
+--- binutils-2.14.90.0.8-dist/gprof/gprof.texi 2004-01-14 15:07:51.000000000 -0600
++++ binutils-2.14.90.0.8/gprof/gprof.texi 2004-02-11 03:42:01.000000000 -0600
+@@ -138,6 +138,10 @@
+ If more than one profile file is specified, the @code{gprof}
+ output shows the sum of the profile information in the given profile files.
+
++If you use gcc 2.95.x or 3.0 to compile your binaries, you may need
++to add the @samp{-fprofile-arcs} to the compile command line in order
++for the call graphs to be properly stored in gmon.out.
++
+ @code{Gprof} calculates the amount of time spent in each routine.
+ Next, these times are propagated along the edges of the call graph.
+ Cycles are discovered, and calls into a cycle are made to share the time
+@@ -182,7 +186,7 @@
+ @c man end
+
+ @c man begin SEEALSO
+-monitor(3), profil(2), cc(1), prof(1), and the Info entry for @file{gprof}.
++profil(2), cc(1), prof(1), and the Info entry for @file{gprof}.
+
+ ``An Execution Profiler for Modular Programs'',
+ by S. Graham, P. Kessler, M. McKusick;
+@@ -268,6 +272,11 @@
+ options. The same option, @samp{-pg}, alters either compilation or linking
+ to do what is necessary for profiling. Here are examples:
+
++If you use gcc 2.95.x or 3.0.x, you may need to add the
++@samp{-fprofile-arcs} option to the compile line along with @samp{-pg}
++in order to allow the call-graphs to be properly included in the gmon.out
++file.
++
+ @example
+ cc -g -c myprog.c utils.c -pg
+ cc -o myprog myprog.o utils.o -pg
+diff -urN binutils-2.14.90.0.8-dist/ld/Makefile.am binutils-2.14.90.0.8/ld/Makefile.am
+--- binutils-2.14.90.0.8-dist/ld/Makefile.am 2004-01-14 15:07:52.000000000 -0600
++++ binutils-2.14.90.0.8/ld/Makefile.am 2004-02-11 03:42:01.000000000 -0600
+@@ -19,7 +19,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -urN binutils-2.14.90.0.8-dist/ld/Makefile.in binutils-2.14.90.0.8/ld/Makefile.in
+--- binutils-2.14.90.0.8-dist/ld/Makefile.in 2004-01-14 15:07:52.000000000 -0600
++++ binutils-2.14.90.0.8/ld/Makefile.in 2004-02-11 03:42:01.000000000 -0600
+@@ -128,7 +128,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -urN binutils-2.14.90.0.8-dist/ld/emultempl/elf32.em binutils-2.14.90.0.8/ld/emultempl/elf32.em
+--- binutils-2.14.90.0.8-dist/ld/emultempl/elf32.em 2004-01-14 15:07:53.000000000 -0600
++++ binutils-2.14.90.0.8/ld/emultempl/elf32.em 2004-02-11 03:42:01.000000000 -0600
+@@ -671,6 +671,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, l->name,
+ force))
+ break;
+@@ -850,6 +852,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf${ELFSIZE}_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
+diff -urN binutils-2.14.90.0.8-dist/ltmain.sh binutils-2.14.90.0.8/ltmain.sh
+--- binutils-2.14.90.0.8-dist/ltmain.sh 2002-03-22 16:06:16.000000000 -0600
++++ binutils-2.14.90.0.8/ltmain.sh 2004-02-11 03:42:05.000000000 -0600
+@@ -4413,6 +4413,10 @@
+ # LD_LIBRARY_PATH before the program is installed.
+ $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+ $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
++ if test -n "$linkname"; then
++ $show "(cd $output_objdir && $rm ../$linkname && $LN_S $output_objdir/$linkname ../$linkname)"
++ $run eval '(cd $output_objdir && $rm ../$linkname && $LN_S $output_objdir/$linkname ../$linkname)' || exit $?
++ fi
+ ;;
+ esac
+ exit 0
+diff -urN binutils-2.14.90.0.8-dist/opcodes/i386-dis.c binutils-2.14.90.0.8/opcodes/i386-dis.c
+--- binutils-2.14.90.0.8-dist/opcodes/i386-dis.c 2004-01-14 15:07:55.000000000 -0600
++++ binutils-2.14.90.0.8/opcodes/i386-dis.c 2004-02-11 03:42:01.000000000 -0600
+@@ -1879,7 +1879,7 @@
+ * The function returns the length of this instruction in bytes.
+ */
+
+-static char intel_syntax;
++static signed char intel_syntax;
+ static char open_char;
+ static char close_char;
+ static char separator_char;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/100-uclibc-conf.patch
new file mode 100644
index 0000000000..60725a3711
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/100-uclibc-conf.patch
@@ -0,0 +1,608 @@
+diff -urN binutils-2.14.90.0.8-001-debian/bfd/config.bfd binutils-2.14.90.0.8/bfd/config.bfd
+--- binutils-2.14.90.0.8-001-debian/bfd/config.bfd 2004-01-14 15:07:43.000000000 -0600
++++ binutils-2.14.90.0.8/bfd/config.bfd 2004-02-12 14:18:14.000000000 -0600
+@@ -121,7 +121,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -131,7 +131,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-linux-uclibc* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -208,7 +208,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-gnu* | arm*b-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -216,8 +216,8 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
+- arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks)
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-linux-uclibc* | \
++ arm*-*-conix* | arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+@@ -350,7 +350,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -361,7 +361,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu* | hppa*-*-netbsd*)
++ hppa*-*-linux-gnu* | hppa*-*-linux-uclibc* | hppa*-*-netbsd*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -483,7 +483,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -497,7 +497,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -672,7 +672,7 @@
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68klinux_vec
+ ;;
+@@ -952,7 +952,8 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
++ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-linux-uclibc* | \
++ powerpc-*-rtems* | \
+ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+@@ -984,8 +985,8 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
+- powerpcle-*-rtems*)
++ powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-linux-uclibc* |\
++ powerpcle-*-vxworks* | powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
+@@ -1141,7 +1142,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-gnu* | sparc-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1188,7 +1189,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+diff -urN binutils-2.14.90.0.8-001-debian/bfd/configure binutils-2.14.90.0.8/bfd/configure
+--- binutils-2.14.90.0.8-001-debian/bfd/configure 2004-01-14 15:07:43.000000000 -0600
++++ binutils-2.14.90.0.8/bfd/configure 2004-02-12 14:09:10.000000000 -0600
+@@ -1699,6 +1699,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5278,7 +5283,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -5338,7 +5343,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -5388,7 +5393,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+diff -urN binutils-2.14.90.0.8-001-debian/bfd/configure.in binutils-2.14.90.0.8/bfd/configure.in
+--- binutils-2.14.90.0.8-001-debian/bfd/configure.in 2004-01-14 15:07:43.000000000 -0600
++++ binutils-2.14.90.0.8/bfd/configure.in 2004-02-12 14:09:10.000000000 -0600
+@@ -178,7 +178,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -259,7 +259,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -312,7 +312,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+diff -urN binutils-2.14.90.0.8-001-debian/configure binutils-2.14.90.0.8/configure
+--- binutils-2.14.90.0.8-001-debian/configure 2004-01-14 15:07:42.000000000 -0600
++++ binutils-2.14.90.0.8/configure 2004-02-12 14:09:10.000000000 -0600
+@@ -1273,6 +1273,18 @@
+ i[3456789]86-*-freebsd* | i[3456789]86-*-kfreebsd*-gnu)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
++ i[3456789]86-*-linux-uclibc)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[3456789]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -urN binutils-2.14.90.0.8-001-debian/configure.in binutils-2.14.90.0.8/configure.in
+--- binutils-2.14.90.0.8-001-debian/configure.in 2004-01-14 15:07:42.000000000 -0600
++++ binutils-2.14.90.0.8/configure.in 2004-02-12 14:50:56.000000000 -0600
+@@ -512,6 +512,18 @@
+ i[[3456789]]86-*-freebsd* | i[[3456789]]86-*-kfreebsd*-gnu)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
++ i[[3456789]]86-*-linux-uclibc)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[[3456789]]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -urN binutils-2.14.90.0.8-001-debian/gas/configure binutils-2.14.90.0.8/gas/configure
+--- binutils-2.14.90.0.8-001-debian/gas/configure 2004-01-14 15:07:45.000000000 -0600
++++ binutils-2.14.90.0.8/gas/configure 2004-02-12 14:57:43.000000000 -0600
+@@ -3215,6 +3215,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -4030,6 +4035,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -4046,6 +4052,7 @@
+ arm*-*-conix*) fmt=elf ;;
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -4059,6 +4066,7 @@
+ avr-*-*) fmt=elf ;;
+
+ cris-*-linux-gnu*) fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-*) fmt=multi bfd_gas=yes ;;
+
+ d10v-*-*) fmt=elf ;;
+@@ -4115,7 +4123,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=coff em=lynx ;;
+ i386-*-sysv[45]*) fmt=elf ;;
+ i386-*-solaris*) fmt=elf ;;
+@@ -4175,6 +4185,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -4202,6 +4213,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -4265,6 +4277,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -4292,7 +4305,9 @@
+ ppc-*-kaos*) fmt=elf ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+ case ${cpu} in
+@@ -4325,6 +4340,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -urN binutils-2.14.90.0.8-001-debian/gas/configure.in binutils-2.14.90.0.8/gas/configure.in
+--- binutils-2.14.90.0.8-001-debian/gas/configure.in 2004-01-14 15:07:45.000000000 -0600
++++ binutils-2.14.90.0.8/gas/configure.in 2004-02-12 14:21:06.000000000 -0600
+@@ -194,6 +194,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -210,6 +211,7 @@
+ arm*-*-conix*) fmt=elf ;;
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -223,6 +225,7 @@
+ avr-*-*) fmt=elf ;;
+
+ cris-*-linux-gnu*) fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-*) fmt=multi bfd_gas=yes ;;
+
+ d10v-*-*) fmt=elf ;;
+@@ -279,7 +282,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=coff em=lynx ;;
+ changequote(,)dnl
+ i386-*-sysv[45]*) fmt=elf ;;
+@@ -332,6 +337,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -359,6 +365,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -419,6 +426,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -439,7 +447,9 @@
+ ppc-*-kaos*) fmt=elf ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+ case ${cpu} in
+@@ -472,6 +482,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -urN binutils-2.14.90.0.8-001-debian/ld/configure binutils-2.14.90.0.8/ld/configure
+--- binutils-2.14.90.0.8-001-debian/ld/configure 2003-05-05 16:46:49.000000000 -0500
++++ binutils-2.14.90.0.8/ld/configure 2004-02-12 14:09:10.000000000 -0600
+@@ -1578,6 +1578,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.14.90.0.8-001-debian/ld/configure.tgt binutils-2.14.90.0.8/ld/configure.tgt
+--- binutils-2.14.90.0.8-001-debian/ld/configure.tgt 2004-01-14 15:07:52.000000000 -0600
++++ binutils-2.14.90.0.8/ld/configure.tgt 2004-02-12 14:14:12.000000000 -0600
+@@ -30,6 +30,7 @@
+ targ_extra_emuls="criself crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ cris-*-linux-gnu*) targ_emul=crislinux ;;
++cris-*-linux-uclibc*) targ_emul=crislinux ;;
+ cris-*-*) targ_emul=criself
+ targ_extra_emuls="crisaout crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+@@ -59,14 +60,16 @@
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'`
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc64-*-linux-gnu*) targ_emul=elf64_sparc
++sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*) \
++ targ_emul=elf64_sparc
+ targ_extra_emuls="elf32_sparc sparclinux sun4"
+ targ_extra_libpath=elf32_sparc
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+ tdir_sparclinux=${tdir_elf32_sparc}aout
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc*-*-linux-gnu*) targ_emul=elf32_sparc
++sparc*-*-linux-gnu* | sparc*-*-linux-uclibc*) \
++ targ_emul=elf32_sparc
+ targ_extra_emuls="sparclinux elf64_sparc sun4"
+ targ_extra_libpath=elf64_sparc
+ tdir_sparclinux=${targ_alias}aout
+@@ -128,7 +131,7 @@
+ m68*-ericsson-ose) targ_emul=sun3 ;;
+ m68*-apple-aux*) targ_emul=m68kaux ;;
+ *-tandem-none) targ_emul=st2000 ;;
+-i370-*-elf* | i370-*-linux-gnu*) targ_emul=elf32i370 ;;
++i370-*-elf* | i370-*-linux-gnu* | i370-*-linux-uclibc*) targ_emul=elf32i370 ;;
+ i[3-7]86-*-nto-qnx*) targ_emul=i386nto ;;
+ i[3-7]86-*-vsta) targ_emul=vsta ;;
+ i[3-7]86-go32-rtems*) targ_emul=i386go32 ;;
+@@ -152,14 +155,16 @@
+ tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+ i[3-7]86-*-linux*oldld) targ_emul=i386linux; targ_extra_emuls=elf_i386 ;;
+-i[3-7]86-*-linux-gnu*) targ_emul=elf_i386
++i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*) \
++ targ_emul=elf_i386
+ targ_extra_emuls=i386linux
+ if test x${want64} = xtrue; then
+ targ_extra_emuls="$targ_extra_emuls elf_x86_64"
+ fi
+ tdir_i386linux=${targ_alias}aout
+ ;;
+-x86_64-*-linux-gnu*) targ_emul=elf_x86_64
++x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*) \
++ targ_emul=elf_x86_64
+ targ_extra_emuls="elf_i386 i386linux"
+ targ_extra_libpath=elf_i386
+ tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
+@@ -259,10 +264,13 @@
+ arm9e-*-elf) targ_emul=armelf ;;
+ arm-*-oabi) targ_emul=armelf_oabi ;;
+ arm*b-*-linux-gnu*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
++arm*b-*-linux-uclibc*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
+ arm*-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++arm*-*-linux-uclibc*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-conix*) targ_emul=armelf ;;
+-thumb-*-linux-gnu* | thumb-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++thumb-*-linux-gnu* | thumb-*-linux-uclibc* | thumb-*-uclinux*) \
++ targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ strongarm-*-coff) targ_emul=armcoff ;;
+ strongarm-*-elf) targ_emul=armelf ;;
+ strongarm-*-kaos*) targ_emul=armelf ;;
+@@ -363,7 +371,8 @@
+ targ_extra_emuls=m68kelf
+ tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+-m68k-*-linux-gnu*) targ_emul=m68kelf
++m68k-*-linux-gnu* | m68k-*-linux-uclibc*) \
++ targ_emul=m68kelf
+ targ_extra_emuls=m68klinux
+ tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'`
+ ;;
+@@ -380,9 +389,9 @@
+ m68*-*-psos*) targ_emul=m68kpsos ;;
+ m68*-*-rtemscoff*) targ_emul=m68kcoff ;;
+ m68*-*-rtems*) targ_emul=m68kelf ;;
+-hppa*64*-*-linux-gnu*) targ_emul=hppa64linux ;;
++hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*) targ_emul=hppa64linux ;;
+ hppa*64*-*) targ_emul=elf64hppa ;;
+-hppa*-*-linux-gnu*) targ_emul=hppalinux ;;
++hppa*-*-linux-gnu* | hppa*-*-linux-uclibc*) targ_emul=hppalinux ;;
+ hppa*-*-*elf*) targ_emul=hppaelf ;;
+ hppa*-*-lites*) targ_emul=hppaelf ;;
+ hppa*-*-netbsd*) targ_emul=hppanbsd ;;
+@@ -429,16 +438,20 @@
+ mips*-*-vxworks*) targ_emul=elf32ebmip
+ targ_extra_emuls="elf32elmip" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-gnu*) targ_emul=elf32ltsmipn32
++mips64*el-*-linux-gnu* | mips64*el-*-linux-uclibc*) \
++ targ_emul=elf32ltsmipn32
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
+ ;;
+-mips64*-*-linux-gnu*) targ_emul=elf32btsmipn32
++mips64*-*-linux-gnu* | mips64*-*-linux-uclibc*) \
++ targ_emul=elf32btsmipn32
+ targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
+ ;;
+-mips*el-*-linux-gnu*) targ_emul=elf32ltsmip
++mips*el-*-linux-gnu* | mips*el-*-linux-uclibc*) \
++ targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
+ ;;
+-mips*-*-linux-gnu*) targ_emul=elf32btsmip
++mips*-*-linux-gnu* | mips*-*-linux-uclibc*) \
++ targ_emul=elf32btsmip
+ targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
+ ;;
+ mips*-*-lnews*) targ_emul=mipslnews ;;
+@@ -461,6 +474,10 @@
+ alpha*-*-linux-gnu*) targ_emul=elf64alpha targ_extra_emuls=alpha
+ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
+ ;;
++alpha*-*-linux-uclibc*) targ_emul=elf64alpha targ_extra_emuls=alpha
++ # The following needs to be checked...
++ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
++ ;;
+ alpha*-*-osf*) targ_emul=alpha ;;
+ alpha*-*-gnu*) targ_emul=elf64alpha ;;
+ alpha*-*-netware*) targ_emul=alpha ;;
+diff -urN binutils-2.14.90.0.8-001-debian/libtool.m4 binutils-2.14.90.0.8/libtool.m4
+--- binutils-2.14.90.0.8-001-debian/libtool.m4 2003-05-05 16:46:46.000000000 -0500
++++ binutils-2.14.90.0.8/libtool.m4 2004-02-12 14:09:10.000000000 -0600
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -urN binutils-2.14.90.0.8-001-debian/ltconfig binutils-2.14.90.0.8/ltconfig
+--- binutils-2.14.90.0.8-001-debian/ltconfig 2004-01-14 15:07:42.000000000 -0600
++++ binutils-2.14.90.0.8/ltconfig 2004-02-12 14:09:10.000000000 -0600
+@@ -603,6 +603,7 @@
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+ linux-gnu*) ;;
++linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1259,6 +1260,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/210-cflags.patch b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/210-cflags.patch
new file mode 100644
index 0000000000..dc67d3c4e3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/210-cflags.patch
@@ -0,0 +1,32 @@
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.am binutils-2.14.90.0.6.new/bfd/doc/Makefile.am
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.am 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.am 2004-03-01 16:05:16.000000000 -0600
+@@ -55,10 +55,10 @@
+ MKDOC = chew$(EXEEXT_FOR_BUILD)
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.in binutils-2.14.90.0.6.new/bfd/doc/Makefile.in
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.in 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.in 2004-03-01 16:05:03.000000000 -0600
+@@ -469,10 +469,10 @@
+
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..e07a7e8cea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1611,7 +1611,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -1976,7 +1976,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/600-arm-textrel.patch b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/600-arm-textrel.patch
new file mode 100644
index 0000000000..73d5b9df8e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.14.90.0.8/600-arm-textrel.patch
@@ -0,0 +1,63 @@
+http://sources.redhat.com/ml/binutils/2004-06/msg00010.html
+--- binutils-2.15.90.0.3-old/bfd/elf32-arm.h 2004-04-12 14:56:33.000000000 -0500
++++ binutils-2.15.90.0.3/bfd/elf32-arm.h 2004-09-03 06:56:40.000000000 -0500
+@@ -87,6 +87,8 @@
+ #endif
+ static bfd_boolean allocate_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *h, PTR inf));
++static bfd_boolean elf32_arm_readonly_dynrelocs
++ PARAMS ((struct elf_link_hash_entry *, PTR));
+ static bfd_boolean create_got_section
+ PARAMS ((bfd * dynobj, struct bfd_link_info * info));
+ static bfd_boolean elf32_arm_create_dynamic_sections
+@@ -3531,6 +3533,37 @@
+ return TRUE;
+ }
+
++/* Find any dynamic relocs that apply to read-only sections. */
++
++static bfd_boolean
++elf32_arm_readonly_dynrelocs (h, inf)
++ struct elf_link_hash_entry *h;
++ PTR inf;
++{
++ struct elf32_arm_link_hash_entry *eh;
++ struct elf32_arm_relocs_copied *p;
++
++ if (h->root.type == bfd_link_hash_warning)
++ h = (struct elf_link_hash_entry *) h->root.u.i.link;
++
++ eh = (struct elf32_arm_link_hash_entry *) h;
++ for (p = eh->relocs_copied; p != NULL; p = p->next)
++ {
++ asection *s = p->section;
++
++ if (s != NULL && (s->flags & SEC_READONLY) != 0)
++ {
++ struct bfd_link_info *info = (struct bfd_link_info *) inf;
++
++ info->flags |= DF_TEXTREL;
++
++ /* Not an error, just cut short the traversal. */
++ return FALSE;
++ }
++ }
++ return TRUE;
++}
++
+ /* Set the sizes of the dynamic sections. */
+
+ static bfd_boolean
+@@ -3740,6 +3773,12 @@
+ return FALSE;
+ }
+
++ /* If any dynamic relocs apply to a read-only section,
++ then we need a DT_TEXTREL entry. */
++ if ((info->flags & DF_TEXTREL) == 0)
++ elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
++ (PTR) info);
++
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/100-uclibc-conf.patch
new file mode 100644
index 0000000000..dc21386f42
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/100-uclibc-conf.patch
@@ -0,0 +1,749 @@
+diff -ur binutils-2.15.94.0.2.orig/bfd/config.bfd binutils-2.15.94.0.2/bfd/config.bfd
+--- binutils-2.15.94.0.2.orig/bfd/config.bfd 2004-12-22 15:00:57.219024360 -0500
++++ binutils-2.15.94.0.2/bfd/config.bfd 2004-12-22 15:01:18.982715776 -0500
+@@ -140,7 +140,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -150,7 +150,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-linux-uclibc* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -227,7 +227,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-gnu* | arm*b-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -235,8 +235,8 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
+- arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks | \
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-linux-uclibc* | \
++ arm*-*-conix* | arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks | \
+ arm*-*-eabi* )
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+@@ -381,7 +381,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -392,7 +392,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu*)
++ hppa*-*-linux-gnu* | hppa*-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -525,7 +525,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -539,7 +539,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -715,7 +715,7 @@
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68klinux_vec
+ ;;
+@@ -1001,7 +1001,8 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
++ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-linux-uclibc* | \
++ powerpc-*-rtems* | \
+ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+@@ -1038,8 +1039,8 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
+- powerpcle-*-rtems*)
++ powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-linux-uclibc* |\
++ powerpcle-*-vxworks* | powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
+@@ -1209,7 +1210,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-gnu* | sparc-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1256,7 +1257,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+@@ -1325,7 +1326,7 @@
+ targ_underscore=yes
+ ;;
+
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_vax_vec
+ ;;
+
+diff -ur binutils-2.15.94.0.2.orig/bfd/configure binutils-2.15.94.0.2/bfd/configure
+--- binutils-2.15.94.0.2.orig/bfd/configure 2004-12-22 15:00:57.221024056 -0500
++++ binutils-2.15.94.0.2/bfd/configure 2004-12-22 15:01:18.996713648 -0500
+@@ -3583,6 +3583,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -9914,7 +9919,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -9978,7 +9983,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -10016,7 +10021,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -10150,7 +10155,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -ur binutils-2.15.94.0.2.orig/bfd/configure.in binutils-2.15.94.0.2/bfd/configure.in
+--- binutils-2.15.94.0.2.orig/bfd/configure.in 2004-12-22 15:00:57.223023752 -0500
++++ binutils-2.15.94.0.2/bfd/configure.in 2004-12-22 15:01:18.998713344 -0500
+@@ -163,7 +163,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -248,7 +248,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -289,7 +289,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -375,7 +375,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -ur binutils-2.15.94.0.2.orig/binutils/configure binutils-2.15.94.0.2/binutils/configure
+--- binutils-2.15.94.0.2.orig/binutils/configure 2004-12-22 15:00:57.351004296 -0500
++++ binutils-2.15.94.0.2/binutils/configure 2004-12-22 15:01:19.002712736 -0500
+@@ -1575,6 +1575,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -ur binutils-2.15.94.0.2.orig/configure binutils-2.15.94.0.2/configure
+--- binutils-2.15.94.0.2.orig/configure 2004-12-22 15:00:57.321008856 -0500
++++ binutils-2.15.94.0.2/configure 2004-12-22 15:01:19.007711976 -0500
+@@ -1352,6 +1352,18 @@
+ i[3456789]86-*-coff | i[3456789]86-*-elf)
+ noconfigdirs="$noconfigdirs ${libgcj}"
+ ;;
++ i[3456789]86-*-linux-uclibc*)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[3456789]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -ur binutils-2.15.94.0.2.orig/configure.in binutils-2.15.94.0.2/configure.in
+--- binutils-2.15.94.0.2.orig/configure.in 2004-12-22 15:00:57.321008856 -0500
++++ binutils-2.15.94.0.2/configure.in 2004-12-22 15:01:19.010711520 -0500
+@@ -561,6 +561,18 @@
+ i[[3456789]]86-*-coff | i[[3456789]]86-*-elf)
+ noconfigdirs="$noconfigdirs ${libgcj}"
+ ;;
++ i[[3456789]]86-*-linux-uclibc*)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[[3456789]]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -ur binutils-2.15.94.0.2.orig/gas/configure binutils-2.15.94.0.2/gas/configure
+--- binutils-2.15.94.0.2.orig/gas/configure 2004-12-22 15:00:57.461987424 -0500
++++ binutils-2.15.94.0.2/gas/configure 2004-12-22 15:01:19.019710152 -0500
+@@ -3420,6 +3420,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -4256,6 +4261,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -4272,6 +4278,7 @@
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnueabi*) fmt=elf em=armlinuxeabi ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -4285,6 +4292,7 @@
+
+ cris-*-linux-gnu* | crisv32-*-linux-gnu*)
+ fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-* | crisv32-*-*) fmt=multi bfd_gas=yes ;;
+
+ crx-*-elf*) fmt=elf ;;
+@@ -4344,7 +4352,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+ i386-*-sysv[45]*) fmt=elf ;;
+ i386-*-solaris*) fmt=elf ;;
+@@ -4404,6 +4414,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -4431,6 +4442,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -4505,6 +4517,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -4532,7 +4545,9 @@
+ ppc-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-tpf*) fmt=elf ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+@@ -4568,6 +4583,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -ur binutils-2.15.94.0.2.orig/gas/configure.in binutils-2.15.94.0.2/gas/configure.in
+--- binutils-2.15.94.0.2.orig/gas/configure.in 2004-12-22 15:00:57.461987424 -0500
++++ binutils-2.15.94.0.2/gas/configure.in 2004-12-22 15:01:19.022709696 -0500
+@@ -202,6 +202,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -218,6 +219,7 @@
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnueabi*) fmt=elf em=armlinuxeabi ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -231,6 +233,7 @@
+
+ cris-*-linux-gnu* | crisv32-*-linux-gnu*)
+ fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-* | crisv32-*-*) fmt=multi bfd_gas=yes ;;
+
+ crx-*-elf*) fmt=elf ;;
+@@ -290,7 +293,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+ changequote(,)dnl
+ i386-*-sysv[45]*) fmt=elf ;;
+@@ -343,6 +348,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -370,6 +376,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -441,6 +448,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -461,7 +469,9 @@
+ ppc-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-tpf*) fmt=elf ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+@@ -493,6 +503,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -ur binutils-2.15.94.0.2.orig/gprof/configure binutils-2.15.94.0.2/gprof/configure
+--- binutils-2.15.94.0.2.orig/gprof/configure 2004-12-22 15:00:57.949913248 -0500
++++ binutils-2.15.94.0.2/gprof/configure 2004-12-22 15:01:19.030708480 -0500
+@@ -3418,6 +3418,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -ur binutils-2.15.94.0.2.orig/ld/configure binutils-2.15.94.0.2/ld/configure
+--- binutils-2.15.94.0.2.orig/ld/configure 2004-12-22 15:00:58.032900632 -0500
++++ binutils-2.15.94.0.2/ld/configure 2004-12-22 15:01:19.035707720 -0500
+@@ -1579,6 +1579,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -ur binutils-2.15.94.0.2.orig/ld/configure.tgt binutils-2.15.94.0.2/ld/configure.tgt
+--- binutils-2.15.94.0.2.orig/ld/configure.tgt 2004-12-22 15:00:58.033900480 -0500
++++ binutils-2.15.94.0.2/ld/configure.tgt 2004-12-22 15:01:19.036707568 -0500
+@@ -32,6 +32,7 @@
+ targ_extra_libpath=$targ_extra_emuls ;;
+ cris-*-linux-gnu* | cris-*-linux-gnu*)
+ targ_emul=crislinux ;;
++cris-*-linux-uclibc*) targ_emul=crislinux ;;
+ cris-*-* | crisv32-*-*) targ_emul=criself
+ targ_extra_emuls="crisaout crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+@@ -62,14 +63,16 @@
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'`
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc64-*-linux-gnu*) targ_emul=elf64_sparc
++sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*) \
++ targ_emul=elf64_sparc
+ targ_extra_emuls="elf32_sparc sparclinux sun4"
+ targ_extra_libpath=elf32_sparc
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+ tdir_sparclinux=${tdir_elf32_sparc}aout
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc*-*-linux-gnu*) targ_emul=elf32_sparc
++sparc*-*-linux-gnu* | sparc*-*-linux-uclibc*) \
++ targ_emul=elf32_sparc
+ targ_extra_emuls="sparclinux elf64_sparc sun4"
+ targ_extra_libpath=elf64_sparc
+ tdir_sparclinux=${targ_alias}aout
+@@ -121,7 +124,9 @@
+ m32r*le-*-elf*) targ_emul=m32rlelf ;;
+ m32r*-*-elf*) targ_emul=m32relf ;;
+ m32r*le-*-linux-gnu*) targ_emul=m32rlelf_linux ;;
++m32r*le-*-linux-uclibc*) targ_emul=m32rlelf_linux ;;
+ m32r*-*-linux-gnu*) targ_emul=m32relf_linux ;;
++m32r*-*-linux-uclibc*) targ_emul=m32relf_linux ;;
+ m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
+ targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
+ m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
+@@ -132,7 +137,7 @@
+ m68*-apple-aux*) targ_emul=m68kaux ;;
+ maxq-*-coff) targ_emul=maxqcoff;;
+ *-tandem-none) targ_emul=st2000 ;;
+-i370-*-elf* | i370-*-linux-gnu*) targ_emul=elf32i370 ;;
++i370-*-elf* | i370-*-linux-gnu* | i370-*-linux-uclibc*) targ_emul=elf32i370 ;;
+ i[3-7]86-*-nto-qnx*) targ_emul=i386nto ;;
+ i[3-7]86-*-vsta) targ_emul=vsta ;;
+ i[3-7]86-go32-rtems*) targ_emul=i386go32 ;;
+@@ -156,14 +161,16 @@
+ tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+ i[3-7]86-*-linux*oldld) targ_emul=i386linux; targ_extra_emuls=elf_i386 ;;
+-i[3-7]86-*-linux-gnu*) targ_emul=elf_i386
++i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*) \
++ targ_emul=elf_i386
+ targ_extra_emuls=i386linux
+ if test x${want64} = xtrue; then
+ targ_extra_emuls="$targ_extra_emuls elf_x86_64"
+ fi
+ tdir_i386linux=${targ_alias}aout
+ ;;
+-x86_64-*-linux-gnu*) targ_emul=elf_x86_64
++x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*) \
++ targ_emul=elf_x86_64
+ targ_extra_emuls="elf_i386 i386linux"
+ targ_extra_libpath=elf_i386
+ tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
+@@ -263,11 +270,14 @@
+ arm-*-kaos*) targ_emul=armelf ;;
+ arm9e-*-elf) targ_emul=armelf ;;
+ arm*b-*-linux-gnu*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
++arm*b-*-linux-uclibc*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
+ arm*-*-linux-gnueabi) targ_emul=armelf_linux_eabi ;;
+ arm*-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++arm*-*-linux-uclibc*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-conix*) targ_emul=armelf ;;
+-thumb-*-linux-gnu* | thumb-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++thumb-*-linux-gnu* | thumb-*-linux-uclibc* | thumb-*-uclinux*) \
++ targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ strongarm-*-coff) targ_emul=armcoff ;;
+ strongarm-*-elf) targ_emul=armelf ;;
+ strongarm-*-kaos*) targ_emul=armelf ;;
+@@ -371,7 +381,8 @@
+ targ_extra_emuls=m68kelf
+ tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+-m68k-*-linux-gnu*) targ_emul=m68kelf
++m68k-*-linux-gnu* | m68k-*-linux-uclibc*) \
++ targ_emul=m68kelf
+ targ_extra_emuls=m68klinux
+ tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'`
+ ;;
+@@ -388,9 +399,9 @@
+ m68*-*-psos*) targ_emul=m68kpsos ;;
+ m68*-*-rtemscoff*) targ_emul=m68kcoff ;;
+ m68*-*-rtems*) targ_emul=m68kelf ;;
+-hppa*64*-*-linux-gnu*) targ_emul=hppa64linux ;;
++hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*) targ_emul=hppa64linux ;;
+ hppa*64*-*) targ_emul=elf64hppa ;;
+-hppa*-*-linux-gnu*) targ_emul=hppalinux ;;
++hppa*-*-linux-gnu* | hppa*-*-linux-uclibc*) targ_emul=hppalinux ;;
+ hppa*-*-*elf*) targ_emul=hppaelf ;;
+ hppa*-*-lites*) targ_emul=hppaelf ;;
+ hppa*-*-netbsd*) targ_emul=hppanbsd ;;
+@@ -403,6 +414,7 @@
+ targ_emul=vaxnbsd
+ targ_extra_emuls=elf32vax ;;
+ vax-*-linux-gnu*) targ_emul=elf32vax ;;
++vax-*-linux-uclibc*) targ_emul=elf32vax ;;
+ mips*-*-pe) targ_emul=mipspe ;
+ targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+ mips*-dec-ultrix*) targ_emul=mipslit ;;
+@@ -436,16 +448,16 @@
+ mips*-*-vxworks*) targ_emul=elf32ebmip
+ targ_extra_emuls="elf32elmip" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-gnu*) targ_emul=elf32ltsmipn32
++mips64*el-*-linux-gnu* | mips64*el-*-linux-uclibc*) targ_emul=elf32ltsmipn32
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
+ ;;
+-mips64*-*-linux-gnu*) targ_emul=elf32btsmipn32
++mips64*-*-linux-gnu* | mips64*-*-linux-uclibc*) targ_emul=elf32btsmipn32
+ targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
+ ;;
+-mips*el-*-linux-gnu*) targ_emul=elf32ltsmip
++mips*el-*-linux-gnu* | mips*el-*-linux-uclibc*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
+ ;;
+-mips*-*-linux-gnu*) targ_emul=elf32btsmip
++mips*-*-linux-gnu* | mips*-*-linux-uclibc*) targ_emul=elf32btsmip
+ targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
+ ;;
+ mips*-*-lnews*) targ_emul=mipslnews ;;
+@@ -468,6 +480,10 @@
+ alpha*-*-linux-gnu*) targ_emul=elf64alpha targ_extra_emuls=alpha
+ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
+ ;;
++alpha*-*-linux-uclibc*) targ_emul=elf64alpha targ_extra_emuls=alpha
++ # The following needs to be checked...
++ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
++ ;;
+ alpha*-*-osf*) targ_emul=alpha ;;
+ alpha*-*-gnu*) targ_emul=elf64alpha ;;
+ alpha*-*-netware*) targ_emul=alpha ;;
+diff -ur binutils-2.15.94.0.2.orig/ld/emultempl/elf32.em binutils-2.15.94.0.2/ld/emultempl/elf32.em
+--- binutils-2.15.94.0.2.orig/ld/emultempl/elf32.em 2004-12-22 15:00:58.044898808 -0500
++++ binutils-2.15.94.0.2/ld/emultempl/elf32.em 2004-12-22 15:01:19.038707264 -0500
+@@ -65,7 +65,7 @@
+
+ if [ "x${USE_LIBPATH}" = xyes ] ; then
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-gnu* | *-*-linux-uclibc*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ #include <glob.h>
+ EOF
+@@ -337,7 +337,7 @@
+
+ EOF
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-gnu* | *-*-linux-uclibc*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ {
+ struct bfd_link_needed_list *l;
+@@ -510,7 +510,7 @@
+
+ EOF
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-gnu* | *-*-linux-uclibc*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ /* For a native linker, check the file /etc/ld.so.conf for directories
+ in which we may find shared libraries. /etc/ld.so.conf is really
+@@ -894,7 +894,7 @@
+ EOF
+ if [ "x${USE_LIBPATH}" = xyes ] ; then
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-gnu* | *-*-linux-uclibc*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
+ break;
+diff -ur binutils-2.15.94.0.2.orig/libiberty/configure binutils-2.15.94.0.2/libiberty/configure
+--- binutils-2.15.94.0.2.orig/libiberty/configure 2004-12-22 15:00:59.263713520 -0500
++++ binutils-2.15.94.0.2/libiberty/configure 2004-12-22 15:03:55.744884304 -0500
+@@ -3682,6 +3682,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -ur binutils-2.15.94.0.2.orig/libtool.m4 binutils-2.15.94.0.2/libtool.m4
+--- binutils-2.15.94.0.2.orig/libtool.m4 2004-12-22 15:00:57.329007640 -0500
++++ binutils-2.15.94.0.2/libtool.m4 2004-12-22 15:01:19.039707112 -0500
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -ur binutils-2.15.94.0.2.orig/ltconfig binutils-2.15.94.0.2/ltconfig
+--- binutils-2.15.94.0.2.orig/ltconfig 2004-12-22 15:00:57.330007488 -0500
++++ binutils-2.15.94.0.2/ltconfig 2004-12-22 15:01:19.041706808 -0500
+@@ -603,6 +603,7 @@
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+ linux-gnu*) ;;
++linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1271,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -ur binutils-2.15.94.0.2.orig/opcodes/configure binutils-2.15.94.0.2/opcodes/configure
+--- binutils-2.15.94.0.2.orig/opcodes/configure 2004-12-22 15:00:59.334702728 -0500
++++ binutils-2.15.94.0.2/opcodes/configure 2004-12-22 15:01:19.053704984 -0500
+@@ -3587,6 +3587,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/210-cflags.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/210-cflags.patch
new file mode 100644
index 0000000000..dc67d3c4e3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/210-cflags.patch
@@ -0,0 +1,32 @@
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.am binutils-2.14.90.0.6.new/bfd/doc/Makefile.am
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.am 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.am 2004-03-01 16:05:16.000000000 -0600
+@@ -55,10 +55,10 @@
+ MKDOC = chew$(EXEEXT_FOR_BUILD)
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.in binutils-2.14.90.0.6.new/bfd/doc/Makefile.in
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.in 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.in 2004-03-01 16:05:03.000000000 -0600
+@@ -469,10 +469,10 @@
+
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..b25d5b7e21
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-001_ld_makefile_patch.patch
@@ -0,0 +1,52 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am binutils-2.14.90.0.6/ld/Makefile.am
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.am 2003-09-10 23:12:09.000000000 +0100
+@@ -19,7 +19,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in binutils-2.14.90.0.6/ld/Makefile.in
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.in 2003-09-10 23:12:09.000000000 +0100
+@@ -128,7 +128,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-120_mips_xgot_multigot_workaround.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-120_mips_xgot_multigot_workaround.patch
new file mode 100644
index 0000000000..ae2033d069
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/300-120_mips_xgot_multigot_workaround.patch
@@ -0,0 +1,39 @@
+#! /bin/sh -e
+## 120_mips_xgot_multigot_workaround.dpatch
+##
+## DP: Description: Make multigot/xgot handling mutually exclusive.
+## DP: Author: Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
+## DP: Upstream status: Not submitted
+## DP: Date: 2004-09-17
+
+if [ $# -lt 1 ]; then
+ echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+ -patch) patch -p1 ${patch_opts} < $0;;
+ -unpatch) patch -R -p1 ${patch_opts} < $0;;
+ *)
+ echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.15/bfd/elfxx-mips.c binutils-2.15/bfd/elfxx-mips.c
+--- /home/james/debian/packages/binutils/binutils-2.15/bfd/elfxx-mips.c 2004-09-23 22:41:37.156466673 +0100
++++ binutils-2.15/bfd/elfxx-mips.c 2004-09-23 22:42:15.998362861 +0100
+@@ -5883,6 +5883,8 @@
+ s->size += i * MIPS_ELF_GOT_SIZE (output_bfd);
+
+ if (s->size > MIPS_ELF_GOT_MAX_SIZE (output_bfd)
++ && g->global_gotno <= (MIPS_ELF_GOT_MAX_SIZE (output_bfd)
++ / MIPS_ELF_GOT_SIZE (output_bfd))
+ && ! mips_elf_multi_got (output_bfd, info, g, s, local_gotno))
+ return FALSE;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..e07a7e8cea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1611,7 +1611,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -1976,7 +1976,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/sh-flags-off-by-one.patch b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/sh-flags-off-by-one.patch
new file mode 100644
index 0000000000..19a2f54cab
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15.94.0.2.2/sh-flags-off-by-one.patch
@@ -0,0 +1,21 @@
+2005-08-25 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * elf32-sh.c (sh_elf_get_flags_from_mach): Fix off-by-one error.
+
+Index: bfd/elf32-sh.c
+===================================================================
+RCS file: /cvs/src/src/bfd/elf32-sh.c,v
+retrieving revision 1.128
+retrieving revision 1.129
+diff -u -p -r1.128 -r1.129
+--- binutils/bfd/elf32-sh.c 25 Aug 2005 02:32:10 -0000 1.128
++++ binutils/bfd/elf32-sh.c 25 Aug 2005 05:10:22 -0000 1.129
+@@ -6655,7 +6655,7 @@ sh_elf_set_mach_from_flags (bfd *abfd)
+ int
+ sh_elf_get_flags_from_mach (unsigned long mach)
+ {
+- int i = ARRAY_SIZE (sh_ef_bfd_table);
++ int i = ARRAY_SIZE (sh_ef_bfd_table) - 1;
+
+ for (; i>0; i--)
+ if (sh_ef_bfd_table[i] == mach)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.15/100-uclibc-conf.patch
new file mode 100644
index 0000000000..1c7fa4a400
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15/100-uclibc-conf.patch
@@ -0,0 +1,692 @@
+diff -urN binutils-2.15-dist/bfd/config.bfd binutils-2.15/bfd/config.bfd
+--- binutils-2.15-dist/bfd/config.bfd 2004-05-17 14:35:56.000000000 -0500
++++ binutils-2.15/bfd/config.bfd 2004-08-04 12:01:44.000000000 -0500
+@@ -126,7 +126,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -136,7 +136,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-linux-uclibc* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -213,7 +213,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-gnu* | arm*b-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -221,7 +221,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-linux-uclibc* | arm*-*-conix* | \
+ arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+@@ -360,7 +360,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -371,7 +371,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu* | hppa*-*-netbsd*)
++ hppa*-*-linux-gnu* | hppa*-*-linux-uclibc* | hppa*-*-netbsd*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -494,7 +494,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -508,7 +508,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -683,7 +683,7 @@
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68klinux_vec
+ ;;
+@@ -955,7 +955,8 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
++ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-linux-uclibc* | \
++ powerpc-*-rtems* | \
+ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+@@ -987,8 +988,8 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
+- powerpcle-*-rtems*)
++ powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-linux-uclibc* |\
++ powerpcle-*-vxworks* | powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
+@@ -1149,7 +1150,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-gnu* | sparc-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1196,7 +1197,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+@@ -1265,7 +1266,7 @@
+ targ_underscore=yes
+ ;;
+
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_vax_vec
+ ;;
+
+diff -urN binutils-2.15-dist/bfd/configure binutils-2.15/bfd/configure
+--- binutils-2.15-dist/bfd/configure 2004-05-17 14:35:57.000000000 -0500
++++ binutils-2.15/bfd/configure 2004-08-04 12:01:44.000000000 -0500
+@@ -1699,6 +1699,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5278,7 +5283,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -5338,7 +5343,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -5376,7 +5381,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -5477,7 +5482,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -urN binutils-2.15-dist/bfd/configure.in binutils-2.15/bfd/configure.in
+--- binutils-2.15-dist/bfd/configure.in 2004-05-17 14:35:57.000000000 -0500
++++ binutils-2.15/bfd/configure.in 2004-08-04 12:01:44.000000000 -0500
+@@ -178,7 +178,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -259,7 +259,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -300,7 +300,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -385,7 +385,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -urN binutils-2.15-dist/binutils/configure binutils-2.15/binutils/configure
+--- binutils-2.15-dist/binutils/configure 2004-01-02 11:08:04.000000000 -0600
++++ binutils-2.15/binutils/configure 2004-08-04 12:01:44.000000000 -0500
+@@ -1585,6 +1585,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.15-dist/configure binutils-2.15/configure
+--- binutils-2.15-dist/configure 2004-05-17 14:36:20.000000000 -0500
++++ binutils-2.15/configure 2004-08-04 12:01:44.000000000 -0500
+@@ -1288,6 +1288,18 @@
+ i[3456789]86-*-freebsd* | i[3456789]86-*-kfreebsd*-gnu)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
++ i[3456789]86-*-linux-uclibc*)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[3456789]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -urN binutils-2.15-dist/configure.in binutils-2.15/configure.in
+--- binutils-2.15-dist/configure.in 2004-05-17 14:40:54.000000000 -0500
++++ binutils-2.15/configure.in 2004-08-04 12:01:44.000000000 -0500
+@@ -521,6 +521,18 @@
+ i[[3456789]]86-*-freebsd* | i[[3456789]]86-*-kfreebsd*-gnu)
+ noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+ ;;
++ i[[3456789]]86-*-linux-uclibc*)
++ # This section makes it possible to build newlib natively on linux.
++ # If we are using a cross compiler then don't configure newlib.
++ if test x${is_cross_compiler} != xno ; then
++ noconfigdirs="$noconfigdirs target-newlib"
++ fi
++ noconfigdirs="$noconfigdirs target-libgloss"
++ # If we are not using a cross compiler, do configure newlib.
++ # Note however, that newlib will only be configured in this situation
++ # if the --with-newlib option has been given, because otherwise
++ # 'target-newlib' will appear in skipdirs.
++ ;;
+ i[[3456789]]86-*-linux*)
+ # The GCC port for glibc1 has no MD_FALLBACK_FRAME_STATE_FOR, so let's
+ # not build java stuff by default.
+diff -urN binutils-2.15-dist/gas/configure binutils-2.15/gas/configure
+--- binutils-2.15-dist/gas/configure 2004-05-17 14:36:07.000000000 -0500
++++ binutils-2.15/gas/configure 2004-08-04 12:07:50.000000000 -0500
+@@ -3400,6 +3400,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -4224,6 +4229,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -4240,6 +4246,7 @@
+ arm*-*-conix*) fmt=elf ;;
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -4253,6 +4260,7 @@
+ avr-*-*) fmt=elf ;;
+
+ cris-*-linux-gnu*) fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-*) fmt=multi bfd_gas=yes ;;
+
+ d10v-*-*) fmt=elf ;;
+@@ -4310,7 +4318,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=coff em=lynx ;;
+ i386-*-sysv[45]*) fmt=elf ;;
+ i386-*-solaris*) fmt=elf ;;
+@@ -4370,6 +4380,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -4397,6 +4408,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -4459,6 +4471,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -4486,7 +4499,9 @@
+ ppc-*-kaos*) fmt=elf ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+ case ${cpu} in
+@@ -4519,6 +4534,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -urN binutils-2.15-dist/gas/configure.in binutils-2.15/gas/configure.in
+--- binutils-2.15-dist/gas/configure.in 2004-05-17 14:36:07.000000000 -0500
++++ binutils-2.15/gas/configure.in 2004-08-04 12:07:21.000000000 -0500
+@@ -194,6 +194,7 @@
+ alpha*-*-osf*) fmt=ecoff ;;
+ alpha*-*-linuxecoff*) fmt=ecoff ;;
+ alpha*-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha*-*-linux-uclibc*) fmt=elf em=linux ;;
+ alpha*-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha*-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -210,6 +211,7 @@
+ arm*-*-conix*) fmt=elf ;;
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm*-*-linux-gnu*) fmt=elf em=linux ;;
++ arm*-*-linux-uclibc*) fmt=elf em=linux ;;
+ arm*-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -223,6 +225,7 @@
+ avr-*-*) fmt=elf ;;
+
+ cris-*-linux-gnu*) fmt=multi bfd_gas=yes em=linux ;;
++ cris-*-linux-uclibc*) fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-*) fmt=multi bfd_gas=yes ;;
+
+ d10v-*-*) fmt=elf ;;
+@@ -280,7 +283,9 @@
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+ i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-uclibc*) fmt=elf em=linux ;;
+ x86_64-*-linux-gnu*) fmt=elf em=linux ;;
++ x86_64-*-linux-uclibc*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=coff em=lynx ;;
+ changequote(,)dnl
+ i386-*-sysv[45]*) fmt=elf ;;
+@@ -333,6 +338,7 @@
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+ ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-uclibc*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -360,6 +366,7 @@
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+ m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-uclibc*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-lynxos*) fmt=coff em=lynx ;;
+@@ -419,6 +426,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
++ ppc-*-linux-uclibc* | \
+ ppc-*-linux-gnu*) fmt=elf em=linux
+ case "$endian" in
+ big) ;;
+@@ -439,7 +447,9 @@
+ ppc-*-kaos*) fmt=elf ;;
+
+ s390x-*-linux-gnu*) fmt=elf em=linux ;;
++ s390x-*-linux-uclibc*) fmt=elf em=linux ;;
+ s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-uclibc*) fmt=elf em=linux ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+ case ${cpu} in
+@@ -472,6 +482,7 @@
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+ sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-uclibc*) fmt=elf em=linux ;;
+ sparc-*-lynxos*) fmt=coff em=lynx ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+diff -urN binutils-2.15-dist/gprof/configure binutils-2.15/gprof/configure
+--- binutils-2.15-dist/gprof/configure 2003-08-26 12:19:19.000000000 -0500
++++ binutils-2.15/gprof/configure 2004-08-04 12:01:45.000000000 -0500
+@@ -1581,6 +1581,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.15-dist/ld/configure binutils-2.15/ld/configure
+--- binutils-2.15-dist/ld/configure 2003-04-24 07:36:07.000000000 -0500
++++ binutils-2.15/ld/configure 2004-08-04 12:01:45.000000000 -0500
+@@ -1589,6 +1589,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.15-dist/ld/configure.tgt binutils-2.15/ld/configure.tgt
+--- binutils-2.15-dist/ld/configure.tgt 2004-05-17 14:36:15.000000000 -0500
++++ binutils-2.15/ld/configure.tgt 2004-08-04 12:01:45.000000000 -0500
+@@ -30,6 +30,7 @@
+ targ_extra_emuls="criself crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ cris-*-linux-gnu*) targ_emul=crislinux ;;
++cris-*-linux-uclibc*) targ_emul=crislinux ;;
+ cris-*-*) targ_emul=criself
+ targ_extra_emuls="crisaout crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+@@ -59,14 +60,16 @@
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'`
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc64-*-linux-gnu*) targ_emul=elf64_sparc
++sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*) \
++ targ_emul=elf64_sparc
+ targ_extra_emuls="elf32_sparc sparclinux sun4"
+ targ_extra_libpath=elf32_sparc
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+ tdir_sparclinux=${tdir_elf32_sparc}aout
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc*-*-linux-gnu*) targ_emul=elf32_sparc
++sparc*-*-linux-gnu* | sparc*-*-linux-uclibc*) \
++ targ_emul=elf32_sparc
+ targ_extra_emuls="sparclinux elf64_sparc sun4"
+ targ_extra_libpath=elf64_sparc
+ tdir_sparclinux=${targ_alias}aout
+@@ -118,7 +121,9 @@
+ m32r*le-*-elf*) targ_emul=m32rlelf ;;
+ m32r*-*-elf*) targ_emul=m32relf ;;
+ m32r*le-*-linux-gnu*) targ_emul=m32rlelf_linux ;;
++m32r*le-*-linux-uclibc*) targ_emul=m32rlelf_linux ;;
+ m32r*-*-linux-gnu*) targ_emul=m32relf_linux ;;
++m32r*-*-linux-uclibc*) targ_emul=m32relf_linux ;;
+ m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
+ targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
+ m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
+@@ -128,7 +133,7 @@
+ m68*-ericsson-ose) targ_emul=sun3 ;;
+ m68*-apple-aux*) targ_emul=m68kaux ;;
+ *-tandem-none) targ_emul=st2000 ;;
+-i370-*-elf* | i370-*-linux-gnu*) targ_emul=elf32i370 ;;
++i370-*-elf* | i370-*-linux-gnu* | i370-*-linux-uclibc*) targ_emul=elf32i370 ;;
+ i[3-7]86-*-nto-qnx*) targ_emul=i386nto ;;
+ i[3-7]86-*-vsta) targ_emul=vsta ;;
+ i[3-7]86-go32-rtems*) targ_emul=i386go32 ;;
+@@ -152,14 +157,16 @@
+ tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+ i[3-7]86-*-linux*oldld) targ_emul=i386linux; targ_extra_emuls=elf_i386 ;;
+-i[3-7]86-*-linux-gnu*) targ_emul=elf_i386
++i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*) \
++ targ_emul=elf_i386
+ targ_extra_emuls=i386linux
+ if test x${want64} = xtrue; then
+ targ_extra_emuls="$targ_extra_emuls elf_x86_64"
+ fi
+ tdir_i386linux=${targ_alias}aout
+ ;;
+-x86_64-*-linux-gnu*) targ_emul=elf_x86_64
++x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*) \
++ targ_emul=elf_x86_64
+ targ_extra_emuls="elf_i386 i386linux"
+ targ_extra_libpath=elf_i386
+ tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
+@@ -259,10 +266,13 @@
+ arm9e-*-elf) targ_emul=armelf ;;
+ arm-*-oabi) targ_emul=armelf_oabi ;;
+ arm*b-*-linux-gnu*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
++arm*b-*-linux-uclibc*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
+ arm*-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++arm*-*-linux-uclibc*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-conix*) targ_emul=armelf ;;
+-thumb-*-linux-gnu* | thumb-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++thumb-*-linux-gnu* | thumb-*-linux-uclibc* | thumb-*-uclinux*) \
++ targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ strongarm-*-coff) targ_emul=armcoff ;;
+ strongarm-*-elf) targ_emul=armelf ;;
+ strongarm-*-kaos*) targ_emul=armelf ;;
+@@ -364,7 +374,8 @@
+ targ_extra_emuls=m68kelf
+ tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+-m68k-*-linux-gnu*) targ_emul=m68kelf
++m68k-*-linux-gnu* | m68k-*-linux-uclibc*) \
++ targ_emul=m68kelf
+ targ_extra_emuls=m68klinux
+ tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'`
+ ;;
+@@ -381,9 +392,9 @@
+ m68*-*-psos*) targ_emul=m68kpsos ;;
+ m68*-*-rtemscoff*) targ_emul=m68kcoff ;;
+ m68*-*-rtems*) targ_emul=m68kelf ;;
+-hppa*64*-*-linux-gnu*) targ_emul=hppa64linux ;;
++hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*) targ_emul=hppa64linux ;;
+ hppa*64*-*) targ_emul=elf64hppa ;;
+-hppa*-*-linux-gnu*) targ_emul=hppalinux ;;
++hppa*-*-linux-gnu* | hppa*-*-linux-uclibc*) targ_emul=hppalinux ;;
+ hppa*-*-*elf*) targ_emul=hppaelf ;;
+ hppa*-*-lites*) targ_emul=hppaelf ;;
+ hppa*-*-netbsd*) targ_emul=hppanbsd ;;
+@@ -396,6 +407,7 @@
+ targ_emul=vaxnbsd
+ targ_extra_emuls=elf32vax ;;
+ vax-*-linux-gnu*) targ_emul=elf32vax ;;
++vax-*-linux-uclibc*) targ_emul=elf32vax ;;
+ mips*-*-pe) targ_emul=mipspe ;
+ targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+ mips*-dec-ultrix*) targ_emul=mipslit ;;
+@@ -429,16 +441,16 @@
+ mips*-*-vxworks*) targ_emul=elf32ebmip
+ targ_extra_emuls="elf32elmip" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-gnu*) targ_emul=elf32ltsmipn32
++mips64*el-*-linux-gnu* | mips64*el-*-linux-uclibc*) targ_emul=elf32ltsmipn32
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
+ ;;
+-mips64*-*-linux-gnu*) targ_emul=elf32btsmipn32
++mips64*-*-linux-gnu* | mips64*-*-linux-uclibc*) targ_emul=elf32btsmipn32
+ targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
+ ;;
+-mips*el-*-linux-gnu*) targ_emul=elf32ltsmip
++mips*el-*-linux-gnu* | mips*el-*-linux-uclibc*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
+ ;;
+-mips*-*-linux-gnu*) targ_emul=elf32btsmip
++mips*-*-linux-gnu* | mips*-*-linux-uclibc*) targ_emul=elf32btsmip
+ targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
+ ;;
+ mips*-*-lnews*) targ_emul=mipslnews ;;
+@@ -461,6 +473,10 @@
+ alpha*-*-linux-gnu*) targ_emul=elf64alpha targ_extra_emuls=alpha
+ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
+ ;;
++alpha*-*-linux-uclibc*) targ_emul=elf64alpha targ_extra_emuls=alpha
++ # The following needs to be checked...
++ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
++ ;;
+ alpha*-*-osf*) targ_emul=alpha ;;
+ alpha*-*-gnu*) targ_emul=elf64alpha ;;
+ alpha*-*-netware*) targ_emul=alpha ;;
+diff -urN binutils-2.15-dist/libtool.m4 binutils-2.15/libtool.m4
+--- binutils-2.15-dist/libtool.m4 2003-04-10 22:58:39.000000000 -0500
++++ binutils-2.15/libtool.m4 2004-08-04 12:01:45.000000000 -0500
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -urN binutils-2.15-dist/ltconfig binutils-2.15/ltconfig
+--- binutils-2.15-dist/ltconfig 2003-10-03 23:54:47.000000000 -0500
++++ binutils-2.15/ltconfig 2004-08-04 12:01:45.000000000 -0500
+@@ -603,6 +603,7 @@
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+ linux-gnu*) ;;
++linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1259,6 +1260,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -urN binutils-2.15-dist/opcodes/configure binutils-2.15/opcodes/configure
+--- binutils-2.15-dist/opcodes/configure 2003-08-05 04:39:31.000000000 -0500
++++ binutils-2.15/opcodes/configure 2004-08-04 12:01:45.000000000 -0500
+@@ -1700,6 +1700,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15/210-cflags.patch b/cleopatre/buildroot/toolchain/binutils/2.15/210-cflags.patch
new file mode 100644
index 0000000000..dc67d3c4e3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15/210-cflags.patch
@@ -0,0 +1,32 @@
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.am binutils-2.14.90.0.6.new/bfd/doc/Makefile.am
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.am 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.am 2004-03-01 16:05:16.000000000 -0600
+@@ -55,10 +55,10 @@
+ MKDOC = chew$(EXEEXT_FOR_BUILD)
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
+diff -urN binutils-2.14.90.0.6/bfd/doc/Makefile.in binutils-2.14.90.0.6.new/bfd/doc/Makefile.in
+--- binutils-2.14.90.0.6/bfd/doc/Makefile.in 2003-07-23 10:08:09.000000000 -0500
++++ binutils-2.14.90.0.6.new/bfd/doc/Makefile.in 2004-03-01 16:05:03.000000000 -0600
+@@ -469,10 +469,10 @@
+
+
+ $(MKDOC): chew.o
+- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS) $(LOADLIBES) $(LDFLAGS)
++ $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(CFLAGS_FOR_BUILD) $(LOADLIBES) $(LDFLAGS)
+
+ chew.o: chew.c
+- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
++ $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include -I$(srcdir)/../../intl -I../../intl $(H_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/chew.c
+
+ protos: libbfd.h libcoff.h bfd.h
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.15/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..e07a7e8cea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1611,7 +1611,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -1976,7 +1976,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15/600-arm-textrel.patch b/cleopatre/buildroot/toolchain/binutils/2.15/600-arm-textrel.patch
new file mode 100644
index 0000000000..73d5b9df8e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15/600-arm-textrel.patch
@@ -0,0 +1,63 @@
+http://sources.redhat.com/ml/binutils/2004-06/msg00010.html
+--- binutils-2.15.90.0.3-old/bfd/elf32-arm.h 2004-04-12 14:56:33.000000000 -0500
++++ binutils-2.15.90.0.3/bfd/elf32-arm.h 2004-09-03 06:56:40.000000000 -0500
+@@ -87,6 +87,8 @@
+ #endif
+ static bfd_boolean allocate_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *h, PTR inf));
++static bfd_boolean elf32_arm_readonly_dynrelocs
++ PARAMS ((struct elf_link_hash_entry *, PTR));
+ static bfd_boolean create_got_section
+ PARAMS ((bfd * dynobj, struct bfd_link_info * info));
+ static bfd_boolean elf32_arm_create_dynamic_sections
+@@ -3531,6 +3533,37 @@
+ return TRUE;
+ }
+
++/* Find any dynamic relocs that apply to read-only sections. */
++
++static bfd_boolean
++elf32_arm_readonly_dynrelocs (h, inf)
++ struct elf_link_hash_entry *h;
++ PTR inf;
++{
++ struct elf32_arm_link_hash_entry *eh;
++ struct elf32_arm_relocs_copied *p;
++
++ if (h->root.type == bfd_link_hash_warning)
++ h = (struct elf_link_hash_entry *) h->root.u.i.link;
++
++ eh = (struct elf32_arm_link_hash_entry *) h;
++ for (p = eh->relocs_copied; p != NULL; p = p->next)
++ {
++ asection *s = p->section;
++
++ if (s != NULL && (s->flags & SEC_READONLY) != 0)
++ {
++ struct bfd_link_info *info = (struct bfd_link_info *) inf;
++
++ info->flags |= DF_TEXTREL;
++
++ /* Not an error, just cut short the traversal. */
++ return FALSE;
++ }
++ }
++ return TRUE;
++}
++
+ /* Set the sizes of the dynamic sections. */
+
+ static bfd_boolean
+@@ -3740,6 +3773,12 @@
+ return FALSE;
+ }
+
++ /* If any dynamic relocs apply to a read-only section,
++ then we need a DT_TEXTREL entry. */
++ if ((info->flags & DF_TEXTREL) == 0)
++ elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
++ (PTR) info);
++
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
diff --git a/cleopatre/buildroot/toolchain/binutils/2.15/700-nios2-2.15.patch b/cleopatre/buildroot/toolchain/binutils/2.15/700-nios2-2.15.patch
new file mode 100644
index 0000000000..50f0caff64
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.15/700-nios2-2.15.patch
@@ -0,0 +1,38957 @@
+diff --git a/bfd/Makefile.am b/bfd/Makefile.am
+index de811af..d55e681 100644
+--- a/bfd/Makefile.am
++++ b/bfd/Makefile.am
+@@ -82,6 +82,7 @@ ALL_MACHINES = \
+ cpu-mips.lo \
+ cpu-mmix.lo \
+ cpu-msp430.lo \
++ cpu-nios2.lo \
+ cpu-or32.lo \
+ cpu-ns32k.lo \
+ cpu-openrisc.lo \
+@@ -139,6 +140,7 @@ ALL_MACHINES_CFILES = \
+ cpu-msp430.c \
+ cpu-or32.c \
+ cpu-ns32k.c \
++ cpu-nios2.c \
+ cpu-openrisc.c \
+ cpu-pdp11.c \
+ cpu-pj.c \
+@@ -241,6 +243,7 @@ BFD32_BACKENDS = \
+ elfxx-mips.lo \
+ elf32-mips.lo \
+ elf32-msp430.lo \
++ elf32-nios2.lo \
+ elf32-openrisc.lo \
+ elf32-or32.lo \
+ elf32-pj.lo \
+@@ -405,6 +408,7 @@ BFD32_BACKENDS_CFILES = \
+ elfxx-mips.c \
+ elf32-mips.c \
+ elf32-msp430.c \
++ elf32-nios2.c \
+ elf32-openrisc.c \
+ elf32-or32.c \
+ elf32-pj.c \
+@@ -943,6 +947,7 @@ cpu-mcore.lo: cpu-mcore.c $(INCDIR)/filenames.h
+ cpu-mips.lo: cpu-mips.c $(INCDIR)/filenames.h
+ cpu-mmix.lo: cpu-mmix.c $(INCDIR)/filenames.h
+ cpu-msp430.lo: cpu-msp430.c $(INCDIR)/filenames.h
++cpu-nios2.lo: cpu-nios2.c $(INCDIR)/filenames.h
+ cpu-or32.lo: cpu-or32.c $(INCDIR)/filenames.h
+ cpu-ns32k.lo: cpu-ns32k.c $(INCDIR)/filenames.h ns32k.h
+ cpu-openrisc.lo: cpu-openrisc.c $(INCDIR)/filenames.h
+@@ -1250,6 +1255,10 @@ elf32-msp430.lo: elf32-msp430.c $(INCDIR)/filenames.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/msp430.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
++elf32-nios2.lo: elf32-nios2.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
++ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/elf/nios2.h \
++ $(INCDIR)/elf/reloc-macros.h elf32-target.h
+ elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \
+diff --git a/bfd/Makefile.in b/bfd/Makefile.in
+index a6685f2..1ea97fe 100644
+--- a/bfd/Makefile.in
++++ b/bfd/Makefile.in
+@@ -210,6 +210,7 @@ ALL_MACHINES = \
+ cpu-mips.lo \
+ cpu-mmix.lo \
+ cpu-msp430.lo \
++ cpu-nios2.lo \
+ cpu-or32.lo \
+ cpu-ns32k.lo \
+ cpu-openrisc.lo \
+@@ -267,6 +268,7 @@ ALL_MACHINES_CFILES = \
+ cpu-mmix.c \
+ cpu-msp430.c \
+ cpu-or32.c \
++ cpu-nios2.c \
+ cpu-ns32k.c \
+ cpu-openrisc.c \
+ cpu-pdp11.c \
+@@ -371,6 +373,7 @@ BFD32_BACKENDS = \
+ elfxx-mips.lo \
+ elf32-mips.lo \
+ elf32-msp430.lo \
++ elf32-nios2.lo \
+ elf32-openrisc.lo \
+ elf32-or32.lo \
+ elf32-pj.lo \
+@@ -536,6 +539,7 @@ BFD32_BACKENDS_CFILES = \
+ elfxx-mips.c \
+ elf32-mips.c \
+ elf32-msp430.c \
++ elf32-nios2.c \
+ elf32-openrisc.c \
+ elf32-or32.c \
+ elf32-pj.c \
+@@ -1482,6 +1486,7 @@ cpu-mmix.lo: cpu-mmix.c $(INCDIR)/filenames.h
+ cpu-msp430.lo: cpu-msp430.c $(INCDIR)/filenames.h
+ cpu-or32.lo: cpu-or32.c $(INCDIR)/filenames.h
+ cpu-ns32k.lo: cpu-ns32k.c $(INCDIR)/filenames.h ns32k.h
++cpu-nios2.lo: cpu-nios2.c $(INCDIR)/filenames.h
+ cpu-openrisc.lo: cpu-openrisc.c $(INCDIR)/filenames.h
+ cpu-pdp11.lo: cpu-pdp11.c $(INCDIR)/filenames.h
+ cpu-pj.lo: cpu-pj.c $(INCDIR)/filenames.h
+@@ -1787,6 +1792,10 @@ elf32-msp430.lo: elf32-msp430.c $(INCDIR)/filenames.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/msp430.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
++elf32-nios2.lo: elf32-nios2.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
++ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/elf/nios2.h \
++ $(INCDIR)/elf/reloc-macros.h elf32-target.h
+ elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \
+diff --git a/bfd/archures.c b/bfd/archures.c
+index f8aeeef..82fe291 100644
+--- a/bfd/archures.c
++++ b/bfd/archures.c
+@@ -330,6 +330,8 @@ DESCRIPTION
+ .#define bfd_mach_msp44 44
+ . bfd_arch_xtensa, {* Tensilica's Xtensa cores. *}
+ .#define bfd_mach_xtensa 1
++. bfd_arch_nios2,
++.#define bfd_mach_nios2 1
+ . bfd_arch_last
+ . };
+ */
+@@ -422,6 +424,7 @@ extern const bfd_arch_info_type bfd_w65_arch;
+ extern const bfd_arch_info_type bfd_xstormy16_arch;
+ extern const bfd_arch_info_type bfd_xtensa_arch;
+ extern const bfd_arch_info_type bfd_z8k_arch;
++extern const bfd_arch_info_type bfd_nios2_arch;
+
+ static const bfd_arch_info_type * const bfd_archures_list[] =
+ {
+@@ -460,6 +463,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
+ &bfd_mn10200_arch,
+ &bfd_mn10300_arch,
+ &bfd_msp430_arch,
++ &bfd_nios2_arch,
+ &bfd_ns32k_arch,
+ &bfd_openrisc_arch,
+ &bfd_or32_arch,
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index 2464d27..1938170 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -1728,6 +1728,8 @@ enum bfd_architecture
+ #define bfd_mach_msp44 44
+ bfd_arch_xtensa, /* Tensilica's Xtensa cores. */
+ #define bfd_mach_xtensa 1
++ bfd_arch_nios2,
++#define bfd_mach_nios2 1
+ bfd_arch_last
+ };
+
+@@ -3439,6 +3441,23 @@ This is the 5 bits of a value. */
+ BFD_RELOC_MSP430_16_PCREL_BYTE,
+ BFD_RELOC_MSP430_16_BYTE,
+
++/* Relocations used by the Altera New Jersey core */
++ BFD_RELOC_NIOS2_S16,
++ BFD_RELOC_NIOS2_U16,
++ BFD_RELOC_NIOS2_CALL26,
++ BFD_RELOC_NIOS2_IMM5,
++ BFD_RELOC_NIOS2_CACHE_OPX,
++ BFD_RELOC_NIOS2_IMM6,
++ BFD_RELOC_NIOS2_IMM8,
++ BFD_RELOC_NIOS2_HI16,
++ BFD_RELOC_NIOS2_LO16,
++ BFD_RELOC_NIOS2_HIADJ16,
++ BFD_RELOC_NIOS2_GPREL,
++ BFD_RELOC_NIOS2_UJMP,
++ BFD_RELOC_NIOS2_CJMP,
++ BFD_RELOC_NIOS2_CALLR,
++ BFD_RELOC_NIOS2_ALIGN,
++
+ /* IQ2000 Relocations. */
+ BFD_RELOC_IQ2000_OFFSET_16,
+ BFD_RELOC_IQ2000_OFFSET_21,
+diff --git a/bfd/config.bfd b/bfd/config.bfd
+index 1428831..caf64b5 100755
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -59,6 +59,7 @@ m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch" ;;
+ m68*) targ_archs=bfd_m68k_arch ;;
+ m88*) targ_archs=bfd_m88k_arch ;;
+ mips*) targ_archs=bfd_mips_arch ;;
++nios2*) targ_archs=bfd_nios2_arch ;;
+ or32*) targ_archs=bfd_or32_arch ;;
+ pdp11*) targ_archs=bfd_pdp11_arch ;;
+ pj*) targ_archs="bfd_pj_arch bfd_i386_arch";;
+@@ -874,6 +875,21 @@ case "${targ}" in
+ targ_underscore=yes
+ ;;
+
++ nios2eb-*-*)
++ targ_defvec=bfd_elf32_bignios2_vec
++ targ_selvecs=bfd_elf32_littlenios2_vec
++ ;;
++
++ nios2el-*-*)
++ targ_defvec=bfd_elf32_littlenios2_vec
++ targ_selvecs=bfd_elf32_bignios2_vec
++ ;;
++
++ nios2-*-*)
++ targ_defvec=bfd_elf32_littlenios2_vec
++ targ_selvecs=bfd_elf32_bignios2_vec
++ ;;
++
+ openrisc-*-elf)
+ targ_defvec=bfd_elf32_openrisc_vec
+ ;;
+diff --git a/bfd/configure b/bfd/configure
+index 46c8170..8c35166 100755
+--- a/bfd/configure
++++ b/bfd/configure
+@@ -6322,6 +6322,8 @@ do
+ bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;;
++ bfd_elf32_littlenios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
++ bfd_elf32_bignios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
+ bfd_elf32_msp430_vec) tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
+ bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+diff --git a/bfd/configure.in b/bfd/configure.in
+index 71f41f4..eed3fa0 100644
+--- a/bfd/configure.in
++++ b/bfd/configure.in
+@@ -631,6 +631,8 @@ do
+ bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;;
+ bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;;
++ bfd_elf32_littlenios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
++ bfd_elf32_bignios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
+ bfd_elf32_msp430_vec) tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
+ bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+diff --git a/bfd/cpu-nios2.c b/bfd/cpu-nios2.c
+new file mode 100644
+index 0000000..c8f39c9
+--- /dev/null
++++ b/bfd/cpu-nios2.c
+@@ -0,0 +1,70 @@
++/* bfd back-end for Altera Nios II support
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include "bfd.h"
++#include "sysdep.h"
++#include "libbfd.h"
++
++static const bfd_arch_info_type *nios2_compatible
++ (const bfd_arch_info_type *, const bfd_arch_info_type *);
++
++/* The default routine tests bits_per_word, which is wrong on mips as
++ mips word size doesn't correlate with reloc size. */
++
++static const bfd_arch_info_type *
++nios2_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
++{
++ if (a->arch != b->arch)
++ return NULL;
++
++ /* Machine compatibility is checked in
++ _bfd_mips_elf_merge_private_bfd_data. */
++
++ return a;
++}
++
++#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
++ { \
++ BITS_WORD, /* bits in a word */ \
++ BITS_ADDR, /* bits in an address */ \
++ 8, /* 8 bits in a byte */ \
++ bfd_arch_nios2, \
++ NUMBER, \
++ "nios2", \
++ PRINT, \
++ 3, \
++ DEFAULT, \
++ nios2_compatible, \
++ bfd_default_scan, \
++ NEXT, \
++ }
++
++#define NN(index) (&arch_info_struct[(index) + 1])
++
++static const bfd_arch_info_type arch_info_struct[] =
++{
++ N (32, 32, bfd_mach_nios2, "nios2", FALSE, 0),
++};
++
++/* There is only one architecture - but we give the default a machine number of 0
++ so the linker can distinguish it */
++const bfd_arch_info_type bfd_nios2_arch =
++N (32, 32, 0, "nios2", TRUE, &arch_info_struct[0]);
+diff --git a/bfd/elf.c b/bfd/elf.c
+index a14fd35..3a061ec 100644
+--- a/bfd/elf.c
++++ b/bfd/elf.c
+@@ -3286,9 +3286,14 @@ map_sections_to_segments (bfd *abfd)
+ phdr_size = elf_tdata (abfd)->program_header_size;
+ if (phdr_size == 0)
+ phdr_size = get_elf_backend_data (abfd)->s->sizeof_phdr;
++
++ /* NG - for standalone embedded applications we don't want the program
++ headers or ELF header in the output memory map (cf CSP) */
+ if ((abfd->flags & D_PAGED) == 0
+ || sections[0]->lma < phdr_size
+- || sections[0]->lma % maxpagesize < phdr_size % maxpagesize)
++ || sections[0]->lma % maxpagesize < phdr_size % maxpagesize
++ || (elf_tdata (abfd)->elf_header[0].e_ident[EI_OSABI]
++ == ELFOSABI_STANDALONE))
+ phdr_in_segment = FALSE;
+ }
+
+diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
+new file mode 100644
+index 0000000..045b3a9
+--- /dev/null
++++ b/bfd/elf32-nios2.c
+@@ -0,0 +1,2191 @@
++/* New Jersey-specific support for 32-bit ELF
++
++ Copyright (C) 2005
++ by Nigel Gray (ngray@altera.com).
++
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++/* This file handles Altera New Jersey ELF targets */
++
++#include "bfd.h"
++#include "sysdep.h"
++#include "libbfd.h"
++#include "bfdlink.h"
++#include "genlink.h"
++#include "elf-bfd.h"
++#include "elf/nios2.h"
++#include "opcode/nios2.h"
++
++/* use RELA relocations*/
++#ifndef USE_RELA
++#define USE_RELA
++#endif
++
++#ifdef USE_REL
++#undef USE_REL
++#endif
++
++/* Function prototypes */
++
++static reloc_howto_type *nios2_elf32_bfd_reloc_type_lookup
++ (bfd *, bfd_reloc_code_real_type);
++
++static bfd_boolean nios2_elf32_relax_section
++ (bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
++
++static bfd_boolean nios2_elf32_relax_delete_bytes
++ (bfd *, asection *, bfd_vma, int);
++
++static reloc_howto_type *nios2_elf32_rtype_to_howto
++ (unsigned int r_type, bfd_boolean rela_p);
++
++static void nios2_elf32_info_to_howto
++ (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst);
++
++static bfd_boolean nios2_elf32_relocate_section
++ (bfd * output_bfd, struct bfd_link_info * info, bfd * input_bfd,
++ asection * input_section, bfd_byte * contents,
++ Elf_Internal_Rela * relocs, Elf_Internal_Sym * local_syms,
++ asection ** local_sections);
++
++static reloc_howto_type *lookup_howto (unsigned int rtype);
++
++static bfd_reloc_status_type nios2_elf_final_gp
++ (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *,
++ struct bfd_link_info *);
++
++static bfd_boolean nios2_elf_assign_gp
++ (bfd *, bfd_vma *, struct bfd_link_info *);
++
++static bfd_reloc_status_type nios2_elf32_ignore_reloc
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_hi16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_lo16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_hiadj16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_pcrel16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_call26_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_gprel_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_ujmp_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_cjmp_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_callr_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_do_hi16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_lo16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_hiadj16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_pcrel16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_call26_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_gprel_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_ujmp_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_cjmp_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_callr_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++
++static void nios2_elf32_post_process_headers
++ (bfd *, struct bfd_link_info *);
++
++static bfd_boolean nios2_elf32_section_from_shdr
++ (bfd *, Elf_Internal_Shdr *, const char *name);
++
++static bfd_boolean nios2_elf32_section_flags
++ (flagword *, Elf_Internal_Shdr *);
++
++static bfd_boolean nios2_elf32_fake_sections
++ (bfd *, Elf_Internal_Shdr *, asection *);
++
++
++
++static bfd_boolean nios2_elf32_check_relocs
++ (bfd *, struct bfd_link_info *, asection *,
++ const Elf_Internal_Rela *);
++
++static asection *nios2_elf32_gc_mark_hook (asection * sec,
++ struct bfd_link_info *
++ info,
++ Elf_Internal_Rela * rel,
++ struct elf_link_hash_entry
++ * h,
++ Elf_Internal_Sym * sym);
++
++
++/* target vector */
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
++
++/* The relocation table used for SHT_REL sections. */
++
++static reloc_howto_type elf_nios2_howto_table_rel[] = {
++ /* No relocation. */
++ HOWTO (R_NIOS2_NONE, /* type */
++ 0, /* rightshift */
++ 0, /* size (0 = byte, 1 = short, 2 = long) */
++ 0, /* bitsize */
++ FALSE, /* pc_relative */
++ 0, /* bitpos */
++ complain_overflow_dont, /* complain_on_overflow */
++ bfd_elf_generic_reloc, /* special_function */
++ "R_NIOS2_NONE", /* name */
++ FALSE, /* partial_inplace */
++ 0, /* src_mask */
++ 0, /* dst_mask */
++ FALSE), /* pcrel_offset */
++
++ /* 16-bit signed immediate relocation */
++ HOWTO (R_NIOS2_S16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_signed, /* complain on overflow */
++ bfd_elf_generic_reloc, /* special function */
++ "R_NIOS2_S16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ FALSE), /* pcrel_offset */
++
++ /* 16-bit unsigned immediate relocation */
++ HOWTO (R_NIOS2_U16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_unsigned, /* complain on overflow */
++ bfd_elf_generic_reloc, /* special function */
++ "R_NIOS2_U16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ FALSE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_PCREL16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ TRUE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_signed, /* complain on overflow */
++ nios2_elf32_pcrel16_relocate, /* special function */
++ "R_NIOS2_PCREL16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ TRUE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_CALL26, /* type */
++ 2, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 26, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_dont, /* complain on overflow */
++ nios2_elf32_call26_relocate, /* special function */
++ "R_NIOS2_CALL26", /* name */
++ FALSE, /* partial_inplace */
++ 0xffffffc0, /* src_mask */
++ 0xffffffc0, /* dst_mask */
++ FALSE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_IMM5,
++ 0,
++ 2,
++ 5,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM5",
++ FALSE,
++ 0x000007c0,
++ 0x000007c0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CACHE_OPX,
++ 0,
++ 2,
++ 5,
++ FALSE,
++ 22,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_CACHE_OPX",
++ FALSE,
++ 0x07c00000,
++ 0x07c00000,
++ FALSE),
++
++ HOWTO (R_NIOS2_IMM6,
++ 0,
++ 2,
++ 6,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM6",
++ FALSE,
++ 0x00000fc0,
++ 0x00000fc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_IMM8,
++ 0,
++ 2,
++ 8,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM8",
++ FALSE,
++ 0x00003fc0,
++ 0x00003fc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_HI16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_hi16_relocate,
++ "R_NIOS2_HI16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_LO16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_lo16_relocate,
++ "R_NIOS2_LO16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_HIADJ16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_hiadj16_relocate,
++ "R_NIOS2_HIADJ16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_32,
++ 0,
++ 2, /* long */
++ 32,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC32",
++ FALSE,
++ 0xffffffff,
++ 0xffffffff,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_16,
++ 0,
++ 1, /* short */
++ 16,
++ FALSE,
++ 0,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC16",
++ FALSE,
++ 0x0000ffff,
++ 0x0000ffff,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_8,
++ 0,
++ 0, /* byte */
++ 8,
++ FALSE,
++ 0,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC8",
++ FALSE,
++ 0x000000ff,
++ 0x000000ff,
++ FALSE),
++
++ HOWTO (R_NIOS2_GPREL,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_gprel_relocate,
++ "R_NIOS2_GPREL",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_GNU_VTINHERIT,
++ 0,
++ 2, /* short */
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ NULL,
++ "R_NIOS2_GNU_VTINHERIT",
++ FALSE,
++ 0,
++ 0,
++ FALSE),
++
++ HOWTO (R_NIOS2_GNU_VTENTRY,
++ 0,
++ 2, /* byte */
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ _bfd_elf_rel_vtable_reloc_fn,
++ "R_NIOS2_GNU_VTENTRY",
++ FALSE,
++ 0,
++ 0,
++ FALSE),
++
++ HOWTO (R_NIOS2_UJMP,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_ujmp_relocate,
++ "R_NIOS2_UJMP",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CJMP,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_cjmp_relocate,
++ "R_NIOS2_CJMP",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CALLR,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_callr_relocate,
++ "R_NIOS2_CALLR",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_ALIGN,
++ 0,
++ 2,
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ nios2_elf32_ignore_reloc,
++ "R_NIOS2_ALIGN",
++ FALSE,
++ 0,
++ 0,
++ TRUE),
++
++/* add other relocations here */
++};
++
++static unsigned char elf_code_to_howto_index[R_NIOS2_ILLEGAL + 1];
++
++static reloc_howto_type *
++lookup_howto (unsigned int rtype)
++{
++ static int initialized = 0;
++ int i;
++ int howto_tbl_size = (int) (sizeof (elf_nios2_howto_table_rel)
++ / sizeof (elf_nios2_howto_table_rel[0]));
++
++ if (!initialized)
++ {
++ initialized = 1;
++ memset (elf_code_to_howto_index, 0xff,
++ sizeof (elf_code_to_howto_index));
++ for (i = 0; i < howto_tbl_size; i++)
++ elf_code_to_howto_index[elf_nios2_howto_table_rel[i].type] = i;
++ }
++
++ BFD_ASSERT (rtype <= R_NIOS2_ILLEGAL);
++ i = elf_code_to_howto_index[rtype];
++ if (i >= howto_tbl_size)
++ return 0;
++ return elf_nios2_howto_table_rel + i;
++}
++
++/*
++ map for converting BFD reloc types to New Jersey
++ reloc types
++ */
++struct elf_reloc_map
++{
++ bfd_reloc_code_real_type bfd_val;
++ enum elf_nios2_reloc_type elf_val;
++};
++
++static const struct elf_reloc_map nios2_reloc_map[] = {
++ {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
++ {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
++ {BFD_RELOC_16_PCREL, R_NIOS2_PCREL16},
++ {BFD_RELOC_NIOS2_CALL26, R_NIOS2_CALL26},
++ {BFD_RELOC_NIOS2_IMM5, R_NIOS2_IMM5},
++ {BFD_RELOC_NIOS2_CACHE_OPX, R_NIOS2_CACHE_OPX},
++ {BFD_RELOC_NIOS2_IMM6, R_NIOS2_IMM6},
++ {BFD_RELOC_NIOS2_IMM8, R_NIOS2_IMM8},
++ {BFD_RELOC_NIOS2_HI16, R_NIOS2_HI16},
++ {BFD_RELOC_NIOS2_LO16, R_NIOS2_LO16},
++ {BFD_RELOC_NIOS2_HIADJ16, R_NIOS2_HIADJ16},
++ {BFD_RELOC_32, R_NIOS2_BFD_RELOC_32},
++ {BFD_RELOC_16, R_NIOS2_BFD_RELOC_16},
++ {BFD_RELOC_8, R_NIOS2_BFD_RELOC_8},
++ {BFD_RELOC_NIOS2_GPREL, R_NIOS2_GPREL},
++ {BFD_RELOC_VTABLE_INHERIT, R_NIOS2_GNU_VTINHERIT},
++ {BFD_RELOC_VTABLE_ENTRY, R_NIOS2_GNU_VTENTRY},
++ {BFD_RELOC_NIOS2_UJMP, R_NIOS2_UJMP},
++ {BFD_RELOC_NIOS2_CJMP, R_NIOS2_CJMP},
++ {BFD_RELOC_NIOS2_CALLR, R_NIOS2_CALLR},
++ {BFD_RELOC_NIOS2_ALIGN, R_NIOS2_ALIGN},
++};
++
++/* Given a BFD reloc type, return a howto structure. */
++
++static reloc_howto_type *
++nios2_elf32_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
++ bfd_reloc_code_real_type code)
++{
++ int i;
++ for (i = 0;
++ i < (int) (sizeof (nios2_reloc_map) / sizeof (struct elf_reloc_map));
++ ++i)
++ {
++ if (nios2_reloc_map[i].bfd_val == code)
++ return &elf_nios2_howto_table_rel[(int) nios2_reloc_map[i].elf_val];
++ }
++
++ return NULL;
++}
++
++/* Helper function for nios2_elf32_info_to_howto */
++
++static reloc_howto_type *
++nios2_elf32_rtype_to_howto (unsigned int r_type,
++ bfd_boolean rela_p ATTRIBUTE_UNUSED)
++{
++ BFD_ASSERT (r_type < R_NIOS2_ILLEGAL);
++ return &elf_nios2_howto_table_rel[r_type];
++}
++
++/* Given a ELF32 relocation, fill in a arelent structure */
++
++static void
++nios2_elf32_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr,
++ Elf_Internal_Rela * dst)
++{
++ unsigned int r_type;
++
++ r_type = ELF32_R_TYPE (dst->r_info);
++ cache_ptr->howto = nios2_elf32_rtype_to_howto (r_type, FALSE);
++
++ // FIXME - do we need to do anything else here???
++}
++
++/* The assembler has output long jmp/call sequences for all calls
++ * and pc-relative branches that it cannot guarantee are within
++ * range, so the linker must attempt to "relax" these sequences to
++ * short branches and calls if it can. We avoid having to re-relax by
++ * replacing redundant instructions with nops instead of deleting them.
++ *
++ *
++ **/
++static bfd_boolean
++nios2_elf32_relax_section (bfd * abfd,
++ asection * sec,
++ struct bfd_link_info *link_info, bfd_boolean * again)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ Elf_Internal_Rela *internal_relocs;
++ Elf_Internal_Rela *irel, *irelend;
++ bfd_byte *contents = NULL;
++ Elf_Internal_Sym *isymbuf = NULL;
++
++#define OP_MATCH_NOP 0x0001883a
++
++ /* Assume nothing changes. */
++ *again = FALSE;
++
++ /* We don't have to do anything for a relocatable link, if
++ this section does not have relocs, or if this is not a
++ code section. */
++ if (link_info->relocatable
++ || (sec->flags & SEC_RELOC) == 0
++ || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0)
++ return TRUE;
++
++ /* If this is the first time we have been called for this section,
++ initialize the cooked size. */
++ if (sec->_cooked_size == 0)
++ sec->_cooked_size = sec->_raw_size;
++
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++
++ /* Get a copy of the native relocations. */
++ internal_relocs = (_bfd_elf_link_read_relocs
++ (abfd, sec, (void *) NULL, (Elf_Internal_Rela *) NULL,
++ link_info->keep_memory));
++ if (internal_relocs == NULL)
++ goto error_return;
++
++ /* Walk through them looking for relaxing opportunities. */
++ irelend = internal_relocs + sec->reloc_count;
++ for (irel = internal_relocs; irel < irelend; irel++)
++ {
++ bfd_vma symval;
++
++ /* If this isn't something that can be relaxed, then ignore
++ this reloc. */
++ if (ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_UJMP
++ && ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_CJMP
++ && ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_CALLR)
++ {
++ continue;
++ }
++
++ /* Get the section contents if we haven't done so already. */
++ if (contents == NULL)
++ {
++ /* Get cached copy if it exists. */
++ if (elf_section_data (sec)->this_hdr.contents != NULL)
++ contents = elf_section_data (sec)->this_hdr.contents;
++ else
++ {
++ /* Go get them off disk. */
++ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
++ if (contents == NULL)
++ goto error_return;
++
++ if (!bfd_get_section_contents (abfd, sec, contents,
++ (file_ptr) 0, sec->_raw_size))
++ goto error_return;
++ }
++ }
++
++ /* Read this BFD's local symbols if we haven't done so already. */
++ if (isymbuf == NULL && symtab_hdr->sh_info != 0)
++ {
++ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
++ if (isymbuf == NULL)
++ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
++ symtab_hdr->sh_info, 0,
++ NULL, NULL, NULL);
++ if (isymbuf == NULL)
++ goto error_return;
++ }
++
++ /* Get the value of the symbol referred to by the reloc. */
++ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
++ {
++ /* A local symbol. */
++ Elf_Internal_Sym *isym;
++ asection *sym_sec;
++
++ isym = isymbuf + ELF32_R_SYM (irel->r_info);
++ if (isym->st_shndx == SHN_UNDEF)
++ sym_sec = bfd_und_section_ptr;
++ else if (isym->st_shndx == SHN_ABS)
++ sym_sec = bfd_abs_section_ptr;
++ else if (isym->st_shndx == SHN_COMMON)
++ sym_sec = bfd_com_section_ptr;
++ else
++ sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
++ symval = (isym->st_value
++ + sym_sec->output_section->vma + sym_sec->output_offset);
++ }
++ else
++ {
++ unsigned long indx;
++ struct elf_link_hash_entry *h;
++
++ /* An external symbol. */
++ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
++ h = elf_sym_hashes (abfd)[indx];
++ BFD_ASSERT (h != NULL);
++ if (h->root.type != bfd_link_hash_defined
++ && h->root.type != bfd_link_hash_defweak)
++ {
++ /* This appears to be a reference to an undefined
++ symbol. Just ignore it--it will be caught by the
++ regular reloc processing. */
++ continue;
++ }
++
++ symval = (h->root.u.def.value
++ + h->root.u.def.section->output_section->vma
++ + h->root.u.def.section->output_offset);
++ }
++
++ /* For simplicity of coding, we are going to modify the section
++ contents, the section relocs, and the BFD symbol table. We
++ must tell the rest of the code not to free up this
++ information. It would be possible to instead create a table
++ of changes which have to be made, as is done in coff-mips.c;
++ that would be more work, but would require less memory when
++ the linker is run. */
++
++ /* try to turn :
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * callr at
++ * into:
++ * call symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_CALLR)
++ {
++ bfd_vma targ_addr = symval + irel->r_addend;
++ bfd_vma curr_addr = (sec->output_section->vma + sec->output_offset);
++ bfd_vma targ_page, curr_page;
++ targ_page = targ_addr & 0xf0000000;
++ curr_page = curr_addr & 0xf0000000;
++
++ if (targ_page == curr_page)
++ {
++ /* change the opcode to a call */
++ bfd_put_32 (abfd, OP_MATCH_CALL, contents + irel->r_offset);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_CALL26);
++
++ /* replace next two instructions with nops */
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 4);
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 8);
++ }
++ }
++
++ /* try to turn :
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * jmp at
++ * into:
++ * br symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_UJMP)
++ {
++ bfd_vma pcrel_offset;
++ Elf_Internal_Rela *irelalign = NULL;
++ Elf_Internal_Rela *irela = elf_section_data (sec)->relocs;
++ Elf_Internal_Rela *irelend = irel + sec->reloc_count;
++
++ for (; irela < irelend; irela++)
++ {
++ if (ELF32_R_TYPE (irela->r_info) == (int) R_NIOS2_ALIGN
++ && irela->r_offset > irel->r_offset + 4
++ && 8 < (1 << irela->r_addend))
++ {
++ irelalign = irela;
++ break;
++ }
++ }
++
++ /* calculate the pcrelative offset from current location */
++ pcrel_offset = symval;
++ pcrel_offset -= (sec->output_section->vma + sec->output_offset);
++ pcrel_offset += irel->r_addend;
++
++ /* we need to compute the pcrel_offset from the next instruction */
++ pcrel_offset -= (irel->r_offset + 4);
++
++ /* does this value fit in 16 bits */
++ if ((irelalign == NULL && (long) pcrel_offset <= 0x8004
++ && (long) pcrel_offset >= -0x8000) || (irelalign != NULL
++ && (long) pcrel_offset
++ <= 0x7ffc
++ && (long) pcrel_offset
++ >= -0x8000))
++ {
++ /* change the opcode to an unconditional branch */
++ bfd_put_32 (abfd, OP_MATCH_BR, contents + irel->r_offset);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_PCREL16);
++
++ /* replace next two instructions with nops */
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 4);
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 8);
++ }
++ }
++
++ /* try to turn :
++ * b{cond} a, b skip
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * jmp at
++ * skip:
++ * ...
++ * into:
++ * br{opp_cond} a, b, symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_CJMP)
++ {
++ bfd_vma pcrel_offset;
++ Elf_Internal_Rela *irelalign = NULL;
++ Elf_Internal_Rela *irela = elf_section_data (sec)->relocs;
++ Elf_Internal_Rela *irelend = irel + sec->reloc_count;
++
++ for (; irela < irelend; irela++)
++ {
++ if (ELF32_R_TYPE (irela->r_info) == (int) R_NIOS2_ALIGN
++ && irela->r_offset > irel->r_offset + 4
++ && 8 < (1 << irela->r_addend))
++ {
++ irelalign = irela;
++ break;
++ }
++ }
++
++ /* calculate the pcrelative offset from current location */
++ pcrel_offset = symval;
++ pcrel_offset -= (sec->output_section->vma + sec->output_offset);
++ pcrel_offset += irel->r_addend;
++
++ /* we need to compute the pcrel_offset from this instruction
++ * ie the movhi */
++ pcrel_offset -= (irel->r_offset);
++
++ /* does this value fit in 16 bits */
++ if ((irelalign == NULL && (long) pcrel_offset <= 0x8008
++ && (long) pcrel_offset >= -0x8000) || (irelalign != NULL
++ && (long) pcrel_offset
++ <= 0x7ffc
++ && (long) pcrel_offset
++ >= -0x8000))
++ {
++ unsigned long opcode, op_a, op_b;
++ /* get the conditional branch opcode */
++ opcode = bfd_get_32 (abfd, contents + irel->r_offset - 4);
++ /* reverse the condition */
++ switch (opcode & OP_MASK_OP)
++ {
++ case OP_MATCH_BEQ:
++ opcode = (opcode & ~OP_MASK_OP) | OP_MATCH_BNE;
++ break;
++ case OP_MATCH_BNE:
++ opcode = (opcode & ~OP_MASK_OP) | OP_MATCH_BEQ;
++ break;
++ case OP_MATCH_BGE:
++ case OP_MATCH_BGEU:
++ case OP_MATCH_BLT:
++ case OP_MATCH_BLTU:
++ /* swap the operands */
++ op_a = (opcode & OP_MASK_RRT) << 5;
++ op_b = (opcode & OP_MASK_RRS) >> 5;
++ opcode =
++ (opcode & ~(OP_MASK_RRS | OP_MASK_RRT)) | op_a | op_b;
++ break;
++ default:
++ fprintf (stderr,
++ "relaxation error - expecting conditional branch, aborting\n");
++ abort ();
++ break;
++ }
++
++ /* we must set the branch target to zero so that the skip over the jmp doesn't get
++ * added to the jmp */
++ opcode = opcode & (~OP_MASK_IMM16);
++
++ /* change the opcode to the reversed conditional branch */
++ bfd_put_32 (abfd, opcode, contents + irel->r_offset - 4);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_PCREL16);
++
++ /* this relocation's offset has also been reduced by 4 bytes */
++ irel->r_offset -= 4;
++
++ /* replace next two instructions with nops */
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 4);
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 8);
++ bfd_put_32 (abfd, OP_MATCH_NOP, contents + irel->r_offset + 12);
++ }
++ }
++
++ /* otherwise, leave alone */
++ }
++
++ if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
++ {
++ if (!link_info->keep_memory)
++ free (isymbuf);
++ else
++ {
++ /* Cache the symbols for elf_link_input_bfd. */
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++ }
++ }
++
++ if (contents != NULL
++ && elf_section_data (sec)->this_hdr.contents != contents)
++ {
++ if (!link_info->keep_memory)
++ free (contents);
++ else
++ {
++ /* Cache the section contents for elf_link_input_bfd. */
++ elf_section_data (sec)->this_hdr.contents = contents;
++ }
++ }
++
++ if (internal_relocs != NULL
++ && elf_section_data (sec)->relocs != internal_relocs)
++ free (internal_relocs);
++
++
++ return TRUE;
++
++error_return:
++ if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
++ free (isymbuf);
++ if (contents != NULL
++ && elf_section_data (sec)->this_hdr.contents != contents)
++ free (contents);
++ if (internal_relocs != NULL
++ && elf_section_data (sec)->relocs != internal_relocs)
++ free (internal_relocs);
++
++ return FALSE;
++}
++
++/* Delete some bytes from a section while relaxing.
++ * Copied from mn10200 port */
++
++static bfd_boolean
++nios2_elf32_relax_delete_bytes (bfd * abfd,
++ asection * sec, bfd_vma addr, int count)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ unsigned int sec_shndx;
++ bfd_byte *contents;
++ Elf_Internal_Rela *irel, *irelend;
++ Elf_Internal_Rela *irelalign;
++ bfd_vma toaddr;
++ Elf_Internal_Sym *isym;
++ Elf_Internal_Sym *isymend;
++ struct elf_link_hash_entry **sym_hashes;
++ struct elf_link_hash_entry **end_hashes;
++ unsigned int symcount;
++ asection *asec;
++
++ sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
++
++ contents = elf_section_data (sec)->this_hdr.contents;
++
++ /* The deletion must stop at the next ALIGN reloc for an aligment
++ power larger than the number of bytes we are deleting. */
++
++ irelalign = NULL;
++ /* +1 because we need to readjust symbols at end of section */
++ toaddr = sec->_cooked_size + 1;
++
++ irel = elf_section_data (sec)->relocs;
++ irelend = irel + sec->reloc_count;
++
++ for (; irel < irelend; irel++)
++ {
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_ALIGN
++ && irel->r_offset > addr && count < (1 << irel->r_addend))
++ {
++ irelalign = irel;
++ /* +1 because we need to readjust symbols at end of section */
++ toaddr = irel->r_offset + 1;
++ break;
++ }
++ }
++
++
++ /* Actually delete the bytes. */
++ memmove (contents + addr, contents + addr + count,
++ (size_t) ((toaddr - 1) - addr - count));
++
++ if (irelalign == NULL)
++ sec->_cooked_size -= count;
++ else
++ {
++ int i;
++
++#define NOP_OPCODE (0x0001883a)
++
++ BFD_ASSERT ((count & 3) == 0);
++ for (i = 0; i < count; i += 4)
++ bfd_put_32 (abfd, (bfd_vma) NOP_OPCODE,
++ contents + (toaddr - 1) - count + i);
++ }
++
++ /* get the symbol table */
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++ isym = (Elf_Internal_Sym *) symtab_hdr->contents;
++
++ /* Adjust all the reloc offsets in this section. */
++ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
++ {
++ /* Get the new reloc address. */
++ if ((irel->r_offset > addr && irel->r_offset < toaddr))
++ irel->r_offset -= count;
++ }
++
++ /* Adjust relocations against targets in this section whose positions
++ * have moved as a result of the relaxation */
++
++ for (asec = abfd->sections; asec; asec = asec->next)
++ {
++ irelend = elf_section_data (asec)->relocs + asec->reloc_count;
++ for (irel = elf_section_data (asec)->relocs; irel < irelend; irel++)
++ {
++ Elf_Internal_Sym *sym;
++ /* if the symbol which this reloc is against doesn't change
++ * we need to change the reloc addend */
++
++ sym = isym + ELF32_R_SYM (irel->r_info);
++ if (sym->st_shndx == sec_shndx
++ && !(sym->st_value > addr && sym->st_value < toaddr)
++ && sym->st_value + irel->r_addend > addr
++ && sym->st_value + irel->r_addend < toaddr)
++ {
++ irel->r_addend -= count;
++ }
++
++ }
++ }
++
++ /* Adjust the local symbols defined in this section. */
++ for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
++ {
++ if (isym->st_shndx == sec_shndx
++ && isym->st_value > addr && isym->st_value < toaddr)
++ isym->st_value -= count;
++
++
++ }
++
++ /* Now adjust the global symbols defined in this section. */
++ symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
++ - symtab_hdr->sh_info);
++ sym_hashes = elf_sym_hashes (abfd);
++ end_hashes = sym_hashes + symcount;
++ for (; sym_hashes < end_hashes; sym_hashes++)
++ {
++ struct elf_link_hash_entry *sym_hash = *sym_hashes;
++ if ((sym_hash->root.type == bfd_link_hash_defined
++ || sym_hash->root.type == bfd_link_hash_defweak)
++ && sym_hash->root.u.def.section == sec
++ && sym_hash->root.u.def.value > addr
++ && sym_hash->root.u.def.value < toaddr)
++ {
++ sym_hash->root.u.def.value -= count;
++ }
++ }
++
++ return TRUE;
++}
++
++struct bfd_link_info *nios2_link_info = NULL;
++
++void
++_bfd_set_link_info (info)
++ struct bfd_link_info *info;
++{
++ nios2_link_info = info;
++}
++
++bfd_boolean linker_force_make_executable = FALSE;
++
++void
++_bfd_set_force_make_executable (force)
++ bfd_boolean force;
++{
++ linker_force_make_executable = force;
++}
++
++/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
++ dangerous relocation. */
++
++static bfd_boolean
++nios2_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp, struct bfd_link_info *info)
++{
++
++ bfd_boolean gp_found;
++ struct bfd_hash_entry *h;
++ struct bfd_link_hash_entry *lh;
++
++ /* If we've already figured out what GP will be, just return it. */
++ *pgp = _bfd_get_gp_value (output_bfd);
++ if (*pgp)
++ return TRUE;
++
++ h = bfd_hash_lookup (&info->hash->table, "_gp", FALSE, FALSE);
++ lh = (struct bfd_link_hash_entry *) h;
++lookup:
++ if (lh)
++ {
++ switch (lh->type)
++ {
++ case bfd_link_hash_undefined:
++ case bfd_link_hash_undefweak:
++ case bfd_link_hash_common:
++ gp_found = FALSE;
++ break;
++ case bfd_link_hash_defined:
++ case bfd_link_hash_defweak:
++ gp_found = TRUE;
++ *pgp = lh->u.def.value;
++ break;
++ case bfd_link_hash_indirect:
++ case bfd_link_hash_warning:
++ lh = lh->u.i.link;
++ /* @@FIXME ignoring warning for now */
++ goto lookup;
++ case bfd_link_hash_new:
++ default:
++ abort ();
++ }
++ }
++ else
++ gp_found = FALSE;
++
++ if (!gp_found)
++ {
++ /* Only get the error once. */
++ *pgp = 4;
++ _bfd_set_gp_value (output_bfd, *pgp);
++ return FALSE;
++ }
++
++ _bfd_set_gp_value (output_bfd, *pgp);
++
++ return TRUE;
++}
++
++/* We have to figure out the gp value, so that we can adjust the
++ symbol value correctly. We look up the symbol _gp in the output
++ BFD. If we can't find it, we're stuck. We cache it in the ELF
++ target data. We don't need to adjust the symbol value for an
++ external symbol if we are producing relocatable output. */
++
++static bfd_reloc_status_type
++nios2_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
++ char **error_message, bfd_vma *pgp, struct bfd_link_info *info)
++{
++ if (bfd_is_und_section (symbol->section) && !relocatable)
++ {
++ *pgp = 0;
++ return bfd_reloc_undefined;
++ }
++
++ *pgp = _bfd_get_gp_value (output_bfd);
++ if (*pgp == 0 && (!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0))
++ {
++ /* if this is called without link_info, then
++ we cannot be doing a final link */
++ if (info == NULL)
++ relocatable = TRUE;
++
++ if (relocatable)
++ {
++ /* Make up a value. */
++ *pgp = symbol->section->output_section->vma + 0x4000;
++ _bfd_set_gp_value (output_bfd, *pgp);
++ }
++ else if (!nios2_elf_assign_gp (output_bfd, pgp, info))
++ {
++ *error_message =
++ (char *)
++ _("global pointer relative relocation when _gp not defined");
++ return bfd_reloc_dangerous;
++ }
++ }
++
++ return bfd_reloc_ok;
++}
++
++
++/* Relocations that require special handling */
++
++/* This is for relocations used only when relaxing to ensure
++ * changes in size of section don't screw up .align */
++static bfd_reloc_status_type
++nios2_elf32_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
++ asymbol *symbol ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED,
++ asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++ if (output_bfd != NULL)
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_hi16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data,
++ asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_hi16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_lo16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_lo16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_hiadj16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd,
++ char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_hiadj16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_pcrel16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd,
++ char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_pcrel16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_call26_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_call26_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_gprel_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg)
++{
++ bfd_vma relocation;
++ bfd_vma gp;
++ bfd_reloc_status_type r;
++
++
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ relocation = symbol->value
++ + symbol->section->output_section->vma + symbol->section->output_offset;
++
++ if ((r =
++ nios2_elf_final_gp (abfd, symbol, FALSE, msg, &gp,
++ nios2_link_info)) == bfd_reloc_ok)
++ {
++ relocation = relocation + reloc_entry->addend - gp;
++ reloc_entry->addend = 0;
++ if ((signed) relocation < -32768 || (signed) relocation > 32767)
++ {
++ *msg = _("global pointer relative address out of range");
++ r = bfd_reloc_outofrange;
++ }
++ else
++ {
++ r = nios2_elf32_do_gprel_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ relocation, reloc_entry->addend);
++ }
++ }
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_ujmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_ujmp_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_cjmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_cjmp_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_callr_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++
++ return nios2_elf32_do_callr_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++/* Do the relocations which require special handling */
++
++static bfd_reloc_status_type
++nios2_elf32_do_hi16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value = (symbol_value >> 16) & 0xffff;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++
++static bfd_reloc_status_type
++nios2_elf32_do_lo16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value = symbol_value & 0xffff;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_hiadj16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data, bfd_vma offset,
++ bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value =
++ ((symbol_value >> 16) & 0xffff) + ((symbol_value >> 15) & 0x01);
++ return _bfd_final_link_relocate (howto, abfd, input_section, data, offset,
++ symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_pcrel16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ // NIOS2 pc relative relocations are relative to the next 32-bit instruction so we need
++ // to subtract 4 before doing a final_link_relocate
++ symbol_value = symbol_value + addend - 4;
++ addend = 0;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_call26_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ /* check that the relocation is in the same page as the current address */
++ if (((symbol_value + addend) & 0xf0000000)
++ != ((input_section->output_section->vma + offset) & 0xf0000000))
++ return bfd_reloc_overflow;
++
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++
++static bfd_reloc_status_type
++nios2_elf32_do_gprel_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ // because we need the output_bfd, the special handling is done
++ // in nios2_elf32_relocate_section or in nios2_elf32_gprel_relocate
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_ujmp_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_cjmp_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_callr_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++/*
++ The function nios2_elf32_relocate_section is used by the linker
++ to perform relocations
++*/
++static bfd_boolean
++nios2_elf32_relocate_section (bfd * output_bfd,
++ struct bfd_link_info *info,
++ bfd * input_bfd,
++ asection * input_section,
++ bfd_byte * contents,
++ Elf_Internal_Rela * relocs,
++ Elf_Internal_Sym * local_syms,
++ asection ** local_sections)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ struct elf_link_hash_entry **sym_hashes;
++ Elf_Internal_Rela *rel;
++ Elf_Internal_Rela *relend;
++
++ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
++ sym_hashes = elf_sym_hashes (input_bfd);
++ relend = relocs + input_section->reloc_count;
++
++// size_t psymalloc = 0;
++// _bfd_generic_link_output_symbols(output_bfd, input_bfd, info, &psymalloc);
++ for (rel = relocs; rel < relend; rel++)
++ {
++ reloc_howto_type *howto;
++ unsigned long r_symndx;
++ Elf_Internal_Sym *sym;
++ asection *sec;
++ struct elf_link_hash_entry *h;
++ bfd_vma relocation;
++ bfd_vma gp;
++ bfd_vma reloc_address;
++ bfd_reloc_status_type r = bfd_reloc_ok;
++ const char *name = NULL;
++ int r_type;
++ const char *format;
++ char msgbuf[256];
++ const char* msg = (const char*) NULL;
++
++
++
++ r_type = ELF32_R_TYPE (rel->r_info);
++
++ r_symndx = ELF32_R_SYM (rel->r_info);
++
++ if (info->relocatable)
++ {
++ /* This is a relocatable link. We don't have to change
++ anything, unless the reloc is against a section symbol,
++ in which case we have to adjust according to where the
++ section symbol winds up in the output section. */
++ if (r_symndx < symtab_hdr->sh_info)
++ {
++ sym = local_syms + r_symndx;
++
++ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
++ {
++ sec = local_sections[r_symndx];
++ rel->r_addend += sec->output_offset + sym->st_value;
++ }
++ }
++ continue;
++ }
++
++ /* This is a final link. */
++ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
++ h = NULL;
++ sym = NULL;
++ sec = NULL;
++
++ if (r_symndx < symtab_hdr->sh_info)
++ {
++ sym = local_syms + r_symndx;
++ sec = local_sections[r_symndx];
++
++ relocation = (sec->output_section->vma
++ + sec->output_offset + sym->st_value);
++
++ // this ensures that relocations against duplicated symbols
++ // in merged sections that have been removed are fixed up against
++ // the remaining symbol and not the one that has been removed
++ if ((sec->flags & SEC_MERGE)
++ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
++ {
++ rel->r_addend =
++ _bfd_elf_rel_local_sym (output_bfd, sym, &sec, rel->r_addend);
++ rel->r_addend -= relocation;
++ rel->r_addend += sec->output_section->vma + sec->output_offset;
++ }
++
++ name = bfd_elf_string_from_elf_section
++ (input_bfd, symtab_hdr->sh_link, sym->st_name);
++
++ name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
++ }
++ else
++ {
++ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
++
++ while (h->root.type == bfd_link_hash_indirect
++ || h->root.type == bfd_link_hash_warning)
++ h = (struct elf_link_hash_entry *) h->root.u.i.link;
++
++ name = h->root.root.string;
++
++ if (h->root.type == bfd_link_hash_defined
++ || h->root.type == bfd_link_hash_defweak)
++ {
++ sec = h->root.u.def.section;
++
++ relocation = (h->root.u.def.value
++ + sec->output_section->vma + sec->output_offset);
++ }
++ else if (h->root.type == bfd_link_hash_undefweak)
++ {
++ relocation = 0;
++ }
++ else
++ {
++ if (!((*info->callbacks->undefined_symbol)
++ (info, h->root.root.string, input_bfd,
++ input_section, rel->r_offset, TRUE)))
++ return FALSE;
++ relocation = 0;
++ }
++ }
++
++ if (sec)
++ reloc_address = sec->output_section->vma + sec->output_offset + rel->r_offset;
++ else
++ reloc_address = 0;
++
++ if (howto != NULL)
++ {
++ switch (howto->type)
++ {
++ case R_NIOS2_HI16:
++ r =
++ nios2_elf32_do_hi16_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_LO16:
++ r =
++ nios2_elf32_do_lo16_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_HIADJ16:
++ r =
++ nios2_elf32_do_hiadj16_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_PCREL16:
++ r =
++ nios2_elf32_do_pcrel16_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_GPREL:
++ // turns an absolute address into a gp-relative address
++ if (!nios2_elf_assign_gp (output_bfd, &gp, info))
++ {
++ format = _("global pointer relative relocation at address 0x%08x when _gp not defined\n");
++ sprintf(msgbuf, format, reloc_address);
++ msg = msgbuf;
++ r = bfd_reloc_dangerous;
++ }
++ else
++ {
++ bfd_vma symbol_address = rel->r_addend + relocation;
++ relocation = relocation + rel->r_addend - gp;
++ rel->r_addend = 0;
++ if ((signed) relocation < -32768
++ || (signed) relocation > 32767)
++ {
++ format = _("Unable to reach %s (at 0x%08x) from the global pointer (at 0x%08x) "
++ "because the offset (%d) is out of the allowed range, -32678 to 32767.\n" );
++ sprintf(msgbuf, format, name, symbol_address, gp, (signed)relocation);
++ msg = msgbuf;
++ r = bfd_reloc_outofrange;
++ }
++ else
++ {
++ r =
++ _bfd_final_link_relocate (howto, input_bfd,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ }
++ }
++
++ break;
++ case R_NIOS2_UJMP:
++ r =
++ nios2_elf32_do_ujmp_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_CJMP:
++ r =
++ nios2_elf32_do_cjmp_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_CALLR:
++ r =
++ nios2_elf32_do_callr_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_CALL26:
++ r =
++ nios2_elf32_do_call26_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_ALIGN:
++ r = bfd_reloc_ok;
++ /* comment - for symmetry this would be
++ r = nios2_elf32_do_ignore_reloc (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ but do_ignore_reloc would do no more than return bfd_reloc_ok */
++ break;
++ default:
++ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ }
++ }
++ else
++ {
++ r = bfd_reloc_notsupported;
++ }
++
++ if (r != bfd_reloc_ok)
++ {
++ if (h != NULL)
++ name = h->root.root.string;
++ else
++ {
++ name = (bfd_elf_string_from_elf_section
++ (input_bfd, symtab_hdr->sh_link, sym->st_name));
++ if (name == NULL || *name == '\0')
++ name = bfd_section_name (input_bfd, sec);
++ }
++
++ switch (r)
++ {
++ case bfd_reloc_overflow:
++ r = info->callbacks->reloc_overflow
++ (info, name, howto->name, (bfd_vma) 0,
++ input_bfd, input_section, rel->r_offset);
++ break;
++
++ case bfd_reloc_undefined:
++ r = info->callbacks->undefined_symbol
++ (info, name, input_bfd, input_section, rel->r_offset, TRUE);
++ break;
++
++ case bfd_reloc_outofrange:
++ if (msg == NULL)
++ msg = _("relocation out of range");
++ break;
++
++ case bfd_reloc_notsupported:
++ if (msg == NULL)
++ msg = _("unsupported relocation");
++ break;
++
++ case bfd_reloc_dangerous:
++ if (msg == NULL)
++ msg = _("dangerous relocation");
++ break;
++
++ default:
++ if (msg == NULL)
++ msg = _("unknown error");
++ break;
++ }
++
++ if (msg)
++ {
++ r = info->callbacks->warning
++ (info, msg, name, input_bfd, input_section, rel->r_offset);
++ return linker_force_make_executable;
++ }
++ }
++ }
++ return TRUE;
++}
++
++
++
++/* Handle an NIOS2 specific section when reading an object file. This
++ is called when elfcode.h finds a section with an unknown type.
++ FIXME: We need to handle the SHF_NIOS2_GPREL flag */
++
++static bfd_boolean
++nios2_elf32_section_from_shdr (bfd *abfd,
++ Elf_Internal_Shdr *hdr, const char *name)
++{
++ asection *newsect;
++
++ /* NG - I'm keeping this code commented out at the moment
++ in case we add a .mdebug section */
++
++ /*
++ switch (hdr->sh_type)
++ {
++ case SHT_NIOS2_DEBUG:
++ if (strcmp (name, ".mdebug") != 0)
++ return FALSE;
++ break;
++ default:
++ return FALSE;
++ }
++ */
++
++ if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name))
++ return FALSE;
++
++ newsect = hdr->bfd_section;
++
++ /* ditto */
++ /*
++ if (hdr->sh_type == SHT_NIOS2_DEBUG)
++ {
++ if (! bfd_set_section_flags (abfd, newsect,
++ (bfd_get_section_flags (abfd, newsect)
++ | SEC_DEBUGGING)))
++ return FALSE;
++ }
++ */
++ return TRUE;
++}
++
++/* Convert NIOS2 specific section flags to bfd internal section flags. */
++
++static bfd_boolean
++nios2_elf32_section_flags (flagword *flags, Elf_Internal_Shdr *hdr)
++{
++ if (hdr->sh_flags & SHF_NIOS2_GPREL)
++ *flags |= SEC_SMALL_DATA;
++
++ return TRUE;
++}
++
++/* Set the correct type for an NIOS2 ELF section. We do this by the
++ section name, which is a hack, but ought to work. */
++
++static bfd_boolean
++nios2_elf32_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
++ Elf_Internal_Shdr *hdr, asection *sec)
++{
++ register const char *name;
++
++ name = bfd_get_section_name (abfd, sec);
++
++ if (strcmp (name, ".mdebug") == 0)
++ {
++ /* we don't yet have an .mdebug section, but I'm leaving this here
++ in case we ever do
++ hdr->sh_type = SHT_NIOS2_DEBUG;
++
++ if ((abfd->flags & DYNAMIC) != 0 )
++ hdr->sh_entsize = 0;
++ else
++ hdr->sh_entsize = 1;
++ */
++ }
++ else if ((sec->flags & SEC_SMALL_DATA)
++ || strcmp (name, ".sdata") == 0
++ || strcmp (name, ".sbss") == 0
++ || strcmp (name, ".lit4") == 0 || strcmp (name, ".lit8") == 0)
++ hdr->sh_flags |= SHF_NIOS2_GPREL;
++
++ return TRUE;
++}
++
++/* Look through the relocs for a section during the first phase.
++ Since we don't do .gots or .plts, we just need to consider the
++ virtual table relocs for gc. */
++
++static bfd_boolean
++nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
++ asection *sec, const Elf_Internal_Rela *relocs)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
++ const Elf_Internal_Rela *rel;
++ const Elf_Internal_Rela *rel_end;
++
++ if (info->relocatable)
++ return TRUE;
++
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++ sym_hashes = elf_sym_hashes (abfd);
++ sym_hashes_end =
++ sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
++ if (!elf_bad_symtab (abfd))
++ sym_hashes_end -= symtab_hdr->sh_info;
++
++ rel_end = relocs + sec->reloc_count;
++ for (rel = relocs; rel < rel_end; rel++)
++ {
++ struct elf_link_hash_entry *h;
++ unsigned long r_symndx;
++
++ r_symndx = ELF32_R_SYM (rel->r_info);
++ if (r_symndx < symtab_hdr->sh_info)
++ h = NULL;
++ else
++ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
++
++ switch (ELF32_R_TYPE (rel->r_info))
++ {
++ /* This relocation describes the C++ object vtable hierarchy.
++ Reconstruct it for later use during GC. */
++ case R_NIOS2_GNU_VTINHERIT:
++ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
++ return FALSE;
++ break;
++
++ /* This relocation describes which C++ vtable entries are actually
++ used. Record for later use during GC. */
++ case R_NIOS2_GNU_VTENTRY:
++ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
++ return FALSE;
++ break;
++ }
++ }
++
++ return TRUE;
++}
++
++
++/* Return the section that should be marked against GC for a given
++ relocation. */
++
++asection *
++nios2_elf32_gc_mark_hook (asection *sec,
++ struct bfd_link_info *info ATTRIBUTE_UNUSED,
++ Elf_Internal_Rela *rel, struct elf_link_hash_entry *h,
++ Elf_Internal_Sym *sym)
++{
++ if (h != NULL)
++ {
++ switch (ELF32_R_TYPE (rel->r_info))
++ {
++ case R_NIOS2_GNU_VTINHERIT:
++ case R_NIOS2_GNU_VTENTRY:
++ break;
++
++ default:
++ switch (h->root.type)
++ {
++ case bfd_link_hash_defined:
++ case bfd_link_hash_defweak:
++ return h->root.u.def.section;
++
++ case bfd_link_hash_common:
++ return h->root.u.c.p->section;
++
++ default:
++ break;
++ }
++ }
++ }
++ else
++ return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
++
++ return NULL;
++}
++
++/*
++ NG ??? I'm marking the sections as standalone ie. I'm linking for
++ standalone embedded applications, not for UNIX System V or any other
++ OS/ABI - this may need to change when we deal with embedded PIC or
++ dynamic linking
++*/
++
++static void
++nios2_elf32_post_process_headers (bfd *abfd,
++ struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
++{
++ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
++
++ i_ehdrp = elf_elfheader (abfd);
++ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_STANDALONE;
++}
++
++#define ELF_ARCH bfd_arch_nios2
++#define ELF_MACHINE_CODE EM_ALTERA_NIOS2
++
++/* for now we just make this 1, as we have no MMU in New Jersey */
++
++#define ELF_MAXPAGESIZE 1
++
++/* relocation table lookup macros */
++
++#define bfd_elf32_bfd_reloc_type_lookup nios2_elf32_bfd_reloc_type_lookup
++
++/* JUMP_TABLE_LINK macros */
++
++#define bfd_elf32_bfd_relax_section nios2_elf32_relax_section
++
++/* elf_info_to_howto (using RELA relocations) */
++
++#define elf_info_to_howto nios2_elf32_info_to_howto
++
++/* elf backend functions */
++
++#define elf_backend_can_gc_sections 1
++
++#define elf_backend_relocate_section nios2_elf32_relocate_section
++#define elf_backend_section_from_shdr nios2_elf32_section_from_shdr
++#define elf_backend_section_flags nios2_elf32_section_flags
++#define elf_backend_fake_sections nios2_elf32_fake_sections
++#define elf_backend_post_process_headers nios2_elf32_post_process_headers
++#define elf_backend_check_relocs nios2_elf32_check_relocs
++
++#define elf_backend_gc_mark_hook nios2_elf32_gc_mark_hook
++
++
++
++/* Support for SGI-ish mips targets. */
++#define TARGET_LITTLE_SYM bfd_elf32_littlenios2_vec
++#define TARGET_LITTLE_NAME "elf32-littlenios2"
++#define TARGET_BIG_SYM bfd_elf32_bignios2_vec
++#define TARGET_BIG_NAME "elf32-bignios2"
++
++#include "elf32-target.h"
+diff --git a/bfd/libbfd.h b/bfd/libbfd.h
+index 62043f3..3335b04 100644
+--- a/bfd/libbfd.h
++++ b/bfd/libbfd.h
+@@ -1504,6 +1504,21 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+ "BFD_RELOC_MSP430_16",
+ "BFD_RELOC_MSP430_16_PCREL_BYTE",
+ "BFD_RELOC_MSP430_16_BYTE",
++ "BFD_RELOC_NIOS2_S16",
++ "BFD_RELOC_NIOS2_U16",
++ "BFD_RELOC_NIOS2_CALL26",
++ "BFD_RELOC_NIOS2_IMM5",
++ "BFD_RELOC_NIOS2_CACHE_OPX",
++ "BFD_RELOC_NIOS2_IMM6",
++ "BFD_RELOC_NIOS2_IMM8",
++ "BFD_RELOC_NIOS2_HI16",
++ "BFD_RELOC_NIOS2_LO16",
++ "BFD_RELOC_NIOS2_HIADJ16",
++ "BFD_RELOC_NIOS2_GPREL",
++ "BFD_RELOC_NIOS2_UJMP",
++ "BFD_RELOC_NIOS2_CJMP",
++ "BFD_RELOC_NIOS2_CALLR",
++ "BFD_RELOC_NIOS2_ALIGN",
+ "BFD_RELOC_IQ2000_OFFSET_16",
+ "BFD_RELOC_IQ2000_OFFSET_21",
+ "BFD_RELOC_IQ2000_UHI16",
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index 9bffaa3..8807b30 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -3943,6 +3943,39 @@ ENUMDOC
+ msp430 specific relocation codes
+
+ ENUM
++ BFD_RELOC_NIOS2_S16
++ENUMX
++ BFD_RELOC_NIOS2_U16
++ENUMX
++ BFD_RELOC_NIOS2_CALL26
++ENUMX
++ BFD_RELOC_NIOS2_IMM5
++ENUMX
++ BFD_RELOC_NIOS2_CACHE_OPX
++ENUMX
++ BFD_RELOC_NIOS2_IMM6
++ENUMX
++ BFD_RELOC_NIOS2_IMM8
++ENUMX
++ BFD_RELOC_NIOS2_HI16
++ENUMX
++ BFD_RELOC_NIOS2_LO16
++ENUMX
++ BFD_RELOC_NIOS2_HIADJ16
++ENUMX
++ BFD_RELOC_NIOS2_GPREL
++ENUMX
++ BFD_RELOC_NIOS2_UJMP
++ENUMX
++ BFD_RELOC_NIOS2_CJMP
++ENUMX
++ BFD_RELOC_NIOS2_CALLR
++ENUMX
++ BFD_RELOC_NIOS2_ALIGN
++ENUMDOC
++ Relocations used by the Altera New Jersey core
++
++ENUM
+ BFD_RELOC_IQ2000_OFFSET_16
+ ENUMX
+ BFD_RELOC_IQ2000_OFFSET_21
+diff --git a/bfd/srec.c b/bfd/srec.c
+index c0a3d58..1a1d0ce 100644
+--- a/bfd/srec.c
++++ b/bfd/srec.c
+@@ -1009,9 +1009,14 @@ srec_write_header (abfd)
+ {
+ unsigned int len = strlen (abfd->filename);
+
+- /* I'll put an arbitrary 40 char limit on header size. */
+- if (len > 40)
+- len = 40;
++ /* validate Chunk for header */
++ if (Chunk == 0)
++ Chunk = 1;
++ else if (Chunk > MAXCHUNK - 2) /* S0 has 2 address bytes */
++ Chunk = MAXCHUNK - 2;
++
++ if (len > Chunk)
++ len = Chunk;
+
+ return srec_write_record (abfd, 0, (bfd_vma) 0,
+ abfd->filename, abfd->filename + len);
+diff --git a/bfd/targets.c b/bfd/targets.c
+index cec339c..1833c94 100644
+--- a/bfd/targets.c
++++ b/bfd/targets.c
+@@ -559,6 +559,8 @@ extern const bfd_target bfd_elf32_nbigmips_vec;
+ extern const bfd_target bfd_elf32_nlittlemips_vec;
+ extern const bfd_target bfd_elf32_ntradbigmips_vec;
+ extern const bfd_target bfd_elf32_ntradlittlemips_vec;
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
+ extern const bfd_target bfd_elf32_openrisc_vec;
+ extern const bfd_target bfd_elf32_or32_big_vec;
+ extern const bfd_target bfd_elf32_pj_vec;
+@@ -746,6 +748,8 @@ extern const bfd_target sco5_core_vec;
+ extern const bfd_target trad_core_vec;
+
+ extern const bfd_target bfd_elf32_am33lin_vec;
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
+ static const bfd_target * const _bfd_target_vector[] = {
+
+ #ifdef SELECT_VECS
+@@ -854,6 +858,8 @@ static const bfd_target * const _bfd_target_vector[] = {
+ &bfd_elf32_ntradbigmips_vec,
+ &bfd_elf32_ntradlittlemips_vec,
+ #endif
++ &bfd_elf32_littlenios2_vec,
++ &bfd_elf32_bignios2_vec,
+ &bfd_elf32_openrisc_vec,
+ &bfd_elf32_or32_big_vec,
+ &bfd_elf32_pj_vec,
+diff --git a/binutils/nios2_binutils_xfail.lst b/binutils/nios2_binutils_xfail.lst
+new file mode 100644
+index 0000000..3219223
+--- /dev/null
++++ b/binutils/nios2_binutils_xfail.lst
+@@ -0,0 +1 @@
++No xfails
+diff --git a/binutils/objcopy.c b/binutils/objcopy.c
+index 9623398..a1b7a05 100644
+--- a/binutils/objcopy.c
++++ b/binutils/objcopy.c
+@@ -1705,8 +1705,53 @@ copy_file (const char *input_filename, const char *output_filename,
+
+ delete = ! copy_object (ibfd, obfd);
+
++ if (!strcmp (obfd->xvec->name, "srec")
++ && (!strcmp (ibfd->xvec->name, "elf32-bignios2")
++ || !strcmp (ibfd->xvec->name, "elf32-littlenios2")))
++ {
++ /*
++ * We're copying a big-endian or little-endian elf to an srec.
++ * Tag the elf with a hardcoded S0 record so other tools know
++ * which endianness was in the original elf file.
++ *
++ * This is a hack, as srec files don't really have an
++ * endianness. We just need a way to tell tools like
++ * flash2dat.pl which endianness was originally present.
++ *
++ * At some point in the future, we should stop using srec files
++ * entirely: flash2dat and friends should just read the elf file
++ * directly.
++ */
++ char *new_filename = NULL;
++ const char *orig_filename = obfd->filename;
++ int result;
++
++ if (!strcmp (ibfd->xvec->name, "elf32-bignios2"))
++ {
++ new_filename = strdup("-EB");
++ }
++ else
++ {
++ new_filename = strdup("-EL");
++ }
++ obfd->filename = new_filename;
++
++ result = bfd_close (obfd);
++
++ if ( obfd != NULL && new_filename == obfd->filename )
++ {
++ free(new_filename);
++ obfd->filename = orig_filename;
++ }
++
++ if (!result)
++ RETURN_NONFATAL (output_filename);
++ }
++ else
++ {
+ if (!bfd_close (obfd))
+ RETURN_NONFATAL (output_filename);
++ }
+
+ if (!bfd_close (ibfd))
+ RETURN_NONFATAL (input_filename);
+diff --git a/binutils/readelf.c b/binutils/readelf.c
+index e95a501..a436778 100644
+--- a/binutils/readelf.c
++++ b/binutils/readelf.c
+@@ -110,6 +110,8 @@
+
+ #include "aout/ar.h"
+
++#include "elf/nios2.h"
++
+ #include "bucomm.h"
+ #include "getopt.h"
+ #include "libiberty.h"
+@@ -668,6 +670,7 @@ guess_is_rela (unsigned long e_machine)
+ case EM_XTENSA:
+ case EM_XTENSA_OLD:
+ case EM_M32R:
++ case EM_ALTERA_NIOS2:
+ return TRUE;
+
+ case EM_MMA:
+@@ -1166,6 +1169,10 @@ dump_relocations (FILE *file,
+ case EM_XTENSA:
+ rtype = elf_xtensa_reloc_type (type);
+ break;
++
++ case EM_ALTERA_NIOS2:
++ rtype = elf_nios2_reloc_type (type);
++ break;
+ }
+
+ if (rtype == NULL)
+@@ -1649,6 +1656,7 @@ get_machine_name (unsigned e_machine)
+ case EM_IQ2000: return "Vitesse IQ2000";
+ case EM_XTENSA_OLD:
+ case EM_XTENSA: return "Tensilica Xtensa Processor";
++ case EM_ALTERA_NIOS2: return "Altera Nios II";
+ default:
+ sprintf (buff, _("<unknown>: %x"), e_machine);
+ return buff;
+diff --git a/binutils/testsuite/binutils-all/bintest.s b/binutils/testsuite/binutils-all/bintest.s
+index 9e00650..177b08c 100644
+--- a/binutils/testsuite/binutils-all/bintest.s
++++ b/binutils/testsuite/binutils-all/bintest.s
+@@ -1,5 +1,8 @@
+ .globl text_symbol
+ .text
++ # this is needed to get the readelf -s, -S and -r tests to work
++ # with nios2 as it has relaxation on by default
++ .set norelax
+ text_symbol:
+ static_text_symbol:
+ .long 1
+diff --git a/configure b/configure
+index d11c49b..41c0c64 100755
+--- a/configure
++++ b/configure
+@@ -1434,6 +1434,10 @@ case "${target}" in
+ mips*-*-*)
+ noconfigdirs="$noconfigdirs gprof ${libgcj}"
+ ;;
++ nios2*-*-*)
++ skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'`
++ noconfigdirs="$noconfigdirs"
++ ;;
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+diff --git a/configure.in b/configure.in
+index 6c0c465..c770956 100644
+--- a/configure.in
++++ b/configure.in
+@@ -667,6 +667,10 @@ case "${target}" in
+ mips*-*-*)
+ noconfigdirs="$noconfigdirs gprof ${libgcj}"
+ ;;
++ nios2*-*-*)
++ skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'`
++ noconfigdirs="$noconfigdirs"
++ ;;
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+diff --git a/gas/Makefile.in b/gas/Makefile.in
+index 67ed432..7870a9e 100644
+--- a/gas/Makefile.in
++++ b/gas/Makefile.in
+@@ -299,6 +299,7 @@ CPU_TYPES = \
+ mn10200 \
+ mn10300 \
+ msp430 \
++ nios2 \
+ ns32k \
+ openrisc \
+ or32 \
+@@ -493,6 +494,7 @@ TARGET_CPU_CFILES = \
+ config/tc-mn10200.c \
+ config/tc-mn10300.c \
+ config/tc-msp430.c \
++ config/tc-nios2.c \
+ config/tc-ns32k.c \
+ config/tc-openrisc.c \
+ config/tc-or32.c \
+@@ -545,6 +547,7 @@ TARGET_CPU_HFILES = \
+ config/tc-mn10200.h \
+ config/tc-mn10300.h \
+ config/tc-msp430.h \
++ config/tc-nios2.h \
+ config/tc-ns32k.h \
+ config/tc-openrisc.h \
+ config/tc-or32.h \
+@@ -1171,6 +1174,13 @@ DEPTC_msp430_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \
+ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/msp430.h \
+ $(INCDIR)/safe-ctype.h
+
++DEPTC_nios2_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \
++ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-nios2.h \
++ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/safe-ctype.h \
++ $(INCDIR)/opcode/nios2.h itbl-ops.h dwarf2dbg.h $(INCDIR)/elf/nios2.h \
++ $(INCDIR)/elf/reloc-macros.h
++
+ DEPTC_ns32k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \
+ $(srcdir)/config/tc-ns32k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/opcode/ns32k.h $(INCDIR)/obstack.h
+@@ -1824,6 +1834,12 @@ DEPOBJ_msp430_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \
+ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
+ struc-symbol.h dwarf2dbg.h $(INCDIR)/aout/aout64.h
+
++DEPOBJ_nios2_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \
++ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-nios2.h \
++ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
++ $(INCDIR)/elf/nios2.h $(INCDIR)/elf/reloc-macros.h
++
+ DEPOBJ_ns32k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \
+ $(srcdir)/config/tc-ns32k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/aout/aout64.h $(INCDIR)/obstack.h
+@@ -2349,6 +2365,10 @@ DEP_msp430_elf = $(srcdir)/config/obj-elf.h $(INCDIR)/symcat.h \
+ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-msp430.h
+
++DEP_nios2_elf = $(srcdir)/config/obj-elf.h $(INCDIR)/symcat.h \
++ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-nios2.h
++
+ DEP_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \
+ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h
+
+diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
+index 14d48f2..6d9639f 100644
+--- a/gas/config/obj-elf.c
++++ b/gas/config/obj-elf.c
+@@ -53,6 +53,10 @@
+ #include "elf/i370.h"
+ #endif
+
++#ifdef TC_NIOS2
++#include "elf/nios2.h"
++#endif
++
+ static void obj_elf_line (int);
+ static void obj_elf_size (int);
+ static void obj_elf_type (int);
+diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
+new file mode 100644
+index 0000000..21f994e
+--- /dev/null
++++ b/gas/config/tc-nios2.c
+@@ -0,0 +1,3197 @@
++/* tc-nios2.c -- assemble code for a New Jersey processor.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++
++ This file is part of GAS.
++
++ GAS is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2, or (at your option)
++ any later version.
++
++ GAS is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with GAS; see the file COPYING. If not, write to the Free
++ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
++ 02111-1307, USA. */
++
++
++#include <stdio.h>
++#include <limits.h>
++#include <string.h>
++#include <stdlib.h>
++#include "as.h"
++#include "opcode/nios2.h"
++#include "elf/nios2.h"
++#include "tc-nios2.h"
++#include "bfd.h"
++#include "dwarf2dbg.h"
++#include "subsegs.h"
++#include "safe-ctype.h"
++
++/* We can choose our endianness at run-time, regardless of configuration */
++extern int target_big_endian;
++
++#ifndef OBJ_ELF
++ /* we are not supporting any other target
++ so we throw a compile time error */
++OBJ_ELF not defined
++#endif
++ typedef enum
++{
++ relax_section = 0,
++ relax_none,
++ relax_all
++}
++relax_optionT;
++
++
++/* struct contains all assembler options set with .set */
++struct
++{
++ /*
++ .set noat -> noat = 1 allows assembly code to use at without warning
++ and macro expansions will generate a warning.
++ .set at -> noat = 0, assembly code using at will warn
++ macro expansions will not generate warnings
++ */
++ bfd_boolean noat;
++
++ /*
++ .set nobreak -> nobreak = 1 allows assembly code to use ba,bt without warning
++ .set break -> nobreak = 0, assembly code using ba,bt will warn
++ */
++ bfd_boolean nobreak;
++
++ /*
++ .cmd line option -relax-all allows all branches and calls to be replaced
++ with longer versions
++ -no-relax inhibits branch/call conversion
++ default value is relax_section, which relaxes branches within a section
++ */
++ relax_optionT relax;
++
++}
++nios2_as_options =
++{
++FALSE, FALSE, relax_section};
++
++
++typedef struct nios2_insn_reloc
++{
++ /* any expression in the instruction is parsed into
++ this field which is passed to fix_new_exp() to
++ generate a fixup */
++ expressionS reloc_expression;
++
++ /* the type of the relocation to be applied */
++ bfd_reloc_code_real_type reloc_type;
++
++ /* pc relative */
++ unsigned int reloc_pcrel;
++
++ /* the next relocation to be applied to the instruction */
++ struct nios2_insn_reloc *reloc_next;
++}
++nios2_insn_relocS;
++
++
++/* ------------------------------------------------------------------
++ This struct is used by the functions in tc-nios2.c to assemble an
++ instruction
++ ------------------------------------------------------------------*/
++
++typedef struct nios2_insn_info
++{
++ /* assembled instruction */
++ unsigned long insn_code;
++ /* ptr to the relevant bit of the opcode table */
++ const struct nios2_opcode *insn_nios2_opcode;
++ /* after parsing ptrs to the tokens in the instruction fill this array
++ it is terminated with a null pointer ( hence the first +1
++ The second +1 is because in some parts of the code the opcode
++ is not counted as a token, but still placed in this array*/
++ const char *insn_tokens[NIOS2_MAX_INSN_TOKENS + 1 + 1];
++
++ /* this holds information used to generate fixups
++ and eventually relocations if it is not null */
++ nios2_insn_relocS *insn_reloc;
++}
++nios2_insn_infoS;
++
++
++/*
++ This struct associates an argument assemble function with
++ an argument syntax string. Used by the assembler to find out
++ how to parse and assemble a set of instruction operands and return the instruction
++ field values
++*/
++
++typedef struct nios2_arg_info
++{
++ const char *args;
++ void (*assemble_args_func) (nios2_insn_infoS * insn_info);
++}
++nios2_arg_infoS;
++
++/*
++ This struct is used to convert New Jersey pseudo-ops into the
++ corresponding real op
++ */
++typedef struct nios2_ps_insn_info
++{
++ const char *pseudo_insn;
++ const char *insn;
++ const char *arg_modifier;
++ void (*arg_modifer_func) (const char *arg, char **parsedArgs, int numArg,
++ int startIndex);
++ int num;
++ int index;
++}
++nios2_ps_insn_infoS;
++
++
++
++/* function prototypes */
++static void NIOS2_CHECK_ASSEMBLY (unsigned int opcode,
++ const char *exp_opcode);
++static void s_nios2_sdata (int);
++void nios2_assemble_args_dst (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_tsi (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_tsu (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_o (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_m (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_s (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_tis (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_dc (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_cs (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_ldst (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_none (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_dsj (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_is (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_sto (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_d (nios2_insn_infoS * insn_info);
++void nios2_assemble_args_b (nios2_insn_infoS * insn_info);
++
++nios2_insn_relocS *nios2_insn_reloc_new (bfd_reloc_code_real_type reloc_type,
++ unsigned int pcrel);
++void nios2_insn_reloc_destroy (nios2_insn_relocS * reloc);
++unsigned long nios2_assemble_expression (const char *exprstr,
++ nios2_insn_infoS * insn,
++ nios2_insn_relocS * prev_reloc,
++ bfd_reloc_code_real_type reloc_type,
++ unsigned int pcrel);
++char *nios2_consume_separator (char *argStr, const char *separator);
++char *nios2_consume_arg (char *argStr, const char *argType);
++void nios2_parse_args (char *argStr, const char *parseStr, char **parsedArgs);
++
++void nios2_modify_arg (const char *modifier, char **parsedArgs, int unused,
++ int index);
++void nios2_append_arg (const char *append, char **parsedArgs, int numAppend,
++ int startIndex);
++void nios2_insert_arg (const char *insert, char **parsedArgs, int numInsert,
++ int startIndex);
++void nios2_swap_args (const char *unused, char **parsedArgs, int index_1,
++ int index_2);
++void nios2_negate_arg (const char *modifier ATTRIBUTE_UNUSED,
++ char **parsedArgs, int unused ATTRIBUTE_UNUSED,
++ int index);
++void nios2_translate_pseudo_insn (nios2_insn_infoS * insn);
++valueT md_chars_to_number (char *buf, int n);
++void md_number_to_imm (char *buf, valueT val, int n);
++void md_number_to_disp (char *buf, valueT val, int n);
++void md_number_to_field (char *buf, valueT val, int n);
++static void nios2_align (int log_size, const char *pfill, symbolS * sym);
++static void s_nios2_ucons (int nbytes);
++static void s_nios2_set (int equiv);
++static void s_nios2_align (int ignore);
++static void s_nios2_text (int);
++static void s_nios2_data (int);
++static void s_nios2_section (int);
++static bfd_boolean nios2_coproc_reg (const char *reg_name);
++static void output_insn (void);
++static void output_ubranch (void);
++static void output_cbranch (void);
++static void output_call (void);
++static void output_movia (void);
++static void output_andi (void);
++static void output_addi (void);
++static void output_ori (void);
++static void output_xori (void);
++static int can_evaluate_expr (void);
++static int get_expr_value (void);
++
++
++bfd_boolean nios2_check_overflow (valueT fixup, reloc_howto_type * howto);
++
++/* The known current alignment of the current section. */
++static int nios2_current_align;
++static segT nios2_current_align_seg;
++
++/* The last seen label in the current section. This is used to auto-align
++ labels preceeding instructions. */
++static symbolS *nios2_last_label;
++
++
++static int nios2_auto_align_on = 1;
++
++/* This array holds the chars that always start a comment. If the
++ pre-processor is disabled, these aren't very useful */
++const char comment_chars[] = "#";
++
++/* This array holds the chars that only start a comment at the beginning of
++ a line. If the line seems to have the form '# 123 filename'
++ .line and .file directives will appear in the pre-processed output */
++/* Note that input_file.c hand checks for '#' at the beginning of the
++ first line of the input file. This is because the compiler outputs
++ #NO_APP at the beginning of its output. */
++/* Also note that C style comments are always supported. */
++const char line_comment_chars[] = "#";
++
++/* This array holds machine specific line separator characters. */
++const char line_separator_chars[] = ";";
++
++/* Chars that can be used to separate mant from exp in floating point nums */
++const char EXP_CHARS[] = "eE";
++
++/* Chars that mean this number is a floating point constant */
++/* As in 0f12.456 */
++/* or 0d1.2345e12 */
++const char FLT_CHARS[] = "rRsSfFdDxXpP";
++
++/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
++ changed in read.c . Ideally it shouldn't have to know about it at all,
++ but nothing is ideal around here.
++ */
++
++/* handle of the OPCODE hash table */
++static struct hash_control *nios2_opcode_hash = NULL;
++
++/* handle of the Register hash table */
++static struct hash_control *nios2_reg_hash = NULL;
++
++/* handle of the parse args hash table */
++static struct hash_control *nios2_arg_hash = NULL;
++
++/* pseudo-op hash table */
++static struct hash_control *nios2_ps_hash = NULL;
++
++/* mode of the assembler */
++typedef enum
++{
++ NIOS2_MODE_ASSEMBLE, // ordinary operation
++ NIOS2_MODE_TEST // hidden mode used for self testing
++}
++NIOS2_MODE;
++
++static NIOS2_MODE nios2_mode = NIOS2_MODE_ASSEMBLE;
++
++/* this function is used to in self-checking mode
++ to check the assembled instruction
++ opcode should be the assembled opcode, and exp_opcode
++ the parsed string representing the expected opcode */
++void
++NIOS2_CHECK_ASSEMBLY (unsigned int opcode, const char *exp_opcode)
++{
++ if (nios2_mode == NIOS2_MODE_TEST)
++ {
++ if ((exp_opcode) == NULL)
++ {
++ as_bad (_("expecting opcode string in self test mode"));
++ }
++ else if ((opcode) != strtoul ((exp_opcode), NULL, 16))
++ {
++ as_bad (_("assembly 0x%08x, expected %s"), (opcode), (exp_opcode));
++ }
++ }
++}
++
++/* Machine-dependent command-line options */
++
++const char *md_shortopts = "r";
++
++struct option md_longopts[] = {
++#define OPTION_RELAX_ALL (OPTION_MD_BASE + 0)
++ {"relax-all", no_argument, NULL, OPTION_RELAX_ALL},
++#define OPTION_NORELAX (OPTION_MD_BASE + 1)
++ {"no-relax", no_argument, NULL, OPTION_NORELAX},
++#define OPTION_RELAX_SECTION (OPTION_MD_BASE + 2)
++ {"relax-section", no_argument, NULL, OPTION_RELAX_SECTION},
++#define OPTION_EB (OPTION_MD_BASE + 3)
++ {"EB", no_argument, NULL, OPTION_EB},
++#define OPTION_EL (OPTION_MD_BASE + 4)
++ {"EL", no_argument, NULL, OPTION_EL}
++};
++
++size_t md_longopts_size = sizeof (md_longopts);
++
++/* Machine dependent pseudo-ops
++ These are actually assembler directives
++ format of each entry is
++
++ { "directive", handler_func, param }
++*/
++const pseudo_typeS md_pseudo_table[] = {
++ {"align", s_nios2_align, 0},
++ {"text", s_nios2_text, 0},
++ {"data", s_nios2_data, 0},
++ {"section", s_nios2_section, 0},
++ {"section.s", s_nios2_section, 0},
++ {"sect", s_nios2_section, 0},
++ {"sect.s", s_nios2_section, 0},
++ /* .dword and .half are included for
++ compatibility with MIPS */
++ {"dword", cons, 8},
++ {"half", cons, 2},
++ /* NIOS2 native word size is 4 bytes, so we override
++ the GAS default of 2 */
++ {"word", cons, 4},
++ /* explicitly unaligned directives */
++ {"2byte", s_nios2_ucons, 2},
++ {"4byte", s_nios2_ucons, 4},
++ {"8byte", s_nios2_ucons, 8},
++ {"16byte", s_nios2_ucons, 16},
++#ifdef OBJ_ELF
++ {"sdata", s_nios2_sdata, 0},
++#endif
++ {"set", s_nios2_set, 0},
++ {NULL, NULL, 0}
++};
++
++#define BYTE_F 32764
++#define BYTE_B -32768
++#define ABS (long)0xffffffff /* special value to indicate non-pc relative jmp */
++
++#define UBRANCH 1
++#define UJMP 2
++#define CBRANCH 3
++#define CJMP 4
++
++
++#define RELAX_MAX_SIZE(type) nios2_relax_table[nios2_relax_table[type].rlx_more].rlx_length
++#define RELAX_SIZE(type) nios2_relax_table[type].rlx_length
++#define RELAX_SUBSTATE(type) type
++
++/* machine dependent relaxations */
++struct relax_type nios2_relax_table[] = {
++ /* first entry unused (ends relaxation sequence) */
++ {1, 1, 0, 0},
++ /* unconditional branch */
++ {BYTE_F, BYTE_B, 4, 2}, /* br label (label is in range) */
++ /* unconditional jmp */
++ {ABS, ABS, 12, 0}, /* movhi at, %hi(label) ; ori at, %lo(label) ; jmp at */
++ /* conditional branch */
++ {BYTE_F, BYTE_B, 4, 4}, /* br{cond} label (label is in range) */
++ /* conditional jmp */
++ {ABS, ABS, 16, 0}, /* br{opp_cond} skip ; movhi at, %hi(label) ; ori at, %lo(label) ; jmp at ; skip: } */
++};
++
++
++/* this is just the generic relax_frag function but
++ amended to include absolute jmps in the relax table
++ */
++
++long
++nios2_relax_frag (segT segment, fragS * fragP, long stretch)
++{
++ const relax_typeS *this_type;
++ const relax_typeS *start_type;
++ relax_substateT next_state;
++ relax_substateT this_state;
++ long growth;
++ offsetT aim;
++ addressT target;
++ addressT address;
++ symbolS *symbolP;
++ const relax_typeS *table;
++
++ target = fragP->fr_offset;
++ address = fragP->fr_address;
++ table = nios2_relax_table;
++ this_state = fragP->fr_subtype;
++ start_type = this_type = table + this_state;
++ symbolP = fragP->fr_symbol;
++
++ if (symbolP)
++ {
++ fragS *sym_frag;
++
++ sym_frag = symbol_get_frag (symbolP);
++
++#ifndef DIFF_EXPR_OK
++#if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
++ know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
++ || (S_GET_SEGMENT (symbolP) == SEG_DATA)
++ || (S_GET_SEGMENT (symbolP) == SEG_BSS)
++ || (S_GET_SEGMENT (symbolP) == SEG_TEXT));
++#endif
++ know (sym_frag != NULL);
++#endif
++ know (!(S_GET_SEGMENT (symbolP) == absolute_section)
++ || sym_frag == &zero_address_frag);
++ target += S_GET_VALUE (symbolP);
++
++ /* If frag has yet to be reached on this pass,
++ assume it will move by STRETCH just as we did.
++ If this is not so, it will be because some frag
++ between grows, and that will force another pass. */
++
++ if (stretch != 0
++ && sym_frag->relax_marker != fragP->relax_marker
++ && S_GET_SEGMENT (symbolP) == segment)
++ {
++ target += stretch;
++ }
++ }
++
++
++ /* NG we subtract 4 because all pc relative branches are
++ from the next instruction */
++ aim = target - address - fragP->fr_fix - 4;
++
++ if (aim < 0)
++ {
++ /* Look backwards. */
++ for (next_state = this_type->rlx_more; next_state;)
++ {
++ if (aim >= this_type->rlx_backward
++ || this_type->rlx_backward == ABS)
++ next_state = 0;
++ else
++ {
++ /* Grow to next state. */
++ this_state = next_state;
++ this_type = table + this_state;
++ next_state = this_type->rlx_more;
++ }
++ }
++ }
++ else
++ {
++ /* Look forwards. */
++
++ for (next_state = this_type->rlx_more; next_state;)
++ {
++ if (aim <= this_type->rlx_forward || this_type->rlx_forward == ABS)
++ next_state = 0;
++ else
++ {
++ /* Grow to next state. */
++ this_state = next_state;
++ this_type = table + this_state;
++ next_state = this_type->rlx_more;
++ }
++ }
++ }
++
++
++ growth = this_type->rlx_length - start_type->rlx_length;
++
++ if (growth != 0)
++ fragP->fr_subtype = this_state;
++
++ return growth;
++}
++
++/*--------------------------------------------------------------------------------
++ The next table associates pointers to functions which parse the arguments to an
++ instruction and fill in the relevant fields of the instruction
++ --------------------------------------------------------------------------------*/
++
++const nios2_arg_infoS nios2_arg_info_structs[] = {
++ /* args assemble_args_func */
++ {"d,s,t", nios2_assemble_args_dst},
++ {"d,s,t,E", nios2_assemble_args_dst},
++ {"t,s,i", nios2_assemble_args_tsi},
++ {"t,s,i,E", nios2_assemble_args_tsi},
++ {"t,s,u", nios2_assemble_args_tsu},
++ {"t,s,u,E", nios2_assemble_args_tsu},
++ {"s,t,o", nios2_assemble_args_sto},
++ {"s,t,o,E", nios2_assemble_args_sto},
++ {"o", nios2_assemble_args_o},
++ {"o,E", nios2_assemble_args_o},
++ {"s", nios2_assemble_args_s},
++ {"s,E", nios2_assemble_args_s},
++ {"", nios2_assemble_args_none},
++ {"E", nios2_assemble_args_none},
++ {"i(s)", nios2_assemble_args_is},
++ {"i(s)E", nios2_assemble_args_is},
++ {"m", nios2_assemble_args_m},
++ {"m,E", nios2_assemble_args_m},
++ {"t,i(s)", nios2_assemble_args_tis},
++ {"t,i(s)E", nios2_assemble_args_tis},
++ {"d,c", nios2_assemble_args_dc},
++ {"d,c,E", nios2_assemble_args_dc},
++ {"c,s", nios2_assemble_args_cs},
++ {"c,s,E", nios2_assemble_args_cs},
++ {"l,d,s,t", nios2_assemble_args_ldst},
++ {"l,d,s,t,E", nios2_assemble_args_ldst},
++ {"d,s,j", nios2_assemble_args_dsj},
++ {"d,s,j,E", nios2_assemble_args_dsj},
++ {"d", nios2_assemble_args_d},
++ {"d,E", nios2_assemble_args_d},
++ {"b", nios2_assemble_args_b},
++ {"b,E", nios2_assemble_args_b}
++};
++
++#define NIOS2_NUM_ARGS \
++ ((sizeof(nios2_arg_info_structs)/sizeof(nios2_arg_info_structs[0])))
++const int nios2_num_arg_info_structs = NIOS2_NUM_ARGS;
++
++
++const nios2_ps_insn_infoS nios2_ps_insn_info_structs[] = {
++ /* pseudo-op real-op arg arg_modifier_func num index */
++ {"mov", "add", "zero", nios2_append_arg, 1, 3},
++ {"movi", "addi", "zero", nios2_insert_arg, 1, 2},
++ {"movhi", "orhi", "zero", nios2_insert_arg, 1, 2},
++ {"movui", "ori", "zero", nios2_insert_arg, 1, 2},
++ {"movia", "orhi", "zero", nios2_insert_arg, 1, 2},
++ {"nop", "add", "zero", nios2_append_arg, 3, 1},
++ {"bgt", "blt", "", nios2_swap_args, 1, 2},
++ {"bgtu", "bltu", "", nios2_swap_args, 1, 2},
++ {"ble", "bge", "", nios2_swap_args, 1, 2},
++ {"bleu", "bgeu", "", nios2_swap_args, 1, 2},
++ {"cmpgt", "cmplt", "", nios2_swap_args, 2, 3},
++ {"cmpgtu", "cmpltu", "", nios2_swap_args, 2, 3},
++ {"cmple", "cmpge", "", nios2_swap_args, 2, 3},
++ {"cmpleu", "cmpgeu", "", nios2_swap_args, 2, 3},
++ {"cmpgti", "cmpgei", "+1", nios2_modify_arg, 0, 3},
++ {"cmpgtui", "cmpgeui", "+1", nios2_modify_arg, 0, 3},
++ {"cmplei", "cmplti", "+1", nios2_modify_arg, 0, 3},
++ {"cmpleui", "cmpltui", "+1", nios2_modify_arg, 0, 3},
++ {"subi", "addi", "", nios2_negate_arg, 0, 3}
++ /* add further pseudo-ops here */
++};
++
++#define NIOS2_NUM_PSEUDO_INSNS \
++ ((sizeof(nios2_ps_insn_info_structs)/sizeof(nios2_ps_insn_info_structs[0])))
++const int nios2_num_ps_insn_info_structs = NIOS2_NUM_PSEUDO_INSNS;
++
++/* special relocation directive strings */
++
++struct nios2_special_relocS
++{
++ const char *string;
++ bfd_reloc_code_real_type reloc_type;
++};
++
++struct nios2_special_relocS nios2_special_reloc[] = {
++ {"%hiadj", BFD_RELOC_NIOS2_HIADJ16},
++ {"%hi", BFD_RELOC_NIOS2_HI16},
++ {"%lo", BFD_RELOC_NIOS2_LO16},
++ {"%gprel", BFD_RELOC_NIOS2_GPREL}
++};
++
++#define NIOS2_NUM_SPECIAL_RELOCS \
++ (sizeof(nios2_special_reloc)/sizeof(nios2_special_reloc[0]))
++const int nios2_num_special_relocs = NIOS2_NUM_SPECIAL_RELOCS;
++
++/*
++ The function nios2_modify_arg appends the string modifier to the string contained
++ in the argument at index in the array parsedArgs[]
++*/
++void
++nios2_modify_arg (const char *modifier,
++ char **parsedArgs, int unused ATTRIBUTE_UNUSED, int index)
++{
++ assert (index < NIOS2_MAX_INSN_TOKENS);
++
++/*
++ we can't just strcat here because strcat will free the memory pointed to by the first
++ argument and allocate new memory - but at this stage, parsedArgs[index] may point into
++ the middle of a block of allocated memory, so trying to free it will cause a seg fault.
++
++ */
++ char *tmp = parsedArgs[index];
++ parsedArgs[index] =
++ (char *) malloc (strlen (parsedArgs[index]) + strlen (modifier) + 1);
++ strcpy (parsedArgs[index], tmp);
++ strcat (parsedArgs[index], modifier);
++}
++
++
++void
++nios2_negate_arg (const char *modifier ATTRIBUTE_UNUSED,
++ char **parsedArgs, int unused ATTRIBUTE_UNUSED, int index)
++{
++ char *tmp = parsedArgs[index];
++ parsedArgs[index] =
++ (char *) malloc (strlen ("~(") + strlen (parsedArgs[index]) +
++ strlen (")+1") + 1);
++
++ strcpy (parsedArgs[index], "~(");
++ strcat (parsedArgs[index], tmp);
++ strcat (parsedArgs[index], ")+1");
++}
++
++/*
++ The function nios2_swap_args swaps the pointers at indices index_1 and
++ index_2 in the array parsedArgs[] - this is used for operand swapping
++ for comparison operations
++ */
++void
++nios2_swap_args (const char *unused ATTRIBUTE_UNUSED,
++ char **parsedArgs, int index_1, int index_2)
++{
++ char *tmp;
++ assert (index_1 < NIOS2_MAX_INSN_TOKENS && index_2 < NIOS2_MAX_INSN_TOKENS);
++ tmp = parsedArgs[index_1];
++ parsedArgs[index_1] = parsedArgs[index_2];
++ parsedArgs[index_2] = tmp;
++}
++
++/*
++ This function appends the string append to the array of strings in
++ parsedArgs numAppend times starting at index startIndex in the array
++*/
++void
++nios2_append_arg (const char *append, char **parsedArgs, int numAppend,
++ int startIndex)
++{
++ int i, count;
++ char *tmp;
++
++ assert ((startIndex + numAppend) < NIOS2_MAX_INSN_TOKENS);
++ i = startIndex;
++ count = numAppend;
++
++ if (nios2_mode == NIOS2_MODE_TEST)
++ tmp = parsedArgs[startIndex];
++ else
++ tmp = NULL;
++
++ while (count > 0)
++ {
++ parsedArgs[i] = (char *) append;
++ ++i;
++ --count;
++ }
++
++ assert (i == (startIndex + numAppend));
++ parsedArgs[i] = tmp;
++ parsedArgs[i + 1] = NULL;
++}
++
++/* This function inserts the string insert numInsert times in the array parsedArgs,
++ starting at the index startIndex
++ */
++void
++nios2_insert_arg (const char *insert, char **parsedArgs, int numInsert,
++ int startIndex)
++{
++ int i, count, from, to;
++
++ assert ((startIndex + numInsert) < NIOS2_MAX_INSN_TOKENS);
++
++ to = startIndex + numInsert;
++ from = startIndex;
++
++ /* move the existing arguments up to create space */
++ i = NIOS2_MAX_INSN_TOKENS;
++ while ((i - numInsert) >= startIndex)
++ {
++ parsedArgs[i] = parsedArgs[i - numInsert];
++ --i;
++ }
++
++ i = startIndex;
++ count = numInsert;
++ while (count > 0)
++ {
++ parsedArgs[i] = (char *) insert;
++ ++i;
++ --count;
++ }
++}
++
++/*
++ This function swaps the pseudo-op for a real op
++ FIXME - only works for 1-to-1 correspondence
++ */
++void
++nios2_translate_pseudo_insn (nios2_insn_infoS * insn)
++{
++
++ nios2_ps_insn_infoS *ps_insn;
++
++ /* find which real insn the pseudo-op transates to and
++ switch the insn_info ptr to point to it */
++ ps_insn =
++ (nios2_ps_insn_infoS *) hash_find (nios2_ps_hash,
++ insn->insn_nios2_opcode->name);
++
++ if (ps_insn != NULL)
++ {
++ insn->insn_nios2_opcode =
++ (struct nios2_opcode *) hash_find (nios2_opcode_hash, ps_insn->insn);
++ insn->insn_tokens[0] = insn->insn_nios2_opcode->name;
++ // modify the args so they work with the real insn
++ ps_insn->arg_modifer_func (ps_insn->arg_modifier,
++ (char **) insn->insn_tokens, ps_insn->num,
++ ps_insn->index);
++ }
++ else
++ {
++ // we cannot recover from this
++ as_fatal (_("unrecognized pseudo-instruction %s"),
++ ps_insn->pseudo_insn);
++ }
++}
++
++/********************************************************************
++ The following functions are called by machine-independent parts of
++ the assembler
++ ********************************************************************/
++
++/*
++ Function : void md_parse_option
++ (char** option_ptr, int* argc_ptr, char*** argv_ptr)
++
++ Description :
++
++ */
++int
++md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
++{
++ switch (c)
++ {
++ case 'r':
++ /* hidden option for self-test mode */
++ nios2_mode = NIOS2_MODE_TEST;
++ break;
++ case OPTION_RELAX_ALL:
++ nios2_as_options.relax = relax_all;
++ break;
++ case OPTION_NORELAX:
++ nios2_as_options.relax = relax_none;
++ break;
++ case OPTION_RELAX_SECTION:
++ nios2_as_options.relax = relax_section;
++ break;
++ case OPTION_EB:
++ target_big_endian = 1;
++ break;
++ case OPTION_EL:
++ target_big_endian = 0;
++ break;
++ default:
++ return 0;
++ break;
++ }
++
++ return 1;
++}
++
++/*
++ * We can choose to be big-endian or little-endian at runtime based
++ * on a switch.
++ */
++const char *
++nios2_target_format (void)
++{
++ return target_big_endian ? "elf32-bignios2" : "elf32-littlenios2";
++}
++
++/*
++ Function : md_show_usage(FILE* stream)
++
++ Description : machine-dependent usage message
++*/
++void
++md_show_usage (FILE * stream)
++{
++ fprintf (stream, "\
++ NIOS2 options:\n\
++ -relax-all replace all branch and call instructions with jmp and callr sequences\n\
++ -relax-section replace identified out of range branches with jmp sequences (default)\n\
++ -no-relax do not replace any branches or calls\n\
++ -EB force big-endian byte ordering\n\
++ -EL force little-endian byte ordering\n");
++}
++
++/*
++ Function : void md_begin()
++
++ Description :
++ This function is called once, at assembler startup time.
++ It should set up all the tables, etc. that the MD part of the
++ assembler will need.
++*/
++void
++md_begin ()
++{
++ int i;
++ const char *inserted;
++
++ /* create and fill a hashtable for the New Jersey opcodes, registers and arguments */
++ nios2_opcode_hash = hash_new ();
++ nios2_reg_hash = hash_new ();
++ nios2_arg_hash = hash_new ();
++ nios2_ps_hash = hash_new ();
++
++ for (i = 0; i < NUMOPCODES; ++i)
++ {
++ inserted =
++ hash_insert (nios2_opcode_hash, nios2_opcodes[i].name,
++ (PTR) & nios2_opcodes[i]);
++ if (inserted != NULL)
++ {
++ fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
++ nios2_opcodes[i].name, inserted);
++ /* Probably a memory allocation problem? Give up now. */
++ as_fatal (_("Broken assembler. No assembly attempted."));
++ }
++ }
++
++ for (i = 0; i < nios2_num_regs; ++i)
++ {
++ inserted =
++ hash_insert (nios2_reg_hash, nios2_regs[i].name,
++ (PTR) & nios2_regs[i]);
++ if (inserted != NULL)
++ {
++ fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
++ nios2_regs[i].name, inserted);
++ /* Probably a memory allocation problem? Give up now. */
++ as_fatal (_("Broken assembler. No assembly attempted."));
++ }
++
++ }
++
++ for (i = 0; i < nios2_num_arg_info_structs; ++i)
++ {
++ inserted =
++ hash_insert (nios2_arg_hash, nios2_arg_info_structs[i].args,
++ (PTR) & nios2_arg_info_structs[i]);
++ if (inserted != NULL)
++ {
++ fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
++ nios2_arg_info_structs[i].args, inserted);
++ /* Probably a memory allocation problem? Give up now. */
++ as_fatal (_("Broken assembler. No assembly attempted."));
++ }
++ }
++
++ for (i = 0; i < nios2_num_ps_insn_info_structs; ++i)
++ {
++ inserted =
++ hash_insert (nios2_ps_hash, nios2_ps_insn_info_structs[i].pseudo_insn,
++ (PTR) & nios2_ps_insn_info_structs[i]);
++ if (inserted != NULL)
++ {
++ fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
++ nios2_ps_insn_info_structs[i].pseudo_insn, inserted);
++ /* Probably a memory allocation problem? Give up now. */
++ as_fatal (_("Broken assembler. No assembly attempted."));
++ }
++ }
++
++ /* assembler option defaults */
++ nios2_as_options.noat = FALSE;
++ nios2_as_options.nobreak = FALSE;
++
++ /* debug information is incompatible with relaxation */
++ if (debug_type != DEBUG_UNSPECIFIED)
++ {
++ nios2_as_options.relax = relax_none;
++ }
++
++ /* initialize the alignment data */
++ nios2_current_align_seg = now_seg;
++ nios2_last_label = NULL;
++ nios2_current_align = 0;
++}
++
++
++
++
++/* made this global to avoid changing one function prototype */
++nios2_insn_infoS insn;
++
++/*
++ Function: void md_assemble(char* op_str)
++
++ Description: assembles a single line of Nios II assembly
++ language
++ */
++void
++md_assemble (char *op_str)
++{
++ char *argstr;
++ char *op_strdup;
++ nios2_arg_infoS *arg_info;
++ unsigned long saved_pinfo = 0;
++
++ /* make sure we are aligned on a 4-byte boundary */
++ if (nios2_current_align < 2)
++ nios2_align (2, NULL, nios2_last_label);
++ else if (nios2_current_align > 2)
++ nios2_current_align = 2;
++ nios2_last_label = NULL;
++
++
++ /* we don't want to clobber to op_str
++ because we want to be able to use it in messages */
++ op_strdup = strdup (op_str);
++
++ insn.insn_tokens[0] = strtok (op_strdup, " ");
++ argstr = strtok (NULL, "");
++
++ /* assemble the opcode */
++ insn.insn_nios2_opcode =
++ (struct nios2_opcode *) hash_find (nios2_opcode_hash,
++ insn.insn_tokens[0]);
++ insn.insn_reloc = NULL;
++
++ if (insn.insn_nios2_opcode != NULL)
++ {
++ /* set the opcode for the instruction */
++ insn.insn_code = insn.insn_nios2_opcode->match;
++
++ /* parse the arguments pointed to by argstr */
++ if (nios2_mode == NIOS2_MODE_ASSEMBLE)
++ {
++ nios2_parse_args (argstr, insn.insn_nios2_opcode->args,
++ (char **) &insn.insn_tokens[1]);
++ }
++ else
++ {
++ nios2_parse_args (argstr, insn.insn_nios2_opcode->args_test,
++ (char **) &insn.insn_tokens[1]);
++ }
++
++ /* we need to preserve the MOVIA macro as this is clobbered by translate_pseudo_insn */
++ if (insn.insn_nios2_opcode->pinfo == NIOS2_INSN_MACRO_MOVIA)
++ {
++ saved_pinfo = NIOS2_INSN_MACRO_MOVIA;
++ }
++ /* if the instruction is an pseudo-instruction, we want to replace it with its
++ real equivalent, and then continue */
++ if ((insn.insn_nios2_opcode->pinfo & NIOS2_INSN_MACRO) ==
++ NIOS2_INSN_MACRO)
++ {
++ nios2_translate_pseudo_insn (&insn);
++ }
++
++ /* find the assemble function, and call it */
++ arg_info =
++ (nios2_arg_infoS *) hash_find (nios2_arg_hash,
++ insn.insn_nios2_opcode->args);
++ if (arg_info != NULL)
++ {
++ arg_info->assemble_args_func (&insn);
++
++ if (nios2_as_options.relax != relax_none
++ && insn.insn_nios2_opcode->pinfo & NIOS2_INSN_UBRANCH)
++ output_ubranch ();
++ else if (nios2_as_options.relax != relax_none
++ && insn.insn_nios2_opcode->pinfo & NIOS2_INSN_CBRANCH)
++ output_cbranch ();
++ else if (nios2_as_options.relax == relax_all
++ && insn.insn_nios2_opcode->pinfo & NIOS2_INSN_CALL)
++ output_call ();
++ else if (insn.insn_nios2_opcode->pinfo & NIOS2_INSN_ANDI)
++ output_andi ();
++ else if (insn.insn_nios2_opcode->pinfo & NIOS2_INSN_ORI)
++ output_ori ();
++ else if (insn.insn_nios2_opcode->pinfo & NIOS2_INSN_XORI)
++ output_xori ();
++ else if (insn.insn_nios2_opcode->pinfo & NIOS2_INSN_ADDI)
++ output_addi ();
++ else if (saved_pinfo == NIOS2_INSN_MACRO_MOVIA)
++ output_movia ();
++ else
++ output_insn ();
++ }
++ else
++ {
++ /* the assembler is broken */
++ fprintf (stderr,
++ _("internal error: %s is not a valid argument syntax\n"),
++ insn.insn_nios2_opcode->args);
++ /* Probably a memory allocation problem? Give up now. */
++ as_fatal (_("Broken assembler. No assembly attempted."));
++ }
++ }
++ else
++ {
++ /* unrecognised instruction - error */
++ as_bad (_("unrecognised instruction %s"), insn.insn_tokens[0]);
++ }
++}
++
++/* output a normal instruction */
++static void
++output_insn ()
++{
++ char *f;
++ nios2_insn_relocS *reloc;
++
++ f = frag_more (4);
++ /* this allocates enough space for the instruction
++ and puts it in the current frag */
++ md_number_to_chars (f, insn.insn_code, 4);
++ /* emit debug info */
++ dwarf2_emit_insn (4);
++ /* create any fixups */
++ reloc = insn.insn_reloc;
++ while (reloc != NULL)
++ {
++ /* this creates any fixups to be acted on later */
++ fix_new_exp (frag_now, f - frag_now->fr_literal, 4,
++ &reloc->reloc_expression, reloc->reloc_pcrel,
++ reloc->reloc_type);
++ reloc = reloc->reloc_next;
++ }
++}
++
++/* output an unconditional branch */
++static void
++output_ubranch ()
++{
++ char *f;
++ nios2_insn_relocS *reloc;
++ symbolS *symp;
++ offsetT offset;
++
++ reloc = insn.insn_reloc;
++
++ /* if the reloc is NULL, there was an error assembling the branch */
++ if (reloc != NULL)
++ {
++
++ symp = reloc->reloc_expression.X_add_symbol;
++ offset = reloc->reloc_expression.X_add_number;
++
++ /* we must tag debug info here since we can't do it after
++ calling frag_var */
++ dwarf2_emit_insn (4);
++
++ /* we create a machine dependent frag which can grow
++ to accommodate the largest possible instruction sequence
++ this may generate */
++ f = frag_var (rs_machine_dependent,
++ RELAX_MAX_SIZE (UBRANCH),
++ RELAX_SIZE (UBRANCH),
++ RELAX_SUBSTATE (UBRANCH), symp, offset, NULL);
++
++ md_number_to_chars (f, insn.insn_code, 4);
++
++ /* we leave fixup generation to md_convert_frag */
++ }
++}
++
++/* output a conditional branch */
++static void
++output_cbranch ()
++{
++ char *f;
++ nios2_insn_relocS *reloc;
++ symbolS *symp;
++ offsetT offset;
++
++ reloc = insn.insn_reloc;
++
++ /* if the reloc is NULL, there was an error assembling the branch */
++ if (reloc != NULL)
++ {
++
++ symp = reloc->reloc_expression.X_add_symbol;
++ offset = reloc->reloc_expression.X_add_number;
++
++ /* we must tag debug info here since we can't do it after
++ calling frag_var */
++ dwarf2_emit_insn (4);
++
++ /* we create a machine dependent frag which can grow
++ to accommodate the largest possible instruction sequence
++ this may generate */
++ f = frag_var (rs_machine_dependent,
++ RELAX_MAX_SIZE (CBRANCH),
++ RELAX_SIZE (CBRANCH),
++ RELAX_SUBSTATE (CBRANCH), symp, offset, NULL);
++
++ md_number_to_chars (f, insn.insn_code, 4);
++
++
++ /* we leave fixup generation to md_convert_frag */
++ }
++}
++
++/* Output a call sequence. Since calls are not pc-relative for NIOS2,
++ but are page-relative, we cannot tell at any stage in assembly
++ whether a call will be out of range since a section may be linked
++ at any address. So if we are relaxing, we convert all call instructions
++ to long call sequences, and rely on the linker to relax them back to
++ short calls */
++static void
++output_call ()
++{
++ char *f;
++ nios2_insn_relocS *reloc;
++ f = frag_more (12);
++ /* this allocates enough space for the instruction
++ and puts it in the current frag */
++ reloc = insn.insn_reloc;
++
++ /* if the reloc is NULL, there was an error assembling the branch */
++ if (reloc != NULL)
++ {
++ md_number_to_chars (f, OP_MATCH_ORHI | 0x00400000, 4);
++ dwarf2_emit_insn (4);
++ md_number_to_chars (f + 4, OP_MATCH_ORI | 0x08400000, 4);
++ dwarf2_emit_insn (4);
++ md_number_to_chars (f + 8, OP_MATCH_CALLR | 0x08000000, 4);
++ dwarf2_emit_insn (4);
++ fix_new (frag_now, f - frag_now->fr_literal, 4,
++ reloc->reloc_expression.X_add_symbol,
++ reloc->reloc_expression.X_add_number, 0,
++ BFD_RELOC_NIOS2_CALLR);
++
++
++ }
++}
++
++
++static int
++can_evaluate_expr ()
++{
++ /* remove this check for null and the invalid insn "ori r9, 1234" seg faults */
++ if (!insn.insn_reloc)
++ {
++ /* ??? Ideally we should do something other than as_fatal here as we can continue to assemble.
++ However this function (actually the output_* functions) should not have been called
++ in the first place once an illegal instruction had been encountered */
++ as_fatal (_("Invalid instruction encountered, cannot recover. No assembly attempted."));
++ }
++
++ if (insn.insn_reloc->reloc_expression.X_op == O_constant)
++ return 1;
++
++ return 0;
++}
++
++static int
++get_expr_value ()
++{
++ int value = 0;
++ if (insn.insn_reloc->reloc_expression.X_op == O_constant)
++ value = insn.insn_reloc->reloc_expression.X_add_number;
++ return value;
++}
++
++/* output an addi - will silently convert to
++ * orhi if rA = r0 and (expr & 0xffff0000) == 0 */
++static void
++output_addi ()
++{
++ int expr_val = 0;
++ if (can_evaluate_expr ())
++ {
++ expr_val = get_expr_value ();
++ if (GET_INSN_FIELD (RRS, insn.insn_code) == 0 &&
++ (expr_val & 0xffff) == 0 && expr_val != 0)
++ {
++
++ /* we really want a movhi (orhi) here */
++ insn.insn_code = (insn.insn_code & ~OP_MATCH_ADDI) | OP_MATCH_ORHI;
++ insn.insn_reloc->reloc_expression.X_add_number =
++ (insn.insn_reloc->reloc_expression.X_add_number >> 16) & 0xffff;
++ insn.insn_reloc->reloc_type = BFD_RELOC_NIOS2_U16;
++ }
++ }
++
++ /* output an instruction */
++ output_insn ();
++}
++
++static void
++output_andi ()
++{
++ int expr_val = 0;
++ if (can_evaluate_expr ())
++ {
++ expr_val = get_expr_value ();
++ if (expr_val != 0 && (expr_val & 0xffff) == 0)
++ {
++ /* we really want a movhi (orhi) here */
++ insn.insn_code = (insn.insn_code & ~OP_MATCH_ANDI) | OP_MATCH_ANDHI;
++ insn.insn_reloc->reloc_expression.X_add_number =
++ (insn.insn_reloc->reloc_expression.X_add_number >> 16) & 0xffff;
++ insn.insn_reloc->reloc_type = BFD_RELOC_NIOS2_U16;
++ }
++ }
++
++ /* output an instruction */
++ output_insn ();
++}
++
++static void
++output_ori ()
++{
++ int expr_val = 0;
++ if (can_evaluate_expr ())
++ {
++ expr_val = get_expr_value ();
++ if (expr_val != 0 && (expr_val & 0xffff) == 0)
++ {
++ /* we really want a movhi (orhi) here */
++ insn.insn_code = (insn.insn_code & ~OP_MATCH_ORI) | OP_MATCH_ORHI;
++ insn.insn_reloc->reloc_expression.X_add_number =
++ (insn.insn_reloc->reloc_expression.X_add_number >> 16) & 0xffff;
++ insn.insn_reloc->reloc_type = BFD_RELOC_NIOS2_U16;
++ }
++ }
++
++ /* output an instruction */
++ output_insn ();
++}
++
++static void
++output_xori ()
++{
++ int expr_val = 0;
++ if (can_evaluate_expr ())
++ {
++ expr_val = get_expr_value ();
++ if (expr_val != 0 && (expr_val & 0xffff) == 0)
++ {
++ /* we really want a movhi (orhi) here */
++ insn.insn_code = (insn.insn_code & ~OP_MATCH_XORI) | OP_MATCH_XORHI;
++ insn.insn_reloc->reloc_expression.X_add_number =
++ (insn.insn_reloc->reloc_expression.X_add_number >> 16) & 0xffff;
++ insn.insn_reloc->reloc_type = BFD_RELOC_NIOS2_U16;
++ }
++ }
++
++ /* output an instruction */
++ output_insn ();
++}
++
++
++/* output a movhi/addi pair for the movia pseudo-op */
++static void
++output_movia ()
++{
++ char *f;
++ nios2_insn_relocS *reloc;
++ f = frag_more (8);
++ unsigned long reg_index = GET_INSN_FIELD (IRT, insn.insn_code);
++
++ /* this allocates enough space for the instruction
++ and puts it in the current frag */
++ reloc = insn.insn_reloc;
++
++ /* if the reloc is NULL, there was an error assembling the movia */
++ if (reloc != NULL)
++ {
++ md_number_to_chars (f, insn.insn_code, 4);
++ dwarf2_emit_insn (4);
++ md_number_to_chars (f + 4,
++ OP_MATCH_ADDI | (reg_index << OP_SH_IRT) |
++ (reg_index << OP_SH_IRS), 4);
++ dwarf2_emit_insn (4);
++ fix_new (frag_now, f - frag_now->fr_literal, 4,
++ reloc->reloc_expression.X_add_symbol,
++ reloc->reloc_expression.X_add_number, 0,
++ BFD_RELOC_NIOS2_HIADJ16);
++ fix_new (frag_now, f + 4 - frag_now->fr_literal, 4,
++ reloc->reloc_expression.X_add_symbol,
++ reloc->reloc_expression.X_add_number, 0, BFD_RELOC_NIOS2_LO16);
++
++ }
++}
++
++/*
++ Function md_chars_to_number takes the sequence of
++ bytes in buf and returns the corresponding value
++ in an int. n must be 1, 2 or 4.
++ */
++valueT
++md_chars_to_number (char *buf, int n)
++{
++ int i;
++ valueT val;
++
++ assert (n == 1 || n == 2 || n == 4);
++
++ val = 0;
++ if (target_big_endian)
++ {
++ for (i = 0; i < n; ++i)
++ {
++ val = val | ((buf[i] & 0xff) << 8 * (n - (i + 1)));
++ }
++ }
++ else
++ {
++ for (i = 0; i < n; ++i)
++ {
++ val = val | ((buf[i] & 0xff) << 8 * i);
++ }
++ }
++ return val;
++}
++
++
++/*
++ Function : void md_number_to_chars(char *buf, valueT val, int n)
++
++ Description : this function turns a C long int, short int or char
++ into the series of bytes that represent the number
++ on the target machine
++ */
++void
++md_number_to_chars (char *buf, valueT val, int n)
++{
++ assert (n == 1 || n == 2 || n == 4);
++ if (target_big_endian)
++ {
++ number_to_chars_bigendian (buf, val, n);
++ }
++ else
++ {
++ number_to_chars_littleendian (buf, val, n);
++ }
++}
++
++/*
++ Function : void md_number_to_imm(char *buf, valueT val, int n)
++
++ Description : this function is identical to md_number_to_chars
++ */
++void
++md_number_to_imm (char *buf, valueT val, int n)
++{
++ md_number_to_chars (buf, val, n);
++}
++
++/*
++ Function : void md_number_to_disp(char *buf, valueT val, int n)
++
++ Description : this function is identical to md_number_to_chars
++ */
++void
++md_number_to_disp (char *buf, valueT val, int n)
++{
++ md_number_to_chars (buf, val, n);
++}
++
++/*
++ Function : void md_number_to_field(char *buf, valueT val, int n)
++
++ Description : this function is identical to md_number_to_chars
++ */
++void
++md_number_to_field (char *buf, valueT val, int n)
++{
++ md_number_to_chars (buf, val, n);
++}
++
++/*
++
++ Function : char * md_atof(int type, char *litP,int *sizeP)
++
++ Description :
++ Turn a string in input_line_pointer into a floating point constant
++ of type TYPE, and store the appropriate bytes in *LITP. The number
++ of LITTLENUMS emitted is stored in *SIZEP. An error message is
++ returned, or NULL on OK.
++
++ */
++
++char *
++md_atof (int type, char *litP, int *sizeP)
++{
++ int prec;
++ LITTLENUM_TYPE words[4];
++ char *t;
++ int i;
++
++ switch (type)
++ {
++ case 'f':
++ prec = 2;
++ break;
++ case 'd':
++ prec = 4;
++ break;
++ default:
++ *sizeP = 0;
++ return _("bad call to md_atof");
++ }
++
++ t = atof_ieee (input_line_pointer, type, words);
++ if (t)
++ input_line_pointer = t;
++
++ *sizeP = prec * 2;
++
++ if (! target_big_endian)
++ {
++ for (i = prec - 1; i >= 0; i--)
++ {
++ md_number_to_chars (litP, (valueT) words[i], 2);
++ litP += 2;
++ }
++ }
++ else
++ {
++ for (i = 0; i < prec; i++)
++ {
++ md_number_to_chars (litP, (valueT) words[i], 2);
++ litP += 2;
++ }
++ }
++
++ return NULL;
++}
++
++
++
++int md_short_jump_size;
++int md_long_jump_size;
++
++void
++md_create_short_jump (char *result_ptr ATTRIBUTE_UNUSED,
++ addressT from_addr ATTRIBUTE_UNUSED,
++ addressT to_addr ATTRIBUTE_UNUSED,
++ fragS * frag ATTRIBUTE_UNUSED,
++ symbolS * to_symbol ATTRIBUTE_UNUSED)
++{
++ abort ();
++}
++
++void
++md_create_long_jump (char *ptr ATTRIBUTE_UNUSED,
++ addressT from_addr ATTRIBUTE_UNUSED,
++ addressT to_addr ATTRIBUTE_UNUSED,
++ fragS * frag ATTRIBUTE_UNUSED,
++ symbolS * to_symbol ATTRIBUTE_UNUSED)
++{
++ abort ();
++}
++
++int
++md_estimate_size_before_relax (fragS * fragp, segT segment ATTRIBUTE_UNUSED)
++{
++ /* we only support ELF targets */
++
++ switch (nios2_as_options.relax)
++ {
++ case relax_none:
++ case relax_section:
++ break;
++ case relax_all:
++ /* The NIOS2 linker performs relaxation so the assembler
++ always assumes the worst case, so that the linker can
++ replace with a better case if possible - this way, linker
++ relaxation can never cause a short branch to be out of range
++ */
++ while (nios2_relax_table[fragp->fr_subtype].rlx_more != 0)
++ fragp->fr_subtype = nios2_relax_table[fragp->fr_subtype].rlx_more;
++ break;
++ default:
++ abort ();
++ break;
++ }
++
++ /* return the estimated size of the frag */
++ return nios2_relax_table[fragp->fr_subtype].rlx_length;
++}
++
++
++void
++md_convert_frag (bfd * headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED,
++ fragS * fragp)
++{
++ unsigned char *buffer = fragp->fr_literal + fragp->fr_fix;
++ relax_substateT subtype = fragp->fr_subtype;
++ unsigned int growth = RELAX_SIZE (subtype);
++ unsigned int br_opcode, br_op_a, br_op_b;
++
++ switch (subtype)
++ {
++ case UBRANCH:
++ /* we just need to generate the fixup for the symbol and offset */
++ fix_new (fragp, fragp->fr_fix, 4, fragp->fr_symbol, fragp->fr_offset, 1,
++ BFD_RELOC_16_PCREL);
++ break;
++ case UJMP:
++ /* replace ubranch at fr_fix with :
++ movhi at, %hi(symbol+offset)
++ ori at, %lo(symbol+offset)
++ jmp at
++ */
++ md_number_to_chars (buffer, OP_MATCH_ORHI | 0x00400000, 4);
++ md_number_to_chars (buffer + 4, OP_MATCH_ORI | 0x08400000, 4);
++ md_number_to_chars (buffer + 8, OP_MATCH_JMP | 0x08000000, 4);
++ fix_new (fragp, fragp->fr_fix, 4, fragp->fr_symbol, fragp->fr_offset, 0,
++ BFD_RELOC_NIOS2_UJMP);
++ break;
++ case CBRANCH:
++ /* we just need to generate the fixup for the symbol and offset */
++ fix_new (fragp, fragp->fr_fix, 4, fragp->fr_symbol, fragp->fr_offset, 1,
++ BFD_RELOC_16_PCREL);
++ break;
++ case CJMP:
++ /* replace cbranch at fr_fix with :
++ b(opposite condition) r, s, skip
++ movhi at, %hi(symbol+offset)
++ ori at, %lo(symbol+offset)
++ jmp at
++ skip:
++ ...
++ */
++ br_opcode = md_chars_to_number (buffer, 4);
++
++ switch (br_opcode & OP_MASK_OP)
++ {
++ case OP_MATCH_BEQ:
++ br_opcode =
++ (br_opcode & ~OP_MASK_OP) | OP_MATCH_BNE | (12 << OP_SH_IMM16);
++ break;
++ case OP_MATCH_BNE:
++ br_opcode =
++ (br_opcode & ~OP_MASK_OP) | OP_MATCH_BEQ | (12 << OP_SH_IMM16);
++ break;
++ case OP_MATCH_BGE:
++ case OP_MATCH_BGEU:
++ case OP_MATCH_BLT:
++ case OP_MATCH_BLTU:
++ /* swap the operands */
++ br_op_a = (br_opcode & OP_MASK_RRT) << 5;
++ br_op_b = (br_opcode & OP_MASK_RRS) >> 5;
++ br_opcode =
++ (br_opcode & ~(OP_MASK_RRS | OP_MASK_RRT)) | br_op_a | br_op_b |
++ (12 << OP_SH_IMM16);
++ break;
++ default:
++ as_bad_where (fragp->fr_file, fragp->fr_line,
++ _("expecting conditional branch for relaxation\n"));
++ abort ();
++ }
++
++ md_number_to_chars (buffer, br_opcode, 4);
++ md_number_to_chars (buffer + 4, OP_MATCH_ORHI | 0x00400000, 4);
++ md_number_to_chars (buffer + 8, OP_MATCH_ORI | 0x08400000, 4);
++ md_number_to_chars (buffer + 12, OP_MATCH_JMP | 0x08000000, 4);
++ fix_new (fragp, fragp->fr_fix + 4, 4, fragp->fr_symbol,
++ fragp->fr_offset, 0, BFD_RELOC_NIOS2_CJMP);
++ break;
++ default:
++ as_bad_where (fragp->fr_file, fragp->fr_line,
++ _("can't relax instruction\n"));
++ abort ();
++ break;
++ }
++
++ fragp->fr_fix += growth;
++}
++
++
++/* round up section size */
++valueT
++md_section_align (asection * seg ATTRIBUTE_UNUSED, valueT size)
++{
++ /* I think byte alignment is fine here */
++ return size;
++}
++
++
++int
++nios2_force_relocation (fixS * fixp)
++{
++ if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
++ || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY
++ || fixp->fx_r_type == BFD_RELOC_NIOS2_ALIGN)
++ return 1;
++
++ return 0;
++}
++
++/* nios2_fix_adjustable is called to see whether a reloc against a defined symbol
++ should be converted into a reloc against a section. */
++
++int
++nios2_fix_adjustable (fixS * fixp)
++{
++#ifdef OBJ_ELF
++ /* Prevent all adjustments to global symbols. */
++ if (OUTPUT_FLAVOR == bfd_target_elf_flavour
++ && (S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy)))
++ return 0;
++#endif
++ if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
++ || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
++ return 0;
++
++ return 1;
++}
++
++/*
++ nios2_frob_symbol is called in adjust_reloc_syms through the macro
++ tc_frob_symbol - it is used to remove *ABS* references from the
++ symbol table
++ */
++int
++nios2_frob_symbol (symbolS * symp)
++{
++ if ((OUTPUT_FLAVOR == bfd_target_elf_flavour
++ && (symp) == section_symbol (absolute_section))
++ || !S_IS_DEFINED (symp))
++ return 1;
++ else
++ return 0;
++}
++
++/*
++ The function tc_gen_reloc creates a relocation structure for the
++ fixup fixp, and returns a pointer to it. This structure is passed
++ to bfd_install_relocation so that it can be written to the object
++ file for linking
++*/
++arelent *
++tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
++{
++ arelent *reloc;
++ reloc = (arelent *) xmalloc (sizeof (arelent));
++ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
++ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
++
++ reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
++ reloc->addend = fixp->fx_addnumber;
++ reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
++ if (reloc->howto == NULL)
++ {
++ as_bad_where (fixp->fx_file, fixp->fx_line,
++ _("can't represent relocation type %s"),
++ bfd_get_reloc_code_name (fixp->fx_r_type));
++
++ /* Set howto to a garbage value so that we can keep going. */
++ reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
++ assert (reloc->howto != NULL);
++ }
++ return reloc;
++}
++
++long
++md_pcrel_from (fixS * fixP ATTRIBUTE_UNUSED)
++{
++ return 0;
++}
++
++
++/* Apply a fixup to the object file. */
++void
++md_apply_fix3 (fixS * fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
++{
++ const struct nios2_opcode *opcode;
++ enum overflow_type overflow_msg_type;
++ bfd_boolean overflowed = FALSE;
++ valueT fixup = 0;
++
++ /* assert that the fixup is one we can handle */
++ assert (fixP != NULL && valP != NULL &&
++ (fixP->fx_r_type == BFD_RELOC_8 ||
++ fixP->fx_r_type == BFD_RELOC_16 ||
++ fixP->fx_r_type == BFD_RELOC_32 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_S16 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_U16 ||
++ fixP->fx_r_type == BFD_RELOC_16_PCREL ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_CALL26 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_IMM5 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_CACHE_OPX ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_IMM6 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_IMM8 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_HI16 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_LO16 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_HIADJ16 ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_GPREL ||
++ fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT ||
++ fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_UJMP ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_CJMP ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_CALLR ||
++ fixP->fx_r_type == BFD_RELOC_NIOS2_ALIGN
++ // add other relocs here as we generate them
++ ));
++
++
++ /* The value passed in valP can be the value of a fully
++ resolved expression, or it can be the value of a partially
++ resolved expression. In the former case, both fixP->fx_addsy
++ and fixP->fx_subsy are NULL, and fixP->fx_offset == *valP, and
++ we can fix up the instruction that fixP relates to.
++ In the latter case, one or both of fixP->fx_addsy and
++ fixP->fx_subsy are not NULL, and fixP->fx_offset may or may not
++ equal *valP. We don't need to check for fixP->fx_subsy being null
++ because the generic part of the assembler generates an error if
++ it is not an absolute symbol */
++
++ if (fixP->fx_addsy != NULL)
++ {
++ fixP->fx_addnumber = fixP->fx_offset;
++ fixP->fx_done = 0;
++ }
++ else
++ {
++ valueT value;
++
++ char *buf;
++ reloc_howto_type *howto;
++ howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
++
++ if (howto == NULL)
++ {
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _("relocation is not supported"));
++ }
++ else
++ {
++ fixup += *valP;
++
++ /* If this is a pc-relative relocation, we need to
++ subtract the current offset within the object file
++ FIXME : for some reason fixP->fx_pcrel isn't 1 when it should be
++ so I'm using the howto structure instead to determine this */
++ if (howto->pc_relative == 1)
++ fixup = fixup - (fixP->fx_frag->fr_address + fixP->fx_where + 4);
++
++
++
++ /* Get the instruction to be fixed up */
++ buf = fixP->fx_frag->fr_literal + fixP->fx_where;
++ value = md_chars_to_number (buf, 4);
++
++ /* What opcode is the instruction? This will determine
++ whether we check for overflow in immediate values
++ and what error message we get */
++ opcode = nios2_find_opcode_hash (value);
++ overflow_msg_type = opcode->overflow_msg;
++
++ overflowed = nios2_check_overflow (fixup, howto);
++
++
++ if (overflowed)
++ {
++ unsigned int range_min;
++ unsigned int range_max;
++ unsigned int address;
++ switch (overflow_msg_type)
++ {
++ case call_target_overflow:
++ range_min =
++ ((fixP->fx_frag->fr_address +
++ fixP->fx_where) & 0xf0000000);
++ range_max = range_min + 0x0fffffff;
++ address = fixup | range_min;
++
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[call_target_overflow]),
++ address, range_min, range_max);
++ break;
++ case branch_target_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[branch_target_overflow]),
++ fixup, BYTE_B, BYTE_F);
++ break;
++ case address_offset_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[address_offset_overflow]),
++ opcode->name, fixup, -32768, 32767);
++ break;
++ case signed_immed16_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[signed_immed16_overflow]),
++ fixup, -32768, 32767);
++ break;
++ case unsigned_immed16_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[unsigned_immed16_overflow]),
++ fixup, 0, 65535);
++ break;
++ case unsigned_immed5_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[unsigned_immed5_overflow]),
++ fixup, 0, 31);
++ break;
++ case custom_opcode_overflow:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _(overflow_msgs[custom_opcode_overflow]),
++ fixup, 0, 255);
++ break;
++ default:
++ as_bad_where (fixP->fx_file, fixP->fx_line,
++ _
++ ("unspecified overflow in immediate argument"));
++ break;
++ }
++ }
++
++
++ /* apply the rightshift */
++ fixup >>= howto->rightshift;
++
++ /* truncate the fixup to right size */
++ switch (fixP->fx_r_type)
++ {
++ case BFD_RELOC_NIOS2_HI16:
++ fixup = (fixup >> 16) & 0xFFFF;
++ break;
++ case BFD_RELOC_NIOS2_LO16:
++ fixup = fixup & 0xFFFF;
++ break;
++ case BFD_RELOC_NIOS2_HIADJ16:
++ fixup = ((fixup >> 16) & 0xFFFF) + ((fixup >> 15) & 0x01);
++ break;
++ default:
++ fixup =
++ (fixup << (32 - howto->bitsize)) >> (32 - howto->bitsize);
++ break;
++ }
++
++ /* fixup the instruction */
++ value = (value & ~howto->dst_mask) | (fixup << howto->bitpos);
++ md_number_to_chars (buf, value, 4);
++ }
++
++ fixP->fx_done = 1;
++ }
++
++ if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
++ {
++ fixP->fx_done = 0;
++ if (fixP->fx_addsy
++ && !S_IS_DEFINED (fixP->fx_addsy) && !S_IS_WEAK (fixP->fx_addsy))
++ S_SET_WEAK (fixP->fx_addsy);
++ }
++ else if (fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
++ {
++ fixP->fx_done = 0;
++ }
++}
++
++bfd_boolean
++nios2_check_overflow (valueT fixup, reloc_howto_type * howto)
++{
++ /* apply the rightshift before checking for overflow */
++ fixup >>= howto->rightshift;
++
++ /* check for overflow - return TRUE if overflow, FALSE if not */
++ switch (howto->complain_on_overflow)
++ {
++ case complain_overflow_dont:
++ break;
++ case complain_overflow_bitfield:
++ if ((fixup >> howto->bitsize) != 0)
++ return TRUE;
++ break;
++ case complain_overflow_signed:
++ if ((fixup & 0x80000000) > 0)
++ {
++ /* check for negative overflow */
++ if ((signed) fixup < ((signed) 0x80000000 >> howto->bitsize))
++ return TRUE;
++ }
++ else
++ {
++ /* check for positive overflow */
++ if (fixup >= ((unsigned) 1 << (howto->bitsize - 1)))
++ return TRUE;
++ }
++ break;
++ case complain_overflow_unsigned:
++ if ((fixup >> howto->bitsize) != 0)
++ return TRUE;
++ break;
++ default:
++ as_bad (_("error checking for overflow - broken assembler"));
++ break;
++ }
++
++ return FALSE;
++}
++
++/*
++ Function : void md_end()
++ Description : Called just before the assembler exits
++ */
++void
++md_end ()
++{
++ /* FIXME - not yet implemented */
++}
++
++
++/*
++ Creates a new nios2_insn_relocS and returns a pointer to it
++*/
++nios2_insn_relocS *
++nios2_insn_reloc_new (bfd_reloc_code_real_type reloc_type, unsigned int pcrel)
++{
++ nios2_insn_relocS *retval;
++ retval = (nios2_insn_relocS *) malloc (sizeof (nios2_insn_relocS));
++ if (retval == NULL)
++ {
++ as_bad (_("can't create relocation"));
++ abort ();
++ }
++
++ /* fill out the fields with default values */
++ retval->reloc_next = NULL;
++ retval->reloc_type = reloc_type;
++ retval->reloc_pcrel = pcrel;
++ return retval;
++}
++
++/*
++ Frees up memory previously allocated by nios2_insn_reloc_new()
++ */
++void
++nios2_insn_reloc_destroy (nios2_insn_relocS * reloc)
++{
++ assert (reloc != NULL);
++ free (reloc);
++}
++
++/*
++ Function : nios2_assemble_expression(char* exprstr)
++
++ Description : The various nios2_assemble_* functions call this
++ function to generate an expression from a
++ string representing an expression
++ It then tries to evaluate the expression, and
++ if it can, returns its value.
++ If not, it creates a new nios2_insn_relocS
++ and stores the expression and reloc_type
++ for future use
++ */
++unsigned long
++nios2_assemble_expression (const char *exprstr,
++ nios2_insn_infoS * insn,
++ nios2_insn_relocS * prev_reloc,
++ bfd_reloc_code_real_type reloc_type,
++ unsigned int pcrel)
++{
++ nios2_insn_relocS *reloc;
++ char *saved_line_ptr;
++ unsigned short value;
++ int i;
++
++ assert (exprstr != NULL);
++ assert (insn != NULL);
++
++ /* check for %gprel, %hi, %lo or %hiadj
++ change the relocation type
++ and advance the ptr to the start of
++ the expression proper */
++ for (i = 0; i < nios2_num_special_relocs; i++)
++ {
++ if (strstr (exprstr, nios2_special_reloc[i].string) != NULL)
++ {
++ reloc_type = nios2_special_reloc[i].reloc_type;
++ exprstr += strlen (nios2_special_reloc[i].string) + 1;
++ break;
++ }
++ }
++
++ /* we potentially have a relocation */
++ reloc = nios2_insn_reloc_new (reloc_type, pcrel);
++ if (prev_reloc != NULL)
++ prev_reloc->reloc_next = reloc;
++ else
++ insn->insn_reloc = reloc;
++
++ /* parse the expression string */
++ saved_line_ptr = input_line_pointer;
++ input_line_pointer = (char *) exprstr;
++ expression (&reloc->reloc_expression);
++ input_line_pointer = saved_line_ptr;
++
++ /* this is redundant as the fixup will put this into
++ the instruction, but it is included here so that
++ self-test mode (-r) works */
++ value = 0;
++ if (nios2_mode == NIOS2_MODE_TEST)
++ {
++ if (reloc->reloc_expression.X_op == O_constant)
++ value = reloc->reloc_expression.X_add_number;
++ }
++
++ return (unsigned long) value;
++}
++
++/*
++ The function consume_separate takes a pointer into a string
++ of instruction tokens (args) and a pointer into a string representing
++ the expected sequence of tokens and separators. It finds the first
++ instance of the character pointed to by separator in argStr, and
++ returns a pointer to the next element of argStr, which is the
++ following token in the sequence.
++ */
++char *
++nios2_consume_separator (char *argStr, const char *separator)
++{
++ char *argPtr;
++
++ /* if we have a opcode reg, expr(reg) type instruction, and
++ * we are separating the expr from the (reg), we find the last
++ * (, just in case the expression has brackets */
++
++ if (*separator == '(')
++ argPtr = strrchr (argStr, *separator);
++ else
++ argPtr = strchr (argStr, *separator);
++
++ if (argPtr != NULL)
++ *argPtr++ = 0;
++ else
++ as_bad (_("expecting %c near %s"), *separator, argStr);
++ return argPtr;
++}
++
++/*
++ The function consume_arg takes a pointer into a string
++ of instruction tokens (args) and a pointer into a string
++ representing the expected sequence of tokens and separators.
++ It checks whether the first argument in argStr is of the
++ expected type, throwing an error if it is not, and returns
++ the pointer argStr.
++ */
++char *
++nios2_consume_arg (char *argStr, const char *argType)
++{
++ char *temp;
++ int regno = -1;
++
++ switch (*argType)
++ {
++ case 'c':
++ if (strncmp (argStr, "ctl", strlen ("ctl")) != 0
++ && strncmp (argStr, "cpuid", strlen ("cpuid")) != 0
++ && strncmp (argStr, "status", strlen ("status")) != 0
++ && strncmp (argStr, "estatus", strlen ("estatus")) != 0
++ && strncmp (argStr, "bstatus", strlen ("bstatus")) != 0
++ && strncmp (argStr, "ienable", strlen ("ienable")) != 0
++ && strncmp (argStr, "ipending", strlen ("ipending")) != 0
++ && strncmp (argStr, "pteaddr", strlen ("pteaddr")) != 0
++ && strncmp (argStr, "tlbacc", strlen ("tlbacc")) != 0
++ && strncmp (argStr, "tlbmisc", strlen ("tlbmisc")) != 0
++ && strncmp (argStr, "fstatus", strlen ("fstatus")) != 0)
++ {
++ as_bad (_("expecting control register"));
++ }
++ break;
++ case 'd':
++ case 's':
++ case 't':
++
++ /* we check to make sure we don't have a control register */
++ if (strncmp (argStr, "ctl", strlen ("ctl")) == 0
++ || strncmp (argStr, "cpuid", strlen ("cpuid")) == 0
++ || strncmp (argStr, "status", strlen ("status")) == 0
++ || strncmp (argStr, "estatus", strlen ("estatus")) == 0
++ || strncmp (argStr, "bstatus", strlen ("bstatus")) == 0
++ || strncmp (argStr, "ienable", strlen ("ienable")) == 0
++ || strncmp (argStr, "ipending", strlen ("ipending")) == 0
++ || strncmp (argStr, "pteaddr", strlen ("pteaddr")) == 0
++ || strncmp (argStr, "tlbacc", strlen ("tlbacc")) == 0
++ || strncmp (argStr, "tlbmisc", strlen ("tlbmisc")) == 0
++ || strncmp (argStr, "fstatus", strlen ("fstatus")) == 0)
++ {
++ as_bad (_("illegal use of control register"));
++ }
++
++ /* and whether coprocessor registers are valid here */
++ if (nios2_coproc_reg (argStr)
++ && insn.insn_nios2_opcode->match != OP_MATCH_CUSTOM)
++ {
++ as_bad (_("illegal use of coprocessor register\n"));
++ }
++
++
++ /* extract a register number if the register is of the
++ form r[0-9]+, if it is a normal register, set
++ regno to its number (0-31), else set regno to -1 */
++ if (argStr[0] == 'r' && ISDIGIT (argStr[1]))
++ {
++ char *p = argStr;
++
++ ++p;
++ regno = 0;
++ do
++ {
++ regno *= 10;
++ regno += *p - '0';
++ ++p;
++ }
++ while (ISDIGIT (*p));
++ }
++ else
++ {
++ regno = -1;
++ }
++
++ /* and whether we are using at */
++ if (!nios2_as_options.noat
++ && (regno == 1
++ || strncmp (argStr, "at", strlen ("at")) == 0))
++ {
++ as_warn (_("Register at (r1) can sometimes be corrupted by assembler optimizations.\n"
++ "Use .set noat to turn off those optimizations (and this warning)."));
++ }
++
++ /* and whether we are using oci registers */
++ if (!nios2_as_options.nobreak
++ && (regno == 25
++ || strncmp (argStr, "bt", strlen ("bt")) == 0))
++ {
++ as_warn (_("The debugger will corrupt bt (r25). If you don't need to debug this\n"
++ "code then use .set nobreak to turn off this warning."));
++ }
++
++ if (!nios2_as_options.nobreak
++ && (regno == 30
++ || strncmp (argStr, "ba", strlen ("ba")) == 0))
++ {
++ as_warn (_("The debugger will corrupt ba (r30). If you don't need to debug this\n"
++ "code then use .set nobreak to turn off this warning."));
++ }
++ break;
++ case 'i':
++ case 'u':
++ if (*argStr == '%')
++ {
++ if (strstr (argStr, "%hi(") || strstr (argStr, "%lo(")
++ || strstr (argStr, "%hiadj(") || strstr (argStr, "%gprel("))
++ {
++ // we zap the brackets because we don't want them confused with separators
++ temp = strchr (argStr, '(');
++ if (temp != NULL)
++ *temp = ' ';
++ temp = strchr (argStr, ')');
++ if (temp != NULL)
++ *temp = ' ';
++ }
++ else
++ {
++ as_bad (_("badly formed expression near %s"), argStr);
++ }
++ }
++ break;
++ case 'm':
++ case 'j':
++ case 'k':
++ case 'l':
++ case 'b':
++ /* we can't have %hi, %lo or %hiadj here */
++ if (*argStr == '%')
++ as_bad (_("badly formed expression near %s"), argStr);
++ break;
++ default:
++ break;
++ }
++
++#if 0
++/* ??? SPR:173865 This is actually supported by the HW but the documentation is a bit funny.
++ The compiler really want the extra register, so let it have it! */
++ /* checks for jmp 31 */
++ /* TODO: move test that insn is jmp to somewhere better.*/
++ if ((strncmp (insn.insn_nios2_opcode->name, "jmp", strlen ("jmp")) == 0)
++ && (regno == 31
++ || strncmp (argStr, "ra", strlen ("ra")) == 0))
++ {
++ as_bad (_("It is illegal to jump to the address contained in register ra (r31). "
++ "To return from subroutines called by call or callr, use ret instead of jmp."));
++ }
++#endif
++
++ return argStr;
++}
++
++/*
++ The principal argument parsing function which takes a string
++ representing the instruction arguments, and extracts the argument
++ tokens
++ */
++void
++nios2_parse_args (char *argStr, const char *parseStr, char **parsedArgs)
++{
++ char *p;
++ char *end = NULL;
++ int i;
++ p = argStr;
++ i = 0;
++ bfd_boolean terminate = FALSE;
++
++ /* This rest of this function is it too fragile and it mostly works,
++ therefore special case this one */
++ if (*parseStr == 0 && argStr != 0)
++ {
++ as_bad (_("too many arguments"));
++ parsedArgs[0] = NULL;
++ return;
++ }
++
++
++ while (p != NULL && !terminate && i < NIOS2_MAX_INSN_TOKENS)
++ {
++ parsedArgs[i] = nios2_consume_arg (p, parseStr);
++ ++parseStr;
++ if (*parseStr != '\0')
++ {
++ p = nios2_consume_separator (p, parseStr);
++ ++parseStr;
++ }
++ else
++ {
++ /* check that the argument string has no trailing arguments */
++ /* if we've got a %lo etc relocation, we've zapped the brackets with spaces */
++ if (strstr (p, "%lo") == p || strstr (p, "%hi") == p
++ || strstr (p, "%hiadj") == p || strstr (p, "%gprel") == p)
++ end = strpbrk (p, ",");
++ else
++ end = strpbrk (p, " ,");
++
++ if (end != NULL)
++ as_bad (_("too many arguments"));
++ }
++
++ if (*parseStr == '\0' || (p != NULL && *p == '\0'))
++ {
++ terminate = TRUE;
++ }
++ ++i;
++ }
++
++ parsedArgs[i] = NULL;
++
++ if (*parseStr != '\0' && insn.insn_nios2_opcode->match != OP_MATCH_BREAK)
++ as_bad (_("missing argument"));
++
++}
++
++
++/* checks whether the register name is a coprocessor
++ register - returns TRUE if it is, FALSE otherwise */
++
++static bfd_boolean
++nios2_coproc_reg (const char *reg_name)
++{
++ assert (reg_name != NULL);
++
++/* check that we do have a valid register name and that it is a
++ * coprocessor register
++ * it must begin with c, not be a control register, and be a valid
++ * register name */
++
++ if (strncmp (reg_name, "c", 1) == 0 &&
++ strncmp (reg_name, "ctl", strlen ("ctl")) != 0 &&
++ hash_find (nios2_reg_hash, reg_name) != NULL)
++ return TRUE;
++ else
++ return FALSE;
++}
++
++
++/*********************************************************************
++ Argument assemble functions
++
++ Description : All take an instruction argument string, and a pointer
++ to an instruction opcode. Upon return the insn_opcode
++ has the relevant fields filled in to represent the arg
++ string. The return value is NULL if successful, or
++ an error message if an error was detected
++ *********************************************************************/
++
++/* assembles register arguments "dst, src1, src2" */
++void
++nios2_assemble_args_dst (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1, *src2;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ src2 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[3]);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, src1->index);
++
++ if (src2 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[3]);
++ else
++ SET_INSN_FIELD (RRT, insn_info->insn_code, src2->index);
++
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++ }
++}
++
++
++/* assembles arguments successfully parsed by nios2_parse_args_tsi */
++void
++nios2_assemble_args_tsi (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1;
++ unsigned int src2;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ src2 =
++ nios2_assemble_expression (insn_info->insn_tokens[3], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_NIOS2_S16,
++ 0);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (IRT, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (IRS, insn_info->insn_code, src1->index);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, src2);
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++/* assembles args successfully parsed by nios2_parse_args_tsu */
++void
++nios2_assemble_args_tsu (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1;
++ unsigned int src2;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ src2 =
++ nios2_assemble_expression (insn_info->insn_tokens[3], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_NIOS2_U16,
++ 0);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (IRT, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (IRS, insn_info->insn_code, src1->index);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, src2);
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++/* assembles args successfully parsed by nios2_parse_args_sti */
++void
++nios2_assemble_args_sto (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1;
++ unsigned int src2;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ src2 =
++ nios2_assemble_expression (insn_info->insn_tokens[3], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_16_PCREL,
++ 1);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (IRS, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (IRT, insn_info->insn_code, src1->index);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, src2);
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++void
++nios2_assemble_args_o (nios2_insn_infoS * insn_info)
++{
++ unsigned long immed;
++
++ if (insn_info->insn_tokens[1] != NULL)
++ {
++ immed =
++ nios2_assemble_expression (insn_info->insn_tokens[1], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_16_PCREL,
++ 1);
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, immed);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++void
++nios2_assemble_args_is (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *addr_src;
++ unsigned long immed;
++
++ if (insn_info->insn_tokens[1] != NULL && insn_info->insn_tokens[2] != NULL)
++ {
++ addr_src =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++
++ immed =
++ nios2_assemble_expression (insn_info->insn_tokens[1], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_NIOS2_S16,
++ 0);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, immed);
++
++ if (addr_src == NULL)
++ as_bad (_("unknown base register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, addr_src->index);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[3]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++void
++nios2_assemble_args_m (nios2_insn_infoS * insn_info)
++{
++ unsigned long immed;
++ if (insn_info->insn_tokens[1] != NULL)
++ {
++ immed =
++ nios2_assemble_expression (insn_info->insn_tokens[1], insn_info,
++ insn_info->insn_reloc,
++ BFD_RELOC_NIOS2_CALL26, 0);
++
++ SET_INSN_FIELD (IMM26, insn_info->insn_code, immed);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++
++ SET_INSN_FIELD (IMM26, insn_info->insn_code, 0);
++ }
++}
++
++
++void
++nios2_assemble_args_s (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *src;
++
++ if (insn_info->insn_tokens[1] != NULL)
++ {
++ src =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++
++ if (src == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, src->index);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++ }
++}
++
++
++void
++nios2_assemble_args_tis (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *addr_src, *dst;
++ unsigned long immed;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ addr_src =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[3]);
++ immed =
++ nios2_assemble_expression (insn_info->insn_tokens[2], insn_info,
++ insn_info->insn_reloc, BFD_RELOC_NIOS2_S16,
++ 0);
++
++
++ if (addr_src == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[3]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, addr_src->index);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RRT, insn_info->insn_code, dst->index);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, immed);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (IMM16, insn_info->insn_code, 0);
++ }
++}
++
++
++/* assemble rdctl dst, ctl */
++void
++nios2_assemble_args_dc (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *ctl;
++
++ if (insn_info->insn_tokens[1] != NULL && insn_info->insn_tokens[2] != NULL)
++ {
++ ctl =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++
++ if (ctl == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RCTL, insn_info->insn_code, ctl->index);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[3]);
++ }
++}
++
++
++/* assemble wrctl ctl, src */
++void
++nios2_assemble_args_cs (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *src, *ctl;
++
++ if (insn_info->insn_tokens[1] != NULL && insn_info->insn_tokens[2] != NULL)
++ {
++ ctl =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++
++ if (ctl == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else if (ctl->index == 4)
++ as_bad (_("ipending control register (ctl4) is read-only\n"));
++ else
++ SET_INSN_FIELD (RCTL, insn_info->insn_code, ctl->index);
++
++ if (src == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, src->index);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[3]);
++ }
++}
++
++
++
++void
++nios2_assemble_args_ldst (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1, *src2;
++ unsigned long custom_n;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL &&
++ insn_info->insn_tokens[3] != NULL && insn_info->insn_tokens[4] != NULL)
++ {
++#if 0 /* ??? Unused/half commented out code */
++ char *end_p;
++ /* custom_n = nios2_strtoul(insn_info->insn_tokens[1], &end_p); */
++#endif
++ custom_n =
++ nios2_assemble_expression (insn_info->insn_tokens[1], insn_info,
++ insn_info->insn_reloc,
++ BFD_RELOC_NIOS2_IMM8, 0);
++
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[3]);
++ src2 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (CUSTOM_N, insn_info->insn_code, custom_n);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[3]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, src1->index);
++
++ if (src2 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[4]);
++ else
++ SET_INSN_FIELD (RRT, insn_info->insn_code, src2->index);
++
++ /* set or clear the bits to indicate whether coprocessor registers are used */
++ if (nios2_coproc_reg (insn_info->insn_tokens[2]))
++ SET_INSN_FIELD (CUSTOM_C, insn_info->insn_code, 0);
++ else
++ SET_INSN_FIELD (CUSTOM_C, insn_info->insn_code, 1);
++
++ if (nios2_coproc_reg (insn_info->insn_tokens[3]))
++ SET_INSN_FIELD (CUSTOM_A, insn_info->insn_code, 0);
++ else
++ SET_INSN_FIELD (CUSTOM_A, insn_info->insn_code, 1);
++
++ if (nios2_coproc_reg (insn_info->insn_tokens[4]))
++ SET_INSN_FIELD (CUSTOM_B, insn_info->insn_code, 0);
++ else
++ SET_INSN_FIELD (CUSTOM_B, insn_info->insn_code, 1);
++
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[5]);
++ }
++}
++
++
++void
++nios2_assemble_args_none (nios2_insn_infoS * insn_info ATTRIBUTE_UNUSED)
++{
++ // nothing to do
++}
++
++
++void
++nios2_assemble_args_dsj (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst, *src1;
++ unsigned int src2;
++
++ if (insn_info->insn_tokens[1] != NULL &&
++ insn_info->insn_tokens[2] != NULL && insn_info->insn_tokens[3] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++ src1 =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[2]);
++
++ // a 5-bit constant expression
++ src2 =
++ nios2_assemble_expression (insn_info->insn_tokens[3], insn_info,
++ insn_info->insn_reloc,
++ BFD_RELOC_NIOS2_IMM5, 0);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
++
++ if (src1 == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
++ else
++ SET_INSN_FIELD (RRS, insn_info->insn_code, src1->index);
++
++ SET_INSN_FIELD (IMM5, insn_info->insn_code, src2);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[4]);
++
++ SET_INSN_FIELD (IMM5, insn_info->insn_code, 0);
++ }
++}
++
++
++/* assembles register arguments "dst" */
++void
++nios2_assemble_args_d (nios2_insn_infoS * insn_info)
++{
++ struct nios2_reg *dst;
++
++ if (insn_info->insn_tokens[1] != NULL)
++ {
++ dst =
++ (struct nios2_reg *) hash_find (nios2_reg_hash,
++ insn_info->insn_tokens[1]);
++
++ if (dst == NULL)
++ as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
++ else
++ SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++ }
++}
++
++/* assemble break op */
++void
++nios2_assemble_args_b (nios2_insn_infoS * insn_info)
++{
++ unsigned int imm5 = 0;
++
++ if (insn_info->insn_tokens[1] != NULL)
++ {
++ // a 5-bit constant expression
++ imm5 =
++ nios2_assemble_expression (insn_info->insn_tokens[1], insn_info,
++ insn_info->insn_reloc,
++ BFD_RELOC_NIOS2_IMM5, 0);
++
++ SET_INSN_FIELD (TRAP_IMM5, insn_info->insn_code, imm5);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++ }
++
++ SET_INSN_FIELD (TRAP_IMM5, insn_info->insn_code, imm5);
++
++ NIOS2_CHECK_ASSEMBLY (insn_info->insn_code, insn_info->insn_tokens[2]);
++}
++
++/* Machine-dependent assembler directive handling follows */
++
++/*
++ .set sets assembler options eg noat/at and is also used
++ to set symbol values (.equ, .equiv )
++*/
++void
++s_nios2_set (int equiv)
++{
++ char *directive = input_line_pointer;
++ char delim = get_symbol_end ();
++ char *endline;
++ endline = input_line_pointer;
++ *endline = delim;
++
++ /* we only want to handle ".set XXX" if the
++ user has tried ".set XXX, YYY" they are not
++ trying a directive. This prevents
++ us from polluting the name space */
++
++ SKIP_WHITESPACE ();
++
++ if (is_end_of_line[(unsigned char) *input_line_pointer])
++ {
++ bfd_boolean done = FALSE;
++ *endline = 0;
++
++ if (!strcmp (directive, "noat"))
++ {
++ done = TRUE;
++ nios2_as_options.noat = TRUE;
++ }
++
++ if (!strcmp (directive, "at"))
++ {
++ done = TRUE;
++ nios2_as_options.noat = FALSE;
++ }
++
++ if (!strcmp (directive, "nobreak"))
++ {
++ done = TRUE;
++ nios2_as_options.nobreak = TRUE;
++ }
++
++ if (!strcmp (directive, "break"))
++ {
++ done = TRUE;
++ nios2_as_options.nobreak = FALSE;
++ }
++
++ if (!strcmp (directive, "norelax"))
++ {
++ done = TRUE;
++ nios2_as_options.relax = relax_none;
++ }
++ else if (!strcmp (directive, "relaxsection"))
++ {
++ done = TRUE;
++ nios2_as_options.relax = relax_section;
++ }
++ else if (!strcmp (directive, "relaxall"))
++ {
++ done = TRUE;
++ nios2_as_options.relax = relax_all;
++ }
++
++
++ if (done)
++ {
++ *endline = delim;
++ demand_empty_rest_of_line ();
++ return;
++ }
++ }
++
++
++ /* If we fall through to here, either we have ".set XXX, YYY"
++ or we have ".set XXX" where XXX is unknown or we have
++ a syntax error */
++ input_line_pointer = directive;
++ *endline = delim;
++ s_set (equiv);
++}
++
++/* nop fill pattern for text section */
++static char const nop[4] = { 0x3a, 0x88, 0x01, 0x00 };
++
++/* nios2_frob_label() is called when after a label is recognized. */
++
++void
++nios2_frob_label (symbolS * lab)
++{
++ /* Update the label's address with the current output pointer. */
++ symbol_set_frag (lab, frag_now);
++ S_SET_VALUE (lab, (valueT) frag_now_fix ());
++
++ /* Record this label for future adjustment after we find out what
++ kind of data it references, and the required alignment therewith. */
++ nios2_last_label = lab;
++}
++
++
++
++/* Hook into cons for auto-alignment. */
++
++void
++nios2_cons_align (int size)
++{
++ int log_size;
++ const char *pfill = NULL;
++
++ log_size = 0;
++ while ((size >>= 1) != 0)
++ ++log_size;
++
++ if (subseg_text_p (now_seg))
++ {
++ pfill = (const char *) &nop;
++ }
++ else
++ pfill = NULL;
++
++ if (nios2_auto_align_on)
++ nios2_align (log_size, pfill, NULL);
++
++ nios2_last_label = NULL;
++}
++
++static void
++s_nios2_sdata (int ignore ATTRIBUTE_UNUSED)
++{
++ int temp;
++
++ temp = get_absolute_expression ();
++ subseg_new (".sdata", 0);
++ demand_empty_rest_of_line ();
++}
++
++/* Map 's' to SHF_NIOS2_GPREL. */
++/* this is from the Alpha code tc-alpha.c */
++int
++nios2_elf_section_letter (int letter, char **ptr_msg)
++{
++ if (letter == 's')
++ return SHF_NIOS2_GPREL;
++
++ *ptr_msg = _("Bad .section directive: want a,s,w,x,M,S,G,T in string");
++ return 0;
++}
++
++/* Map SHF_ALPHA_GPREL to SEC_SMALL_DATA. */
++/* this is from the Alpha code tc-alpha.c */
++flagword
++nios2_elf_section_flags (flagword flags, int attr, int type ATTRIBUTE_UNUSED)
++{
++ if (attr & SHF_NIOS2_GPREL)
++ flags |= SEC_SMALL_DATA;
++ return flags;
++}
++
++/* explicitly unaligned cons */
++
++static void
++s_nios2_ucons (int nbytes)
++{
++ int hold;
++ hold = nios2_auto_align_on;
++ nios2_auto_align_on = 0;
++ cons (nbytes);
++ nios2_auto_align_on = hold;
++}
++
++/* Handles all machine-dependent alignment needs */
++static void
++nios2_align (int log_size, const char *pfill, symbolS * label)
++{
++ int align;
++ long max_alignment = 15;
++
++ /* The front end is prone to changing segments out from under us
++ temporarily when -g is in effect. */
++ int switched_seg_p = (nios2_current_align_seg != now_seg);
++
++ align = log_size;
++ if (align > max_alignment)
++ {
++ align = max_alignment;
++ as_bad (_("Alignment too large: %d. assumed"), align);
++ }
++ else if (align < 0)
++ {
++ as_warn (_("Alignment negative: 0 assumed"));
++ align = 0;
++ }
++
++ if (align != 0)
++ {
++ if (subseg_text_p (now_seg) && align >= 2)
++ {
++ /* First, make sure we're on a four-byte boundary, in case
++ someone has been putting .byte values the text section. */
++ if (nios2_current_align < 2 || switched_seg_p)
++ frag_align (2, 0, 0);
++
++ /* now fill in the alignment pattern */
++ if (pfill != NULL)
++ frag_align_pattern (align, pfill, sizeof nop, 0);
++ else
++ frag_align (align, 0, 0);
++ }
++ else
++ {
++ frag_align (align, 0, 0);
++ }
++
++ if (!switched_seg_p)
++ nios2_current_align = align;
++
++ /* If the last label was in a different section we can't align it */
++ if (label != NULL && !switched_seg_p)
++ {
++ symbolS *sym;
++ int label_seen = FALSE;
++ struct frag *old_frag;
++ valueT old_value;
++ valueT new_value;
++
++ assert (S_GET_SEGMENT (label) == now_seg);
++
++ old_frag = symbol_get_frag (label);
++ old_value = S_GET_VALUE (label);
++ new_value = (valueT) frag_now_fix ();
++
++ /* It is possible to have more than one label at a particular
++ address, especially if debugging is enabled, so we must
++ take care to adjust all the labels at this address in this
++ fragment. To save time we search from the end of the symbol
++ list, backwards, since the symbols we are interested in are
++ almost certainly the ones that were most recently added.
++ Also to save time we stop searching once we have seen at least
++ one matching label, and we encounter a label that is no longer
++ in the target fragment. Note, this search is guaranteed to
++ find at least one match when sym == label, so no special case
++ code is necessary. */
++ for (sym = symbol_lastP; sym != NULL; sym = symbol_previous (sym))
++ {
++ if (symbol_get_frag (sym) == old_frag
++ && S_GET_VALUE (sym) == old_value)
++ {
++ label_seen = TRUE;
++ symbol_set_frag (sym, frag_now);
++ S_SET_VALUE (sym, new_value);
++ }
++ else if (label_seen && symbol_get_frag (sym) != old_frag)
++ break;
++ }
++ }
++ record_alignment (now_seg, align);
++ }
++}
++
++/* This is called from HANDLE_ALIGN in tc-nios2.h. */
++
++void
++nios2_handle_align (fragS * fragp)
++{
++ /* If we are expecting to relax in the linker, then we must output a relocation
++ * to tell the linker we are aligning code */
++ if (nios2_as_options.relax == relax_all
++ && (fragp->fr_type == rs_align
++ || fragp->fr_type == rs_align_code)
++ && fragp->fr_address + fragp->fr_fix > 0
++ && fragp->fr_offset > 1 && now_seg != bss_section)
++ fix_new (fragp, fragp->fr_fix, 4, &abs_symbol, fragp->fr_offset, 0,
++ BFD_RELOC_NIOS2_ALIGN);
++
++}
++
++/* Handle the .align pseudo-op. This aligns to a power of two. It
++ also adjusts any current instruction label. We treat this the same
++ way the MIPS port does: .align 0 turns off auto alignment. */
++
++static void
++s_nios2_align (int ignore ATTRIBUTE_UNUSED)
++{
++ int align;
++ char fill;
++ const char *pfill = NULL;
++ long max_alignment = 15;
++
++
++ align = get_absolute_expression ();
++ if (align > max_alignment)
++ {
++ align = max_alignment;
++ as_bad (_("Alignment too large: %d. assumed"), align);
++ }
++ else if (align < 0)
++ {
++ as_warn (_("Alignment negative: 0 assumed"));
++ align = 0;
++ }
++
++ if (*input_line_pointer == ',')
++ {
++ input_line_pointer++;
++ fill = get_absolute_expression ();
++ pfill = (const char *) &fill;
++ }
++ else if (subseg_text_p (now_seg))
++ {
++ pfill = (const char *) &nop;
++ }
++ else
++ {
++ pfill = NULL;
++ nios2_last_label = NULL;
++ }
++
++ if (align != 0)
++ {
++ nios2_auto_align_on = 1;
++ nios2_align (align, pfill, nios2_last_label);
++ nios2_last_label = NULL;
++ }
++ else
++ {
++ nios2_auto_align_on = 0;
++ }
++
++ demand_empty_rest_of_line ();
++}
++
++
++/* Handle the .text pseudo-op. This is like the usual one, but it
++ clears the saved last label and resets known alignment. */
++
++static void
++s_nios2_text (int i)
++{
++ s_text (i);
++ nios2_last_label = NULL;
++ nios2_current_align = 0;
++ nios2_current_align_seg = now_seg;
++}
++
++/* Handle the .data pseudo-op. This is like the usual one, but it
++ clears the saved last label and resets known alignment. */
++
++static void
++s_nios2_data (int i)
++{
++ s_data (i);
++ nios2_last_label = NULL;
++ nios2_current_align = 0;
++ nios2_current_align_seg = now_seg;
++}
++
++/* Handle the .section pseudo-op. This is like the usual one, but it
++ clears the saved last label and resets known alignment. */
++
++static void
++s_nios2_section (int ignore)
++{
++ obj_elf_section (ignore);
++ nios2_last_label = NULL;
++ nios2_current_align = 0;
++ nios2_current_align_seg = now_seg;
++}
+diff --git a/gas/config/tc-nios2.h b/gas/config/tc-nios2.h
+new file mode 100644
+index 0000000..660aaa3
+--- /dev/null
++++ b/gas/config/tc-nios2.h
+@@ -0,0 +1,105 @@
++/* tc-nios2.h -- header file for tc-nios2.c.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++ This file is part of GAS.
++
++ GAS is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2, or (at your option)
++ any later version.
++
++ GAS is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with GAS; see the file COPYING. If not, write to the Free
++ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
++ 02111-1307, USA. */
++
++#ifndef TC_NIOS2
++#define TC_NIOS2
++
++/*
++ * If unspecified, default to little endian. We can explicitly specify
++ * a big-endian default by configuring with --target=nios2eb-elf. We
++ * can override the default with the -EB and -EL options.
++ */
++#ifndef TARGET_BYTES_BIG_ENDIAN
++#define TARGET_BYTES_BIG_ENDIAN 0
++#endif
++
++#ifdef OBJ_ELF
++extern const char *nios2_target_format (void);
++#define TARGET_FORMAT nios2_target_format ()
++#define TARGET_ARCH bfd_arch_nios2
++#endif
++
++/* An NIOS2 instruction consists of tokens and separator characters
++// the tokens are things like the instruction name (add, or jmp etc),
++// the register indices ($5, $7 etc), and constant expressions. The
++// separator characters are commas, brackets and space.
++// The instruction name is always separated from other tokens by a space
++// The maximum number of tokens in an instruction is 5 (the instruction name,
++// 3 arguments, and a 4th string representing the expected instructin opcode
++// after assembly. The latter is only used when the assemble is running in
++// self test mode, otherwise its presence will generate an error. */
++#define NIOS2_MAX_INSN_TOKENS 6
++
++/* There are no machine-specific operands so we #define this to nothing */
++#define md_operand(x)
++
++/* NG this may need to change when we look at implementing symbols */
++#define md_undefined_symbol(name) (0)
++
++/* function prototypes exported to rest of GAS */
++extern void md_assemble (char *op_str);
++extern void md_end (void);
++extern void md_begin (void);
++
++#define TC_FORCE_RELOCATION(fixp) nios2_force_relocation (fixp)
++extern int nios2_force_relocation (struct fix *);
++
++#define tc_fix_adjustable(fixp) nios2_fix_adjustable (fixp)
++extern int nios2_fix_adjustable (struct fix *);
++
++#define tc_frob_label(lab) nios2_frob_label(lab)
++extern void nios2_frob_label (symbolS *);
++
++#define tc_frob_symbol(symp, punt) punt = nios2_frob_symbol(symp) ? 1 : punt
++extern int nios2_frob_symbol (symbolS * symp);
++
++#define md_cons_align(nbytes) nios2_cons_align (nbytes)
++extern void nios2_cons_align (int);
++
++extern void md_convert_frag (bfd * headers, segT sec, fragS * fragP);
++
++/* When relaxing, we need to generate relocations for alignment
++ directives. */
++#define HANDLE_ALIGN(frag) nios2_handle_align (frag)
++extern void nios2_handle_align (fragS *);
++
++
++#define md_relax_frag nios2_relax_frag
++extern long nios2_relax_frag
++ (segT segment, fragS * fragP, long stretch);
++
++#ifdef OBJ_ELF
++#define ELF_TC_SPECIAL_SECTIONS \
++ { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL }, \
++ { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL }, \
++ { ".lit4", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL }, \
++ { ".lit8", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL },
++
++/* Processor specific section directives */
++#define md_elf_section_letter nios2_elf_section_letter
++extern int nios2_elf_section_letter (int, char **);
++#define md_elf_section_flags nios2_elf_section_flags
++extern flagword nios2_elf_section_flags (flagword, int, int);
++#endif
++
++
++#endif // TC_NIOS2
+diff --git a/gas/configure b/gas/configure
+index e66abca..cbb3889 100755
+--- a/gas/configure
++++ b/gas/configure
+@@ -4173,6 +4173,8 @@ for this_target in $target $canon_targets ; do
+ m8*) cpu_type=m88k ;;
+ mips*el) cpu_type=mips endian=little ;;
+ mips*) cpu_type=mips endian=big ;;
++ nios2eb) cpu_type=nios2 endian=big ;;
++ nios2el|nios2) cpu_type=nios2 endian=little ;;
+ or32*) cpu_type=or32 endian=big ;;
+ pjl*) cpu_type=pj endian=little ;;
+ pj*) cpu_type=pj endian=big ;;
+@@ -4439,6 +4441,7 @@ echo "$as_me: error: Unknown vendor for mips-bsd configuration." >&2;}
+ mn10200-*-*) fmt=elf ;;
+ mn10300-*-*) fmt=elf ;;
+ msp430-*-*) fmt=elf ;;
++ nios2*-*-*) fmt=elf ;;
+ openrisc-*-*) fmt=elf ;;
+ or32-*-rtems*) fmt=elf ;;
+ or32-*-coff) fmt=coff ;;
+@@ -4589,7 +4592,7 @@ _ACEOF
+ fi
+
+ case ${cpu_type}-${fmt} in
+- alpha*-* | arm-* | i386-* | ia64*-* | mips-* | ns32k-* \
++ alpha*-* | arm-* | i386-* | ia64*-* | mips-* | nios2*-* | ns32k-* \
+ | pdp11-* | ppc-* | sparc-* | strongarm-* | xscale-* \
+ | *-elf | *-ecoff | *-som)
+ bfd_gas=yes ;;
+diff --git a/gas/configure.in b/gas/configure.in
+index f7d0acb..e20754e 100644
+--- a/gas/configure.in
++++ b/gas/configure.in
+@@ -143,6 +143,8 @@ changequote([,])dnl
+ m8*) cpu_type=m88k ;;
+ mips*el) cpu_type=mips endian=little ;;
+ mips*) cpu_type=mips endian=big ;;
++ nios2eb) cpu_type=nios2 endian=big ;;
++ nios2el|nios2) cpu_type=nios2 endian=little ;;
+ or32*) cpu_type=or32 endian=big ;;
+ pjl*) cpu_type=pj endian=little ;;
+ pj*) cpu_type=pj endian=big ;;
+@@ -400,6 +402,7 @@ changequote([,])dnl
+ mn10200-*-*) fmt=elf ;;
+ mn10300-*-*) fmt=elf ;;
+ msp430-*-*) fmt=elf ;;
++ nios2*-*-*) fmt=elf ;;
+ openrisc-*-*) fmt=elf ;;
+ or32-*-rtems*) fmt=elf ;;
+ or32-*-coff) fmt=coff ;;
+@@ -539,7 +542,7 @@ changequote([,])dnl
+ fi
+
+ case ${cpu_type}-${fmt} in
+- alpha*-* | arm-* | i386-* | ia64*-* | mips-* | ns32k-* \
++ alpha*-* | arm-* | i386-* | ia64*-* | mips-* | nios2*-* | ns32k-* \
+ | pdp11-* | ppc-* | sparc-* | strongarm-* | xscale-* \
+ | *-elf | *-ecoff | *-som)
+ bfd_gas=yes ;;
+diff --git a/gas/doc/Makefile.am b/gas/doc/Makefile.am
+index 7f0f805..3e6af57 100644
+--- a/gas/doc/Makefile.am
++++ b/gas/doc/Makefile.am
+@@ -24,6 +24,7 @@ asconfig.texi: $(CONFIG).texi
+ || cp $(srcdir)/$(CONFIG).texi ./asconfig.texi
+
+ CPU_DOCS = \
++ c-nios2.texi \
+ c-a29k.texi \
+ c-alpha.texi \
+ c-arc.texi \
+diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in
+index 0c6a1b0..c7472d0 100644
+--- a/gas/doc/Makefile.in
++++ b/gas/doc/Makefile.in
+@@ -213,6 +213,7 @@ POD2MAN = pod2man --center="GNU Development Tools" \
+ man_MANS = as.1
+ info_TEXINFOS = as.texinfo
+ CPU_DOCS = \
++ c-nios2.texi \
+ c-a29k.texi \
+ c-alpha.texi \
+ c-arc.texi \
+diff --git a/gas/doc/all.texi b/gas/doc/all.texi
+index 4e302ce..3094553 100644
+--- a/gas/doc/all.texi
++++ b/gas/doc/all.texi
+@@ -26,6 +26,7 @@
+
+ @c CPUs of interest
+ @c ================
++@set NIOSII
+ @set A29K
+ @set ALPHA
+ @set ARC
+diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
+index d9d23df..ab2affa 100644
+--- a/gas/doc/as.texinfo
++++ b/gas/doc/as.texinfo
+@@ -238,6 +238,15 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
+ @c
+ @c Target dependent options are listed below. Keep the list sorted.
+ @c Add an empty line for separation.
++
++
++@ifset NIOSII
++@emph{Target Altera Nios II options:}
++ [@b{-relax-all}]
++ [@b{-relax-section}]
++ [@b{-no-relax}]
++@end ifset
++
+ @ifset A29K
+ @c am29k has no machine-dependent assembler options
+ @end ifset
+@@ -577,6 +586,21 @@ Standard input, or source files to assemble.
+
+ @end table
+
++@ifset NIOSII
++The following options are available when @value{AS} is configured for
++an Altera Nios II processor.
++
++@table @gcctabopt
++@item -relax-all
++Replace all branch and call instructions with @code{jmp} and @code{callr} sequences
++@item -relax-section
++Replace identified out of range branches with @code{jmp} sequences (default)
++@item -no-relax
++Do not replace any branches or calls
++@end table
++@end ifset
++
++
+ @ifset ARC
+ The following options are available when @value{AS} is configured for
+ an ARC processor.
+@@ -2035,6 +2059,9 @@ This means you may not nest these comments.
+ @cindex line comment character
+ Anything from the @dfn{line comment} character to the next newline
+ is considered a comment and is ignored. The line comment character is
++@ifset NIOSII
++@samp{#} for the Altera Nios II family;
++@end ifset
+ @ifset A29K
+ @samp{;} for the AMD 29K family;
+ @end ifset
+@@ -3876,7 +3903,7 @@ is already a multiple of 8, no change is needed. For the tic54x, the
+ first expression is the alignment request in words.
+
+ For other systems, including the i386 using a.out format, and the arm and
+-strongarm, it is the
++strongarm, and the Altera Nios II, it is the
+ number of low-order zero bits the location counter must have after
+ advancement. For example @samp{.align 3} advances the location
+ counter until it a multiple of 8. If the location counter is already a
+@@ -5864,6 +5891,9 @@ include details on any machine's instruction set. For details on that
+ subject, see the hardware manufacturer's manual.
+
+ @menu
++@ifset NIOSII
++* NiosII-Dependent:: Altera Nios II Dependent Features
++@end ifset
+ @ifset A29K
+ * AMD29K-Dependent:: AMD 29K Dependent Features
+ @end ifset
+@@ -5974,6 +6004,11 @@ subject, see the hardware manufacturer's manual.
+ @c node and sectioning commands; hence the repetition of @chapter BLAH
+ @c in both conditional blocks.
+
++
++@ifset NIOSII
++@include c-nios2.texi
++@end ifset
++
+ @ifset A29K
+ @include c-a29k.texi
+ @end ifset
+diff --git a/gas/doc/c-nios2.texi b/gas/doc/c-nios2.texi
+new file mode 100644
+index 0000000..b2d5d61
+--- /dev/null
++++ b/gas/doc/c-nios2.texi
+@@ -0,0 +1,222 @@
++@c Copyright 2004
++@c This is part of the GAS manual.
++@c For copying conditions, see the file as.texinfo.
++@ifset GENERIC
++@page
++@node NiosII-Dependent
++@chapter Altera Nios II Dependent Features
++@end ifset
++@ifclear GENERIC
++@node Machine Dependencies
++@chapter ltera Nios II Dependent Features
++@end ifclear
++
++@cindex Altera Nios II support
++@cindex Nios support
++@cindex Nios II support
++@menu
++* Nios II Options:: Options
++* Nios II Syntax:: Syntax
++* Nios II Relocations:: Relocations
++* Nios II Directives:: Nios II Machine Directives
++* Nios II Opcodes:: Opcodes
++@end menu
++
++@node Nios II Options
++@section Options
++@cindex Nios II options
++@cindex options for Nios II
++
++@table @code
++
++@cindex @code{relax-all} command line option, Nios II
++@item -relax-all
++Replace all branch and call instructions with @code{jmp} and @code{callr} sequences
++
++@cindex @code{relax-section} command line option, Nios II
++@item -relax-section
++Replace identified out of range branches with @code{jmp} sequences (default)
++
++@cindex @code{no-relax} command line option, Nios II
++@item -no-relax
++Do not replace any branches or calls
++
++@cindex @code{EB} command line option, Nios II
++@item -EB
++Generate big-endian output
++
++@cindex @code{EL} command line option, Nios II
++@item -EL
++Generate little-endian output
++
++@end table
++
++
++@node Nios II Syntax
++@section Syntax
++@menu
++* Nios II Chars:: Special Characters
++@end menu
++
++
++@node Nios II Chars
++@subsection Special Characters
++
++@cindex line comment character, Nios II
++@cindex Nios II line comment character
++@samp{#} is the line comment character.
++
++@cindex line separator character, Nios II
++@cindex Nios II line separator character
++@samp{;} is the line separator character.
++
++
++@node Nios II Relocations
++@section Nios II Machine Relocations
++
++@cindex machine relocations, Nios II
++@cindex Nios II machine relocations
++
++@table @code
++@cindex @code{hiadj} directive, Nios II
++@item %hiadj(@var{expression})
++Extract the upper 16-bits of @var{expression} and add
++one if the 15th bit is set.
++
++The value of %hiadj is:
++((@var{expression} >> 16) & 0xffff) + ((@var{expression} >> 15) & 0x01).
++
++The intention of the @code{%hiadj} relocation is to be used with
++an @code{addi}, @code{ld} or @code{st} instructions
++along with a @code{%lo}.
++
++@smallexample
++movhi r2, %hiadj(symbol)
++addi r2, r2, %lo(symbol)
++@end smallexample
++
++@cindex @code{hi} directive, Nios II
++@item %hi(@var{expression})
++Extract the upper 16-bits of @var{expression}.
++
++
++@cindex @code{lo} directive, Nios II
++@item %lo(@var{expression})
++Extract the lower 16-bits of @var{expression}.
++
++
++@cindex @code{gprel} directive, Nios II
++@item %gprel(@var{expression})
++Subtract the value of the symbol @code{_gp} from
++@var{expression}.
++
++The intention of the @code{%gprel} relocation is
++to have a fast small area of memory which only
++takes a 16-bit immediate to access.
++
++@smallexample
++ .section .sdata
++fastint:
++ .int 123
++ .section .text
++ ldw r4, %gprel(fastint)(gp)
++@end smallexample
++
++
++@end table
++
++
++@node Nios II Directives
++@section Nios II Machine Directives
++
++@cindex machine directives, Nios II
++@cindex Nios II machine directives
++
++@table @code
++
++@cindex @code{align} directive, Nios II
++@item .align @var{expression} [, @var{expression}]
++This is the generic @var{.align} directive, however
++this aligns to a power of two.
++
++@cindex @code{half} directive, Nios II
++@item .half @var{expression}
++Create an aligned constant 2-bytes in size
++
++@cindex @code{word} directive, Nios II
++@item .word @var{expression}
++Create an aligned constant 4-bytes in size
++
++@cindex @code{dword} directive, Nios II
++@item .dword @var{expression}
++Create an aligned constant 8-bytes in size
++
++@cindex @code{2byte} directive, Nios II
++@item .2byte @var{expression}
++Create an un-aligned constant 2-bytes in size
++
++@cindex @code{4byte} directive, Nios II
++@item .4byte @var{expression}
++Create an un-aligned constant 4-bytes in size
++
++@cindex @code{8byte} directive, Nios II
++@item .8byte @var{expression}
++Create an un-aligned constant 8-bytes in size
++
++@cindex @code{16byte} directive, Nios II
++@item .16byte @var{expression}
++Create an un-aligned constant 16-bytes in size
++
++@cindex @code{set noat} directive, Nios II
++@item .set noat
++Allows assembly code to use @code{at} register without
++warning and macro or relaxation expansions will
++generate a warning.
++
++@cindex @code{set at} directive, Nios II
++@item .set at
++Assembly code using @code{at} register will generate
++warnings, and macro expansion and relaxation will be
++enabled.
++
++@cindex @code{set nobreak} directive, Nios II
++@item .set nobreak
++Allows assembly code to use @code{ba}, @code{bt},
++registers without warning.
++
++@cindex @code{set break} directive, Nios II
++@item .set break
++Turns warnings back on for using @code{ba}, @code{bt}
++registers.
++
++@cindex @code{set norelax} directive, Nios II
++@item .set norelax
++Do not replace any branches or calls.
++
++@cindex @code{set relaxsection} directive, Nios II
++@item .set relaxsection
++Replace identified out of range branches with
++@code{jmp} sequences (default).
++
++@cindex @code{set relaxall} directive, Nios II
++@item .set relaxsection
++Replace all branch and call instructions with
++@code{jmp} and @code{callr} sequences.
++
++@cindex @code{set} directive, Nios II
++@item .set @dots{}
++All other @code{.set} are the normal use.
++
++@end table
++
++@node Nios II Opcodes
++@section Opcodes
++
++@cindex Nios II opcodes
++@cindex opcodes for Nios II
++@code{@value{AS}} implements all the standard Nios II opcodes. No
++additional pseudo-instructions are needed on this family.
++
++For information on the Nios II machine instruction set, see the @cite{Nios II
++User's Manual}
++
+diff --git a/gas/testsuite/gas/macros/irp.s b/gas/testsuite/gas/macros/irp.s
+index f37dd54..95a91e3 100644
+--- a/gas/testsuite/gas/macros/irp.s
++++ b/gas/testsuite/gas/macros/irp.s
+@@ -1,3 +1,4 @@
++ .set norelax
+ .irp param,1,2,3
+ .long foo\param
+ .endr
+diff --git a/gas/testsuite/gas/macros/rept.s b/gas/testsuite/gas/macros/rept.s
+index 571b6f8..d6f86c1 100644
+--- a/gas/testsuite/gas/macros/rept.s
++++ b/gas/testsuite/gas/macros/rept.s
+@@ -1,3 +1,4 @@
++ .set norelax
+ .rept 3
+ .long foo1
+ .endr
+diff --git a/gas/testsuite/gas/macros/test2.s b/gas/testsuite/gas/macros/test2.s
+index 0cfca29..ad62adc 100644
+--- a/gas/testsuite/gas/macros/test2.s
++++ b/gas/testsuite/gas/macros/test2.s
+@@ -1,3 +1,4 @@
++ .set norelax
+ .macro m arg1 arg2 arg3
+ .long \arg1
+ .ifc ,\arg2\arg3
+diff --git a/gas/testsuite/gas/macros/test3.s b/gas/testsuite/gas/macros/test3.s
+index e80aa20..0070527 100644
+--- a/gas/testsuite/gas/macros/test3.s
++++ b/gas/testsuite/gas/macros/test3.s
+@@ -1,3 +1,4 @@
++ .set norelax
+ .macro m arg1 arg2
+ \arg1
+ .exitm
+diff --git a/gas/testsuite/gas/nios2/add.d b/gas/testsuite/gas/nios2/add.d
+new file mode 100644
+index 0000000..ba3d27f
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/add.d
+@@ -0,0 +1,16 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 add
++
++# Test the add instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> add r4,r4,r4
++0+0004 <[^>]*> addi r4,r4,32767
++0+0008 <[^>]*> addi r4,r4,-32768
++0+000c <[^>]*> addi r4,r4,0
++0+0010 <[^>]*> addi r4,r4,-1
++0+0014 <[^>]*> addi r4,r4,-1
++0+0018 <[^>]*> addi r4,r4,13398
++0+001c <[^>]*> nop
+diff --git a/gas/testsuite/gas/nios2/add.s b/gas/testsuite/gas/nios2/add.s
+new file mode 100644
+index 0000000..5b72a82
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/add.s
+@@ -0,0 +1,13 @@
++# Source file used to test the add and addi instructions.
++
++foo:
++ add r4,r4,r4
++ addi r4,r4,0x7fff
++ addi r4,r4,-0x8000
++ addi r4,r4,0x0
++ addi r4,r4,-0x01
++ subi r4,r4,0x01
++ addi r4,r4,0x3456
++
++# should disassemble to add r0,0,r0
++ nop
+diff --git a/gas/testsuite/gas/nios2/align_fill.d b/gas/testsuite/gas/nios2/align_fill.d
+new file mode 100644
+index 0000000..90a9e5f
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/align_fill.d
+@@ -0,0 +1,23 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 align_fill
++
++# Test the and macro.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> addi sp,sp,-8
++0+0004 <[^>]*> stw fp,4\(sp\)
++0+0008 <[^>]*> mov fp,sp
++0+000c <[^>]*> mov r3,zero
++0+0010 <[^>]*> nop
++0+0014 <[^>]*> nop
++0+0018 <[^>]*> nop
++0+001c <[^>]*> nop
++0+0020 <[^>]*> addi r3,r3,1
++0+0024 <[^>]*> cmplti r2,r3,100
++0+0028 <[^>]*> bne r2,zero,0+0020 <[^>*]*>
++0+002c <[^>]*> ldw fp,4\(sp\)
++0+0030 <[^>]*> addi sp,sp,8
++0+0034 <[^>]*> ret
++ ...
+diff --git a/gas/testsuite/gas/nios2/align_fill.s b/gas/testsuite/gas/nios2/align_fill.s
+new file mode 100644
+index 0000000..5683839
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/align_fill.s
+@@ -0,0 +1,20 @@
++ .file "a.c"
++ .section .text
++ .align 3
++ .global x
++ .type x, @function
++x:
++ addi sp, sp, -8
++ stw fp, 4(sp)
++ mov fp, sp
++ mov r3, zero
++ .align 5
++.L6:
++ addi r3, r3, 1
++ cmplti r2, r3, 100
++ bne r2, zero, .L6
++ ldw fp, 4(sp)
++ addi sp, sp, 8
++ ret
++ .size x, .-x
++ .ident "GCC: (GNU) 3.3.3 (Altera Nios II 1.0 b302)"
+diff --git a/gas/testsuite/gas/nios2/align_text.d b/gas/testsuite/gas/nios2/align_text.d
+new file mode 100644
+index 0000000..d11e7fc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/align_text.d
+@@ -0,0 +1,22 @@
++#objdump: -dr
++#name: NIOS2 align_test
++
++# Test alignment in text sections.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++00000000 <label-0x20>:
++ 0: 00000000 call 0 <label-0x20>
++ 4: 0001883a nop
++ 8: 0001883a nop
++ c: 0001883a nop
++ 10: 0001883a nop
++ 14: 0001883a nop
++ 18: 0001883a nop
++ 1c: 0001883a nop
++
++00000020 <label>:
++ 20: 0001883a nop
++00000024 <label2>:
++ ...
+\ No newline at end of file
+diff --git a/gas/testsuite/gas/nios2/align_text.s b/gas/testsuite/gas/nios2/align_text.s
+new file mode 100644
+index 0000000..d073b6f
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/align_text.s
+@@ -0,0 +1,15 @@
++ .asciz "" # empty string
++ .align 2
++
++ nop
++ nop
++ label:
++ .align 5
++ nop
++ label2:
++ .section mysection
++ .align 2
++
++
++
++
+diff --git a/gas/testsuite/gas/nios2/and.d b/gas/testsuite/gas/nios2/and.d
+new file mode 100644
+index 0000000..350ca69
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/and.d
+@@ -0,0 +1,17 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 and
++
++# Test the and macro.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> and r4,r4,r4
++0+0004 <[^>]*> andi r4,r4,32767
++0+0008 <[^>]*> andi r4,r4,32768
++0+000c <[^>]*> andi r4,r4,65535
++0+0010 <[^>]*> andi r4,r4,0
++0+0014 <[^>]*> andhi r4,r4,32767
++0+0018 <[^>]*> andhi r4,r4,32768
++0+001c <[^>]*> andhi r4,r4,65535
++0+0020 <[^>]*> andhi r4,r4,0
+diff --git a/gas/testsuite/gas/nios2/and.s b/gas/testsuite/gas/nios2/and.s
+new file mode 100644
+index 0000000..a7de05f
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/and.s
+@@ -0,0 +1,13 @@
++# Source file used to test the and, andhi and andi instructions
++
++foo:
++ and r4,r4,r4
++ andi r4,r4,0x7fff
++ andi r4,r4,0x8000
++ andi r4,r4,0xffff
++ andi r4,r4,0x0
++ andhi r4,r4,0x7fff
++ andhi r4,r4,0x8000
++ andhi r4,r4,0xffff
++ andhi r4,r4,0x0
++
+\ No newline at end of file
+diff --git a/gas/testsuite/gas/nios2/blt.d b/gas/testsuite/gas/nios2/blt.d
+new file mode 100644
+index 0000000..aed1b26
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/blt.d
+@@ -0,0 +1 @@
++This file is obsolete
+\ No newline at end of file
+diff --git a/gas/testsuite/gas/nios2/blt.s b/gas/testsuite/gas/nios2/blt.s
+new file mode 100644
+index 0000000..aed1b26
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/blt.s
+@@ -0,0 +1 @@
++This file is obsolete
+\ No newline at end of file
+diff --git a/gas/testsuite/gas/nios2/branch.d b/gas/testsuite/gas/nios2/branch.d
+new file mode 100644
+index 0000000..b689dee
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/branch.d
+@@ -0,0 +1,16 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 branch
++
++# Test the branch instructions.
++dump.o: file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> beq r4,r5,00000000 <text_label>
++0+0004 <[^>]*> bge r4,r5,00000000 <text_label>
++0+0008 <[^>]*> bgeu r4,r5,00000000 <text_label>
++0+000c <[^>]*> blt r4,r5,00000000 <text_label>
++0+0010 <[^>]*> bltu r4,r5,00000000 <text_label>
++0+0014 <[^>]*> bne r4,r5,00000000 <text_label>
++0+0018 <[^>]*> br 0000001c <text_label\+0x1c>
++[ ]*18: R_NIOS2_PCREL16 external_label
++
+diff --git a/gas/testsuite/gas/nios2/branch.s b/gas/testsuite/gas/nios2/branch.s
+new file mode 100644
+index 0000000..0853167
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/branch.s
+@@ -0,0 +1,15 @@
++# Source file used to test the beq macro.
++ .globl text_label
++ .text
++.set norelax
++text_label:
++ beq r4,r5,text_label
++ bge r4,r5,text_label
++ bgeu r4,r5,text_label
++ blt r4,r5,text_label
++ bltu r4,r5,text_label
++ bne r4,r5,text_label
++
++# Branch to an external label.
++ br external_label
++
+diff --git a/gas/testsuite/gas/nios2/break.d b/gas/testsuite/gas/nios2/break.d
+new file mode 100644
+index 0000000..be487bb
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/break.d
+@@ -0,0 +1,12 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 break
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> break 0
++0+0004 <[^>]*> break 0
++0+0008 <[^>]*> break 31
++0+000c <[^>]*> break 14
++
++
+diff --git a/gas/testsuite/gas/nios2/break.s b/gas/testsuite/gas/nios2/break.s
+new file mode 100644
+index 0000000..88d3422
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/break.s
+@@ -0,0 +1,8 @@
++# Source file used to test the 20-bit break instructions
++foo:
++ break
++ break 0
++ break 31
++ break 14
++
++
+diff --git a/gas/testsuite/gas/nios2/bret.d b/gas/testsuite/gas/nios2/bret.d
+new file mode 100644
+index 0000000..a12530b
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/bret.d
+@@ -0,0 +1,8 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 bret
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> bret
++
+diff --git a/gas/testsuite/gas/nios2/bret.s b/gas/testsuite/gas/nios2/bret.s
+new file mode 100644
+index 0000000..d368e64
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/bret.s
+@@ -0,0 +1,5 @@
++# Source file used to test the bret instructions
++foo:
++ bret
++
++
+diff --git a/gas/testsuite/gas/nios2/cache.d b/gas/testsuite/gas/nios2/cache.d
+new file mode 100644
+index 0000000..7c278d8
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/cache.d
+@@ -0,0 +1,17 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 cache
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> flushd -32768\(r6\)
++0+0004 <[^>]*> flushd 32767\(r6\)
++0+0008 <[^>]*> flushd 0\(r6\)
++0+000c <[^>]*> flushd -1\(r6\)
++0+0010 <[^>]*> flushd 0\(r6\)
++[ ]*10: R_NIOS2_S16 .text
++0+0014 <[^>]*> flushd 0\(r6\)
++[ ]*14: R_NIOS2_S16 external
++0+0018 <[^>]*> flushi r2
++0+001c <[^>]*> flushp
++
+diff --git a/gas/testsuite/gas/nios2/cache.s b/gas/testsuite/gas/nios2/cache.s
+new file mode 100644
+index 0000000..1701c19
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/cache.s
+@@ -0,0 +1,21 @@
++# Source file used to test the cache instruction
++foo:
++ flushd -0x8000(r6)
++ flushd 0x7fff(r6)
++ flushd 0x0(r6)
++ flushd -0x0001(r6)
++
++# use symbol for offset
++ flushd foo(r6)
++
++# use external symbol
++ .global external
++ flushd external(r6)
++
++# flushi
++ flushi r2
++
++#flushp
++ flushp
++
++
+diff --git a/gas/testsuite/gas/nios2/call.d b/gas/testsuite/gas/nios2/call.d
+new file mode 100644
+index 0000000..cfa6aec
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/call.d
+@@ -0,0 +1,11 @@
++# objdump: -dr --prefix-addresses
++#name: NIOS2 call
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> call 00000000 <foo>
++[ ]*0: R_NIOS2_CALL26 .text\+0xc
++0+0004 <[^>]*> callr r10
++0+0008 <[^>]*> call 00000000 <foo>
++[ ]*8: R_NIOS2_CALL26 external
+diff --git a/gas/testsuite/gas/nios2/call.s b/gas/testsuite/gas/nios2/call.s
+new file mode 100644
+index 0000000..39409b7
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/call.s
+@@ -0,0 +1,13 @@
++# Source file used to test the call and callr instructions
++.text
++.set norelax
++foo:
++ call func1
++ callr r10
++# use external symbol
++ .global external
++ call external
++func1:
++
++
++
+diff --git a/gas/testsuite/gas/nios2/cmp.d b/gas/testsuite/gas/nios2/cmp.d
+new file mode 100644
+index 0000000..07bf9f5
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/cmp.d
+@@ -0,0 +1,24 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 cmp
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> cmpeq r11,r2,r3
++0+0004 <[^>]*> cmpge r11,r2,r3
++0+0008 <[^>]*> cmpgeu r11,r2,r3
++0+000c <[^>]*> cmplt r11,r2,r3
++0+0010 <[^>]*> cmpltu r11,r2,r3
++0+0014 <[^>]*> cmpne r11,r2,r3
++0+0018 <[^>]*> cmpgei r11,r2,0
++[ ]*18: R_NIOS2_S16 value
++0+001c <[^>]*> cmpgeui r11,r2,0
++[ ]*1c: R_NIOS2_U16 value\+0x200
++0+0020 <[^>]*> cmplti r11,r2,0
++[ ]*20: R_NIOS2_S16 value
++0+0024 <[^>]*> cmpltui r11,r2,0
++[ ]*24: R_NIOS2_U16 value\+0x200
++0+0028 <[^>]*> cmpgei r11,r2,32767
++0+002c <[^>]*> cmpgeui r11,r2,32768
++0+0030 <[^>]*> cmplti r11,r2,-32768
++0+0034 <[^>]*> cmpltui r11,r2,65535
+\ No newline at end of file
+diff --git a/gas/testsuite/gas/nios2/cmp.s b/gas/testsuite/gas/nios2/cmp.s
+new file mode 100644
+index 0000000..6f7c15b
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/cmp.s
+@@ -0,0 +1,22 @@
++# Source file used to test the compare instructions
++foo:
++ cmpeq r11,r2,r3
++ cmpge r11,r2,r3
++ cmpgeu r11,r2,r3
++ cmplt r11,r2,r3
++ cmpltu r11,r2,r3
++ cmpne r11,r2,r3
++# test that cmp generates relocations correctly
++ cmpgei r11,r2,value
++ cmpgeui r11,r2,value+0x200
++ cmplti r11,r2,value
++ cmpltui r11,r2,value+0x200
++
++ cmpgei r11,r2,0x7fff
++ cmpgeui r11,r2,0x8000
++ cmplti r11,r2,-0x8000
++ cmpltui r11,r2,0xFFFF
++.global value
++
++
++
+diff --git a/gas/testsuite/gas/nios2/comments.d b/gas/testsuite/gas/nios2/comments.d
+new file mode 100644
+index 0000000..890dcc2
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/comments.d
+@@ -0,0 +1,26 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 comments
++
++# Test the add instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> br 0000001c <start>
++0+0004 <[^>]*> br 00000008 <abort>
++0+0008 <[^>]*> movui r3,0
++0+000c <[^>]*> movui r2,1
++0+0010 <[^>]*> movui r3,0
++0+0014 <[^>]*> movui r2,0
++0+0018 <[^>]*> br 00000044 <exit>
++0+001c <[^>]*> addi r2,r2,-4
++0+0020 <[^>]*> movui r11,1
++0+0024 <[^>]*> movui r5,0
++0+0028 <[^>]*> movui r6,0
++0+002c <[^>]*> br 00000030 <ldst>
++0+0030 <[^>]*> movui r2,61452
++0+0034 <[^>]*> movui r20,64206
++0+0038 <[^>]*> stw r20,0\(r2\)
++0+003c <[^>]*> ldw r21,0\(r2\)
++0+0040 <[^>]*> br 00000010 <end>
++0+0044 <[^>]*> br 00000044 <exit>
+diff --git a/gas/testsuite/gas/nios2/comments.s b/gas/testsuite/gas/nios2/comments.s
+new file mode 100644
+index 0000000..7ab2027
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/comments.s
+@@ -0,0 +1,28 @@
++.set norelax
++_main: br start
++trap:
++ br abort
++.globl _main
++abort: movui r3, 0x0
++ movui r2, 0x1
++
++end: movui r3, 0x0
++ movui r2, 0x0
++ br exit
++
++start:
++ addi r2, r2, -4 # test for ve numbers
++ movui r11, 0x1
++ ori r5, r0, %lo(0x0) # r5 = 0x0
++ ori r6, r0, %lo(0x0) # r6 = 0x0
++ br ldst
++
++ldst:
++ movui r2, 0xF00C
++ movui r20, 0xFACE
++ stw r20,(r2)
++ ldw r21, (r2)
++ br end
++
++
++exit: br exit
+diff --git a/gas/testsuite/gas/nios2/complex.d b/gas/testsuite/gas/nios2/complex.d
+new file mode 100644
+index 0000000..d2af6ae
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/complex.d
+@@ -0,0 +1,12 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 complex
++
++# Test complex expression parsing
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> ldw r2,-1\(r3\)
++0+0004 <[^>]*> ldw r2,1\(r3\)
++0+0008 <[^>]*> ldw r2,0\(r3\)
++ 8: R_NIOS2_S16 stack_top\+0xffffffff
+diff --git a/gas/testsuite/gas/nios2/complex.s b/gas/testsuite/gas/nios2/complex.s
+new file mode 100644
+index 0000000..65141f9
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/complex.s
+@@ -0,0 +1,5 @@
++foo:
++ ldw r2, (2-3)(r3)
++ ldw r2, 2 + (2-3)(r3)
++ ldw r2, 2 + (stack_top-3)(r3)
++
+diff --git a/gas/testsuite/gas/nios2/ctl.d b/gas/testsuite/gas/nios2/ctl.d
+new file mode 100644
+index 0000000..f698ce6
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ctl.d
+@@ -0,0 +1,20 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 ctl
++
++# Test the ctl instructions
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> rdctl r8,ctl31
++0+0004 <[^>]*> rdctl r8,ctl30
++0+0008 <[^>]*> rdctl r8,ctl29
++0+000c <[^>]*> rdctl r8,status
++0+0010 <[^>]*> rdctl r8,bstatus
++0+0014 <[^>]*> rdctl r8,estatus
++0+0018 <[^>]*> wrctl ctl31,r8
++0+001c <[^>]*> wrctl ctl30,r8
++0+0020 <[^>]*> wrctl ctl29,r8
++0+0024 <[^>]*> wrctl status,r8
++0+0028 <[^>]*> wrctl bstatus,r8
++0+002c <[^>]*> wrctl estatus,r8
+diff --git a/gas/testsuite/gas/nios2/ctl.s b/gas/testsuite/gas/nios2/ctl.s
+new file mode 100644
+index 0000000..dc6c983
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ctl.s
+@@ -0,0 +1,18 @@
++# Source file used to test the nor instruction
++
++foo:
++ rdctl r8,ctl31
++ rdctl r8,ctl30
++ rdctl r8,ctl29
++ rdctl r8,status
++ rdctl r8,bstatus
++ rdctl r8,estatus
++ wrctl ctl31,r8
++ wrctl ctl30,r8
++ wrctl ctl29,r8
++ wrctl status,r8
++ wrctl bstatus,r8
++ wrctl estatus,r8
++
++
++
+diff --git a/gas/testsuite/gas/nios2/custom.d b/gas/testsuite/gas/nios2/custom.d
+new file mode 100644
+index 0000000..c1e17be
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/custom.d
+@@ -0,0 +1,13 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 custom
++
++# Test the custom instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> custom 0,r11,r2,r3
++0+0004 <[^>]*> custom 255,r11,r2,r3
++0+0008 <[^>]*> custom 150,c1,r2,r3
++0+000c <[^>]*> custom 24,c1,c2,r3
++0+0010 <[^>]*> custom 56,c1,c2,c3
+diff --git a/gas/testsuite/gas/nios2/custom.s b/gas/testsuite/gas/nios2/custom.s
+new file mode 100644
+index 0000000..903122a
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/custom.s
+@@ -0,0 +1,8 @@
++# test progam for assembling user instructions
++
++foo:
++ custom 0, r11, r2, r3
++ custom 255, r11, r2, r3
++ custom 150, c1, r2, r3
++ custom 0x18, c1, c2, r3
++ custom 070, c1, c2, c3
+diff --git a/gas/testsuite/gas/nios2/etbt.d b/gas/testsuite/gas/nios2/etbt.d
+new file mode 100644
+index 0000000..58b8e32
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/etbt.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 etbt
++
++# Test the et, bt registers
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> add et,bt,r6
++0+0004 <[^>]*> add et,bt,r6
+diff --git a/gas/testsuite/gas/nios2/etbt.s b/gas/testsuite/gas/nios2/etbt.s
+new file mode 100644
+index 0000000..3e5fc24
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/etbt.s
+@@ -0,0 +1,4 @@
++.set nobreak
++foo:
++ add r24, r25, r6
++ add et, bt, r6
+diff --git a/gas/testsuite/gas/nios2/flushda.d b/gas/testsuite/gas/nios2/flushda.d
+new file mode 100644
+index 0000000..f3b5e3e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/flushda.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 flushda
++
++# Test the jmp instruction.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> flushda 12\(r2\)
++
+diff --git a/gas/testsuite/gas/nios2/flushda.s b/gas/testsuite/gas/nios2/flushda.s
+new file mode 100644
+index 0000000..3a32474
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/flushda.s
+@@ -0,0 +1,6 @@
++# Source file used to test the flushda instruction.
++.text
++.set nobreak
++foo:
++ flushda 12(r2)
++
+diff --git a/gas/testsuite/gas/nios2/hilo_symbol.s b/gas/testsuite/gas/nios2/hilo_symbol.s
+new file mode 100644
+index 0000000..88fdddc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/hilo_symbol.s
+@@ -0,0 +1,3 @@
++.global long_symbol
++.set long_symbol, 0xDEADBEEF
++
+diff --git a/gas/testsuite/gas/nios2/illegal.l b/gas/testsuite/gas/nios2/illegal.l
+new file mode 100644
+index 0000000..6248567
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/illegal.l
+@@ -0,0 +1,14 @@
++.*illegal.s: Assembler messages:
++.*illegal.s:5: Error: unknown register r56
++.*illegal.s:8: Error: expecting \( near 0x1000
++.*illegal.s:8: Error: missing argument
++.*illegal.s:9: Error: expecting \) near r5
++.*illegal.s:10: Error: expecting \( near 0x1000r5\)
++.*illegal.s:10: Error: missing argument
++.*illegal.s:11: Error: expecting \( near 0x1000,r5
++.*illegal.s:11: Error: missing argument
++.*illegal.s:12: Error: unknown register 0x1000
++.*illegal.s:14: Error: unrecognised instruction fop
++.*illegal.s:16: Error: too many arguments
++.*illegal.s:17: Error: too many arguments
++.*illegal.s:17: Error: unknown register r2,r4
+diff --git a/gas/testsuite/gas/nios2/illegal.s b/gas/testsuite/gas/nios2/illegal.s
+new file mode 100644
+index 0000000..75b6d89
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/illegal.s
+@@ -0,0 +1,17 @@
++# Source file used to test illegal operands.
++
++foo:
++# Illegal registers
++ add r3,r4,r56
++ add r4,r0,r2
++# Illegal syntax
++ ldw r4,0x1000
++ ldw r4,0x1000(r5
++ ldw r4,0x1000r5)
++ ldw r4,0x1000,r5
++ ldw r4,(0x1000)r5
++# Illegal opcodes
++ fop r3,r4,r5
++# Extra operands
++ nop Crapola
++ add r2, r2, r2, r4
+diff --git a/gas/testsuite/gas/nios2/imm5_symbol.s b/gas/testsuite/gas/nios2/imm5_symbol.s
+new file mode 100644
+index 0000000..d988951
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/imm5_symbol.s
+@@ -0,0 +1,4 @@
++.global imm5
++.text
++.byte imm5
++.set imm5, 31
+diff --git a/gas/testsuite/gas/nios2/jmp.d b/gas/testsuite/gas/nios2/jmp.d
+new file mode 100644
+index 0000000..b8727b3
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/jmp.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 jmp
++
++# Test the jmp instruction.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> jmp bt
++
+diff --git a/gas/testsuite/gas/nios2/jmp.s b/gas/testsuite/gas/nios2/jmp.s
+new file mode 100644
+index 0000000..8d859f2
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/jmp.s
+@@ -0,0 +1,6 @@
++# Source file used to test the jmp instruction.
++.text
++.set nobreak
++foo:
++ jmp r25
++
+diff --git a/gas/testsuite/gas/nios2/ldb.d b/gas/testsuite/gas/nios2/ldb.d
+new file mode 100644
+index 0000000..10ad705
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldb.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 ldb
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> ldb r4,0\(zero\)
++0+0004 <[^>]*> ldb r4,4\(zero\)
++0+0008 <[^>]*> ldb r4,32764\(zero\)
++0+000c <[^>]*> ldb r4,-32768\(zero\)
++0+0010 <[^>]*> ldb r4,0\(r5\)
++0+0014 <[^>]*> ldb r4,4\(r5\)
++0+0018 <[^>]*> ldb r4,32764\(r5\)
++0+001c <[^>]*> ldb r4,-32768\(r5\)
++0+0020 <[^>]*> ldb r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> ldb r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> ldb r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> ldb r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> ldb r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> ldb r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> ldb r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> ldb r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> ldb r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> ldb r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> ldb r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> ldb r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> ldb r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> ldb r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> ldb r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> ldb r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> ldb r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> ldb r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> ldb r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> ldb r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> ldb r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> ldb r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> ldb r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> ldb r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> ldb r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> ldb r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> ldb r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> ldb r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> ldb r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> ldb r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> ldb r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> ldb r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> ldb r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> ldb r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> ldb r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> ldb r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> ldb r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> ldb r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> ldb r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> ldb r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> ldb r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> ldb r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> ldb r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> ldbio r4,0\(zero\)
++0+00d0 <[^>]*> ldbio r4,4\(zero\)
++0+00d4 <[^>]*> ldbio r4,32764\(zero\)
++0+00d8 <[^>]*> ldbio r4,-32768\(zero\)
++0+00dc <[^>]*> ldbio r4,0\(r5\)
++0+00e0 <[^>]*> ldbio r4,4\(r5\)
++0+00e4 <[^>]*> ldbio r4,32764\(r5\)
++0+00e8 <[^>]*> ldbio r4,-32768\(r5\)
++0+00ec <[^>]*> ldbio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> ldbio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> ldbio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> ldbio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> ldbio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> ldbio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> ldbio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> ldbio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> ldbio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> ldbio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> ldbio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> ldbio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> ldbio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> ldbio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> ldbio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> ldbio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> ldbio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> ldbio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> ldbio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> ldbio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> ldbio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> ldbio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> ldbio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> ldbio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> ldbio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> ldbio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> ldbio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> ldbio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> ldbio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> ldbio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> ldbio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> ldbio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> ldbio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> ldbio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> ldbio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> ldbio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> ldbio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> ldbio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> ldbio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> ldbio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> ldbio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> ldbio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> ldbio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/ldb.s b/gas/testsuite/gas/nios2/ldb.s
+new file mode 100644
+index 0000000..71c51f1
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldb.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ ldb r4,0(r0)
++ ldb r4,4(r0)
++ ldb r4,0x7ffc(r0)
++ ldb r4,-0x8000(r0)
++ ldb r4,0(r5)
++ ldb r4,4(r5)
++ ldb r4,0x7ffc(r5)
++ ldb r4,-0x8000(r5)
++ ldb r4,data_label(r0)
++ ldb r4,big_external_data_label(r0)
++ ldb r4,small_external_data_label(r0)
++ ldb r4,big_external_common(r0)
++ ldb r4,small_external_common(r0)
++ ldb r4,big_local_common(r0)
++ ldb r4,small_local_common(r0)
++ ldb r4,data_label+4(r0)
++ ldb r4,big_external_data_label+4(r0)
++ ldb r4,small_external_data_label+4(r0)
++ ldb r4,big_external_common+4(r0)
++ ldb r4,small_external_common+4(r0)
++ ldb r4,big_local_common+4(r0)
++ ldb r4,small_local_common+4(r0)
++ ldb r4,data_label-0x8000(r0)
++ ldb r4,big_external_data_label-0x8000(r0)
++ ldb r4,small_external_data_label-0x8000(r0)
++ ldb r4,big_external_common-0x8000(r0)
++ ldb r4,small_external_common-0x8000(r0)
++ ldb r4,big_local_common-0x8000(r0)
++ ldb r4,small_local_common-0x8000(r0)
++ ldb r4,data_label+0x10000(r0)
++ ldb r4,data_label(r5)
++ ldb r4,big_external_data_label(r5)
++ ldb r4,small_external_data_label(r5)
++ ldb r4,big_external_common(r5)
++ ldb r4,small_external_common(r5)
++ ldb r4,big_local_common(r5)
++ ldb r4,small_local_common(r5)
++ ldb r4,data_label+4(r5)
++ ldb r4,big_external_data_label+4(r5)
++ ldb r4,small_external_data_label+4(r5)
++ ldb r4,big_external_common+4(r5)
++ ldb r4,small_external_common+4(r5)
++ ldb r4,big_local_common+4(r5)
++ ldb r4,small_local_common+4(r5)
++ ldb r4,data_label-0x8000(r5)
++ ldb r4,big_external_data_label-0x8000(r5)
++ ldb r4,small_external_data_label-0x8000(r5)
++ ldb r4,big_external_common-0x8000(r5)
++ ldb r4,small_external_common-0x8000(r5)
++ ldb r4,big_local_common-0x8000(r5)
++ ldb r4,small_local_common-0x8000(r5)
++
++ ldbio r4,0(r0)
++ ldbio r4,4(r0)
++ ldbio r4,0x7ffc(r0)
++ ldbio r4,-0x8000(r0)
++ ldbio r4,0(r5)
++ ldbio r4,4(r5)
++ ldbio r4,0x7ffc(r5)
++ ldbio r4,-0x8000(r5)
++ ldbio r4,data_label(r0)
++ ldbio r4,big_external_data_label(r0)
++ ldbio r4,small_external_data_label(r0)
++ ldbio r4,big_external_common(r0)
++ ldbio r4,small_external_common(r0)
++ ldbio r4,big_local_common(r0)
++ ldbio r4,small_local_common(r0)
++ ldbio r4,data_label+4(r0)
++ ldbio r4,big_external_data_label+4(r0)
++ ldbio r4,small_external_data_label+4(r0)
++ ldbio r4,big_external_common+4(r0)
++ ldbio r4,small_external_common+4(r0)
++ ldbio r4,big_local_common+4(r0)
++ ldbio r4,small_local_common+4(r0)
++ ldbio r4,data_label-0x8000(r0)
++ ldbio r4,big_external_data_label-0x8000(r0)
++ ldbio r4,small_external_data_label-0x8000(r0)
++ ldbio r4,big_external_common-0x8000(r0)
++ ldbio r4,small_external_common-0x8000(r0)
++ ldbio r4,big_local_common-0x8000(r0)
++ ldbio r4,small_local_common-0x8000(r0)
++ ldbio r4,data_label+0x10000(r0)
++ ldbio r4,data_label(r5)
++ ldbio r4,big_external_data_label(r5)
++ ldbio r4,small_external_data_label(r5)
++ ldbio r4,big_external_common(r5)
++ ldbio r4,small_external_common(r5)
++ ldbio r4,big_local_common(r5)
++ ldbio r4,small_local_common(r5)
++ ldbio r4,data_label+4(r5)
++ ldbio r4,big_external_data_label+4(r5)
++ ldbio r4,small_external_data_label+4(r5)
++ ldbio r4,big_external_common+4(r5)
++ ldbio r4,small_external_common+4(r5)
++ ldbio r4,big_local_common+4(r5)
++ ldbio r4,small_local_common+4(r5)
++ ldbio r4,data_label-0x8000(r5)
++ ldbio r4,big_external_data_label-0x8000(r5)
++ ldbio r4,small_external_data_label-0x8000(r5)
++ ldbio r4,big_external_common-0x8000(r5)
++ ldbio r4,small_external_common-0x8000(r5)
++ ldbio r4,big_local_common-0x8000(r5)
++ ldbio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/ldh.d b/gas/testsuite/gas/nios2/ldh.d
+new file mode 100644
+index 0000000..54c2f7e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldh.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 ldh
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> ldh r4,0\(zero\)
++0+0004 <[^>]*> ldh r4,4\(zero\)
++0+0008 <[^>]*> ldh r4,32764\(zero\)
++0+000c <[^>]*> ldh r4,-32768\(zero\)
++0+0010 <[^>]*> ldh r4,0\(r5\)
++0+0014 <[^>]*> ldh r4,4\(r5\)
++0+0018 <[^>]*> ldh r4,32764\(r5\)
++0+001c <[^>]*> ldh r4,-32768\(r5\)
++0+0020 <[^>]*> ldh r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> ldh r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> ldh r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> ldh r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> ldh r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> ldh r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> ldh r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> ldh r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> ldh r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> ldh r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> ldh r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> ldh r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> ldh r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> ldh r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> ldh r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> ldh r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> ldh r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> ldh r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> ldh r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> ldh r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> ldh r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> ldh r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> ldh r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> ldh r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> ldh r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> ldh r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> ldh r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> ldh r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> ldh r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> ldh r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> ldh r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> ldh r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> ldh r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> ldh r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> ldh r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> ldh r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> ldh r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> ldh r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> ldh r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> ldh r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> ldh r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> ldh r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> ldh r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> ldhio r4,0\(zero\)
++0+00d0 <[^>]*> ldhio r4,4\(zero\)
++0+00d4 <[^>]*> ldhio r4,32764\(zero\)
++0+00d8 <[^>]*> ldhio r4,-32768\(zero\)
++0+00dc <[^>]*> ldhio r4,0\(r5\)
++0+00e0 <[^>]*> ldhio r4,4\(r5\)
++0+00e4 <[^>]*> ldhio r4,32764\(r5\)
++0+00e8 <[^>]*> ldhio r4,-32768\(r5\)
++0+00ec <[^>]*> ldhio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> ldhio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> ldhio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> ldhio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> ldhio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> ldhio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> ldhio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> ldhio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> ldhio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> ldhio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> ldhio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> ldhio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> ldhio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> ldhio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> ldhio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> ldhio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> ldhio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> ldhio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> ldhio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> ldhio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> ldhio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> ldhio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> ldhio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> ldhio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> ldhio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> ldhio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> ldhio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> ldhio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> ldhio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> ldhio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> ldhio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> ldhio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> ldhio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> ldhio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> ldhio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> ldhio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> ldhio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> ldhio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> ldhio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> ldhio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> ldhio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> ldhio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> ldhio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/ldh.s b/gas/testsuite/gas/nios2/ldh.s
+new file mode 100644
+index 0000000..87040ee
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldh.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ ldh r4,0(r0)
++ ldh r4,4(r0)
++ ldh r4,0x7ffc(r0)
++ ldh r4,-0x8000(r0)
++ ldh r4,0(r5)
++ ldh r4,4(r5)
++ ldh r4,0x7ffc(r5)
++ ldh r4,-0x8000(r5)
++ ldh r4,data_label(r0)
++ ldh r4,big_external_data_label(r0)
++ ldh r4,small_external_data_label(r0)
++ ldh r4,big_external_common(r0)
++ ldh r4,small_external_common(r0)
++ ldh r4,big_local_common(r0)
++ ldh r4,small_local_common(r0)
++ ldh r4,data_label+4(r0)
++ ldh r4,big_external_data_label+4(r0)
++ ldh r4,small_external_data_label+4(r0)
++ ldh r4,big_external_common+4(r0)
++ ldh r4,small_external_common+4(r0)
++ ldh r4,big_local_common+4(r0)
++ ldh r4,small_local_common+4(r0)
++ ldh r4,data_label-0x8000(r0)
++ ldh r4,big_external_data_label-0x8000(r0)
++ ldh r4,small_external_data_label-0x8000(r0)
++ ldh r4,big_external_common-0x8000(r0)
++ ldh r4,small_external_common-0x8000(r0)
++ ldh r4,big_local_common-0x8000(r0)
++ ldh r4,small_local_common-0x8000(r0)
++ ldh r4,data_label+0x10000(r0)
++ ldh r4,data_label(r5)
++ ldh r4,big_external_data_label(r5)
++ ldh r4,small_external_data_label(r5)
++ ldh r4,big_external_common(r5)
++ ldh r4,small_external_common(r5)
++ ldh r4,big_local_common(r5)
++ ldh r4,small_local_common(r5)
++ ldh r4,data_label+4(r5)
++ ldh r4,big_external_data_label+4(r5)
++ ldh r4,small_external_data_label+4(r5)
++ ldh r4,big_external_common+4(r5)
++ ldh r4,small_external_common+4(r5)
++ ldh r4,big_local_common+4(r5)
++ ldh r4,small_local_common+4(r5)
++ ldh r4,data_label-0x8000(r5)
++ ldh r4,big_external_data_label-0x8000(r5)
++ ldh r4,small_external_data_label-0x8000(r5)
++ ldh r4,big_external_common-0x8000(r5)
++ ldh r4,small_external_common-0x8000(r5)
++ ldh r4,big_local_common-0x8000(r5)
++ ldh r4,small_local_common-0x8000(r5)
++
++ ldhio r4,0(r0)
++ ldhio r4,4(r0)
++ ldhio r4,0x7ffc(r0)
++ ldhio r4,-0x8000(r0)
++ ldhio r4,0(r5)
++ ldhio r4,4(r5)
++ ldhio r4,0x7ffc(r5)
++ ldhio r4,-0x8000(r5)
++ ldhio r4,data_label(r0)
++ ldhio r4,big_external_data_label(r0)
++ ldhio r4,small_external_data_label(r0)
++ ldhio r4,big_external_common(r0)
++ ldhio r4,small_external_common(r0)
++ ldhio r4,big_local_common(r0)
++ ldhio r4,small_local_common(r0)
++ ldhio r4,data_label+4(r0)
++ ldhio r4,big_external_data_label+4(r0)
++ ldhio r4,small_external_data_label+4(r0)
++ ldhio r4,big_external_common+4(r0)
++ ldhio r4,small_external_common+4(r0)
++ ldhio r4,big_local_common+4(r0)
++ ldhio r4,small_local_common+4(r0)
++ ldhio r4,data_label-0x8000(r0)
++ ldhio r4,big_external_data_label-0x8000(r0)
++ ldhio r4,small_external_data_label-0x8000(r0)
++ ldhio r4,big_external_common-0x8000(r0)
++ ldhio r4,small_external_common-0x8000(r0)
++ ldhio r4,big_local_common-0x8000(r0)
++ ldhio r4,small_local_common-0x8000(r0)
++ ldhio r4,data_label+0x10000(r0)
++ ldhio r4,data_label(r5)
++ ldhio r4,big_external_data_label(r5)
++ ldhio r4,small_external_data_label(r5)
++ ldhio r4,big_external_common(r5)
++ ldhio r4,small_external_common(r5)
++ ldhio r4,big_local_common(r5)
++ ldhio r4,small_local_common(r5)
++ ldhio r4,data_label+4(r5)
++ ldhio r4,big_external_data_label+4(r5)
++ ldhio r4,small_external_data_label+4(r5)
++ ldhio r4,big_external_common+4(r5)
++ ldhio r4,small_external_common+4(r5)
++ ldhio r4,big_local_common+4(r5)
++ ldhio r4,small_local_common+4(r5)
++ ldhio r4,data_label-0x8000(r5)
++ ldhio r4,big_external_data_label-0x8000(r5)
++ ldhio r4,small_external_data_label-0x8000(r5)
++ ldhio r4,big_external_common-0x8000(r5)
++ ldhio r4,small_external_common-0x8000(r5)
++ ldhio r4,big_local_common-0x8000(r5)
++ ldhio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/ldw.d b/gas/testsuite/gas/nios2/ldw.d
+new file mode 100644
+index 0000000..a9a6905
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldw.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 ldw
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> ldw r4,0\(zero\)
++0+0004 <[^>]*> ldw r4,4\(zero\)
++0+0008 <[^>]*> ldw r4,32764\(zero\)
++0+000c <[^>]*> ldw r4,-32768\(zero\)
++0+0010 <[^>]*> ldw r4,0\(r5\)
++0+0014 <[^>]*> ldw r4,4\(r5\)
++0+0018 <[^>]*> ldw r4,32764\(r5\)
++0+001c <[^>]*> ldw r4,-32768\(r5\)
++0+0020 <[^>]*> ldw r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> ldw r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> ldw r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> ldw r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> ldw r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> ldw r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> ldw r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> ldw r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> ldw r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> ldw r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> ldw r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> ldw r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> ldw r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> ldw r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> ldw r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> ldw r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> ldw r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> ldw r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> ldw r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> ldw r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> ldw r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> ldw r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> ldw r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> ldw r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> ldw r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> ldw r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> ldw r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> ldw r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> ldw r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> ldw r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> ldw r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> ldw r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> ldw r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> ldw r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> ldw r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> ldw r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> ldw r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> ldw r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> ldw r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> ldw r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> ldw r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> ldw r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> ldw r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> ldwio r4,0\(zero\)
++0+00d0 <[^>]*> ldwio r4,4\(zero\)
++0+00d4 <[^>]*> ldwio r4,32764\(zero\)
++0+00d8 <[^>]*> ldwio r4,-32768\(zero\)
++0+00dc <[^>]*> ldwio r4,0\(r5\)
++0+00e0 <[^>]*> ldwio r4,4\(r5\)
++0+00e4 <[^>]*> ldwio r4,32764\(r5\)
++0+00e8 <[^>]*> ldwio r4,-32768\(r5\)
++0+00ec <[^>]*> ldwio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> ldwio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> ldwio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> ldwio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> ldwio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> ldwio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> ldwio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> ldwio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> ldwio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> ldwio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> ldwio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> ldwio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> ldwio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> ldwio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> ldwio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> ldwio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> ldwio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> ldwio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> ldwio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> ldwio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> ldwio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> ldwio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> ldwio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> ldwio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> ldwio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> ldwio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> ldwio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> ldwio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> ldwio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> ldwio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> ldwio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> ldwio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> ldwio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> ldwio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> ldwio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> ldwio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> ldwio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> ldwio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> ldwio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> ldwio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> ldwio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> ldwio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> ldwio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/ldw.s b/gas/testsuite/gas/nios2/ldw.s
+new file mode 100644
+index 0000000..cf6de19
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ldw.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ ldw r4,0(r0)
++ ldw r4,4(r0)
++ ldw r4,0x7ffc(r0)
++ ldw r4,-0x8000(r0)
++ ldw r4,0(r5)
++ ldw r4,4(r5)
++ ldw r4,0x7ffc(r5)
++ ldw r4,-0x8000(r5)
++ ldw r4,data_label(r0)
++ ldw r4,big_external_data_label(r0)
++ ldw r4,small_external_data_label(r0)
++ ldw r4,big_external_common(r0)
++ ldw r4,small_external_common(r0)
++ ldw r4,big_local_common(r0)
++ ldw r4,small_local_common(r0)
++ ldw r4,data_label+4(r0)
++ ldw r4,big_external_data_label+4(r0)
++ ldw r4,small_external_data_label+4(r0)
++ ldw r4,big_external_common+4(r0)
++ ldw r4,small_external_common+4(r0)
++ ldw r4,big_local_common+4(r0)
++ ldw r4,small_local_common+4(r0)
++ ldw r4,data_label-0x8000(r0)
++ ldw r4,big_external_data_label-0x8000(r0)
++ ldw r4,small_external_data_label-0x8000(r0)
++ ldw r4,big_external_common-0x8000(r0)
++ ldw r4,small_external_common-0x8000(r0)
++ ldw r4,big_local_common-0x8000(r0)
++ ldw r4,small_local_common-0x8000(r0)
++ ldw r4,data_label+0x10000(r0)
++ ldw r4,data_label(r5)
++ ldw r4,big_external_data_label(r5)
++ ldw r4,small_external_data_label(r5)
++ ldw r4,big_external_common(r5)
++ ldw r4,small_external_common(r5)
++ ldw r4,big_local_common(r5)
++ ldw r4,small_local_common(r5)
++ ldw r4,data_label+4(r5)
++ ldw r4,big_external_data_label+4(r5)
++ ldw r4,small_external_data_label+4(r5)
++ ldw r4,big_external_common+4(r5)
++ ldw r4,small_external_common+4(r5)
++ ldw r4,big_local_common+4(r5)
++ ldw r4,small_local_common+4(r5)
++ ldw r4,data_label-0x8000(r5)
++ ldw r4,big_external_data_label-0x8000(r5)
++ ldw r4,small_external_data_label-0x8000(r5)
++ ldw r4,big_external_common-0x8000(r5)
++ ldw r4,small_external_common-0x8000(r5)
++ ldw r4,big_local_common-0x8000(r5)
++ ldw r4,small_local_common-0x8000(r5)
++
++ ldwio r4,0(r0)
++ ldwio r4,4(r0)
++ ldwio r4,0x7ffc(r0)
++ ldwio r4,-0x8000(r0)
++ ldwio r4,0(r5)
++ ldwio r4,4(r5)
++ ldwio r4,0x7ffc(r5)
++ ldwio r4,-0x8000(r5)
++ ldwio r4,data_label(r0)
++ ldwio r4,big_external_data_label(r0)
++ ldwio r4,small_external_data_label(r0)
++ ldwio r4,big_external_common(r0)
++ ldwio r4,small_external_common(r0)
++ ldwio r4,big_local_common(r0)
++ ldwio r4,small_local_common(r0)
++ ldwio r4,data_label+4(r0)
++ ldwio r4,big_external_data_label+4(r0)
++ ldwio r4,small_external_data_label+4(r0)
++ ldwio r4,big_external_common+4(r0)
++ ldwio r4,small_external_common+4(r0)
++ ldwio r4,big_local_common+4(r0)
++ ldwio r4,small_local_common+4(r0)
++ ldwio r4,data_label-0x8000(r0)
++ ldwio r4,big_external_data_label-0x8000(r0)
++ ldwio r4,small_external_data_label-0x8000(r0)
++ ldwio r4,big_external_common-0x8000(r0)
++ ldwio r4,small_external_common-0x8000(r0)
++ ldwio r4,big_local_common-0x8000(r0)
++ ldwio r4,small_local_common-0x8000(r0)
++ ldwio r4,data_label+0x10000(r0)
++ ldwio r4,data_label(r5)
++ ldwio r4,big_external_data_label(r5)
++ ldwio r4,small_external_data_label(r5)
++ ldwio r4,big_external_common(r5)
++ ldwio r4,small_external_common(r5)
++ ldwio r4,big_local_common(r5)
++ ldwio r4,small_local_common(r5)
++ ldwio r4,data_label+4(r5)
++ ldwio r4,big_external_data_label+4(r5)
++ ldwio r4,small_external_data_label+4(r5)
++ ldwio r4,big_external_common+4(r5)
++ ldwio r4,small_external_common+4(r5)
++ ldwio r4,big_local_common+4(r5)
++ ldwio r4,small_local_common+4(r5)
++ ldwio r4,data_label-0x8000(r5)
++ ldwio r4,big_external_data_label-0x8000(r5)
++ ldwio r4,small_external_data_label-0x8000(r5)
++ ldwio r4,big_external_common-0x8000(r5)
++ ldwio r4,small_external_common-0x8000(r5)
++ ldwio r4,big_local_common-0x8000(r5)
++ ldwio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/lineseparator.d b/gas/testsuite/gas/nios2/lineseparator.d
+new file mode 100644
+index 0000000..09c66ea
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/lineseparator.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 lineseparator
++
++# Test the add instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0x0+0000 mov r5,r4
++0x0+0004 mov r4,r5
+diff --git a/gas/testsuite/gas/nios2/lineseparator.s b/gas/testsuite/gas/nios2/lineseparator.s
+new file mode 100644
+index 0000000..d16efc3
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/lineseparator.s
+@@ -0,0 +1,4 @@
++mov r5, r4 ; mov r4, r5
++
++
++
+diff --git a/gas/testsuite/gas/nios2/link1.lds b/gas/testsuite/gas/nios2/link1.lds
+new file mode 100644
+index 0000000..df6c220
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/link1.lds
+@@ -0,0 +1,11 @@
++/* Simple script for testing relaxation */
++
++OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
++OUTPUT_ARCH(nios2)
++ENTRY(_start)
++SECTIONS
++{
++ _start = .;
++ text2 0 : { *(text2) }
++ text1 0x8000 : { *(text1) }
++}
+diff --git a/gas/testsuite/gas/nios2/link2.lds b/gas/testsuite/gas/nios2/link2.lds
+new file mode 100644
+index 0000000..ee46354
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/link2.lds
+@@ -0,0 +1,11 @@
++/* Simple script for testing relaxation */
++
++OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
++OUTPUT_ARCH(nios2)
++ENTRY(_start)
++SECTIONS
++{
++ _start = .;
++ text1 0 : { *(text1) }
++ text2 0x80000000 : { *(text2) }
++}
+diff --git a/gas/testsuite/gas/nios2/link3.lds b/gas/testsuite/gas/nios2/link3.lds
+new file mode 100644
+index 0000000..bc02d40
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/link3.lds
+@@ -0,0 +1,11 @@
++/* Simple script for testing relaxation */
++
++OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
++OUTPUT_ARCH(nios2)
++ENTRY(_start)
++SECTIONS
++{
++ _start = .;
++ text1 0 : { *(text1) }
++ text2 0x08000000 : { *(text2) }
++}
+diff --git a/gas/testsuite/gas/nios2/mov.d b/gas/testsuite/gas/nios2/mov.d
+new file mode 100644
+index 0000000..13bf6db
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/mov.d
+@@ -0,0 +1,11 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 mov
++
++# Test the mov instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> movz \$4,\$5,\$6
++0+0004 <[^>]*> movnz \$4,\$5,\$6
++
+diff --git a/gas/testsuite/gas/nios2/mov.s b/gas/testsuite/gas/nios2/mov.s
+new file mode 100644
+index 0000000..a66aaeb
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/mov.s
+@@ -0,0 +1,5 @@
++# Source file used to test the movz and movnz instructions
++
++foo:
++ movz $4,$5,$6
++ movnz $4,$5,$6
+diff --git a/gas/testsuite/gas/nios2/movi.d b/gas/testsuite/gas/nios2/movi.d
+new file mode 100644
+index 0000000..9e35c7b
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/movi.d
+@@ -0,0 +1,13 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 movi
++
++# Test implicit conversion of movi/movhi etc
++.*: file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> movi r2,32
++0+0004 <[^>]*> movhi r2,8192
++0+0008 <[^>]*> movhi r2,65535
++0+000c <[^>]*> orhi r2,r5,65535
++0+0010 <[^>]*> xorhi r2,r10,65535
++0+0014 <[^>]*> andhi r2,r15,65535
+diff --git a/gas/testsuite/gas/nios2/movi.s b/gas/testsuite/gas/nios2/movi.s
+new file mode 100644
+index 0000000..07d9fed
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/movi.s
+@@ -0,0 +1,21 @@
++# Source file used to test silent conversion of
++# movi to orhi etc
++
++foo:
++# this doesn't get converted
++movi r2, 0x20
++
++# this does
++movi r2, 0x20000000
++
++# addi should convert only if the source register is r0
++addi r2, r0, 0xffff0000
++# but we can't test for non-conversion because the value would
++# be out of range
++
++# logical ops should convert for any register
++ori r2, r5, 0xffff0000
++xori r2, r10, 0xffff0000
++andi r2, r15, 0xffff0000
++
++
+diff --git a/gas/testsuite/gas/nios2/movia.d b/gas/testsuite/gas/nios2/movia.d
+new file mode 100644
+index 0000000..78a2559
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/movia.d
+@@ -0,0 +1,18 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 movia
++
++# Test the movia instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> movhi r2,32897
++0+0004 <[^>]*> addi r2,r2,-32640
++0+0008 <[^>]*> movhi r3,0
++ 8: R_NIOS2_HIADJ16 sym\+0x80000000
++0+000c <[^>]*> addi r3,r3,0
++ c: R_NIOS2_LO16 sym\+0x80000000
++0+0010 <[^>]*> movhi r4,0
++ 10: R_NIOS2_HIADJ16 sym\+0x80000001
++0+0014 <[^>]*> addi r4,r4,0
++ 14: R_NIOS2_LO16 sym\+0x80000001
+diff --git a/gas/testsuite/gas/nios2/movia.s b/gas/testsuite/gas/nios2/movia.s
+new file mode 100644
+index 0000000..fe1d56c
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/movia.s
+@@ -0,0 +1,6 @@
++# Test program for movia reg, immed32 macro
++
++foo:
++ movia r2, 0x80808080
++ movia r3, sym + 0x80000000
++ movia r4, sym - 0x7fffffff
+diff --git a/gas/testsuite/gas/nios2/mul.d b/gas/testsuite/gas/nios2/mul.d
+new file mode 100644
+index 0000000..79e86d1
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/mul.d
+@@ -0,0 +1,19 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 mul
++
++# Test the mul macro.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> mul r4,r5,r6
++0+0004 <[^>]*> muli r4,r5,0
++0+0008 <[^>]*> muli r4,r5,1
++0+000c <[^>]*> muli r4,r5,-32768
++0+0010 <[^>]*> muli r4,r5,32767
++0+0014 <[^>]*> muli r4,r5,0
++[ ]*14: R_NIOS2_S16 undefined_symbol
++0+0018 <[^>]*> muli r4,r5,16448
++0+001c <[^>]*> mulxss r4,r5,r6
++0+0020 <[^>]*> mulxsu r4,r5,r6
++0+0024 <[^>]*> mulxuu r4,r5,r6
+diff --git a/gas/testsuite/gas/nios2/mul.s b/gas/testsuite/gas/nios2/mul.s
+new file mode 100644
+index 0000000..3e47bc7
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/mul.s
+@@ -0,0 +1,15 @@
++# Source file used to test the mul macro.
++
++foo:
++ mul r4,r5,r6
++ muli r4,r5,0
++ muli r4,r5,1
++ muli r4,r5,-0x8000
++ muli r4,r5,0x7fff
++ muli r4,r5,undefined_symbol
++ muli r4,r5,defined_symbol
++ mulxss r4,r5,r6
++ mulxsu r4,r5,r6
++ mulxuu r4,r5,r6
++.data
++.set defined_symbol, 0x4040
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.d b/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.d
+new file mode 100644
+index 0000000..21c69e3
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.d
+@@ -0,0 +1,17 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 reloc against merged strings
++
++# Test the merged duplicate strings
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> addi r2,r2,32
++0+0004 <[^>]*> addi r3,r3,63
++0+0008 <[^>]*> addi r4,r4,70
++0+000c <[^>]*> call 00000000 <func1>
++0+0010 <[^>]*> addi r2,r2,101
++0+0014 <[^>]*> addi r3,r3,63
++0+0018 <[^>]*> addi r4,r4,132
++0+001c <[^>]*> call 00000000 <func1>
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.s b/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.s
+new file mode 100644
+index 0000000..1e14fdc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-merged_strings.s
+@@ -0,0 +1,21 @@
++ .section .rodata.str1.1,"aMS",@progbits,1
++.LC0:
++ .string "DHRYSTONE PROGRAM, 1'ST STRING"
++.LC1:
++ .string "COMMON"
++.LC2:
++ .string "DHRYSTONE PROGRAM, 2'ND STRING"
++
++ .section .text
++ .align 3
++ .global func1
++ .type func1, @function
++func1:
++ #movhi $2, %hiadj(.LC0)
++ addi r2, r2, .LC0
++ #movhi $3, %hiadj(.LC1)
++ addi r3, r3, .LC1
++ #movhi $4, %hiadj(.LC2)
++ addi r4, r4, .LC2
++ .size func1, .-func1
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.d
+new file mode 100644
+index 0000000..047745b
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.d
+@@ -0,0 +1,8 @@
++#objdump: -s
++#name: NIOS2 R_NIOS2_BFD_RELOC_XX
++
++# Test the branch instructions.
++.*: +file format elf32-littlenios2
++
++Contents of section .text:
++ 0000 fa00cefa efbeadde facefaef beadde00 ................
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.s
+new file mode 100644
+index 0000000..fff5ace
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-bfd-reloc-xx.s
+@@ -0,0 +1,9 @@
++# Test for New Jersey 32-bit, 16 and 8-bit relocations
++
++.global byte_sym
++.global short_sym
++.global long_sym
++
++.set byte_sym, 0xFA
++.set short_sym, 0xFACE
++.set long_sym, 0xDEADBEEF
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.d
+new file mode 100644
+index 0000000..2ee02e8
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 R_NIOS2_CACHE_OPX
++
++# Test the cache opx relocation
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> cache 0x1f,0x1000\(\$1\)
++0+0004 <[^>]*> Address 0x4 is out of bounds.
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.s
+new file mode 100644
+index 0000000..2c59174
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-cache-opx.s
+@@ -0,0 +1,6 @@
++# Test the imm5 relocation
++
++.text
++ cache imm5, 0x1000($1)
++
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.d
+new file mode 100644
+index 0000000..63364ef
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.d
+@@ -0,0 +1,76 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 nios2-reloc-r-nios2-call26
++
++# Test the branch instructions.
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++[ ]*\.\.\.
++[ ]*0: R_NIOS2_CALL26 .text\+0x100
++[ ]*4: R_NIOS2_CALL26 globalfunc
++0+0008 <[^>]*> nop
++0+000c <[^>]*> nop
++0+0010 <[^>]*> nop
++0+0014 <[^>]*> nop
++0+0018 <[^>]*> nop
++0+001c <[^>]*> nop
++0+0020 <[^>]*> nop
++0+0024 <[^>]*> nop
++0+0028 <[^>]*> nop
++0+002c <[^>]*> nop
++0+0030 <[^>]*> nop
++0+0034 <[^>]*> nop
++0+0038 <[^>]*> nop
++0+003c <[^>]*> nop
++0+0040 <[^>]*> nop
++0+0044 <[^>]*> nop
++0+0048 <[^>]*> nop
++0+004c <[^>]*> nop
++0+0050 <[^>]*> nop
++0+0054 <[^>]*> nop
++0+0058 <[^>]*> nop
++0+005c <[^>]*> nop
++0+0060 <[^>]*> nop
++0+0064 <[^>]*> nop
++0+0068 <[^>]*> nop
++0+006c <[^>]*> nop
++0+0070 <[^>]*> nop
++0+0074 <[^>]*> nop
++0+0078 <[^>]*> nop
++0+007c <[^>]*> nop
++0+0080 <[^>]*> nop
++0+0084 <[^>]*> nop
++0+0088 <[^>]*> nop
++0+008c <[^>]*> nop
++0+0090 <[^>]*> nop
++0+0094 <[^>]*> nop
++0+0098 <[^>]*> nop
++0+009c <[^>]*> nop
++0+00a0 <[^>]*> nop
++0+00a4 <[^>]*> nop
++0+00a8 <[^>]*> nop
++0+00ac <[^>]*> nop
++0+00b0 <[^>]*> nop
++0+00b4 <[^>]*> nop
++0+00b8 <[^>]*> nop
++0+00bc <[^>]*> nop
++0+00c0 <[^>]*> nop
++0+00c4 <[^>]*> nop
++0+00c8 <[^>]*> nop
++0+00cc <[^>]*> nop
++0+00d0 <[^>]*> nop
++0+00d4 <[^>]*> nop
++0+00d8 <[^>]*> nop
++0+00dc <[^>]*> nop
++0+00e0 <[^>]*> nop
++0+00e4 <[^>]*> nop
++0+00e8 <[^>]*> nop
++0+00ec <[^>]*> nop
++0+00f0 <[^>]*> nop
++0+00f4 <[^>]*> nop
++0+00f8 <[^>]*> nop
++0+00fc <[^>]*> nop
++0+0100 <[^>]*> nop
++ ...
++
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.s
+new file mode 100644
+index 0000000..b81896d
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-call26.s
+@@ -0,0 +1,12 @@
++# Test for New Jersey 32-bit relocations
++
++.global globalfunc
++.text
++.set norelax
++start:
++ call localfunc
++ call globalfunc
++
++.align 8
++localfunc:
++ nop
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.d
+new file mode 100644
+index 0000000..00c0023
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.d
+@@ -0,0 +1,15 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 gp-relative relocations
++
++# Test the %gprel macro.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> movui gp,32784
++0+0004 <[^>]*> ldw at,-32756\(gp\)
++0+0008 <[^>]*> ldw r2,-32752\(gp\)
++0+000c <[^>]*> ldb r3,-32748\(gp\)
++0+0010 <[^>]*> ldw at,-32744\(gp\)
++0+0014 <[^>]*> ldw r2,-32740\(gp\)
++0+0018 <[^>]*> ldb r3,-32736\(gp\)
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.s
+new file mode 100644
+index 0000000..5bdcc46
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-gprel.s
+@@ -0,0 +1,24 @@
++.sdata
++sym1:
++.long 0xdead
++sym2:
++.long 0xbeef
++sym3:
++.byte 0x7f
++
++.section sdata1, "s"
++sym4:
++.long 0xdead
++sym5:
++.long 0xbeef
++sym6:
++.byte 0x7f
++
++.text
++ movui gp, _gp
++ ldw r1, %gprel(sym1)(gp)
++ ldw r2, %gprel(sym2)(gp)
++ ldb r3, %gprel(sym3)(gp)
++ ldw r1, %gprel(sym4)(gp)
++ ldw r2, %gprel(sym5)(gp)
++ ldb r3, %gprel(sym6)(gp)
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.d
+new file mode 100644
+index 0000000..7a9e707
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 R_NIOS2_HI16,LO16,HIADJ16
++
++# Test the %hi, %lo and %hiadi relocations
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> addi at,at,-8531
++0+0004 <[^>]*> addi at,at,-16657
++0+0008 <[^>]*> addi at,at,-8530
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.s
+new file mode 100644
+index 0000000..266f2c7
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-hilo16.s
+@@ -0,0 +1,6 @@
++# Test the %hi, lo and %hiadj relocations
++
++.text
++ addi r1, r1, %hi(long_symbol)
++ addi r1, r1, %lo(long_symbol)
++ addi r1, r1, %hiadj(long_symbol)
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.d
+new file mode 100644
+index 0000000..8457747
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 R_NIOS2_IMM5
++
++# Test the branch instructions.
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> roli at,at,31
++0+0004 <.[^>]*> Address 0x4 is out of bounds.
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.s
+new file mode 100644
+index 0000000..fdec546
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-imm5.s
+@@ -0,0 +1,6 @@
++# Test the imm5 relocation
++
++.text
++ roli r1, r1, imm5
++
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.d
+new file mode 100644
+index 0000000..b9f9ae5
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.d
+@@ -0,0 +1,12 @@
++#objdump: -s
++#name: NIOS2 R_NIOS2_PCREL16
++
++# Test the relative branch relocations.
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++
++0+0000 <[^>]*> br 00000008 <ext_label>
++0+0004 <[^>]*> br 00000018 <__bss_start\+0x8>
++0+0008 <[^>]*> nop
++0+000c <[^>]*> nop
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.s
+new file mode 100644
+index 0000000..72970cc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-pcrel16.s
+@@ -0,0 +1,6 @@
++# Test for pc-relative relocations
++.set norelax
++.text
++ br ext_label
++ br ext_label + 16
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s.d
+new file mode 100644
+index 0000000..0230d0e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s.d
+@@ -0,0 +1,8 @@
++
++a.exe: file format elf32-littlenios2
++
++Contents of section .text:
++ 0000 04004408 04006008 c4ff5f08 44004808 ..D...`..._.D.H.
++ 0010 44004008 D.@.
++Contents of section .data:
++Contents of section .sbss:
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.d
+new file mode 100644
+index 0000000..0d0f535
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.d
+@@ -0,0 +1,9 @@
++#objdump: -s
++#name: NIOS2 R_NIOS2_S16
++
++# Test the signed 16-bit relocations.
++.*: +file format elf32-littlenios2
++
++Contents of section .text:
++ 0000 04004408 04006008 c4ff5f08 44004808 ..D...`..._.D.H.
++ 0010 44004008 D.@.
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.s
+new file mode 100644
+index 0000000..11986d1
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-s16.s
+@@ -0,0 +1,13 @@
++# Test for New Jersey 32-bit, 16 and 8-bit relocations
++
++.set some_other_sym, 0x1000
++.text
++# signed 16-bit relocation
++ addi r1, r1, some_sym
++ addi r1, r1, min
++ addi r1, r1, max
++ addi r1, r1, some_sym + some_other_sym + 1
++ addi r1, r1, some_sym - some_other_sym + 1
++
++
++
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.d b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.d
+new file mode 100644
+index 0000000..160dba2
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.d
+@@ -0,0 +1,9 @@
++#objdump: -s
++#name: NIOS2 R_NIOS2_U16
++
++# Test the unsigned 16-bit relocations.
++.*: +file format elf32-littlenios2
++
++Contents of section .text:
++ 0000 0c004408 0c004008 ccff7f08 4c004808 ..D...@.....L.H.
++ 0010 4c004008 L.@.
+diff --git a/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.s b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.s
+new file mode 100644
+index 0000000..0d78368
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2-reloc-r-nios2-u16.s
+@@ -0,0 +1,13 @@
++# Test for New Jersey 32-bit, 16 and 8-bit relocations
++
++.set some_other_sym, 0x1000
++.text
++# signed 16-bit relocation
++ andi r1, r1, some_sym
++ andi r1, r1, min
++ andi r1, r1, max
++ andi r1, r1, some_sym + some_other_sym + 1
++ andi r1, r1, some_sym - some_other_sym + 1
++
++
++
+diff --git a/gas/testsuite/gas/nios2/nios2.exp b/gas/testsuite/gas/nios2/nios2.exp
+new file mode 100644
+index 0000000..475e5e5
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nios2.exp
+@@ -0,0 +1,201 @@
++#
++# Some generic New Jersey tests
++#
++
++# "LOSE" marks information about tests which fail at a particular point
++# in time, but which are not XFAILed. Either they used to pass
++# and indicate either regressions or the need to tweak the tests to keep
++# up the with code, or they are new tests and it is unknown whether or not
++# they should pass as-is for the given object formats.
++
++if ![info exists LD] then {
++ set LD [findfile $base_dir/../../ld/ld-new]
++}
++
++proc run_list_test { name } {
++ global srcdir subdir
++ set testname "NIOS2 $name"
++ set file $srcdir/$subdir/$name
++ gas_run ${name}.s "" ">&dump.out"
++ if { [regexp_diff "dump.out" "${file}.l"] } then {
++ fail $testname
++ verbose "output is [file_contents "dump.out"]" 2
++ return
++ }
++ pass $testname
++}
++
++proc ld_run { obj0 obj1 opts } {
++ global LD
++ global comp_output
++ global srcdir
++ global subdir
++ global host_triplet
++
++ verbose "Executing $srcdir/lib/run $LD $obj0 $obj1 $opts"
++ catch "exec $srcdir/lib/run $LD $obj0 $obj1 $opts" comp_output
++ set comp_output [prune_warnings $comp_output]
++ verbose "output was $comp_output"
++ return [list $comp_output ""];
++}
++
++proc objdump_run { prog opts redir } {
++ global OBJDUMP
++ global comp_output
++ global srcdir
++ global subdir
++ global host_triplet
++
++ verbose "Executing $srcdir/lib/run $OBJDUMP -s $prog"
++ catch "exec $srcdir/lib/run $OBJDUMP $opts $prog $redir" comp_output
++ set comp_output [prune_warnings $comp_output]
++ verbose "output was $comp_output"
++ return [list $comp_output ""];
++}
++
++proc run_reloc_test { name other objdump_opts} {
++ global LD OBJDUMP AS
++ global srcdir subdir
++ set testname "NIOS2 $name"
++ set file $srcdir/$subdir/$name
++ set file1 $srcdir/$subdir/$other
++ gas_run ${name}.s "-o ${name}.o" ""
++ gas_run ${other}.s "-o ${other}.o" ""
++ ld_run ${name}.o ${other}.o "-o ${name}.exe"
++ objdump_run ${name}.exe ${objdump_opts} ">&dump.out"
++ if { [regexp_diff "dump.out" "${file}.d"] } then {
++ fail $testname
++ verbose "output is [file_contents "dump.out"]" 2
++ return
++ }
++ pass $testname
++}
++
++proc run_gpreloc_test { name objdump_opts} {
++ global LD OBJDUMP AS
++ global srcdir subdir
++ set testname "NIOS2 $name"
++ set file $srcdir/$subdir/$name
++ gas_run ${name}.s "-o ${name}.o" ""
++ ld_run ${name}.o "" "-o ${name}.exe"
++ objdump_run ${name}.exe ${objdump_opts} ">&dump.out"
++ if { [regexp_diff "dump.out" "${file}.d"] } then {
++ fail $testname
++ verbose "output is [file_contents "dump.out"]" 2
++ return
++ }
++ pass $testname
++}
++
++proc run_relax_test { name asm_opts link_opts objdump_opts} {
++ global LD OBJDUMP AS
++ global srcdir subdir
++ set testname "NIOS2 $name"
++ set file $srcdir/$subdir/$name
++ gas_run ${name}.s "-o ${name}.o" ${asm_opts}
++ ld_run ${name}.o "" "-o ${name}.exe -T${srcdir}/${subdir}/${link_opts} --relax"
++ objdump_run ${name}.exe ${objdump_opts} ">&dump.out"
++ if { [regexp_diff "dump.out" "${file}.d"] } then {
++ fail $testname
++ verbose "output is [file_contents "dump.out"]" 2
++ return
++ }
++ pass $testname
++}
++
++proc run_relax_section_test { name asm_opts objdump_opts} {
++ global LD OBJDUMP AS
++ global srcdir subdir
++ set testname "NIOS2 $name"
++ set file $srcdir/$subdir/$name
++ gas_run ${name}.s "-o ${name}.o" ${asm_opts}
++ ld_run ${name}.o "" "-o ${name}.exe"
++ objdump_run ${name}.exe ${objdump_opts} ">&dump.out"
++ if { [regexp_diff "dump.out" "${file}.d"] } then {
++ fail $testname
++ verbose "output is [file_contents "dump.out"]" 2
++ return
++ }
++ pass $testname
++}
++
++if { [istarget nios2-*-elf] } then {
++ set elf 1
++
++ run_dump_test "add"
++ run_dump_test "and"
++ run_dump_test "align_fill"
++ run_dump_test "align_text"
++
++ run_dump_test "branch"
++
++
++ run_dump_test "break"
++ run_dump_test "bret"
++ run_dump_test "cache"
++
++ run_dump_test "call"
++
++
++ run_dump_test "cmp"
++
++
++ run_dump_test "jmp"
++ run_dump_test "ldw"
++ run_dump_test "ldh"
++ run_dump_test "ldb"
++
++ run_dump_test "flushda"
++
++ run_dump_test "mul"
++
++ run_dump_test "nor"
++ run_dump_test "or"
++
++ run_dump_test "ctl"
++ run_dump_test "ret"
++ run_dump_test "rotate"
++
++ run_dump_test "stw"
++ run_dump_test "sth"
++ run_dump_test "stb"
++
++ run_dump_test "sub"
++ run_dump_test "sync"
++ run_dump_test "trap"
++ run_dump_test "tret"
++
++ run_dump_test "custom"
++ run_dump_test "xor"
++ run_dump_test "movia"
++
++ run_dump_test "complex"
++ run_dump_test "comments"
++ run_dump_test "etbt"
++ run_dump_test "lineseparator"
++ run_dump_test "movi"
++
++ run_list_test "illegal"
++ run_list_test "warn_nobreak"
++ run_list_test "warn_noat"
++
++
++# now lets make sure that the assembler generates all the relocations
++# that it should correctly, and that the linker links them correctly
++
++ run_reloc_test "nios2-reloc-r-nios2-bfd-reloc-xx" "reloc_symbols" "-s"
++ run_reloc_test "nios2-reloc-r-nios2-s16" "s16_symbol" "-s"
++ run_reloc_test "nios2-reloc-r-nios2-u16" "u16_symbol" "-s"
++ run_reloc_test "nios2-reloc-r-nios2-pcrel16" "pcrel_label" "-dr --prefix-addresses"
++ run_reloc_test "nios2-reloc-r-nios2-hilo16" "hilo_symbol" "-dr --prefix-addresses"
++ run_dump_test "nios2-reloc-r-nios2-call26"
++ run_reloc_test "nios2-reloc-r-nios2-imm5" "imm5_symbol" "-dr --prefix-addresses"
++ run_reloc_test "nios2-reloc-merged_strings" "str2" "-dr --prefix-addresses"
++ run_gpreloc_test "nios2-reloc-r-nios2-gprel" "-dr --prefix-addresses"
++
++# relaxation tests
++ run_relax_test "relax_ujmp" "-relax-all" "link1.lds" "-dr --prefix-addresses"
++ run_relax_test "relax_cjmp" "-relax-all" "link1.lds" "-dr --prefix-addresses"
++ run_relax_test "relax_callr" "-relax-all" "link3.lds" "-dr --prefix-addresses"
++ run_relax_section_test "relax_section" "-relax-section" "-dr --prefix-addresses"
++}
+diff --git a/gas/testsuite/gas/nios2/nor.d b/gas/testsuite/gas/nios2/nor.d
+new file mode 100644
+index 0000000..fab8e69
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nor.d
+@@ -0,0 +1,9 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 nor
++
++# Test the nor instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> nor r6,r8,r10
+diff --git a/gas/testsuite/gas/nios2/nor.s b/gas/testsuite/gas/nios2/nor.s
+new file mode 100644
+index 0000000..da78254
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/nor.s
+@@ -0,0 +1,5 @@
++# Source file used to test the nor instruction
++
++foo:
++ nor r6,r8,r10
++
+diff --git a/gas/testsuite/gas/nios2/or.d b/gas/testsuite/gas/nios2/or.d
+new file mode 100644
+index 0000000..e5035bc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/or.d
+@@ -0,0 +1,11 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 or
++
++# Test the nor instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> or r6,r8,r10
++0+0004 <[^>]*> orhi r6,r7,65535
++0+0008 <[^>]*> ori r6,r7,65535
+diff --git a/gas/testsuite/gas/nios2/or.s b/gas/testsuite/gas/nios2/or.s
+new file mode 100644
+index 0000000..675df17
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/or.s
+@@ -0,0 +1,7 @@
++# Source file used to test the nor instruction
++
++foo:
++ or r6,r8,r10
++ orhi r6,r7,0xffff
++ ori r6,r7,0xffff
++
+diff --git a/gas/testsuite/gas/nios2/pcrel_label.s b/gas/testsuite/gas/nios2/pcrel_label.s
+new file mode 100644
+index 0000000..3a76612
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/pcrel_label.s
+@@ -0,0 +1,5 @@
++.text
++ext_label:
++ nop
++ nop
++.global ext_label
+diff --git a/gas/testsuite/gas/nios2/relax_callr.d b/gas/testsuite/gas/nios2/relax_callr.d
+new file mode 100644
+index 0000000..6218c6d
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_callr.d
+@@ -0,0 +1,22 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 relax_callr
++# Test relaxation of callr
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section text1:
++00000000 <[^>]*> call 08000000 <func>
++00000004 <[^>]*> nop
++00000008 <[^>]*> nop
++0000000c <[^>]*> call 0800001c <func1>
++00000010 <[^>]*> nop
++00000014 <[^>]*> nop
++Disassembly of section text2:
++08000000 <[^>]*> nop
++08000004 <[^>]*> br 0800001c <func1>
++08000008 <[^>]*> nop
++0800000c <[^>]*> nop
++08000010 <[^>]*> nop
++08000014 <[^>]*> nop
++08000018 <[^>]*> nop
++0800001c <[^>]*> nop
+diff --git a/gas/testsuite/gas/nios2/relax_callr.s b/gas/testsuite/gas/nios2/relax_callr.s
+new file mode 100644
+index 0000000..b4cc2c4
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_callr.s
+@@ -0,0 +1,17 @@
++# relaxation test for callr
++
++.globl text1
++.section text1, "ax", @progbits
++
++ call func
++ call func1
++
++.section text2, "ax", @progbits
++func:
++ nop
++ br func1
++ nop
++ nop
++ nop
++func1:
++ nop
+diff --git a/gas/testsuite/gas/nios2/relax_cjmp.d b/gas/testsuite/gas/nios2/relax_cjmp.d
+new file mode 100644
+index 0000000..2b6d907
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_cjmp.d
+@@ -0,0 +1,8227 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 relax_cjmp
++
++# Test relaxation of conditional jumps
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section text2:
++00000000 <[^>]*> bge r2,r3,00008000 <[^>]*>
++00000004 <[^>]*> nop
++00000008 <[^>]*> nop
++0000000c <[^>]*> nop
++00000010 <[^>]*> blt r3,r2,00000020 <[^>]*>
++00000014 <[^>]*> movhi at,1
++00000018 <[^>]*> ori at,at,36
++0000001c <[^>]*> jmp at
++00000020 <[^>]*> bge r3,r2,00000038 <[^>]*>
++00000024 <[^>]*> nop
++00000028 <[^>]*> nop
++0000002c <[^>]*> nop
++00000030 <[^>]*> nop
++00000034 <[^>]*> nop
++00000038 <[^>]*> nop
++Disassembly of section text1:
++00008000 <[^>]*> beq r2,r3,00010000 <[^>]*>
++00008004 <[^>]*> nop
++00008008 <[^>]*> nop
++0000800c <[^>]*> nop
++00008010 <[^>]*> bne r2,r3,00008020 <[^>]*>
++00008014 <[^>]*> movhi at,1
++00008018 <[^>]*> ori at,at,36
++0000801c <[^>]*> jmp at
++00008020 <[^>]*> nop
++00008024 <[^>]*> nop
++00008028 <[^>]*> nop
++0000802c <[^>]*> nop
++00008030 <[^>]*> nop
++00008034 <[^>]*> nop
++00008038 <[^>]*> nop
++0000803c <[^>]*> nop
++00008040 <[^>]*> nop
++00008044 <[^>]*> nop
++00008048 <[^>]*> nop
++0000804c <[^>]*> nop
++00008050 <[^>]*> nop
++00008054 <[^>]*> nop
++00008058 <[^>]*> nop
++0000805c <[^>]*> nop
++00008060 <[^>]*> nop
++00008064 <[^>]*> nop
++00008068 <[^>]*> nop
++0000806c <[^>]*> nop
++00008070 <[^>]*> nop
++00008074 <[^>]*> nop
++00008078 <[^>]*> nop
++0000807c <[^>]*> nop
++00008080 <[^>]*> nop
++00008084 <[^>]*> nop
++00008088 <[^>]*> nop
++0000808c <[^>]*> nop
++00008090 <[^>]*> nop
++00008094 <[^>]*> nop
++00008098 <[^>]*> nop
++0000809c <[^>]*> nop
++000080a0 <[^>]*> nop
++000080a4 <[^>]*> nop
++000080a8 <[^>]*> nop
++000080ac <[^>]*> nop
++000080b0 <[^>]*> nop
++000080b4 <[^>]*> nop
++000080b8 <[^>]*> nop
++000080bc <[^>]*> nop
++000080c0 <[^>]*> nop
++000080c4 <[^>]*> nop
++000080c8 <[^>]*> nop
++000080cc <[^>]*> nop
++000080d0 <[^>]*> nop
++000080d4 <[^>]*> nop
++000080d8 <[^>]*> nop
++000080dc <[^>]*> nop
++000080e0 <[^>]*> nop
++000080e4 <[^>]*> nop
++000080e8 <[^>]*> nop
++000080ec <[^>]*> nop
++000080f0 <[^>]*> nop
++000080f4 <[^>]*> nop
++000080f8 <[^>]*> nop
++000080fc <[^>]*> nop
++00008100 <[^>]*> nop
++00008104 <[^>]*> nop
++00008108 <[^>]*> nop
++0000810c <[^>]*> nop
++00008110 <[^>]*> nop
++00008114 <[^>]*> nop
++00008118 <[^>]*> nop
++0000811c <[^>]*> nop
++00008120 <[^>]*> nop
++00008124 <[^>]*> nop
++00008128 <[^>]*> nop
++0000812c <[^>]*> nop
++00008130 <[^>]*> nop
++00008134 <[^>]*> nop
++00008138 <[^>]*> nop
++0000813c <[^>]*> nop
++00008140 <[^>]*> nop
++00008144 <[^>]*> nop
++00008148 <[^>]*> nop
++0000814c <[^>]*> nop
++00008150 <[^>]*> nop
++00008154 <[^>]*> nop
++00008158 <[^>]*> nop
++0000815c <[^>]*> nop
++00008160 <[^>]*> nop
++00008164 <[^>]*> nop
++00008168 <[^>]*> nop
++0000816c <[^>]*> nop
++00008170 <[^>]*> nop
++00008174 <[^>]*> nop
++00008178 <[^>]*> nop
++0000817c <[^>]*> nop
++00008180 <[^>]*> nop
++00008184 <[^>]*> nop
++00008188 <[^>]*> nop
++0000818c <[^>]*> nop
++00008190 <[^>]*> nop
++00008194 <[^>]*> nop
++00008198 <[^>]*> nop
++0000819c <[^>]*> nop
++000081a0 <[^>]*> nop
++000081a4 <[^>]*> nop
++000081a8 <[^>]*> nop
++000081ac <[^>]*> nop
++000081b0 <[^>]*> nop
++000081b4 <[^>]*> nop
++000081b8 <[^>]*> nop
++000081bc <[^>]*> nop
++000081c0 <[^>]*> nop
++000081c4 <[^>]*> nop
++000081c8 <[^>]*> nop
++000081cc <[^>]*> nop
++000081d0 <[^>]*> nop
++000081d4 <[^>]*> nop
++000081d8 <[^>]*> nop
++000081dc <[^>]*> nop
++000081e0 <[^>]*> nop
++000081e4 <[^>]*> nop
++000081e8 <[^>]*> nop
++000081ec <[^>]*> nop
++000081f0 <[^>]*> nop
++000081f4 <[^>]*> nop
++000081f8 <[^>]*> nop
++000081fc <[^>]*> nop
++00008200 <[^>]*> nop
++00008204 <[^>]*> nop
++00008208 <[^>]*> nop
++0000820c <[^>]*> nop
++00008210 <[^>]*> nop
++00008214 <[^>]*> nop
++00008218 <[^>]*> nop
++0000821c <[^>]*> nop
++00008220 <[^>]*> nop
++00008224 <[^>]*> nop
++00008228 <[^>]*> nop
++0000822c <[^>]*> nop
++00008230 <[^>]*> nop
++00008234 <[^>]*> nop
++00008238 <[^>]*> nop
++0000823c <[^>]*> nop
++00008240 <[^>]*> nop
++00008244 <[^>]*> nop
++00008248 <[^>]*> nop
++0000824c <[^>]*> nop
++00008250 <[^>]*> nop
++00008254 <[^>]*> nop
++00008258 <[^>]*> nop
++0000825c <[^>]*> nop
++00008260 <[^>]*> nop
++00008264 <[^>]*> nop
++00008268 <[^>]*> nop
++0000826c <[^>]*> nop
++00008270 <[^>]*> nop
++00008274 <[^>]*> nop
++00008278 <[^>]*> nop
++0000827c <[^>]*> nop
++00008280 <[^>]*> nop
++00008284 <[^>]*> nop
++00008288 <[^>]*> nop
++0000828c <[^>]*> nop
++00008290 <[^>]*> nop
++00008294 <[^>]*> nop
++00008298 <[^>]*> nop
++0000829c <[^>]*> nop
++000082a0 <[^>]*> nop
++000082a4 <[^>]*> nop
++000082a8 <[^>]*> nop
++000082ac <[^>]*> nop
++000082b0 <[^>]*> nop
++000082b4 <[^>]*> nop
++000082b8 <[^>]*> nop
++000082bc <[^>]*> nop
++000082c0 <[^>]*> nop
++000082c4 <[^>]*> nop
++000082c8 <[^>]*> nop
++000082cc <[^>]*> nop
++000082d0 <[^>]*> nop
++000082d4 <[^>]*> nop
++000082d8 <[^>]*> nop
++000082dc <[^>]*> nop
++000082e0 <[^>]*> nop
++000082e4 <[^>]*> nop
++000082e8 <[^>]*> nop
++000082ec <[^>]*> nop
++000082f0 <[^>]*> nop
++000082f4 <[^>]*> nop
++000082f8 <[^>]*> nop
++000082fc <[^>]*> nop
++00008300 <[^>]*> nop
++00008304 <[^>]*> nop
++00008308 <[^>]*> nop
++0000830c <[^>]*> nop
++00008310 <[^>]*> nop
++00008314 <[^>]*> nop
++00008318 <[^>]*> nop
++0000831c <[^>]*> nop
++00008320 <[^>]*> nop
++00008324 <[^>]*> nop
++00008328 <[^>]*> nop
++0000832c <[^>]*> nop
++00008330 <[^>]*> nop
++00008334 <[^>]*> nop
++00008338 <[^>]*> nop
++0000833c <[^>]*> nop
++00008340 <[^>]*> nop
++00008344 <[^>]*> nop
++00008348 <[^>]*> nop
++0000834c <[^>]*> nop
++00008350 <[^>]*> nop
++00008354 <[^>]*> nop
++00008358 <[^>]*> nop
++0000835c <[^>]*> nop
++00008360 <[^>]*> nop
++00008364 <[^>]*> nop
++00008368 <[^>]*> nop
++0000836c <[^>]*> nop
++00008370 <[^>]*> nop
++00008374 <[^>]*> nop
++00008378 <[^>]*> nop
++0000837c <[^>]*> nop
++00008380 <[^>]*> nop
++00008384 <[^>]*> nop
++00008388 <[^>]*> nop
++0000838c <[^>]*> nop
++00008390 <[^>]*> nop
++00008394 <[^>]*> nop
++00008398 <[^>]*> nop
++0000839c <[^>]*> nop
++000083a0 <[^>]*> nop
++000083a4 <[^>]*> nop
++000083a8 <[^>]*> nop
++000083ac <[^>]*> nop
++000083b0 <[^>]*> nop
++000083b4 <[^>]*> nop
++000083b8 <[^>]*> nop
++000083bc <[^>]*> nop
++000083c0 <[^>]*> nop
++000083c4 <[^>]*> nop
++000083c8 <[^>]*> nop
++000083cc <[^>]*> nop
++000083d0 <[^>]*> nop
++000083d4 <[^>]*> nop
++000083d8 <[^>]*> nop
++000083dc <[^>]*> nop
++000083e0 <[^>]*> nop
++000083e4 <[^>]*> nop
++000083e8 <[^>]*> nop
++000083ec <[^>]*> nop
++000083f0 <[^>]*> nop
++000083f4 <[^>]*> nop
++000083f8 <[^>]*> nop
++000083fc <[^>]*> nop
++00008400 <[^>]*> nop
++00008404 <[^>]*> nop
++00008408 <[^>]*> nop
++0000840c <[^>]*> nop
++00008410 <[^>]*> nop
++00008414 <[^>]*> nop
++00008418 <[^>]*> nop
++0000841c <[^>]*> nop
++00008420 <[^>]*> nop
++00008424 <[^>]*> nop
++00008428 <[^>]*> nop
++0000842c <[^>]*> nop
++00008430 <[^>]*> nop
++00008434 <[^>]*> nop
++00008438 <[^>]*> nop
++0000843c <[^>]*> nop
++00008440 <[^>]*> nop
++00008444 <[^>]*> nop
++00008448 <[^>]*> nop
++0000844c <[^>]*> nop
++00008450 <[^>]*> nop
++00008454 <[^>]*> nop
++00008458 <[^>]*> nop
++0000845c <[^>]*> nop
++00008460 <[^>]*> nop
++00008464 <[^>]*> nop
++00008468 <[^>]*> nop
++0000846c <[^>]*> nop
++00008470 <[^>]*> nop
++00008474 <[^>]*> nop
++00008478 <[^>]*> nop
++0000847c <[^>]*> nop
++00008480 <[^>]*> nop
++00008484 <[^>]*> nop
++00008488 <[^>]*> nop
++0000848c <[^>]*> nop
++00008490 <[^>]*> nop
++00008494 <[^>]*> nop
++00008498 <[^>]*> nop
++0000849c <[^>]*> nop
++000084a0 <[^>]*> nop
++000084a4 <[^>]*> nop
++000084a8 <[^>]*> nop
++000084ac <[^>]*> nop
++000084b0 <[^>]*> nop
++000084b4 <[^>]*> nop
++000084b8 <[^>]*> nop
++000084bc <[^>]*> nop
++000084c0 <[^>]*> nop
++000084c4 <[^>]*> nop
++000084c8 <[^>]*> nop
++000084cc <[^>]*> nop
++000084d0 <[^>]*> nop
++000084d4 <[^>]*> nop
++000084d8 <[^>]*> nop
++000084dc <[^>]*> nop
++000084e0 <[^>]*> nop
++000084e4 <[^>]*> nop
++000084e8 <[^>]*> nop
++000084ec <[^>]*> nop
++000084f0 <[^>]*> nop
++000084f4 <[^>]*> nop
++000084f8 <[^>]*> nop
++000084fc <[^>]*> nop
++00008500 <[^>]*> nop
++00008504 <[^>]*> nop
++00008508 <[^>]*> nop
++0000850c <[^>]*> nop
++00008510 <[^>]*> nop
++00008514 <[^>]*> nop
++00008518 <[^>]*> nop
++0000851c <[^>]*> nop
++00008520 <[^>]*> nop
++00008524 <[^>]*> nop
++00008528 <[^>]*> nop
++0000852c <[^>]*> nop
++00008530 <[^>]*> nop
++00008534 <[^>]*> nop
++00008538 <[^>]*> nop
++0000853c <[^>]*> nop
++00008540 <[^>]*> nop
++00008544 <[^>]*> nop
++00008548 <[^>]*> nop
++0000854c <[^>]*> nop
++00008550 <[^>]*> nop
++00008554 <[^>]*> nop
++00008558 <[^>]*> nop
++0000855c <[^>]*> nop
++00008560 <[^>]*> nop
++00008564 <[^>]*> nop
++00008568 <[^>]*> nop
++0000856c <[^>]*> nop
++00008570 <[^>]*> nop
++00008574 <[^>]*> nop
++00008578 <[^>]*> nop
++0000857c <[^>]*> nop
++00008580 <[^>]*> nop
++00008584 <[^>]*> nop
++00008588 <[^>]*> nop
++0000858c <[^>]*> nop
++00008590 <[^>]*> nop
++00008594 <[^>]*> nop
++00008598 <[^>]*> nop
++0000859c <[^>]*> nop
++000085a0 <[^>]*> nop
++000085a4 <[^>]*> nop
++000085a8 <[^>]*> nop
++000085ac <[^>]*> nop
++000085b0 <[^>]*> nop
++000085b4 <[^>]*> nop
++000085b8 <[^>]*> nop
++000085bc <[^>]*> nop
++000085c0 <[^>]*> nop
++000085c4 <[^>]*> nop
++000085c8 <[^>]*> nop
++000085cc <[^>]*> nop
++000085d0 <[^>]*> nop
++000085d4 <[^>]*> nop
++000085d8 <[^>]*> nop
++000085dc <[^>]*> nop
++000085e0 <[^>]*> nop
++000085e4 <[^>]*> nop
++000085e8 <[^>]*> nop
++000085ec <[^>]*> nop
++000085f0 <[^>]*> nop
++000085f4 <[^>]*> nop
++000085f8 <[^>]*> nop
++000085fc <[^>]*> nop
++00008600 <[^>]*> nop
++00008604 <[^>]*> nop
++00008608 <[^>]*> nop
++0000860c <[^>]*> nop
++00008610 <[^>]*> nop
++00008614 <[^>]*> nop
++00008618 <[^>]*> nop
++0000861c <[^>]*> nop
++00008620 <[^>]*> nop
++00008624 <[^>]*> nop
++00008628 <[^>]*> nop
++0000862c <[^>]*> nop
++00008630 <[^>]*> nop
++00008634 <[^>]*> nop
++00008638 <[^>]*> nop
++0000863c <[^>]*> nop
++00008640 <[^>]*> nop
++00008644 <[^>]*> nop
++00008648 <[^>]*> nop
++0000864c <[^>]*> nop
++00008650 <[^>]*> nop
++00008654 <[^>]*> nop
++00008658 <[^>]*> nop
++0000865c <[^>]*> nop
++00008660 <[^>]*> nop
++00008664 <[^>]*> nop
++00008668 <[^>]*> nop
++0000866c <[^>]*> nop
++00008670 <[^>]*> nop
++00008674 <[^>]*> nop
++00008678 <[^>]*> nop
++0000867c <[^>]*> nop
++00008680 <[^>]*> nop
++00008684 <[^>]*> nop
++00008688 <[^>]*> nop
++0000868c <[^>]*> nop
++00008690 <[^>]*> nop
++00008694 <[^>]*> nop
++00008698 <[^>]*> nop
++0000869c <[^>]*> nop
++000086a0 <[^>]*> nop
++000086a4 <[^>]*> nop
++000086a8 <[^>]*> nop
++000086ac <[^>]*> nop
++000086b0 <[^>]*> nop
++000086b4 <[^>]*> nop
++000086b8 <[^>]*> nop
++000086bc <[^>]*> nop
++000086c0 <[^>]*> nop
++000086c4 <[^>]*> nop
++000086c8 <[^>]*> nop
++000086cc <[^>]*> nop
++000086d0 <[^>]*> nop
++000086d4 <[^>]*> nop
++000086d8 <[^>]*> nop
++000086dc <[^>]*> nop
++000086e0 <[^>]*> nop
++000086e4 <[^>]*> nop
++000086e8 <[^>]*> nop
++000086ec <[^>]*> nop
++000086f0 <[^>]*> nop
++000086f4 <[^>]*> nop
++000086f8 <[^>]*> nop
++000086fc <[^>]*> nop
++00008700 <[^>]*> nop
++00008704 <[^>]*> nop
++00008708 <[^>]*> nop
++0000870c <[^>]*> nop
++00008710 <[^>]*> nop
++00008714 <[^>]*> nop
++00008718 <[^>]*> nop
++0000871c <[^>]*> nop
++00008720 <[^>]*> nop
++00008724 <[^>]*> nop
++00008728 <[^>]*> nop
++0000872c <[^>]*> nop
++00008730 <[^>]*> nop
++00008734 <[^>]*> nop
++00008738 <[^>]*> nop
++0000873c <[^>]*> nop
++00008740 <[^>]*> nop
++00008744 <[^>]*> nop
++00008748 <[^>]*> nop
++0000874c <[^>]*> nop
++00008750 <[^>]*> nop
++00008754 <[^>]*> nop
++00008758 <[^>]*> nop
++0000875c <[^>]*> nop
++00008760 <[^>]*> nop
++00008764 <[^>]*> nop
++00008768 <[^>]*> nop
++0000876c <[^>]*> nop
++00008770 <[^>]*> nop
++00008774 <[^>]*> nop
++00008778 <[^>]*> nop
++0000877c <[^>]*> nop
++00008780 <[^>]*> nop
++00008784 <[^>]*> nop
++00008788 <[^>]*> nop
++0000878c <[^>]*> nop
++00008790 <[^>]*> nop
++00008794 <[^>]*> nop
++00008798 <[^>]*> nop
++0000879c <[^>]*> nop
++000087a0 <[^>]*> nop
++000087a4 <[^>]*> nop
++000087a8 <[^>]*> nop
++000087ac <[^>]*> nop
++000087b0 <[^>]*> nop
++000087b4 <[^>]*> nop
++000087b8 <[^>]*> nop
++000087bc <[^>]*> nop
++000087c0 <[^>]*> nop
++000087c4 <[^>]*> nop
++000087c8 <[^>]*> nop
++000087cc <[^>]*> nop
++000087d0 <[^>]*> nop
++000087d4 <[^>]*> nop
++000087d8 <[^>]*> nop
++000087dc <[^>]*> nop
++000087e0 <[^>]*> nop
++000087e4 <[^>]*> nop
++000087e8 <[^>]*> nop
++000087ec <[^>]*> nop
++000087f0 <[^>]*> nop
++000087f4 <[^>]*> nop
++000087f8 <[^>]*> nop
++000087fc <[^>]*> nop
++00008800 <[^>]*> nop
++00008804 <[^>]*> nop
++00008808 <[^>]*> nop
++0000880c <[^>]*> nop
++00008810 <[^>]*> nop
++00008814 <[^>]*> nop
++00008818 <[^>]*> nop
++0000881c <[^>]*> nop
++00008820 <[^>]*> nop
++00008824 <[^>]*> nop
++00008828 <[^>]*> nop
++0000882c <[^>]*> nop
++00008830 <[^>]*> nop
++00008834 <[^>]*> nop
++00008838 <[^>]*> nop
++0000883c <[^>]*> nop
++00008840 <[^>]*> nop
++00008844 <[^>]*> nop
++00008848 <[^>]*> nop
++0000884c <[^>]*> nop
++00008850 <[^>]*> nop
++00008854 <[^>]*> nop
++00008858 <[^>]*> nop
++0000885c <[^>]*> nop
++00008860 <[^>]*> nop
++00008864 <[^>]*> nop
++00008868 <[^>]*> nop
++0000886c <[^>]*> nop
++00008870 <[^>]*> nop
++00008874 <[^>]*> nop
++00008878 <[^>]*> nop
++0000887c <[^>]*> nop
++00008880 <[^>]*> nop
++00008884 <[^>]*> nop
++00008888 <[^>]*> nop
++0000888c <[^>]*> nop
++00008890 <[^>]*> nop
++00008894 <[^>]*> nop
++00008898 <[^>]*> nop
++0000889c <[^>]*> nop
++000088a0 <[^>]*> nop
++000088a4 <[^>]*> nop
++000088a8 <[^>]*> nop
++000088ac <[^>]*> nop
++000088b0 <[^>]*> nop
++000088b4 <[^>]*> nop
++000088b8 <[^>]*> nop
++000088bc <[^>]*> nop
++000088c0 <[^>]*> nop
++000088c4 <[^>]*> nop
++000088c8 <[^>]*> nop
++000088cc <[^>]*> nop
++000088d0 <[^>]*> nop
++000088d4 <[^>]*> nop
++000088d8 <[^>]*> nop
++000088dc <[^>]*> nop
++000088e0 <[^>]*> nop
++000088e4 <[^>]*> nop
++000088e8 <[^>]*> nop
++000088ec <[^>]*> nop
++000088f0 <[^>]*> nop
++000088f4 <[^>]*> nop
++000088f8 <[^>]*> nop
++000088fc <[^>]*> nop
++00008900 <[^>]*> nop
++00008904 <[^>]*> nop
++00008908 <[^>]*> nop
++0000890c <[^>]*> nop
++00008910 <[^>]*> nop
++00008914 <[^>]*> nop
++00008918 <[^>]*> nop
++0000891c <[^>]*> nop
++00008920 <[^>]*> nop
++00008924 <[^>]*> nop
++00008928 <[^>]*> nop
++0000892c <[^>]*> nop
++00008930 <[^>]*> nop
++00008934 <[^>]*> nop
++00008938 <[^>]*> nop
++0000893c <[^>]*> nop
++00008940 <[^>]*> nop
++00008944 <[^>]*> nop
++00008948 <[^>]*> nop
++0000894c <[^>]*> nop
++00008950 <[^>]*> nop
++00008954 <[^>]*> nop
++00008958 <[^>]*> nop
++0000895c <[^>]*> nop
++00008960 <[^>]*> nop
++00008964 <[^>]*> nop
++00008968 <[^>]*> nop
++0000896c <[^>]*> nop
++00008970 <[^>]*> nop
++00008974 <[^>]*> nop
++00008978 <[^>]*> nop
++0000897c <[^>]*> nop
++00008980 <[^>]*> nop
++00008984 <[^>]*> nop
++00008988 <[^>]*> nop
++0000898c <[^>]*> nop
++00008990 <[^>]*> nop
++00008994 <[^>]*> nop
++00008998 <[^>]*> nop
++0000899c <[^>]*> nop
++000089a0 <[^>]*> nop
++000089a4 <[^>]*> nop
++000089a8 <[^>]*> nop
++000089ac <[^>]*> nop
++000089b0 <[^>]*> nop
++000089b4 <[^>]*> nop
++000089b8 <[^>]*> nop
++000089bc <[^>]*> nop
++000089c0 <[^>]*> nop
++000089c4 <[^>]*> nop
++000089c8 <[^>]*> nop
++000089cc <[^>]*> nop
++000089d0 <[^>]*> nop
++000089d4 <[^>]*> nop
++000089d8 <[^>]*> nop
++000089dc <[^>]*> nop
++000089e0 <[^>]*> nop
++000089e4 <[^>]*> nop
++000089e8 <[^>]*> nop
++000089ec <[^>]*> nop
++000089f0 <[^>]*> nop
++000089f4 <[^>]*> nop
++000089f8 <[^>]*> nop
++000089fc <[^>]*> nop
++00008a00 <[^>]*> nop
++00008a04 <[^>]*> nop
++00008a08 <[^>]*> nop
++00008a0c <[^>]*> nop
++00008a10 <[^>]*> nop
++00008a14 <[^>]*> nop
++00008a18 <[^>]*> nop
++00008a1c <[^>]*> nop
++00008a20 <[^>]*> nop
++00008a24 <[^>]*> nop
++00008a28 <[^>]*> nop
++00008a2c <[^>]*> nop
++00008a30 <[^>]*> nop
++00008a34 <[^>]*> nop
++00008a38 <[^>]*> nop
++00008a3c <[^>]*> nop
++00008a40 <[^>]*> nop
++00008a44 <[^>]*> nop
++00008a48 <[^>]*> nop
++00008a4c <[^>]*> nop
++00008a50 <[^>]*> nop
++00008a54 <[^>]*> nop
++00008a58 <[^>]*> nop
++00008a5c <[^>]*> nop
++00008a60 <[^>]*> nop
++00008a64 <[^>]*> nop
++00008a68 <[^>]*> nop
++00008a6c <[^>]*> nop
++00008a70 <[^>]*> nop
++00008a74 <[^>]*> nop
++00008a78 <[^>]*> nop
++00008a7c <[^>]*> nop
++00008a80 <[^>]*> nop
++00008a84 <[^>]*> nop
++00008a88 <[^>]*> nop
++00008a8c <[^>]*> nop
++00008a90 <[^>]*> nop
++00008a94 <[^>]*> nop
++00008a98 <[^>]*> nop
++00008a9c <[^>]*> nop
++00008aa0 <[^>]*> nop
++00008aa4 <[^>]*> nop
++00008aa8 <[^>]*> nop
++00008aac <[^>]*> nop
++00008ab0 <[^>]*> nop
++00008ab4 <[^>]*> nop
++00008ab8 <[^>]*> nop
++00008abc <[^>]*> nop
++00008ac0 <[^>]*> nop
++00008ac4 <[^>]*> nop
++00008ac8 <[^>]*> nop
++00008acc <[^>]*> nop
++00008ad0 <[^>]*> nop
++00008ad4 <[^>]*> nop
++00008ad8 <[^>]*> nop
++00008adc <[^>]*> nop
++00008ae0 <[^>]*> nop
++00008ae4 <[^>]*> nop
++00008ae8 <[^>]*> nop
++00008aec <[^>]*> nop
++00008af0 <[^>]*> nop
++00008af4 <[^>]*> nop
++00008af8 <[^>]*> nop
++00008afc <[^>]*> nop
++00008b00 <[^>]*> nop
++00008b04 <[^>]*> nop
++00008b08 <[^>]*> nop
++00008b0c <[^>]*> nop
++00008b10 <[^>]*> nop
++00008b14 <[^>]*> nop
++00008b18 <[^>]*> nop
++00008b1c <[^>]*> nop
++00008b20 <[^>]*> nop
++00008b24 <[^>]*> nop
++00008b28 <[^>]*> nop
++00008b2c <[^>]*> nop
++00008b30 <[^>]*> nop
++00008b34 <[^>]*> nop
++00008b38 <[^>]*> nop
++00008b3c <[^>]*> nop
++00008b40 <[^>]*> nop
++00008b44 <[^>]*> nop
++00008b48 <[^>]*> nop
++00008b4c <[^>]*> nop
++00008b50 <[^>]*> nop
++00008b54 <[^>]*> nop
++00008b58 <[^>]*> nop
++00008b5c <[^>]*> nop
++00008b60 <[^>]*> nop
++00008b64 <[^>]*> nop
++00008b68 <[^>]*> nop
++00008b6c <[^>]*> nop
++00008b70 <[^>]*> nop
++00008b74 <[^>]*> nop
++00008b78 <[^>]*> nop
++00008b7c <[^>]*> nop
++00008b80 <[^>]*> nop
++00008b84 <[^>]*> nop
++00008b88 <[^>]*> nop
++00008b8c <[^>]*> nop
++00008b90 <[^>]*> nop
++00008b94 <[^>]*> nop
++00008b98 <[^>]*> nop
++00008b9c <[^>]*> nop
++00008ba0 <[^>]*> nop
++00008ba4 <[^>]*> nop
++00008ba8 <[^>]*> nop
++00008bac <[^>]*> nop
++00008bb0 <[^>]*> nop
++00008bb4 <[^>]*> nop
++00008bb8 <[^>]*> nop
++00008bbc <[^>]*> nop
++00008bc0 <[^>]*> nop
++00008bc4 <[^>]*> nop
++00008bc8 <[^>]*> nop
++00008bcc <[^>]*> nop
++00008bd0 <[^>]*> nop
++00008bd4 <[^>]*> nop
++00008bd8 <[^>]*> nop
++00008bdc <[^>]*> nop
++00008be0 <[^>]*> nop
++00008be4 <[^>]*> nop
++00008be8 <[^>]*> nop
++00008bec <[^>]*> nop
++00008bf0 <[^>]*> nop
++00008bf4 <[^>]*> nop
++00008bf8 <[^>]*> nop
++00008bfc <[^>]*> nop
++00008c00 <[^>]*> nop
++00008c04 <[^>]*> nop
++00008c08 <[^>]*> nop
++00008c0c <[^>]*> nop
++00008c10 <[^>]*> nop
++00008c14 <[^>]*> nop
++00008c18 <[^>]*> nop
++00008c1c <[^>]*> nop
++00008c20 <[^>]*> nop
++00008c24 <[^>]*> nop
++00008c28 <[^>]*> nop
++00008c2c <[^>]*> nop
++00008c30 <[^>]*> nop
++00008c34 <[^>]*> nop
++00008c38 <[^>]*> nop
++00008c3c <[^>]*> nop
++00008c40 <[^>]*> nop
++00008c44 <[^>]*> nop
++00008c48 <[^>]*> nop
++00008c4c <[^>]*> nop
++00008c50 <[^>]*> nop
++00008c54 <[^>]*> nop
++00008c58 <[^>]*> nop
++00008c5c <[^>]*> nop
++00008c60 <[^>]*> nop
++00008c64 <[^>]*> nop
++00008c68 <[^>]*> nop
++00008c6c <[^>]*> nop
++00008c70 <[^>]*> nop
++00008c74 <[^>]*> nop
++00008c78 <[^>]*> nop
++00008c7c <[^>]*> nop
++00008c80 <[^>]*> nop
++00008c84 <[^>]*> nop
++00008c88 <[^>]*> nop
++00008c8c <[^>]*> nop
++00008c90 <[^>]*> nop
++00008c94 <[^>]*> nop
++00008c98 <[^>]*> nop
++00008c9c <[^>]*> nop
++00008ca0 <[^>]*> nop
++00008ca4 <[^>]*> nop
++00008ca8 <[^>]*> nop
++00008cac <[^>]*> nop
++00008cb0 <[^>]*> nop
++00008cb4 <[^>]*> nop
++00008cb8 <[^>]*> nop
++00008cbc <[^>]*> nop
++00008cc0 <[^>]*> nop
++00008cc4 <[^>]*> nop
++00008cc8 <[^>]*> nop
++00008ccc <[^>]*> nop
++00008cd0 <[^>]*> nop
++00008cd4 <[^>]*> nop
++00008cd8 <[^>]*> nop
++00008cdc <[^>]*> nop
++00008ce0 <[^>]*> nop
++00008ce4 <[^>]*> nop
++00008ce8 <[^>]*> nop
++00008cec <[^>]*> nop
++00008cf0 <[^>]*> nop
++00008cf4 <[^>]*> nop
++00008cf8 <[^>]*> nop
++00008cfc <[^>]*> nop
++00008d00 <[^>]*> nop
++00008d04 <[^>]*> nop
++00008d08 <[^>]*> nop
++00008d0c <[^>]*> nop
++00008d10 <[^>]*> nop
++00008d14 <[^>]*> nop
++00008d18 <[^>]*> nop
++00008d1c <[^>]*> nop
++00008d20 <[^>]*> nop
++00008d24 <[^>]*> nop
++00008d28 <[^>]*> nop
++00008d2c <[^>]*> nop
++00008d30 <[^>]*> nop
++00008d34 <[^>]*> nop
++00008d38 <[^>]*> nop
++00008d3c <[^>]*> nop
++00008d40 <[^>]*> nop
++00008d44 <[^>]*> nop
++00008d48 <[^>]*> nop
++00008d4c <[^>]*> nop
++00008d50 <[^>]*> nop
++00008d54 <[^>]*> nop
++00008d58 <[^>]*> nop
++00008d5c <[^>]*> nop
++00008d60 <[^>]*> nop
++00008d64 <[^>]*> nop
++00008d68 <[^>]*> nop
++00008d6c <[^>]*> nop
++00008d70 <[^>]*> nop
++00008d74 <[^>]*> nop
++00008d78 <[^>]*> nop
++00008d7c <[^>]*> nop
++00008d80 <[^>]*> nop
++00008d84 <[^>]*> nop
++00008d88 <[^>]*> nop
++00008d8c <[^>]*> nop
++00008d90 <[^>]*> nop
++00008d94 <[^>]*> nop
++00008d98 <[^>]*> nop
++00008d9c <[^>]*> nop
++00008da0 <[^>]*> nop
++00008da4 <[^>]*> nop
++00008da8 <[^>]*> nop
++00008dac <[^>]*> nop
++00008db0 <[^>]*> nop
++00008db4 <[^>]*> nop
++00008db8 <[^>]*> nop
++00008dbc <[^>]*> nop
++00008dc0 <[^>]*> nop
++00008dc4 <[^>]*> nop
++00008dc8 <[^>]*> nop
++00008dcc <[^>]*> nop
++00008dd0 <[^>]*> nop
++00008dd4 <[^>]*> nop
++00008dd8 <[^>]*> nop
++00008ddc <[^>]*> nop
++00008de0 <[^>]*> nop
++00008de4 <[^>]*> nop
++00008de8 <[^>]*> nop
++00008dec <[^>]*> nop
++00008df0 <[^>]*> nop
++00008df4 <[^>]*> nop
++00008df8 <[^>]*> nop
++00008dfc <[^>]*> nop
++00008e00 <[^>]*> nop
++00008e04 <[^>]*> nop
++00008e08 <[^>]*> nop
++00008e0c <[^>]*> nop
++00008e10 <[^>]*> nop
++00008e14 <[^>]*> nop
++00008e18 <[^>]*> nop
++00008e1c <[^>]*> nop
++00008e20 <[^>]*> nop
++00008e24 <[^>]*> nop
++00008e28 <[^>]*> nop
++00008e2c <[^>]*> nop
++00008e30 <[^>]*> nop
++00008e34 <[^>]*> nop
++00008e38 <[^>]*> nop
++00008e3c <[^>]*> nop
++00008e40 <[^>]*> nop
++00008e44 <[^>]*> nop
++00008e48 <[^>]*> nop
++00008e4c <[^>]*> nop
++00008e50 <[^>]*> nop
++00008e54 <[^>]*> nop
++00008e58 <[^>]*> nop
++00008e5c <[^>]*> nop
++00008e60 <[^>]*> nop
++00008e64 <[^>]*> nop
++00008e68 <[^>]*> nop
++00008e6c <[^>]*> nop
++00008e70 <[^>]*> nop
++00008e74 <[^>]*> nop
++00008e78 <[^>]*> nop
++00008e7c <[^>]*> nop
++00008e80 <[^>]*> nop
++00008e84 <[^>]*> nop
++00008e88 <[^>]*> nop
++00008e8c <[^>]*> nop
++00008e90 <[^>]*> nop
++00008e94 <[^>]*> nop
++00008e98 <[^>]*> nop
++00008e9c <[^>]*> nop
++00008ea0 <[^>]*> nop
++00008ea4 <[^>]*> nop
++00008ea8 <[^>]*> nop
++00008eac <[^>]*> nop
++00008eb0 <[^>]*> nop
++00008eb4 <[^>]*> nop
++00008eb8 <[^>]*> nop
++00008ebc <[^>]*> nop
++00008ec0 <[^>]*> nop
++00008ec4 <[^>]*> nop
++00008ec8 <[^>]*> nop
++00008ecc <[^>]*> nop
++00008ed0 <[^>]*> nop
++00008ed4 <[^>]*> nop
++00008ed8 <[^>]*> nop
++00008edc <[^>]*> nop
++00008ee0 <[^>]*> nop
++00008ee4 <[^>]*> nop
++00008ee8 <[^>]*> nop
++00008eec <[^>]*> nop
++00008ef0 <[^>]*> nop
++00008ef4 <[^>]*> nop
++00008ef8 <[^>]*> nop
++00008efc <[^>]*> nop
++00008f00 <[^>]*> nop
++00008f04 <[^>]*> nop
++00008f08 <[^>]*> nop
++00008f0c <[^>]*> nop
++00008f10 <[^>]*> nop
++00008f14 <[^>]*> nop
++00008f18 <[^>]*> nop
++00008f1c <[^>]*> nop
++00008f20 <[^>]*> nop
++00008f24 <[^>]*> nop
++00008f28 <[^>]*> nop
++00008f2c <[^>]*> nop
++00008f30 <[^>]*> nop
++00008f34 <[^>]*> nop
++00008f38 <[^>]*> nop
++00008f3c <[^>]*> nop
++00008f40 <[^>]*> nop
++00008f44 <[^>]*> nop
++00008f48 <[^>]*> nop
++00008f4c <[^>]*> nop
++00008f50 <[^>]*> nop
++00008f54 <[^>]*> nop
++00008f58 <[^>]*> nop
++00008f5c <[^>]*> nop
++00008f60 <[^>]*> nop
++00008f64 <[^>]*> nop
++00008f68 <[^>]*> nop
++00008f6c <[^>]*> nop
++00008f70 <[^>]*> nop
++00008f74 <[^>]*> nop
++00008f78 <[^>]*> nop
++00008f7c <[^>]*> nop
++00008f80 <[^>]*> nop
++00008f84 <[^>]*> nop
++00008f88 <[^>]*> nop
++00008f8c <[^>]*> nop
++00008f90 <[^>]*> nop
++00008f94 <[^>]*> nop
++00008f98 <[^>]*> nop
++00008f9c <[^>]*> nop
++00008fa0 <[^>]*> nop
++00008fa4 <[^>]*> nop
++00008fa8 <[^>]*> nop
++00008fac <[^>]*> nop
++00008fb0 <[^>]*> nop
++00008fb4 <[^>]*> nop
++00008fb8 <[^>]*> nop
++00008fbc <[^>]*> nop
++00008fc0 <[^>]*> nop
++00008fc4 <[^>]*> nop
++00008fc8 <[^>]*> nop
++00008fcc <[^>]*> nop
++00008fd0 <[^>]*> nop
++00008fd4 <[^>]*> nop
++00008fd8 <[^>]*> nop
++00008fdc <[^>]*> nop
++00008fe0 <[^>]*> nop
++00008fe4 <[^>]*> nop
++00008fe8 <[^>]*> nop
++00008fec <[^>]*> nop
++00008ff0 <[^>]*> nop
++00008ff4 <[^>]*> nop
++00008ff8 <[^>]*> nop
++00008ffc <[^>]*> nop
++00009000 <[^>]*> nop
++00009004 <[^>]*> nop
++00009008 <[^>]*> nop
++0000900c <[^>]*> nop
++00009010 <[^>]*> nop
++00009014 <[^>]*> nop
++00009018 <[^>]*> nop
++0000901c <[^>]*> nop
++00009020 <[^>]*> nop
++00009024 <[^>]*> nop
++00009028 <[^>]*> nop
++0000902c <[^>]*> nop
++00009030 <[^>]*> nop
++00009034 <[^>]*> nop
++00009038 <[^>]*> nop
++0000903c <[^>]*> nop
++00009040 <[^>]*> nop
++00009044 <[^>]*> nop
++00009048 <[^>]*> nop
++0000904c <[^>]*> nop
++00009050 <[^>]*> nop
++00009054 <[^>]*> nop
++00009058 <[^>]*> nop
++0000905c <[^>]*> nop
++00009060 <[^>]*> nop
++00009064 <[^>]*> nop
++00009068 <[^>]*> nop
++0000906c <[^>]*> nop
++00009070 <[^>]*> nop
++00009074 <[^>]*> nop
++00009078 <[^>]*> nop
++0000907c <[^>]*> nop
++00009080 <[^>]*> nop
++00009084 <[^>]*> nop
++00009088 <[^>]*> nop
++0000908c <[^>]*> nop
++00009090 <[^>]*> nop
++00009094 <[^>]*> nop
++00009098 <[^>]*> nop
++0000909c <[^>]*> nop
++000090a0 <[^>]*> nop
++000090a4 <[^>]*> nop
++000090a8 <[^>]*> nop
++000090ac <[^>]*> nop
++000090b0 <[^>]*> nop
++000090b4 <[^>]*> nop
++000090b8 <[^>]*> nop
++000090bc <[^>]*> nop
++000090c0 <[^>]*> nop
++000090c4 <[^>]*> nop
++000090c8 <[^>]*> nop
++000090cc <[^>]*> nop
++000090d0 <[^>]*> nop
++000090d4 <[^>]*> nop
++000090d8 <[^>]*> nop
++000090dc <[^>]*> nop
++000090e0 <[^>]*> nop
++000090e4 <[^>]*> nop
++000090e8 <[^>]*> nop
++000090ec <[^>]*> nop
++000090f0 <[^>]*> nop
++000090f4 <[^>]*> nop
++000090f8 <[^>]*> nop
++000090fc <[^>]*> nop
++00009100 <[^>]*> nop
++00009104 <[^>]*> nop
++00009108 <[^>]*> nop
++0000910c <[^>]*> nop
++00009110 <[^>]*> nop
++00009114 <[^>]*> nop
++00009118 <[^>]*> nop
++0000911c <[^>]*> nop
++00009120 <[^>]*> nop
++00009124 <[^>]*> nop
++00009128 <[^>]*> nop
++0000912c <[^>]*> nop
++00009130 <[^>]*> nop
++00009134 <[^>]*> nop
++00009138 <[^>]*> nop
++0000913c <[^>]*> nop
++00009140 <[^>]*> nop
++00009144 <[^>]*> nop
++00009148 <[^>]*> nop
++0000914c <[^>]*> nop
++00009150 <[^>]*> nop
++00009154 <[^>]*> nop
++00009158 <[^>]*> nop
++0000915c <[^>]*> nop
++00009160 <[^>]*> nop
++00009164 <[^>]*> nop
++00009168 <[^>]*> nop
++0000916c <[^>]*> nop
++00009170 <[^>]*> nop
++00009174 <[^>]*> nop
++00009178 <[^>]*> nop
++0000917c <[^>]*> nop
++00009180 <[^>]*> nop
++00009184 <[^>]*> nop
++00009188 <[^>]*> nop
++0000918c <[^>]*> nop
++00009190 <[^>]*> nop
++00009194 <[^>]*> nop
++00009198 <[^>]*> nop
++0000919c <[^>]*> nop
++000091a0 <[^>]*> nop
++000091a4 <[^>]*> nop
++000091a8 <[^>]*> nop
++000091ac <[^>]*> nop
++000091b0 <[^>]*> nop
++000091b4 <[^>]*> nop
++000091b8 <[^>]*> nop
++000091bc <[^>]*> nop
++000091c0 <[^>]*> nop
++000091c4 <[^>]*> nop
++000091c8 <[^>]*> nop
++000091cc <[^>]*> nop
++000091d0 <[^>]*> nop
++000091d4 <[^>]*> nop
++000091d8 <[^>]*> nop
++000091dc <[^>]*> nop
++000091e0 <[^>]*> nop
++000091e4 <[^>]*> nop
++000091e8 <[^>]*> nop
++000091ec <[^>]*> nop
++000091f0 <[^>]*> nop
++000091f4 <[^>]*> nop
++000091f8 <[^>]*> nop
++000091fc <[^>]*> nop
++00009200 <[^>]*> nop
++00009204 <[^>]*> nop
++00009208 <[^>]*> nop
++0000920c <[^>]*> nop
++00009210 <[^>]*> nop
++00009214 <[^>]*> nop
++00009218 <[^>]*> nop
++0000921c <[^>]*> nop
++00009220 <[^>]*> nop
++00009224 <[^>]*> nop
++00009228 <[^>]*> nop
++0000922c <[^>]*> nop
++00009230 <[^>]*> nop
++00009234 <[^>]*> nop
++00009238 <[^>]*> nop
++0000923c <[^>]*> nop
++00009240 <[^>]*> nop
++00009244 <[^>]*> nop
++00009248 <[^>]*> nop
++0000924c <[^>]*> nop
++00009250 <[^>]*> nop
++00009254 <[^>]*> nop
++00009258 <[^>]*> nop
++0000925c <[^>]*> nop
++00009260 <[^>]*> nop
++00009264 <[^>]*> nop
++00009268 <[^>]*> nop
++0000926c <[^>]*> nop
++00009270 <[^>]*> nop
++00009274 <[^>]*> nop
++00009278 <[^>]*> nop
++0000927c <[^>]*> nop
++00009280 <[^>]*> nop
++00009284 <[^>]*> nop
++00009288 <[^>]*> nop
++0000928c <[^>]*> nop
++00009290 <[^>]*> nop
++00009294 <[^>]*> nop
++00009298 <[^>]*> nop
++0000929c <[^>]*> nop
++000092a0 <[^>]*> nop
++000092a4 <[^>]*> nop
++000092a8 <[^>]*> nop
++000092ac <[^>]*> nop
++000092b0 <[^>]*> nop
++000092b4 <[^>]*> nop
++000092b8 <[^>]*> nop
++000092bc <[^>]*> nop
++000092c0 <[^>]*> nop
++000092c4 <[^>]*> nop
++000092c8 <[^>]*> nop
++000092cc <[^>]*> nop
++000092d0 <[^>]*> nop
++000092d4 <[^>]*> nop
++000092d8 <[^>]*> nop
++000092dc <[^>]*> nop
++000092e0 <[^>]*> nop
++000092e4 <[^>]*> nop
++000092e8 <[^>]*> nop
++000092ec <[^>]*> nop
++000092f0 <[^>]*> nop
++000092f4 <[^>]*> nop
++000092f8 <[^>]*> nop
++000092fc <[^>]*> nop
++00009300 <[^>]*> nop
++00009304 <[^>]*> nop
++00009308 <[^>]*> nop
++0000930c <[^>]*> nop
++00009310 <[^>]*> nop
++00009314 <[^>]*> nop
++00009318 <[^>]*> nop
++0000931c <[^>]*> nop
++00009320 <[^>]*> nop
++00009324 <[^>]*> nop
++00009328 <[^>]*> nop
++0000932c <[^>]*> nop
++00009330 <[^>]*> nop
++00009334 <[^>]*> nop
++00009338 <[^>]*> nop
++0000933c <[^>]*> nop
++00009340 <[^>]*> nop
++00009344 <[^>]*> nop
++00009348 <[^>]*> nop
++0000934c <[^>]*> nop
++00009350 <[^>]*> nop
++00009354 <[^>]*> nop
++00009358 <[^>]*> nop
++0000935c <[^>]*> nop
++00009360 <[^>]*> nop
++00009364 <[^>]*> nop
++00009368 <[^>]*> nop
++0000936c <[^>]*> nop
++00009370 <[^>]*> nop
++00009374 <[^>]*> nop
++00009378 <[^>]*> nop
++0000937c <[^>]*> nop
++00009380 <[^>]*> nop
++00009384 <[^>]*> nop
++00009388 <[^>]*> nop
++0000938c <[^>]*> nop
++00009390 <[^>]*> nop
++00009394 <[^>]*> nop
++00009398 <[^>]*> nop
++0000939c <[^>]*> nop
++000093a0 <[^>]*> nop
++000093a4 <[^>]*> nop
++000093a8 <[^>]*> nop
++000093ac <[^>]*> nop
++000093b0 <[^>]*> nop
++000093b4 <[^>]*> nop
++000093b8 <[^>]*> nop
++000093bc <[^>]*> nop
++000093c0 <[^>]*> nop
++000093c4 <[^>]*> nop
++000093c8 <[^>]*> nop
++000093cc <[^>]*> nop
++000093d0 <[^>]*> nop
++000093d4 <[^>]*> nop
++000093d8 <[^>]*> nop
++000093dc <[^>]*> nop
++000093e0 <[^>]*> nop
++000093e4 <[^>]*> nop
++000093e8 <[^>]*> nop
++000093ec <[^>]*> nop
++000093f0 <[^>]*> nop
++000093f4 <[^>]*> nop
++000093f8 <[^>]*> nop
++000093fc <[^>]*> nop
++00009400 <[^>]*> nop
++00009404 <[^>]*> nop
++00009408 <[^>]*> nop
++0000940c <[^>]*> nop
++00009410 <[^>]*> nop
++00009414 <[^>]*> nop
++00009418 <[^>]*> nop
++0000941c <[^>]*> nop
++00009420 <[^>]*> nop
++00009424 <[^>]*> nop
++00009428 <[^>]*> nop
++0000942c <[^>]*> nop
++00009430 <[^>]*> nop
++00009434 <[^>]*> nop
++00009438 <[^>]*> nop
++0000943c <[^>]*> nop
++00009440 <[^>]*> nop
++00009444 <[^>]*> nop
++00009448 <[^>]*> nop
++0000944c <[^>]*> nop
++00009450 <[^>]*> nop
++00009454 <[^>]*> nop
++00009458 <[^>]*> nop
++0000945c <[^>]*> nop
++00009460 <[^>]*> nop
++00009464 <[^>]*> nop
++00009468 <[^>]*> nop
++0000946c <[^>]*> nop
++00009470 <[^>]*> nop
++00009474 <[^>]*> nop
++00009478 <[^>]*> nop
++0000947c <[^>]*> nop
++00009480 <[^>]*> nop
++00009484 <[^>]*> nop
++00009488 <[^>]*> nop
++0000948c <[^>]*> nop
++00009490 <[^>]*> nop
++00009494 <[^>]*> nop
++00009498 <[^>]*> nop
++0000949c <[^>]*> nop
++000094a0 <[^>]*> nop
++000094a4 <[^>]*> nop
++000094a8 <[^>]*> nop
++000094ac <[^>]*> nop
++000094b0 <[^>]*> nop
++000094b4 <[^>]*> nop
++000094b8 <[^>]*> nop
++000094bc <[^>]*> nop
++000094c0 <[^>]*> nop
++000094c4 <[^>]*> nop
++000094c8 <[^>]*> nop
++000094cc <[^>]*> nop
++000094d0 <[^>]*> nop
++000094d4 <[^>]*> nop
++000094d8 <[^>]*> nop
++000094dc <[^>]*> nop
++000094e0 <[^>]*> nop
++000094e4 <[^>]*> nop
++000094e8 <[^>]*> nop
++000094ec <[^>]*> nop
++000094f0 <[^>]*> nop
++000094f4 <[^>]*> nop
++000094f8 <[^>]*> nop
++000094fc <[^>]*> nop
++00009500 <[^>]*> nop
++00009504 <[^>]*> nop
++00009508 <[^>]*> nop
++0000950c <[^>]*> nop
++00009510 <[^>]*> nop
++00009514 <[^>]*> nop
++00009518 <[^>]*> nop
++0000951c <[^>]*> nop
++00009520 <[^>]*> nop
++00009524 <[^>]*> nop
++00009528 <[^>]*> nop
++0000952c <[^>]*> nop
++00009530 <[^>]*> nop
++00009534 <[^>]*> nop
++00009538 <[^>]*> nop
++0000953c <[^>]*> nop
++00009540 <[^>]*> nop
++00009544 <[^>]*> nop
++00009548 <[^>]*> nop
++0000954c <[^>]*> nop
++00009550 <[^>]*> nop
++00009554 <[^>]*> nop
++00009558 <[^>]*> nop
++0000955c <[^>]*> nop
++00009560 <[^>]*> nop
++00009564 <[^>]*> nop
++00009568 <[^>]*> nop
++0000956c <[^>]*> nop
++00009570 <[^>]*> nop
++00009574 <[^>]*> nop
++00009578 <[^>]*> nop
++0000957c <[^>]*> nop
++00009580 <[^>]*> nop
++00009584 <[^>]*> nop
++00009588 <[^>]*> nop
++0000958c <[^>]*> nop
++00009590 <[^>]*> nop
++00009594 <[^>]*> nop
++00009598 <[^>]*> nop
++0000959c <[^>]*> nop
++000095a0 <[^>]*> nop
++000095a4 <[^>]*> nop
++000095a8 <[^>]*> nop
++000095ac <[^>]*> nop
++000095b0 <[^>]*> nop
++000095b4 <[^>]*> nop
++000095b8 <[^>]*> nop
++000095bc <[^>]*> nop
++000095c0 <[^>]*> nop
++000095c4 <[^>]*> nop
++000095c8 <[^>]*> nop
++000095cc <[^>]*> nop
++000095d0 <[^>]*> nop
++000095d4 <[^>]*> nop
++000095d8 <[^>]*> nop
++000095dc <[^>]*> nop
++000095e0 <[^>]*> nop
++000095e4 <[^>]*> nop
++000095e8 <[^>]*> nop
++000095ec <[^>]*> nop
++000095f0 <[^>]*> nop
++000095f4 <[^>]*> nop
++000095f8 <[^>]*> nop
++000095fc <[^>]*> nop
++00009600 <[^>]*> nop
++00009604 <[^>]*> nop
++00009608 <[^>]*> nop
++0000960c <[^>]*> nop
++00009610 <[^>]*> nop
++00009614 <[^>]*> nop
++00009618 <[^>]*> nop
++0000961c <[^>]*> nop
++00009620 <[^>]*> nop
++00009624 <[^>]*> nop
++00009628 <[^>]*> nop
++0000962c <[^>]*> nop
++00009630 <[^>]*> nop
++00009634 <[^>]*> nop
++00009638 <[^>]*> nop
++0000963c <[^>]*> nop
++00009640 <[^>]*> nop
++00009644 <[^>]*> nop
++00009648 <[^>]*> nop
++0000964c <[^>]*> nop
++00009650 <[^>]*> nop
++00009654 <[^>]*> nop
++00009658 <[^>]*> nop
++0000965c <[^>]*> nop
++00009660 <[^>]*> nop
++00009664 <[^>]*> nop
++00009668 <[^>]*> nop
++0000966c <[^>]*> nop
++00009670 <[^>]*> nop
++00009674 <[^>]*> nop
++00009678 <[^>]*> nop
++0000967c <[^>]*> nop
++00009680 <[^>]*> nop
++00009684 <[^>]*> nop
++00009688 <[^>]*> nop
++0000968c <[^>]*> nop
++00009690 <[^>]*> nop
++00009694 <[^>]*> nop
++00009698 <[^>]*> nop
++0000969c <[^>]*> nop
++000096a0 <[^>]*> nop
++000096a4 <[^>]*> nop
++000096a8 <[^>]*> nop
++000096ac <[^>]*> nop
++000096b0 <[^>]*> nop
++000096b4 <[^>]*> nop
++000096b8 <[^>]*> nop
++000096bc <[^>]*> nop
++000096c0 <[^>]*> nop
++000096c4 <[^>]*> nop
++000096c8 <[^>]*> nop
++000096cc <[^>]*> nop
++000096d0 <[^>]*> nop
++000096d4 <[^>]*> nop
++000096d8 <[^>]*> nop
++000096dc <[^>]*> nop
++000096e0 <[^>]*> nop
++000096e4 <[^>]*> nop
++000096e8 <[^>]*> nop
++000096ec <[^>]*> nop
++000096f0 <[^>]*> nop
++000096f4 <[^>]*> nop
++000096f8 <[^>]*> nop
++000096fc <[^>]*> nop
++00009700 <[^>]*> nop
++00009704 <[^>]*> nop
++00009708 <[^>]*> nop
++0000970c <[^>]*> nop
++00009710 <[^>]*> nop
++00009714 <[^>]*> nop
++00009718 <[^>]*> nop
++0000971c <[^>]*> nop
++00009720 <[^>]*> nop
++00009724 <[^>]*> nop
++00009728 <[^>]*> nop
++0000972c <[^>]*> nop
++00009730 <[^>]*> nop
++00009734 <[^>]*> nop
++00009738 <[^>]*> nop
++0000973c <[^>]*> nop
++00009740 <[^>]*> nop
++00009744 <[^>]*> nop
++00009748 <[^>]*> nop
++0000974c <[^>]*> nop
++00009750 <[^>]*> nop
++00009754 <[^>]*> nop
++00009758 <[^>]*> nop
++0000975c <[^>]*> nop
++00009760 <[^>]*> nop
++00009764 <[^>]*> nop
++00009768 <[^>]*> nop
++0000976c <[^>]*> nop
++00009770 <[^>]*> nop
++00009774 <[^>]*> nop
++00009778 <[^>]*> nop
++0000977c <[^>]*> nop
++00009780 <[^>]*> nop
++00009784 <[^>]*> nop
++00009788 <[^>]*> nop
++0000978c <[^>]*> nop
++00009790 <[^>]*> nop
++00009794 <[^>]*> nop
++00009798 <[^>]*> nop
++0000979c <[^>]*> nop
++000097a0 <[^>]*> nop
++000097a4 <[^>]*> nop
++000097a8 <[^>]*> nop
++000097ac <[^>]*> nop
++000097b0 <[^>]*> nop
++000097b4 <[^>]*> nop
++000097b8 <[^>]*> nop
++000097bc <[^>]*> nop
++000097c0 <[^>]*> nop
++000097c4 <[^>]*> nop
++000097c8 <[^>]*> nop
++000097cc <[^>]*> nop
++000097d0 <[^>]*> nop
++000097d4 <[^>]*> nop
++000097d8 <[^>]*> nop
++000097dc <[^>]*> nop
++000097e0 <[^>]*> nop
++000097e4 <[^>]*> nop
++000097e8 <[^>]*> nop
++000097ec <[^>]*> nop
++000097f0 <[^>]*> nop
++000097f4 <[^>]*> nop
++000097f8 <[^>]*> nop
++000097fc <[^>]*> nop
++00009800 <[^>]*> nop
++00009804 <[^>]*> nop
++00009808 <[^>]*> nop
++0000980c <[^>]*> nop
++00009810 <[^>]*> nop
++00009814 <[^>]*> nop
++00009818 <[^>]*> nop
++0000981c <[^>]*> nop
++00009820 <[^>]*> nop
++00009824 <[^>]*> nop
++00009828 <[^>]*> nop
++0000982c <[^>]*> nop
++00009830 <[^>]*> nop
++00009834 <[^>]*> nop
++00009838 <[^>]*> nop
++0000983c <[^>]*> nop
++00009840 <[^>]*> nop
++00009844 <[^>]*> nop
++00009848 <[^>]*> nop
++0000984c <[^>]*> nop
++00009850 <[^>]*> nop
++00009854 <[^>]*> nop
++00009858 <[^>]*> nop
++0000985c <[^>]*> nop
++00009860 <[^>]*> nop
++00009864 <[^>]*> nop
++00009868 <[^>]*> nop
++0000986c <[^>]*> nop
++00009870 <[^>]*> nop
++00009874 <[^>]*> nop
++00009878 <[^>]*> nop
++0000987c <[^>]*> nop
++00009880 <[^>]*> nop
++00009884 <[^>]*> nop
++00009888 <[^>]*> nop
++0000988c <[^>]*> nop
++00009890 <[^>]*> nop
++00009894 <[^>]*> nop
++00009898 <[^>]*> nop
++0000989c <[^>]*> nop
++000098a0 <[^>]*> nop
++000098a4 <[^>]*> nop
++000098a8 <[^>]*> nop
++000098ac <[^>]*> nop
++000098b0 <[^>]*> nop
++000098b4 <[^>]*> nop
++000098b8 <[^>]*> nop
++000098bc <[^>]*> nop
++000098c0 <[^>]*> nop
++000098c4 <[^>]*> nop
++000098c8 <[^>]*> nop
++000098cc <[^>]*> nop
++000098d0 <[^>]*> nop
++000098d4 <[^>]*> nop
++000098d8 <[^>]*> nop
++000098dc <[^>]*> nop
++000098e0 <[^>]*> nop
++000098e4 <[^>]*> nop
++000098e8 <[^>]*> nop
++000098ec <[^>]*> nop
++000098f0 <[^>]*> nop
++000098f4 <[^>]*> nop
++000098f8 <[^>]*> nop
++000098fc <[^>]*> nop
++00009900 <[^>]*> nop
++00009904 <[^>]*> nop
++00009908 <[^>]*> nop
++0000990c <[^>]*> nop
++00009910 <[^>]*> nop
++00009914 <[^>]*> nop
++00009918 <[^>]*> nop
++0000991c <[^>]*> nop
++00009920 <[^>]*> nop
++00009924 <[^>]*> nop
++00009928 <[^>]*> nop
++0000992c <[^>]*> nop
++00009930 <[^>]*> nop
++00009934 <[^>]*> nop
++00009938 <[^>]*> nop
++0000993c <[^>]*> nop
++00009940 <[^>]*> nop
++00009944 <[^>]*> nop
++00009948 <[^>]*> nop
++0000994c <[^>]*> nop
++00009950 <[^>]*> nop
++00009954 <[^>]*> nop
++00009958 <[^>]*> nop
++0000995c <[^>]*> nop
++00009960 <[^>]*> nop
++00009964 <[^>]*> nop
++00009968 <[^>]*> nop
++0000996c <[^>]*> nop
++00009970 <[^>]*> nop
++00009974 <[^>]*> nop
++00009978 <[^>]*> nop
++0000997c <[^>]*> nop
++00009980 <[^>]*> nop
++00009984 <[^>]*> nop
++00009988 <[^>]*> nop
++0000998c <[^>]*> nop
++00009990 <[^>]*> nop
++00009994 <[^>]*> nop
++00009998 <[^>]*> nop
++0000999c <[^>]*> nop
++000099a0 <[^>]*> nop
++000099a4 <[^>]*> nop
++000099a8 <[^>]*> nop
++000099ac <[^>]*> nop
++000099b0 <[^>]*> nop
++000099b4 <[^>]*> nop
++000099b8 <[^>]*> nop
++000099bc <[^>]*> nop
++000099c0 <[^>]*> nop
++000099c4 <[^>]*> nop
++000099c8 <[^>]*> nop
++000099cc <[^>]*> nop
++000099d0 <[^>]*> nop
++000099d4 <[^>]*> nop
++000099d8 <[^>]*> nop
++000099dc <[^>]*> nop
++000099e0 <[^>]*> nop
++000099e4 <[^>]*> nop
++000099e8 <[^>]*> nop
++000099ec <[^>]*> nop
++000099f0 <[^>]*> nop
++000099f4 <[^>]*> nop
++000099f8 <[^>]*> nop
++000099fc <[^>]*> nop
++00009a00 <[^>]*> nop
++00009a04 <[^>]*> nop
++00009a08 <[^>]*> nop
++00009a0c <[^>]*> nop
++00009a10 <[^>]*> nop
++00009a14 <[^>]*> nop
++00009a18 <[^>]*> nop
++00009a1c <[^>]*> nop
++00009a20 <[^>]*> nop
++00009a24 <[^>]*> nop
++00009a28 <[^>]*> nop
++00009a2c <[^>]*> nop
++00009a30 <[^>]*> nop
++00009a34 <[^>]*> nop
++00009a38 <[^>]*> nop
++00009a3c <[^>]*> nop
++00009a40 <[^>]*> nop
++00009a44 <[^>]*> nop
++00009a48 <[^>]*> nop
++00009a4c <[^>]*> nop
++00009a50 <[^>]*> nop
++00009a54 <[^>]*> nop
++00009a58 <[^>]*> nop
++00009a5c <[^>]*> nop
++00009a60 <[^>]*> nop
++00009a64 <[^>]*> nop
++00009a68 <[^>]*> nop
++00009a6c <[^>]*> nop
++00009a70 <[^>]*> nop
++00009a74 <[^>]*> nop
++00009a78 <[^>]*> nop
++00009a7c <[^>]*> nop
++00009a80 <[^>]*> nop
++00009a84 <[^>]*> nop
++00009a88 <[^>]*> nop
++00009a8c <[^>]*> nop
++00009a90 <[^>]*> nop
++00009a94 <[^>]*> nop
++00009a98 <[^>]*> nop
++00009a9c <[^>]*> nop
++00009aa0 <[^>]*> nop
++00009aa4 <[^>]*> nop
++00009aa8 <[^>]*> nop
++00009aac <[^>]*> nop
++00009ab0 <[^>]*> nop
++00009ab4 <[^>]*> nop
++00009ab8 <[^>]*> nop
++00009abc <[^>]*> nop
++00009ac0 <[^>]*> nop
++00009ac4 <[^>]*> nop
++00009ac8 <[^>]*> nop
++00009acc <[^>]*> nop
++00009ad0 <[^>]*> nop
++00009ad4 <[^>]*> nop
++00009ad8 <[^>]*> nop
++00009adc <[^>]*> nop
++00009ae0 <[^>]*> nop
++00009ae4 <[^>]*> nop
++00009ae8 <[^>]*> nop
++00009aec <[^>]*> nop
++00009af0 <[^>]*> nop
++00009af4 <[^>]*> nop
++00009af8 <[^>]*> nop
++00009afc <[^>]*> nop
++00009b00 <[^>]*> nop
++00009b04 <[^>]*> nop
++00009b08 <[^>]*> nop
++00009b0c <[^>]*> nop
++00009b10 <[^>]*> nop
++00009b14 <[^>]*> nop
++00009b18 <[^>]*> nop
++00009b1c <[^>]*> nop
++00009b20 <[^>]*> nop
++00009b24 <[^>]*> nop
++00009b28 <[^>]*> nop
++00009b2c <[^>]*> nop
++00009b30 <[^>]*> nop
++00009b34 <[^>]*> nop
++00009b38 <[^>]*> nop
++00009b3c <[^>]*> nop
++00009b40 <[^>]*> nop
++00009b44 <[^>]*> nop
++00009b48 <[^>]*> nop
++00009b4c <[^>]*> nop
++00009b50 <[^>]*> nop
++00009b54 <[^>]*> nop
++00009b58 <[^>]*> nop
++00009b5c <[^>]*> nop
++00009b60 <[^>]*> nop
++00009b64 <[^>]*> nop
++00009b68 <[^>]*> nop
++00009b6c <[^>]*> nop
++00009b70 <[^>]*> nop
++00009b74 <[^>]*> nop
++00009b78 <[^>]*> nop
++00009b7c <[^>]*> nop
++00009b80 <[^>]*> nop
++00009b84 <[^>]*> nop
++00009b88 <[^>]*> nop
++00009b8c <[^>]*> nop
++00009b90 <[^>]*> nop
++00009b94 <[^>]*> nop
++00009b98 <[^>]*> nop
++00009b9c <[^>]*> nop
++00009ba0 <[^>]*> nop
++00009ba4 <[^>]*> nop
++00009ba8 <[^>]*> nop
++00009bac <[^>]*> nop
++00009bb0 <[^>]*> nop
++00009bb4 <[^>]*> nop
++00009bb8 <[^>]*> nop
++00009bbc <[^>]*> nop
++00009bc0 <[^>]*> nop
++00009bc4 <[^>]*> nop
++00009bc8 <[^>]*> nop
++00009bcc <[^>]*> nop
++00009bd0 <[^>]*> nop
++00009bd4 <[^>]*> nop
++00009bd8 <[^>]*> nop
++00009bdc <[^>]*> nop
++00009be0 <[^>]*> nop
++00009be4 <[^>]*> nop
++00009be8 <[^>]*> nop
++00009bec <[^>]*> nop
++00009bf0 <[^>]*> nop
++00009bf4 <[^>]*> nop
++00009bf8 <[^>]*> nop
++00009bfc <[^>]*> nop
++00009c00 <[^>]*> nop
++00009c04 <[^>]*> nop
++00009c08 <[^>]*> nop
++00009c0c <[^>]*> nop
++00009c10 <[^>]*> nop
++00009c14 <[^>]*> nop
++00009c18 <[^>]*> nop
++00009c1c <[^>]*> nop
++00009c20 <[^>]*> nop
++00009c24 <[^>]*> nop
++00009c28 <[^>]*> nop
++00009c2c <[^>]*> nop
++00009c30 <[^>]*> nop
++00009c34 <[^>]*> nop
++00009c38 <[^>]*> nop
++00009c3c <[^>]*> nop
++00009c40 <[^>]*> nop
++00009c44 <[^>]*> nop
++00009c48 <[^>]*> nop
++00009c4c <[^>]*> nop
++00009c50 <[^>]*> nop
++00009c54 <[^>]*> nop
++00009c58 <[^>]*> nop
++00009c5c <[^>]*> nop
++00009c60 <[^>]*> nop
++00009c64 <[^>]*> nop
++00009c68 <[^>]*> nop
++00009c6c <[^>]*> nop
++00009c70 <[^>]*> nop
++00009c74 <[^>]*> nop
++00009c78 <[^>]*> nop
++00009c7c <[^>]*> nop
++00009c80 <[^>]*> nop
++00009c84 <[^>]*> nop
++00009c88 <[^>]*> nop
++00009c8c <[^>]*> nop
++00009c90 <[^>]*> nop
++00009c94 <[^>]*> nop
++00009c98 <[^>]*> nop
++00009c9c <[^>]*> nop
++00009ca0 <[^>]*> nop
++00009ca4 <[^>]*> nop
++00009ca8 <[^>]*> nop
++00009cac <[^>]*> nop
++00009cb0 <[^>]*> nop
++00009cb4 <[^>]*> nop
++00009cb8 <[^>]*> nop
++00009cbc <[^>]*> nop
++00009cc0 <[^>]*> nop
++00009cc4 <[^>]*> nop
++00009cc8 <[^>]*> nop
++00009ccc <[^>]*> nop
++00009cd0 <[^>]*> nop
++00009cd4 <[^>]*> nop
++00009cd8 <[^>]*> nop
++00009cdc <[^>]*> nop
++00009ce0 <[^>]*> nop
++00009ce4 <[^>]*> nop
++00009ce8 <[^>]*> nop
++00009cec <[^>]*> nop
++00009cf0 <[^>]*> nop
++00009cf4 <[^>]*> nop
++00009cf8 <[^>]*> nop
++00009cfc <[^>]*> nop
++00009d00 <[^>]*> nop
++00009d04 <[^>]*> nop
++00009d08 <[^>]*> nop
++00009d0c <[^>]*> nop
++00009d10 <[^>]*> nop
++00009d14 <[^>]*> nop
++00009d18 <[^>]*> nop
++00009d1c <[^>]*> nop
++00009d20 <[^>]*> nop
++00009d24 <[^>]*> nop
++00009d28 <[^>]*> nop
++00009d2c <[^>]*> nop
++00009d30 <[^>]*> nop
++00009d34 <[^>]*> nop
++00009d38 <[^>]*> nop
++00009d3c <[^>]*> nop
++00009d40 <[^>]*> nop
++00009d44 <[^>]*> nop
++00009d48 <[^>]*> nop
++00009d4c <[^>]*> nop
++00009d50 <[^>]*> nop
++00009d54 <[^>]*> nop
++00009d58 <[^>]*> nop
++00009d5c <[^>]*> nop
++00009d60 <[^>]*> nop
++00009d64 <[^>]*> nop
++00009d68 <[^>]*> nop
++00009d6c <[^>]*> nop
++00009d70 <[^>]*> nop
++00009d74 <[^>]*> nop
++00009d78 <[^>]*> nop
++00009d7c <[^>]*> nop
++00009d80 <[^>]*> nop
++00009d84 <[^>]*> nop
++00009d88 <[^>]*> nop
++00009d8c <[^>]*> nop
++00009d90 <[^>]*> nop
++00009d94 <[^>]*> nop
++00009d98 <[^>]*> nop
++00009d9c <[^>]*> nop
++00009da0 <[^>]*> nop
++00009da4 <[^>]*> nop
++00009da8 <[^>]*> nop
++00009dac <[^>]*> nop
++00009db0 <[^>]*> nop
++00009db4 <[^>]*> nop
++00009db8 <[^>]*> nop
++00009dbc <[^>]*> nop
++00009dc0 <[^>]*> nop
++00009dc4 <[^>]*> nop
++00009dc8 <[^>]*> nop
++00009dcc <[^>]*> nop
++00009dd0 <[^>]*> nop
++00009dd4 <[^>]*> nop
++00009dd8 <[^>]*> nop
++00009ddc <[^>]*> nop
++00009de0 <[^>]*> nop
++00009de4 <[^>]*> nop
++00009de8 <[^>]*> nop
++00009dec <[^>]*> nop
++00009df0 <[^>]*> nop
++00009df4 <[^>]*> nop
++00009df8 <[^>]*> nop
++00009dfc <[^>]*> nop
++00009e00 <[^>]*> nop
++00009e04 <[^>]*> nop
++00009e08 <[^>]*> nop
++00009e0c <[^>]*> nop
++00009e10 <[^>]*> nop
++00009e14 <[^>]*> nop
++00009e18 <[^>]*> nop
++00009e1c <[^>]*> nop
++00009e20 <[^>]*> nop
++00009e24 <[^>]*> nop
++00009e28 <[^>]*> nop
++00009e2c <[^>]*> nop
++00009e30 <[^>]*> nop
++00009e34 <[^>]*> nop
++00009e38 <[^>]*> nop
++00009e3c <[^>]*> nop
++00009e40 <[^>]*> nop
++00009e44 <[^>]*> nop
++00009e48 <[^>]*> nop
++00009e4c <[^>]*> nop
++00009e50 <[^>]*> nop
++00009e54 <[^>]*> nop
++00009e58 <[^>]*> nop
++00009e5c <[^>]*> nop
++00009e60 <[^>]*> nop
++00009e64 <[^>]*> nop
++00009e68 <[^>]*> nop
++00009e6c <[^>]*> nop
++00009e70 <[^>]*> nop
++00009e74 <[^>]*> nop
++00009e78 <[^>]*> nop
++00009e7c <[^>]*> nop
++00009e80 <[^>]*> nop
++00009e84 <[^>]*> nop
++00009e88 <[^>]*> nop
++00009e8c <[^>]*> nop
++00009e90 <[^>]*> nop
++00009e94 <[^>]*> nop
++00009e98 <[^>]*> nop
++00009e9c <[^>]*> nop
++00009ea0 <[^>]*> nop
++00009ea4 <[^>]*> nop
++00009ea8 <[^>]*> nop
++00009eac <[^>]*> nop
++00009eb0 <[^>]*> nop
++00009eb4 <[^>]*> nop
++00009eb8 <[^>]*> nop
++00009ebc <[^>]*> nop
++00009ec0 <[^>]*> nop
++00009ec4 <[^>]*> nop
++00009ec8 <[^>]*> nop
++00009ecc <[^>]*> nop
++00009ed0 <[^>]*> nop
++00009ed4 <[^>]*> nop
++00009ed8 <[^>]*> nop
++00009edc <[^>]*> nop
++00009ee0 <[^>]*> nop
++00009ee4 <[^>]*> nop
++00009ee8 <[^>]*> nop
++00009eec <[^>]*> nop
++00009ef0 <[^>]*> nop
++00009ef4 <[^>]*> nop
++00009ef8 <[^>]*> nop
++00009efc <[^>]*> nop
++00009f00 <[^>]*> nop
++00009f04 <[^>]*> nop
++00009f08 <[^>]*> nop
++00009f0c <[^>]*> nop
++00009f10 <[^>]*> nop
++00009f14 <[^>]*> nop
++00009f18 <[^>]*> nop
++00009f1c <[^>]*> nop
++00009f20 <[^>]*> nop
++00009f24 <[^>]*> nop
++00009f28 <[^>]*> nop
++00009f2c <[^>]*> nop
++00009f30 <[^>]*> nop
++00009f34 <[^>]*> nop
++00009f38 <[^>]*> nop
++00009f3c <[^>]*> nop
++00009f40 <[^>]*> nop
++00009f44 <[^>]*> nop
++00009f48 <[^>]*> nop
++00009f4c <[^>]*> nop
++00009f50 <[^>]*> nop
++00009f54 <[^>]*> nop
++00009f58 <[^>]*> nop
++00009f5c <[^>]*> nop
++00009f60 <[^>]*> nop
++00009f64 <[^>]*> nop
++00009f68 <[^>]*> nop
++00009f6c <[^>]*> nop
++00009f70 <[^>]*> nop
++00009f74 <[^>]*> nop
++00009f78 <[^>]*> nop
++00009f7c <[^>]*> nop
++00009f80 <[^>]*> nop
++00009f84 <[^>]*> nop
++00009f88 <[^>]*> nop
++00009f8c <[^>]*> nop
++00009f90 <[^>]*> nop
++00009f94 <[^>]*> nop
++00009f98 <[^>]*> nop
++00009f9c <[^>]*> nop
++00009fa0 <[^>]*> nop
++00009fa4 <[^>]*> nop
++00009fa8 <[^>]*> nop
++00009fac <[^>]*> nop
++00009fb0 <[^>]*> nop
++00009fb4 <[^>]*> nop
++00009fb8 <[^>]*> nop
++00009fbc <[^>]*> nop
++00009fc0 <[^>]*> nop
++00009fc4 <[^>]*> nop
++00009fc8 <[^>]*> nop
++00009fcc <[^>]*> nop
++00009fd0 <[^>]*> nop
++00009fd4 <[^>]*> nop
++00009fd8 <[^>]*> nop
++00009fdc <[^>]*> nop
++00009fe0 <[^>]*> nop
++00009fe4 <[^>]*> nop
++00009fe8 <[^>]*> nop
++00009fec <[^>]*> nop
++00009ff0 <[^>]*> nop
++00009ff4 <[^>]*> nop
++00009ff8 <[^>]*> nop
++00009ffc <[^>]*> nop
++0000a000 <[^>]*> nop
++0000a004 <[^>]*> nop
++0000a008 <[^>]*> nop
++0000a00c <[^>]*> nop
++0000a010 <[^>]*> nop
++0000a014 <[^>]*> nop
++0000a018 <[^>]*> nop
++0000a01c <[^>]*> nop
++0000a020 <[^>]*> nop
++0000a024 <[^>]*> nop
++0000a028 <[^>]*> nop
++0000a02c <[^>]*> nop
++0000a030 <[^>]*> nop
++0000a034 <[^>]*> nop
++0000a038 <[^>]*> nop
++0000a03c <[^>]*> nop
++0000a040 <[^>]*> nop
++0000a044 <[^>]*> nop
++0000a048 <[^>]*> nop
++0000a04c <[^>]*> nop
++0000a050 <[^>]*> nop
++0000a054 <[^>]*> nop
++0000a058 <[^>]*> nop
++0000a05c <[^>]*> nop
++0000a060 <[^>]*> nop
++0000a064 <[^>]*> nop
++0000a068 <[^>]*> nop
++0000a06c <[^>]*> nop
++0000a070 <[^>]*> nop
++0000a074 <[^>]*> nop
++0000a078 <[^>]*> nop
++0000a07c <[^>]*> nop
++0000a080 <[^>]*> nop
++0000a084 <[^>]*> nop
++0000a088 <[^>]*> nop
++0000a08c <[^>]*> nop
++0000a090 <[^>]*> nop
++0000a094 <[^>]*> nop
++0000a098 <[^>]*> nop
++0000a09c <[^>]*> nop
++0000a0a0 <[^>]*> nop
++0000a0a4 <[^>]*> nop
++0000a0a8 <[^>]*> nop
++0000a0ac <[^>]*> nop
++0000a0b0 <[^>]*> nop
++0000a0b4 <[^>]*> nop
++0000a0b8 <[^>]*> nop
++0000a0bc <[^>]*> nop
++0000a0c0 <[^>]*> nop
++0000a0c4 <[^>]*> nop
++0000a0c8 <[^>]*> nop
++0000a0cc <[^>]*> nop
++0000a0d0 <[^>]*> nop
++0000a0d4 <[^>]*> nop
++0000a0d8 <[^>]*> nop
++0000a0dc <[^>]*> nop
++0000a0e0 <[^>]*> nop
++0000a0e4 <[^>]*> nop
++0000a0e8 <[^>]*> nop
++0000a0ec <[^>]*> nop
++0000a0f0 <[^>]*> nop
++0000a0f4 <[^>]*> nop
++0000a0f8 <[^>]*> nop
++0000a0fc <[^>]*> nop
++0000a100 <[^>]*> nop
++0000a104 <[^>]*> nop
++0000a108 <[^>]*> nop
++0000a10c <[^>]*> nop
++0000a110 <[^>]*> nop
++0000a114 <[^>]*> nop
++0000a118 <[^>]*> nop
++0000a11c <[^>]*> nop
++0000a120 <[^>]*> nop
++0000a124 <[^>]*> nop
++0000a128 <[^>]*> nop
++0000a12c <[^>]*> nop
++0000a130 <[^>]*> nop
++0000a134 <[^>]*> nop
++0000a138 <[^>]*> nop
++0000a13c <[^>]*> nop
++0000a140 <[^>]*> nop
++0000a144 <[^>]*> nop
++0000a148 <[^>]*> nop
++0000a14c <[^>]*> nop
++0000a150 <[^>]*> nop
++0000a154 <[^>]*> nop
++0000a158 <[^>]*> nop
++0000a15c <[^>]*> nop
++0000a160 <[^>]*> nop
++0000a164 <[^>]*> nop
++0000a168 <[^>]*> nop
++0000a16c <[^>]*> nop
++0000a170 <[^>]*> nop
++0000a174 <[^>]*> nop
++0000a178 <[^>]*> nop
++0000a17c <[^>]*> nop
++0000a180 <[^>]*> nop
++0000a184 <[^>]*> nop
++0000a188 <[^>]*> nop
++0000a18c <[^>]*> nop
++0000a190 <[^>]*> nop
++0000a194 <[^>]*> nop
++0000a198 <[^>]*> nop
++0000a19c <[^>]*> nop
++0000a1a0 <[^>]*> nop
++0000a1a4 <[^>]*> nop
++0000a1a8 <[^>]*> nop
++0000a1ac <[^>]*> nop
++0000a1b0 <[^>]*> nop
++0000a1b4 <[^>]*> nop
++0000a1b8 <[^>]*> nop
++0000a1bc <[^>]*> nop
++0000a1c0 <[^>]*> nop
++0000a1c4 <[^>]*> nop
++0000a1c8 <[^>]*> nop
++0000a1cc <[^>]*> nop
++0000a1d0 <[^>]*> nop
++0000a1d4 <[^>]*> nop
++0000a1d8 <[^>]*> nop
++0000a1dc <[^>]*> nop
++0000a1e0 <[^>]*> nop
++0000a1e4 <[^>]*> nop
++0000a1e8 <[^>]*> nop
++0000a1ec <[^>]*> nop
++0000a1f0 <[^>]*> nop
++0000a1f4 <[^>]*> nop
++0000a1f8 <[^>]*> nop
++0000a1fc <[^>]*> nop
++0000a200 <[^>]*> nop
++0000a204 <[^>]*> nop
++0000a208 <[^>]*> nop
++0000a20c <[^>]*> nop
++0000a210 <[^>]*> nop
++0000a214 <[^>]*> nop
++0000a218 <[^>]*> nop
++0000a21c <[^>]*> nop
++0000a220 <[^>]*> nop
++0000a224 <[^>]*> nop
++0000a228 <[^>]*> nop
++0000a22c <[^>]*> nop
++0000a230 <[^>]*> nop
++0000a234 <[^>]*> nop
++0000a238 <[^>]*> nop
++0000a23c <[^>]*> nop
++0000a240 <[^>]*> nop
++0000a244 <[^>]*> nop
++0000a248 <[^>]*> nop
++0000a24c <[^>]*> nop
++0000a250 <[^>]*> nop
++0000a254 <[^>]*> nop
++0000a258 <[^>]*> nop
++0000a25c <[^>]*> nop
++0000a260 <[^>]*> nop
++0000a264 <[^>]*> nop
++0000a268 <[^>]*> nop
++0000a26c <[^>]*> nop
++0000a270 <[^>]*> nop
++0000a274 <[^>]*> nop
++0000a278 <[^>]*> nop
++0000a27c <[^>]*> nop
++0000a280 <[^>]*> nop
++0000a284 <[^>]*> nop
++0000a288 <[^>]*> nop
++0000a28c <[^>]*> nop
++0000a290 <[^>]*> nop
++0000a294 <[^>]*> nop
++0000a298 <[^>]*> nop
++0000a29c <[^>]*> nop
++0000a2a0 <[^>]*> nop
++0000a2a4 <[^>]*> nop
++0000a2a8 <[^>]*> nop
++0000a2ac <[^>]*> nop
++0000a2b0 <[^>]*> nop
++0000a2b4 <[^>]*> nop
++0000a2b8 <[^>]*> nop
++0000a2bc <[^>]*> nop
++0000a2c0 <[^>]*> nop
++0000a2c4 <[^>]*> nop
++0000a2c8 <[^>]*> nop
++0000a2cc <[^>]*> nop
++0000a2d0 <[^>]*> nop
++0000a2d4 <[^>]*> nop
++0000a2d8 <[^>]*> nop
++0000a2dc <[^>]*> nop
++0000a2e0 <[^>]*> nop
++0000a2e4 <[^>]*> nop
++0000a2e8 <[^>]*> nop
++0000a2ec <[^>]*> nop
++0000a2f0 <[^>]*> nop
++0000a2f4 <[^>]*> nop
++0000a2f8 <[^>]*> nop
++0000a2fc <[^>]*> nop
++0000a300 <[^>]*> nop
++0000a304 <[^>]*> nop
++0000a308 <[^>]*> nop
++0000a30c <[^>]*> nop
++0000a310 <[^>]*> nop
++0000a314 <[^>]*> nop
++0000a318 <[^>]*> nop
++0000a31c <[^>]*> nop
++0000a320 <[^>]*> nop
++0000a324 <[^>]*> nop
++0000a328 <[^>]*> nop
++0000a32c <[^>]*> nop
++0000a330 <[^>]*> nop
++0000a334 <[^>]*> nop
++0000a338 <[^>]*> nop
++0000a33c <[^>]*> nop
++0000a340 <[^>]*> nop
++0000a344 <[^>]*> nop
++0000a348 <[^>]*> nop
++0000a34c <[^>]*> nop
++0000a350 <[^>]*> nop
++0000a354 <[^>]*> nop
++0000a358 <[^>]*> nop
++0000a35c <[^>]*> nop
++0000a360 <[^>]*> nop
++0000a364 <[^>]*> nop
++0000a368 <[^>]*> nop
++0000a36c <[^>]*> nop
++0000a370 <[^>]*> nop
++0000a374 <[^>]*> nop
++0000a378 <[^>]*> nop
++0000a37c <[^>]*> nop
++0000a380 <[^>]*> nop
++0000a384 <[^>]*> nop
++0000a388 <[^>]*> nop
++0000a38c <[^>]*> nop
++0000a390 <[^>]*> nop
++0000a394 <[^>]*> nop
++0000a398 <[^>]*> nop
++0000a39c <[^>]*> nop
++0000a3a0 <[^>]*> nop
++0000a3a4 <[^>]*> nop
++0000a3a8 <[^>]*> nop
++0000a3ac <[^>]*> nop
++0000a3b0 <[^>]*> nop
++0000a3b4 <[^>]*> nop
++0000a3b8 <[^>]*> nop
++0000a3bc <[^>]*> nop
++0000a3c0 <[^>]*> nop
++0000a3c4 <[^>]*> nop
++0000a3c8 <[^>]*> nop
++0000a3cc <[^>]*> nop
++0000a3d0 <[^>]*> nop
++0000a3d4 <[^>]*> nop
++0000a3d8 <[^>]*> nop
++0000a3dc <[^>]*> nop
++0000a3e0 <[^>]*> nop
++0000a3e4 <[^>]*> nop
++0000a3e8 <[^>]*> nop
++0000a3ec <[^>]*> nop
++0000a3f0 <[^>]*> nop
++0000a3f4 <[^>]*> nop
++0000a3f8 <[^>]*> nop
++0000a3fc <[^>]*> nop
++0000a400 <[^>]*> nop
++0000a404 <[^>]*> nop
++0000a408 <[^>]*> nop
++0000a40c <[^>]*> nop
++0000a410 <[^>]*> nop
++0000a414 <[^>]*> nop
++0000a418 <[^>]*> nop
++0000a41c <[^>]*> nop
++0000a420 <[^>]*> nop
++0000a424 <[^>]*> nop
++0000a428 <[^>]*> nop
++0000a42c <[^>]*> nop
++0000a430 <[^>]*> nop
++0000a434 <[^>]*> nop
++0000a438 <[^>]*> nop
++0000a43c <[^>]*> nop
++0000a440 <[^>]*> nop
++0000a444 <[^>]*> nop
++0000a448 <[^>]*> nop
++0000a44c <[^>]*> nop
++0000a450 <[^>]*> nop
++0000a454 <[^>]*> nop
++0000a458 <[^>]*> nop
++0000a45c <[^>]*> nop
++0000a460 <[^>]*> nop
++0000a464 <[^>]*> nop
++0000a468 <[^>]*> nop
++0000a46c <[^>]*> nop
++0000a470 <[^>]*> nop
++0000a474 <[^>]*> nop
++0000a478 <[^>]*> nop
++0000a47c <[^>]*> nop
++0000a480 <[^>]*> nop
++0000a484 <[^>]*> nop
++0000a488 <[^>]*> nop
++0000a48c <[^>]*> nop
++0000a490 <[^>]*> nop
++0000a494 <[^>]*> nop
++0000a498 <[^>]*> nop
++0000a49c <[^>]*> nop
++0000a4a0 <[^>]*> nop
++0000a4a4 <[^>]*> nop
++0000a4a8 <[^>]*> nop
++0000a4ac <[^>]*> nop
++0000a4b0 <[^>]*> nop
++0000a4b4 <[^>]*> nop
++0000a4b8 <[^>]*> nop
++0000a4bc <[^>]*> nop
++0000a4c0 <[^>]*> nop
++0000a4c4 <[^>]*> nop
++0000a4c8 <[^>]*> nop
++0000a4cc <[^>]*> nop
++0000a4d0 <[^>]*> nop
++0000a4d4 <[^>]*> nop
++0000a4d8 <[^>]*> nop
++0000a4dc <[^>]*> nop
++0000a4e0 <[^>]*> nop
++0000a4e4 <[^>]*> nop
++0000a4e8 <[^>]*> nop
++0000a4ec <[^>]*> nop
++0000a4f0 <[^>]*> nop
++0000a4f4 <[^>]*> nop
++0000a4f8 <[^>]*> nop
++0000a4fc <[^>]*> nop
++0000a500 <[^>]*> nop
++0000a504 <[^>]*> nop
++0000a508 <[^>]*> nop
++0000a50c <[^>]*> nop
++0000a510 <[^>]*> nop
++0000a514 <[^>]*> nop
++0000a518 <[^>]*> nop
++0000a51c <[^>]*> nop
++0000a520 <[^>]*> nop
++0000a524 <[^>]*> nop
++0000a528 <[^>]*> nop
++0000a52c <[^>]*> nop
++0000a530 <[^>]*> nop
++0000a534 <[^>]*> nop
++0000a538 <[^>]*> nop
++0000a53c <[^>]*> nop
++0000a540 <[^>]*> nop
++0000a544 <[^>]*> nop
++0000a548 <[^>]*> nop
++0000a54c <[^>]*> nop
++0000a550 <[^>]*> nop
++0000a554 <[^>]*> nop
++0000a558 <[^>]*> nop
++0000a55c <[^>]*> nop
++0000a560 <[^>]*> nop
++0000a564 <[^>]*> nop
++0000a568 <[^>]*> nop
++0000a56c <[^>]*> nop
++0000a570 <[^>]*> nop
++0000a574 <[^>]*> nop
++0000a578 <[^>]*> nop
++0000a57c <[^>]*> nop
++0000a580 <[^>]*> nop
++0000a584 <[^>]*> nop
++0000a588 <[^>]*> nop
++0000a58c <[^>]*> nop
++0000a590 <[^>]*> nop
++0000a594 <[^>]*> nop
++0000a598 <[^>]*> nop
++0000a59c <[^>]*> nop
++0000a5a0 <[^>]*> nop
++0000a5a4 <[^>]*> nop
++0000a5a8 <[^>]*> nop
++0000a5ac <[^>]*> nop
++0000a5b0 <[^>]*> nop
++0000a5b4 <[^>]*> nop
++0000a5b8 <[^>]*> nop
++0000a5bc <[^>]*> nop
++0000a5c0 <[^>]*> nop
++0000a5c4 <[^>]*> nop
++0000a5c8 <[^>]*> nop
++0000a5cc <[^>]*> nop
++0000a5d0 <[^>]*> nop
++0000a5d4 <[^>]*> nop
++0000a5d8 <[^>]*> nop
++0000a5dc <[^>]*> nop
++0000a5e0 <[^>]*> nop
++0000a5e4 <[^>]*> nop
++0000a5e8 <[^>]*> nop
++0000a5ec <[^>]*> nop
++0000a5f0 <[^>]*> nop
++0000a5f4 <[^>]*> nop
++0000a5f8 <[^>]*> nop
++0000a5fc <[^>]*> nop
++0000a600 <[^>]*> nop
++0000a604 <[^>]*> nop
++0000a608 <[^>]*> nop
++0000a60c <[^>]*> nop
++0000a610 <[^>]*> nop
++0000a614 <[^>]*> nop
++0000a618 <[^>]*> nop
++0000a61c <[^>]*> nop
++0000a620 <[^>]*> nop
++0000a624 <[^>]*> nop
++0000a628 <[^>]*> nop
++0000a62c <[^>]*> nop
++0000a630 <[^>]*> nop
++0000a634 <[^>]*> nop
++0000a638 <[^>]*> nop
++0000a63c <[^>]*> nop
++0000a640 <[^>]*> nop
++0000a644 <[^>]*> nop
++0000a648 <[^>]*> nop
++0000a64c <[^>]*> nop
++0000a650 <[^>]*> nop
++0000a654 <[^>]*> nop
++0000a658 <[^>]*> nop
++0000a65c <[^>]*> nop
++0000a660 <[^>]*> nop
++0000a664 <[^>]*> nop
++0000a668 <[^>]*> nop
++0000a66c <[^>]*> nop
++0000a670 <[^>]*> nop
++0000a674 <[^>]*> nop
++0000a678 <[^>]*> nop
++0000a67c <[^>]*> nop
++0000a680 <[^>]*> nop
++0000a684 <[^>]*> nop
++0000a688 <[^>]*> nop
++0000a68c <[^>]*> nop
++0000a690 <[^>]*> nop
++0000a694 <[^>]*> nop
++0000a698 <[^>]*> nop
++0000a69c <[^>]*> nop
++0000a6a0 <[^>]*> nop
++0000a6a4 <[^>]*> nop
++0000a6a8 <[^>]*> nop
++0000a6ac <[^>]*> nop
++0000a6b0 <[^>]*> nop
++0000a6b4 <[^>]*> nop
++0000a6b8 <[^>]*> nop
++0000a6bc <[^>]*> nop
++0000a6c0 <[^>]*> nop
++0000a6c4 <[^>]*> nop
++0000a6c8 <[^>]*> nop
++0000a6cc <[^>]*> nop
++0000a6d0 <[^>]*> nop
++0000a6d4 <[^>]*> nop
++0000a6d8 <[^>]*> nop
++0000a6dc <[^>]*> nop
++0000a6e0 <[^>]*> nop
++0000a6e4 <[^>]*> nop
++0000a6e8 <[^>]*> nop
++0000a6ec <[^>]*> nop
++0000a6f0 <[^>]*> nop
++0000a6f4 <[^>]*> nop
++0000a6f8 <[^>]*> nop
++0000a6fc <[^>]*> nop
++0000a700 <[^>]*> nop
++0000a704 <[^>]*> nop
++0000a708 <[^>]*> nop
++0000a70c <[^>]*> nop
++0000a710 <[^>]*> nop
++0000a714 <[^>]*> nop
++0000a718 <[^>]*> nop
++0000a71c <[^>]*> nop
++0000a720 <[^>]*> nop
++0000a724 <[^>]*> nop
++0000a728 <[^>]*> nop
++0000a72c <[^>]*> nop
++0000a730 <[^>]*> nop
++0000a734 <[^>]*> nop
++0000a738 <[^>]*> nop
++0000a73c <[^>]*> nop
++0000a740 <[^>]*> nop
++0000a744 <[^>]*> nop
++0000a748 <[^>]*> nop
++0000a74c <[^>]*> nop
++0000a750 <[^>]*> nop
++0000a754 <[^>]*> nop
++0000a758 <[^>]*> nop
++0000a75c <[^>]*> nop
++0000a760 <[^>]*> nop
++0000a764 <[^>]*> nop
++0000a768 <[^>]*> nop
++0000a76c <[^>]*> nop
++0000a770 <[^>]*> nop
++0000a774 <[^>]*> nop
++0000a778 <[^>]*> nop
++0000a77c <[^>]*> nop
++0000a780 <[^>]*> nop
++0000a784 <[^>]*> nop
++0000a788 <[^>]*> nop
++0000a78c <[^>]*> nop
++0000a790 <[^>]*> nop
++0000a794 <[^>]*> nop
++0000a798 <[^>]*> nop
++0000a79c <[^>]*> nop
++0000a7a0 <[^>]*> nop
++0000a7a4 <[^>]*> nop
++0000a7a8 <[^>]*> nop
++0000a7ac <[^>]*> nop
++0000a7b0 <[^>]*> nop
++0000a7b4 <[^>]*> nop
++0000a7b8 <[^>]*> nop
++0000a7bc <[^>]*> nop
++0000a7c0 <[^>]*> nop
++0000a7c4 <[^>]*> nop
++0000a7c8 <[^>]*> nop
++0000a7cc <[^>]*> nop
++0000a7d0 <[^>]*> nop
++0000a7d4 <[^>]*> nop
++0000a7d8 <[^>]*> nop
++0000a7dc <[^>]*> nop
++0000a7e0 <[^>]*> nop
++0000a7e4 <[^>]*> nop
++0000a7e8 <[^>]*> nop
++0000a7ec <[^>]*> nop
++0000a7f0 <[^>]*> nop
++0000a7f4 <[^>]*> nop
++0000a7f8 <[^>]*> nop
++0000a7fc <[^>]*> nop
++0000a800 <[^>]*> nop
++0000a804 <[^>]*> nop
++0000a808 <[^>]*> nop
++0000a80c <[^>]*> nop
++0000a810 <[^>]*> nop
++0000a814 <[^>]*> nop
++0000a818 <[^>]*> nop
++0000a81c <[^>]*> nop
++0000a820 <[^>]*> nop
++0000a824 <[^>]*> nop
++0000a828 <[^>]*> nop
++0000a82c <[^>]*> nop
++0000a830 <[^>]*> nop
++0000a834 <[^>]*> nop
++0000a838 <[^>]*> nop
++0000a83c <[^>]*> nop
++0000a840 <[^>]*> nop
++0000a844 <[^>]*> nop
++0000a848 <[^>]*> nop
++0000a84c <[^>]*> nop
++0000a850 <[^>]*> nop
++0000a854 <[^>]*> nop
++0000a858 <[^>]*> nop
++0000a85c <[^>]*> nop
++0000a860 <[^>]*> nop
++0000a864 <[^>]*> nop
++0000a868 <[^>]*> nop
++0000a86c <[^>]*> nop
++0000a870 <[^>]*> nop
++0000a874 <[^>]*> nop
++0000a878 <[^>]*> nop
++0000a87c <[^>]*> nop
++0000a880 <[^>]*> nop
++0000a884 <[^>]*> nop
++0000a888 <[^>]*> nop
++0000a88c <[^>]*> nop
++0000a890 <[^>]*> nop
++0000a894 <[^>]*> nop
++0000a898 <[^>]*> nop
++0000a89c <[^>]*> nop
++0000a8a0 <[^>]*> nop
++0000a8a4 <[^>]*> nop
++0000a8a8 <[^>]*> nop
++0000a8ac <[^>]*> nop
++0000a8b0 <[^>]*> nop
++0000a8b4 <[^>]*> nop
++0000a8b8 <[^>]*> nop
++0000a8bc <[^>]*> nop
++0000a8c0 <[^>]*> nop
++0000a8c4 <[^>]*> nop
++0000a8c8 <[^>]*> nop
++0000a8cc <[^>]*> nop
++0000a8d0 <[^>]*> nop
++0000a8d4 <[^>]*> nop
++0000a8d8 <[^>]*> nop
++0000a8dc <[^>]*> nop
++0000a8e0 <[^>]*> nop
++0000a8e4 <[^>]*> nop
++0000a8e8 <[^>]*> nop
++0000a8ec <[^>]*> nop
++0000a8f0 <[^>]*> nop
++0000a8f4 <[^>]*> nop
++0000a8f8 <[^>]*> nop
++0000a8fc <[^>]*> nop
++0000a900 <[^>]*> nop
++0000a904 <[^>]*> nop
++0000a908 <[^>]*> nop
++0000a90c <[^>]*> nop
++0000a910 <[^>]*> nop
++0000a914 <[^>]*> nop
++0000a918 <[^>]*> nop
++0000a91c <[^>]*> nop
++0000a920 <[^>]*> nop
++0000a924 <[^>]*> nop
++0000a928 <[^>]*> nop
++0000a92c <[^>]*> nop
++0000a930 <[^>]*> nop
++0000a934 <[^>]*> nop
++0000a938 <[^>]*> nop
++0000a93c <[^>]*> nop
++0000a940 <[^>]*> nop
++0000a944 <[^>]*> nop
++0000a948 <[^>]*> nop
++0000a94c <[^>]*> nop
++0000a950 <[^>]*> nop
++0000a954 <[^>]*> nop
++0000a958 <[^>]*> nop
++0000a95c <[^>]*> nop
++0000a960 <[^>]*> nop
++0000a964 <[^>]*> nop
++0000a968 <[^>]*> nop
++0000a96c <[^>]*> nop
++0000a970 <[^>]*> nop
++0000a974 <[^>]*> nop
++0000a978 <[^>]*> nop
++0000a97c <[^>]*> nop
++0000a980 <[^>]*> nop
++0000a984 <[^>]*> nop
++0000a988 <[^>]*> nop
++0000a98c <[^>]*> nop
++0000a990 <[^>]*> nop
++0000a994 <[^>]*> nop
++0000a998 <[^>]*> nop
++0000a99c <[^>]*> nop
++0000a9a0 <[^>]*> nop
++0000a9a4 <[^>]*> nop
++0000a9a8 <[^>]*> nop
++0000a9ac <[^>]*> nop
++0000a9b0 <[^>]*> nop
++0000a9b4 <[^>]*> nop
++0000a9b8 <[^>]*> nop
++0000a9bc <[^>]*> nop
++0000a9c0 <[^>]*> nop
++0000a9c4 <[^>]*> nop
++0000a9c8 <[^>]*> nop
++0000a9cc <[^>]*> nop
++0000a9d0 <[^>]*> nop
++0000a9d4 <[^>]*> nop
++0000a9d8 <[^>]*> nop
++0000a9dc <[^>]*> nop
++0000a9e0 <[^>]*> nop
++0000a9e4 <[^>]*> nop
++0000a9e8 <[^>]*> nop
++0000a9ec <[^>]*> nop
++0000a9f0 <[^>]*> nop
++0000a9f4 <[^>]*> nop
++0000a9f8 <[^>]*> nop
++0000a9fc <[^>]*> nop
++0000aa00 <[^>]*> nop
++0000aa04 <[^>]*> nop
++0000aa08 <[^>]*> nop
++0000aa0c <[^>]*> nop
++0000aa10 <[^>]*> nop
++0000aa14 <[^>]*> nop
++0000aa18 <[^>]*> nop
++0000aa1c <[^>]*> nop
++0000aa20 <[^>]*> nop
++0000aa24 <[^>]*> nop
++0000aa28 <[^>]*> nop
++0000aa2c <[^>]*> nop
++0000aa30 <[^>]*> nop
++0000aa34 <[^>]*> nop
++0000aa38 <[^>]*> nop
++0000aa3c <[^>]*> nop
++0000aa40 <[^>]*> nop
++0000aa44 <[^>]*> nop
++0000aa48 <[^>]*> nop
++0000aa4c <[^>]*> nop
++0000aa50 <[^>]*> nop
++0000aa54 <[^>]*> nop
++0000aa58 <[^>]*> nop
++0000aa5c <[^>]*> nop
++0000aa60 <[^>]*> nop
++0000aa64 <[^>]*> nop
++0000aa68 <[^>]*> nop
++0000aa6c <[^>]*> nop
++0000aa70 <[^>]*> nop
++0000aa74 <[^>]*> nop
++0000aa78 <[^>]*> nop
++0000aa7c <[^>]*> nop
++0000aa80 <[^>]*> nop
++0000aa84 <[^>]*> nop
++0000aa88 <[^>]*> nop
++0000aa8c <[^>]*> nop
++0000aa90 <[^>]*> nop
++0000aa94 <[^>]*> nop
++0000aa98 <[^>]*> nop
++0000aa9c <[^>]*> nop
++0000aaa0 <[^>]*> nop
++0000aaa4 <[^>]*> nop
++0000aaa8 <[^>]*> nop
++0000aaac <[^>]*> nop
++0000aab0 <[^>]*> nop
++0000aab4 <[^>]*> nop
++0000aab8 <[^>]*> nop
++0000aabc <[^>]*> nop
++0000aac0 <[^>]*> nop
++0000aac4 <[^>]*> nop
++0000aac8 <[^>]*> nop
++0000aacc <[^>]*> nop
++0000aad0 <[^>]*> nop
++0000aad4 <[^>]*> nop
++0000aad8 <[^>]*> nop
++0000aadc <[^>]*> nop
++0000aae0 <[^>]*> nop
++0000aae4 <[^>]*> nop
++0000aae8 <[^>]*> nop
++0000aaec <[^>]*> nop
++0000aaf0 <[^>]*> nop
++0000aaf4 <[^>]*> nop
++0000aaf8 <[^>]*> nop
++0000aafc <[^>]*> nop
++0000ab00 <[^>]*> nop
++0000ab04 <[^>]*> nop
++0000ab08 <[^>]*> nop
++0000ab0c <[^>]*> nop
++0000ab10 <[^>]*> nop
++0000ab14 <[^>]*> nop
++0000ab18 <[^>]*> nop
++0000ab1c <[^>]*> nop
++0000ab20 <[^>]*> nop
++0000ab24 <[^>]*> nop
++0000ab28 <[^>]*> nop
++0000ab2c <[^>]*> nop
++0000ab30 <[^>]*> nop
++0000ab34 <[^>]*> nop
++0000ab38 <[^>]*> nop
++0000ab3c <[^>]*> nop
++0000ab40 <[^>]*> nop
++0000ab44 <[^>]*> nop
++0000ab48 <[^>]*> nop
++0000ab4c <[^>]*> nop
++0000ab50 <[^>]*> nop
++0000ab54 <[^>]*> nop
++0000ab58 <[^>]*> nop
++0000ab5c <[^>]*> nop
++0000ab60 <[^>]*> nop
++0000ab64 <[^>]*> nop
++0000ab68 <[^>]*> nop
++0000ab6c <[^>]*> nop
++0000ab70 <[^>]*> nop
++0000ab74 <[^>]*> nop
++0000ab78 <[^>]*> nop
++0000ab7c <[^>]*> nop
++0000ab80 <[^>]*> nop
++0000ab84 <[^>]*> nop
++0000ab88 <[^>]*> nop
++0000ab8c <[^>]*> nop
++0000ab90 <[^>]*> nop
++0000ab94 <[^>]*> nop
++0000ab98 <[^>]*> nop
++0000ab9c <[^>]*> nop
++0000aba0 <[^>]*> nop
++0000aba4 <[^>]*> nop
++0000aba8 <[^>]*> nop
++0000abac <[^>]*> nop
++0000abb0 <[^>]*> nop
++0000abb4 <[^>]*> nop
++0000abb8 <[^>]*> nop
++0000abbc <[^>]*> nop
++0000abc0 <[^>]*> nop
++0000abc4 <[^>]*> nop
++0000abc8 <[^>]*> nop
++0000abcc <[^>]*> nop
++0000abd0 <[^>]*> nop
++0000abd4 <[^>]*> nop
++0000abd8 <[^>]*> nop
++0000abdc <[^>]*> nop
++0000abe0 <[^>]*> nop
++0000abe4 <[^>]*> nop
++0000abe8 <[^>]*> nop
++0000abec <[^>]*> nop
++0000abf0 <[^>]*> nop
++0000abf4 <[^>]*> nop
++0000abf8 <[^>]*> nop
++0000abfc <[^>]*> nop
++0000ac00 <[^>]*> nop
++0000ac04 <[^>]*> nop
++0000ac08 <[^>]*> nop
++0000ac0c <[^>]*> nop
++0000ac10 <[^>]*> nop
++0000ac14 <[^>]*> nop
++0000ac18 <[^>]*> nop
++0000ac1c <[^>]*> nop
++0000ac20 <[^>]*> nop
++0000ac24 <[^>]*> nop
++0000ac28 <[^>]*> nop
++0000ac2c <[^>]*> nop
++0000ac30 <[^>]*> nop
++0000ac34 <[^>]*> nop
++0000ac38 <[^>]*> nop
++0000ac3c <[^>]*> nop
++0000ac40 <[^>]*> nop
++0000ac44 <[^>]*> nop
++0000ac48 <[^>]*> nop
++0000ac4c <[^>]*> nop
++0000ac50 <[^>]*> nop
++0000ac54 <[^>]*> nop
++0000ac58 <[^>]*> nop
++0000ac5c <[^>]*> nop
++0000ac60 <[^>]*> nop
++0000ac64 <[^>]*> nop
++0000ac68 <[^>]*> nop
++0000ac6c <[^>]*> nop
++0000ac70 <[^>]*> nop
++0000ac74 <[^>]*> nop
++0000ac78 <[^>]*> nop
++0000ac7c <[^>]*> nop
++0000ac80 <[^>]*> nop
++0000ac84 <[^>]*> nop
++0000ac88 <[^>]*> nop
++0000ac8c <[^>]*> nop
++0000ac90 <[^>]*> nop
++0000ac94 <[^>]*> nop
++0000ac98 <[^>]*> nop
++0000ac9c <[^>]*> nop
++0000aca0 <[^>]*> nop
++0000aca4 <[^>]*> nop
++0000aca8 <[^>]*> nop
++0000acac <[^>]*> nop
++0000acb0 <[^>]*> nop
++0000acb4 <[^>]*> nop
++0000acb8 <[^>]*> nop
++0000acbc <[^>]*> nop
++0000acc0 <[^>]*> nop
++0000acc4 <[^>]*> nop
++0000acc8 <[^>]*> nop
++0000accc <[^>]*> nop
++0000acd0 <[^>]*> nop
++0000acd4 <[^>]*> nop
++0000acd8 <[^>]*> nop
++0000acdc <[^>]*> nop
++0000ace0 <[^>]*> nop
++0000ace4 <[^>]*> nop
++0000ace8 <[^>]*> nop
++0000acec <[^>]*> nop
++0000acf0 <[^>]*> nop
++0000acf4 <[^>]*> nop
++0000acf8 <[^>]*> nop
++0000acfc <[^>]*> nop
++0000ad00 <[^>]*> nop
++0000ad04 <[^>]*> nop
++0000ad08 <[^>]*> nop
++0000ad0c <[^>]*> nop
++0000ad10 <[^>]*> nop
++0000ad14 <[^>]*> nop
++0000ad18 <[^>]*> nop
++0000ad1c <[^>]*> nop
++0000ad20 <[^>]*> nop
++0000ad24 <[^>]*> nop
++0000ad28 <[^>]*> nop
++0000ad2c <[^>]*> nop
++0000ad30 <[^>]*> nop
++0000ad34 <[^>]*> nop
++0000ad38 <[^>]*> nop
++0000ad3c <[^>]*> nop
++0000ad40 <[^>]*> nop
++0000ad44 <[^>]*> nop
++0000ad48 <[^>]*> nop
++0000ad4c <[^>]*> nop
++0000ad50 <[^>]*> nop
++0000ad54 <[^>]*> nop
++0000ad58 <[^>]*> nop
++0000ad5c <[^>]*> nop
++0000ad60 <[^>]*> nop
++0000ad64 <[^>]*> nop
++0000ad68 <[^>]*> nop
++0000ad6c <[^>]*> nop
++0000ad70 <[^>]*> nop
++0000ad74 <[^>]*> nop
++0000ad78 <[^>]*> nop
++0000ad7c <[^>]*> nop
++0000ad80 <[^>]*> nop
++0000ad84 <[^>]*> nop
++0000ad88 <[^>]*> nop
++0000ad8c <[^>]*> nop
++0000ad90 <[^>]*> nop
++0000ad94 <[^>]*> nop
++0000ad98 <[^>]*> nop
++0000ad9c <[^>]*> nop
++0000ada0 <[^>]*> nop
++0000ada4 <[^>]*> nop
++0000ada8 <[^>]*> nop
++0000adac <[^>]*> nop
++0000adb0 <[^>]*> nop
++0000adb4 <[^>]*> nop
++0000adb8 <[^>]*> nop
++0000adbc <[^>]*> nop
++0000adc0 <[^>]*> nop
++0000adc4 <[^>]*> nop
++0000adc8 <[^>]*> nop
++0000adcc <[^>]*> nop
++0000add0 <[^>]*> nop
++0000add4 <[^>]*> nop
++0000add8 <[^>]*> nop
++0000addc <[^>]*> nop
++0000ade0 <[^>]*> nop
++0000ade4 <[^>]*> nop
++0000ade8 <[^>]*> nop
++0000adec <[^>]*> nop
++0000adf0 <[^>]*> nop
++0000adf4 <[^>]*> nop
++0000adf8 <[^>]*> nop
++0000adfc <[^>]*> nop
++0000ae00 <[^>]*> nop
++0000ae04 <[^>]*> nop
++0000ae08 <[^>]*> nop
++0000ae0c <[^>]*> nop
++0000ae10 <[^>]*> nop
++0000ae14 <[^>]*> nop
++0000ae18 <[^>]*> nop
++0000ae1c <[^>]*> nop
++0000ae20 <[^>]*> nop
++0000ae24 <[^>]*> nop
++0000ae28 <[^>]*> nop
++0000ae2c <[^>]*> nop
++0000ae30 <[^>]*> nop
++0000ae34 <[^>]*> nop
++0000ae38 <[^>]*> nop
++0000ae3c <[^>]*> nop
++0000ae40 <[^>]*> nop
++0000ae44 <[^>]*> nop
++0000ae48 <[^>]*> nop
++0000ae4c <[^>]*> nop
++0000ae50 <[^>]*> nop
++0000ae54 <[^>]*> nop
++0000ae58 <[^>]*> nop
++0000ae5c <[^>]*> nop
++0000ae60 <[^>]*> nop
++0000ae64 <[^>]*> nop
++0000ae68 <[^>]*> nop
++0000ae6c <[^>]*> nop
++0000ae70 <[^>]*> nop
++0000ae74 <[^>]*> nop
++0000ae78 <[^>]*> nop
++0000ae7c <[^>]*> nop
++0000ae80 <[^>]*> nop
++0000ae84 <[^>]*> nop
++0000ae88 <[^>]*> nop
++0000ae8c <[^>]*> nop
++0000ae90 <[^>]*> nop
++0000ae94 <[^>]*> nop
++0000ae98 <[^>]*> nop
++0000ae9c <[^>]*> nop
++0000aea0 <[^>]*> nop
++0000aea4 <[^>]*> nop
++0000aea8 <[^>]*> nop
++0000aeac <[^>]*> nop
++0000aeb0 <[^>]*> nop
++0000aeb4 <[^>]*> nop
++0000aeb8 <[^>]*> nop
++0000aebc <[^>]*> nop
++0000aec0 <[^>]*> nop
++0000aec4 <[^>]*> nop
++0000aec8 <[^>]*> nop
++0000aecc <[^>]*> nop
++0000aed0 <[^>]*> nop
++0000aed4 <[^>]*> nop
++0000aed8 <[^>]*> nop
++0000aedc <[^>]*> nop
++0000aee0 <[^>]*> nop
++0000aee4 <[^>]*> nop
++0000aee8 <[^>]*> nop
++0000aeec <[^>]*> nop
++0000aef0 <[^>]*> nop
++0000aef4 <[^>]*> nop
++0000aef8 <[^>]*> nop
++0000aefc <[^>]*> nop
++0000af00 <[^>]*> nop
++0000af04 <[^>]*> nop
++0000af08 <[^>]*> nop
++0000af0c <[^>]*> nop
++0000af10 <[^>]*> nop
++0000af14 <[^>]*> nop
++0000af18 <[^>]*> nop
++0000af1c <[^>]*> nop
++0000af20 <[^>]*> nop
++0000af24 <[^>]*> nop
++0000af28 <[^>]*> nop
++0000af2c <[^>]*> nop
++0000af30 <[^>]*> nop
++0000af34 <[^>]*> nop
++0000af38 <[^>]*> nop
++0000af3c <[^>]*> nop
++0000af40 <[^>]*> nop
++0000af44 <[^>]*> nop
++0000af48 <[^>]*> nop
++0000af4c <[^>]*> nop
++0000af50 <[^>]*> nop
++0000af54 <[^>]*> nop
++0000af58 <[^>]*> nop
++0000af5c <[^>]*> nop
++0000af60 <[^>]*> nop
++0000af64 <[^>]*> nop
++0000af68 <[^>]*> nop
++0000af6c <[^>]*> nop
++0000af70 <[^>]*> nop
++0000af74 <[^>]*> nop
++0000af78 <[^>]*> nop
++0000af7c <[^>]*> nop
++0000af80 <[^>]*> nop
++0000af84 <[^>]*> nop
++0000af88 <[^>]*> nop
++0000af8c <[^>]*> nop
++0000af90 <[^>]*> nop
++0000af94 <[^>]*> nop
++0000af98 <[^>]*> nop
++0000af9c <[^>]*> nop
++0000afa0 <[^>]*> nop
++0000afa4 <[^>]*> nop
++0000afa8 <[^>]*> nop
++0000afac <[^>]*> nop
++0000afb0 <[^>]*> nop
++0000afb4 <[^>]*> nop
++0000afb8 <[^>]*> nop
++0000afbc <[^>]*> nop
++0000afc0 <[^>]*> nop
++0000afc4 <[^>]*> nop
++0000afc8 <[^>]*> nop
++0000afcc <[^>]*> nop
++0000afd0 <[^>]*> nop
++0000afd4 <[^>]*> nop
++0000afd8 <[^>]*> nop
++0000afdc <[^>]*> nop
++0000afe0 <[^>]*> nop
++0000afe4 <[^>]*> nop
++0000afe8 <[^>]*> nop
++0000afec <[^>]*> nop
++0000aff0 <[^>]*> nop
++0000aff4 <[^>]*> nop
++0000aff8 <[^>]*> nop
++0000affc <[^>]*> nop
++0000b000 <[^>]*> nop
++0000b004 <[^>]*> nop
++0000b008 <[^>]*> nop
++0000b00c <[^>]*> nop
++0000b010 <[^>]*> nop
++0000b014 <[^>]*> nop
++0000b018 <[^>]*> nop
++0000b01c <[^>]*> nop
++0000b020 <[^>]*> nop
++0000b024 <[^>]*> nop
++0000b028 <[^>]*> nop
++0000b02c <[^>]*> nop
++0000b030 <[^>]*> nop
++0000b034 <[^>]*> nop
++0000b038 <[^>]*> nop
++0000b03c <[^>]*> nop
++0000b040 <[^>]*> nop
++0000b044 <[^>]*> nop
++0000b048 <[^>]*> nop
++0000b04c <[^>]*> nop
++0000b050 <[^>]*> nop
++0000b054 <[^>]*> nop
++0000b058 <[^>]*> nop
++0000b05c <[^>]*> nop
++0000b060 <[^>]*> nop
++0000b064 <[^>]*> nop
++0000b068 <[^>]*> nop
++0000b06c <[^>]*> nop
++0000b070 <[^>]*> nop
++0000b074 <[^>]*> nop
++0000b078 <[^>]*> nop
++0000b07c <[^>]*> nop
++0000b080 <[^>]*> nop
++0000b084 <[^>]*> nop
++0000b088 <[^>]*> nop
++0000b08c <[^>]*> nop
++0000b090 <[^>]*> nop
++0000b094 <[^>]*> nop
++0000b098 <[^>]*> nop
++0000b09c <[^>]*> nop
++0000b0a0 <[^>]*> nop
++0000b0a4 <[^>]*> nop
++0000b0a8 <[^>]*> nop
++0000b0ac <[^>]*> nop
++0000b0b0 <[^>]*> nop
++0000b0b4 <[^>]*> nop
++0000b0b8 <[^>]*> nop
++0000b0bc <[^>]*> nop
++0000b0c0 <[^>]*> nop
++0000b0c4 <[^>]*> nop
++0000b0c8 <[^>]*> nop
++0000b0cc <[^>]*> nop
++0000b0d0 <[^>]*> nop
++0000b0d4 <[^>]*> nop
++0000b0d8 <[^>]*> nop
++0000b0dc <[^>]*> nop
++0000b0e0 <[^>]*> nop
++0000b0e4 <[^>]*> nop
++0000b0e8 <[^>]*> nop
++0000b0ec <[^>]*> nop
++0000b0f0 <[^>]*> nop
++0000b0f4 <[^>]*> nop
++0000b0f8 <[^>]*> nop
++0000b0fc <[^>]*> nop
++0000b100 <[^>]*> nop
++0000b104 <[^>]*> nop
++0000b108 <[^>]*> nop
++0000b10c <[^>]*> nop
++0000b110 <[^>]*> nop
++0000b114 <[^>]*> nop
++0000b118 <[^>]*> nop
++0000b11c <[^>]*> nop
++0000b120 <[^>]*> nop
++0000b124 <[^>]*> nop
++0000b128 <[^>]*> nop
++0000b12c <[^>]*> nop
++0000b130 <[^>]*> nop
++0000b134 <[^>]*> nop
++0000b138 <[^>]*> nop
++0000b13c <[^>]*> nop
++0000b140 <[^>]*> nop
++0000b144 <[^>]*> nop
++0000b148 <[^>]*> nop
++0000b14c <[^>]*> nop
++0000b150 <[^>]*> nop
++0000b154 <[^>]*> nop
++0000b158 <[^>]*> nop
++0000b15c <[^>]*> nop
++0000b160 <[^>]*> nop
++0000b164 <[^>]*> nop
++0000b168 <[^>]*> nop
++0000b16c <[^>]*> nop
++0000b170 <[^>]*> nop
++0000b174 <[^>]*> nop
++0000b178 <[^>]*> nop
++0000b17c <[^>]*> nop
++0000b180 <[^>]*> nop
++0000b184 <[^>]*> nop
++0000b188 <[^>]*> nop
++0000b18c <[^>]*> nop
++0000b190 <[^>]*> nop
++0000b194 <[^>]*> nop
++0000b198 <[^>]*> nop
++0000b19c <[^>]*> nop
++0000b1a0 <[^>]*> nop
++0000b1a4 <[^>]*> nop
++0000b1a8 <[^>]*> nop
++0000b1ac <[^>]*> nop
++0000b1b0 <[^>]*> nop
++0000b1b4 <[^>]*> nop
++0000b1b8 <[^>]*> nop
++0000b1bc <[^>]*> nop
++0000b1c0 <[^>]*> nop
++0000b1c4 <[^>]*> nop
++0000b1c8 <[^>]*> nop
++0000b1cc <[^>]*> nop
++0000b1d0 <[^>]*> nop
++0000b1d4 <[^>]*> nop
++0000b1d8 <[^>]*> nop
++0000b1dc <[^>]*> nop
++0000b1e0 <[^>]*> nop
++0000b1e4 <[^>]*> nop
++0000b1e8 <[^>]*> nop
++0000b1ec <[^>]*> nop
++0000b1f0 <[^>]*> nop
++0000b1f4 <[^>]*> nop
++0000b1f8 <[^>]*> nop
++0000b1fc <[^>]*> nop
++0000b200 <[^>]*> nop
++0000b204 <[^>]*> nop
++0000b208 <[^>]*> nop
++0000b20c <[^>]*> nop
++0000b210 <[^>]*> nop
++0000b214 <[^>]*> nop
++0000b218 <[^>]*> nop
++0000b21c <[^>]*> nop
++0000b220 <[^>]*> nop
++0000b224 <[^>]*> nop
++0000b228 <[^>]*> nop
++0000b22c <[^>]*> nop
++0000b230 <[^>]*> nop
++0000b234 <[^>]*> nop
++0000b238 <[^>]*> nop
++0000b23c <[^>]*> nop
++0000b240 <[^>]*> nop
++0000b244 <[^>]*> nop
++0000b248 <[^>]*> nop
++0000b24c <[^>]*> nop
++0000b250 <[^>]*> nop
++0000b254 <[^>]*> nop
++0000b258 <[^>]*> nop
++0000b25c <[^>]*> nop
++0000b260 <[^>]*> nop
++0000b264 <[^>]*> nop
++0000b268 <[^>]*> nop
++0000b26c <[^>]*> nop
++0000b270 <[^>]*> nop
++0000b274 <[^>]*> nop
++0000b278 <[^>]*> nop
++0000b27c <[^>]*> nop
++0000b280 <[^>]*> nop
++0000b284 <[^>]*> nop
++0000b288 <[^>]*> nop
++0000b28c <[^>]*> nop
++0000b290 <[^>]*> nop
++0000b294 <[^>]*> nop
++0000b298 <[^>]*> nop
++0000b29c <[^>]*> nop
++0000b2a0 <[^>]*> nop
++0000b2a4 <[^>]*> nop
++0000b2a8 <[^>]*> nop
++0000b2ac <[^>]*> nop
++0000b2b0 <[^>]*> nop
++0000b2b4 <[^>]*> nop
++0000b2b8 <[^>]*> nop
++0000b2bc <[^>]*> nop
++0000b2c0 <[^>]*> nop
++0000b2c4 <[^>]*> nop
++0000b2c8 <[^>]*> nop
++0000b2cc <[^>]*> nop
++0000b2d0 <[^>]*> nop
++0000b2d4 <[^>]*> nop
++0000b2d8 <[^>]*> nop
++0000b2dc <[^>]*> nop
++0000b2e0 <[^>]*> nop
++0000b2e4 <[^>]*> nop
++0000b2e8 <[^>]*> nop
++0000b2ec <[^>]*> nop
++0000b2f0 <[^>]*> nop
++0000b2f4 <[^>]*> nop
++0000b2f8 <[^>]*> nop
++0000b2fc <[^>]*> nop
++0000b300 <[^>]*> nop
++0000b304 <[^>]*> nop
++0000b308 <[^>]*> nop
++0000b30c <[^>]*> nop
++0000b310 <[^>]*> nop
++0000b314 <[^>]*> nop
++0000b318 <[^>]*> nop
++0000b31c <[^>]*> nop
++0000b320 <[^>]*> nop
++0000b324 <[^>]*> nop
++0000b328 <[^>]*> nop
++0000b32c <[^>]*> nop
++0000b330 <[^>]*> nop
++0000b334 <[^>]*> nop
++0000b338 <[^>]*> nop
++0000b33c <[^>]*> nop
++0000b340 <[^>]*> nop
++0000b344 <[^>]*> nop
++0000b348 <[^>]*> nop
++0000b34c <[^>]*> nop
++0000b350 <[^>]*> nop
++0000b354 <[^>]*> nop
++0000b358 <[^>]*> nop
++0000b35c <[^>]*> nop
++0000b360 <[^>]*> nop
++0000b364 <[^>]*> nop
++0000b368 <[^>]*> nop
++0000b36c <[^>]*> nop
++0000b370 <[^>]*> nop
++0000b374 <[^>]*> nop
++0000b378 <[^>]*> nop
++0000b37c <[^>]*> nop
++0000b380 <[^>]*> nop
++0000b384 <[^>]*> nop
++0000b388 <[^>]*> nop
++0000b38c <[^>]*> nop
++0000b390 <[^>]*> nop
++0000b394 <[^>]*> nop
++0000b398 <[^>]*> nop
++0000b39c <[^>]*> nop
++0000b3a0 <[^>]*> nop
++0000b3a4 <[^>]*> nop
++0000b3a8 <[^>]*> nop
++0000b3ac <[^>]*> nop
++0000b3b0 <[^>]*> nop
++0000b3b4 <[^>]*> nop
++0000b3b8 <[^>]*> nop
++0000b3bc <[^>]*> nop
++0000b3c0 <[^>]*> nop
++0000b3c4 <[^>]*> nop
++0000b3c8 <[^>]*> nop
++0000b3cc <[^>]*> nop
++0000b3d0 <[^>]*> nop
++0000b3d4 <[^>]*> nop
++0000b3d8 <[^>]*> nop
++0000b3dc <[^>]*> nop
++0000b3e0 <[^>]*> nop
++0000b3e4 <[^>]*> nop
++0000b3e8 <[^>]*> nop
++0000b3ec <[^>]*> nop
++0000b3f0 <[^>]*> nop
++0000b3f4 <[^>]*> nop
++0000b3f8 <[^>]*> nop
++0000b3fc <[^>]*> nop
++0000b400 <[^>]*> nop
++0000b404 <[^>]*> nop
++0000b408 <[^>]*> nop
++0000b40c <[^>]*> nop
++0000b410 <[^>]*> nop
++0000b414 <[^>]*> nop
++0000b418 <[^>]*> nop
++0000b41c <[^>]*> nop
++0000b420 <[^>]*> nop
++0000b424 <[^>]*> nop
++0000b428 <[^>]*> nop
++0000b42c <[^>]*> nop
++0000b430 <[^>]*> nop
++0000b434 <[^>]*> nop
++0000b438 <[^>]*> nop
++0000b43c <[^>]*> nop
++0000b440 <[^>]*> nop
++0000b444 <[^>]*> nop
++0000b448 <[^>]*> nop
++0000b44c <[^>]*> nop
++0000b450 <[^>]*> nop
++0000b454 <[^>]*> nop
++0000b458 <[^>]*> nop
++0000b45c <[^>]*> nop
++0000b460 <[^>]*> nop
++0000b464 <[^>]*> nop
++0000b468 <[^>]*> nop
++0000b46c <[^>]*> nop
++0000b470 <[^>]*> nop
++0000b474 <[^>]*> nop
++0000b478 <[^>]*> nop
++0000b47c <[^>]*> nop
++0000b480 <[^>]*> nop
++0000b484 <[^>]*> nop
++0000b488 <[^>]*> nop
++0000b48c <[^>]*> nop
++0000b490 <[^>]*> nop
++0000b494 <[^>]*> nop
++0000b498 <[^>]*> nop
++0000b49c <[^>]*> nop
++0000b4a0 <[^>]*> nop
++0000b4a4 <[^>]*> nop
++0000b4a8 <[^>]*> nop
++0000b4ac <[^>]*> nop
++0000b4b0 <[^>]*> nop
++0000b4b4 <[^>]*> nop
++0000b4b8 <[^>]*> nop
++0000b4bc <[^>]*> nop
++0000b4c0 <[^>]*> nop
++0000b4c4 <[^>]*> nop
++0000b4c8 <[^>]*> nop
++0000b4cc <[^>]*> nop
++0000b4d0 <[^>]*> nop
++0000b4d4 <[^>]*> nop
++0000b4d8 <[^>]*> nop
++0000b4dc <[^>]*> nop
++0000b4e0 <[^>]*> nop
++0000b4e4 <[^>]*> nop
++0000b4e8 <[^>]*> nop
++0000b4ec <[^>]*> nop
++0000b4f0 <[^>]*> nop
++0000b4f4 <[^>]*> nop
++0000b4f8 <[^>]*> nop
++0000b4fc <[^>]*> nop
++0000b500 <[^>]*> nop
++0000b504 <[^>]*> nop
++0000b508 <[^>]*> nop
++0000b50c <[^>]*> nop
++0000b510 <[^>]*> nop
++0000b514 <[^>]*> nop
++0000b518 <[^>]*> nop
++0000b51c <[^>]*> nop
++0000b520 <[^>]*> nop
++0000b524 <[^>]*> nop
++0000b528 <[^>]*> nop
++0000b52c <[^>]*> nop
++0000b530 <[^>]*> nop
++0000b534 <[^>]*> nop
++0000b538 <[^>]*> nop
++0000b53c <[^>]*> nop
++0000b540 <[^>]*> nop
++0000b544 <[^>]*> nop
++0000b548 <[^>]*> nop
++0000b54c <[^>]*> nop
++0000b550 <[^>]*> nop
++0000b554 <[^>]*> nop
++0000b558 <[^>]*> nop
++0000b55c <[^>]*> nop
++0000b560 <[^>]*> nop
++0000b564 <[^>]*> nop
++0000b568 <[^>]*> nop
++0000b56c <[^>]*> nop
++0000b570 <[^>]*> nop
++0000b574 <[^>]*> nop
++0000b578 <[^>]*> nop
++0000b57c <[^>]*> nop
++0000b580 <[^>]*> nop
++0000b584 <[^>]*> nop
++0000b588 <[^>]*> nop
++0000b58c <[^>]*> nop
++0000b590 <[^>]*> nop
++0000b594 <[^>]*> nop
++0000b598 <[^>]*> nop
++0000b59c <[^>]*> nop
++0000b5a0 <[^>]*> nop
++0000b5a4 <[^>]*> nop
++0000b5a8 <[^>]*> nop
++0000b5ac <[^>]*> nop
++0000b5b0 <[^>]*> nop
++0000b5b4 <[^>]*> nop
++0000b5b8 <[^>]*> nop
++0000b5bc <[^>]*> nop
++0000b5c0 <[^>]*> nop
++0000b5c4 <[^>]*> nop
++0000b5c8 <[^>]*> nop
++0000b5cc <[^>]*> nop
++0000b5d0 <[^>]*> nop
++0000b5d4 <[^>]*> nop
++0000b5d8 <[^>]*> nop
++0000b5dc <[^>]*> nop
++0000b5e0 <[^>]*> nop
++0000b5e4 <[^>]*> nop
++0000b5e8 <[^>]*> nop
++0000b5ec <[^>]*> nop
++0000b5f0 <[^>]*> nop
++0000b5f4 <[^>]*> nop
++0000b5f8 <[^>]*> nop
++0000b5fc <[^>]*> nop
++0000b600 <[^>]*> nop
++0000b604 <[^>]*> nop
++0000b608 <[^>]*> nop
++0000b60c <[^>]*> nop
++0000b610 <[^>]*> nop
++0000b614 <[^>]*> nop
++0000b618 <[^>]*> nop
++0000b61c <[^>]*> nop
++0000b620 <[^>]*> nop
++0000b624 <[^>]*> nop
++0000b628 <[^>]*> nop
++0000b62c <[^>]*> nop
++0000b630 <[^>]*> nop
++0000b634 <[^>]*> nop
++0000b638 <[^>]*> nop
++0000b63c <[^>]*> nop
++0000b640 <[^>]*> nop
++0000b644 <[^>]*> nop
++0000b648 <[^>]*> nop
++0000b64c <[^>]*> nop
++0000b650 <[^>]*> nop
++0000b654 <[^>]*> nop
++0000b658 <[^>]*> nop
++0000b65c <[^>]*> nop
++0000b660 <[^>]*> nop
++0000b664 <[^>]*> nop
++0000b668 <[^>]*> nop
++0000b66c <[^>]*> nop
++0000b670 <[^>]*> nop
++0000b674 <[^>]*> nop
++0000b678 <[^>]*> nop
++0000b67c <[^>]*> nop
++0000b680 <[^>]*> nop
++0000b684 <[^>]*> nop
++0000b688 <[^>]*> nop
++0000b68c <[^>]*> nop
++0000b690 <[^>]*> nop
++0000b694 <[^>]*> nop
++0000b698 <[^>]*> nop
++0000b69c <[^>]*> nop
++0000b6a0 <[^>]*> nop
++0000b6a4 <[^>]*> nop
++0000b6a8 <[^>]*> nop
++0000b6ac <[^>]*> nop
++0000b6b0 <[^>]*> nop
++0000b6b4 <[^>]*> nop
++0000b6b8 <[^>]*> nop
++0000b6bc <[^>]*> nop
++0000b6c0 <[^>]*> nop
++0000b6c4 <[^>]*> nop
++0000b6c8 <[^>]*> nop
++0000b6cc <[^>]*> nop
++0000b6d0 <[^>]*> nop
++0000b6d4 <[^>]*> nop
++0000b6d8 <[^>]*> nop
++0000b6dc <[^>]*> nop
++0000b6e0 <[^>]*> nop
++0000b6e4 <[^>]*> nop
++0000b6e8 <[^>]*> nop
++0000b6ec <[^>]*> nop
++0000b6f0 <[^>]*> nop
++0000b6f4 <[^>]*> nop
++0000b6f8 <[^>]*> nop
++0000b6fc <[^>]*> nop
++0000b700 <[^>]*> nop
++0000b704 <[^>]*> nop
++0000b708 <[^>]*> nop
++0000b70c <[^>]*> nop
++0000b710 <[^>]*> nop
++0000b714 <[^>]*> nop
++0000b718 <[^>]*> nop
++0000b71c <[^>]*> nop
++0000b720 <[^>]*> nop
++0000b724 <[^>]*> nop
++0000b728 <[^>]*> nop
++0000b72c <[^>]*> nop
++0000b730 <[^>]*> nop
++0000b734 <[^>]*> nop
++0000b738 <[^>]*> nop
++0000b73c <[^>]*> nop
++0000b740 <[^>]*> nop
++0000b744 <[^>]*> nop
++0000b748 <[^>]*> nop
++0000b74c <[^>]*> nop
++0000b750 <[^>]*> nop
++0000b754 <[^>]*> nop
++0000b758 <[^>]*> nop
++0000b75c <[^>]*> nop
++0000b760 <[^>]*> nop
++0000b764 <[^>]*> nop
++0000b768 <[^>]*> nop
++0000b76c <[^>]*> nop
++0000b770 <[^>]*> nop
++0000b774 <[^>]*> nop
++0000b778 <[^>]*> nop
++0000b77c <[^>]*> nop
++0000b780 <[^>]*> nop
++0000b784 <[^>]*> nop
++0000b788 <[^>]*> nop
++0000b78c <[^>]*> nop
++0000b790 <[^>]*> nop
++0000b794 <[^>]*> nop
++0000b798 <[^>]*> nop
++0000b79c <[^>]*> nop
++0000b7a0 <[^>]*> nop
++0000b7a4 <[^>]*> nop
++0000b7a8 <[^>]*> nop
++0000b7ac <[^>]*> nop
++0000b7b0 <[^>]*> nop
++0000b7b4 <[^>]*> nop
++0000b7b8 <[^>]*> nop
++0000b7bc <[^>]*> nop
++0000b7c0 <[^>]*> nop
++0000b7c4 <[^>]*> nop
++0000b7c8 <[^>]*> nop
++0000b7cc <[^>]*> nop
++0000b7d0 <[^>]*> nop
++0000b7d4 <[^>]*> nop
++0000b7d8 <[^>]*> nop
++0000b7dc <[^>]*> nop
++0000b7e0 <[^>]*> nop
++0000b7e4 <[^>]*> nop
++0000b7e8 <[^>]*> nop
++0000b7ec <[^>]*> nop
++0000b7f0 <[^>]*> nop
++0000b7f4 <[^>]*> nop
++0000b7f8 <[^>]*> nop
++0000b7fc <[^>]*> nop
++0000b800 <[^>]*> nop
++0000b804 <[^>]*> nop
++0000b808 <[^>]*> nop
++0000b80c <[^>]*> nop
++0000b810 <[^>]*> nop
++0000b814 <[^>]*> nop
++0000b818 <[^>]*> nop
++0000b81c <[^>]*> nop
++0000b820 <[^>]*> nop
++0000b824 <[^>]*> nop
++0000b828 <[^>]*> nop
++0000b82c <[^>]*> nop
++0000b830 <[^>]*> nop
++0000b834 <[^>]*> nop
++0000b838 <[^>]*> nop
++0000b83c <[^>]*> nop
++0000b840 <[^>]*> nop
++0000b844 <[^>]*> nop
++0000b848 <[^>]*> nop
++0000b84c <[^>]*> nop
++0000b850 <[^>]*> nop
++0000b854 <[^>]*> nop
++0000b858 <[^>]*> nop
++0000b85c <[^>]*> nop
++0000b860 <[^>]*> nop
++0000b864 <[^>]*> nop
++0000b868 <[^>]*> nop
++0000b86c <[^>]*> nop
++0000b870 <[^>]*> nop
++0000b874 <[^>]*> nop
++0000b878 <[^>]*> nop
++0000b87c <[^>]*> nop
++0000b880 <[^>]*> nop
++0000b884 <[^>]*> nop
++0000b888 <[^>]*> nop
++0000b88c <[^>]*> nop
++0000b890 <[^>]*> nop
++0000b894 <[^>]*> nop
++0000b898 <[^>]*> nop
++0000b89c <[^>]*> nop
++0000b8a0 <[^>]*> nop
++0000b8a4 <[^>]*> nop
++0000b8a8 <[^>]*> nop
++0000b8ac <[^>]*> nop
++0000b8b0 <[^>]*> nop
++0000b8b4 <[^>]*> nop
++0000b8b8 <[^>]*> nop
++0000b8bc <[^>]*> nop
++0000b8c0 <[^>]*> nop
++0000b8c4 <[^>]*> nop
++0000b8c8 <[^>]*> nop
++0000b8cc <[^>]*> nop
++0000b8d0 <[^>]*> nop
++0000b8d4 <[^>]*> nop
++0000b8d8 <[^>]*> nop
++0000b8dc <[^>]*> nop
++0000b8e0 <[^>]*> nop
++0000b8e4 <[^>]*> nop
++0000b8e8 <[^>]*> nop
++0000b8ec <[^>]*> nop
++0000b8f0 <[^>]*> nop
++0000b8f4 <[^>]*> nop
++0000b8f8 <[^>]*> nop
++0000b8fc <[^>]*> nop
++0000b900 <[^>]*> nop
++0000b904 <[^>]*> nop
++0000b908 <[^>]*> nop
++0000b90c <[^>]*> nop
++0000b910 <[^>]*> nop
++0000b914 <[^>]*> nop
++0000b918 <[^>]*> nop
++0000b91c <[^>]*> nop
++0000b920 <[^>]*> nop
++0000b924 <[^>]*> nop
++0000b928 <[^>]*> nop
++0000b92c <[^>]*> nop
++0000b930 <[^>]*> nop
++0000b934 <[^>]*> nop
++0000b938 <[^>]*> nop
++0000b93c <[^>]*> nop
++0000b940 <[^>]*> nop
++0000b944 <[^>]*> nop
++0000b948 <[^>]*> nop
++0000b94c <[^>]*> nop
++0000b950 <[^>]*> nop
++0000b954 <[^>]*> nop
++0000b958 <[^>]*> nop
++0000b95c <[^>]*> nop
++0000b960 <[^>]*> nop
++0000b964 <[^>]*> nop
++0000b968 <[^>]*> nop
++0000b96c <[^>]*> nop
++0000b970 <[^>]*> nop
++0000b974 <[^>]*> nop
++0000b978 <[^>]*> nop
++0000b97c <[^>]*> nop
++0000b980 <[^>]*> nop
++0000b984 <[^>]*> nop
++0000b988 <[^>]*> nop
++0000b98c <[^>]*> nop
++0000b990 <[^>]*> nop
++0000b994 <[^>]*> nop
++0000b998 <[^>]*> nop
++0000b99c <[^>]*> nop
++0000b9a0 <[^>]*> nop
++0000b9a4 <[^>]*> nop
++0000b9a8 <[^>]*> nop
++0000b9ac <[^>]*> nop
++0000b9b0 <[^>]*> nop
++0000b9b4 <[^>]*> nop
++0000b9b8 <[^>]*> nop
++0000b9bc <[^>]*> nop
++0000b9c0 <[^>]*> nop
++0000b9c4 <[^>]*> nop
++0000b9c8 <[^>]*> nop
++0000b9cc <[^>]*> nop
++0000b9d0 <[^>]*> nop
++0000b9d4 <[^>]*> nop
++0000b9d8 <[^>]*> nop
++0000b9dc <[^>]*> nop
++0000b9e0 <[^>]*> nop
++0000b9e4 <[^>]*> nop
++0000b9e8 <[^>]*> nop
++0000b9ec <[^>]*> nop
++0000b9f0 <[^>]*> nop
++0000b9f4 <[^>]*> nop
++0000b9f8 <[^>]*> nop
++0000b9fc <[^>]*> nop
++0000ba00 <[^>]*> nop
++0000ba04 <[^>]*> nop
++0000ba08 <[^>]*> nop
++0000ba0c <[^>]*> nop
++0000ba10 <[^>]*> nop
++0000ba14 <[^>]*> nop
++0000ba18 <[^>]*> nop
++0000ba1c <[^>]*> nop
++0000ba20 <[^>]*> nop
++0000ba24 <[^>]*> nop
++0000ba28 <[^>]*> nop
++0000ba2c <[^>]*> nop
++0000ba30 <[^>]*> nop
++0000ba34 <[^>]*> nop
++0000ba38 <[^>]*> nop
++0000ba3c <[^>]*> nop
++0000ba40 <[^>]*> nop
++0000ba44 <[^>]*> nop
++0000ba48 <[^>]*> nop
++0000ba4c <[^>]*> nop
++0000ba50 <[^>]*> nop
++0000ba54 <[^>]*> nop
++0000ba58 <[^>]*> nop
++0000ba5c <[^>]*> nop
++0000ba60 <[^>]*> nop
++0000ba64 <[^>]*> nop
++0000ba68 <[^>]*> nop
++0000ba6c <[^>]*> nop
++0000ba70 <[^>]*> nop
++0000ba74 <[^>]*> nop
++0000ba78 <[^>]*> nop
++0000ba7c <[^>]*> nop
++0000ba80 <[^>]*> nop
++0000ba84 <[^>]*> nop
++0000ba88 <[^>]*> nop
++0000ba8c <[^>]*> nop
++0000ba90 <[^>]*> nop
++0000ba94 <[^>]*> nop
++0000ba98 <[^>]*> nop
++0000ba9c <[^>]*> nop
++0000baa0 <[^>]*> nop
++0000baa4 <[^>]*> nop
++0000baa8 <[^>]*> nop
++0000baac <[^>]*> nop
++0000bab0 <[^>]*> nop
++0000bab4 <[^>]*> nop
++0000bab8 <[^>]*> nop
++0000babc <[^>]*> nop
++0000bac0 <[^>]*> nop
++0000bac4 <[^>]*> nop
++0000bac8 <[^>]*> nop
++0000bacc <[^>]*> nop
++0000bad0 <[^>]*> nop
++0000bad4 <[^>]*> nop
++0000bad8 <[^>]*> nop
++0000badc <[^>]*> nop
++0000bae0 <[^>]*> nop
++0000bae4 <[^>]*> nop
++0000bae8 <[^>]*> nop
++0000baec <[^>]*> nop
++0000baf0 <[^>]*> nop
++0000baf4 <[^>]*> nop
++0000baf8 <[^>]*> nop
++0000bafc <[^>]*> nop
++0000bb00 <[^>]*> nop
++0000bb04 <[^>]*> nop
++0000bb08 <[^>]*> nop
++0000bb0c <[^>]*> nop
++0000bb10 <[^>]*> nop
++0000bb14 <[^>]*> nop
++0000bb18 <[^>]*> nop
++0000bb1c <[^>]*> nop
++0000bb20 <[^>]*> nop
++0000bb24 <[^>]*> nop
++0000bb28 <[^>]*> nop
++0000bb2c <[^>]*> nop
++0000bb30 <[^>]*> nop
++0000bb34 <[^>]*> nop
++0000bb38 <[^>]*> nop
++0000bb3c <[^>]*> nop
++0000bb40 <[^>]*> nop
++0000bb44 <[^>]*> nop
++0000bb48 <[^>]*> nop
++0000bb4c <[^>]*> nop
++0000bb50 <[^>]*> nop
++0000bb54 <[^>]*> nop
++0000bb58 <[^>]*> nop
++0000bb5c <[^>]*> nop
++0000bb60 <[^>]*> nop
++0000bb64 <[^>]*> nop
++0000bb68 <[^>]*> nop
++0000bb6c <[^>]*> nop
++0000bb70 <[^>]*> nop
++0000bb74 <[^>]*> nop
++0000bb78 <[^>]*> nop
++0000bb7c <[^>]*> nop
++0000bb80 <[^>]*> nop
++0000bb84 <[^>]*> nop
++0000bb88 <[^>]*> nop
++0000bb8c <[^>]*> nop
++0000bb90 <[^>]*> nop
++0000bb94 <[^>]*> nop
++0000bb98 <[^>]*> nop
++0000bb9c <[^>]*> nop
++0000bba0 <[^>]*> nop
++0000bba4 <[^>]*> nop
++0000bba8 <[^>]*> nop
++0000bbac <[^>]*> nop
++0000bbb0 <[^>]*> nop
++0000bbb4 <[^>]*> nop
++0000bbb8 <[^>]*> nop
++0000bbbc <[^>]*> nop
++0000bbc0 <[^>]*> nop
++0000bbc4 <[^>]*> nop
++0000bbc8 <[^>]*> nop
++0000bbcc <[^>]*> nop
++0000bbd0 <[^>]*> nop
++0000bbd4 <[^>]*> nop
++0000bbd8 <[^>]*> nop
++0000bbdc <[^>]*> nop
++0000bbe0 <[^>]*> nop
++0000bbe4 <[^>]*> nop
++0000bbe8 <[^>]*> nop
++0000bbec <[^>]*> nop
++0000bbf0 <[^>]*> nop
++0000bbf4 <[^>]*> nop
++0000bbf8 <[^>]*> nop
++0000bbfc <[^>]*> nop
++0000bc00 <[^>]*> nop
++0000bc04 <[^>]*> nop
++0000bc08 <[^>]*> nop
++0000bc0c <[^>]*> nop
++0000bc10 <[^>]*> nop
++0000bc14 <[^>]*> nop
++0000bc18 <[^>]*> nop
++0000bc1c <[^>]*> nop
++0000bc20 <[^>]*> nop
++0000bc24 <[^>]*> nop
++0000bc28 <[^>]*> nop
++0000bc2c <[^>]*> nop
++0000bc30 <[^>]*> nop
++0000bc34 <[^>]*> nop
++0000bc38 <[^>]*> nop
++0000bc3c <[^>]*> nop
++0000bc40 <[^>]*> nop
++0000bc44 <[^>]*> nop
++0000bc48 <[^>]*> nop
++0000bc4c <[^>]*> nop
++0000bc50 <[^>]*> nop
++0000bc54 <[^>]*> nop
++0000bc58 <[^>]*> nop
++0000bc5c <[^>]*> nop
++0000bc60 <[^>]*> nop
++0000bc64 <[^>]*> nop
++0000bc68 <[^>]*> nop
++0000bc6c <[^>]*> nop
++0000bc70 <[^>]*> nop
++0000bc74 <[^>]*> nop
++0000bc78 <[^>]*> nop
++0000bc7c <[^>]*> nop
++0000bc80 <[^>]*> nop
++0000bc84 <[^>]*> nop
++0000bc88 <[^>]*> nop
++0000bc8c <[^>]*> nop
++0000bc90 <[^>]*> nop
++0000bc94 <[^>]*> nop
++0000bc98 <[^>]*> nop
++0000bc9c <[^>]*> nop
++0000bca0 <[^>]*> nop
++0000bca4 <[^>]*> nop
++0000bca8 <[^>]*> nop
++0000bcac <[^>]*> nop
++0000bcb0 <[^>]*> nop
++0000bcb4 <[^>]*> nop
++0000bcb8 <[^>]*> nop
++0000bcbc <[^>]*> nop
++0000bcc0 <[^>]*> nop
++0000bcc4 <[^>]*> nop
++0000bcc8 <[^>]*> nop
++0000bccc <[^>]*> nop
++0000bcd0 <[^>]*> nop
++0000bcd4 <[^>]*> nop
++0000bcd8 <[^>]*> nop
++0000bcdc <[^>]*> nop
++0000bce0 <[^>]*> nop
++0000bce4 <[^>]*> nop
++0000bce8 <[^>]*> nop
++0000bcec <[^>]*> nop
++0000bcf0 <[^>]*> nop
++0000bcf4 <[^>]*> nop
++0000bcf8 <[^>]*> nop
++0000bcfc <[^>]*> nop
++0000bd00 <[^>]*> nop
++0000bd04 <[^>]*> nop
++0000bd08 <[^>]*> nop
++0000bd0c <[^>]*> nop
++0000bd10 <[^>]*> nop
++0000bd14 <[^>]*> nop
++0000bd18 <[^>]*> nop
++0000bd1c <[^>]*> nop
++0000bd20 <[^>]*> nop
++0000bd24 <[^>]*> nop
++0000bd28 <[^>]*> nop
++0000bd2c <[^>]*> nop
++0000bd30 <[^>]*> nop
++0000bd34 <[^>]*> nop
++0000bd38 <[^>]*> nop
++0000bd3c <[^>]*> nop
++0000bd40 <[^>]*> nop
++0000bd44 <[^>]*> nop
++0000bd48 <[^>]*> nop
++0000bd4c <[^>]*> nop
++0000bd50 <[^>]*> nop
++0000bd54 <[^>]*> nop
++0000bd58 <[^>]*> nop
++0000bd5c <[^>]*> nop
++0000bd60 <[^>]*> nop
++0000bd64 <[^>]*> nop
++0000bd68 <[^>]*> nop
++0000bd6c <[^>]*> nop
++0000bd70 <[^>]*> nop
++0000bd74 <[^>]*> nop
++0000bd78 <[^>]*> nop
++0000bd7c <[^>]*> nop
++0000bd80 <[^>]*> nop
++0000bd84 <[^>]*> nop
++0000bd88 <[^>]*> nop
++0000bd8c <[^>]*> nop
++0000bd90 <[^>]*> nop
++0000bd94 <[^>]*> nop
++0000bd98 <[^>]*> nop
++0000bd9c <[^>]*> nop
++0000bda0 <[^>]*> nop
++0000bda4 <[^>]*> nop
++0000bda8 <[^>]*> nop
++0000bdac <[^>]*> nop
++0000bdb0 <[^>]*> nop
++0000bdb4 <[^>]*> nop
++0000bdb8 <[^>]*> nop
++0000bdbc <[^>]*> nop
++0000bdc0 <[^>]*> nop
++0000bdc4 <[^>]*> nop
++0000bdc8 <[^>]*> nop
++0000bdcc <[^>]*> nop
++0000bdd0 <[^>]*> nop
++0000bdd4 <[^>]*> nop
++0000bdd8 <[^>]*> nop
++0000bddc <[^>]*> nop
++0000bde0 <[^>]*> nop
++0000bde4 <[^>]*> nop
++0000bde8 <[^>]*> nop
++0000bdec <[^>]*> nop
++0000bdf0 <[^>]*> nop
++0000bdf4 <[^>]*> nop
++0000bdf8 <[^>]*> nop
++0000bdfc <[^>]*> nop
++0000be00 <[^>]*> nop
++0000be04 <[^>]*> nop
++0000be08 <[^>]*> nop
++0000be0c <[^>]*> nop
++0000be10 <[^>]*> nop
++0000be14 <[^>]*> nop
++0000be18 <[^>]*> nop
++0000be1c <[^>]*> nop
++0000be20 <[^>]*> nop
++0000be24 <[^>]*> nop
++0000be28 <[^>]*> nop
++0000be2c <[^>]*> nop
++0000be30 <[^>]*> nop
++0000be34 <[^>]*> nop
++0000be38 <[^>]*> nop
++0000be3c <[^>]*> nop
++0000be40 <[^>]*> nop
++0000be44 <[^>]*> nop
++0000be48 <[^>]*> nop
++0000be4c <[^>]*> nop
++0000be50 <[^>]*> nop
++0000be54 <[^>]*> nop
++0000be58 <[^>]*> nop
++0000be5c <[^>]*> nop
++0000be60 <[^>]*> nop
++0000be64 <[^>]*> nop
++0000be68 <[^>]*> nop
++0000be6c <[^>]*> nop
++0000be70 <[^>]*> nop
++0000be74 <[^>]*> nop
++0000be78 <[^>]*> nop
++0000be7c <[^>]*> nop
++0000be80 <[^>]*> nop
++0000be84 <[^>]*> nop
++0000be88 <[^>]*> nop
++0000be8c <[^>]*> nop
++0000be90 <[^>]*> nop
++0000be94 <[^>]*> nop
++0000be98 <[^>]*> nop
++0000be9c <[^>]*> nop
++0000bea0 <[^>]*> nop
++0000bea4 <[^>]*> nop
++0000bea8 <[^>]*> nop
++0000beac <[^>]*> nop
++0000beb0 <[^>]*> nop
++0000beb4 <[^>]*> nop
++0000beb8 <[^>]*> nop
++0000bebc <[^>]*> nop
++0000bec0 <[^>]*> nop
++0000bec4 <[^>]*> nop
++0000bec8 <[^>]*> nop
++0000becc <[^>]*> nop
++0000bed0 <[^>]*> nop
++0000bed4 <[^>]*> nop
++0000bed8 <[^>]*> nop
++0000bedc <[^>]*> nop
++0000bee0 <[^>]*> nop
++0000bee4 <[^>]*> nop
++0000bee8 <[^>]*> nop
++0000beec <[^>]*> nop
++0000bef0 <[^>]*> nop
++0000bef4 <[^>]*> nop
++0000bef8 <[^>]*> nop
++0000befc <[^>]*> nop
++0000bf00 <[^>]*> nop
++0000bf04 <[^>]*> nop
++0000bf08 <[^>]*> nop
++0000bf0c <[^>]*> nop
++0000bf10 <[^>]*> nop
++0000bf14 <[^>]*> nop
++0000bf18 <[^>]*> nop
++0000bf1c <[^>]*> nop
++0000bf20 <[^>]*> nop
++0000bf24 <[^>]*> nop
++0000bf28 <[^>]*> nop
++0000bf2c <[^>]*> nop
++0000bf30 <[^>]*> nop
++0000bf34 <[^>]*> nop
++0000bf38 <[^>]*> nop
++0000bf3c <[^>]*> nop
++0000bf40 <[^>]*> nop
++0000bf44 <[^>]*> nop
++0000bf48 <[^>]*> nop
++0000bf4c <[^>]*> nop
++0000bf50 <[^>]*> nop
++0000bf54 <[^>]*> nop
++0000bf58 <[^>]*> nop
++0000bf5c <[^>]*> nop
++0000bf60 <[^>]*> nop
++0000bf64 <[^>]*> nop
++0000bf68 <[^>]*> nop
++0000bf6c <[^>]*> nop
++0000bf70 <[^>]*> nop
++0000bf74 <[^>]*> nop
++0000bf78 <[^>]*> nop
++0000bf7c <[^>]*> nop
++0000bf80 <[^>]*> nop
++0000bf84 <[^>]*> nop
++0000bf88 <[^>]*> nop
++0000bf8c <[^>]*> nop
++0000bf90 <[^>]*> nop
++0000bf94 <[^>]*> nop
++0000bf98 <[^>]*> nop
++0000bf9c <[^>]*> nop
++0000bfa0 <[^>]*> nop
++0000bfa4 <[^>]*> nop
++0000bfa8 <[^>]*> nop
++0000bfac <[^>]*> nop
++0000bfb0 <[^>]*> nop
++0000bfb4 <[^>]*> nop
++0000bfb8 <[^>]*> nop
++0000bfbc <[^>]*> nop
++0000bfc0 <[^>]*> nop
++0000bfc4 <[^>]*> nop
++0000bfc8 <[^>]*> nop
++0000bfcc <[^>]*> nop
++0000bfd0 <[^>]*> nop
++0000bfd4 <[^>]*> nop
++0000bfd8 <[^>]*> nop
++0000bfdc <[^>]*> nop
++0000bfe0 <[^>]*> nop
++0000bfe4 <[^>]*> nop
++0000bfe8 <[^>]*> nop
++0000bfec <[^>]*> nop
++0000bff0 <[^>]*> nop
++0000bff4 <[^>]*> nop
++0000bff8 <[^>]*> nop
++0000bffc <[^>]*> nop
++0000c000 <[^>]*> nop
++0000c004 <[^>]*> nop
++0000c008 <[^>]*> nop
++0000c00c <[^>]*> nop
++0000c010 <[^>]*> nop
++0000c014 <[^>]*> nop
++0000c018 <[^>]*> nop
++0000c01c <[^>]*> nop
++0000c020 <[^>]*> nop
++0000c024 <[^>]*> nop
++0000c028 <[^>]*> nop
++0000c02c <[^>]*> nop
++0000c030 <[^>]*> nop
++0000c034 <[^>]*> nop
++0000c038 <[^>]*> nop
++0000c03c <[^>]*> nop
++0000c040 <[^>]*> nop
++0000c044 <[^>]*> nop
++0000c048 <[^>]*> nop
++0000c04c <[^>]*> nop
++0000c050 <[^>]*> nop
++0000c054 <[^>]*> nop
++0000c058 <[^>]*> nop
++0000c05c <[^>]*> nop
++0000c060 <[^>]*> nop
++0000c064 <[^>]*> nop
++0000c068 <[^>]*> nop
++0000c06c <[^>]*> nop
++0000c070 <[^>]*> nop
++0000c074 <[^>]*> nop
++0000c078 <[^>]*> nop
++0000c07c <[^>]*> nop
++0000c080 <[^>]*> nop
++0000c084 <[^>]*> nop
++0000c088 <[^>]*> nop
++0000c08c <[^>]*> nop
++0000c090 <[^>]*> nop
++0000c094 <[^>]*> nop
++0000c098 <[^>]*> nop
++0000c09c <[^>]*> nop
++0000c0a0 <[^>]*> nop
++0000c0a4 <[^>]*> nop
++0000c0a8 <[^>]*> nop
++0000c0ac <[^>]*> nop
++0000c0b0 <[^>]*> nop
++0000c0b4 <[^>]*> nop
++0000c0b8 <[^>]*> nop
++0000c0bc <[^>]*> nop
++0000c0c0 <[^>]*> nop
++0000c0c4 <[^>]*> nop
++0000c0c8 <[^>]*> nop
++0000c0cc <[^>]*> nop
++0000c0d0 <[^>]*> nop
++0000c0d4 <[^>]*> nop
++0000c0d8 <[^>]*> nop
++0000c0dc <[^>]*> nop
++0000c0e0 <[^>]*> nop
++0000c0e4 <[^>]*> nop
++0000c0e8 <[^>]*> nop
++0000c0ec <[^>]*> nop
++0000c0f0 <[^>]*> nop
++0000c0f4 <[^>]*> nop
++0000c0f8 <[^>]*> nop
++0000c0fc <[^>]*> nop
++0000c100 <[^>]*> nop
++0000c104 <[^>]*> nop
++0000c108 <[^>]*> nop
++0000c10c <[^>]*> nop
++0000c110 <[^>]*> nop
++0000c114 <[^>]*> nop
++0000c118 <[^>]*> nop
++0000c11c <[^>]*> nop
++0000c120 <[^>]*> nop
++0000c124 <[^>]*> nop
++0000c128 <[^>]*> nop
++0000c12c <[^>]*> nop
++0000c130 <[^>]*> nop
++0000c134 <[^>]*> nop
++0000c138 <[^>]*> nop
++0000c13c <[^>]*> nop
++0000c140 <[^>]*> nop
++0000c144 <[^>]*> nop
++0000c148 <[^>]*> nop
++0000c14c <[^>]*> nop
++0000c150 <[^>]*> nop
++0000c154 <[^>]*> nop
++0000c158 <[^>]*> nop
++0000c15c <[^>]*> nop
++0000c160 <[^>]*> nop
++0000c164 <[^>]*> nop
++0000c168 <[^>]*> nop
++0000c16c <[^>]*> nop
++0000c170 <[^>]*> nop
++0000c174 <[^>]*> nop
++0000c178 <[^>]*> nop
++0000c17c <[^>]*> nop
++0000c180 <[^>]*> nop
++0000c184 <[^>]*> nop
++0000c188 <[^>]*> nop
++0000c18c <[^>]*> nop
++0000c190 <[^>]*> nop
++0000c194 <[^>]*> nop
++0000c198 <[^>]*> nop
++0000c19c <[^>]*> nop
++0000c1a0 <[^>]*> nop
++0000c1a4 <[^>]*> nop
++0000c1a8 <[^>]*> nop
++0000c1ac <[^>]*> nop
++0000c1b0 <[^>]*> nop
++0000c1b4 <[^>]*> nop
++0000c1b8 <[^>]*> nop
++0000c1bc <[^>]*> nop
++0000c1c0 <[^>]*> nop
++0000c1c4 <[^>]*> nop
++0000c1c8 <[^>]*> nop
++0000c1cc <[^>]*> nop
++0000c1d0 <[^>]*> nop
++0000c1d4 <[^>]*> nop
++0000c1d8 <[^>]*> nop
++0000c1dc <[^>]*> nop
++0000c1e0 <[^>]*> nop
++0000c1e4 <[^>]*> nop
++0000c1e8 <[^>]*> nop
++0000c1ec <[^>]*> nop
++0000c1f0 <[^>]*> nop
++0000c1f4 <[^>]*> nop
++0000c1f8 <[^>]*> nop
++0000c1fc <[^>]*> nop
++0000c200 <[^>]*> nop
++0000c204 <[^>]*> nop
++0000c208 <[^>]*> nop
++0000c20c <[^>]*> nop
++0000c210 <[^>]*> nop
++0000c214 <[^>]*> nop
++0000c218 <[^>]*> nop
++0000c21c <[^>]*> nop
++0000c220 <[^>]*> nop
++0000c224 <[^>]*> nop
++0000c228 <[^>]*> nop
++0000c22c <[^>]*> nop
++0000c230 <[^>]*> nop
++0000c234 <[^>]*> nop
++0000c238 <[^>]*> nop
++0000c23c <[^>]*> nop
++0000c240 <[^>]*> nop
++0000c244 <[^>]*> nop
++0000c248 <[^>]*> nop
++0000c24c <[^>]*> nop
++0000c250 <[^>]*> nop
++0000c254 <[^>]*> nop
++0000c258 <[^>]*> nop
++0000c25c <[^>]*> nop
++0000c260 <[^>]*> nop
++0000c264 <[^>]*> nop
++0000c268 <[^>]*> nop
++0000c26c <[^>]*> nop
++0000c270 <[^>]*> nop
++0000c274 <[^>]*> nop
++0000c278 <[^>]*> nop
++0000c27c <[^>]*> nop
++0000c280 <[^>]*> nop
++0000c284 <[^>]*> nop
++0000c288 <[^>]*> nop
++0000c28c <[^>]*> nop
++0000c290 <[^>]*> nop
++0000c294 <[^>]*> nop
++0000c298 <[^>]*> nop
++0000c29c <[^>]*> nop
++0000c2a0 <[^>]*> nop
++0000c2a4 <[^>]*> nop
++0000c2a8 <[^>]*> nop
++0000c2ac <[^>]*> nop
++0000c2b0 <[^>]*> nop
++0000c2b4 <[^>]*> nop
++0000c2b8 <[^>]*> nop
++0000c2bc <[^>]*> nop
++0000c2c0 <[^>]*> nop
++0000c2c4 <[^>]*> nop
++0000c2c8 <[^>]*> nop
++0000c2cc <[^>]*> nop
++0000c2d0 <[^>]*> nop
++0000c2d4 <[^>]*> nop
++0000c2d8 <[^>]*> nop
++0000c2dc <[^>]*> nop
++0000c2e0 <[^>]*> nop
++0000c2e4 <[^>]*> nop
++0000c2e8 <[^>]*> nop
++0000c2ec <[^>]*> nop
++0000c2f0 <[^>]*> nop
++0000c2f4 <[^>]*> nop
++0000c2f8 <[^>]*> nop
++0000c2fc <[^>]*> nop
++0000c300 <[^>]*> nop
++0000c304 <[^>]*> nop
++0000c308 <[^>]*> nop
++0000c30c <[^>]*> nop
++0000c310 <[^>]*> nop
++0000c314 <[^>]*> nop
++0000c318 <[^>]*> nop
++0000c31c <[^>]*> nop
++0000c320 <[^>]*> nop
++0000c324 <[^>]*> nop
++0000c328 <[^>]*> nop
++0000c32c <[^>]*> nop
++0000c330 <[^>]*> nop
++0000c334 <[^>]*> nop
++0000c338 <[^>]*> nop
++0000c33c <[^>]*> nop
++0000c340 <[^>]*> nop
++0000c344 <[^>]*> nop
++0000c348 <[^>]*> nop
++0000c34c <[^>]*> nop
++0000c350 <[^>]*> nop
++0000c354 <[^>]*> nop
++0000c358 <[^>]*> nop
++0000c35c <[^>]*> nop
++0000c360 <[^>]*> nop
++0000c364 <[^>]*> nop
++0000c368 <[^>]*> nop
++0000c36c <[^>]*> nop
++0000c370 <[^>]*> nop
++0000c374 <[^>]*> nop
++0000c378 <[^>]*> nop
++0000c37c <[^>]*> nop
++0000c380 <[^>]*> nop
++0000c384 <[^>]*> nop
++0000c388 <[^>]*> nop
++0000c38c <[^>]*> nop
++0000c390 <[^>]*> nop
++0000c394 <[^>]*> nop
++0000c398 <[^>]*> nop
++0000c39c <[^>]*> nop
++0000c3a0 <[^>]*> nop
++0000c3a4 <[^>]*> nop
++0000c3a8 <[^>]*> nop
++0000c3ac <[^>]*> nop
++0000c3b0 <[^>]*> nop
++0000c3b4 <[^>]*> nop
++0000c3b8 <[^>]*> nop
++0000c3bc <[^>]*> nop
++0000c3c0 <[^>]*> nop
++0000c3c4 <[^>]*> nop
++0000c3c8 <[^>]*> nop
++0000c3cc <[^>]*> nop
++0000c3d0 <[^>]*> nop
++0000c3d4 <[^>]*> nop
++0000c3d8 <[^>]*> nop
++0000c3dc <[^>]*> nop
++0000c3e0 <[^>]*> nop
++0000c3e4 <[^>]*> nop
++0000c3e8 <[^>]*> nop
++0000c3ec <[^>]*> nop
++0000c3f0 <[^>]*> nop
++0000c3f4 <[^>]*> nop
++0000c3f8 <[^>]*> nop
++0000c3fc <[^>]*> nop
++0000c400 <[^>]*> nop
++0000c404 <[^>]*> nop
++0000c408 <[^>]*> nop
++0000c40c <[^>]*> nop
++0000c410 <[^>]*> nop
++0000c414 <[^>]*> nop
++0000c418 <[^>]*> nop
++0000c41c <[^>]*> nop
++0000c420 <[^>]*> nop
++0000c424 <[^>]*> nop
++0000c428 <[^>]*> nop
++0000c42c <[^>]*> nop
++0000c430 <[^>]*> nop
++0000c434 <[^>]*> nop
++0000c438 <[^>]*> nop
++0000c43c <[^>]*> nop
++0000c440 <[^>]*> nop
++0000c444 <[^>]*> nop
++0000c448 <[^>]*> nop
++0000c44c <[^>]*> nop
++0000c450 <[^>]*> nop
++0000c454 <[^>]*> nop
++0000c458 <[^>]*> nop
++0000c45c <[^>]*> nop
++0000c460 <[^>]*> nop
++0000c464 <[^>]*> nop
++0000c468 <[^>]*> nop
++0000c46c <[^>]*> nop
++0000c470 <[^>]*> nop
++0000c474 <[^>]*> nop
++0000c478 <[^>]*> nop
++0000c47c <[^>]*> nop
++0000c480 <[^>]*> nop
++0000c484 <[^>]*> nop
++0000c488 <[^>]*> nop
++0000c48c <[^>]*> nop
++0000c490 <[^>]*> nop
++0000c494 <[^>]*> nop
++0000c498 <[^>]*> nop
++0000c49c <[^>]*> nop
++0000c4a0 <[^>]*> nop
++0000c4a4 <[^>]*> nop
++0000c4a8 <[^>]*> nop
++0000c4ac <[^>]*> nop
++0000c4b0 <[^>]*> nop
++0000c4b4 <[^>]*> nop
++0000c4b8 <[^>]*> nop
++0000c4bc <[^>]*> nop
++0000c4c0 <[^>]*> nop
++0000c4c4 <[^>]*> nop
++0000c4c8 <[^>]*> nop
++0000c4cc <[^>]*> nop
++0000c4d0 <[^>]*> nop
++0000c4d4 <[^>]*> nop
++0000c4d8 <[^>]*> nop
++0000c4dc <[^>]*> nop
++0000c4e0 <[^>]*> nop
++0000c4e4 <[^>]*> nop
++0000c4e8 <[^>]*> nop
++0000c4ec <[^>]*> nop
++0000c4f0 <[^>]*> nop
++0000c4f4 <[^>]*> nop
++0000c4f8 <[^>]*> nop
++0000c4fc <[^>]*> nop
++0000c500 <[^>]*> nop
++0000c504 <[^>]*> nop
++0000c508 <[^>]*> nop
++0000c50c <[^>]*> nop
++0000c510 <[^>]*> nop
++0000c514 <[^>]*> nop
++0000c518 <[^>]*> nop
++0000c51c <[^>]*> nop
++0000c520 <[^>]*> nop
++0000c524 <[^>]*> nop
++0000c528 <[^>]*> nop
++0000c52c <[^>]*> nop
++0000c530 <[^>]*> nop
++0000c534 <[^>]*> nop
++0000c538 <[^>]*> nop
++0000c53c <[^>]*> nop
++0000c540 <[^>]*> nop
++0000c544 <[^>]*> nop
++0000c548 <[^>]*> nop
++0000c54c <[^>]*> nop
++0000c550 <[^>]*> nop
++0000c554 <[^>]*> nop
++0000c558 <[^>]*> nop
++0000c55c <[^>]*> nop
++0000c560 <[^>]*> nop
++0000c564 <[^>]*> nop
++0000c568 <[^>]*> nop
++0000c56c <[^>]*> nop
++0000c570 <[^>]*> nop
++0000c574 <[^>]*> nop
++0000c578 <[^>]*> nop
++0000c57c <[^>]*> nop
++0000c580 <[^>]*> nop
++0000c584 <[^>]*> nop
++0000c588 <[^>]*> nop
++0000c58c <[^>]*> nop
++0000c590 <[^>]*> nop
++0000c594 <[^>]*> nop
++0000c598 <[^>]*> nop
++0000c59c <[^>]*> nop
++0000c5a0 <[^>]*> nop
++0000c5a4 <[^>]*> nop
++0000c5a8 <[^>]*> nop
++0000c5ac <[^>]*> nop
++0000c5b0 <[^>]*> nop
++0000c5b4 <[^>]*> nop
++0000c5b8 <[^>]*> nop
++0000c5bc <[^>]*> nop
++0000c5c0 <[^>]*> nop
++0000c5c4 <[^>]*> nop
++0000c5c8 <[^>]*> nop
++0000c5cc <[^>]*> nop
++0000c5d0 <[^>]*> nop
++0000c5d4 <[^>]*> nop
++0000c5d8 <[^>]*> nop
++0000c5dc <[^>]*> nop
++0000c5e0 <[^>]*> nop
++0000c5e4 <[^>]*> nop
++0000c5e8 <[^>]*> nop
++0000c5ec <[^>]*> nop
++0000c5f0 <[^>]*> nop
++0000c5f4 <[^>]*> nop
++0000c5f8 <[^>]*> nop
++0000c5fc <[^>]*> nop
++0000c600 <[^>]*> nop
++0000c604 <[^>]*> nop
++0000c608 <[^>]*> nop
++0000c60c <[^>]*> nop
++0000c610 <[^>]*> nop
++0000c614 <[^>]*> nop
++0000c618 <[^>]*> nop
++0000c61c <[^>]*> nop
++0000c620 <[^>]*> nop
++0000c624 <[^>]*> nop
++0000c628 <[^>]*> nop
++0000c62c <[^>]*> nop
++0000c630 <[^>]*> nop
++0000c634 <[^>]*> nop
++0000c638 <[^>]*> nop
++0000c63c <[^>]*> nop
++0000c640 <[^>]*> nop
++0000c644 <[^>]*> nop
++0000c648 <[^>]*> nop
++0000c64c <[^>]*> nop
++0000c650 <[^>]*> nop
++0000c654 <[^>]*> nop
++0000c658 <[^>]*> nop
++0000c65c <[^>]*> nop
++0000c660 <[^>]*> nop
++0000c664 <[^>]*> nop
++0000c668 <[^>]*> nop
++0000c66c <[^>]*> nop
++0000c670 <[^>]*> nop
++0000c674 <[^>]*> nop
++0000c678 <[^>]*> nop
++0000c67c <[^>]*> nop
++0000c680 <[^>]*> nop
++0000c684 <[^>]*> nop
++0000c688 <[^>]*> nop
++0000c68c <[^>]*> nop
++0000c690 <[^>]*> nop
++0000c694 <[^>]*> nop
++0000c698 <[^>]*> nop
++0000c69c <[^>]*> nop
++0000c6a0 <[^>]*> nop
++0000c6a4 <[^>]*> nop
++0000c6a8 <[^>]*> nop
++0000c6ac <[^>]*> nop
++0000c6b0 <[^>]*> nop
++0000c6b4 <[^>]*> nop
++0000c6b8 <[^>]*> nop
++0000c6bc <[^>]*> nop
++0000c6c0 <[^>]*> nop
++0000c6c4 <[^>]*> nop
++0000c6c8 <[^>]*> nop
++0000c6cc <[^>]*> nop
++0000c6d0 <[^>]*> nop
++0000c6d4 <[^>]*> nop
++0000c6d8 <[^>]*> nop
++0000c6dc <[^>]*> nop
++0000c6e0 <[^>]*> nop
++0000c6e4 <[^>]*> nop
++0000c6e8 <[^>]*> nop
++0000c6ec <[^>]*> nop
++0000c6f0 <[^>]*> nop
++0000c6f4 <[^>]*> nop
++0000c6f8 <[^>]*> nop
++0000c6fc <[^>]*> nop
++0000c700 <[^>]*> nop
++0000c704 <[^>]*> nop
++0000c708 <[^>]*> nop
++0000c70c <[^>]*> nop
++0000c710 <[^>]*> nop
++0000c714 <[^>]*> nop
++0000c718 <[^>]*> nop
++0000c71c <[^>]*> nop
++0000c720 <[^>]*> nop
++0000c724 <[^>]*> nop
++0000c728 <[^>]*> nop
++0000c72c <[^>]*> nop
++0000c730 <[^>]*> nop
++0000c734 <[^>]*> nop
++0000c738 <[^>]*> nop
++0000c73c <[^>]*> nop
++0000c740 <[^>]*> nop
++0000c744 <[^>]*> nop
++0000c748 <[^>]*> nop
++0000c74c <[^>]*> nop
++0000c750 <[^>]*> nop
++0000c754 <[^>]*> nop
++0000c758 <[^>]*> nop
++0000c75c <[^>]*> nop
++0000c760 <[^>]*> nop
++0000c764 <[^>]*> nop
++0000c768 <[^>]*> nop
++0000c76c <[^>]*> nop
++0000c770 <[^>]*> nop
++0000c774 <[^>]*> nop
++0000c778 <[^>]*> nop
++0000c77c <[^>]*> nop
++0000c780 <[^>]*> nop
++0000c784 <[^>]*> nop
++0000c788 <[^>]*> nop
++0000c78c <[^>]*> nop
++0000c790 <[^>]*> nop
++0000c794 <[^>]*> nop
++0000c798 <[^>]*> nop
++0000c79c <[^>]*> nop
++0000c7a0 <[^>]*> nop
++0000c7a4 <[^>]*> nop
++0000c7a8 <[^>]*> nop
++0000c7ac <[^>]*> nop
++0000c7b0 <[^>]*> nop
++0000c7b4 <[^>]*> nop
++0000c7b8 <[^>]*> nop
++0000c7bc <[^>]*> nop
++0000c7c0 <[^>]*> nop
++0000c7c4 <[^>]*> nop
++0000c7c8 <[^>]*> nop
++0000c7cc <[^>]*> nop
++0000c7d0 <[^>]*> nop
++0000c7d4 <[^>]*> nop
++0000c7d8 <[^>]*> nop
++0000c7dc <[^>]*> nop
++0000c7e0 <[^>]*> nop
++0000c7e4 <[^>]*> nop
++0000c7e8 <[^>]*> nop
++0000c7ec <[^>]*> nop
++0000c7f0 <[^>]*> nop
++0000c7f4 <[^>]*> nop
++0000c7f8 <[^>]*> nop
++0000c7fc <[^>]*> nop
++0000c800 <[^>]*> nop
++0000c804 <[^>]*> nop
++0000c808 <[^>]*> nop
++0000c80c <[^>]*> nop
++0000c810 <[^>]*> nop
++0000c814 <[^>]*> nop
++0000c818 <[^>]*> nop
++0000c81c <[^>]*> nop
++0000c820 <[^>]*> nop
++0000c824 <[^>]*> nop
++0000c828 <[^>]*> nop
++0000c82c <[^>]*> nop
++0000c830 <[^>]*> nop
++0000c834 <[^>]*> nop
++0000c838 <[^>]*> nop
++0000c83c <[^>]*> nop
++0000c840 <[^>]*> nop
++0000c844 <[^>]*> nop
++0000c848 <[^>]*> nop
++0000c84c <[^>]*> nop
++0000c850 <[^>]*> nop
++0000c854 <[^>]*> nop
++0000c858 <[^>]*> nop
++0000c85c <[^>]*> nop
++0000c860 <[^>]*> nop
++0000c864 <[^>]*> nop
++0000c868 <[^>]*> nop
++0000c86c <[^>]*> nop
++0000c870 <[^>]*> nop
++0000c874 <[^>]*> nop
++0000c878 <[^>]*> nop
++0000c87c <[^>]*> nop
++0000c880 <[^>]*> nop
++0000c884 <[^>]*> nop
++0000c888 <[^>]*> nop
++0000c88c <[^>]*> nop
++0000c890 <[^>]*> nop
++0000c894 <[^>]*> nop
++0000c898 <[^>]*> nop
++0000c89c <[^>]*> nop
++0000c8a0 <[^>]*> nop
++0000c8a4 <[^>]*> nop
++0000c8a8 <[^>]*> nop
++0000c8ac <[^>]*> nop
++0000c8b0 <[^>]*> nop
++0000c8b4 <[^>]*> nop
++0000c8b8 <[^>]*> nop
++0000c8bc <[^>]*> nop
++0000c8c0 <[^>]*> nop
++0000c8c4 <[^>]*> nop
++0000c8c8 <[^>]*> nop
++0000c8cc <[^>]*> nop
++0000c8d0 <[^>]*> nop
++0000c8d4 <[^>]*> nop
++0000c8d8 <[^>]*> nop
++0000c8dc <[^>]*> nop
++0000c8e0 <[^>]*> nop
++0000c8e4 <[^>]*> nop
++0000c8e8 <[^>]*> nop
++0000c8ec <[^>]*> nop
++0000c8f0 <[^>]*> nop
++0000c8f4 <[^>]*> nop
++0000c8f8 <[^>]*> nop
++0000c8fc <[^>]*> nop
++0000c900 <[^>]*> nop
++0000c904 <[^>]*> nop
++0000c908 <[^>]*> nop
++0000c90c <[^>]*> nop
++0000c910 <[^>]*> nop
++0000c914 <[^>]*> nop
++0000c918 <[^>]*> nop
++0000c91c <[^>]*> nop
++0000c920 <[^>]*> nop
++0000c924 <[^>]*> nop
++0000c928 <[^>]*> nop
++0000c92c <[^>]*> nop
++0000c930 <[^>]*> nop
++0000c934 <[^>]*> nop
++0000c938 <[^>]*> nop
++0000c93c <[^>]*> nop
++0000c940 <[^>]*> nop
++0000c944 <[^>]*> nop
++0000c948 <[^>]*> nop
++0000c94c <[^>]*> nop
++0000c950 <[^>]*> nop
++0000c954 <[^>]*> nop
++0000c958 <[^>]*> nop
++0000c95c <[^>]*> nop
++0000c960 <[^>]*> nop
++0000c964 <[^>]*> nop
++0000c968 <[^>]*> nop
++0000c96c <[^>]*> nop
++0000c970 <[^>]*> nop
++0000c974 <[^>]*> nop
++0000c978 <[^>]*> nop
++0000c97c <[^>]*> nop
++0000c980 <[^>]*> nop
++0000c984 <[^>]*> nop
++0000c988 <[^>]*> nop
++0000c98c <[^>]*> nop
++0000c990 <[^>]*> nop
++0000c994 <[^>]*> nop
++0000c998 <[^>]*> nop
++0000c99c <[^>]*> nop
++0000c9a0 <[^>]*> nop
++0000c9a4 <[^>]*> nop
++0000c9a8 <[^>]*> nop
++0000c9ac <[^>]*> nop
++0000c9b0 <[^>]*> nop
++0000c9b4 <[^>]*> nop
++0000c9b8 <[^>]*> nop
++0000c9bc <[^>]*> nop
++0000c9c0 <[^>]*> nop
++0000c9c4 <[^>]*> nop
++0000c9c8 <[^>]*> nop
++0000c9cc <[^>]*> nop
++0000c9d0 <[^>]*> nop
++0000c9d4 <[^>]*> nop
++0000c9d8 <[^>]*> nop
++0000c9dc <[^>]*> nop
++0000c9e0 <[^>]*> nop
++0000c9e4 <[^>]*> nop
++0000c9e8 <[^>]*> nop
++0000c9ec <[^>]*> nop
++0000c9f0 <[^>]*> nop
++0000c9f4 <[^>]*> nop
++0000c9f8 <[^>]*> nop
++0000c9fc <[^>]*> nop
++0000ca00 <[^>]*> nop
++0000ca04 <[^>]*> nop
++0000ca08 <[^>]*> nop
++0000ca0c <[^>]*> nop
++0000ca10 <[^>]*> nop
++0000ca14 <[^>]*> nop
++0000ca18 <[^>]*> nop
++0000ca1c <[^>]*> nop
++0000ca20 <[^>]*> nop
++0000ca24 <[^>]*> nop
++0000ca28 <[^>]*> nop
++0000ca2c <[^>]*> nop
++0000ca30 <[^>]*> nop
++0000ca34 <[^>]*> nop
++0000ca38 <[^>]*> nop
++0000ca3c <[^>]*> nop
++0000ca40 <[^>]*> nop
++0000ca44 <[^>]*> nop
++0000ca48 <[^>]*> nop
++0000ca4c <[^>]*> nop
++0000ca50 <[^>]*> nop
++0000ca54 <[^>]*> nop
++0000ca58 <[^>]*> nop
++0000ca5c <[^>]*> nop
++0000ca60 <[^>]*> nop
++0000ca64 <[^>]*> nop
++0000ca68 <[^>]*> nop
++0000ca6c <[^>]*> nop
++0000ca70 <[^>]*> nop
++0000ca74 <[^>]*> nop
++0000ca78 <[^>]*> nop
++0000ca7c <[^>]*> nop
++0000ca80 <[^>]*> nop
++0000ca84 <[^>]*> nop
++0000ca88 <[^>]*> nop
++0000ca8c <[^>]*> nop
++0000ca90 <[^>]*> nop
++0000ca94 <[^>]*> nop
++0000ca98 <[^>]*> nop
++0000ca9c <[^>]*> nop
++0000caa0 <[^>]*> nop
++0000caa4 <[^>]*> nop
++0000caa8 <[^>]*> nop
++0000caac <[^>]*> nop
++0000cab0 <[^>]*> nop
++0000cab4 <[^>]*> nop
++0000cab8 <[^>]*> nop
++0000cabc <[^>]*> nop
++0000cac0 <[^>]*> nop
++0000cac4 <[^>]*> nop
++0000cac8 <[^>]*> nop
++0000cacc <[^>]*> nop
++0000cad0 <[^>]*> nop
++0000cad4 <[^>]*> nop
++0000cad8 <[^>]*> nop
++0000cadc <[^>]*> nop
++0000cae0 <[^>]*> nop
++0000cae4 <[^>]*> nop
++0000cae8 <[^>]*> nop
++0000caec <[^>]*> nop
++0000caf0 <[^>]*> nop
++0000caf4 <[^>]*> nop
++0000caf8 <[^>]*> nop
++0000cafc <[^>]*> nop
++0000cb00 <[^>]*> nop
++0000cb04 <[^>]*> nop
++0000cb08 <[^>]*> nop
++0000cb0c <[^>]*> nop
++0000cb10 <[^>]*> nop
++0000cb14 <[^>]*> nop
++0000cb18 <[^>]*> nop
++0000cb1c <[^>]*> nop
++0000cb20 <[^>]*> nop
++0000cb24 <[^>]*> nop
++0000cb28 <[^>]*> nop
++0000cb2c <[^>]*> nop
++0000cb30 <[^>]*> nop
++0000cb34 <[^>]*> nop
++0000cb38 <[^>]*> nop
++0000cb3c <[^>]*> nop
++0000cb40 <[^>]*> nop
++0000cb44 <[^>]*> nop
++0000cb48 <[^>]*> nop
++0000cb4c <[^>]*> nop
++0000cb50 <[^>]*> nop
++0000cb54 <[^>]*> nop
++0000cb58 <[^>]*> nop
++0000cb5c <[^>]*> nop
++0000cb60 <[^>]*> nop
++0000cb64 <[^>]*> nop
++0000cb68 <[^>]*> nop
++0000cb6c <[^>]*> nop
++0000cb70 <[^>]*> nop
++0000cb74 <[^>]*> nop
++0000cb78 <[^>]*> nop
++0000cb7c <[^>]*> nop
++0000cb80 <[^>]*> nop
++0000cb84 <[^>]*> nop
++0000cb88 <[^>]*> nop
++0000cb8c <[^>]*> nop
++0000cb90 <[^>]*> nop
++0000cb94 <[^>]*> nop
++0000cb98 <[^>]*> nop
++0000cb9c <[^>]*> nop
++0000cba0 <[^>]*> nop
++0000cba4 <[^>]*> nop
++0000cba8 <[^>]*> nop
++0000cbac <[^>]*> nop
++0000cbb0 <[^>]*> nop
++0000cbb4 <[^>]*> nop
++0000cbb8 <[^>]*> nop
++0000cbbc <[^>]*> nop
++0000cbc0 <[^>]*> nop
++0000cbc4 <[^>]*> nop
++0000cbc8 <[^>]*> nop
++0000cbcc <[^>]*> nop
++0000cbd0 <[^>]*> nop
++0000cbd4 <[^>]*> nop
++0000cbd8 <[^>]*> nop
++0000cbdc <[^>]*> nop
++0000cbe0 <[^>]*> nop
++0000cbe4 <[^>]*> nop
++0000cbe8 <[^>]*> nop
++0000cbec <[^>]*> nop
++0000cbf0 <[^>]*> nop
++0000cbf4 <[^>]*> nop
++0000cbf8 <[^>]*> nop
++0000cbfc <[^>]*> nop
++0000cc00 <[^>]*> nop
++0000cc04 <[^>]*> nop
++0000cc08 <[^>]*> nop
++0000cc0c <[^>]*> nop
++0000cc10 <[^>]*> nop
++0000cc14 <[^>]*> nop
++0000cc18 <[^>]*> nop
++0000cc1c <[^>]*> nop
++0000cc20 <[^>]*> nop
++0000cc24 <[^>]*> nop
++0000cc28 <[^>]*> nop
++0000cc2c <[^>]*> nop
++0000cc30 <[^>]*> nop
++0000cc34 <[^>]*> nop
++0000cc38 <[^>]*> nop
++0000cc3c <[^>]*> nop
++0000cc40 <[^>]*> nop
++0000cc44 <[^>]*> nop
++0000cc48 <[^>]*> nop
++0000cc4c <[^>]*> nop
++0000cc50 <[^>]*> nop
++0000cc54 <[^>]*> nop
++0000cc58 <[^>]*> nop
++0000cc5c <[^>]*> nop
++0000cc60 <[^>]*> nop
++0000cc64 <[^>]*> nop
++0000cc68 <[^>]*> nop
++0000cc6c <[^>]*> nop
++0000cc70 <[^>]*> nop
++0000cc74 <[^>]*> nop
++0000cc78 <[^>]*> nop
++0000cc7c <[^>]*> nop
++0000cc80 <[^>]*> nop
++0000cc84 <[^>]*> nop
++0000cc88 <[^>]*> nop
++0000cc8c <[^>]*> nop
++0000cc90 <[^>]*> nop
++0000cc94 <[^>]*> nop
++0000cc98 <[^>]*> nop
++0000cc9c <[^>]*> nop
++0000cca0 <[^>]*> nop
++0000cca4 <[^>]*> nop
++0000cca8 <[^>]*> nop
++0000ccac <[^>]*> nop
++0000ccb0 <[^>]*> nop
++0000ccb4 <[^>]*> nop
++0000ccb8 <[^>]*> nop
++0000ccbc <[^>]*> nop
++0000ccc0 <[^>]*> nop
++0000ccc4 <[^>]*> nop
++0000ccc8 <[^>]*> nop
++0000cccc <[^>]*> nop
++0000ccd0 <[^>]*> nop
++0000ccd4 <[^>]*> nop
++0000ccd8 <[^>]*> nop
++0000ccdc <[^>]*> nop
++0000cce0 <[^>]*> nop
++0000cce4 <[^>]*> nop
++0000cce8 <[^>]*> nop
++0000ccec <[^>]*> nop
++0000ccf0 <[^>]*> nop
++0000ccf4 <[^>]*> nop
++0000ccf8 <[^>]*> nop
++0000ccfc <[^>]*> nop
++0000cd00 <[^>]*> nop
++0000cd04 <[^>]*> nop
++0000cd08 <[^>]*> nop
++0000cd0c <[^>]*> nop
++0000cd10 <[^>]*> nop
++0000cd14 <[^>]*> nop
++0000cd18 <[^>]*> nop
++0000cd1c <[^>]*> nop
++0000cd20 <[^>]*> nop
++0000cd24 <[^>]*> nop
++0000cd28 <[^>]*> nop
++0000cd2c <[^>]*> nop
++0000cd30 <[^>]*> nop
++0000cd34 <[^>]*> nop
++0000cd38 <[^>]*> nop
++0000cd3c <[^>]*> nop
++0000cd40 <[^>]*> nop
++0000cd44 <[^>]*> nop
++0000cd48 <[^>]*> nop
++0000cd4c <[^>]*> nop
++0000cd50 <[^>]*> nop
++0000cd54 <[^>]*> nop
++0000cd58 <[^>]*> nop
++0000cd5c <[^>]*> nop
++0000cd60 <[^>]*> nop
++0000cd64 <[^>]*> nop
++0000cd68 <[^>]*> nop
++0000cd6c <[^>]*> nop
++0000cd70 <[^>]*> nop
++0000cd74 <[^>]*> nop
++0000cd78 <[^>]*> nop
++0000cd7c <[^>]*> nop
++0000cd80 <[^>]*> nop
++0000cd84 <[^>]*> nop
++0000cd88 <[^>]*> nop
++0000cd8c <[^>]*> nop
++0000cd90 <[^>]*> nop
++0000cd94 <[^>]*> nop
++0000cd98 <[^>]*> nop
++0000cd9c <[^>]*> nop
++0000cda0 <[^>]*> nop
++0000cda4 <[^>]*> nop
++0000cda8 <[^>]*> nop
++0000cdac <[^>]*> nop
++0000cdb0 <[^>]*> nop
++0000cdb4 <[^>]*> nop
++0000cdb8 <[^>]*> nop
++0000cdbc <[^>]*> nop
++0000cdc0 <[^>]*> nop
++0000cdc4 <[^>]*> nop
++0000cdc8 <[^>]*> nop
++0000cdcc <[^>]*> nop
++0000cdd0 <[^>]*> nop
++0000cdd4 <[^>]*> nop
++0000cdd8 <[^>]*> nop
++0000cddc <[^>]*> nop
++0000cde0 <[^>]*> nop
++0000cde4 <[^>]*> nop
++0000cde8 <[^>]*> nop
++0000cdec <[^>]*> nop
++0000cdf0 <[^>]*> nop
++0000cdf4 <[^>]*> nop
++0000cdf8 <[^>]*> nop
++0000cdfc <[^>]*> nop
++0000ce00 <[^>]*> nop
++0000ce04 <[^>]*> nop
++0000ce08 <[^>]*> nop
++0000ce0c <[^>]*> nop
++0000ce10 <[^>]*> nop
++0000ce14 <[^>]*> nop
++0000ce18 <[^>]*> nop
++0000ce1c <[^>]*> nop
++0000ce20 <[^>]*> nop
++0000ce24 <[^>]*> nop
++0000ce28 <[^>]*> nop
++0000ce2c <[^>]*> nop
++0000ce30 <[^>]*> nop
++0000ce34 <[^>]*> nop
++0000ce38 <[^>]*> nop
++0000ce3c <[^>]*> nop
++0000ce40 <[^>]*> nop
++0000ce44 <[^>]*> nop
++0000ce48 <[^>]*> nop
++0000ce4c <[^>]*> nop
++0000ce50 <[^>]*> nop
++0000ce54 <[^>]*> nop
++0000ce58 <[^>]*> nop
++0000ce5c <[^>]*> nop
++0000ce60 <[^>]*> nop
++0000ce64 <[^>]*> nop
++0000ce68 <[^>]*> nop
++0000ce6c <[^>]*> nop
++0000ce70 <[^>]*> nop
++0000ce74 <[^>]*> nop
++0000ce78 <[^>]*> nop
++0000ce7c <[^>]*> nop
++0000ce80 <[^>]*> nop
++0000ce84 <[^>]*> nop
++0000ce88 <[^>]*> nop
++0000ce8c <[^>]*> nop
++0000ce90 <[^>]*> nop
++0000ce94 <[^>]*> nop
++0000ce98 <[^>]*> nop
++0000ce9c <[^>]*> nop
++0000cea0 <[^>]*> nop
++0000cea4 <[^>]*> nop
++0000cea8 <[^>]*> nop
++0000ceac <[^>]*> nop
++0000ceb0 <[^>]*> nop
++0000ceb4 <[^>]*> nop
++0000ceb8 <[^>]*> nop
++0000cebc <[^>]*> nop
++0000cec0 <[^>]*> nop
++0000cec4 <[^>]*> nop
++0000cec8 <[^>]*> nop
++0000cecc <[^>]*> nop
++0000ced0 <[^>]*> nop
++0000ced4 <[^>]*> nop
++0000ced8 <[^>]*> nop
++0000cedc <[^>]*> nop
++0000cee0 <[^>]*> nop
++0000cee4 <[^>]*> nop
++0000cee8 <[^>]*> nop
++0000ceec <[^>]*> nop
++0000cef0 <[^>]*> nop
++0000cef4 <[^>]*> nop
++0000cef8 <[^>]*> nop
++0000cefc <[^>]*> nop
++0000cf00 <[^>]*> nop
++0000cf04 <[^>]*> nop
++0000cf08 <[^>]*> nop
++0000cf0c <[^>]*> nop
++0000cf10 <[^>]*> nop
++0000cf14 <[^>]*> nop
++0000cf18 <[^>]*> nop
++0000cf1c <[^>]*> nop
++0000cf20 <[^>]*> nop
++0000cf24 <[^>]*> nop
++0000cf28 <[^>]*> nop
++0000cf2c <[^>]*> nop
++0000cf30 <[^>]*> nop
++0000cf34 <[^>]*> nop
++0000cf38 <[^>]*> nop
++0000cf3c <[^>]*> nop
++0000cf40 <[^>]*> nop
++0000cf44 <[^>]*> nop
++0000cf48 <[^>]*> nop
++0000cf4c <[^>]*> nop
++0000cf50 <[^>]*> nop
++0000cf54 <[^>]*> nop
++0000cf58 <[^>]*> nop
++0000cf5c <[^>]*> nop
++0000cf60 <[^>]*> nop
++0000cf64 <[^>]*> nop
++0000cf68 <[^>]*> nop
++0000cf6c <[^>]*> nop
++0000cf70 <[^>]*> nop
++0000cf74 <[^>]*> nop
++0000cf78 <[^>]*> nop
++0000cf7c <[^>]*> nop
++0000cf80 <[^>]*> nop
++0000cf84 <[^>]*> nop
++0000cf88 <[^>]*> nop
++0000cf8c <[^>]*> nop
++0000cf90 <[^>]*> nop
++0000cf94 <[^>]*> nop
++0000cf98 <[^>]*> nop
++0000cf9c <[^>]*> nop
++0000cfa0 <[^>]*> nop
++0000cfa4 <[^>]*> nop
++0000cfa8 <[^>]*> nop
++0000cfac <[^>]*> nop
++0000cfb0 <[^>]*> nop
++0000cfb4 <[^>]*> nop
++0000cfb8 <[^>]*> nop
++0000cfbc <[^>]*> nop
++0000cfc0 <[^>]*> nop
++0000cfc4 <[^>]*> nop
++0000cfc8 <[^>]*> nop
++0000cfcc <[^>]*> nop
++0000cfd0 <[^>]*> nop
++0000cfd4 <[^>]*> nop
++0000cfd8 <[^>]*> nop
++0000cfdc <[^>]*> nop
++0000cfe0 <[^>]*> nop
++0000cfe4 <[^>]*> nop
++0000cfe8 <[^>]*> nop
++0000cfec <[^>]*> nop
++0000cff0 <[^>]*> nop
++0000cff4 <[^>]*> nop
++0000cff8 <[^>]*> nop
++0000cffc <[^>]*> nop
++0000d000 <[^>]*> nop
++0000d004 <[^>]*> nop
++0000d008 <[^>]*> nop
++0000d00c <[^>]*> nop
++0000d010 <[^>]*> nop
++0000d014 <[^>]*> nop
++0000d018 <[^>]*> nop
++0000d01c <[^>]*> nop
++0000d020 <[^>]*> nop
++0000d024 <[^>]*> nop
++0000d028 <[^>]*> nop
++0000d02c <[^>]*> nop
++0000d030 <[^>]*> nop
++0000d034 <[^>]*> nop
++0000d038 <[^>]*> nop
++0000d03c <[^>]*> nop
++0000d040 <[^>]*> nop
++0000d044 <[^>]*> nop
++0000d048 <[^>]*> nop
++0000d04c <[^>]*> nop
++0000d050 <[^>]*> nop
++0000d054 <[^>]*> nop
++0000d058 <[^>]*> nop
++0000d05c <[^>]*> nop
++0000d060 <[^>]*> nop
++0000d064 <[^>]*> nop
++0000d068 <[^>]*> nop
++0000d06c <[^>]*> nop
++0000d070 <[^>]*> nop
++0000d074 <[^>]*> nop
++0000d078 <[^>]*> nop
++0000d07c <[^>]*> nop
++0000d080 <[^>]*> nop
++0000d084 <[^>]*> nop
++0000d088 <[^>]*> nop
++0000d08c <[^>]*> nop
++0000d090 <[^>]*> nop
++0000d094 <[^>]*> nop
++0000d098 <[^>]*> nop
++0000d09c <[^>]*> nop
++0000d0a0 <[^>]*> nop
++0000d0a4 <[^>]*> nop
++0000d0a8 <[^>]*> nop
++0000d0ac <[^>]*> nop
++0000d0b0 <[^>]*> nop
++0000d0b4 <[^>]*> nop
++0000d0b8 <[^>]*> nop
++0000d0bc <[^>]*> nop
++0000d0c0 <[^>]*> nop
++0000d0c4 <[^>]*> nop
++0000d0c8 <[^>]*> nop
++0000d0cc <[^>]*> nop
++0000d0d0 <[^>]*> nop
++0000d0d4 <[^>]*> nop
++0000d0d8 <[^>]*> nop
++0000d0dc <[^>]*> nop
++0000d0e0 <[^>]*> nop
++0000d0e4 <[^>]*> nop
++0000d0e8 <[^>]*> nop
++0000d0ec <[^>]*> nop
++0000d0f0 <[^>]*> nop
++0000d0f4 <[^>]*> nop
++0000d0f8 <[^>]*> nop
++0000d0fc <[^>]*> nop
++0000d100 <[^>]*> nop
++0000d104 <[^>]*> nop
++0000d108 <[^>]*> nop
++0000d10c <[^>]*> nop
++0000d110 <[^>]*> nop
++0000d114 <[^>]*> nop
++0000d118 <[^>]*> nop
++0000d11c <[^>]*> nop
++0000d120 <[^>]*> nop
++0000d124 <[^>]*> nop
++0000d128 <[^>]*> nop
++0000d12c <[^>]*> nop
++0000d130 <[^>]*> nop
++0000d134 <[^>]*> nop
++0000d138 <[^>]*> nop
++0000d13c <[^>]*> nop
++0000d140 <[^>]*> nop
++0000d144 <[^>]*> nop
++0000d148 <[^>]*> nop
++0000d14c <[^>]*> nop
++0000d150 <[^>]*> nop
++0000d154 <[^>]*> nop
++0000d158 <[^>]*> nop
++0000d15c <[^>]*> nop
++0000d160 <[^>]*> nop
++0000d164 <[^>]*> nop
++0000d168 <[^>]*> nop
++0000d16c <[^>]*> nop
++0000d170 <[^>]*> nop
++0000d174 <[^>]*> nop
++0000d178 <[^>]*> nop
++0000d17c <[^>]*> nop
++0000d180 <[^>]*> nop
++0000d184 <[^>]*> nop
++0000d188 <[^>]*> nop
++0000d18c <[^>]*> nop
++0000d190 <[^>]*> nop
++0000d194 <[^>]*> nop
++0000d198 <[^>]*> nop
++0000d19c <[^>]*> nop
++0000d1a0 <[^>]*> nop
++0000d1a4 <[^>]*> nop
++0000d1a8 <[^>]*> nop
++0000d1ac <[^>]*> nop
++0000d1b0 <[^>]*> nop
++0000d1b4 <[^>]*> nop
++0000d1b8 <[^>]*> nop
++0000d1bc <[^>]*> nop
++0000d1c0 <[^>]*> nop
++0000d1c4 <[^>]*> nop
++0000d1c8 <[^>]*> nop
++0000d1cc <[^>]*> nop
++0000d1d0 <[^>]*> nop
++0000d1d4 <[^>]*> nop
++0000d1d8 <[^>]*> nop
++0000d1dc <[^>]*> nop
++0000d1e0 <[^>]*> nop
++0000d1e4 <[^>]*> nop
++0000d1e8 <[^>]*> nop
++0000d1ec <[^>]*> nop
++0000d1f0 <[^>]*> nop
++0000d1f4 <[^>]*> nop
++0000d1f8 <[^>]*> nop
++0000d1fc <[^>]*> nop
++0000d200 <[^>]*> nop
++0000d204 <[^>]*> nop
++0000d208 <[^>]*> nop
++0000d20c <[^>]*> nop
++0000d210 <[^>]*> nop
++0000d214 <[^>]*> nop
++0000d218 <[^>]*> nop
++0000d21c <[^>]*> nop
++0000d220 <[^>]*> nop
++0000d224 <[^>]*> nop
++0000d228 <[^>]*> nop
++0000d22c <[^>]*> nop
++0000d230 <[^>]*> nop
++0000d234 <[^>]*> nop
++0000d238 <[^>]*> nop
++0000d23c <[^>]*> nop
++0000d240 <[^>]*> nop
++0000d244 <[^>]*> nop
++0000d248 <[^>]*> nop
++0000d24c <[^>]*> nop
++0000d250 <[^>]*> nop
++0000d254 <[^>]*> nop
++0000d258 <[^>]*> nop
++0000d25c <[^>]*> nop
++0000d260 <[^>]*> nop
++0000d264 <[^>]*> nop
++0000d268 <[^>]*> nop
++0000d26c <[^>]*> nop
++0000d270 <[^>]*> nop
++0000d274 <[^>]*> nop
++0000d278 <[^>]*> nop
++0000d27c <[^>]*> nop
++0000d280 <[^>]*> nop
++0000d284 <[^>]*> nop
++0000d288 <[^>]*> nop
++0000d28c <[^>]*> nop
++0000d290 <[^>]*> nop
++0000d294 <[^>]*> nop
++0000d298 <[^>]*> nop
++0000d29c <[^>]*> nop
++0000d2a0 <[^>]*> nop
++0000d2a4 <[^>]*> nop
++0000d2a8 <[^>]*> nop
++0000d2ac <[^>]*> nop
++0000d2b0 <[^>]*> nop
++0000d2b4 <[^>]*> nop
++0000d2b8 <[^>]*> nop
++0000d2bc <[^>]*> nop
++0000d2c0 <[^>]*> nop
++0000d2c4 <[^>]*> nop
++0000d2c8 <[^>]*> nop
++0000d2cc <[^>]*> nop
++0000d2d0 <[^>]*> nop
++0000d2d4 <[^>]*> nop
++0000d2d8 <[^>]*> nop
++0000d2dc <[^>]*> nop
++0000d2e0 <[^>]*> nop
++0000d2e4 <[^>]*> nop
++0000d2e8 <[^>]*> nop
++0000d2ec <[^>]*> nop
++0000d2f0 <[^>]*> nop
++0000d2f4 <[^>]*> nop
++0000d2f8 <[^>]*> nop
++0000d2fc <[^>]*> nop
++0000d300 <[^>]*> nop
++0000d304 <[^>]*> nop
++0000d308 <[^>]*> nop
++0000d30c <[^>]*> nop
++0000d310 <[^>]*> nop
++0000d314 <[^>]*> nop
++0000d318 <[^>]*> nop
++0000d31c <[^>]*> nop
++0000d320 <[^>]*> nop
++0000d324 <[^>]*> nop
++0000d328 <[^>]*> nop
++0000d32c <[^>]*> nop
++0000d330 <[^>]*> nop
++0000d334 <[^>]*> nop
++0000d338 <[^>]*> nop
++0000d33c <[^>]*> nop
++0000d340 <[^>]*> nop
++0000d344 <[^>]*> nop
++0000d348 <[^>]*> nop
++0000d34c <[^>]*> nop
++0000d350 <[^>]*> nop
++0000d354 <[^>]*> nop
++0000d358 <[^>]*> nop
++0000d35c <[^>]*> nop
++0000d360 <[^>]*> nop
++0000d364 <[^>]*> nop
++0000d368 <[^>]*> nop
++0000d36c <[^>]*> nop
++0000d370 <[^>]*> nop
++0000d374 <[^>]*> nop
++0000d378 <[^>]*> nop
++0000d37c <[^>]*> nop
++0000d380 <[^>]*> nop
++0000d384 <[^>]*> nop
++0000d388 <[^>]*> nop
++0000d38c <[^>]*> nop
++0000d390 <[^>]*> nop
++0000d394 <[^>]*> nop
++0000d398 <[^>]*> nop
++0000d39c <[^>]*> nop
++0000d3a0 <[^>]*> nop
++0000d3a4 <[^>]*> nop
++0000d3a8 <[^>]*> nop
++0000d3ac <[^>]*> nop
++0000d3b0 <[^>]*> nop
++0000d3b4 <[^>]*> nop
++0000d3b8 <[^>]*> nop
++0000d3bc <[^>]*> nop
++0000d3c0 <[^>]*> nop
++0000d3c4 <[^>]*> nop
++0000d3c8 <[^>]*> nop
++0000d3cc <[^>]*> nop
++0000d3d0 <[^>]*> nop
++0000d3d4 <[^>]*> nop
++0000d3d8 <[^>]*> nop
++0000d3dc <[^>]*> nop
++0000d3e0 <[^>]*> nop
++0000d3e4 <[^>]*> nop
++0000d3e8 <[^>]*> nop
++0000d3ec <[^>]*> nop
++0000d3f0 <[^>]*> nop
++0000d3f4 <[^>]*> nop
++0000d3f8 <[^>]*> nop
++0000d3fc <[^>]*> nop
++0000d400 <[^>]*> nop
++0000d404 <[^>]*> nop
++0000d408 <[^>]*> nop
++0000d40c <[^>]*> nop
++0000d410 <[^>]*> nop
++0000d414 <[^>]*> nop
++0000d418 <[^>]*> nop
++0000d41c <[^>]*> nop
++0000d420 <[^>]*> nop
++0000d424 <[^>]*> nop
++0000d428 <[^>]*> nop
++0000d42c <[^>]*> nop
++0000d430 <[^>]*> nop
++0000d434 <[^>]*> nop
++0000d438 <[^>]*> nop
++0000d43c <[^>]*> nop
++0000d440 <[^>]*> nop
++0000d444 <[^>]*> nop
++0000d448 <[^>]*> nop
++0000d44c <[^>]*> nop
++0000d450 <[^>]*> nop
++0000d454 <[^>]*> nop
++0000d458 <[^>]*> nop
++0000d45c <[^>]*> nop
++0000d460 <[^>]*> nop
++0000d464 <[^>]*> nop
++0000d468 <[^>]*> nop
++0000d46c <[^>]*> nop
++0000d470 <[^>]*> nop
++0000d474 <[^>]*> nop
++0000d478 <[^>]*> nop
++0000d47c <[^>]*> nop
++0000d480 <[^>]*> nop
++0000d484 <[^>]*> nop
++0000d488 <[^>]*> nop
++0000d48c <[^>]*> nop
++0000d490 <[^>]*> nop
++0000d494 <[^>]*> nop
++0000d498 <[^>]*> nop
++0000d49c <[^>]*> nop
++0000d4a0 <[^>]*> nop
++0000d4a4 <[^>]*> nop
++0000d4a8 <[^>]*> nop
++0000d4ac <[^>]*> nop
++0000d4b0 <[^>]*> nop
++0000d4b4 <[^>]*> nop
++0000d4b8 <[^>]*> nop
++0000d4bc <[^>]*> nop
++0000d4c0 <[^>]*> nop
++0000d4c4 <[^>]*> nop
++0000d4c8 <[^>]*> nop
++0000d4cc <[^>]*> nop
++0000d4d0 <[^>]*> nop
++0000d4d4 <[^>]*> nop
++0000d4d8 <[^>]*> nop
++0000d4dc <[^>]*> nop
++0000d4e0 <[^>]*> nop
++0000d4e4 <[^>]*> nop
++0000d4e8 <[^>]*> nop
++0000d4ec <[^>]*> nop
++0000d4f0 <[^>]*> nop
++0000d4f4 <[^>]*> nop
++0000d4f8 <[^>]*> nop
++0000d4fc <[^>]*> nop
++0000d500 <[^>]*> nop
++0000d504 <[^>]*> nop
++0000d508 <[^>]*> nop
++0000d50c <[^>]*> nop
++0000d510 <[^>]*> nop
++0000d514 <[^>]*> nop
++0000d518 <[^>]*> nop
++0000d51c <[^>]*> nop
++0000d520 <[^>]*> nop
++0000d524 <[^>]*> nop
++0000d528 <[^>]*> nop
++0000d52c <[^>]*> nop
++0000d530 <[^>]*> nop
++0000d534 <[^>]*> nop
++0000d538 <[^>]*> nop
++0000d53c <[^>]*> nop
++0000d540 <[^>]*> nop
++0000d544 <[^>]*> nop
++0000d548 <[^>]*> nop
++0000d54c <[^>]*> nop
++0000d550 <[^>]*> nop
++0000d554 <[^>]*> nop
++0000d558 <[^>]*> nop
++0000d55c <[^>]*> nop
++0000d560 <[^>]*> nop
++0000d564 <[^>]*> nop
++0000d568 <[^>]*> nop
++0000d56c <[^>]*> nop
++0000d570 <[^>]*> nop
++0000d574 <[^>]*> nop
++0000d578 <[^>]*> nop
++0000d57c <[^>]*> nop
++0000d580 <[^>]*> nop
++0000d584 <[^>]*> nop
++0000d588 <[^>]*> nop
++0000d58c <[^>]*> nop
++0000d590 <[^>]*> nop
++0000d594 <[^>]*> nop
++0000d598 <[^>]*> nop
++0000d59c <[^>]*> nop
++0000d5a0 <[^>]*> nop
++0000d5a4 <[^>]*> nop
++0000d5a8 <[^>]*> nop
++0000d5ac <[^>]*> nop
++0000d5b0 <[^>]*> nop
++0000d5b4 <[^>]*> nop
++0000d5b8 <[^>]*> nop
++0000d5bc <[^>]*> nop
++0000d5c0 <[^>]*> nop
++0000d5c4 <[^>]*> nop
++0000d5c8 <[^>]*> nop
++0000d5cc <[^>]*> nop
++0000d5d0 <[^>]*> nop
++0000d5d4 <[^>]*> nop
++0000d5d8 <[^>]*> nop
++0000d5dc <[^>]*> nop
++0000d5e0 <[^>]*> nop
++0000d5e4 <[^>]*> nop
++0000d5e8 <[^>]*> nop
++0000d5ec <[^>]*> nop
++0000d5f0 <[^>]*> nop
++0000d5f4 <[^>]*> nop
++0000d5f8 <[^>]*> nop
++0000d5fc <[^>]*> nop
++0000d600 <[^>]*> nop
++0000d604 <[^>]*> nop
++0000d608 <[^>]*> nop
++0000d60c <[^>]*> nop
++0000d610 <[^>]*> nop
++0000d614 <[^>]*> nop
++0000d618 <[^>]*> nop
++0000d61c <[^>]*> nop
++0000d620 <[^>]*> nop
++0000d624 <[^>]*> nop
++0000d628 <[^>]*> nop
++0000d62c <[^>]*> nop
++0000d630 <[^>]*> nop
++0000d634 <[^>]*> nop
++0000d638 <[^>]*> nop
++0000d63c <[^>]*> nop
++0000d640 <[^>]*> nop
++0000d644 <[^>]*> nop
++0000d648 <[^>]*> nop
++0000d64c <[^>]*> nop
++0000d650 <[^>]*> nop
++0000d654 <[^>]*> nop
++0000d658 <[^>]*> nop
++0000d65c <[^>]*> nop
++0000d660 <[^>]*> nop
++0000d664 <[^>]*> nop
++0000d668 <[^>]*> nop
++0000d66c <[^>]*> nop
++0000d670 <[^>]*> nop
++0000d674 <[^>]*> nop
++0000d678 <[^>]*> nop
++0000d67c <[^>]*> nop
++0000d680 <[^>]*> nop
++0000d684 <[^>]*> nop
++0000d688 <[^>]*> nop
++0000d68c <[^>]*> nop
++0000d690 <[^>]*> nop
++0000d694 <[^>]*> nop
++0000d698 <[^>]*> nop
++0000d69c <[^>]*> nop
++0000d6a0 <[^>]*> nop
++0000d6a4 <[^>]*> nop
++0000d6a8 <[^>]*> nop
++0000d6ac <[^>]*> nop
++0000d6b0 <[^>]*> nop
++0000d6b4 <[^>]*> nop
++0000d6b8 <[^>]*> nop
++0000d6bc <[^>]*> nop
++0000d6c0 <[^>]*> nop
++0000d6c4 <[^>]*> nop
++0000d6c8 <[^>]*> nop
++0000d6cc <[^>]*> nop
++0000d6d0 <[^>]*> nop
++0000d6d4 <[^>]*> nop
++0000d6d8 <[^>]*> nop
++0000d6dc <[^>]*> nop
++0000d6e0 <[^>]*> nop
++0000d6e4 <[^>]*> nop
++0000d6e8 <[^>]*> nop
++0000d6ec <[^>]*> nop
++0000d6f0 <[^>]*> nop
++0000d6f4 <[^>]*> nop
++0000d6f8 <[^>]*> nop
++0000d6fc <[^>]*> nop
++0000d700 <[^>]*> nop
++0000d704 <[^>]*> nop
++0000d708 <[^>]*> nop
++0000d70c <[^>]*> nop
++0000d710 <[^>]*> nop
++0000d714 <[^>]*> nop
++0000d718 <[^>]*> nop
++0000d71c <[^>]*> nop
++0000d720 <[^>]*> nop
++0000d724 <[^>]*> nop
++0000d728 <[^>]*> nop
++0000d72c <[^>]*> nop
++0000d730 <[^>]*> nop
++0000d734 <[^>]*> nop
++0000d738 <[^>]*> nop
++0000d73c <[^>]*> nop
++0000d740 <[^>]*> nop
++0000d744 <[^>]*> nop
++0000d748 <[^>]*> nop
++0000d74c <[^>]*> nop
++0000d750 <[^>]*> nop
++0000d754 <[^>]*> nop
++0000d758 <[^>]*> nop
++0000d75c <[^>]*> nop
++0000d760 <[^>]*> nop
++0000d764 <[^>]*> nop
++0000d768 <[^>]*> nop
++0000d76c <[^>]*> nop
++0000d770 <[^>]*> nop
++0000d774 <[^>]*> nop
++0000d778 <[^>]*> nop
++0000d77c <[^>]*> nop
++0000d780 <[^>]*> nop
++0000d784 <[^>]*> nop
++0000d788 <[^>]*> nop
++0000d78c <[^>]*> nop
++0000d790 <[^>]*> nop
++0000d794 <[^>]*> nop
++0000d798 <[^>]*> nop
++0000d79c <[^>]*> nop
++0000d7a0 <[^>]*> nop
++0000d7a4 <[^>]*> nop
++0000d7a8 <[^>]*> nop
++0000d7ac <[^>]*> nop
++0000d7b0 <[^>]*> nop
++0000d7b4 <[^>]*> nop
++0000d7b8 <[^>]*> nop
++0000d7bc <[^>]*> nop
++0000d7c0 <[^>]*> nop
++0000d7c4 <[^>]*> nop
++0000d7c8 <[^>]*> nop
++0000d7cc <[^>]*> nop
++0000d7d0 <[^>]*> nop
++0000d7d4 <[^>]*> nop
++0000d7d8 <[^>]*> nop
++0000d7dc <[^>]*> nop
++0000d7e0 <[^>]*> nop
++0000d7e4 <[^>]*> nop
++0000d7e8 <[^>]*> nop
++0000d7ec <[^>]*> nop
++0000d7f0 <[^>]*> nop
++0000d7f4 <[^>]*> nop
++0000d7f8 <[^>]*> nop
++0000d7fc <[^>]*> nop
++0000d800 <[^>]*> nop
++0000d804 <[^>]*> nop
++0000d808 <[^>]*> nop
++0000d80c <[^>]*> nop
++0000d810 <[^>]*> nop
++0000d814 <[^>]*> nop
++0000d818 <[^>]*> nop
++0000d81c <[^>]*> nop
++0000d820 <[^>]*> nop
++0000d824 <[^>]*> nop
++0000d828 <[^>]*> nop
++0000d82c <[^>]*> nop
++0000d830 <[^>]*> nop
++0000d834 <[^>]*> nop
++0000d838 <[^>]*> nop
++0000d83c <[^>]*> nop
++0000d840 <[^>]*> nop
++0000d844 <[^>]*> nop
++0000d848 <[^>]*> nop
++0000d84c <[^>]*> nop
++0000d850 <[^>]*> nop
++0000d854 <[^>]*> nop
++0000d858 <[^>]*> nop
++0000d85c <[^>]*> nop
++0000d860 <[^>]*> nop
++0000d864 <[^>]*> nop
++0000d868 <[^>]*> nop
++0000d86c <[^>]*> nop
++0000d870 <[^>]*> nop
++0000d874 <[^>]*> nop
++0000d878 <[^>]*> nop
++0000d87c <[^>]*> nop
++0000d880 <[^>]*> nop
++0000d884 <[^>]*> nop
++0000d888 <[^>]*> nop
++0000d88c <[^>]*> nop
++0000d890 <[^>]*> nop
++0000d894 <[^>]*> nop
++0000d898 <[^>]*> nop
++0000d89c <[^>]*> nop
++0000d8a0 <[^>]*> nop
++0000d8a4 <[^>]*> nop
++0000d8a8 <[^>]*> nop
++0000d8ac <[^>]*> nop
++0000d8b0 <[^>]*> nop
++0000d8b4 <[^>]*> nop
++0000d8b8 <[^>]*> nop
++0000d8bc <[^>]*> nop
++0000d8c0 <[^>]*> nop
++0000d8c4 <[^>]*> nop
++0000d8c8 <[^>]*> nop
++0000d8cc <[^>]*> nop
++0000d8d0 <[^>]*> nop
++0000d8d4 <[^>]*> nop
++0000d8d8 <[^>]*> nop
++0000d8dc <[^>]*> nop
++0000d8e0 <[^>]*> nop
++0000d8e4 <[^>]*> nop
++0000d8e8 <[^>]*> nop
++0000d8ec <[^>]*> nop
++0000d8f0 <[^>]*> nop
++0000d8f4 <[^>]*> nop
++0000d8f8 <[^>]*> nop
++0000d8fc <[^>]*> nop
++0000d900 <[^>]*> nop
++0000d904 <[^>]*> nop
++0000d908 <[^>]*> nop
++0000d90c <[^>]*> nop
++0000d910 <[^>]*> nop
++0000d914 <[^>]*> nop
++0000d918 <[^>]*> nop
++0000d91c <[^>]*> nop
++0000d920 <[^>]*> nop
++0000d924 <[^>]*> nop
++0000d928 <[^>]*> nop
++0000d92c <[^>]*> nop
++0000d930 <[^>]*> nop
++0000d934 <[^>]*> nop
++0000d938 <[^>]*> nop
++0000d93c <[^>]*> nop
++0000d940 <[^>]*> nop
++0000d944 <[^>]*> nop
++0000d948 <[^>]*> nop
++0000d94c <[^>]*> nop
++0000d950 <[^>]*> nop
++0000d954 <[^>]*> nop
++0000d958 <[^>]*> nop
++0000d95c <[^>]*> nop
++0000d960 <[^>]*> nop
++0000d964 <[^>]*> nop
++0000d968 <[^>]*> nop
++0000d96c <[^>]*> nop
++0000d970 <[^>]*> nop
++0000d974 <[^>]*> nop
++0000d978 <[^>]*> nop
++0000d97c <[^>]*> nop
++0000d980 <[^>]*> nop
++0000d984 <[^>]*> nop
++0000d988 <[^>]*> nop
++0000d98c <[^>]*> nop
++0000d990 <[^>]*> nop
++0000d994 <[^>]*> nop
++0000d998 <[^>]*> nop
++0000d99c <[^>]*> nop
++0000d9a0 <[^>]*> nop
++0000d9a4 <[^>]*> nop
++0000d9a8 <[^>]*> nop
++0000d9ac <[^>]*> nop
++0000d9b0 <[^>]*> nop
++0000d9b4 <[^>]*> nop
++0000d9b8 <[^>]*> nop
++0000d9bc <[^>]*> nop
++0000d9c0 <[^>]*> nop
++0000d9c4 <[^>]*> nop
++0000d9c8 <[^>]*> nop
++0000d9cc <[^>]*> nop
++0000d9d0 <[^>]*> nop
++0000d9d4 <[^>]*> nop
++0000d9d8 <[^>]*> nop
++0000d9dc <[^>]*> nop
++0000d9e0 <[^>]*> nop
++0000d9e4 <[^>]*> nop
++0000d9e8 <[^>]*> nop
++0000d9ec <[^>]*> nop
++0000d9f0 <[^>]*> nop
++0000d9f4 <[^>]*> nop
++0000d9f8 <[^>]*> nop
++0000d9fc <[^>]*> nop
++0000da00 <[^>]*> nop
++0000da04 <[^>]*> nop
++0000da08 <[^>]*> nop
++0000da0c <[^>]*> nop
++0000da10 <[^>]*> nop
++0000da14 <[^>]*> nop
++0000da18 <[^>]*> nop
++0000da1c <[^>]*> nop
++0000da20 <[^>]*> nop
++0000da24 <[^>]*> nop
++0000da28 <[^>]*> nop
++0000da2c <[^>]*> nop
++0000da30 <[^>]*> nop
++0000da34 <[^>]*> nop
++0000da38 <[^>]*> nop
++0000da3c <[^>]*> nop
++0000da40 <[^>]*> nop
++0000da44 <[^>]*> nop
++0000da48 <[^>]*> nop
++0000da4c <[^>]*> nop
++0000da50 <[^>]*> nop
++0000da54 <[^>]*> nop
++0000da58 <[^>]*> nop
++0000da5c <[^>]*> nop
++0000da60 <[^>]*> nop
++0000da64 <[^>]*> nop
++0000da68 <[^>]*> nop
++0000da6c <[^>]*> nop
++0000da70 <[^>]*> nop
++0000da74 <[^>]*> nop
++0000da78 <[^>]*> nop
++0000da7c <[^>]*> nop
++0000da80 <[^>]*> nop
++0000da84 <[^>]*> nop
++0000da88 <[^>]*> nop
++0000da8c <[^>]*> nop
++0000da90 <[^>]*> nop
++0000da94 <[^>]*> nop
++0000da98 <[^>]*> nop
++0000da9c <[^>]*> nop
++0000daa0 <[^>]*> nop
++0000daa4 <[^>]*> nop
++0000daa8 <[^>]*> nop
++0000daac <[^>]*> nop
++0000dab0 <[^>]*> nop
++0000dab4 <[^>]*> nop
++0000dab8 <[^>]*> nop
++0000dabc <[^>]*> nop
++0000dac0 <[^>]*> nop
++0000dac4 <[^>]*> nop
++0000dac8 <[^>]*> nop
++0000dacc <[^>]*> nop
++0000dad0 <[^>]*> nop
++0000dad4 <[^>]*> nop
++0000dad8 <[^>]*> nop
++0000dadc <[^>]*> nop
++0000dae0 <[^>]*> nop
++0000dae4 <[^>]*> nop
++0000dae8 <[^>]*> nop
++0000daec <[^>]*> nop
++0000daf0 <[^>]*> nop
++0000daf4 <[^>]*> nop
++0000daf8 <[^>]*> nop
++0000dafc <[^>]*> nop
++0000db00 <[^>]*> nop
++0000db04 <[^>]*> nop
++0000db08 <[^>]*> nop
++0000db0c <[^>]*> nop
++0000db10 <[^>]*> nop
++0000db14 <[^>]*> nop
++0000db18 <[^>]*> nop
++0000db1c <[^>]*> nop
++0000db20 <[^>]*> nop
++0000db24 <[^>]*> nop
++0000db28 <[^>]*> nop
++0000db2c <[^>]*> nop
++0000db30 <[^>]*> nop
++0000db34 <[^>]*> nop
++0000db38 <[^>]*> nop
++0000db3c <[^>]*> nop
++0000db40 <[^>]*> nop
++0000db44 <[^>]*> nop
++0000db48 <[^>]*> nop
++0000db4c <[^>]*> nop
++0000db50 <[^>]*> nop
++0000db54 <[^>]*> nop
++0000db58 <[^>]*> nop
++0000db5c <[^>]*> nop
++0000db60 <[^>]*> nop
++0000db64 <[^>]*> nop
++0000db68 <[^>]*> nop
++0000db6c <[^>]*> nop
++0000db70 <[^>]*> nop
++0000db74 <[^>]*> nop
++0000db78 <[^>]*> nop
++0000db7c <[^>]*> nop
++0000db80 <[^>]*> nop
++0000db84 <[^>]*> nop
++0000db88 <[^>]*> nop
++0000db8c <[^>]*> nop
++0000db90 <[^>]*> nop
++0000db94 <[^>]*> nop
++0000db98 <[^>]*> nop
++0000db9c <[^>]*> nop
++0000dba0 <[^>]*> nop
++0000dba4 <[^>]*> nop
++0000dba8 <[^>]*> nop
++0000dbac <[^>]*> nop
++0000dbb0 <[^>]*> nop
++0000dbb4 <[^>]*> nop
++0000dbb8 <[^>]*> nop
++0000dbbc <[^>]*> nop
++0000dbc0 <[^>]*> nop
++0000dbc4 <[^>]*> nop
++0000dbc8 <[^>]*> nop
++0000dbcc <[^>]*> nop
++0000dbd0 <[^>]*> nop
++0000dbd4 <[^>]*> nop
++0000dbd8 <[^>]*> nop
++0000dbdc <[^>]*> nop
++0000dbe0 <[^>]*> nop
++0000dbe4 <[^>]*> nop
++0000dbe8 <[^>]*> nop
++0000dbec <[^>]*> nop
++0000dbf0 <[^>]*> nop
++0000dbf4 <[^>]*> nop
++0000dbf8 <[^>]*> nop
++0000dbfc <[^>]*> nop
++0000dc00 <[^>]*> nop
++0000dc04 <[^>]*> nop
++0000dc08 <[^>]*> nop
++0000dc0c <[^>]*> nop
++0000dc10 <[^>]*> nop
++0000dc14 <[^>]*> nop
++0000dc18 <[^>]*> nop
++0000dc1c <[^>]*> nop
++0000dc20 <[^>]*> nop
++0000dc24 <[^>]*> nop
++0000dc28 <[^>]*> nop
++0000dc2c <[^>]*> nop
++0000dc30 <[^>]*> nop
++0000dc34 <[^>]*> nop
++0000dc38 <[^>]*> nop
++0000dc3c <[^>]*> nop
++0000dc40 <[^>]*> nop
++0000dc44 <[^>]*> nop
++0000dc48 <[^>]*> nop
++0000dc4c <[^>]*> nop
++0000dc50 <[^>]*> nop
++0000dc54 <[^>]*> nop
++0000dc58 <[^>]*> nop
++0000dc5c <[^>]*> nop
++0000dc60 <[^>]*> nop
++0000dc64 <[^>]*> nop
++0000dc68 <[^>]*> nop
++0000dc6c <[^>]*> nop
++0000dc70 <[^>]*> nop
++0000dc74 <[^>]*> nop
++0000dc78 <[^>]*> nop
++0000dc7c <[^>]*> nop
++0000dc80 <[^>]*> nop
++0000dc84 <[^>]*> nop
++0000dc88 <[^>]*> nop
++0000dc8c <[^>]*> nop
++0000dc90 <[^>]*> nop
++0000dc94 <[^>]*> nop
++0000dc98 <[^>]*> nop
++0000dc9c <[^>]*> nop
++0000dca0 <[^>]*> nop
++0000dca4 <[^>]*> nop
++0000dca8 <[^>]*> nop
++0000dcac <[^>]*> nop
++0000dcb0 <[^>]*> nop
++0000dcb4 <[^>]*> nop
++0000dcb8 <[^>]*> nop
++0000dcbc <[^>]*> nop
++0000dcc0 <[^>]*> nop
++0000dcc4 <[^>]*> nop
++0000dcc8 <[^>]*> nop
++0000dccc <[^>]*> nop
++0000dcd0 <[^>]*> nop
++0000dcd4 <[^>]*> nop
++0000dcd8 <[^>]*> nop
++0000dcdc <[^>]*> nop
++0000dce0 <[^>]*> nop
++0000dce4 <[^>]*> nop
++0000dce8 <[^>]*> nop
++0000dcec <[^>]*> nop
++0000dcf0 <[^>]*> nop
++0000dcf4 <[^>]*> nop
++0000dcf8 <[^>]*> nop
++0000dcfc <[^>]*> nop
++0000dd00 <[^>]*> nop
++0000dd04 <[^>]*> nop
++0000dd08 <[^>]*> nop
++0000dd0c <[^>]*> nop
++0000dd10 <[^>]*> nop
++0000dd14 <[^>]*> nop
++0000dd18 <[^>]*> nop
++0000dd1c <[^>]*> nop
++0000dd20 <[^>]*> nop
++0000dd24 <[^>]*> nop
++0000dd28 <[^>]*> nop
++0000dd2c <[^>]*> nop
++0000dd30 <[^>]*> nop
++0000dd34 <[^>]*> nop
++0000dd38 <[^>]*> nop
++0000dd3c <[^>]*> nop
++0000dd40 <[^>]*> nop
++0000dd44 <[^>]*> nop
++0000dd48 <[^>]*> nop
++0000dd4c <[^>]*> nop
++0000dd50 <[^>]*> nop
++0000dd54 <[^>]*> nop
++0000dd58 <[^>]*> nop
++0000dd5c <[^>]*> nop
++0000dd60 <[^>]*> nop
++0000dd64 <[^>]*> nop
++0000dd68 <[^>]*> nop
++0000dd6c <[^>]*> nop
++0000dd70 <[^>]*> nop
++0000dd74 <[^>]*> nop
++0000dd78 <[^>]*> nop
++0000dd7c <[^>]*> nop
++0000dd80 <[^>]*> nop
++0000dd84 <[^>]*> nop
++0000dd88 <[^>]*> nop
++0000dd8c <[^>]*> nop
++0000dd90 <[^>]*> nop
++0000dd94 <[^>]*> nop
++0000dd98 <[^>]*> nop
++0000dd9c <[^>]*> nop
++0000dda0 <[^>]*> nop
++0000dda4 <[^>]*> nop
++0000dda8 <[^>]*> nop
++0000ddac <[^>]*> nop
++0000ddb0 <[^>]*> nop
++0000ddb4 <[^>]*> nop
++0000ddb8 <[^>]*> nop
++0000ddbc <[^>]*> nop
++0000ddc0 <[^>]*> nop
++0000ddc4 <[^>]*> nop
++0000ddc8 <[^>]*> nop
++0000ddcc <[^>]*> nop
++0000ddd0 <[^>]*> nop
++0000ddd4 <[^>]*> nop
++0000ddd8 <[^>]*> nop
++0000dddc <[^>]*> nop
++0000dde0 <[^>]*> nop
++0000dde4 <[^>]*> nop
++0000dde8 <[^>]*> nop
++0000ddec <[^>]*> nop
++0000ddf0 <[^>]*> nop
++0000ddf4 <[^>]*> nop
++0000ddf8 <[^>]*> nop
++0000ddfc <[^>]*> nop
++0000de00 <[^>]*> nop
++0000de04 <[^>]*> nop
++0000de08 <[^>]*> nop
++0000de0c <[^>]*> nop
++0000de10 <[^>]*> nop
++0000de14 <[^>]*> nop
++0000de18 <[^>]*> nop
++0000de1c <[^>]*> nop
++0000de20 <[^>]*> nop
++0000de24 <[^>]*> nop
++0000de28 <[^>]*> nop
++0000de2c <[^>]*> nop
++0000de30 <[^>]*> nop
++0000de34 <[^>]*> nop
++0000de38 <[^>]*> nop
++0000de3c <[^>]*> nop
++0000de40 <[^>]*> nop
++0000de44 <[^>]*> nop
++0000de48 <[^>]*> nop
++0000de4c <[^>]*> nop
++0000de50 <[^>]*> nop
++0000de54 <[^>]*> nop
++0000de58 <[^>]*> nop
++0000de5c <[^>]*> nop
++0000de60 <[^>]*> nop
++0000de64 <[^>]*> nop
++0000de68 <[^>]*> nop
++0000de6c <[^>]*> nop
++0000de70 <[^>]*> nop
++0000de74 <[^>]*> nop
++0000de78 <[^>]*> nop
++0000de7c <[^>]*> nop
++0000de80 <[^>]*> nop
++0000de84 <[^>]*> nop
++0000de88 <[^>]*> nop
++0000de8c <[^>]*> nop
++0000de90 <[^>]*> nop
++0000de94 <[^>]*> nop
++0000de98 <[^>]*> nop
++0000de9c <[^>]*> nop
++0000dea0 <[^>]*> nop
++0000dea4 <[^>]*> nop
++0000dea8 <[^>]*> nop
++0000deac <[^>]*> nop
++0000deb0 <[^>]*> nop
++0000deb4 <[^>]*> nop
++0000deb8 <[^>]*> nop
++0000debc <[^>]*> nop
++0000dec0 <[^>]*> nop
++0000dec4 <[^>]*> nop
++0000dec8 <[^>]*> nop
++0000decc <[^>]*> nop
++0000ded0 <[^>]*> nop
++0000ded4 <[^>]*> nop
++0000ded8 <[^>]*> nop
++0000dedc <[^>]*> nop
++0000dee0 <[^>]*> nop
++0000dee4 <[^>]*> nop
++0000dee8 <[^>]*> nop
++0000deec <[^>]*> nop
++0000def0 <[^>]*> nop
++0000def4 <[^>]*> nop
++0000def8 <[^>]*> nop
++0000defc <[^>]*> nop
++0000df00 <[^>]*> nop
++0000df04 <[^>]*> nop
++0000df08 <[^>]*> nop
++0000df0c <[^>]*> nop
++0000df10 <[^>]*> nop
++0000df14 <[^>]*> nop
++0000df18 <[^>]*> nop
++0000df1c <[^>]*> nop
++0000df20 <[^>]*> nop
++0000df24 <[^>]*> nop
++0000df28 <[^>]*> nop
++0000df2c <[^>]*> nop
++0000df30 <[^>]*> nop
++0000df34 <[^>]*> nop
++0000df38 <[^>]*> nop
++0000df3c <[^>]*> nop
++0000df40 <[^>]*> nop
++0000df44 <[^>]*> nop
++0000df48 <[^>]*> nop
++0000df4c <[^>]*> nop
++0000df50 <[^>]*> nop
++0000df54 <[^>]*> nop
++0000df58 <[^>]*> nop
++0000df5c <[^>]*> nop
++0000df60 <[^>]*> nop
++0000df64 <[^>]*> nop
++0000df68 <[^>]*> nop
++0000df6c <[^>]*> nop
++0000df70 <[^>]*> nop
++0000df74 <[^>]*> nop
++0000df78 <[^>]*> nop
++0000df7c <[^>]*> nop
++0000df80 <[^>]*> nop
++0000df84 <[^>]*> nop
++0000df88 <[^>]*> nop
++0000df8c <[^>]*> nop
++0000df90 <[^>]*> nop
++0000df94 <[^>]*> nop
++0000df98 <[^>]*> nop
++0000df9c <[^>]*> nop
++0000dfa0 <[^>]*> nop
++0000dfa4 <[^>]*> nop
++0000dfa8 <[^>]*> nop
++0000dfac <[^>]*> nop
++0000dfb0 <[^>]*> nop
++0000dfb4 <[^>]*> nop
++0000dfb8 <[^>]*> nop
++0000dfbc <[^>]*> nop
++0000dfc0 <[^>]*> nop
++0000dfc4 <[^>]*> nop
++0000dfc8 <[^>]*> nop
++0000dfcc <[^>]*> nop
++0000dfd0 <[^>]*> nop
++0000dfd4 <[^>]*> nop
++0000dfd8 <[^>]*> nop
++0000dfdc <[^>]*> nop
++0000dfe0 <[^>]*> nop
++0000dfe4 <[^>]*> nop
++0000dfe8 <[^>]*> nop
++0000dfec <[^>]*> nop
++0000dff0 <[^>]*> nop
++0000dff4 <[^>]*> nop
++0000dff8 <[^>]*> nop
++0000dffc <[^>]*> nop
++0000e000 <[^>]*> nop
++0000e004 <[^>]*> nop
++0000e008 <[^>]*> nop
++0000e00c <[^>]*> nop
++0000e010 <[^>]*> nop
++0000e014 <[^>]*> nop
++0000e018 <[^>]*> nop
++0000e01c <[^>]*> nop
++0000e020 <[^>]*> nop
++0000e024 <[^>]*> nop
++0000e028 <[^>]*> nop
++0000e02c <[^>]*> nop
++0000e030 <[^>]*> nop
++0000e034 <[^>]*> nop
++0000e038 <[^>]*> nop
++0000e03c <[^>]*> nop
++0000e040 <[^>]*> nop
++0000e044 <[^>]*> nop
++0000e048 <[^>]*> nop
++0000e04c <[^>]*> nop
++0000e050 <[^>]*> nop
++0000e054 <[^>]*> nop
++0000e058 <[^>]*> nop
++0000e05c <[^>]*> nop
++0000e060 <[^>]*> nop
++0000e064 <[^>]*> nop
++0000e068 <[^>]*> nop
++0000e06c <[^>]*> nop
++0000e070 <[^>]*> nop
++0000e074 <[^>]*> nop
++0000e078 <[^>]*> nop
++0000e07c <[^>]*> nop
++0000e080 <[^>]*> nop
++0000e084 <[^>]*> nop
++0000e088 <[^>]*> nop
++0000e08c <[^>]*> nop
++0000e090 <[^>]*> nop
++0000e094 <[^>]*> nop
++0000e098 <[^>]*> nop
++0000e09c <[^>]*> nop
++0000e0a0 <[^>]*> nop
++0000e0a4 <[^>]*> nop
++0000e0a8 <[^>]*> nop
++0000e0ac <[^>]*> nop
++0000e0b0 <[^>]*> nop
++0000e0b4 <[^>]*> nop
++0000e0b8 <[^>]*> nop
++0000e0bc <[^>]*> nop
++0000e0c0 <[^>]*> nop
++0000e0c4 <[^>]*> nop
++0000e0c8 <[^>]*> nop
++0000e0cc <[^>]*> nop
++0000e0d0 <[^>]*> nop
++0000e0d4 <[^>]*> nop
++0000e0d8 <[^>]*> nop
++0000e0dc <[^>]*> nop
++0000e0e0 <[^>]*> nop
++0000e0e4 <[^>]*> nop
++0000e0e8 <[^>]*> nop
++0000e0ec <[^>]*> nop
++0000e0f0 <[^>]*> nop
++0000e0f4 <[^>]*> nop
++0000e0f8 <[^>]*> nop
++0000e0fc <[^>]*> nop
++0000e100 <[^>]*> nop
++0000e104 <[^>]*> nop
++0000e108 <[^>]*> nop
++0000e10c <[^>]*> nop
++0000e110 <[^>]*> nop
++0000e114 <[^>]*> nop
++0000e118 <[^>]*> nop
++0000e11c <[^>]*> nop
++0000e120 <[^>]*> nop
++0000e124 <[^>]*> nop
++0000e128 <[^>]*> nop
++0000e12c <[^>]*> nop
++0000e130 <[^>]*> nop
++0000e134 <[^>]*> nop
++0000e138 <[^>]*> nop
++0000e13c <[^>]*> nop
++0000e140 <[^>]*> nop
++0000e144 <[^>]*> nop
++0000e148 <[^>]*> nop
++0000e14c <[^>]*> nop
++0000e150 <[^>]*> nop
++0000e154 <[^>]*> nop
++0000e158 <[^>]*> nop
++0000e15c <[^>]*> nop
++0000e160 <[^>]*> nop
++0000e164 <[^>]*> nop
++0000e168 <[^>]*> nop
++0000e16c <[^>]*> nop
++0000e170 <[^>]*> nop
++0000e174 <[^>]*> nop
++0000e178 <[^>]*> nop
++0000e17c <[^>]*> nop
++0000e180 <[^>]*> nop
++0000e184 <[^>]*> nop
++0000e188 <[^>]*> nop
++0000e18c <[^>]*> nop
++0000e190 <[^>]*> nop
++0000e194 <[^>]*> nop
++0000e198 <[^>]*> nop
++0000e19c <[^>]*> nop
++0000e1a0 <[^>]*> nop
++0000e1a4 <[^>]*> nop
++0000e1a8 <[^>]*> nop
++0000e1ac <[^>]*> nop
++0000e1b0 <[^>]*> nop
++0000e1b4 <[^>]*> nop
++0000e1b8 <[^>]*> nop
++0000e1bc <[^>]*> nop
++0000e1c0 <[^>]*> nop
++0000e1c4 <[^>]*> nop
++0000e1c8 <[^>]*> nop
++0000e1cc <[^>]*> nop
++0000e1d0 <[^>]*> nop
++0000e1d4 <[^>]*> nop
++0000e1d8 <[^>]*> nop
++0000e1dc <[^>]*> nop
++0000e1e0 <[^>]*> nop
++0000e1e4 <[^>]*> nop
++0000e1e8 <[^>]*> nop
++0000e1ec <[^>]*> nop
++0000e1f0 <[^>]*> nop
++0000e1f4 <[^>]*> nop
++0000e1f8 <[^>]*> nop
++0000e1fc <[^>]*> nop
++0000e200 <[^>]*> nop
++0000e204 <[^>]*> nop
++0000e208 <[^>]*> nop
++0000e20c <[^>]*> nop
++0000e210 <[^>]*> nop
++0000e214 <[^>]*> nop
++0000e218 <[^>]*> nop
++0000e21c <[^>]*> nop
++0000e220 <[^>]*> nop
++0000e224 <[^>]*> nop
++0000e228 <[^>]*> nop
++0000e22c <[^>]*> nop
++0000e230 <[^>]*> nop
++0000e234 <[^>]*> nop
++0000e238 <[^>]*> nop
++0000e23c <[^>]*> nop
++0000e240 <[^>]*> nop
++0000e244 <[^>]*> nop
++0000e248 <[^>]*> nop
++0000e24c <[^>]*> nop
++0000e250 <[^>]*> nop
++0000e254 <[^>]*> nop
++0000e258 <[^>]*> nop
++0000e25c <[^>]*> nop
++0000e260 <[^>]*> nop
++0000e264 <[^>]*> nop
++0000e268 <[^>]*> nop
++0000e26c <[^>]*> nop
++0000e270 <[^>]*> nop
++0000e274 <[^>]*> nop
++0000e278 <[^>]*> nop
++0000e27c <[^>]*> nop
++0000e280 <[^>]*> nop
++0000e284 <[^>]*> nop
++0000e288 <[^>]*> nop
++0000e28c <[^>]*> nop
++0000e290 <[^>]*> nop
++0000e294 <[^>]*> nop
++0000e298 <[^>]*> nop
++0000e29c <[^>]*> nop
++0000e2a0 <[^>]*> nop
++0000e2a4 <[^>]*> nop
++0000e2a8 <[^>]*> nop
++0000e2ac <[^>]*> nop
++0000e2b0 <[^>]*> nop
++0000e2b4 <[^>]*> nop
++0000e2b8 <[^>]*> nop
++0000e2bc <[^>]*> nop
++0000e2c0 <[^>]*> nop
++0000e2c4 <[^>]*> nop
++0000e2c8 <[^>]*> nop
++0000e2cc <[^>]*> nop
++0000e2d0 <[^>]*> nop
++0000e2d4 <[^>]*> nop
++0000e2d8 <[^>]*> nop
++0000e2dc <[^>]*> nop
++0000e2e0 <[^>]*> nop
++0000e2e4 <[^>]*> nop
++0000e2e8 <[^>]*> nop
++0000e2ec <[^>]*> nop
++0000e2f0 <[^>]*> nop
++0000e2f4 <[^>]*> nop
++0000e2f8 <[^>]*> nop
++0000e2fc <[^>]*> nop
++0000e300 <[^>]*> nop
++0000e304 <[^>]*> nop
++0000e308 <[^>]*> nop
++0000e30c <[^>]*> nop
++0000e310 <[^>]*> nop
++0000e314 <[^>]*> nop
++0000e318 <[^>]*> nop
++0000e31c <[^>]*> nop
++0000e320 <[^>]*> nop
++0000e324 <[^>]*> nop
++0000e328 <[^>]*> nop
++0000e32c <[^>]*> nop
++0000e330 <[^>]*> nop
++0000e334 <[^>]*> nop
++0000e338 <[^>]*> nop
++0000e33c <[^>]*> nop
++0000e340 <[^>]*> nop
++0000e344 <[^>]*> nop
++0000e348 <[^>]*> nop
++0000e34c <[^>]*> nop
++0000e350 <[^>]*> nop
++0000e354 <[^>]*> nop
++0000e358 <[^>]*> nop
++0000e35c <[^>]*> nop
++0000e360 <[^>]*> nop
++0000e364 <[^>]*> nop
++0000e368 <[^>]*> nop
++0000e36c <[^>]*> nop
++0000e370 <[^>]*> nop
++0000e374 <[^>]*> nop
++0000e378 <[^>]*> nop
++0000e37c <[^>]*> nop
++0000e380 <[^>]*> nop
++0000e384 <[^>]*> nop
++0000e388 <[^>]*> nop
++0000e38c <[^>]*> nop
++0000e390 <[^>]*> nop
++0000e394 <[^>]*> nop
++0000e398 <[^>]*> nop
++0000e39c <[^>]*> nop
++0000e3a0 <[^>]*> nop
++0000e3a4 <[^>]*> nop
++0000e3a8 <[^>]*> nop
++0000e3ac <[^>]*> nop
++0000e3b0 <[^>]*> nop
++0000e3b4 <[^>]*> nop
++0000e3b8 <[^>]*> nop
++0000e3bc <[^>]*> nop
++0000e3c0 <[^>]*> nop
++0000e3c4 <[^>]*> nop
++0000e3c8 <[^>]*> nop
++0000e3cc <[^>]*> nop
++0000e3d0 <[^>]*> nop
++0000e3d4 <[^>]*> nop
++0000e3d8 <[^>]*> nop
++0000e3dc <[^>]*> nop
++0000e3e0 <[^>]*> nop
++0000e3e4 <[^>]*> nop
++0000e3e8 <[^>]*> nop
++0000e3ec <[^>]*> nop
++0000e3f0 <[^>]*> nop
++0000e3f4 <[^>]*> nop
++0000e3f8 <[^>]*> nop
++0000e3fc <[^>]*> nop
++0000e400 <[^>]*> nop
++0000e404 <[^>]*> nop
++0000e408 <[^>]*> nop
++0000e40c <[^>]*> nop
++0000e410 <[^>]*> nop
++0000e414 <[^>]*> nop
++0000e418 <[^>]*> nop
++0000e41c <[^>]*> nop
++0000e420 <[^>]*> nop
++0000e424 <[^>]*> nop
++0000e428 <[^>]*> nop
++0000e42c <[^>]*> nop
++0000e430 <[^>]*> nop
++0000e434 <[^>]*> nop
++0000e438 <[^>]*> nop
++0000e43c <[^>]*> nop
++0000e440 <[^>]*> nop
++0000e444 <[^>]*> nop
++0000e448 <[^>]*> nop
++0000e44c <[^>]*> nop
++0000e450 <[^>]*> nop
++0000e454 <[^>]*> nop
++0000e458 <[^>]*> nop
++0000e45c <[^>]*> nop
++0000e460 <[^>]*> nop
++0000e464 <[^>]*> nop
++0000e468 <[^>]*> nop
++0000e46c <[^>]*> nop
++0000e470 <[^>]*> nop
++0000e474 <[^>]*> nop
++0000e478 <[^>]*> nop
++0000e47c <[^>]*> nop
++0000e480 <[^>]*> nop
++0000e484 <[^>]*> nop
++0000e488 <[^>]*> nop
++0000e48c <[^>]*> nop
++0000e490 <[^>]*> nop
++0000e494 <[^>]*> nop
++0000e498 <[^>]*> nop
++0000e49c <[^>]*> nop
++0000e4a0 <[^>]*> nop
++0000e4a4 <[^>]*> nop
++0000e4a8 <[^>]*> nop
++0000e4ac <[^>]*> nop
++0000e4b0 <[^>]*> nop
++0000e4b4 <[^>]*> nop
++0000e4b8 <[^>]*> nop
++0000e4bc <[^>]*> nop
++0000e4c0 <[^>]*> nop
++0000e4c4 <[^>]*> nop
++0000e4c8 <[^>]*> nop
++0000e4cc <[^>]*> nop
++0000e4d0 <[^>]*> nop
++0000e4d4 <[^>]*> nop
++0000e4d8 <[^>]*> nop
++0000e4dc <[^>]*> nop
++0000e4e0 <[^>]*> nop
++0000e4e4 <[^>]*> nop
++0000e4e8 <[^>]*> nop
++0000e4ec <[^>]*> nop
++0000e4f0 <[^>]*> nop
++0000e4f4 <[^>]*> nop
++0000e4f8 <[^>]*> nop
++0000e4fc <[^>]*> nop
++0000e500 <[^>]*> nop
++0000e504 <[^>]*> nop
++0000e508 <[^>]*> nop
++0000e50c <[^>]*> nop
++0000e510 <[^>]*> nop
++0000e514 <[^>]*> nop
++0000e518 <[^>]*> nop
++0000e51c <[^>]*> nop
++0000e520 <[^>]*> nop
++0000e524 <[^>]*> nop
++0000e528 <[^>]*> nop
++0000e52c <[^>]*> nop
++0000e530 <[^>]*> nop
++0000e534 <[^>]*> nop
++0000e538 <[^>]*> nop
++0000e53c <[^>]*> nop
++0000e540 <[^>]*> nop
++0000e544 <[^>]*> nop
++0000e548 <[^>]*> nop
++0000e54c <[^>]*> nop
++0000e550 <[^>]*> nop
++0000e554 <[^>]*> nop
++0000e558 <[^>]*> nop
++0000e55c <[^>]*> nop
++0000e560 <[^>]*> nop
++0000e564 <[^>]*> nop
++0000e568 <[^>]*> nop
++0000e56c <[^>]*> nop
++0000e570 <[^>]*> nop
++0000e574 <[^>]*> nop
++0000e578 <[^>]*> nop
++0000e57c <[^>]*> nop
++0000e580 <[^>]*> nop
++0000e584 <[^>]*> nop
++0000e588 <[^>]*> nop
++0000e58c <[^>]*> nop
++0000e590 <[^>]*> nop
++0000e594 <[^>]*> nop
++0000e598 <[^>]*> nop
++0000e59c <[^>]*> nop
++0000e5a0 <[^>]*> nop
++0000e5a4 <[^>]*> nop
++0000e5a8 <[^>]*> nop
++0000e5ac <[^>]*> nop
++0000e5b0 <[^>]*> nop
++0000e5b4 <[^>]*> nop
++0000e5b8 <[^>]*> nop
++0000e5bc <[^>]*> nop
++0000e5c0 <[^>]*> nop
++0000e5c4 <[^>]*> nop
++0000e5c8 <[^>]*> nop
++0000e5cc <[^>]*> nop
++0000e5d0 <[^>]*> nop
++0000e5d4 <[^>]*> nop
++0000e5d8 <[^>]*> nop
++0000e5dc <[^>]*> nop
++0000e5e0 <[^>]*> nop
++0000e5e4 <[^>]*> nop
++0000e5e8 <[^>]*> nop
++0000e5ec <[^>]*> nop
++0000e5f0 <[^>]*> nop
++0000e5f4 <[^>]*> nop
++0000e5f8 <[^>]*> nop
++0000e5fc <[^>]*> nop
++0000e600 <[^>]*> nop
++0000e604 <[^>]*> nop
++0000e608 <[^>]*> nop
++0000e60c <[^>]*> nop
++0000e610 <[^>]*> nop
++0000e614 <[^>]*> nop
++0000e618 <[^>]*> nop
++0000e61c <[^>]*> nop
++0000e620 <[^>]*> nop
++0000e624 <[^>]*> nop
++0000e628 <[^>]*> nop
++0000e62c <[^>]*> nop
++0000e630 <[^>]*> nop
++0000e634 <[^>]*> nop
++0000e638 <[^>]*> nop
++0000e63c <[^>]*> nop
++0000e640 <[^>]*> nop
++0000e644 <[^>]*> nop
++0000e648 <[^>]*> nop
++0000e64c <[^>]*> nop
++0000e650 <[^>]*> nop
++0000e654 <[^>]*> nop
++0000e658 <[^>]*> nop
++0000e65c <[^>]*> nop
++0000e660 <[^>]*> nop
++0000e664 <[^>]*> nop
++0000e668 <[^>]*> nop
++0000e66c <[^>]*> nop
++0000e670 <[^>]*> nop
++0000e674 <[^>]*> nop
++0000e678 <[^>]*> nop
++0000e67c <[^>]*> nop
++0000e680 <[^>]*> nop
++0000e684 <[^>]*> nop
++0000e688 <[^>]*> nop
++0000e68c <[^>]*> nop
++0000e690 <[^>]*> nop
++0000e694 <[^>]*> nop
++0000e698 <[^>]*> nop
++0000e69c <[^>]*> nop
++0000e6a0 <[^>]*> nop
++0000e6a4 <[^>]*> nop
++0000e6a8 <[^>]*> nop
++0000e6ac <[^>]*> nop
++0000e6b0 <[^>]*> nop
++0000e6b4 <[^>]*> nop
++0000e6b8 <[^>]*> nop
++0000e6bc <[^>]*> nop
++0000e6c0 <[^>]*> nop
++0000e6c4 <[^>]*> nop
++0000e6c8 <[^>]*> nop
++0000e6cc <[^>]*> nop
++0000e6d0 <[^>]*> nop
++0000e6d4 <[^>]*> nop
++0000e6d8 <[^>]*> nop
++0000e6dc <[^>]*> nop
++0000e6e0 <[^>]*> nop
++0000e6e4 <[^>]*> nop
++0000e6e8 <[^>]*> nop
++0000e6ec <[^>]*> nop
++0000e6f0 <[^>]*> nop
++0000e6f4 <[^>]*> nop
++0000e6f8 <[^>]*> nop
++0000e6fc <[^>]*> nop
++0000e700 <[^>]*> nop
++0000e704 <[^>]*> nop
++0000e708 <[^>]*> nop
++0000e70c <[^>]*> nop
++0000e710 <[^>]*> nop
++0000e714 <[^>]*> nop
++0000e718 <[^>]*> nop
++0000e71c <[^>]*> nop
++0000e720 <[^>]*> nop
++0000e724 <[^>]*> nop
++0000e728 <[^>]*> nop
++0000e72c <[^>]*> nop
++0000e730 <[^>]*> nop
++0000e734 <[^>]*> nop
++0000e738 <[^>]*> nop
++0000e73c <[^>]*> nop
++0000e740 <[^>]*> nop
++0000e744 <[^>]*> nop
++0000e748 <[^>]*> nop
++0000e74c <[^>]*> nop
++0000e750 <[^>]*> nop
++0000e754 <[^>]*> nop
++0000e758 <[^>]*> nop
++0000e75c <[^>]*> nop
++0000e760 <[^>]*> nop
++0000e764 <[^>]*> nop
++0000e768 <[^>]*> nop
++0000e76c <[^>]*> nop
++0000e770 <[^>]*> nop
++0000e774 <[^>]*> nop
++0000e778 <[^>]*> nop
++0000e77c <[^>]*> nop
++0000e780 <[^>]*> nop
++0000e784 <[^>]*> nop
++0000e788 <[^>]*> nop
++0000e78c <[^>]*> nop
++0000e790 <[^>]*> nop
++0000e794 <[^>]*> nop
++0000e798 <[^>]*> nop
++0000e79c <[^>]*> nop
++0000e7a0 <[^>]*> nop
++0000e7a4 <[^>]*> nop
++0000e7a8 <[^>]*> nop
++0000e7ac <[^>]*> nop
++0000e7b0 <[^>]*> nop
++0000e7b4 <[^>]*> nop
++0000e7b8 <[^>]*> nop
++0000e7bc <[^>]*> nop
++0000e7c0 <[^>]*> nop
++0000e7c4 <[^>]*> nop
++0000e7c8 <[^>]*> nop
++0000e7cc <[^>]*> nop
++0000e7d0 <[^>]*> nop
++0000e7d4 <[^>]*> nop
++0000e7d8 <[^>]*> nop
++0000e7dc <[^>]*> nop
++0000e7e0 <[^>]*> nop
++0000e7e4 <[^>]*> nop
++0000e7e8 <[^>]*> nop
++0000e7ec <[^>]*> nop
++0000e7f0 <[^>]*> nop
++0000e7f4 <[^>]*> nop
++0000e7f8 <[^>]*> nop
++0000e7fc <[^>]*> nop
++0000e800 <[^>]*> nop
++0000e804 <[^>]*> nop
++0000e808 <[^>]*> nop
++0000e80c <[^>]*> nop
++0000e810 <[^>]*> nop
++0000e814 <[^>]*> nop
++0000e818 <[^>]*> nop
++0000e81c <[^>]*> nop
++0000e820 <[^>]*> nop
++0000e824 <[^>]*> nop
++0000e828 <[^>]*> nop
++0000e82c <[^>]*> nop
++0000e830 <[^>]*> nop
++0000e834 <[^>]*> nop
++0000e838 <[^>]*> nop
++0000e83c <[^>]*> nop
++0000e840 <[^>]*> nop
++0000e844 <[^>]*> nop
++0000e848 <[^>]*> nop
++0000e84c <[^>]*> nop
++0000e850 <[^>]*> nop
++0000e854 <[^>]*> nop
++0000e858 <[^>]*> nop
++0000e85c <[^>]*> nop
++0000e860 <[^>]*> nop
++0000e864 <[^>]*> nop
++0000e868 <[^>]*> nop
++0000e86c <[^>]*> nop
++0000e870 <[^>]*> nop
++0000e874 <[^>]*> nop
++0000e878 <[^>]*> nop
++0000e87c <[^>]*> nop
++0000e880 <[^>]*> nop
++0000e884 <[^>]*> nop
++0000e888 <[^>]*> nop
++0000e88c <[^>]*> nop
++0000e890 <[^>]*> nop
++0000e894 <[^>]*> nop
++0000e898 <[^>]*> nop
++0000e89c <[^>]*> nop
++0000e8a0 <[^>]*> nop
++0000e8a4 <[^>]*> nop
++0000e8a8 <[^>]*> nop
++0000e8ac <[^>]*> nop
++0000e8b0 <[^>]*> nop
++0000e8b4 <[^>]*> nop
++0000e8b8 <[^>]*> nop
++0000e8bc <[^>]*> nop
++0000e8c0 <[^>]*> nop
++0000e8c4 <[^>]*> nop
++0000e8c8 <[^>]*> nop
++0000e8cc <[^>]*> nop
++0000e8d0 <[^>]*> nop
++0000e8d4 <[^>]*> nop
++0000e8d8 <[^>]*> nop
++0000e8dc <[^>]*> nop
++0000e8e0 <[^>]*> nop
++0000e8e4 <[^>]*> nop
++0000e8e8 <[^>]*> nop
++0000e8ec <[^>]*> nop
++0000e8f0 <[^>]*> nop
++0000e8f4 <[^>]*> nop
++0000e8f8 <[^>]*> nop
++0000e8fc <[^>]*> nop
++0000e900 <[^>]*> nop
++0000e904 <[^>]*> nop
++0000e908 <[^>]*> nop
++0000e90c <[^>]*> nop
++0000e910 <[^>]*> nop
++0000e914 <[^>]*> nop
++0000e918 <[^>]*> nop
++0000e91c <[^>]*> nop
++0000e920 <[^>]*> nop
++0000e924 <[^>]*> nop
++0000e928 <[^>]*> nop
++0000e92c <[^>]*> nop
++0000e930 <[^>]*> nop
++0000e934 <[^>]*> nop
++0000e938 <[^>]*> nop
++0000e93c <[^>]*> nop
++0000e940 <[^>]*> nop
++0000e944 <[^>]*> nop
++0000e948 <[^>]*> nop
++0000e94c <[^>]*> nop
++0000e950 <[^>]*> nop
++0000e954 <[^>]*> nop
++0000e958 <[^>]*> nop
++0000e95c <[^>]*> nop
++0000e960 <[^>]*> nop
++0000e964 <[^>]*> nop
++0000e968 <[^>]*> nop
++0000e96c <[^>]*> nop
++0000e970 <[^>]*> nop
++0000e974 <[^>]*> nop
++0000e978 <[^>]*> nop
++0000e97c <[^>]*> nop
++0000e980 <[^>]*> nop
++0000e984 <[^>]*> nop
++0000e988 <[^>]*> nop
++0000e98c <[^>]*> nop
++0000e990 <[^>]*> nop
++0000e994 <[^>]*> nop
++0000e998 <[^>]*> nop
++0000e99c <[^>]*> nop
++0000e9a0 <[^>]*> nop
++0000e9a4 <[^>]*> nop
++0000e9a8 <[^>]*> nop
++0000e9ac <[^>]*> nop
++0000e9b0 <[^>]*> nop
++0000e9b4 <[^>]*> nop
++0000e9b8 <[^>]*> nop
++0000e9bc <[^>]*> nop
++0000e9c0 <[^>]*> nop
++0000e9c4 <[^>]*> nop
++0000e9c8 <[^>]*> nop
++0000e9cc <[^>]*> nop
++0000e9d0 <[^>]*> nop
++0000e9d4 <[^>]*> nop
++0000e9d8 <[^>]*> nop
++0000e9dc <[^>]*> nop
++0000e9e0 <[^>]*> nop
++0000e9e4 <[^>]*> nop
++0000e9e8 <[^>]*> nop
++0000e9ec <[^>]*> nop
++0000e9f0 <[^>]*> nop
++0000e9f4 <[^>]*> nop
++0000e9f8 <[^>]*> nop
++0000e9fc <[^>]*> nop
++0000ea00 <[^>]*> nop
++0000ea04 <[^>]*> nop
++0000ea08 <[^>]*> nop
++0000ea0c <[^>]*> nop
++0000ea10 <[^>]*> nop
++0000ea14 <[^>]*> nop
++0000ea18 <[^>]*> nop
++0000ea1c <[^>]*> nop
++0000ea20 <[^>]*> nop
++0000ea24 <[^>]*> nop
++0000ea28 <[^>]*> nop
++0000ea2c <[^>]*> nop
++0000ea30 <[^>]*> nop
++0000ea34 <[^>]*> nop
++0000ea38 <[^>]*> nop
++0000ea3c <[^>]*> nop
++0000ea40 <[^>]*> nop
++0000ea44 <[^>]*> nop
++0000ea48 <[^>]*> nop
++0000ea4c <[^>]*> nop
++0000ea50 <[^>]*> nop
++0000ea54 <[^>]*> nop
++0000ea58 <[^>]*> nop
++0000ea5c <[^>]*> nop
++0000ea60 <[^>]*> nop
++0000ea64 <[^>]*> nop
++0000ea68 <[^>]*> nop
++0000ea6c <[^>]*> nop
++0000ea70 <[^>]*> nop
++0000ea74 <[^>]*> nop
++0000ea78 <[^>]*> nop
++0000ea7c <[^>]*> nop
++0000ea80 <[^>]*> nop
++0000ea84 <[^>]*> nop
++0000ea88 <[^>]*> nop
++0000ea8c <[^>]*> nop
++0000ea90 <[^>]*> nop
++0000ea94 <[^>]*> nop
++0000ea98 <[^>]*> nop
++0000ea9c <[^>]*> nop
++0000eaa0 <[^>]*> nop
++0000eaa4 <[^>]*> nop
++0000eaa8 <[^>]*> nop
++0000eaac <[^>]*> nop
++0000eab0 <[^>]*> nop
++0000eab4 <[^>]*> nop
++0000eab8 <[^>]*> nop
++0000eabc <[^>]*> nop
++0000eac0 <[^>]*> nop
++0000eac4 <[^>]*> nop
++0000eac8 <[^>]*> nop
++0000eacc <[^>]*> nop
++0000ead0 <[^>]*> nop
++0000ead4 <[^>]*> nop
++0000ead8 <[^>]*> nop
++0000eadc <[^>]*> nop
++0000eae0 <[^>]*> nop
++0000eae4 <[^>]*> nop
++0000eae8 <[^>]*> nop
++0000eaec <[^>]*> nop
++0000eaf0 <[^>]*> nop
++0000eaf4 <[^>]*> nop
++0000eaf8 <[^>]*> nop
++0000eafc <[^>]*> nop
++0000eb00 <[^>]*> nop
++0000eb04 <[^>]*> nop
++0000eb08 <[^>]*> nop
++0000eb0c <[^>]*> nop
++0000eb10 <[^>]*> nop
++0000eb14 <[^>]*> nop
++0000eb18 <[^>]*> nop
++0000eb1c <[^>]*> nop
++0000eb20 <[^>]*> nop
++0000eb24 <[^>]*> nop
++0000eb28 <[^>]*> nop
++0000eb2c <[^>]*> nop
++0000eb30 <[^>]*> nop
++0000eb34 <[^>]*> nop
++0000eb38 <[^>]*> nop
++0000eb3c <[^>]*> nop
++0000eb40 <[^>]*> nop
++0000eb44 <[^>]*> nop
++0000eb48 <[^>]*> nop
++0000eb4c <[^>]*> nop
++0000eb50 <[^>]*> nop
++0000eb54 <[^>]*> nop
++0000eb58 <[^>]*> nop
++0000eb5c <[^>]*> nop
++0000eb60 <[^>]*> nop
++0000eb64 <[^>]*> nop
++0000eb68 <[^>]*> nop
++0000eb6c <[^>]*> nop
++0000eb70 <[^>]*> nop
++0000eb74 <[^>]*> nop
++0000eb78 <[^>]*> nop
++0000eb7c <[^>]*> nop
++0000eb80 <[^>]*> nop
++0000eb84 <[^>]*> nop
++0000eb88 <[^>]*> nop
++0000eb8c <[^>]*> nop
++0000eb90 <[^>]*> nop
++0000eb94 <[^>]*> nop
++0000eb98 <[^>]*> nop
++0000eb9c <[^>]*> nop
++0000eba0 <[^>]*> nop
++0000eba4 <[^>]*> nop
++0000eba8 <[^>]*> nop
++0000ebac <[^>]*> nop
++0000ebb0 <[^>]*> nop
++0000ebb4 <[^>]*> nop
++0000ebb8 <[^>]*> nop
++0000ebbc <[^>]*> nop
++0000ebc0 <[^>]*> nop
++0000ebc4 <[^>]*> nop
++0000ebc8 <[^>]*> nop
++0000ebcc <[^>]*> nop
++0000ebd0 <[^>]*> nop
++0000ebd4 <[^>]*> nop
++0000ebd8 <[^>]*> nop
++0000ebdc <[^>]*> nop
++0000ebe0 <[^>]*> nop
++0000ebe4 <[^>]*> nop
++0000ebe8 <[^>]*> nop
++0000ebec <[^>]*> nop
++0000ebf0 <[^>]*> nop
++0000ebf4 <[^>]*> nop
++0000ebf8 <[^>]*> nop
++0000ebfc <[^>]*> nop
++0000ec00 <[^>]*> nop
++0000ec04 <[^>]*> nop
++0000ec08 <[^>]*> nop
++0000ec0c <[^>]*> nop
++0000ec10 <[^>]*> nop
++0000ec14 <[^>]*> nop
++0000ec18 <[^>]*> nop
++0000ec1c <[^>]*> nop
++0000ec20 <[^>]*> nop
++0000ec24 <[^>]*> nop
++0000ec28 <[^>]*> nop
++0000ec2c <[^>]*> nop
++0000ec30 <[^>]*> nop
++0000ec34 <[^>]*> nop
++0000ec38 <[^>]*> nop
++0000ec3c <[^>]*> nop
++0000ec40 <[^>]*> nop
++0000ec44 <[^>]*> nop
++0000ec48 <[^>]*> nop
++0000ec4c <[^>]*> nop
++0000ec50 <[^>]*> nop
++0000ec54 <[^>]*> nop
++0000ec58 <[^>]*> nop
++0000ec5c <[^>]*> nop
++0000ec60 <[^>]*> nop
++0000ec64 <[^>]*> nop
++0000ec68 <[^>]*> nop
++0000ec6c <[^>]*> nop
++0000ec70 <[^>]*> nop
++0000ec74 <[^>]*> nop
++0000ec78 <[^>]*> nop
++0000ec7c <[^>]*> nop
++0000ec80 <[^>]*> nop
++0000ec84 <[^>]*> nop
++0000ec88 <[^>]*> nop
++0000ec8c <[^>]*> nop
++0000ec90 <[^>]*> nop
++0000ec94 <[^>]*> nop
++0000ec98 <[^>]*> nop
++0000ec9c <[^>]*> nop
++0000eca0 <[^>]*> nop
++0000eca4 <[^>]*> nop
++0000eca8 <[^>]*> nop
++0000ecac <[^>]*> nop
++0000ecb0 <[^>]*> nop
++0000ecb4 <[^>]*> nop
++0000ecb8 <[^>]*> nop
++0000ecbc <[^>]*> nop
++0000ecc0 <[^>]*> nop
++0000ecc4 <[^>]*> nop
++0000ecc8 <[^>]*> nop
++0000eccc <[^>]*> nop
++0000ecd0 <[^>]*> nop
++0000ecd4 <[^>]*> nop
++0000ecd8 <[^>]*> nop
++0000ecdc <[^>]*> nop
++0000ece0 <[^>]*> nop
++0000ece4 <[^>]*> nop
++0000ece8 <[^>]*> nop
++0000ecec <[^>]*> nop
++0000ecf0 <[^>]*> nop
++0000ecf4 <[^>]*> nop
++0000ecf8 <[^>]*> nop
++0000ecfc <[^>]*> nop
++0000ed00 <[^>]*> nop
++0000ed04 <[^>]*> nop
++0000ed08 <[^>]*> nop
++0000ed0c <[^>]*> nop
++0000ed10 <[^>]*> nop
++0000ed14 <[^>]*> nop
++0000ed18 <[^>]*> nop
++0000ed1c <[^>]*> nop
++0000ed20 <[^>]*> nop
++0000ed24 <[^>]*> nop
++0000ed28 <[^>]*> nop
++0000ed2c <[^>]*> nop
++0000ed30 <[^>]*> nop
++0000ed34 <[^>]*> nop
++0000ed38 <[^>]*> nop
++0000ed3c <[^>]*> nop
++0000ed40 <[^>]*> nop
++0000ed44 <[^>]*> nop
++0000ed48 <[^>]*> nop
++0000ed4c <[^>]*> nop
++0000ed50 <[^>]*> nop
++0000ed54 <[^>]*> nop
++0000ed58 <[^>]*> nop
++0000ed5c <[^>]*> nop
++0000ed60 <[^>]*> nop
++0000ed64 <[^>]*> nop
++0000ed68 <[^>]*> nop
++0000ed6c <[^>]*> nop
++0000ed70 <[^>]*> nop
++0000ed74 <[^>]*> nop
++0000ed78 <[^>]*> nop
++0000ed7c <[^>]*> nop
++0000ed80 <[^>]*> nop
++0000ed84 <[^>]*> nop
++0000ed88 <[^>]*> nop
++0000ed8c <[^>]*> nop
++0000ed90 <[^>]*> nop
++0000ed94 <[^>]*> nop
++0000ed98 <[^>]*> nop
++0000ed9c <[^>]*> nop
++0000eda0 <[^>]*> nop
++0000eda4 <[^>]*> nop
++0000eda8 <[^>]*> nop
++0000edac <[^>]*> nop
++0000edb0 <[^>]*> nop
++0000edb4 <[^>]*> nop
++0000edb8 <[^>]*> nop
++0000edbc <[^>]*> nop
++0000edc0 <[^>]*> nop
++0000edc4 <[^>]*> nop
++0000edc8 <[^>]*> nop
++0000edcc <[^>]*> nop
++0000edd0 <[^>]*> nop
++0000edd4 <[^>]*> nop
++0000edd8 <[^>]*> nop
++0000eddc <[^>]*> nop
++0000ede0 <[^>]*> nop
++0000ede4 <[^>]*> nop
++0000ede8 <[^>]*> nop
++0000edec <[^>]*> nop
++0000edf0 <[^>]*> nop
++0000edf4 <[^>]*> nop
++0000edf8 <[^>]*> nop
++0000edfc <[^>]*> nop
++0000ee00 <[^>]*> nop
++0000ee04 <[^>]*> nop
++0000ee08 <[^>]*> nop
++0000ee0c <[^>]*> nop
++0000ee10 <[^>]*> nop
++0000ee14 <[^>]*> nop
++0000ee18 <[^>]*> nop
++0000ee1c <[^>]*> nop
++0000ee20 <[^>]*> nop
++0000ee24 <[^>]*> nop
++0000ee28 <[^>]*> nop
++0000ee2c <[^>]*> nop
++0000ee30 <[^>]*> nop
++0000ee34 <[^>]*> nop
++0000ee38 <[^>]*> nop
++0000ee3c <[^>]*> nop
++0000ee40 <[^>]*> nop
++0000ee44 <[^>]*> nop
++0000ee48 <[^>]*> nop
++0000ee4c <[^>]*> nop
++0000ee50 <[^>]*> nop
++0000ee54 <[^>]*> nop
++0000ee58 <[^>]*> nop
++0000ee5c <[^>]*> nop
++0000ee60 <[^>]*> nop
++0000ee64 <[^>]*> nop
++0000ee68 <[^>]*> nop
++0000ee6c <[^>]*> nop
++0000ee70 <[^>]*> nop
++0000ee74 <[^>]*> nop
++0000ee78 <[^>]*> nop
++0000ee7c <[^>]*> nop
++0000ee80 <[^>]*> nop
++0000ee84 <[^>]*> nop
++0000ee88 <[^>]*> nop
++0000ee8c <[^>]*> nop
++0000ee90 <[^>]*> nop
++0000ee94 <[^>]*> nop
++0000ee98 <[^>]*> nop
++0000ee9c <[^>]*> nop
++0000eea0 <[^>]*> nop
++0000eea4 <[^>]*> nop
++0000eea8 <[^>]*> nop
++0000eeac <[^>]*> nop
++0000eeb0 <[^>]*> nop
++0000eeb4 <[^>]*> nop
++0000eeb8 <[^>]*> nop
++0000eebc <[^>]*> nop
++0000eec0 <[^>]*> nop
++0000eec4 <[^>]*> nop
++0000eec8 <[^>]*> nop
++0000eecc <[^>]*> nop
++0000eed0 <[^>]*> nop
++0000eed4 <[^>]*> nop
++0000eed8 <[^>]*> nop
++0000eedc <[^>]*> nop
++0000eee0 <[^>]*> nop
++0000eee4 <[^>]*> nop
++0000eee8 <[^>]*> nop
++0000eeec <[^>]*> nop
++0000eef0 <[^>]*> nop
++0000eef4 <[^>]*> nop
++0000eef8 <[^>]*> nop
++0000eefc <[^>]*> nop
++0000ef00 <[^>]*> nop
++0000ef04 <[^>]*> nop
++0000ef08 <[^>]*> nop
++0000ef0c <[^>]*> nop
++0000ef10 <[^>]*> nop
++0000ef14 <[^>]*> nop
++0000ef18 <[^>]*> nop
++0000ef1c <[^>]*> nop
++0000ef20 <[^>]*> nop
++0000ef24 <[^>]*> nop
++0000ef28 <[^>]*> nop
++0000ef2c <[^>]*> nop
++0000ef30 <[^>]*> nop
++0000ef34 <[^>]*> nop
++0000ef38 <[^>]*> nop
++0000ef3c <[^>]*> nop
++0000ef40 <[^>]*> nop
++0000ef44 <[^>]*> nop
++0000ef48 <[^>]*> nop
++0000ef4c <[^>]*> nop
++0000ef50 <[^>]*> nop
++0000ef54 <[^>]*> nop
++0000ef58 <[^>]*> nop
++0000ef5c <[^>]*> nop
++0000ef60 <[^>]*> nop
++0000ef64 <[^>]*> nop
++0000ef68 <[^>]*> nop
++0000ef6c <[^>]*> nop
++0000ef70 <[^>]*> nop
++0000ef74 <[^>]*> nop
++0000ef78 <[^>]*> nop
++0000ef7c <[^>]*> nop
++0000ef80 <[^>]*> nop
++0000ef84 <[^>]*> nop
++0000ef88 <[^>]*> nop
++0000ef8c <[^>]*> nop
++0000ef90 <[^>]*> nop
++0000ef94 <[^>]*> nop
++0000ef98 <[^>]*> nop
++0000ef9c <[^>]*> nop
++0000efa0 <[^>]*> nop
++0000efa4 <[^>]*> nop
++0000efa8 <[^>]*> nop
++0000efac <[^>]*> nop
++0000efb0 <[^>]*> nop
++0000efb4 <[^>]*> nop
++0000efb8 <[^>]*> nop
++0000efbc <[^>]*> nop
++0000efc0 <[^>]*> nop
++0000efc4 <[^>]*> nop
++0000efc8 <[^>]*> nop
++0000efcc <[^>]*> nop
++0000efd0 <[^>]*> nop
++0000efd4 <[^>]*> nop
++0000efd8 <[^>]*> nop
++0000efdc <[^>]*> nop
++0000efe0 <[^>]*> nop
++0000efe4 <[^>]*> nop
++0000efe8 <[^>]*> nop
++0000efec <[^>]*> nop
++0000eff0 <[^>]*> nop
++0000eff4 <[^>]*> nop
++0000eff8 <[^>]*> nop
++0000effc <[^>]*> nop
++0000f000 <[^>]*> nop
++0000f004 <[^>]*> nop
++0000f008 <[^>]*> nop
++0000f00c <[^>]*> nop
++0000f010 <[^>]*> nop
++0000f014 <[^>]*> nop
++0000f018 <[^>]*> nop
++0000f01c <[^>]*> nop
++0000f020 <[^>]*> nop
++0000f024 <[^>]*> nop
++0000f028 <[^>]*> nop
++0000f02c <[^>]*> nop
++0000f030 <[^>]*> nop
++0000f034 <[^>]*> nop
++0000f038 <[^>]*> nop
++0000f03c <[^>]*> nop
++0000f040 <[^>]*> nop
++0000f044 <[^>]*> nop
++0000f048 <[^>]*> nop
++0000f04c <[^>]*> nop
++0000f050 <[^>]*> nop
++0000f054 <[^>]*> nop
++0000f058 <[^>]*> nop
++0000f05c <[^>]*> nop
++0000f060 <[^>]*> nop
++0000f064 <[^>]*> nop
++0000f068 <[^>]*> nop
++0000f06c <[^>]*> nop
++0000f070 <[^>]*> nop
++0000f074 <[^>]*> nop
++0000f078 <[^>]*> nop
++0000f07c <[^>]*> nop
++0000f080 <[^>]*> nop
++0000f084 <[^>]*> nop
++0000f088 <[^>]*> nop
++0000f08c <[^>]*> nop
++0000f090 <[^>]*> nop
++0000f094 <[^>]*> nop
++0000f098 <[^>]*> nop
++0000f09c <[^>]*> nop
++0000f0a0 <[^>]*> nop
++0000f0a4 <[^>]*> nop
++0000f0a8 <[^>]*> nop
++0000f0ac <[^>]*> nop
++0000f0b0 <[^>]*> nop
++0000f0b4 <[^>]*> nop
++0000f0b8 <[^>]*> nop
++0000f0bc <[^>]*> nop
++0000f0c0 <[^>]*> nop
++0000f0c4 <[^>]*> nop
++0000f0c8 <[^>]*> nop
++0000f0cc <[^>]*> nop
++0000f0d0 <[^>]*> nop
++0000f0d4 <[^>]*> nop
++0000f0d8 <[^>]*> nop
++0000f0dc <[^>]*> nop
++0000f0e0 <[^>]*> nop
++0000f0e4 <[^>]*> nop
++0000f0e8 <[^>]*> nop
++0000f0ec <[^>]*> nop
++0000f0f0 <[^>]*> nop
++0000f0f4 <[^>]*> nop
++0000f0f8 <[^>]*> nop
++0000f0fc <[^>]*> nop
++0000f100 <[^>]*> nop
++0000f104 <[^>]*> nop
++0000f108 <[^>]*> nop
++0000f10c <[^>]*> nop
++0000f110 <[^>]*> nop
++0000f114 <[^>]*> nop
++0000f118 <[^>]*> nop
++0000f11c <[^>]*> nop
++0000f120 <[^>]*> nop
++0000f124 <[^>]*> nop
++0000f128 <[^>]*> nop
++0000f12c <[^>]*> nop
++0000f130 <[^>]*> nop
++0000f134 <[^>]*> nop
++0000f138 <[^>]*> nop
++0000f13c <[^>]*> nop
++0000f140 <[^>]*> nop
++0000f144 <[^>]*> nop
++0000f148 <[^>]*> nop
++0000f14c <[^>]*> nop
++0000f150 <[^>]*> nop
++0000f154 <[^>]*> nop
++0000f158 <[^>]*> nop
++0000f15c <[^>]*> nop
++0000f160 <[^>]*> nop
++0000f164 <[^>]*> nop
++0000f168 <[^>]*> nop
++0000f16c <[^>]*> nop
++0000f170 <[^>]*> nop
++0000f174 <[^>]*> nop
++0000f178 <[^>]*> nop
++0000f17c <[^>]*> nop
++0000f180 <[^>]*> nop
++0000f184 <[^>]*> nop
++0000f188 <[^>]*> nop
++0000f18c <[^>]*> nop
++0000f190 <[^>]*> nop
++0000f194 <[^>]*> nop
++0000f198 <[^>]*> nop
++0000f19c <[^>]*> nop
++0000f1a0 <[^>]*> nop
++0000f1a4 <[^>]*> nop
++0000f1a8 <[^>]*> nop
++0000f1ac <[^>]*> nop
++0000f1b0 <[^>]*> nop
++0000f1b4 <[^>]*> nop
++0000f1b8 <[^>]*> nop
++0000f1bc <[^>]*> nop
++0000f1c0 <[^>]*> nop
++0000f1c4 <[^>]*> nop
++0000f1c8 <[^>]*> nop
++0000f1cc <[^>]*> nop
++0000f1d0 <[^>]*> nop
++0000f1d4 <[^>]*> nop
++0000f1d8 <[^>]*> nop
++0000f1dc <[^>]*> nop
++0000f1e0 <[^>]*> nop
++0000f1e4 <[^>]*> nop
++0000f1e8 <[^>]*> nop
++0000f1ec <[^>]*> nop
++0000f1f0 <[^>]*> nop
++0000f1f4 <[^>]*> nop
++0000f1f8 <[^>]*> nop
++0000f1fc <[^>]*> nop
++0000f200 <[^>]*> nop
++0000f204 <[^>]*> nop
++0000f208 <[^>]*> nop
++0000f20c <[^>]*> nop
++0000f210 <[^>]*> nop
++0000f214 <[^>]*> nop
++0000f218 <[^>]*> nop
++0000f21c <[^>]*> nop
++0000f220 <[^>]*> nop
++0000f224 <[^>]*> nop
++0000f228 <[^>]*> nop
++0000f22c <[^>]*> nop
++0000f230 <[^>]*> nop
++0000f234 <[^>]*> nop
++0000f238 <[^>]*> nop
++0000f23c <[^>]*> nop
++0000f240 <[^>]*> nop
++0000f244 <[^>]*> nop
++0000f248 <[^>]*> nop
++0000f24c <[^>]*> nop
++0000f250 <[^>]*> nop
++0000f254 <[^>]*> nop
++0000f258 <[^>]*> nop
++0000f25c <[^>]*> nop
++0000f260 <[^>]*> nop
++0000f264 <[^>]*> nop
++0000f268 <[^>]*> nop
++0000f26c <[^>]*> nop
++0000f270 <[^>]*> nop
++0000f274 <[^>]*> nop
++0000f278 <[^>]*> nop
++0000f27c <[^>]*> nop
++0000f280 <[^>]*> nop
++0000f284 <[^>]*> nop
++0000f288 <[^>]*> nop
++0000f28c <[^>]*> nop
++0000f290 <[^>]*> nop
++0000f294 <[^>]*> nop
++0000f298 <[^>]*> nop
++0000f29c <[^>]*> nop
++0000f2a0 <[^>]*> nop
++0000f2a4 <[^>]*> nop
++0000f2a8 <[^>]*> nop
++0000f2ac <[^>]*> nop
++0000f2b0 <[^>]*> nop
++0000f2b4 <[^>]*> nop
++0000f2b8 <[^>]*> nop
++0000f2bc <[^>]*> nop
++0000f2c0 <[^>]*> nop
++0000f2c4 <[^>]*> nop
++0000f2c8 <[^>]*> nop
++0000f2cc <[^>]*> nop
++0000f2d0 <[^>]*> nop
++0000f2d4 <[^>]*> nop
++0000f2d8 <[^>]*> nop
++0000f2dc <[^>]*> nop
++0000f2e0 <[^>]*> nop
++0000f2e4 <[^>]*> nop
++0000f2e8 <[^>]*> nop
++0000f2ec <[^>]*> nop
++0000f2f0 <[^>]*> nop
++0000f2f4 <[^>]*> nop
++0000f2f8 <[^>]*> nop
++0000f2fc <[^>]*> nop
++0000f300 <[^>]*> nop
++0000f304 <[^>]*> nop
++0000f308 <[^>]*> nop
++0000f30c <[^>]*> nop
++0000f310 <[^>]*> nop
++0000f314 <[^>]*> nop
++0000f318 <[^>]*> nop
++0000f31c <[^>]*> nop
++0000f320 <[^>]*> nop
++0000f324 <[^>]*> nop
++0000f328 <[^>]*> nop
++0000f32c <[^>]*> nop
++0000f330 <[^>]*> nop
++0000f334 <[^>]*> nop
++0000f338 <[^>]*> nop
++0000f33c <[^>]*> nop
++0000f340 <[^>]*> nop
++0000f344 <[^>]*> nop
++0000f348 <[^>]*> nop
++0000f34c <[^>]*> nop
++0000f350 <[^>]*> nop
++0000f354 <[^>]*> nop
++0000f358 <[^>]*> nop
++0000f35c <[^>]*> nop
++0000f360 <[^>]*> nop
++0000f364 <[^>]*> nop
++0000f368 <[^>]*> nop
++0000f36c <[^>]*> nop
++0000f370 <[^>]*> nop
++0000f374 <[^>]*> nop
++0000f378 <[^>]*> nop
++0000f37c <[^>]*> nop
++0000f380 <[^>]*> nop
++0000f384 <[^>]*> nop
++0000f388 <[^>]*> nop
++0000f38c <[^>]*> nop
++0000f390 <[^>]*> nop
++0000f394 <[^>]*> nop
++0000f398 <[^>]*> nop
++0000f39c <[^>]*> nop
++0000f3a0 <[^>]*> nop
++0000f3a4 <[^>]*> nop
++0000f3a8 <[^>]*> nop
++0000f3ac <[^>]*> nop
++0000f3b0 <[^>]*> nop
++0000f3b4 <[^>]*> nop
++0000f3b8 <[^>]*> nop
++0000f3bc <[^>]*> nop
++0000f3c0 <[^>]*> nop
++0000f3c4 <[^>]*> nop
++0000f3c8 <[^>]*> nop
++0000f3cc <[^>]*> nop
++0000f3d0 <[^>]*> nop
++0000f3d4 <[^>]*> nop
++0000f3d8 <[^>]*> nop
++0000f3dc <[^>]*> nop
++0000f3e0 <[^>]*> nop
++0000f3e4 <[^>]*> nop
++0000f3e8 <[^>]*> nop
++0000f3ec <[^>]*> nop
++0000f3f0 <[^>]*> nop
++0000f3f4 <[^>]*> nop
++0000f3f8 <[^>]*> nop
++0000f3fc <[^>]*> nop
++0000f400 <[^>]*> nop
++0000f404 <[^>]*> nop
++0000f408 <[^>]*> nop
++0000f40c <[^>]*> nop
++0000f410 <[^>]*> nop
++0000f414 <[^>]*> nop
++0000f418 <[^>]*> nop
++0000f41c <[^>]*> nop
++0000f420 <[^>]*> nop
++0000f424 <[^>]*> nop
++0000f428 <[^>]*> nop
++0000f42c <[^>]*> nop
++0000f430 <[^>]*> nop
++0000f434 <[^>]*> nop
++0000f438 <[^>]*> nop
++0000f43c <[^>]*> nop
++0000f440 <[^>]*> nop
++0000f444 <[^>]*> nop
++0000f448 <[^>]*> nop
++0000f44c <[^>]*> nop
++0000f450 <[^>]*> nop
++0000f454 <[^>]*> nop
++0000f458 <[^>]*> nop
++0000f45c <[^>]*> nop
++0000f460 <[^>]*> nop
++0000f464 <[^>]*> nop
++0000f468 <[^>]*> nop
++0000f46c <[^>]*> nop
++0000f470 <[^>]*> nop
++0000f474 <[^>]*> nop
++0000f478 <[^>]*> nop
++0000f47c <[^>]*> nop
++0000f480 <[^>]*> nop
++0000f484 <[^>]*> nop
++0000f488 <[^>]*> nop
++0000f48c <[^>]*> nop
++0000f490 <[^>]*> nop
++0000f494 <[^>]*> nop
++0000f498 <[^>]*> nop
++0000f49c <[^>]*> nop
++0000f4a0 <[^>]*> nop
++0000f4a4 <[^>]*> nop
++0000f4a8 <[^>]*> nop
++0000f4ac <[^>]*> nop
++0000f4b0 <[^>]*> nop
++0000f4b4 <[^>]*> nop
++0000f4b8 <[^>]*> nop
++0000f4bc <[^>]*> nop
++0000f4c0 <[^>]*> nop
++0000f4c4 <[^>]*> nop
++0000f4c8 <[^>]*> nop
++0000f4cc <[^>]*> nop
++0000f4d0 <[^>]*> nop
++0000f4d4 <[^>]*> nop
++0000f4d8 <[^>]*> nop
++0000f4dc <[^>]*> nop
++0000f4e0 <[^>]*> nop
++0000f4e4 <[^>]*> nop
++0000f4e8 <[^>]*> nop
++0000f4ec <[^>]*> nop
++0000f4f0 <[^>]*> nop
++0000f4f4 <[^>]*> nop
++0000f4f8 <[^>]*> nop
++0000f4fc <[^>]*> nop
++0000f500 <[^>]*> nop
++0000f504 <[^>]*> nop
++0000f508 <[^>]*> nop
++0000f50c <[^>]*> nop
++0000f510 <[^>]*> nop
++0000f514 <[^>]*> nop
++0000f518 <[^>]*> nop
++0000f51c <[^>]*> nop
++0000f520 <[^>]*> nop
++0000f524 <[^>]*> nop
++0000f528 <[^>]*> nop
++0000f52c <[^>]*> nop
++0000f530 <[^>]*> nop
++0000f534 <[^>]*> nop
++0000f538 <[^>]*> nop
++0000f53c <[^>]*> nop
++0000f540 <[^>]*> nop
++0000f544 <[^>]*> nop
++0000f548 <[^>]*> nop
++0000f54c <[^>]*> nop
++0000f550 <[^>]*> nop
++0000f554 <[^>]*> nop
++0000f558 <[^>]*> nop
++0000f55c <[^>]*> nop
++0000f560 <[^>]*> nop
++0000f564 <[^>]*> nop
++0000f568 <[^>]*> nop
++0000f56c <[^>]*> nop
++0000f570 <[^>]*> nop
++0000f574 <[^>]*> nop
++0000f578 <[^>]*> nop
++0000f57c <[^>]*> nop
++0000f580 <[^>]*> nop
++0000f584 <[^>]*> nop
++0000f588 <[^>]*> nop
++0000f58c <[^>]*> nop
++0000f590 <[^>]*> nop
++0000f594 <[^>]*> nop
++0000f598 <[^>]*> nop
++0000f59c <[^>]*> nop
++0000f5a0 <[^>]*> nop
++0000f5a4 <[^>]*> nop
++0000f5a8 <[^>]*> nop
++0000f5ac <[^>]*> nop
++0000f5b0 <[^>]*> nop
++0000f5b4 <[^>]*> nop
++0000f5b8 <[^>]*> nop
++0000f5bc <[^>]*> nop
++0000f5c0 <[^>]*> nop
++0000f5c4 <[^>]*> nop
++0000f5c8 <[^>]*> nop
++0000f5cc <[^>]*> nop
++0000f5d0 <[^>]*> nop
++0000f5d4 <[^>]*> nop
++0000f5d8 <[^>]*> nop
++0000f5dc <[^>]*> nop
++0000f5e0 <[^>]*> nop
++0000f5e4 <[^>]*> nop
++0000f5e8 <[^>]*> nop
++0000f5ec <[^>]*> nop
++0000f5f0 <[^>]*> nop
++0000f5f4 <[^>]*> nop
++0000f5f8 <[^>]*> nop
++0000f5fc <[^>]*> nop
++0000f600 <[^>]*> nop
++0000f604 <[^>]*> nop
++0000f608 <[^>]*> nop
++0000f60c <[^>]*> nop
++0000f610 <[^>]*> nop
++0000f614 <[^>]*> nop
++0000f618 <[^>]*> nop
++0000f61c <[^>]*> nop
++0000f620 <[^>]*> nop
++0000f624 <[^>]*> nop
++0000f628 <[^>]*> nop
++0000f62c <[^>]*> nop
++0000f630 <[^>]*> nop
++0000f634 <[^>]*> nop
++0000f638 <[^>]*> nop
++0000f63c <[^>]*> nop
++0000f640 <[^>]*> nop
++0000f644 <[^>]*> nop
++0000f648 <[^>]*> nop
++0000f64c <[^>]*> nop
++0000f650 <[^>]*> nop
++0000f654 <[^>]*> nop
++0000f658 <[^>]*> nop
++0000f65c <[^>]*> nop
++0000f660 <[^>]*> nop
++0000f664 <[^>]*> nop
++0000f668 <[^>]*> nop
++0000f66c <[^>]*> nop
++0000f670 <[^>]*> nop
++0000f674 <[^>]*> nop
++0000f678 <[^>]*> nop
++0000f67c <[^>]*> nop
++0000f680 <[^>]*> nop
++0000f684 <[^>]*> nop
++0000f688 <[^>]*> nop
++0000f68c <[^>]*> nop
++0000f690 <[^>]*> nop
++0000f694 <[^>]*> nop
++0000f698 <[^>]*> nop
++0000f69c <[^>]*> nop
++0000f6a0 <[^>]*> nop
++0000f6a4 <[^>]*> nop
++0000f6a8 <[^>]*> nop
++0000f6ac <[^>]*> nop
++0000f6b0 <[^>]*> nop
++0000f6b4 <[^>]*> nop
++0000f6b8 <[^>]*> nop
++0000f6bc <[^>]*> nop
++0000f6c0 <[^>]*> nop
++0000f6c4 <[^>]*> nop
++0000f6c8 <[^>]*> nop
++0000f6cc <[^>]*> nop
++0000f6d0 <[^>]*> nop
++0000f6d4 <[^>]*> nop
++0000f6d8 <[^>]*> nop
++0000f6dc <[^>]*> nop
++0000f6e0 <[^>]*> nop
++0000f6e4 <[^>]*> nop
++0000f6e8 <[^>]*> nop
++0000f6ec <[^>]*> nop
++0000f6f0 <[^>]*> nop
++0000f6f4 <[^>]*> nop
++0000f6f8 <[^>]*> nop
++0000f6fc <[^>]*> nop
++0000f700 <[^>]*> nop
++0000f704 <[^>]*> nop
++0000f708 <[^>]*> nop
++0000f70c <[^>]*> nop
++0000f710 <[^>]*> nop
++0000f714 <[^>]*> nop
++0000f718 <[^>]*> nop
++0000f71c <[^>]*> nop
++0000f720 <[^>]*> nop
++0000f724 <[^>]*> nop
++0000f728 <[^>]*> nop
++0000f72c <[^>]*> nop
++0000f730 <[^>]*> nop
++0000f734 <[^>]*> nop
++0000f738 <[^>]*> nop
++0000f73c <[^>]*> nop
++0000f740 <[^>]*> nop
++0000f744 <[^>]*> nop
++0000f748 <[^>]*> nop
++0000f74c <[^>]*> nop
++0000f750 <[^>]*> nop
++0000f754 <[^>]*> nop
++0000f758 <[^>]*> nop
++0000f75c <[^>]*> nop
++0000f760 <[^>]*> nop
++0000f764 <[^>]*> nop
++0000f768 <[^>]*> nop
++0000f76c <[^>]*> nop
++0000f770 <[^>]*> nop
++0000f774 <[^>]*> nop
++0000f778 <[^>]*> nop
++0000f77c <[^>]*> nop
++0000f780 <[^>]*> nop
++0000f784 <[^>]*> nop
++0000f788 <[^>]*> nop
++0000f78c <[^>]*> nop
++0000f790 <[^>]*> nop
++0000f794 <[^>]*> nop
++0000f798 <[^>]*> nop
++0000f79c <[^>]*> nop
++0000f7a0 <[^>]*> nop
++0000f7a4 <[^>]*> nop
++0000f7a8 <[^>]*> nop
++0000f7ac <[^>]*> nop
++0000f7b0 <[^>]*> nop
++0000f7b4 <[^>]*> nop
++0000f7b8 <[^>]*> nop
++0000f7bc <[^>]*> nop
++0000f7c0 <[^>]*> nop
++0000f7c4 <[^>]*> nop
++0000f7c8 <[^>]*> nop
++0000f7cc <[^>]*> nop
++0000f7d0 <[^>]*> nop
++0000f7d4 <[^>]*> nop
++0000f7d8 <[^>]*> nop
++0000f7dc <[^>]*> nop
++0000f7e0 <[^>]*> nop
++0000f7e4 <[^>]*> nop
++0000f7e8 <[^>]*> nop
++0000f7ec <[^>]*> nop
++0000f7f0 <[^>]*> nop
++0000f7f4 <[^>]*> nop
++0000f7f8 <[^>]*> nop
++0000f7fc <[^>]*> nop
++0000f800 <[^>]*> nop
++0000f804 <[^>]*> nop
++0000f808 <[^>]*> nop
++0000f80c <[^>]*> nop
++0000f810 <[^>]*> nop
++0000f814 <[^>]*> nop
++0000f818 <[^>]*> nop
++0000f81c <[^>]*> nop
++0000f820 <[^>]*> nop
++0000f824 <[^>]*> nop
++0000f828 <[^>]*> nop
++0000f82c <[^>]*> nop
++0000f830 <[^>]*> nop
++0000f834 <[^>]*> nop
++0000f838 <[^>]*> nop
++0000f83c <[^>]*> nop
++0000f840 <[^>]*> nop
++0000f844 <[^>]*> nop
++0000f848 <[^>]*> nop
++0000f84c <[^>]*> nop
++0000f850 <[^>]*> nop
++0000f854 <[^>]*> nop
++0000f858 <[^>]*> nop
++0000f85c <[^>]*> nop
++0000f860 <[^>]*> nop
++0000f864 <[^>]*> nop
++0000f868 <[^>]*> nop
++0000f86c <[^>]*> nop
++0000f870 <[^>]*> nop
++0000f874 <[^>]*> nop
++0000f878 <[^>]*> nop
++0000f87c <[^>]*> nop
++0000f880 <[^>]*> nop
++0000f884 <[^>]*> nop
++0000f888 <[^>]*> nop
++0000f88c <[^>]*> nop
++0000f890 <[^>]*> nop
++0000f894 <[^>]*> nop
++0000f898 <[^>]*> nop
++0000f89c <[^>]*> nop
++0000f8a0 <[^>]*> nop
++0000f8a4 <[^>]*> nop
++0000f8a8 <[^>]*> nop
++0000f8ac <[^>]*> nop
++0000f8b0 <[^>]*> nop
++0000f8b4 <[^>]*> nop
++0000f8b8 <[^>]*> nop
++0000f8bc <[^>]*> nop
++0000f8c0 <[^>]*> nop
++0000f8c4 <[^>]*> nop
++0000f8c8 <[^>]*> nop
++0000f8cc <[^>]*> nop
++0000f8d0 <[^>]*> nop
++0000f8d4 <[^>]*> nop
++0000f8d8 <[^>]*> nop
++0000f8dc <[^>]*> nop
++0000f8e0 <[^>]*> nop
++0000f8e4 <[^>]*> nop
++0000f8e8 <[^>]*> nop
++0000f8ec <[^>]*> nop
++0000f8f0 <[^>]*> nop
++0000f8f4 <[^>]*> nop
++0000f8f8 <[^>]*> nop
++0000f8fc <[^>]*> nop
++0000f900 <[^>]*> nop
++0000f904 <[^>]*> nop
++0000f908 <[^>]*> nop
++0000f90c <[^>]*> nop
++0000f910 <[^>]*> nop
++0000f914 <[^>]*> nop
++0000f918 <[^>]*> nop
++0000f91c <[^>]*> nop
++0000f920 <[^>]*> nop
++0000f924 <[^>]*> nop
++0000f928 <[^>]*> nop
++0000f92c <[^>]*> nop
++0000f930 <[^>]*> nop
++0000f934 <[^>]*> nop
++0000f938 <[^>]*> nop
++0000f93c <[^>]*> nop
++0000f940 <[^>]*> nop
++0000f944 <[^>]*> nop
++0000f948 <[^>]*> nop
++0000f94c <[^>]*> nop
++0000f950 <[^>]*> nop
++0000f954 <[^>]*> nop
++0000f958 <[^>]*> nop
++0000f95c <[^>]*> nop
++0000f960 <[^>]*> nop
++0000f964 <[^>]*> nop
++0000f968 <[^>]*> nop
++0000f96c <[^>]*> nop
++0000f970 <[^>]*> nop
++0000f974 <[^>]*> nop
++0000f978 <[^>]*> nop
++0000f97c <[^>]*> nop
++0000f980 <[^>]*> nop
++0000f984 <[^>]*> nop
++0000f988 <[^>]*> nop
++0000f98c <[^>]*> nop
++0000f990 <[^>]*> nop
++0000f994 <[^>]*> nop
++0000f998 <[^>]*> nop
++0000f99c <[^>]*> nop
++0000f9a0 <[^>]*> nop
++0000f9a4 <[^>]*> nop
++0000f9a8 <[^>]*> nop
++0000f9ac <[^>]*> nop
++0000f9b0 <[^>]*> nop
++0000f9b4 <[^>]*> nop
++0000f9b8 <[^>]*> nop
++0000f9bc <[^>]*> nop
++0000f9c0 <[^>]*> nop
++0000f9c4 <[^>]*> nop
++0000f9c8 <[^>]*> nop
++0000f9cc <[^>]*> nop
++0000f9d0 <[^>]*> nop
++0000f9d4 <[^>]*> nop
++0000f9d8 <[^>]*> nop
++0000f9dc <[^>]*> nop
++0000f9e0 <[^>]*> nop
++0000f9e4 <[^>]*> nop
++0000f9e8 <[^>]*> nop
++0000f9ec <[^>]*> nop
++0000f9f0 <[^>]*> nop
++0000f9f4 <[^>]*> nop
++0000f9f8 <[^>]*> nop
++0000f9fc <[^>]*> nop
++0000fa00 <[^>]*> nop
++0000fa04 <[^>]*> nop
++0000fa08 <[^>]*> nop
++0000fa0c <[^>]*> nop
++0000fa10 <[^>]*> nop
++0000fa14 <[^>]*> nop
++0000fa18 <[^>]*> nop
++0000fa1c <[^>]*> nop
++0000fa20 <[^>]*> nop
++0000fa24 <[^>]*> nop
++0000fa28 <[^>]*> nop
++0000fa2c <[^>]*> nop
++0000fa30 <[^>]*> nop
++0000fa34 <[^>]*> nop
++0000fa38 <[^>]*> nop
++0000fa3c <[^>]*> nop
++0000fa40 <[^>]*> nop
++0000fa44 <[^>]*> nop
++0000fa48 <[^>]*> nop
++0000fa4c <[^>]*> nop
++0000fa50 <[^>]*> nop
++0000fa54 <[^>]*> nop
++0000fa58 <[^>]*> nop
++0000fa5c <[^>]*> nop
++0000fa60 <[^>]*> nop
++0000fa64 <[^>]*> nop
++0000fa68 <[^>]*> nop
++0000fa6c <[^>]*> nop
++0000fa70 <[^>]*> nop
++0000fa74 <[^>]*> nop
++0000fa78 <[^>]*> nop
++0000fa7c <[^>]*> nop
++0000fa80 <[^>]*> nop
++0000fa84 <[^>]*> nop
++0000fa88 <[^>]*> nop
++0000fa8c <[^>]*> nop
++0000fa90 <[^>]*> nop
++0000fa94 <[^>]*> nop
++0000fa98 <[^>]*> nop
++0000fa9c <[^>]*> nop
++0000faa0 <[^>]*> nop
++0000faa4 <[^>]*> nop
++0000faa8 <[^>]*> nop
++0000faac <[^>]*> nop
++0000fab0 <[^>]*> nop
++0000fab4 <[^>]*> nop
++0000fab8 <[^>]*> nop
++0000fabc <[^>]*> nop
++0000fac0 <[^>]*> nop
++0000fac4 <[^>]*> nop
++0000fac8 <[^>]*> nop
++0000facc <[^>]*> nop
++0000fad0 <[^>]*> nop
++0000fad4 <[^>]*> nop
++0000fad8 <[^>]*> nop
++0000fadc <[^>]*> nop
++0000fae0 <[^>]*> nop
++0000fae4 <[^>]*> nop
++0000fae8 <[^>]*> nop
++0000faec <[^>]*> nop
++0000faf0 <[^>]*> nop
++0000faf4 <[^>]*> nop
++0000faf8 <[^>]*> nop
++0000fafc <[^>]*> nop
++0000fb00 <[^>]*> nop
++0000fb04 <[^>]*> nop
++0000fb08 <[^>]*> nop
++0000fb0c <[^>]*> nop
++0000fb10 <[^>]*> nop
++0000fb14 <[^>]*> nop
++0000fb18 <[^>]*> nop
++0000fb1c <[^>]*> nop
++0000fb20 <[^>]*> nop
++0000fb24 <[^>]*> nop
++0000fb28 <[^>]*> nop
++0000fb2c <[^>]*> nop
++0000fb30 <[^>]*> nop
++0000fb34 <[^>]*> nop
++0000fb38 <[^>]*> nop
++0000fb3c <[^>]*> nop
++0000fb40 <[^>]*> nop
++0000fb44 <[^>]*> nop
++0000fb48 <[^>]*> nop
++0000fb4c <[^>]*> nop
++0000fb50 <[^>]*> nop
++0000fb54 <[^>]*> nop
++0000fb58 <[^>]*> nop
++0000fb5c <[^>]*> nop
++0000fb60 <[^>]*> nop
++0000fb64 <[^>]*> nop
++0000fb68 <[^>]*> nop
++0000fb6c <[^>]*> nop
++0000fb70 <[^>]*> nop
++0000fb74 <[^>]*> nop
++0000fb78 <[^>]*> nop
++0000fb7c <[^>]*> nop
++0000fb80 <[^>]*> nop
++0000fb84 <[^>]*> nop
++0000fb88 <[^>]*> nop
++0000fb8c <[^>]*> nop
++0000fb90 <[^>]*> nop
++0000fb94 <[^>]*> nop
++0000fb98 <[^>]*> nop
++0000fb9c <[^>]*> nop
++0000fba0 <[^>]*> nop
++0000fba4 <[^>]*> nop
++0000fba8 <[^>]*> nop
++0000fbac <[^>]*> nop
++0000fbb0 <[^>]*> nop
++0000fbb4 <[^>]*> nop
++0000fbb8 <[^>]*> nop
++0000fbbc <[^>]*> nop
++0000fbc0 <[^>]*> nop
++0000fbc4 <[^>]*> nop
++0000fbc8 <[^>]*> nop
++0000fbcc <[^>]*> nop
++0000fbd0 <[^>]*> nop
++0000fbd4 <[^>]*> nop
++0000fbd8 <[^>]*> nop
++0000fbdc <[^>]*> nop
++0000fbe0 <[^>]*> nop
++0000fbe4 <[^>]*> nop
++0000fbe8 <[^>]*> nop
++0000fbec <[^>]*> nop
++0000fbf0 <[^>]*> nop
++0000fbf4 <[^>]*> nop
++0000fbf8 <[^>]*> nop
++0000fbfc <[^>]*> nop
++0000fc00 <[^>]*> nop
++0000fc04 <[^>]*> nop
++0000fc08 <[^>]*> nop
++0000fc0c <[^>]*> nop
++0000fc10 <[^>]*> nop
++0000fc14 <[^>]*> nop
++0000fc18 <[^>]*> nop
++0000fc1c <[^>]*> nop
++0000fc20 <[^>]*> nop
++0000fc24 <[^>]*> nop
++0000fc28 <[^>]*> nop
++0000fc2c <[^>]*> nop
++0000fc30 <[^>]*> nop
++0000fc34 <[^>]*> nop
++0000fc38 <[^>]*> nop
++0000fc3c <[^>]*> nop
++0000fc40 <[^>]*> nop
++0000fc44 <[^>]*> nop
++0000fc48 <[^>]*> nop
++0000fc4c <[^>]*> nop
++0000fc50 <[^>]*> nop
++0000fc54 <[^>]*> nop
++0000fc58 <[^>]*> nop
++0000fc5c <[^>]*> nop
++0000fc60 <[^>]*> nop
++0000fc64 <[^>]*> nop
++0000fc68 <[^>]*> nop
++0000fc6c <[^>]*> nop
++0000fc70 <[^>]*> nop
++0000fc74 <[^>]*> nop
++0000fc78 <[^>]*> nop
++0000fc7c <[^>]*> nop
++0000fc80 <[^>]*> nop
++0000fc84 <[^>]*> nop
++0000fc88 <[^>]*> nop
++0000fc8c <[^>]*> nop
++0000fc90 <[^>]*> nop
++0000fc94 <[^>]*> nop
++0000fc98 <[^>]*> nop
++0000fc9c <[^>]*> nop
++0000fca0 <[^>]*> nop
++0000fca4 <[^>]*> nop
++0000fca8 <[^>]*> nop
++0000fcac <[^>]*> nop
++0000fcb0 <[^>]*> nop
++0000fcb4 <[^>]*> nop
++0000fcb8 <[^>]*> nop
++0000fcbc <[^>]*> nop
++0000fcc0 <[^>]*> nop
++0000fcc4 <[^>]*> nop
++0000fcc8 <[^>]*> nop
++0000fccc <[^>]*> nop
++0000fcd0 <[^>]*> nop
++0000fcd4 <[^>]*> nop
++0000fcd8 <[^>]*> nop
++0000fcdc <[^>]*> nop
++0000fce0 <[^>]*> nop
++0000fce4 <[^>]*> nop
++0000fce8 <[^>]*> nop
++0000fcec <[^>]*> nop
++0000fcf0 <[^>]*> nop
++0000fcf4 <[^>]*> nop
++0000fcf8 <[^>]*> nop
++0000fcfc <[^>]*> nop
++0000fd00 <[^>]*> nop
++0000fd04 <[^>]*> nop
++0000fd08 <[^>]*> nop
++0000fd0c <[^>]*> nop
++0000fd10 <[^>]*> nop
++0000fd14 <[^>]*> nop
++0000fd18 <[^>]*> nop
++0000fd1c <[^>]*> nop
++0000fd20 <[^>]*> nop
++0000fd24 <[^>]*> nop
++0000fd28 <[^>]*> nop
++0000fd2c <[^>]*> nop
++0000fd30 <[^>]*> nop
++0000fd34 <[^>]*> nop
++0000fd38 <[^>]*> nop
++0000fd3c <[^>]*> nop
++0000fd40 <[^>]*> nop
++0000fd44 <[^>]*> nop
++0000fd48 <[^>]*> nop
++0000fd4c <[^>]*> nop
++0000fd50 <[^>]*> nop
++0000fd54 <[^>]*> nop
++0000fd58 <[^>]*> nop
++0000fd5c <[^>]*> nop
++0000fd60 <[^>]*> nop
++0000fd64 <[^>]*> nop
++0000fd68 <[^>]*> nop
++0000fd6c <[^>]*> nop
++0000fd70 <[^>]*> nop
++0000fd74 <[^>]*> nop
++0000fd78 <[^>]*> nop
++0000fd7c <[^>]*> nop
++0000fd80 <[^>]*> nop
++0000fd84 <[^>]*> nop
++0000fd88 <[^>]*> nop
++0000fd8c <[^>]*> nop
++0000fd90 <[^>]*> nop
++0000fd94 <[^>]*> nop
++0000fd98 <[^>]*> nop
++0000fd9c <[^>]*> nop
++0000fda0 <[^>]*> nop
++0000fda4 <[^>]*> nop
++0000fda8 <[^>]*> nop
++0000fdac <[^>]*> nop
++0000fdb0 <[^>]*> nop
++0000fdb4 <[^>]*> nop
++0000fdb8 <[^>]*> nop
++0000fdbc <[^>]*> nop
++0000fdc0 <[^>]*> nop
++0000fdc4 <[^>]*> nop
++0000fdc8 <[^>]*> nop
++0000fdcc <[^>]*> nop
++0000fdd0 <[^>]*> nop
++0000fdd4 <[^>]*> nop
++0000fdd8 <[^>]*> nop
++0000fddc <[^>]*> nop
++0000fde0 <[^>]*> nop
++0000fde4 <[^>]*> nop
++0000fde8 <[^>]*> nop
++0000fdec <[^>]*> nop
++0000fdf0 <[^>]*> nop
++0000fdf4 <[^>]*> nop
++0000fdf8 <[^>]*> nop
++0000fdfc <[^>]*> nop
++0000fe00 <[^>]*> nop
++0000fe04 <[^>]*> nop
++0000fe08 <[^>]*> nop
++0000fe0c <[^>]*> nop
++0000fe10 <[^>]*> nop
++0000fe14 <[^>]*> nop
++0000fe18 <[^>]*> nop
++0000fe1c <[^>]*> nop
++0000fe20 <[^>]*> nop
++0000fe24 <[^>]*> nop
++0000fe28 <[^>]*> nop
++0000fe2c <[^>]*> nop
++0000fe30 <[^>]*> nop
++0000fe34 <[^>]*> nop
++0000fe38 <[^>]*> nop
++0000fe3c <[^>]*> nop
++0000fe40 <[^>]*> nop
++0000fe44 <[^>]*> nop
++0000fe48 <[^>]*> nop
++0000fe4c <[^>]*> nop
++0000fe50 <[^>]*> nop
++0000fe54 <[^>]*> nop
++0000fe58 <[^>]*> nop
++0000fe5c <[^>]*> nop
++0000fe60 <[^>]*> nop
++0000fe64 <[^>]*> nop
++0000fe68 <[^>]*> nop
++0000fe6c <[^>]*> nop
++0000fe70 <[^>]*> nop
++0000fe74 <[^>]*> nop
++0000fe78 <[^>]*> nop
++0000fe7c <[^>]*> nop
++0000fe80 <[^>]*> nop
++0000fe84 <[^>]*> nop
++0000fe88 <[^>]*> nop
++0000fe8c <[^>]*> nop
++0000fe90 <[^>]*> nop
++0000fe94 <[^>]*> nop
++0000fe98 <[^>]*> nop
++0000fe9c <[^>]*> nop
++0000fea0 <[^>]*> nop
++0000fea4 <[^>]*> nop
++0000fea8 <[^>]*> nop
++0000feac <[^>]*> nop
++0000feb0 <[^>]*> nop
++0000feb4 <[^>]*> nop
++0000feb8 <[^>]*> nop
++0000febc <[^>]*> nop
++0000fec0 <[^>]*> nop
++0000fec4 <[^>]*> nop
++0000fec8 <[^>]*> nop
++0000fecc <[^>]*> nop
++0000fed0 <[^>]*> nop
++0000fed4 <[^>]*> nop
++0000fed8 <[^>]*> nop
++0000fedc <[^>]*> nop
++0000fee0 <[^>]*> nop
++0000fee4 <[^>]*> nop
++0000fee8 <[^>]*> nop
++0000feec <[^>]*> nop
++0000fef0 <[^>]*> nop
++0000fef4 <[^>]*> nop
++0000fef8 <[^>]*> nop
++0000fefc <[^>]*> nop
++0000ff00 <[^>]*> nop
++0000ff04 <[^>]*> nop
++0000ff08 <[^>]*> nop
++0000ff0c <[^>]*> nop
++0000ff10 <[^>]*> nop
++0000ff14 <[^>]*> nop
++0000ff18 <[^>]*> nop
++0000ff1c <[^>]*> nop
++0000ff20 <[^>]*> nop
++0000ff24 <[^>]*> nop
++0000ff28 <[^>]*> nop
++0000ff2c <[^>]*> nop
++0000ff30 <[^>]*> nop
++0000ff34 <[^>]*> nop
++0000ff38 <[^>]*> nop
++0000ff3c <[^>]*> nop
++0000ff40 <[^>]*> nop
++0000ff44 <[^>]*> nop
++0000ff48 <[^>]*> nop
++0000ff4c <[^>]*> nop
++0000ff50 <[^>]*> nop
++0000ff54 <[^>]*> nop
++0000ff58 <[^>]*> nop
++0000ff5c <[^>]*> nop
++0000ff60 <[^>]*> nop
++0000ff64 <[^>]*> nop
++0000ff68 <[^>]*> nop
++0000ff6c <[^>]*> nop
++0000ff70 <[^>]*> nop
++0000ff74 <[^>]*> nop
++0000ff78 <[^>]*> nop
++0000ff7c <[^>]*> nop
++0000ff80 <[^>]*> nop
++0000ff84 <[^>]*> nop
++0000ff88 <[^>]*> nop
++0000ff8c <[^>]*> nop
++0000ff90 <[^>]*> nop
++0000ff94 <[^>]*> nop
++0000ff98 <[^>]*> nop
++0000ff9c <[^>]*> nop
++0000ffa0 <[^>]*> nop
++0000ffa4 <[^>]*> nop
++0000ffa8 <[^>]*> nop
++0000ffac <[^>]*> nop
++0000ffb0 <[^>]*> nop
++0000ffb4 <[^>]*> nop
++0000ffb8 <[^>]*> nop
++0000ffbc <[^>]*> nop
++0000ffc0 <[^>]*> nop
++0000ffc4 <[^>]*> nop
++0000ffc8 <[^>]*> nop
++0000ffcc <[^>]*> nop
++0000ffd0 <[^>]*> nop
++0000ffd4 <[^>]*> nop
++0000ffd8 <[^>]*> nop
++0000ffdc <[^>]*> nop
++0000ffe0 <[^>]*> nop
++0000ffe4 <[^>]*> nop
++0000ffe8 <[^>]*> nop
++0000ffec <[^>]*> nop
++0000fff0 <[^>]*> nop
++0000fff4 <[^>]*> nop
++0000fff8 <[^>]*> nop
++0000fffc <[^>]*> nop
++00010000 <[^>]*> bne r2,r3,00010024 <[^>]*>
++00010004 <[^>]*> nop
++00010008 <[^>]*> nop
++0001000c <[^>]*> nop
++00010010 <[^>]*> nop
++00010014 <[^>]*> nop
++00010018 <[^>]*> nop
++0001001c <[^>]*> nop
++00010020 <[^>]*> nop
++00010024 <[^>]*> nop
++ ...
+diff --git a/gas/testsuite/gas/nios2/relax_cjmp.s b/gas/testsuite/gas/nios2/relax_cjmp.s
+new file mode 100644
+index 0000000..4cd24a4
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_cjmp.s
+@@ -0,0 +1,37 @@
++# relaxing unconditional jumps
++
++.globl text1
++.section text1, "ax", @progbits
++
++ beq r2, r3, on_border
++ beq r2, r3, out_of_range
++ nop
++ nop
++
++
++.align 15
++ #nop
++ #nop
++ #nop
++on_border:
++ bne r2, r3, in_range
++ nop
++ nop
++ nop
++ nop
++ nop
++out_of_range:
++in_range:
++ nop
++
++.globl text2
++.section text2, "ax", @progbits
++
++ bge r2, r3, text1
++ blt r2, r3, out_of_range
++ ble r2, r3, sym
++ nop
++ nop
++sym:
++ nop
++
+diff --git a/gas/testsuite/gas/nios2/relax_section.d b/gas/testsuite/gas/nios2/relax_section.d
+new file mode 100644
+index 0000000..31cfe42
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_section.d
+@@ -0,0 +1,8206 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 relax_section
++
++# Test relaxation of section
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> bne r2,r3,00000010 <in_range-0xc>
++0+0004 <[^>]*> movhi at,0
++0+0008 <[^>]*> ori at,at,32780
++0+000c <[^>]*> jmp at
++0+0010 <[^>]*> bne r2,r3,0000001c <in_range>
++0+0014 <[^>]*> nop
++0+0018 <[^>]*> nop
++0+001c <[^>]*> nop
++0+0020 <[^>]*> nop
++0+0024 <[^>]*> nop
++0+0028 <[^>]*> nop
++0+002c <[^>]*> nop
++0+0030 <[^>]*> nop
++0+0034 <[^>]*> nop
++0+0038 <[^>]*> nop
++0+003c <[^>]*> nop
++0+0040 <[^>]*> nop
++0+0044 <[^>]*> nop
++0+0048 <[^>]*> nop
++0+004c <[^>]*> nop
++0+0050 <[^>]*> nop
++0+0054 <[^>]*> nop
++0+0058 <[^>]*> nop
++0+005c <[^>]*> nop
++0+0060 <[^>]*> nop
++0+0064 <[^>]*> nop
++0+0068 <[^>]*> nop
++0+006c <[^>]*> nop
++0+0070 <[^>]*> nop
++0+0074 <[^>]*> nop
++0+0078 <[^>]*> nop
++0+007c <[^>]*> nop
++0+0080 <[^>]*> nop
++0+0084 <[^>]*> nop
++0+0088 <[^>]*> nop
++0+008c <[^>]*> nop
++0+0090 <[^>]*> nop
++0+0094 <[^>]*> nop
++0+0098 <[^>]*> nop
++0+009c <[^>]*> nop
++0+00a0 <[^>]*> nop
++0+00a4 <[^>]*> nop
++0+00a8 <[^>]*> nop
++0+00ac <[^>]*> nop
++0+00b0 <[^>]*> nop
++0+00b4 <[^>]*> nop
++0+00b8 <[^>]*> nop
++0+00bc <[^>]*> nop
++0+00c0 <[^>]*> nop
++0+00c4 <[^>]*> nop
++0+00c8 <[^>]*> nop
++0+00cc <[^>]*> nop
++0+00d0 <[^>]*> nop
++0+00d4 <[^>]*> nop
++0+00d8 <[^>]*> nop
++0+00dc <[^>]*> nop
++0+00e0 <[^>]*> nop
++0+00e4 <[^>]*> nop
++0+00e8 <[^>]*> nop
++0+00ec <[^>]*> nop
++0+00f0 <[^>]*> nop
++0+00f4 <[^>]*> nop
++0+00f8 <[^>]*> nop
++0+00fc <[^>]*> nop
++0+0100 <[^>]*> nop
++0+0104 <[^>]*> nop
++0+0108 <[^>]*> nop
++0+010c <[^>]*> nop
++0+0110 <[^>]*> nop
++0+0114 <[^>]*> nop
++0+0118 <[^>]*> nop
++0+011c <[^>]*> nop
++0+0120 <[^>]*> nop
++0+0124 <[^>]*> nop
++0+0128 <[^>]*> nop
++0+012c <[^>]*> nop
++0+0130 <[^>]*> nop
++0+0134 <[^>]*> nop
++0+0138 <[^>]*> nop
++0+013c <[^>]*> nop
++0+0140 <[^>]*> nop
++0+0144 <[^>]*> nop
++0+0148 <[^>]*> nop
++0+014c <[^>]*> nop
++0+0150 <[^>]*> nop
++0+0154 <[^>]*> nop
++0+0158 <[^>]*> nop
++0+015c <[^>]*> nop
++0+0160 <[^>]*> nop
++0+0164 <[^>]*> nop
++0+0168 <[^>]*> nop
++0+016c <[^>]*> nop
++0+0170 <[^>]*> nop
++0+0174 <[^>]*> nop
++0+0178 <[^>]*> nop
++0+017c <[^>]*> nop
++0+0180 <[^>]*> nop
++0+0184 <[^>]*> nop
++0+0188 <[^>]*> nop
++0+018c <[^>]*> nop
++0+0190 <[^>]*> nop
++0+0194 <[^>]*> nop
++0+0198 <[^>]*> nop
++0+019c <[^>]*> nop
++0+01a0 <[^>]*> nop
++0+01a4 <[^>]*> nop
++0+01a8 <[^>]*> nop
++0+01ac <[^>]*> nop
++0+01b0 <[^>]*> nop
++0+01b4 <[^>]*> nop
++0+01b8 <[^>]*> nop
++0+01bc <[^>]*> nop
++0+01c0 <[^>]*> nop
++0+01c4 <[^>]*> nop
++0+01c8 <[^>]*> nop
++0+01cc <[^>]*> nop
++0+01d0 <[^>]*> nop
++0+01d4 <[^>]*> nop
++0+01d8 <[^>]*> nop
++0+01dc <[^>]*> nop
++0+01e0 <[^>]*> nop
++0+01e4 <[^>]*> nop
++0+01e8 <[^>]*> nop
++0+01ec <[^>]*> nop
++0+01f0 <[^>]*> nop
++0+01f4 <[^>]*> nop
++0+01f8 <[^>]*> nop
++0+01fc <[^>]*> nop
++0+0200 <[^>]*> nop
++0+0204 <[^>]*> nop
++0+0208 <[^>]*> nop
++0+020c <[^>]*> nop
++0+0210 <[^>]*> nop
++0+0214 <[^>]*> nop
++0+0218 <[^>]*> nop
++0+021c <[^>]*> nop
++0+0220 <[^>]*> nop
++0+0224 <[^>]*> nop
++0+0228 <[^>]*> nop
++0+022c <[^>]*> nop
++0+0230 <[^>]*> nop
++0+0234 <[^>]*> nop
++0+0238 <[^>]*> nop
++0+023c <[^>]*> nop
++0+0240 <[^>]*> nop
++0+0244 <[^>]*> nop
++0+0248 <[^>]*> nop
++0+024c <[^>]*> nop
++0+0250 <[^>]*> nop
++0+0254 <[^>]*> nop
++0+0258 <[^>]*> nop
++0+025c <[^>]*> nop
++0+0260 <[^>]*> nop
++0+0264 <[^>]*> nop
++0+0268 <[^>]*> nop
++0+026c <[^>]*> nop
++0+0270 <[^>]*> nop
++0+0274 <[^>]*> nop
++0+0278 <[^>]*> nop
++0+027c <[^>]*> nop
++0+0280 <[^>]*> nop
++0+0284 <[^>]*> nop
++0+0288 <[^>]*> nop
++0+028c <[^>]*> nop
++0+0290 <[^>]*> nop
++0+0294 <[^>]*> nop
++0+0298 <[^>]*> nop
++0+029c <[^>]*> nop
++0+02a0 <[^>]*> nop
++0+02a4 <[^>]*> nop
++0+02a8 <[^>]*> nop
++0+02ac <[^>]*> nop
++0+02b0 <[^>]*> nop
++0+02b4 <[^>]*> nop
++0+02b8 <[^>]*> nop
++0+02bc <[^>]*> nop
++0+02c0 <[^>]*> nop
++0+02c4 <[^>]*> nop
++0+02c8 <[^>]*> nop
++0+02cc <[^>]*> nop
++0+02d0 <[^>]*> nop
++0+02d4 <[^>]*> nop
++0+02d8 <[^>]*> nop
++0+02dc <[^>]*> nop
++0+02e0 <[^>]*> nop
++0+02e4 <[^>]*> nop
++0+02e8 <[^>]*> nop
++0+02ec <[^>]*> nop
++0+02f0 <[^>]*> nop
++0+02f4 <[^>]*> nop
++0+02f8 <[^>]*> nop
++0+02fc <[^>]*> nop
++0+0300 <[^>]*> nop
++0+0304 <[^>]*> nop
++0+0308 <[^>]*> nop
++0+030c <[^>]*> nop
++0+0310 <[^>]*> nop
++0+0314 <[^>]*> nop
++0+0318 <[^>]*> nop
++0+031c <[^>]*> nop
++0+0320 <[^>]*> nop
++0+0324 <[^>]*> nop
++0+0328 <[^>]*> nop
++0+032c <[^>]*> nop
++0+0330 <[^>]*> nop
++0+0334 <[^>]*> nop
++0+0338 <[^>]*> nop
++0+033c <[^>]*> nop
++0+0340 <[^>]*> nop
++0+0344 <[^>]*> nop
++0+0348 <[^>]*> nop
++0+034c <[^>]*> nop
++0+0350 <[^>]*> nop
++0+0354 <[^>]*> nop
++0+0358 <[^>]*> nop
++0+035c <[^>]*> nop
++0+0360 <[^>]*> nop
++0+0364 <[^>]*> nop
++0+0368 <[^>]*> nop
++0+036c <[^>]*> nop
++0+0370 <[^>]*> nop
++0+0374 <[^>]*> nop
++0+0378 <[^>]*> nop
++0+037c <[^>]*> nop
++0+0380 <[^>]*> nop
++0+0384 <[^>]*> nop
++0+0388 <[^>]*> nop
++0+038c <[^>]*> nop
++0+0390 <[^>]*> nop
++0+0394 <[^>]*> nop
++0+0398 <[^>]*> nop
++0+039c <[^>]*> nop
++0+03a0 <[^>]*> nop
++0+03a4 <[^>]*> nop
++0+03a8 <[^>]*> nop
++0+03ac <[^>]*> nop
++0+03b0 <[^>]*> nop
++0+03b4 <[^>]*> nop
++0+03b8 <[^>]*> nop
++0+03bc <[^>]*> nop
++0+03c0 <[^>]*> nop
++0+03c4 <[^>]*> nop
++0+03c8 <[^>]*> nop
++0+03cc <[^>]*> nop
++0+03d0 <[^>]*> nop
++0+03d4 <[^>]*> nop
++0+03d8 <[^>]*> nop
++0+03dc <[^>]*> nop
++0+03e0 <[^>]*> nop
++0+03e4 <[^>]*> nop
++0+03e8 <[^>]*> nop
++0+03ec <[^>]*> nop
++0+03f0 <[^>]*> nop
++0+03f4 <[^>]*> nop
++0+03f8 <[^>]*> nop
++0+03fc <[^>]*> nop
++0+0400 <[^>]*> nop
++0+0404 <[^>]*> nop
++0+0408 <[^>]*> nop
++0+040c <[^>]*> nop
++0+0410 <[^>]*> nop
++0+0414 <[^>]*> nop
++0+0418 <[^>]*> nop
++0+041c <[^>]*> nop
++0+0420 <[^>]*> nop
++0+0424 <[^>]*> nop
++0+0428 <[^>]*> nop
++0+042c <[^>]*> nop
++0+0430 <[^>]*> nop
++0+0434 <[^>]*> nop
++0+0438 <[^>]*> nop
++0+043c <[^>]*> nop
++0+0440 <[^>]*> nop
++0+0444 <[^>]*> nop
++0+0448 <[^>]*> nop
++0+044c <[^>]*> nop
++0+0450 <[^>]*> nop
++0+0454 <[^>]*> nop
++0+0458 <[^>]*> nop
++0+045c <[^>]*> nop
++0+0460 <[^>]*> nop
++0+0464 <[^>]*> nop
++0+0468 <[^>]*> nop
++0+046c <[^>]*> nop
++0+0470 <[^>]*> nop
++0+0474 <[^>]*> nop
++0+0478 <[^>]*> nop
++0+047c <[^>]*> nop
++0+0480 <[^>]*> nop
++0+0484 <[^>]*> nop
++0+0488 <[^>]*> nop
++0+048c <[^>]*> nop
++0+0490 <[^>]*> nop
++0+0494 <[^>]*> nop
++0+0498 <[^>]*> nop
++0+049c <[^>]*> nop
++0+04a0 <[^>]*> nop
++0+04a4 <[^>]*> nop
++0+04a8 <[^>]*> nop
++0+04ac <[^>]*> nop
++0+04b0 <[^>]*> nop
++0+04b4 <[^>]*> nop
++0+04b8 <[^>]*> nop
++0+04bc <[^>]*> nop
++0+04c0 <[^>]*> nop
++0+04c4 <[^>]*> nop
++0+04c8 <[^>]*> nop
++0+04cc <[^>]*> nop
++0+04d0 <[^>]*> nop
++0+04d4 <[^>]*> nop
++0+04d8 <[^>]*> nop
++0+04dc <[^>]*> nop
++0+04e0 <[^>]*> nop
++0+04e4 <[^>]*> nop
++0+04e8 <[^>]*> nop
++0+04ec <[^>]*> nop
++0+04f0 <[^>]*> nop
++0+04f4 <[^>]*> nop
++0+04f8 <[^>]*> nop
++0+04fc <[^>]*> nop
++0+0500 <[^>]*> nop
++0+0504 <[^>]*> nop
++0+0508 <[^>]*> nop
++0+050c <[^>]*> nop
++0+0510 <[^>]*> nop
++0+0514 <[^>]*> nop
++0+0518 <[^>]*> nop
++0+051c <[^>]*> nop
++0+0520 <[^>]*> nop
++0+0524 <[^>]*> nop
++0+0528 <[^>]*> nop
++0+052c <[^>]*> nop
++0+0530 <[^>]*> nop
++0+0534 <[^>]*> nop
++0+0538 <[^>]*> nop
++0+053c <[^>]*> nop
++0+0540 <[^>]*> nop
++0+0544 <[^>]*> nop
++0+0548 <[^>]*> nop
++0+054c <[^>]*> nop
++0+0550 <[^>]*> nop
++0+0554 <[^>]*> nop
++0+0558 <[^>]*> nop
++0+055c <[^>]*> nop
++0+0560 <[^>]*> nop
++0+0564 <[^>]*> nop
++0+0568 <[^>]*> nop
++0+056c <[^>]*> nop
++0+0570 <[^>]*> nop
++0+0574 <[^>]*> nop
++0+0578 <[^>]*> nop
++0+057c <[^>]*> nop
++0+0580 <[^>]*> nop
++0+0584 <[^>]*> nop
++0+0588 <[^>]*> nop
++0+058c <[^>]*> nop
++0+0590 <[^>]*> nop
++0+0594 <[^>]*> nop
++0+0598 <[^>]*> nop
++0+059c <[^>]*> nop
++0+05a0 <[^>]*> nop
++0+05a4 <[^>]*> nop
++0+05a8 <[^>]*> nop
++0+05ac <[^>]*> nop
++0+05b0 <[^>]*> nop
++0+05b4 <[^>]*> nop
++0+05b8 <[^>]*> nop
++0+05bc <[^>]*> nop
++0+05c0 <[^>]*> nop
++0+05c4 <[^>]*> nop
++0+05c8 <[^>]*> nop
++0+05cc <[^>]*> nop
++0+05d0 <[^>]*> nop
++0+05d4 <[^>]*> nop
++0+05d8 <[^>]*> nop
++0+05dc <[^>]*> nop
++0+05e0 <[^>]*> nop
++0+05e4 <[^>]*> nop
++0+05e8 <[^>]*> nop
++0+05ec <[^>]*> nop
++0+05f0 <[^>]*> nop
++0+05f4 <[^>]*> nop
++0+05f8 <[^>]*> nop
++0+05fc <[^>]*> nop
++0+0600 <[^>]*> nop
++0+0604 <[^>]*> nop
++0+0608 <[^>]*> nop
++0+060c <[^>]*> nop
++0+0610 <[^>]*> nop
++0+0614 <[^>]*> nop
++0+0618 <[^>]*> nop
++0+061c <[^>]*> nop
++0+0620 <[^>]*> nop
++0+0624 <[^>]*> nop
++0+0628 <[^>]*> nop
++0+062c <[^>]*> nop
++0+0630 <[^>]*> nop
++0+0634 <[^>]*> nop
++0+0638 <[^>]*> nop
++0+063c <[^>]*> nop
++0+0640 <[^>]*> nop
++0+0644 <[^>]*> nop
++0+0648 <[^>]*> nop
++0+064c <[^>]*> nop
++0+0650 <[^>]*> nop
++0+0654 <[^>]*> nop
++0+0658 <[^>]*> nop
++0+065c <[^>]*> nop
++0+0660 <[^>]*> nop
++0+0664 <[^>]*> nop
++0+0668 <[^>]*> nop
++0+066c <[^>]*> nop
++0+0670 <[^>]*> nop
++0+0674 <[^>]*> nop
++0+0678 <[^>]*> nop
++0+067c <[^>]*> nop
++0+0680 <[^>]*> nop
++0+0684 <[^>]*> nop
++0+0688 <[^>]*> nop
++0+068c <[^>]*> nop
++0+0690 <[^>]*> nop
++0+0694 <[^>]*> nop
++0+0698 <[^>]*> nop
++0+069c <[^>]*> nop
++0+06a0 <[^>]*> nop
++0+06a4 <[^>]*> nop
++0+06a8 <[^>]*> nop
++0+06ac <[^>]*> nop
++0+06b0 <[^>]*> nop
++0+06b4 <[^>]*> nop
++0+06b8 <[^>]*> nop
++0+06bc <[^>]*> nop
++0+06c0 <[^>]*> nop
++0+06c4 <[^>]*> nop
++0+06c8 <[^>]*> nop
++0+06cc <[^>]*> nop
++0+06d0 <[^>]*> nop
++0+06d4 <[^>]*> nop
++0+06d8 <[^>]*> nop
++0+06dc <[^>]*> nop
++0+06e0 <[^>]*> nop
++0+06e4 <[^>]*> nop
++0+06e8 <[^>]*> nop
++0+06ec <[^>]*> nop
++0+06f0 <[^>]*> nop
++0+06f4 <[^>]*> nop
++0+06f8 <[^>]*> nop
++0+06fc <[^>]*> nop
++0+0700 <[^>]*> nop
++0+0704 <[^>]*> nop
++0+0708 <[^>]*> nop
++0+070c <[^>]*> nop
++0+0710 <[^>]*> nop
++0+0714 <[^>]*> nop
++0+0718 <[^>]*> nop
++0+071c <[^>]*> nop
++0+0720 <[^>]*> nop
++0+0724 <[^>]*> nop
++0+0728 <[^>]*> nop
++0+072c <[^>]*> nop
++0+0730 <[^>]*> nop
++0+0734 <[^>]*> nop
++0+0738 <[^>]*> nop
++0+073c <[^>]*> nop
++0+0740 <[^>]*> nop
++0+0744 <[^>]*> nop
++0+0748 <[^>]*> nop
++0+074c <[^>]*> nop
++0+0750 <[^>]*> nop
++0+0754 <[^>]*> nop
++0+0758 <[^>]*> nop
++0+075c <[^>]*> nop
++0+0760 <[^>]*> nop
++0+0764 <[^>]*> nop
++0+0768 <[^>]*> nop
++0+076c <[^>]*> nop
++0+0770 <[^>]*> nop
++0+0774 <[^>]*> nop
++0+0778 <[^>]*> nop
++0+077c <[^>]*> nop
++0+0780 <[^>]*> nop
++0+0784 <[^>]*> nop
++0+0788 <[^>]*> nop
++0+078c <[^>]*> nop
++0+0790 <[^>]*> nop
++0+0794 <[^>]*> nop
++0+0798 <[^>]*> nop
++0+079c <[^>]*> nop
++0+07a0 <[^>]*> nop
++0+07a4 <[^>]*> nop
++0+07a8 <[^>]*> nop
++0+07ac <[^>]*> nop
++0+07b0 <[^>]*> nop
++0+07b4 <[^>]*> nop
++0+07b8 <[^>]*> nop
++0+07bc <[^>]*> nop
++0+07c0 <[^>]*> nop
++0+07c4 <[^>]*> nop
++0+07c8 <[^>]*> nop
++0+07cc <[^>]*> nop
++0+07d0 <[^>]*> nop
++0+07d4 <[^>]*> nop
++0+07d8 <[^>]*> nop
++0+07dc <[^>]*> nop
++0+07e0 <[^>]*> nop
++0+07e4 <[^>]*> nop
++0+07e8 <[^>]*> nop
++0+07ec <[^>]*> nop
++0+07f0 <[^>]*> nop
++0+07f4 <[^>]*> nop
++0+07f8 <[^>]*> nop
++0+07fc <[^>]*> nop
++0+0800 <[^>]*> nop
++0+0804 <[^>]*> nop
++0+0808 <[^>]*> nop
++0+080c <[^>]*> nop
++0+0810 <[^>]*> nop
++0+0814 <[^>]*> nop
++0+0818 <[^>]*> nop
++0+081c <[^>]*> nop
++0+0820 <[^>]*> nop
++0+0824 <[^>]*> nop
++0+0828 <[^>]*> nop
++0+082c <[^>]*> nop
++0+0830 <[^>]*> nop
++0+0834 <[^>]*> nop
++0+0838 <[^>]*> nop
++0+083c <[^>]*> nop
++0+0840 <[^>]*> nop
++0+0844 <[^>]*> nop
++0+0848 <[^>]*> nop
++0+084c <[^>]*> nop
++0+0850 <[^>]*> nop
++0+0854 <[^>]*> nop
++0+0858 <[^>]*> nop
++0+085c <[^>]*> nop
++0+0860 <[^>]*> nop
++0+0864 <[^>]*> nop
++0+0868 <[^>]*> nop
++0+086c <[^>]*> nop
++0+0870 <[^>]*> nop
++0+0874 <[^>]*> nop
++0+0878 <[^>]*> nop
++0+087c <[^>]*> nop
++0+0880 <[^>]*> nop
++0+0884 <[^>]*> nop
++0+0888 <[^>]*> nop
++0+088c <[^>]*> nop
++0+0890 <[^>]*> nop
++0+0894 <[^>]*> nop
++0+0898 <[^>]*> nop
++0+089c <[^>]*> nop
++0+08a0 <[^>]*> nop
++0+08a4 <[^>]*> nop
++0+08a8 <[^>]*> nop
++0+08ac <[^>]*> nop
++0+08b0 <[^>]*> nop
++0+08b4 <[^>]*> nop
++0+08b8 <[^>]*> nop
++0+08bc <[^>]*> nop
++0+08c0 <[^>]*> nop
++0+08c4 <[^>]*> nop
++0+08c8 <[^>]*> nop
++0+08cc <[^>]*> nop
++0+08d0 <[^>]*> nop
++0+08d4 <[^>]*> nop
++0+08d8 <[^>]*> nop
++0+08dc <[^>]*> nop
++0+08e0 <[^>]*> nop
++0+08e4 <[^>]*> nop
++0+08e8 <[^>]*> nop
++0+08ec <[^>]*> nop
++0+08f0 <[^>]*> nop
++0+08f4 <[^>]*> nop
++0+08f8 <[^>]*> nop
++0+08fc <[^>]*> nop
++0+0900 <[^>]*> nop
++0+0904 <[^>]*> nop
++0+0908 <[^>]*> nop
++0+090c <[^>]*> nop
++0+0910 <[^>]*> nop
++0+0914 <[^>]*> nop
++0+0918 <[^>]*> nop
++0+091c <[^>]*> nop
++0+0920 <[^>]*> nop
++0+0924 <[^>]*> nop
++0+0928 <[^>]*> nop
++0+092c <[^>]*> nop
++0+0930 <[^>]*> nop
++0+0934 <[^>]*> nop
++0+0938 <[^>]*> nop
++0+093c <[^>]*> nop
++0+0940 <[^>]*> nop
++0+0944 <[^>]*> nop
++0+0948 <[^>]*> nop
++0+094c <[^>]*> nop
++0+0950 <[^>]*> nop
++0+0954 <[^>]*> nop
++0+0958 <[^>]*> nop
++0+095c <[^>]*> nop
++0+0960 <[^>]*> nop
++0+0964 <[^>]*> nop
++0+0968 <[^>]*> nop
++0+096c <[^>]*> nop
++0+0970 <[^>]*> nop
++0+0974 <[^>]*> nop
++0+0978 <[^>]*> nop
++0+097c <[^>]*> nop
++0+0980 <[^>]*> nop
++0+0984 <[^>]*> nop
++0+0988 <[^>]*> nop
++0+098c <[^>]*> nop
++0+0990 <[^>]*> nop
++0+0994 <[^>]*> nop
++0+0998 <[^>]*> nop
++0+099c <[^>]*> nop
++0+09a0 <[^>]*> nop
++0+09a4 <[^>]*> nop
++0+09a8 <[^>]*> nop
++0+09ac <[^>]*> nop
++0+09b0 <[^>]*> nop
++0+09b4 <[^>]*> nop
++0+09b8 <[^>]*> nop
++0+09bc <[^>]*> nop
++0+09c0 <[^>]*> nop
++0+09c4 <[^>]*> nop
++0+09c8 <[^>]*> nop
++0+09cc <[^>]*> nop
++0+09d0 <[^>]*> nop
++0+09d4 <[^>]*> nop
++0+09d8 <[^>]*> nop
++0+09dc <[^>]*> nop
++0+09e0 <[^>]*> nop
++0+09e4 <[^>]*> nop
++0+09e8 <[^>]*> nop
++0+09ec <[^>]*> nop
++0+09f0 <[^>]*> nop
++0+09f4 <[^>]*> nop
++0+09f8 <[^>]*> nop
++0+09fc <[^>]*> nop
++0+0a00 <[^>]*> nop
++0+0a04 <[^>]*> nop
++0+0a08 <[^>]*> nop
++0+0a0c <[^>]*> nop
++0+0a10 <[^>]*> nop
++0+0a14 <[^>]*> nop
++0+0a18 <[^>]*> nop
++0+0a1c <[^>]*> nop
++0+0a20 <[^>]*> nop
++0+0a24 <[^>]*> nop
++0+0a28 <[^>]*> nop
++0+0a2c <[^>]*> nop
++0+0a30 <[^>]*> nop
++0+0a34 <[^>]*> nop
++0+0a38 <[^>]*> nop
++0+0a3c <[^>]*> nop
++0+0a40 <[^>]*> nop
++0+0a44 <[^>]*> nop
++0+0a48 <[^>]*> nop
++0+0a4c <[^>]*> nop
++0+0a50 <[^>]*> nop
++0+0a54 <[^>]*> nop
++0+0a58 <[^>]*> nop
++0+0a5c <[^>]*> nop
++0+0a60 <[^>]*> nop
++0+0a64 <[^>]*> nop
++0+0a68 <[^>]*> nop
++0+0a6c <[^>]*> nop
++0+0a70 <[^>]*> nop
++0+0a74 <[^>]*> nop
++0+0a78 <[^>]*> nop
++0+0a7c <[^>]*> nop
++0+0a80 <[^>]*> nop
++0+0a84 <[^>]*> nop
++0+0a88 <[^>]*> nop
++0+0a8c <[^>]*> nop
++0+0a90 <[^>]*> nop
++0+0a94 <[^>]*> nop
++0+0a98 <[^>]*> nop
++0+0a9c <[^>]*> nop
++0+0aa0 <[^>]*> nop
++0+0aa4 <[^>]*> nop
++0+0aa8 <[^>]*> nop
++0+0aac <[^>]*> nop
++0+0ab0 <[^>]*> nop
++0+0ab4 <[^>]*> nop
++0+0ab8 <[^>]*> nop
++0+0abc <[^>]*> nop
++0+0ac0 <[^>]*> nop
++0+0ac4 <[^>]*> nop
++0+0ac8 <[^>]*> nop
++0+0acc <[^>]*> nop
++0+0ad0 <[^>]*> nop
++0+0ad4 <[^>]*> nop
++0+0ad8 <[^>]*> nop
++0+0adc <[^>]*> nop
++0+0ae0 <[^>]*> nop
++0+0ae4 <[^>]*> nop
++0+0ae8 <[^>]*> nop
++0+0aec <[^>]*> nop
++0+0af0 <[^>]*> nop
++0+0af4 <[^>]*> nop
++0+0af8 <[^>]*> nop
++0+0afc <[^>]*> nop
++0+0b00 <[^>]*> nop
++0+0b04 <[^>]*> nop
++0+0b08 <[^>]*> nop
++0+0b0c <[^>]*> nop
++0+0b10 <[^>]*> nop
++0+0b14 <[^>]*> nop
++0+0b18 <[^>]*> nop
++0+0b1c <[^>]*> nop
++0+0b20 <[^>]*> nop
++0+0b24 <[^>]*> nop
++0+0b28 <[^>]*> nop
++0+0b2c <[^>]*> nop
++0+0b30 <[^>]*> nop
++0+0b34 <[^>]*> nop
++0+0b38 <[^>]*> nop
++0+0b3c <[^>]*> nop
++0+0b40 <[^>]*> nop
++0+0b44 <[^>]*> nop
++0+0b48 <[^>]*> nop
++0+0b4c <[^>]*> nop
++0+0b50 <[^>]*> nop
++0+0b54 <[^>]*> nop
++0+0b58 <[^>]*> nop
++0+0b5c <[^>]*> nop
++0+0b60 <[^>]*> nop
++0+0b64 <[^>]*> nop
++0+0b68 <[^>]*> nop
++0+0b6c <[^>]*> nop
++0+0b70 <[^>]*> nop
++0+0b74 <[^>]*> nop
++0+0b78 <[^>]*> nop
++0+0b7c <[^>]*> nop
++0+0b80 <[^>]*> nop
++0+0b84 <[^>]*> nop
++0+0b88 <[^>]*> nop
++0+0b8c <[^>]*> nop
++0+0b90 <[^>]*> nop
++0+0b94 <[^>]*> nop
++0+0b98 <[^>]*> nop
++0+0b9c <[^>]*> nop
++0+0ba0 <[^>]*> nop
++0+0ba4 <[^>]*> nop
++0+0ba8 <[^>]*> nop
++0+0bac <[^>]*> nop
++0+0bb0 <[^>]*> nop
++0+0bb4 <[^>]*> nop
++0+0bb8 <[^>]*> nop
++0+0bbc <[^>]*> nop
++0+0bc0 <[^>]*> nop
++0+0bc4 <[^>]*> nop
++0+0bc8 <[^>]*> nop
++0+0bcc <[^>]*> nop
++0+0bd0 <[^>]*> nop
++0+0bd4 <[^>]*> nop
++0+0bd8 <[^>]*> nop
++0+0bdc <[^>]*> nop
++0+0be0 <[^>]*> nop
++0+0be4 <[^>]*> nop
++0+0be8 <[^>]*> nop
++0+0bec <[^>]*> nop
++0+0bf0 <[^>]*> nop
++0+0bf4 <[^>]*> nop
++0+0bf8 <[^>]*> nop
++0+0bfc <[^>]*> nop
++0+0c00 <[^>]*> nop
++0+0c04 <[^>]*> nop
++0+0c08 <[^>]*> nop
++0+0c0c <[^>]*> nop
++0+0c10 <[^>]*> nop
++0+0c14 <[^>]*> nop
++0+0c18 <[^>]*> nop
++0+0c1c <[^>]*> nop
++0+0c20 <[^>]*> nop
++0+0c24 <[^>]*> nop
++0+0c28 <[^>]*> nop
++0+0c2c <[^>]*> nop
++0+0c30 <[^>]*> nop
++0+0c34 <[^>]*> nop
++0+0c38 <[^>]*> nop
++0+0c3c <[^>]*> nop
++0+0c40 <[^>]*> nop
++0+0c44 <[^>]*> nop
++0+0c48 <[^>]*> nop
++0+0c4c <[^>]*> nop
++0+0c50 <[^>]*> nop
++0+0c54 <[^>]*> nop
++0+0c58 <[^>]*> nop
++0+0c5c <[^>]*> nop
++0+0c60 <[^>]*> nop
++0+0c64 <[^>]*> nop
++0+0c68 <[^>]*> nop
++0+0c6c <[^>]*> nop
++0+0c70 <[^>]*> nop
++0+0c74 <[^>]*> nop
++0+0c78 <[^>]*> nop
++0+0c7c <[^>]*> nop
++0+0c80 <[^>]*> nop
++0+0c84 <[^>]*> nop
++0+0c88 <[^>]*> nop
++0+0c8c <[^>]*> nop
++0+0c90 <[^>]*> nop
++0+0c94 <[^>]*> nop
++0+0c98 <[^>]*> nop
++0+0c9c <[^>]*> nop
++0+0ca0 <[^>]*> nop
++0+0ca4 <[^>]*> nop
++0+0ca8 <[^>]*> nop
++0+0cac <[^>]*> nop
++0+0cb0 <[^>]*> nop
++0+0cb4 <[^>]*> nop
++0+0cb8 <[^>]*> nop
++0+0cbc <[^>]*> nop
++0+0cc0 <[^>]*> nop
++0+0cc4 <[^>]*> nop
++0+0cc8 <[^>]*> nop
++0+0ccc <[^>]*> nop
++0+0cd0 <[^>]*> nop
++0+0cd4 <[^>]*> nop
++0+0cd8 <[^>]*> nop
++0+0cdc <[^>]*> nop
++0+0ce0 <[^>]*> nop
++0+0ce4 <[^>]*> nop
++0+0ce8 <[^>]*> nop
++0+0cec <[^>]*> nop
++0+0cf0 <[^>]*> nop
++0+0cf4 <[^>]*> nop
++0+0cf8 <[^>]*> nop
++0+0cfc <[^>]*> nop
++0+0d00 <[^>]*> nop
++0+0d04 <[^>]*> nop
++0+0d08 <[^>]*> nop
++0+0d0c <[^>]*> nop
++0+0d10 <[^>]*> nop
++0+0d14 <[^>]*> nop
++0+0d18 <[^>]*> nop
++0+0d1c <[^>]*> nop
++0+0d20 <[^>]*> nop
++0+0d24 <[^>]*> nop
++0+0d28 <[^>]*> nop
++0+0d2c <[^>]*> nop
++0+0d30 <[^>]*> nop
++0+0d34 <[^>]*> nop
++0+0d38 <[^>]*> nop
++0+0d3c <[^>]*> nop
++0+0d40 <[^>]*> nop
++0+0d44 <[^>]*> nop
++0+0d48 <[^>]*> nop
++0+0d4c <[^>]*> nop
++0+0d50 <[^>]*> nop
++0+0d54 <[^>]*> nop
++0+0d58 <[^>]*> nop
++0+0d5c <[^>]*> nop
++0+0d60 <[^>]*> nop
++0+0d64 <[^>]*> nop
++0+0d68 <[^>]*> nop
++0+0d6c <[^>]*> nop
++0+0d70 <[^>]*> nop
++0+0d74 <[^>]*> nop
++0+0d78 <[^>]*> nop
++0+0d7c <[^>]*> nop
++0+0d80 <[^>]*> nop
++0+0d84 <[^>]*> nop
++0+0d88 <[^>]*> nop
++0+0d8c <[^>]*> nop
++0+0d90 <[^>]*> nop
++0+0d94 <[^>]*> nop
++0+0d98 <[^>]*> nop
++0+0d9c <[^>]*> nop
++0+0da0 <[^>]*> nop
++0+0da4 <[^>]*> nop
++0+0da8 <[^>]*> nop
++0+0dac <[^>]*> nop
++0+0db0 <[^>]*> nop
++0+0db4 <[^>]*> nop
++0+0db8 <[^>]*> nop
++0+0dbc <[^>]*> nop
++0+0dc0 <[^>]*> nop
++0+0dc4 <[^>]*> nop
++0+0dc8 <[^>]*> nop
++0+0dcc <[^>]*> nop
++0+0dd0 <[^>]*> nop
++0+0dd4 <[^>]*> nop
++0+0dd8 <[^>]*> nop
++0+0ddc <[^>]*> nop
++0+0de0 <[^>]*> nop
++0+0de4 <[^>]*> nop
++0+0de8 <[^>]*> nop
++0+0dec <[^>]*> nop
++0+0df0 <[^>]*> nop
++0+0df4 <[^>]*> nop
++0+0df8 <[^>]*> nop
++0+0dfc <[^>]*> nop
++0+0e00 <[^>]*> nop
++0+0e04 <[^>]*> nop
++0+0e08 <[^>]*> nop
++0+0e0c <[^>]*> nop
++0+0e10 <[^>]*> nop
++0+0e14 <[^>]*> nop
++0+0e18 <[^>]*> nop
++0+0e1c <[^>]*> nop
++0+0e20 <[^>]*> nop
++0+0e24 <[^>]*> nop
++0+0e28 <[^>]*> nop
++0+0e2c <[^>]*> nop
++0+0e30 <[^>]*> nop
++0+0e34 <[^>]*> nop
++0+0e38 <[^>]*> nop
++0+0e3c <[^>]*> nop
++0+0e40 <[^>]*> nop
++0+0e44 <[^>]*> nop
++0+0e48 <[^>]*> nop
++0+0e4c <[^>]*> nop
++0+0e50 <[^>]*> nop
++0+0e54 <[^>]*> nop
++0+0e58 <[^>]*> nop
++0+0e5c <[^>]*> nop
++0+0e60 <[^>]*> nop
++0+0e64 <[^>]*> nop
++0+0e68 <[^>]*> nop
++0+0e6c <[^>]*> nop
++0+0e70 <[^>]*> nop
++0+0e74 <[^>]*> nop
++0+0e78 <[^>]*> nop
++0+0e7c <[^>]*> nop
++0+0e80 <[^>]*> nop
++0+0e84 <[^>]*> nop
++0+0e88 <[^>]*> nop
++0+0e8c <[^>]*> nop
++0+0e90 <[^>]*> nop
++0+0e94 <[^>]*> nop
++0+0e98 <[^>]*> nop
++0+0e9c <[^>]*> nop
++0+0ea0 <[^>]*> nop
++0+0ea4 <[^>]*> nop
++0+0ea8 <[^>]*> nop
++0+0eac <[^>]*> nop
++0+0eb0 <[^>]*> nop
++0+0eb4 <[^>]*> nop
++0+0eb8 <[^>]*> nop
++0+0ebc <[^>]*> nop
++0+0ec0 <[^>]*> nop
++0+0ec4 <[^>]*> nop
++0+0ec8 <[^>]*> nop
++0+0ecc <[^>]*> nop
++0+0ed0 <[^>]*> nop
++0+0ed4 <[^>]*> nop
++0+0ed8 <[^>]*> nop
++0+0edc <[^>]*> nop
++0+0ee0 <[^>]*> nop
++0+0ee4 <[^>]*> nop
++0+0ee8 <[^>]*> nop
++0+0eec <[^>]*> nop
++0+0ef0 <[^>]*> nop
++0+0ef4 <[^>]*> nop
++0+0ef8 <[^>]*> nop
++0+0efc <[^>]*> nop
++0+0f00 <[^>]*> nop
++0+0f04 <[^>]*> nop
++0+0f08 <[^>]*> nop
++0+0f0c <[^>]*> nop
++0+0f10 <[^>]*> nop
++0+0f14 <[^>]*> nop
++0+0f18 <[^>]*> nop
++0+0f1c <[^>]*> nop
++0+0f20 <[^>]*> nop
++0+0f24 <[^>]*> nop
++0+0f28 <[^>]*> nop
++0+0f2c <[^>]*> nop
++0+0f30 <[^>]*> nop
++0+0f34 <[^>]*> nop
++0+0f38 <[^>]*> nop
++0+0f3c <[^>]*> nop
++0+0f40 <[^>]*> nop
++0+0f44 <[^>]*> nop
++0+0f48 <[^>]*> nop
++0+0f4c <[^>]*> nop
++0+0f50 <[^>]*> nop
++0+0f54 <[^>]*> nop
++0+0f58 <[^>]*> nop
++0+0f5c <[^>]*> nop
++0+0f60 <[^>]*> nop
++0+0f64 <[^>]*> nop
++0+0f68 <[^>]*> nop
++0+0f6c <[^>]*> nop
++0+0f70 <[^>]*> nop
++0+0f74 <[^>]*> nop
++0+0f78 <[^>]*> nop
++0+0f7c <[^>]*> nop
++0+0f80 <[^>]*> nop
++0+0f84 <[^>]*> nop
++0+0f88 <[^>]*> nop
++0+0f8c <[^>]*> nop
++0+0f90 <[^>]*> nop
++0+0f94 <[^>]*> nop
++0+0f98 <[^>]*> nop
++0+0f9c <[^>]*> nop
++0+0fa0 <[^>]*> nop
++0+0fa4 <[^>]*> nop
++0+0fa8 <[^>]*> nop
++0+0fac <[^>]*> nop
++0+0fb0 <[^>]*> nop
++0+0fb4 <[^>]*> nop
++0+0fb8 <[^>]*> nop
++0+0fbc <[^>]*> nop
++0+0fc0 <[^>]*> nop
++0+0fc4 <[^>]*> nop
++0+0fc8 <[^>]*> nop
++0+0fcc <[^>]*> nop
++0+0fd0 <[^>]*> nop
++0+0fd4 <[^>]*> nop
++0+0fd8 <[^>]*> nop
++0+0fdc <[^>]*> nop
++0+0fe0 <[^>]*> nop
++0+0fe4 <[^>]*> nop
++0+0fe8 <[^>]*> nop
++0+0fec <[^>]*> nop
++0+0ff0 <[^>]*> nop
++0+0ff4 <[^>]*> nop
++0+0ff8 <[^>]*> nop
++0+0ffc <[^>]*> nop
++0+1000 <[^>]*> nop
++0+1004 <[^>]*> nop
++0+1008 <[^>]*> nop
++0+100c <[^>]*> nop
++0+1010 <[^>]*> nop
++0+1014 <[^>]*> nop
++0+1018 <[^>]*> nop
++0+101c <[^>]*> nop
++0+1020 <[^>]*> nop
++0+1024 <[^>]*> nop
++0+1028 <[^>]*> nop
++0+102c <[^>]*> nop
++0+1030 <[^>]*> nop
++0+1034 <[^>]*> nop
++0+1038 <[^>]*> nop
++0+103c <[^>]*> nop
++0+1040 <[^>]*> nop
++0+1044 <[^>]*> nop
++0+1048 <[^>]*> nop
++0+104c <[^>]*> nop
++0+1050 <[^>]*> nop
++0+1054 <[^>]*> nop
++0+1058 <[^>]*> nop
++0+105c <[^>]*> nop
++0+1060 <[^>]*> nop
++0+1064 <[^>]*> nop
++0+1068 <[^>]*> nop
++0+106c <[^>]*> nop
++0+1070 <[^>]*> nop
++0+1074 <[^>]*> nop
++0+1078 <[^>]*> nop
++0+107c <[^>]*> nop
++0+1080 <[^>]*> nop
++0+1084 <[^>]*> nop
++0+1088 <[^>]*> nop
++0+108c <[^>]*> nop
++0+1090 <[^>]*> nop
++0+1094 <[^>]*> nop
++0+1098 <[^>]*> nop
++0+109c <[^>]*> nop
++0+10a0 <[^>]*> nop
++0+10a4 <[^>]*> nop
++0+10a8 <[^>]*> nop
++0+10ac <[^>]*> nop
++0+10b0 <[^>]*> nop
++0+10b4 <[^>]*> nop
++0+10b8 <[^>]*> nop
++0+10bc <[^>]*> nop
++0+10c0 <[^>]*> nop
++0+10c4 <[^>]*> nop
++0+10c8 <[^>]*> nop
++0+10cc <[^>]*> nop
++0+10d0 <[^>]*> nop
++0+10d4 <[^>]*> nop
++0+10d8 <[^>]*> nop
++0+10dc <[^>]*> nop
++0+10e0 <[^>]*> nop
++0+10e4 <[^>]*> nop
++0+10e8 <[^>]*> nop
++0+10ec <[^>]*> nop
++0+10f0 <[^>]*> nop
++0+10f4 <[^>]*> nop
++0+10f8 <[^>]*> nop
++0+10fc <[^>]*> nop
++0+1100 <[^>]*> nop
++0+1104 <[^>]*> nop
++0+1108 <[^>]*> nop
++0+110c <[^>]*> nop
++0+1110 <[^>]*> nop
++0+1114 <[^>]*> nop
++0+1118 <[^>]*> nop
++0+111c <[^>]*> nop
++0+1120 <[^>]*> nop
++0+1124 <[^>]*> nop
++0+1128 <[^>]*> nop
++0+112c <[^>]*> nop
++0+1130 <[^>]*> nop
++0+1134 <[^>]*> nop
++0+1138 <[^>]*> nop
++0+113c <[^>]*> nop
++0+1140 <[^>]*> nop
++0+1144 <[^>]*> nop
++0+1148 <[^>]*> nop
++0+114c <[^>]*> nop
++0+1150 <[^>]*> nop
++0+1154 <[^>]*> nop
++0+1158 <[^>]*> nop
++0+115c <[^>]*> nop
++0+1160 <[^>]*> nop
++0+1164 <[^>]*> nop
++0+1168 <[^>]*> nop
++0+116c <[^>]*> nop
++0+1170 <[^>]*> nop
++0+1174 <[^>]*> nop
++0+1178 <[^>]*> nop
++0+117c <[^>]*> nop
++0+1180 <[^>]*> nop
++0+1184 <[^>]*> nop
++0+1188 <[^>]*> nop
++0+118c <[^>]*> nop
++0+1190 <[^>]*> nop
++0+1194 <[^>]*> nop
++0+1198 <[^>]*> nop
++0+119c <[^>]*> nop
++0+11a0 <[^>]*> nop
++0+11a4 <[^>]*> nop
++0+11a8 <[^>]*> nop
++0+11ac <[^>]*> nop
++0+11b0 <[^>]*> nop
++0+11b4 <[^>]*> nop
++0+11b8 <[^>]*> nop
++0+11bc <[^>]*> nop
++0+11c0 <[^>]*> nop
++0+11c4 <[^>]*> nop
++0+11c8 <[^>]*> nop
++0+11cc <[^>]*> nop
++0+11d0 <[^>]*> nop
++0+11d4 <[^>]*> nop
++0+11d8 <[^>]*> nop
++0+11dc <[^>]*> nop
++0+11e0 <[^>]*> nop
++0+11e4 <[^>]*> nop
++0+11e8 <[^>]*> nop
++0+11ec <[^>]*> nop
++0+11f0 <[^>]*> nop
++0+11f4 <[^>]*> nop
++0+11f8 <[^>]*> nop
++0+11fc <[^>]*> nop
++0+1200 <[^>]*> nop
++0+1204 <[^>]*> nop
++0+1208 <[^>]*> nop
++0+120c <[^>]*> nop
++0+1210 <[^>]*> nop
++0+1214 <[^>]*> nop
++0+1218 <[^>]*> nop
++0+121c <[^>]*> nop
++0+1220 <[^>]*> nop
++0+1224 <[^>]*> nop
++0+1228 <[^>]*> nop
++0+122c <[^>]*> nop
++0+1230 <[^>]*> nop
++0+1234 <[^>]*> nop
++0+1238 <[^>]*> nop
++0+123c <[^>]*> nop
++0+1240 <[^>]*> nop
++0+1244 <[^>]*> nop
++0+1248 <[^>]*> nop
++0+124c <[^>]*> nop
++0+1250 <[^>]*> nop
++0+1254 <[^>]*> nop
++0+1258 <[^>]*> nop
++0+125c <[^>]*> nop
++0+1260 <[^>]*> nop
++0+1264 <[^>]*> nop
++0+1268 <[^>]*> nop
++0+126c <[^>]*> nop
++0+1270 <[^>]*> nop
++0+1274 <[^>]*> nop
++0+1278 <[^>]*> nop
++0+127c <[^>]*> nop
++0+1280 <[^>]*> nop
++0+1284 <[^>]*> nop
++0+1288 <[^>]*> nop
++0+128c <[^>]*> nop
++0+1290 <[^>]*> nop
++0+1294 <[^>]*> nop
++0+1298 <[^>]*> nop
++0+129c <[^>]*> nop
++0+12a0 <[^>]*> nop
++0+12a4 <[^>]*> nop
++0+12a8 <[^>]*> nop
++0+12ac <[^>]*> nop
++0+12b0 <[^>]*> nop
++0+12b4 <[^>]*> nop
++0+12b8 <[^>]*> nop
++0+12bc <[^>]*> nop
++0+12c0 <[^>]*> nop
++0+12c4 <[^>]*> nop
++0+12c8 <[^>]*> nop
++0+12cc <[^>]*> nop
++0+12d0 <[^>]*> nop
++0+12d4 <[^>]*> nop
++0+12d8 <[^>]*> nop
++0+12dc <[^>]*> nop
++0+12e0 <[^>]*> nop
++0+12e4 <[^>]*> nop
++0+12e8 <[^>]*> nop
++0+12ec <[^>]*> nop
++0+12f0 <[^>]*> nop
++0+12f4 <[^>]*> nop
++0+12f8 <[^>]*> nop
++0+12fc <[^>]*> nop
++0+1300 <[^>]*> nop
++0+1304 <[^>]*> nop
++0+1308 <[^>]*> nop
++0+130c <[^>]*> nop
++0+1310 <[^>]*> nop
++0+1314 <[^>]*> nop
++0+1318 <[^>]*> nop
++0+131c <[^>]*> nop
++0+1320 <[^>]*> nop
++0+1324 <[^>]*> nop
++0+1328 <[^>]*> nop
++0+132c <[^>]*> nop
++0+1330 <[^>]*> nop
++0+1334 <[^>]*> nop
++0+1338 <[^>]*> nop
++0+133c <[^>]*> nop
++0+1340 <[^>]*> nop
++0+1344 <[^>]*> nop
++0+1348 <[^>]*> nop
++0+134c <[^>]*> nop
++0+1350 <[^>]*> nop
++0+1354 <[^>]*> nop
++0+1358 <[^>]*> nop
++0+135c <[^>]*> nop
++0+1360 <[^>]*> nop
++0+1364 <[^>]*> nop
++0+1368 <[^>]*> nop
++0+136c <[^>]*> nop
++0+1370 <[^>]*> nop
++0+1374 <[^>]*> nop
++0+1378 <[^>]*> nop
++0+137c <[^>]*> nop
++0+1380 <[^>]*> nop
++0+1384 <[^>]*> nop
++0+1388 <[^>]*> nop
++0+138c <[^>]*> nop
++0+1390 <[^>]*> nop
++0+1394 <[^>]*> nop
++0+1398 <[^>]*> nop
++0+139c <[^>]*> nop
++0+13a0 <[^>]*> nop
++0+13a4 <[^>]*> nop
++0+13a8 <[^>]*> nop
++0+13ac <[^>]*> nop
++0+13b0 <[^>]*> nop
++0+13b4 <[^>]*> nop
++0+13b8 <[^>]*> nop
++0+13bc <[^>]*> nop
++0+13c0 <[^>]*> nop
++0+13c4 <[^>]*> nop
++0+13c8 <[^>]*> nop
++0+13cc <[^>]*> nop
++0+13d0 <[^>]*> nop
++0+13d4 <[^>]*> nop
++0+13d8 <[^>]*> nop
++0+13dc <[^>]*> nop
++0+13e0 <[^>]*> nop
++0+13e4 <[^>]*> nop
++0+13e8 <[^>]*> nop
++0+13ec <[^>]*> nop
++0+13f0 <[^>]*> nop
++0+13f4 <[^>]*> nop
++0+13f8 <[^>]*> nop
++0+13fc <[^>]*> nop
++0+1400 <[^>]*> nop
++0+1404 <[^>]*> nop
++0+1408 <[^>]*> nop
++0+140c <[^>]*> nop
++0+1410 <[^>]*> nop
++0+1414 <[^>]*> nop
++0+1418 <[^>]*> nop
++0+141c <[^>]*> nop
++0+1420 <[^>]*> nop
++0+1424 <[^>]*> nop
++0+1428 <[^>]*> nop
++0+142c <[^>]*> nop
++0+1430 <[^>]*> nop
++0+1434 <[^>]*> nop
++0+1438 <[^>]*> nop
++0+143c <[^>]*> nop
++0+1440 <[^>]*> nop
++0+1444 <[^>]*> nop
++0+1448 <[^>]*> nop
++0+144c <[^>]*> nop
++0+1450 <[^>]*> nop
++0+1454 <[^>]*> nop
++0+1458 <[^>]*> nop
++0+145c <[^>]*> nop
++0+1460 <[^>]*> nop
++0+1464 <[^>]*> nop
++0+1468 <[^>]*> nop
++0+146c <[^>]*> nop
++0+1470 <[^>]*> nop
++0+1474 <[^>]*> nop
++0+1478 <[^>]*> nop
++0+147c <[^>]*> nop
++0+1480 <[^>]*> nop
++0+1484 <[^>]*> nop
++0+1488 <[^>]*> nop
++0+148c <[^>]*> nop
++0+1490 <[^>]*> nop
++0+1494 <[^>]*> nop
++0+1498 <[^>]*> nop
++0+149c <[^>]*> nop
++0+14a0 <[^>]*> nop
++0+14a4 <[^>]*> nop
++0+14a8 <[^>]*> nop
++0+14ac <[^>]*> nop
++0+14b0 <[^>]*> nop
++0+14b4 <[^>]*> nop
++0+14b8 <[^>]*> nop
++0+14bc <[^>]*> nop
++0+14c0 <[^>]*> nop
++0+14c4 <[^>]*> nop
++0+14c8 <[^>]*> nop
++0+14cc <[^>]*> nop
++0+14d0 <[^>]*> nop
++0+14d4 <[^>]*> nop
++0+14d8 <[^>]*> nop
++0+14dc <[^>]*> nop
++0+14e0 <[^>]*> nop
++0+14e4 <[^>]*> nop
++0+14e8 <[^>]*> nop
++0+14ec <[^>]*> nop
++0+14f0 <[^>]*> nop
++0+14f4 <[^>]*> nop
++0+14f8 <[^>]*> nop
++0+14fc <[^>]*> nop
++0+1500 <[^>]*> nop
++0+1504 <[^>]*> nop
++0+1508 <[^>]*> nop
++0+150c <[^>]*> nop
++0+1510 <[^>]*> nop
++0+1514 <[^>]*> nop
++0+1518 <[^>]*> nop
++0+151c <[^>]*> nop
++0+1520 <[^>]*> nop
++0+1524 <[^>]*> nop
++0+1528 <[^>]*> nop
++0+152c <[^>]*> nop
++0+1530 <[^>]*> nop
++0+1534 <[^>]*> nop
++0+1538 <[^>]*> nop
++0+153c <[^>]*> nop
++0+1540 <[^>]*> nop
++0+1544 <[^>]*> nop
++0+1548 <[^>]*> nop
++0+154c <[^>]*> nop
++0+1550 <[^>]*> nop
++0+1554 <[^>]*> nop
++0+1558 <[^>]*> nop
++0+155c <[^>]*> nop
++0+1560 <[^>]*> nop
++0+1564 <[^>]*> nop
++0+1568 <[^>]*> nop
++0+156c <[^>]*> nop
++0+1570 <[^>]*> nop
++0+1574 <[^>]*> nop
++0+1578 <[^>]*> nop
++0+157c <[^>]*> nop
++0+1580 <[^>]*> nop
++0+1584 <[^>]*> nop
++0+1588 <[^>]*> nop
++0+158c <[^>]*> nop
++0+1590 <[^>]*> nop
++0+1594 <[^>]*> nop
++0+1598 <[^>]*> nop
++0+159c <[^>]*> nop
++0+15a0 <[^>]*> nop
++0+15a4 <[^>]*> nop
++0+15a8 <[^>]*> nop
++0+15ac <[^>]*> nop
++0+15b0 <[^>]*> nop
++0+15b4 <[^>]*> nop
++0+15b8 <[^>]*> nop
++0+15bc <[^>]*> nop
++0+15c0 <[^>]*> nop
++0+15c4 <[^>]*> nop
++0+15c8 <[^>]*> nop
++0+15cc <[^>]*> nop
++0+15d0 <[^>]*> nop
++0+15d4 <[^>]*> nop
++0+15d8 <[^>]*> nop
++0+15dc <[^>]*> nop
++0+15e0 <[^>]*> nop
++0+15e4 <[^>]*> nop
++0+15e8 <[^>]*> nop
++0+15ec <[^>]*> nop
++0+15f0 <[^>]*> nop
++0+15f4 <[^>]*> nop
++0+15f8 <[^>]*> nop
++0+15fc <[^>]*> nop
++0+1600 <[^>]*> nop
++0+1604 <[^>]*> nop
++0+1608 <[^>]*> nop
++0+160c <[^>]*> nop
++0+1610 <[^>]*> nop
++0+1614 <[^>]*> nop
++0+1618 <[^>]*> nop
++0+161c <[^>]*> nop
++0+1620 <[^>]*> nop
++0+1624 <[^>]*> nop
++0+1628 <[^>]*> nop
++0+162c <[^>]*> nop
++0+1630 <[^>]*> nop
++0+1634 <[^>]*> nop
++0+1638 <[^>]*> nop
++0+163c <[^>]*> nop
++0+1640 <[^>]*> nop
++0+1644 <[^>]*> nop
++0+1648 <[^>]*> nop
++0+164c <[^>]*> nop
++0+1650 <[^>]*> nop
++0+1654 <[^>]*> nop
++0+1658 <[^>]*> nop
++0+165c <[^>]*> nop
++0+1660 <[^>]*> nop
++0+1664 <[^>]*> nop
++0+1668 <[^>]*> nop
++0+166c <[^>]*> nop
++0+1670 <[^>]*> nop
++0+1674 <[^>]*> nop
++0+1678 <[^>]*> nop
++0+167c <[^>]*> nop
++0+1680 <[^>]*> nop
++0+1684 <[^>]*> nop
++0+1688 <[^>]*> nop
++0+168c <[^>]*> nop
++0+1690 <[^>]*> nop
++0+1694 <[^>]*> nop
++0+1698 <[^>]*> nop
++0+169c <[^>]*> nop
++0+16a0 <[^>]*> nop
++0+16a4 <[^>]*> nop
++0+16a8 <[^>]*> nop
++0+16ac <[^>]*> nop
++0+16b0 <[^>]*> nop
++0+16b4 <[^>]*> nop
++0+16b8 <[^>]*> nop
++0+16bc <[^>]*> nop
++0+16c0 <[^>]*> nop
++0+16c4 <[^>]*> nop
++0+16c8 <[^>]*> nop
++0+16cc <[^>]*> nop
++0+16d0 <[^>]*> nop
++0+16d4 <[^>]*> nop
++0+16d8 <[^>]*> nop
++0+16dc <[^>]*> nop
++0+16e0 <[^>]*> nop
++0+16e4 <[^>]*> nop
++0+16e8 <[^>]*> nop
++0+16ec <[^>]*> nop
++0+16f0 <[^>]*> nop
++0+16f4 <[^>]*> nop
++0+16f8 <[^>]*> nop
++0+16fc <[^>]*> nop
++0+1700 <[^>]*> nop
++0+1704 <[^>]*> nop
++0+1708 <[^>]*> nop
++0+170c <[^>]*> nop
++0+1710 <[^>]*> nop
++0+1714 <[^>]*> nop
++0+1718 <[^>]*> nop
++0+171c <[^>]*> nop
++0+1720 <[^>]*> nop
++0+1724 <[^>]*> nop
++0+1728 <[^>]*> nop
++0+172c <[^>]*> nop
++0+1730 <[^>]*> nop
++0+1734 <[^>]*> nop
++0+1738 <[^>]*> nop
++0+173c <[^>]*> nop
++0+1740 <[^>]*> nop
++0+1744 <[^>]*> nop
++0+1748 <[^>]*> nop
++0+174c <[^>]*> nop
++0+1750 <[^>]*> nop
++0+1754 <[^>]*> nop
++0+1758 <[^>]*> nop
++0+175c <[^>]*> nop
++0+1760 <[^>]*> nop
++0+1764 <[^>]*> nop
++0+1768 <[^>]*> nop
++0+176c <[^>]*> nop
++0+1770 <[^>]*> nop
++0+1774 <[^>]*> nop
++0+1778 <[^>]*> nop
++0+177c <[^>]*> nop
++0+1780 <[^>]*> nop
++0+1784 <[^>]*> nop
++0+1788 <[^>]*> nop
++0+178c <[^>]*> nop
++0+1790 <[^>]*> nop
++0+1794 <[^>]*> nop
++0+1798 <[^>]*> nop
++0+179c <[^>]*> nop
++0+17a0 <[^>]*> nop
++0+17a4 <[^>]*> nop
++0+17a8 <[^>]*> nop
++0+17ac <[^>]*> nop
++0+17b0 <[^>]*> nop
++0+17b4 <[^>]*> nop
++0+17b8 <[^>]*> nop
++0+17bc <[^>]*> nop
++0+17c0 <[^>]*> nop
++0+17c4 <[^>]*> nop
++0+17c8 <[^>]*> nop
++0+17cc <[^>]*> nop
++0+17d0 <[^>]*> nop
++0+17d4 <[^>]*> nop
++0+17d8 <[^>]*> nop
++0+17dc <[^>]*> nop
++0+17e0 <[^>]*> nop
++0+17e4 <[^>]*> nop
++0+17e8 <[^>]*> nop
++0+17ec <[^>]*> nop
++0+17f0 <[^>]*> nop
++0+17f4 <[^>]*> nop
++0+17f8 <[^>]*> nop
++0+17fc <[^>]*> nop
++0+1800 <[^>]*> nop
++0+1804 <[^>]*> nop
++0+1808 <[^>]*> nop
++0+180c <[^>]*> nop
++0+1810 <[^>]*> nop
++0+1814 <[^>]*> nop
++0+1818 <[^>]*> nop
++0+181c <[^>]*> nop
++0+1820 <[^>]*> nop
++0+1824 <[^>]*> nop
++0+1828 <[^>]*> nop
++0+182c <[^>]*> nop
++0+1830 <[^>]*> nop
++0+1834 <[^>]*> nop
++0+1838 <[^>]*> nop
++0+183c <[^>]*> nop
++0+1840 <[^>]*> nop
++0+1844 <[^>]*> nop
++0+1848 <[^>]*> nop
++0+184c <[^>]*> nop
++0+1850 <[^>]*> nop
++0+1854 <[^>]*> nop
++0+1858 <[^>]*> nop
++0+185c <[^>]*> nop
++0+1860 <[^>]*> nop
++0+1864 <[^>]*> nop
++0+1868 <[^>]*> nop
++0+186c <[^>]*> nop
++0+1870 <[^>]*> nop
++0+1874 <[^>]*> nop
++0+1878 <[^>]*> nop
++0+187c <[^>]*> nop
++0+1880 <[^>]*> nop
++0+1884 <[^>]*> nop
++0+1888 <[^>]*> nop
++0+188c <[^>]*> nop
++0+1890 <[^>]*> nop
++0+1894 <[^>]*> nop
++0+1898 <[^>]*> nop
++0+189c <[^>]*> nop
++0+18a0 <[^>]*> nop
++0+18a4 <[^>]*> nop
++0+18a8 <[^>]*> nop
++0+18ac <[^>]*> nop
++0+18b0 <[^>]*> nop
++0+18b4 <[^>]*> nop
++0+18b8 <[^>]*> nop
++0+18bc <[^>]*> nop
++0+18c0 <[^>]*> nop
++0+18c4 <[^>]*> nop
++0+18c8 <[^>]*> nop
++0+18cc <[^>]*> nop
++0+18d0 <[^>]*> nop
++0+18d4 <[^>]*> nop
++0+18d8 <[^>]*> nop
++0+18dc <[^>]*> nop
++0+18e0 <[^>]*> nop
++0+18e4 <[^>]*> nop
++0+18e8 <[^>]*> nop
++0+18ec <[^>]*> nop
++0+18f0 <[^>]*> nop
++0+18f4 <[^>]*> nop
++0+18f8 <[^>]*> nop
++0+18fc <[^>]*> nop
++0+1900 <[^>]*> nop
++0+1904 <[^>]*> nop
++0+1908 <[^>]*> nop
++0+190c <[^>]*> nop
++0+1910 <[^>]*> nop
++0+1914 <[^>]*> nop
++0+1918 <[^>]*> nop
++0+191c <[^>]*> nop
++0+1920 <[^>]*> nop
++0+1924 <[^>]*> nop
++0+1928 <[^>]*> nop
++0+192c <[^>]*> nop
++0+1930 <[^>]*> nop
++0+1934 <[^>]*> nop
++0+1938 <[^>]*> nop
++0+193c <[^>]*> nop
++0+1940 <[^>]*> nop
++0+1944 <[^>]*> nop
++0+1948 <[^>]*> nop
++0+194c <[^>]*> nop
++0+1950 <[^>]*> nop
++0+1954 <[^>]*> nop
++0+1958 <[^>]*> nop
++0+195c <[^>]*> nop
++0+1960 <[^>]*> nop
++0+1964 <[^>]*> nop
++0+1968 <[^>]*> nop
++0+196c <[^>]*> nop
++0+1970 <[^>]*> nop
++0+1974 <[^>]*> nop
++0+1978 <[^>]*> nop
++0+197c <[^>]*> nop
++0+1980 <[^>]*> nop
++0+1984 <[^>]*> nop
++0+1988 <[^>]*> nop
++0+198c <[^>]*> nop
++0+1990 <[^>]*> nop
++0+1994 <[^>]*> nop
++0+1998 <[^>]*> nop
++0+199c <[^>]*> nop
++0+19a0 <[^>]*> nop
++0+19a4 <[^>]*> nop
++0+19a8 <[^>]*> nop
++0+19ac <[^>]*> nop
++0+19b0 <[^>]*> nop
++0+19b4 <[^>]*> nop
++0+19b8 <[^>]*> nop
++0+19bc <[^>]*> nop
++0+19c0 <[^>]*> nop
++0+19c4 <[^>]*> nop
++0+19c8 <[^>]*> nop
++0+19cc <[^>]*> nop
++0+19d0 <[^>]*> nop
++0+19d4 <[^>]*> nop
++0+19d8 <[^>]*> nop
++0+19dc <[^>]*> nop
++0+19e0 <[^>]*> nop
++0+19e4 <[^>]*> nop
++0+19e8 <[^>]*> nop
++0+19ec <[^>]*> nop
++0+19f0 <[^>]*> nop
++0+19f4 <[^>]*> nop
++0+19f8 <[^>]*> nop
++0+19fc <[^>]*> nop
++0+1a00 <[^>]*> nop
++0+1a04 <[^>]*> nop
++0+1a08 <[^>]*> nop
++0+1a0c <[^>]*> nop
++0+1a10 <[^>]*> nop
++0+1a14 <[^>]*> nop
++0+1a18 <[^>]*> nop
++0+1a1c <[^>]*> nop
++0+1a20 <[^>]*> nop
++0+1a24 <[^>]*> nop
++0+1a28 <[^>]*> nop
++0+1a2c <[^>]*> nop
++0+1a30 <[^>]*> nop
++0+1a34 <[^>]*> nop
++0+1a38 <[^>]*> nop
++0+1a3c <[^>]*> nop
++0+1a40 <[^>]*> nop
++0+1a44 <[^>]*> nop
++0+1a48 <[^>]*> nop
++0+1a4c <[^>]*> nop
++0+1a50 <[^>]*> nop
++0+1a54 <[^>]*> nop
++0+1a58 <[^>]*> nop
++0+1a5c <[^>]*> nop
++0+1a60 <[^>]*> nop
++0+1a64 <[^>]*> nop
++0+1a68 <[^>]*> nop
++0+1a6c <[^>]*> nop
++0+1a70 <[^>]*> nop
++0+1a74 <[^>]*> nop
++0+1a78 <[^>]*> nop
++0+1a7c <[^>]*> nop
++0+1a80 <[^>]*> nop
++0+1a84 <[^>]*> nop
++0+1a88 <[^>]*> nop
++0+1a8c <[^>]*> nop
++0+1a90 <[^>]*> nop
++0+1a94 <[^>]*> nop
++0+1a98 <[^>]*> nop
++0+1a9c <[^>]*> nop
++0+1aa0 <[^>]*> nop
++0+1aa4 <[^>]*> nop
++0+1aa8 <[^>]*> nop
++0+1aac <[^>]*> nop
++0+1ab0 <[^>]*> nop
++0+1ab4 <[^>]*> nop
++0+1ab8 <[^>]*> nop
++0+1abc <[^>]*> nop
++0+1ac0 <[^>]*> nop
++0+1ac4 <[^>]*> nop
++0+1ac8 <[^>]*> nop
++0+1acc <[^>]*> nop
++0+1ad0 <[^>]*> nop
++0+1ad4 <[^>]*> nop
++0+1ad8 <[^>]*> nop
++0+1adc <[^>]*> nop
++0+1ae0 <[^>]*> nop
++0+1ae4 <[^>]*> nop
++0+1ae8 <[^>]*> nop
++0+1aec <[^>]*> nop
++0+1af0 <[^>]*> nop
++0+1af4 <[^>]*> nop
++0+1af8 <[^>]*> nop
++0+1afc <[^>]*> nop
++0+1b00 <[^>]*> nop
++0+1b04 <[^>]*> nop
++0+1b08 <[^>]*> nop
++0+1b0c <[^>]*> nop
++0+1b10 <[^>]*> nop
++0+1b14 <[^>]*> nop
++0+1b18 <[^>]*> nop
++0+1b1c <[^>]*> nop
++0+1b20 <[^>]*> nop
++0+1b24 <[^>]*> nop
++0+1b28 <[^>]*> nop
++0+1b2c <[^>]*> nop
++0+1b30 <[^>]*> nop
++0+1b34 <[^>]*> nop
++0+1b38 <[^>]*> nop
++0+1b3c <[^>]*> nop
++0+1b40 <[^>]*> nop
++0+1b44 <[^>]*> nop
++0+1b48 <[^>]*> nop
++0+1b4c <[^>]*> nop
++0+1b50 <[^>]*> nop
++0+1b54 <[^>]*> nop
++0+1b58 <[^>]*> nop
++0+1b5c <[^>]*> nop
++0+1b60 <[^>]*> nop
++0+1b64 <[^>]*> nop
++0+1b68 <[^>]*> nop
++0+1b6c <[^>]*> nop
++0+1b70 <[^>]*> nop
++0+1b74 <[^>]*> nop
++0+1b78 <[^>]*> nop
++0+1b7c <[^>]*> nop
++0+1b80 <[^>]*> nop
++0+1b84 <[^>]*> nop
++0+1b88 <[^>]*> nop
++0+1b8c <[^>]*> nop
++0+1b90 <[^>]*> nop
++0+1b94 <[^>]*> nop
++0+1b98 <[^>]*> nop
++0+1b9c <[^>]*> nop
++0+1ba0 <[^>]*> nop
++0+1ba4 <[^>]*> nop
++0+1ba8 <[^>]*> nop
++0+1bac <[^>]*> nop
++0+1bb0 <[^>]*> nop
++0+1bb4 <[^>]*> nop
++0+1bb8 <[^>]*> nop
++0+1bbc <[^>]*> nop
++0+1bc0 <[^>]*> nop
++0+1bc4 <[^>]*> nop
++0+1bc8 <[^>]*> nop
++0+1bcc <[^>]*> nop
++0+1bd0 <[^>]*> nop
++0+1bd4 <[^>]*> nop
++0+1bd8 <[^>]*> nop
++0+1bdc <[^>]*> nop
++0+1be0 <[^>]*> nop
++0+1be4 <[^>]*> nop
++0+1be8 <[^>]*> nop
++0+1bec <[^>]*> nop
++0+1bf0 <[^>]*> nop
++0+1bf4 <[^>]*> nop
++0+1bf8 <[^>]*> nop
++0+1bfc <[^>]*> nop
++0+1c00 <[^>]*> nop
++0+1c04 <[^>]*> nop
++0+1c08 <[^>]*> nop
++0+1c0c <[^>]*> nop
++0+1c10 <[^>]*> nop
++0+1c14 <[^>]*> nop
++0+1c18 <[^>]*> nop
++0+1c1c <[^>]*> nop
++0+1c20 <[^>]*> nop
++0+1c24 <[^>]*> nop
++0+1c28 <[^>]*> nop
++0+1c2c <[^>]*> nop
++0+1c30 <[^>]*> nop
++0+1c34 <[^>]*> nop
++0+1c38 <[^>]*> nop
++0+1c3c <[^>]*> nop
++0+1c40 <[^>]*> nop
++0+1c44 <[^>]*> nop
++0+1c48 <[^>]*> nop
++0+1c4c <[^>]*> nop
++0+1c50 <[^>]*> nop
++0+1c54 <[^>]*> nop
++0+1c58 <[^>]*> nop
++0+1c5c <[^>]*> nop
++0+1c60 <[^>]*> nop
++0+1c64 <[^>]*> nop
++0+1c68 <[^>]*> nop
++0+1c6c <[^>]*> nop
++0+1c70 <[^>]*> nop
++0+1c74 <[^>]*> nop
++0+1c78 <[^>]*> nop
++0+1c7c <[^>]*> nop
++0+1c80 <[^>]*> nop
++0+1c84 <[^>]*> nop
++0+1c88 <[^>]*> nop
++0+1c8c <[^>]*> nop
++0+1c90 <[^>]*> nop
++0+1c94 <[^>]*> nop
++0+1c98 <[^>]*> nop
++0+1c9c <[^>]*> nop
++0+1ca0 <[^>]*> nop
++0+1ca4 <[^>]*> nop
++0+1ca8 <[^>]*> nop
++0+1cac <[^>]*> nop
++0+1cb0 <[^>]*> nop
++0+1cb4 <[^>]*> nop
++0+1cb8 <[^>]*> nop
++0+1cbc <[^>]*> nop
++0+1cc0 <[^>]*> nop
++0+1cc4 <[^>]*> nop
++0+1cc8 <[^>]*> nop
++0+1ccc <[^>]*> nop
++0+1cd0 <[^>]*> nop
++0+1cd4 <[^>]*> nop
++0+1cd8 <[^>]*> nop
++0+1cdc <[^>]*> nop
++0+1ce0 <[^>]*> nop
++0+1ce4 <[^>]*> nop
++0+1ce8 <[^>]*> nop
++0+1cec <[^>]*> nop
++0+1cf0 <[^>]*> nop
++0+1cf4 <[^>]*> nop
++0+1cf8 <[^>]*> nop
++0+1cfc <[^>]*> nop
++0+1d00 <[^>]*> nop
++0+1d04 <[^>]*> nop
++0+1d08 <[^>]*> nop
++0+1d0c <[^>]*> nop
++0+1d10 <[^>]*> nop
++0+1d14 <[^>]*> nop
++0+1d18 <[^>]*> nop
++0+1d1c <[^>]*> nop
++0+1d20 <[^>]*> nop
++0+1d24 <[^>]*> nop
++0+1d28 <[^>]*> nop
++0+1d2c <[^>]*> nop
++0+1d30 <[^>]*> nop
++0+1d34 <[^>]*> nop
++0+1d38 <[^>]*> nop
++0+1d3c <[^>]*> nop
++0+1d40 <[^>]*> nop
++0+1d44 <[^>]*> nop
++0+1d48 <[^>]*> nop
++0+1d4c <[^>]*> nop
++0+1d50 <[^>]*> nop
++0+1d54 <[^>]*> nop
++0+1d58 <[^>]*> nop
++0+1d5c <[^>]*> nop
++0+1d60 <[^>]*> nop
++0+1d64 <[^>]*> nop
++0+1d68 <[^>]*> nop
++0+1d6c <[^>]*> nop
++0+1d70 <[^>]*> nop
++0+1d74 <[^>]*> nop
++0+1d78 <[^>]*> nop
++0+1d7c <[^>]*> nop
++0+1d80 <[^>]*> nop
++0+1d84 <[^>]*> nop
++0+1d88 <[^>]*> nop
++0+1d8c <[^>]*> nop
++0+1d90 <[^>]*> nop
++0+1d94 <[^>]*> nop
++0+1d98 <[^>]*> nop
++0+1d9c <[^>]*> nop
++0+1da0 <[^>]*> nop
++0+1da4 <[^>]*> nop
++0+1da8 <[^>]*> nop
++0+1dac <[^>]*> nop
++0+1db0 <[^>]*> nop
++0+1db4 <[^>]*> nop
++0+1db8 <[^>]*> nop
++0+1dbc <[^>]*> nop
++0+1dc0 <[^>]*> nop
++0+1dc4 <[^>]*> nop
++0+1dc8 <[^>]*> nop
++0+1dcc <[^>]*> nop
++0+1dd0 <[^>]*> nop
++0+1dd4 <[^>]*> nop
++0+1dd8 <[^>]*> nop
++0+1ddc <[^>]*> nop
++0+1de0 <[^>]*> nop
++0+1de4 <[^>]*> nop
++0+1de8 <[^>]*> nop
++0+1dec <[^>]*> nop
++0+1df0 <[^>]*> nop
++0+1df4 <[^>]*> nop
++0+1df8 <[^>]*> nop
++0+1dfc <[^>]*> nop
++0+1e00 <[^>]*> nop
++0+1e04 <[^>]*> nop
++0+1e08 <[^>]*> nop
++0+1e0c <[^>]*> nop
++0+1e10 <[^>]*> nop
++0+1e14 <[^>]*> nop
++0+1e18 <[^>]*> nop
++0+1e1c <[^>]*> nop
++0+1e20 <[^>]*> nop
++0+1e24 <[^>]*> nop
++0+1e28 <[^>]*> nop
++0+1e2c <[^>]*> nop
++0+1e30 <[^>]*> nop
++0+1e34 <[^>]*> nop
++0+1e38 <[^>]*> nop
++0+1e3c <[^>]*> nop
++0+1e40 <[^>]*> nop
++0+1e44 <[^>]*> nop
++0+1e48 <[^>]*> nop
++0+1e4c <[^>]*> nop
++0+1e50 <[^>]*> nop
++0+1e54 <[^>]*> nop
++0+1e58 <[^>]*> nop
++0+1e5c <[^>]*> nop
++0+1e60 <[^>]*> nop
++0+1e64 <[^>]*> nop
++0+1e68 <[^>]*> nop
++0+1e6c <[^>]*> nop
++0+1e70 <[^>]*> nop
++0+1e74 <[^>]*> nop
++0+1e78 <[^>]*> nop
++0+1e7c <[^>]*> nop
++0+1e80 <[^>]*> nop
++0+1e84 <[^>]*> nop
++0+1e88 <[^>]*> nop
++0+1e8c <[^>]*> nop
++0+1e90 <[^>]*> nop
++0+1e94 <[^>]*> nop
++0+1e98 <[^>]*> nop
++0+1e9c <[^>]*> nop
++0+1ea0 <[^>]*> nop
++0+1ea4 <[^>]*> nop
++0+1ea8 <[^>]*> nop
++0+1eac <[^>]*> nop
++0+1eb0 <[^>]*> nop
++0+1eb4 <[^>]*> nop
++0+1eb8 <[^>]*> nop
++0+1ebc <[^>]*> nop
++0+1ec0 <[^>]*> nop
++0+1ec4 <[^>]*> nop
++0+1ec8 <[^>]*> nop
++0+1ecc <[^>]*> nop
++0+1ed0 <[^>]*> nop
++0+1ed4 <[^>]*> nop
++0+1ed8 <[^>]*> nop
++0+1edc <[^>]*> nop
++0+1ee0 <[^>]*> nop
++0+1ee4 <[^>]*> nop
++0+1ee8 <[^>]*> nop
++0+1eec <[^>]*> nop
++0+1ef0 <[^>]*> nop
++0+1ef4 <[^>]*> nop
++0+1ef8 <[^>]*> nop
++0+1efc <[^>]*> nop
++0+1f00 <[^>]*> nop
++0+1f04 <[^>]*> nop
++0+1f08 <[^>]*> nop
++0+1f0c <[^>]*> nop
++0+1f10 <[^>]*> nop
++0+1f14 <[^>]*> nop
++0+1f18 <[^>]*> nop
++0+1f1c <[^>]*> nop
++0+1f20 <[^>]*> nop
++0+1f24 <[^>]*> nop
++0+1f28 <[^>]*> nop
++0+1f2c <[^>]*> nop
++0+1f30 <[^>]*> nop
++0+1f34 <[^>]*> nop
++0+1f38 <[^>]*> nop
++0+1f3c <[^>]*> nop
++0+1f40 <[^>]*> nop
++0+1f44 <[^>]*> nop
++0+1f48 <[^>]*> nop
++0+1f4c <[^>]*> nop
++0+1f50 <[^>]*> nop
++0+1f54 <[^>]*> nop
++0+1f58 <[^>]*> nop
++0+1f5c <[^>]*> nop
++0+1f60 <[^>]*> nop
++0+1f64 <[^>]*> nop
++0+1f68 <[^>]*> nop
++0+1f6c <[^>]*> nop
++0+1f70 <[^>]*> nop
++0+1f74 <[^>]*> nop
++0+1f78 <[^>]*> nop
++0+1f7c <[^>]*> nop
++0+1f80 <[^>]*> nop
++0+1f84 <[^>]*> nop
++0+1f88 <[^>]*> nop
++0+1f8c <[^>]*> nop
++0+1f90 <[^>]*> nop
++0+1f94 <[^>]*> nop
++0+1f98 <[^>]*> nop
++0+1f9c <[^>]*> nop
++0+1fa0 <[^>]*> nop
++0+1fa4 <[^>]*> nop
++0+1fa8 <[^>]*> nop
++0+1fac <[^>]*> nop
++0+1fb0 <[^>]*> nop
++0+1fb4 <[^>]*> nop
++0+1fb8 <[^>]*> nop
++0+1fbc <[^>]*> nop
++0+1fc0 <[^>]*> nop
++0+1fc4 <[^>]*> nop
++0+1fc8 <[^>]*> nop
++0+1fcc <[^>]*> nop
++0+1fd0 <[^>]*> nop
++0+1fd4 <[^>]*> nop
++0+1fd8 <[^>]*> nop
++0+1fdc <[^>]*> nop
++0+1fe0 <[^>]*> nop
++0+1fe4 <[^>]*> nop
++0+1fe8 <[^>]*> nop
++0+1fec <[^>]*> nop
++0+1ff0 <[^>]*> nop
++0+1ff4 <[^>]*> nop
++0+1ff8 <[^>]*> nop
++0+1ffc <[^>]*> nop
++0+2000 <[^>]*> nop
++0+2004 <[^>]*> nop
++0+2008 <[^>]*> nop
++0+200c <[^>]*> nop
++0+2010 <[^>]*> nop
++0+2014 <[^>]*> nop
++0+2018 <[^>]*> nop
++0+201c <[^>]*> nop
++0+2020 <[^>]*> nop
++0+2024 <[^>]*> nop
++0+2028 <[^>]*> nop
++0+202c <[^>]*> nop
++0+2030 <[^>]*> nop
++0+2034 <[^>]*> nop
++0+2038 <[^>]*> nop
++0+203c <[^>]*> nop
++0+2040 <[^>]*> nop
++0+2044 <[^>]*> nop
++0+2048 <[^>]*> nop
++0+204c <[^>]*> nop
++0+2050 <[^>]*> nop
++0+2054 <[^>]*> nop
++0+2058 <[^>]*> nop
++0+205c <[^>]*> nop
++0+2060 <[^>]*> nop
++0+2064 <[^>]*> nop
++0+2068 <[^>]*> nop
++0+206c <[^>]*> nop
++0+2070 <[^>]*> nop
++0+2074 <[^>]*> nop
++0+2078 <[^>]*> nop
++0+207c <[^>]*> nop
++0+2080 <[^>]*> nop
++0+2084 <[^>]*> nop
++0+2088 <[^>]*> nop
++0+208c <[^>]*> nop
++0+2090 <[^>]*> nop
++0+2094 <[^>]*> nop
++0+2098 <[^>]*> nop
++0+209c <[^>]*> nop
++0+20a0 <[^>]*> nop
++0+20a4 <[^>]*> nop
++0+20a8 <[^>]*> nop
++0+20ac <[^>]*> nop
++0+20b0 <[^>]*> nop
++0+20b4 <[^>]*> nop
++0+20b8 <[^>]*> nop
++0+20bc <[^>]*> nop
++0+20c0 <[^>]*> nop
++0+20c4 <[^>]*> nop
++0+20c8 <[^>]*> nop
++0+20cc <[^>]*> nop
++0+20d0 <[^>]*> nop
++0+20d4 <[^>]*> nop
++0+20d8 <[^>]*> nop
++0+20dc <[^>]*> nop
++0+20e0 <[^>]*> nop
++0+20e4 <[^>]*> nop
++0+20e8 <[^>]*> nop
++0+20ec <[^>]*> nop
++0+20f0 <[^>]*> nop
++0+20f4 <[^>]*> nop
++0+20f8 <[^>]*> nop
++0+20fc <[^>]*> nop
++0+2100 <[^>]*> nop
++0+2104 <[^>]*> nop
++0+2108 <[^>]*> nop
++0+210c <[^>]*> nop
++0+2110 <[^>]*> nop
++0+2114 <[^>]*> nop
++0+2118 <[^>]*> nop
++0+211c <[^>]*> nop
++0+2120 <[^>]*> nop
++0+2124 <[^>]*> nop
++0+2128 <[^>]*> nop
++0+212c <[^>]*> nop
++0+2130 <[^>]*> nop
++0+2134 <[^>]*> nop
++0+2138 <[^>]*> nop
++0+213c <[^>]*> nop
++0+2140 <[^>]*> nop
++0+2144 <[^>]*> nop
++0+2148 <[^>]*> nop
++0+214c <[^>]*> nop
++0+2150 <[^>]*> nop
++0+2154 <[^>]*> nop
++0+2158 <[^>]*> nop
++0+215c <[^>]*> nop
++0+2160 <[^>]*> nop
++0+2164 <[^>]*> nop
++0+2168 <[^>]*> nop
++0+216c <[^>]*> nop
++0+2170 <[^>]*> nop
++0+2174 <[^>]*> nop
++0+2178 <[^>]*> nop
++0+217c <[^>]*> nop
++0+2180 <[^>]*> nop
++0+2184 <[^>]*> nop
++0+2188 <[^>]*> nop
++0+218c <[^>]*> nop
++0+2190 <[^>]*> nop
++0+2194 <[^>]*> nop
++0+2198 <[^>]*> nop
++0+219c <[^>]*> nop
++0+21a0 <[^>]*> nop
++0+21a4 <[^>]*> nop
++0+21a8 <[^>]*> nop
++0+21ac <[^>]*> nop
++0+21b0 <[^>]*> nop
++0+21b4 <[^>]*> nop
++0+21b8 <[^>]*> nop
++0+21bc <[^>]*> nop
++0+21c0 <[^>]*> nop
++0+21c4 <[^>]*> nop
++0+21c8 <[^>]*> nop
++0+21cc <[^>]*> nop
++0+21d0 <[^>]*> nop
++0+21d4 <[^>]*> nop
++0+21d8 <[^>]*> nop
++0+21dc <[^>]*> nop
++0+21e0 <[^>]*> nop
++0+21e4 <[^>]*> nop
++0+21e8 <[^>]*> nop
++0+21ec <[^>]*> nop
++0+21f0 <[^>]*> nop
++0+21f4 <[^>]*> nop
++0+21f8 <[^>]*> nop
++0+21fc <[^>]*> nop
++0+2200 <[^>]*> nop
++0+2204 <[^>]*> nop
++0+2208 <[^>]*> nop
++0+220c <[^>]*> nop
++0+2210 <[^>]*> nop
++0+2214 <[^>]*> nop
++0+2218 <[^>]*> nop
++0+221c <[^>]*> nop
++0+2220 <[^>]*> nop
++0+2224 <[^>]*> nop
++0+2228 <[^>]*> nop
++0+222c <[^>]*> nop
++0+2230 <[^>]*> nop
++0+2234 <[^>]*> nop
++0+2238 <[^>]*> nop
++0+223c <[^>]*> nop
++0+2240 <[^>]*> nop
++0+2244 <[^>]*> nop
++0+2248 <[^>]*> nop
++0+224c <[^>]*> nop
++0+2250 <[^>]*> nop
++0+2254 <[^>]*> nop
++0+2258 <[^>]*> nop
++0+225c <[^>]*> nop
++0+2260 <[^>]*> nop
++0+2264 <[^>]*> nop
++0+2268 <[^>]*> nop
++0+226c <[^>]*> nop
++0+2270 <[^>]*> nop
++0+2274 <[^>]*> nop
++0+2278 <[^>]*> nop
++0+227c <[^>]*> nop
++0+2280 <[^>]*> nop
++0+2284 <[^>]*> nop
++0+2288 <[^>]*> nop
++0+228c <[^>]*> nop
++0+2290 <[^>]*> nop
++0+2294 <[^>]*> nop
++0+2298 <[^>]*> nop
++0+229c <[^>]*> nop
++0+22a0 <[^>]*> nop
++0+22a4 <[^>]*> nop
++0+22a8 <[^>]*> nop
++0+22ac <[^>]*> nop
++0+22b0 <[^>]*> nop
++0+22b4 <[^>]*> nop
++0+22b8 <[^>]*> nop
++0+22bc <[^>]*> nop
++0+22c0 <[^>]*> nop
++0+22c4 <[^>]*> nop
++0+22c8 <[^>]*> nop
++0+22cc <[^>]*> nop
++0+22d0 <[^>]*> nop
++0+22d4 <[^>]*> nop
++0+22d8 <[^>]*> nop
++0+22dc <[^>]*> nop
++0+22e0 <[^>]*> nop
++0+22e4 <[^>]*> nop
++0+22e8 <[^>]*> nop
++0+22ec <[^>]*> nop
++0+22f0 <[^>]*> nop
++0+22f4 <[^>]*> nop
++0+22f8 <[^>]*> nop
++0+22fc <[^>]*> nop
++0+2300 <[^>]*> nop
++0+2304 <[^>]*> nop
++0+2308 <[^>]*> nop
++0+230c <[^>]*> nop
++0+2310 <[^>]*> nop
++0+2314 <[^>]*> nop
++0+2318 <[^>]*> nop
++0+231c <[^>]*> nop
++0+2320 <[^>]*> nop
++0+2324 <[^>]*> nop
++0+2328 <[^>]*> nop
++0+232c <[^>]*> nop
++0+2330 <[^>]*> nop
++0+2334 <[^>]*> nop
++0+2338 <[^>]*> nop
++0+233c <[^>]*> nop
++0+2340 <[^>]*> nop
++0+2344 <[^>]*> nop
++0+2348 <[^>]*> nop
++0+234c <[^>]*> nop
++0+2350 <[^>]*> nop
++0+2354 <[^>]*> nop
++0+2358 <[^>]*> nop
++0+235c <[^>]*> nop
++0+2360 <[^>]*> nop
++0+2364 <[^>]*> nop
++0+2368 <[^>]*> nop
++0+236c <[^>]*> nop
++0+2370 <[^>]*> nop
++0+2374 <[^>]*> nop
++0+2378 <[^>]*> nop
++0+237c <[^>]*> nop
++0+2380 <[^>]*> nop
++0+2384 <[^>]*> nop
++0+2388 <[^>]*> nop
++0+238c <[^>]*> nop
++0+2390 <[^>]*> nop
++0+2394 <[^>]*> nop
++0+2398 <[^>]*> nop
++0+239c <[^>]*> nop
++0+23a0 <[^>]*> nop
++0+23a4 <[^>]*> nop
++0+23a8 <[^>]*> nop
++0+23ac <[^>]*> nop
++0+23b0 <[^>]*> nop
++0+23b4 <[^>]*> nop
++0+23b8 <[^>]*> nop
++0+23bc <[^>]*> nop
++0+23c0 <[^>]*> nop
++0+23c4 <[^>]*> nop
++0+23c8 <[^>]*> nop
++0+23cc <[^>]*> nop
++0+23d0 <[^>]*> nop
++0+23d4 <[^>]*> nop
++0+23d8 <[^>]*> nop
++0+23dc <[^>]*> nop
++0+23e0 <[^>]*> nop
++0+23e4 <[^>]*> nop
++0+23e8 <[^>]*> nop
++0+23ec <[^>]*> nop
++0+23f0 <[^>]*> nop
++0+23f4 <[^>]*> nop
++0+23f8 <[^>]*> nop
++0+23fc <[^>]*> nop
++0+2400 <[^>]*> nop
++0+2404 <[^>]*> nop
++0+2408 <[^>]*> nop
++0+240c <[^>]*> nop
++0+2410 <[^>]*> nop
++0+2414 <[^>]*> nop
++0+2418 <[^>]*> nop
++0+241c <[^>]*> nop
++0+2420 <[^>]*> nop
++0+2424 <[^>]*> nop
++0+2428 <[^>]*> nop
++0+242c <[^>]*> nop
++0+2430 <[^>]*> nop
++0+2434 <[^>]*> nop
++0+2438 <[^>]*> nop
++0+243c <[^>]*> nop
++0+2440 <[^>]*> nop
++0+2444 <[^>]*> nop
++0+2448 <[^>]*> nop
++0+244c <[^>]*> nop
++0+2450 <[^>]*> nop
++0+2454 <[^>]*> nop
++0+2458 <[^>]*> nop
++0+245c <[^>]*> nop
++0+2460 <[^>]*> nop
++0+2464 <[^>]*> nop
++0+2468 <[^>]*> nop
++0+246c <[^>]*> nop
++0+2470 <[^>]*> nop
++0+2474 <[^>]*> nop
++0+2478 <[^>]*> nop
++0+247c <[^>]*> nop
++0+2480 <[^>]*> nop
++0+2484 <[^>]*> nop
++0+2488 <[^>]*> nop
++0+248c <[^>]*> nop
++0+2490 <[^>]*> nop
++0+2494 <[^>]*> nop
++0+2498 <[^>]*> nop
++0+249c <[^>]*> nop
++0+24a0 <[^>]*> nop
++0+24a4 <[^>]*> nop
++0+24a8 <[^>]*> nop
++0+24ac <[^>]*> nop
++0+24b0 <[^>]*> nop
++0+24b4 <[^>]*> nop
++0+24b8 <[^>]*> nop
++0+24bc <[^>]*> nop
++0+24c0 <[^>]*> nop
++0+24c4 <[^>]*> nop
++0+24c8 <[^>]*> nop
++0+24cc <[^>]*> nop
++0+24d0 <[^>]*> nop
++0+24d4 <[^>]*> nop
++0+24d8 <[^>]*> nop
++0+24dc <[^>]*> nop
++0+24e0 <[^>]*> nop
++0+24e4 <[^>]*> nop
++0+24e8 <[^>]*> nop
++0+24ec <[^>]*> nop
++0+24f0 <[^>]*> nop
++0+24f4 <[^>]*> nop
++0+24f8 <[^>]*> nop
++0+24fc <[^>]*> nop
++0+2500 <[^>]*> nop
++0+2504 <[^>]*> nop
++0+2508 <[^>]*> nop
++0+250c <[^>]*> nop
++0+2510 <[^>]*> nop
++0+2514 <[^>]*> nop
++0+2518 <[^>]*> nop
++0+251c <[^>]*> nop
++0+2520 <[^>]*> nop
++0+2524 <[^>]*> nop
++0+2528 <[^>]*> nop
++0+252c <[^>]*> nop
++0+2530 <[^>]*> nop
++0+2534 <[^>]*> nop
++0+2538 <[^>]*> nop
++0+253c <[^>]*> nop
++0+2540 <[^>]*> nop
++0+2544 <[^>]*> nop
++0+2548 <[^>]*> nop
++0+254c <[^>]*> nop
++0+2550 <[^>]*> nop
++0+2554 <[^>]*> nop
++0+2558 <[^>]*> nop
++0+255c <[^>]*> nop
++0+2560 <[^>]*> nop
++0+2564 <[^>]*> nop
++0+2568 <[^>]*> nop
++0+256c <[^>]*> nop
++0+2570 <[^>]*> nop
++0+2574 <[^>]*> nop
++0+2578 <[^>]*> nop
++0+257c <[^>]*> nop
++0+2580 <[^>]*> nop
++0+2584 <[^>]*> nop
++0+2588 <[^>]*> nop
++0+258c <[^>]*> nop
++0+2590 <[^>]*> nop
++0+2594 <[^>]*> nop
++0+2598 <[^>]*> nop
++0+259c <[^>]*> nop
++0+25a0 <[^>]*> nop
++0+25a4 <[^>]*> nop
++0+25a8 <[^>]*> nop
++0+25ac <[^>]*> nop
++0+25b0 <[^>]*> nop
++0+25b4 <[^>]*> nop
++0+25b8 <[^>]*> nop
++0+25bc <[^>]*> nop
++0+25c0 <[^>]*> nop
++0+25c4 <[^>]*> nop
++0+25c8 <[^>]*> nop
++0+25cc <[^>]*> nop
++0+25d0 <[^>]*> nop
++0+25d4 <[^>]*> nop
++0+25d8 <[^>]*> nop
++0+25dc <[^>]*> nop
++0+25e0 <[^>]*> nop
++0+25e4 <[^>]*> nop
++0+25e8 <[^>]*> nop
++0+25ec <[^>]*> nop
++0+25f0 <[^>]*> nop
++0+25f4 <[^>]*> nop
++0+25f8 <[^>]*> nop
++0+25fc <[^>]*> nop
++0+2600 <[^>]*> nop
++0+2604 <[^>]*> nop
++0+2608 <[^>]*> nop
++0+260c <[^>]*> nop
++0+2610 <[^>]*> nop
++0+2614 <[^>]*> nop
++0+2618 <[^>]*> nop
++0+261c <[^>]*> nop
++0+2620 <[^>]*> nop
++0+2624 <[^>]*> nop
++0+2628 <[^>]*> nop
++0+262c <[^>]*> nop
++0+2630 <[^>]*> nop
++0+2634 <[^>]*> nop
++0+2638 <[^>]*> nop
++0+263c <[^>]*> nop
++0+2640 <[^>]*> nop
++0+2644 <[^>]*> nop
++0+2648 <[^>]*> nop
++0+264c <[^>]*> nop
++0+2650 <[^>]*> nop
++0+2654 <[^>]*> nop
++0+2658 <[^>]*> nop
++0+265c <[^>]*> nop
++0+2660 <[^>]*> nop
++0+2664 <[^>]*> nop
++0+2668 <[^>]*> nop
++0+266c <[^>]*> nop
++0+2670 <[^>]*> nop
++0+2674 <[^>]*> nop
++0+2678 <[^>]*> nop
++0+267c <[^>]*> nop
++0+2680 <[^>]*> nop
++0+2684 <[^>]*> nop
++0+2688 <[^>]*> nop
++0+268c <[^>]*> nop
++0+2690 <[^>]*> nop
++0+2694 <[^>]*> nop
++0+2698 <[^>]*> nop
++0+269c <[^>]*> nop
++0+26a0 <[^>]*> nop
++0+26a4 <[^>]*> nop
++0+26a8 <[^>]*> nop
++0+26ac <[^>]*> nop
++0+26b0 <[^>]*> nop
++0+26b4 <[^>]*> nop
++0+26b8 <[^>]*> nop
++0+26bc <[^>]*> nop
++0+26c0 <[^>]*> nop
++0+26c4 <[^>]*> nop
++0+26c8 <[^>]*> nop
++0+26cc <[^>]*> nop
++0+26d0 <[^>]*> nop
++0+26d4 <[^>]*> nop
++0+26d8 <[^>]*> nop
++0+26dc <[^>]*> nop
++0+26e0 <[^>]*> nop
++0+26e4 <[^>]*> nop
++0+26e8 <[^>]*> nop
++0+26ec <[^>]*> nop
++0+26f0 <[^>]*> nop
++0+26f4 <[^>]*> nop
++0+26f8 <[^>]*> nop
++0+26fc <[^>]*> nop
++0+2700 <[^>]*> nop
++0+2704 <[^>]*> nop
++0+2708 <[^>]*> nop
++0+270c <[^>]*> nop
++0+2710 <[^>]*> nop
++0+2714 <[^>]*> nop
++0+2718 <[^>]*> nop
++0+271c <[^>]*> nop
++0+2720 <[^>]*> nop
++0+2724 <[^>]*> nop
++0+2728 <[^>]*> nop
++0+272c <[^>]*> nop
++0+2730 <[^>]*> nop
++0+2734 <[^>]*> nop
++0+2738 <[^>]*> nop
++0+273c <[^>]*> nop
++0+2740 <[^>]*> nop
++0+2744 <[^>]*> nop
++0+2748 <[^>]*> nop
++0+274c <[^>]*> nop
++0+2750 <[^>]*> nop
++0+2754 <[^>]*> nop
++0+2758 <[^>]*> nop
++0+275c <[^>]*> nop
++0+2760 <[^>]*> nop
++0+2764 <[^>]*> nop
++0+2768 <[^>]*> nop
++0+276c <[^>]*> nop
++0+2770 <[^>]*> nop
++0+2774 <[^>]*> nop
++0+2778 <[^>]*> nop
++0+277c <[^>]*> nop
++0+2780 <[^>]*> nop
++0+2784 <[^>]*> nop
++0+2788 <[^>]*> nop
++0+278c <[^>]*> nop
++0+2790 <[^>]*> nop
++0+2794 <[^>]*> nop
++0+2798 <[^>]*> nop
++0+279c <[^>]*> nop
++0+27a0 <[^>]*> nop
++0+27a4 <[^>]*> nop
++0+27a8 <[^>]*> nop
++0+27ac <[^>]*> nop
++0+27b0 <[^>]*> nop
++0+27b4 <[^>]*> nop
++0+27b8 <[^>]*> nop
++0+27bc <[^>]*> nop
++0+27c0 <[^>]*> nop
++0+27c4 <[^>]*> nop
++0+27c8 <[^>]*> nop
++0+27cc <[^>]*> nop
++0+27d0 <[^>]*> nop
++0+27d4 <[^>]*> nop
++0+27d8 <[^>]*> nop
++0+27dc <[^>]*> nop
++0+27e0 <[^>]*> nop
++0+27e4 <[^>]*> nop
++0+27e8 <[^>]*> nop
++0+27ec <[^>]*> nop
++0+27f0 <[^>]*> nop
++0+27f4 <[^>]*> nop
++0+27f8 <[^>]*> nop
++0+27fc <[^>]*> nop
++0+2800 <[^>]*> nop
++0+2804 <[^>]*> nop
++0+2808 <[^>]*> nop
++0+280c <[^>]*> nop
++0+2810 <[^>]*> nop
++0+2814 <[^>]*> nop
++0+2818 <[^>]*> nop
++0+281c <[^>]*> nop
++0+2820 <[^>]*> nop
++0+2824 <[^>]*> nop
++0+2828 <[^>]*> nop
++0+282c <[^>]*> nop
++0+2830 <[^>]*> nop
++0+2834 <[^>]*> nop
++0+2838 <[^>]*> nop
++0+283c <[^>]*> nop
++0+2840 <[^>]*> nop
++0+2844 <[^>]*> nop
++0+2848 <[^>]*> nop
++0+284c <[^>]*> nop
++0+2850 <[^>]*> nop
++0+2854 <[^>]*> nop
++0+2858 <[^>]*> nop
++0+285c <[^>]*> nop
++0+2860 <[^>]*> nop
++0+2864 <[^>]*> nop
++0+2868 <[^>]*> nop
++0+286c <[^>]*> nop
++0+2870 <[^>]*> nop
++0+2874 <[^>]*> nop
++0+2878 <[^>]*> nop
++0+287c <[^>]*> nop
++0+2880 <[^>]*> nop
++0+2884 <[^>]*> nop
++0+2888 <[^>]*> nop
++0+288c <[^>]*> nop
++0+2890 <[^>]*> nop
++0+2894 <[^>]*> nop
++0+2898 <[^>]*> nop
++0+289c <[^>]*> nop
++0+28a0 <[^>]*> nop
++0+28a4 <[^>]*> nop
++0+28a8 <[^>]*> nop
++0+28ac <[^>]*> nop
++0+28b0 <[^>]*> nop
++0+28b4 <[^>]*> nop
++0+28b8 <[^>]*> nop
++0+28bc <[^>]*> nop
++0+28c0 <[^>]*> nop
++0+28c4 <[^>]*> nop
++0+28c8 <[^>]*> nop
++0+28cc <[^>]*> nop
++0+28d0 <[^>]*> nop
++0+28d4 <[^>]*> nop
++0+28d8 <[^>]*> nop
++0+28dc <[^>]*> nop
++0+28e0 <[^>]*> nop
++0+28e4 <[^>]*> nop
++0+28e8 <[^>]*> nop
++0+28ec <[^>]*> nop
++0+28f0 <[^>]*> nop
++0+28f4 <[^>]*> nop
++0+28f8 <[^>]*> nop
++0+28fc <[^>]*> nop
++0+2900 <[^>]*> nop
++0+2904 <[^>]*> nop
++0+2908 <[^>]*> nop
++0+290c <[^>]*> nop
++0+2910 <[^>]*> nop
++0+2914 <[^>]*> nop
++0+2918 <[^>]*> nop
++0+291c <[^>]*> nop
++0+2920 <[^>]*> nop
++0+2924 <[^>]*> nop
++0+2928 <[^>]*> nop
++0+292c <[^>]*> nop
++0+2930 <[^>]*> nop
++0+2934 <[^>]*> nop
++0+2938 <[^>]*> nop
++0+293c <[^>]*> nop
++0+2940 <[^>]*> nop
++0+2944 <[^>]*> nop
++0+2948 <[^>]*> nop
++0+294c <[^>]*> nop
++0+2950 <[^>]*> nop
++0+2954 <[^>]*> nop
++0+2958 <[^>]*> nop
++0+295c <[^>]*> nop
++0+2960 <[^>]*> nop
++0+2964 <[^>]*> nop
++0+2968 <[^>]*> nop
++0+296c <[^>]*> nop
++0+2970 <[^>]*> nop
++0+2974 <[^>]*> nop
++0+2978 <[^>]*> nop
++0+297c <[^>]*> nop
++0+2980 <[^>]*> nop
++0+2984 <[^>]*> nop
++0+2988 <[^>]*> nop
++0+298c <[^>]*> nop
++0+2990 <[^>]*> nop
++0+2994 <[^>]*> nop
++0+2998 <[^>]*> nop
++0+299c <[^>]*> nop
++0+29a0 <[^>]*> nop
++0+29a4 <[^>]*> nop
++0+29a8 <[^>]*> nop
++0+29ac <[^>]*> nop
++0+29b0 <[^>]*> nop
++0+29b4 <[^>]*> nop
++0+29b8 <[^>]*> nop
++0+29bc <[^>]*> nop
++0+29c0 <[^>]*> nop
++0+29c4 <[^>]*> nop
++0+29c8 <[^>]*> nop
++0+29cc <[^>]*> nop
++0+29d0 <[^>]*> nop
++0+29d4 <[^>]*> nop
++0+29d8 <[^>]*> nop
++0+29dc <[^>]*> nop
++0+29e0 <[^>]*> nop
++0+29e4 <[^>]*> nop
++0+29e8 <[^>]*> nop
++0+29ec <[^>]*> nop
++0+29f0 <[^>]*> nop
++0+29f4 <[^>]*> nop
++0+29f8 <[^>]*> nop
++0+29fc <[^>]*> nop
++0+2a00 <[^>]*> nop
++0+2a04 <[^>]*> nop
++0+2a08 <[^>]*> nop
++0+2a0c <[^>]*> nop
++0+2a10 <[^>]*> nop
++0+2a14 <[^>]*> nop
++0+2a18 <[^>]*> nop
++0+2a1c <[^>]*> nop
++0+2a20 <[^>]*> nop
++0+2a24 <[^>]*> nop
++0+2a28 <[^>]*> nop
++0+2a2c <[^>]*> nop
++0+2a30 <[^>]*> nop
++0+2a34 <[^>]*> nop
++0+2a38 <[^>]*> nop
++0+2a3c <[^>]*> nop
++0+2a40 <[^>]*> nop
++0+2a44 <[^>]*> nop
++0+2a48 <[^>]*> nop
++0+2a4c <[^>]*> nop
++0+2a50 <[^>]*> nop
++0+2a54 <[^>]*> nop
++0+2a58 <[^>]*> nop
++0+2a5c <[^>]*> nop
++0+2a60 <[^>]*> nop
++0+2a64 <[^>]*> nop
++0+2a68 <[^>]*> nop
++0+2a6c <[^>]*> nop
++0+2a70 <[^>]*> nop
++0+2a74 <[^>]*> nop
++0+2a78 <[^>]*> nop
++0+2a7c <[^>]*> nop
++0+2a80 <[^>]*> nop
++0+2a84 <[^>]*> nop
++0+2a88 <[^>]*> nop
++0+2a8c <[^>]*> nop
++0+2a90 <[^>]*> nop
++0+2a94 <[^>]*> nop
++0+2a98 <[^>]*> nop
++0+2a9c <[^>]*> nop
++0+2aa0 <[^>]*> nop
++0+2aa4 <[^>]*> nop
++0+2aa8 <[^>]*> nop
++0+2aac <[^>]*> nop
++0+2ab0 <[^>]*> nop
++0+2ab4 <[^>]*> nop
++0+2ab8 <[^>]*> nop
++0+2abc <[^>]*> nop
++0+2ac0 <[^>]*> nop
++0+2ac4 <[^>]*> nop
++0+2ac8 <[^>]*> nop
++0+2acc <[^>]*> nop
++0+2ad0 <[^>]*> nop
++0+2ad4 <[^>]*> nop
++0+2ad8 <[^>]*> nop
++0+2adc <[^>]*> nop
++0+2ae0 <[^>]*> nop
++0+2ae4 <[^>]*> nop
++0+2ae8 <[^>]*> nop
++0+2aec <[^>]*> nop
++0+2af0 <[^>]*> nop
++0+2af4 <[^>]*> nop
++0+2af8 <[^>]*> nop
++0+2afc <[^>]*> nop
++0+2b00 <[^>]*> nop
++0+2b04 <[^>]*> nop
++0+2b08 <[^>]*> nop
++0+2b0c <[^>]*> nop
++0+2b10 <[^>]*> nop
++0+2b14 <[^>]*> nop
++0+2b18 <[^>]*> nop
++0+2b1c <[^>]*> nop
++0+2b20 <[^>]*> nop
++0+2b24 <[^>]*> nop
++0+2b28 <[^>]*> nop
++0+2b2c <[^>]*> nop
++0+2b30 <[^>]*> nop
++0+2b34 <[^>]*> nop
++0+2b38 <[^>]*> nop
++0+2b3c <[^>]*> nop
++0+2b40 <[^>]*> nop
++0+2b44 <[^>]*> nop
++0+2b48 <[^>]*> nop
++0+2b4c <[^>]*> nop
++0+2b50 <[^>]*> nop
++0+2b54 <[^>]*> nop
++0+2b58 <[^>]*> nop
++0+2b5c <[^>]*> nop
++0+2b60 <[^>]*> nop
++0+2b64 <[^>]*> nop
++0+2b68 <[^>]*> nop
++0+2b6c <[^>]*> nop
++0+2b70 <[^>]*> nop
++0+2b74 <[^>]*> nop
++0+2b78 <[^>]*> nop
++0+2b7c <[^>]*> nop
++0+2b80 <[^>]*> nop
++0+2b84 <[^>]*> nop
++0+2b88 <[^>]*> nop
++0+2b8c <[^>]*> nop
++0+2b90 <[^>]*> nop
++0+2b94 <[^>]*> nop
++0+2b98 <[^>]*> nop
++0+2b9c <[^>]*> nop
++0+2ba0 <[^>]*> nop
++0+2ba4 <[^>]*> nop
++0+2ba8 <[^>]*> nop
++0+2bac <[^>]*> nop
++0+2bb0 <[^>]*> nop
++0+2bb4 <[^>]*> nop
++0+2bb8 <[^>]*> nop
++0+2bbc <[^>]*> nop
++0+2bc0 <[^>]*> nop
++0+2bc4 <[^>]*> nop
++0+2bc8 <[^>]*> nop
++0+2bcc <[^>]*> nop
++0+2bd0 <[^>]*> nop
++0+2bd4 <[^>]*> nop
++0+2bd8 <[^>]*> nop
++0+2bdc <[^>]*> nop
++0+2be0 <[^>]*> nop
++0+2be4 <[^>]*> nop
++0+2be8 <[^>]*> nop
++0+2bec <[^>]*> nop
++0+2bf0 <[^>]*> nop
++0+2bf4 <[^>]*> nop
++0+2bf8 <[^>]*> nop
++0+2bfc <[^>]*> nop
++0+2c00 <[^>]*> nop
++0+2c04 <[^>]*> nop
++0+2c08 <[^>]*> nop
++0+2c0c <[^>]*> nop
++0+2c10 <[^>]*> nop
++0+2c14 <[^>]*> nop
++0+2c18 <[^>]*> nop
++0+2c1c <[^>]*> nop
++0+2c20 <[^>]*> nop
++0+2c24 <[^>]*> nop
++0+2c28 <[^>]*> nop
++0+2c2c <[^>]*> nop
++0+2c30 <[^>]*> nop
++0+2c34 <[^>]*> nop
++0+2c38 <[^>]*> nop
++0+2c3c <[^>]*> nop
++0+2c40 <[^>]*> nop
++0+2c44 <[^>]*> nop
++0+2c48 <[^>]*> nop
++0+2c4c <[^>]*> nop
++0+2c50 <[^>]*> nop
++0+2c54 <[^>]*> nop
++0+2c58 <[^>]*> nop
++0+2c5c <[^>]*> nop
++0+2c60 <[^>]*> nop
++0+2c64 <[^>]*> nop
++0+2c68 <[^>]*> nop
++0+2c6c <[^>]*> nop
++0+2c70 <[^>]*> nop
++0+2c74 <[^>]*> nop
++0+2c78 <[^>]*> nop
++0+2c7c <[^>]*> nop
++0+2c80 <[^>]*> nop
++0+2c84 <[^>]*> nop
++0+2c88 <[^>]*> nop
++0+2c8c <[^>]*> nop
++0+2c90 <[^>]*> nop
++0+2c94 <[^>]*> nop
++0+2c98 <[^>]*> nop
++0+2c9c <[^>]*> nop
++0+2ca0 <[^>]*> nop
++0+2ca4 <[^>]*> nop
++0+2ca8 <[^>]*> nop
++0+2cac <[^>]*> nop
++0+2cb0 <[^>]*> nop
++0+2cb4 <[^>]*> nop
++0+2cb8 <[^>]*> nop
++0+2cbc <[^>]*> nop
++0+2cc0 <[^>]*> nop
++0+2cc4 <[^>]*> nop
++0+2cc8 <[^>]*> nop
++0+2ccc <[^>]*> nop
++0+2cd0 <[^>]*> nop
++0+2cd4 <[^>]*> nop
++0+2cd8 <[^>]*> nop
++0+2cdc <[^>]*> nop
++0+2ce0 <[^>]*> nop
++0+2ce4 <[^>]*> nop
++0+2ce8 <[^>]*> nop
++0+2cec <[^>]*> nop
++0+2cf0 <[^>]*> nop
++0+2cf4 <[^>]*> nop
++0+2cf8 <[^>]*> nop
++0+2cfc <[^>]*> nop
++0+2d00 <[^>]*> nop
++0+2d04 <[^>]*> nop
++0+2d08 <[^>]*> nop
++0+2d0c <[^>]*> nop
++0+2d10 <[^>]*> nop
++0+2d14 <[^>]*> nop
++0+2d18 <[^>]*> nop
++0+2d1c <[^>]*> nop
++0+2d20 <[^>]*> nop
++0+2d24 <[^>]*> nop
++0+2d28 <[^>]*> nop
++0+2d2c <[^>]*> nop
++0+2d30 <[^>]*> nop
++0+2d34 <[^>]*> nop
++0+2d38 <[^>]*> nop
++0+2d3c <[^>]*> nop
++0+2d40 <[^>]*> nop
++0+2d44 <[^>]*> nop
++0+2d48 <[^>]*> nop
++0+2d4c <[^>]*> nop
++0+2d50 <[^>]*> nop
++0+2d54 <[^>]*> nop
++0+2d58 <[^>]*> nop
++0+2d5c <[^>]*> nop
++0+2d60 <[^>]*> nop
++0+2d64 <[^>]*> nop
++0+2d68 <[^>]*> nop
++0+2d6c <[^>]*> nop
++0+2d70 <[^>]*> nop
++0+2d74 <[^>]*> nop
++0+2d78 <[^>]*> nop
++0+2d7c <[^>]*> nop
++0+2d80 <[^>]*> nop
++0+2d84 <[^>]*> nop
++0+2d88 <[^>]*> nop
++0+2d8c <[^>]*> nop
++0+2d90 <[^>]*> nop
++0+2d94 <[^>]*> nop
++0+2d98 <[^>]*> nop
++0+2d9c <[^>]*> nop
++0+2da0 <[^>]*> nop
++0+2da4 <[^>]*> nop
++0+2da8 <[^>]*> nop
++0+2dac <[^>]*> nop
++0+2db0 <[^>]*> nop
++0+2db4 <[^>]*> nop
++0+2db8 <[^>]*> nop
++0+2dbc <[^>]*> nop
++0+2dc0 <[^>]*> nop
++0+2dc4 <[^>]*> nop
++0+2dc8 <[^>]*> nop
++0+2dcc <[^>]*> nop
++0+2dd0 <[^>]*> nop
++0+2dd4 <[^>]*> nop
++0+2dd8 <[^>]*> nop
++0+2ddc <[^>]*> nop
++0+2de0 <[^>]*> nop
++0+2de4 <[^>]*> nop
++0+2de8 <[^>]*> nop
++0+2dec <[^>]*> nop
++0+2df0 <[^>]*> nop
++0+2df4 <[^>]*> nop
++0+2df8 <[^>]*> nop
++0+2dfc <[^>]*> nop
++0+2e00 <[^>]*> nop
++0+2e04 <[^>]*> nop
++0+2e08 <[^>]*> nop
++0+2e0c <[^>]*> nop
++0+2e10 <[^>]*> nop
++0+2e14 <[^>]*> nop
++0+2e18 <[^>]*> nop
++0+2e1c <[^>]*> nop
++0+2e20 <[^>]*> nop
++0+2e24 <[^>]*> nop
++0+2e28 <[^>]*> nop
++0+2e2c <[^>]*> nop
++0+2e30 <[^>]*> nop
++0+2e34 <[^>]*> nop
++0+2e38 <[^>]*> nop
++0+2e3c <[^>]*> nop
++0+2e40 <[^>]*> nop
++0+2e44 <[^>]*> nop
++0+2e48 <[^>]*> nop
++0+2e4c <[^>]*> nop
++0+2e50 <[^>]*> nop
++0+2e54 <[^>]*> nop
++0+2e58 <[^>]*> nop
++0+2e5c <[^>]*> nop
++0+2e60 <[^>]*> nop
++0+2e64 <[^>]*> nop
++0+2e68 <[^>]*> nop
++0+2e6c <[^>]*> nop
++0+2e70 <[^>]*> nop
++0+2e74 <[^>]*> nop
++0+2e78 <[^>]*> nop
++0+2e7c <[^>]*> nop
++0+2e80 <[^>]*> nop
++0+2e84 <[^>]*> nop
++0+2e88 <[^>]*> nop
++0+2e8c <[^>]*> nop
++0+2e90 <[^>]*> nop
++0+2e94 <[^>]*> nop
++0+2e98 <[^>]*> nop
++0+2e9c <[^>]*> nop
++0+2ea0 <[^>]*> nop
++0+2ea4 <[^>]*> nop
++0+2ea8 <[^>]*> nop
++0+2eac <[^>]*> nop
++0+2eb0 <[^>]*> nop
++0+2eb4 <[^>]*> nop
++0+2eb8 <[^>]*> nop
++0+2ebc <[^>]*> nop
++0+2ec0 <[^>]*> nop
++0+2ec4 <[^>]*> nop
++0+2ec8 <[^>]*> nop
++0+2ecc <[^>]*> nop
++0+2ed0 <[^>]*> nop
++0+2ed4 <[^>]*> nop
++0+2ed8 <[^>]*> nop
++0+2edc <[^>]*> nop
++0+2ee0 <[^>]*> nop
++0+2ee4 <[^>]*> nop
++0+2ee8 <[^>]*> nop
++0+2eec <[^>]*> nop
++0+2ef0 <[^>]*> nop
++0+2ef4 <[^>]*> nop
++0+2ef8 <[^>]*> nop
++0+2efc <[^>]*> nop
++0+2f00 <[^>]*> nop
++0+2f04 <[^>]*> nop
++0+2f08 <[^>]*> nop
++0+2f0c <[^>]*> nop
++0+2f10 <[^>]*> nop
++0+2f14 <[^>]*> nop
++0+2f18 <[^>]*> nop
++0+2f1c <[^>]*> nop
++0+2f20 <[^>]*> nop
++0+2f24 <[^>]*> nop
++0+2f28 <[^>]*> nop
++0+2f2c <[^>]*> nop
++0+2f30 <[^>]*> nop
++0+2f34 <[^>]*> nop
++0+2f38 <[^>]*> nop
++0+2f3c <[^>]*> nop
++0+2f40 <[^>]*> nop
++0+2f44 <[^>]*> nop
++0+2f48 <[^>]*> nop
++0+2f4c <[^>]*> nop
++0+2f50 <[^>]*> nop
++0+2f54 <[^>]*> nop
++0+2f58 <[^>]*> nop
++0+2f5c <[^>]*> nop
++0+2f60 <[^>]*> nop
++0+2f64 <[^>]*> nop
++0+2f68 <[^>]*> nop
++0+2f6c <[^>]*> nop
++0+2f70 <[^>]*> nop
++0+2f74 <[^>]*> nop
++0+2f78 <[^>]*> nop
++0+2f7c <[^>]*> nop
++0+2f80 <[^>]*> nop
++0+2f84 <[^>]*> nop
++0+2f88 <[^>]*> nop
++0+2f8c <[^>]*> nop
++0+2f90 <[^>]*> nop
++0+2f94 <[^>]*> nop
++0+2f98 <[^>]*> nop
++0+2f9c <[^>]*> nop
++0+2fa0 <[^>]*> nop
++0+2fa4 <[^>]*> nop
++0+2fa8 <[^>]*> nop
++0+2fac <[^>]*> nop
++0+2fb0 <[^>]*> nop
++0+2fb4 <[^>]*> nop
++0+2fb8 <[^>]*> nop
++0+2fbc <[^>]*> nop
++0+2fc0 <[^>]*> nop
++0+2fc4 <[^>]*> nop
++0+2fc8 <[^>]*> nop
++0+2fcc <[^>]*> nop
++0+2fd0 <[^>]*> nop
++0+2fd4 <[^>]*> nop
++0+2fd8 <[^>]*> nop
++0+2fdc <[^>]*> nop
++0+2fe0 <[^>]*> nop
++0+2fe4 <[^>]*> nop
++0+2fe8 <[^>]*> nop
++0+2fec <[^>]*> nop
++0+2ff0 <[^>]*> nop
++0+2ff4 <[^>]*> nop
++0+2ff8 <[^>]*> nop
++0+2ffc <[^>]*> nop
++0+3000 <[^>]*> nop
++0+3004 <[^>]*> nop
++0+3008 <[^>]*> nop
++0+300c <[^>]*> nop
++0+3010 <[^>]*> nop
++0+3014 <[^>]*> nop
++0+3018 <[^>]*> nop
++0+301c <[^>]*> nop
++0+3020 <[^>]*> nop
++0+3024 <[^>]*> nop
++0+3028 <[^>]*> nop
++0+302c <[^>]*> nop
++0+3030 <[^>]*> nop
++0+3034 <[^>]*> nop
++0+3038 <[^>]*> nop
++0+303c <[^>]*> nop
++0+3040 <[^>]*> nop
++0+3044 <[^>]*> nop
++0+3048 <[^>]*> nop
++0+304c <[^>]*> nop
++0+3050 <[^>]*> nop
++0+3054 <[^>]*> nop
++0+3058 <[^>]*> nop
++0+305c <[^>]*> nop
++0+3060 <[^>]*> nop
++0+3064 <[^>]*> nop
++0+3068 <[^>]*> nop
++0+306c <[^>]*> nop
++0+3070 <[^>]*> nop
++0+3074 <[^>]*> nop
++0+3078 <[^>]*> nop
++0+307c <[^>]*> nop
++0+3080 <[^>]*> nop
++0+3084 <[^>]*> nop
++0+3088 <[^>]*> nop
++0+308c <[^>]*> nop
++0+3090 <[^>]*> nop
++0+3094 <[^>]*> nop
++0+3098 <[^>]*> nop
++0+309c <[^>]*> nop
++0+30a0 <[^>]*> nop
++0+30a4 <[^>]*> nop
++0+30a8 <[^>]*> nop
++0+30ac <[^>]*> nop
++0+30b0 <[^>]*> nop
++0+30b4 <[^>]*> nop
++0+30b8 <[^>]*> nop
++0+30bc <[^>]*> nop
++0+30c0 <[^>]*> nop
++0+30c4 <[^>]*> nop
++0+30c8 <[^>]*> nop
++0+30cc <[^>]*> nop
++0+30d0 <[^>]*> nop
++0+30d4 <[^>]*> nop
++0+30d8 <[^>]*> nop
++0+30dc <[^>]*> nop
++0+30e0 <[^>]*> nop
++0+30e4 <[^>]*> nop
++0+30e8 <[^>]*> nop
++0+30ec <[^>]*> nop
++0+30f0 <[^>]*> nop
++0+30f4 <[^>]*> nop
++0+30f8 <[^>]*> nop
++0+30fc <[^>]*> nop
++0+3100 <[^>]*> nop
++0+3104 <[^>]*> nop
++0+3108 <[^>]*> nop
++0+310c <[^>]*> nop
++0+3110 <[^>]*> nop
++0+3114 <[^>]*> nop
++0+3118 <[^>]*> nop
++0+311c <[^>]*> nop
++0+3120 <[^>]*> nop
++0+3124 <[^>]*> nop
++0+3128 <[^>]*> nop
++0+312c <[^>]*> nop
++0+3130 <[^>]*> nop
++0+3134 <[^>]*> nop
++0+3138 <[^>]*> nop
++0+313c <[^>]*> nop
++0+3140 <[^>]*> nop
++0+3144 <[^>]*> nop
++0+3148 <[^>]*> nop
++0+314c <[^>]*> nop
++0+3150 <[^>]*> nop
++0+3154 <[^>]*> nop
++0+3158 <[^>]*> nop
++0+315c <[^>]*> nop
++0+3160 <[^>]*> nop
++0+3164 <[^>]*> nop
++0+3168 <[^>]*> nop
++0+316c <[^>]*> nop
++0+3170 <[^>]*> nop
++0+3174 <[^>]*> nop
++0+3178 <[^>]*> nop
++0+317c <[^>]*> nop
++0+3180 <[^>]*> nop
++0+3184 <[^>]*> nop
++0+3188 <[^>]*> nop
++0+318c <[^>]*> nop
++0+3190 <[^>]*> nop
++0+3194 <[^>]*> nop
++0+3198 <[^>]*> nop
++0+319c <[^>]*> nop
++0+31a0 <[^>]*> nop
++0+31a4 <[^>]*> nop
++0+31a8 <[^>]*> nop
++0+31ac <[^>]*> nop
++0+31b0 <[^>]*> nop
++0+31b4 <[^>]*> nop
++0+31b8 <[^>]*> nop
++0+31bc <[^>]*> nop
++0+31c0 <[^>]*> nop
++0+31c4 <[^>]*> nop
++0+31c8 <[^>]*> nop
++0+31cc <[^>]*> nop
++0+31d0 <[^>]*> nop
++0+31d4 <[^>]*> nop
++0+31d8 <[^>]*> nop
++0+31dc <[^>]*> nop
++0+31e0 <[^>]*> nop
++0+31e4 <[^>]*> nop
++0+31e8 <[^>]*> nop
++0+31ec <[^>]*> nop
++0+31f0 <[^>]*> nop
++0+31f4 <[^>]*> nop
++0+31f8 <[^>]*> nop
++0+31fc <[^>]*> nop
++0+3200 <[^>]*> nop
++0+3204 <[^>]*> nop
++0+3208 <[^>]*> nop
++0+320c <[^>]*> nop
++0+3210 <[^>]*> nop
++0+3214 <[^>]*> nop
++0+3218 <[^>]*> nop
++0+321c <[^>]*> nop
++0+3220 <[^>]*> nop
++0+3224 <[^>]*> nop
++0+3228 <[^>]*> nop
++0+322c <[^>]*> nop
++0+3230 <[^>]*> nop
++0+3234 <[^>]*> nop
++0+3238 <[^>]*> nop
++0+323c <[^>]*> nop
++0+3240 <[^>]*> nop
++0+3244 <[^>]*> nop
++0+3248 <[^>]*> nop
++0+324c <[^>]*> nop
++0+3250 <[^>]*> nop
++0+3254 <[^>]*> nop
++0+3258 <[^>]*> nop
++0+325c <[^>]*> nop
++0+3260 <[^>]*> nop
++0+3264 <[^>]*> nop
++0+3268 <[^>]*> nop
++0+326c <[^>]*> nop
++0+3270 <[^>]*> nop
++0+3274 <[^>]*> nop
++0+3278 <[^>]*> nop
++0+327c <[^>]*> nop
++0+3280 <[^>]*> nop
++0+3284 <[^>]*> nop
++0+3288 <[^>]*> nop
++0+328c <[^>]*> nop
++0+3290 <[^>]*> nop
++0+3294 <[^>]*> nop
++0+3298 <[^>]*> nop
++0+329c <[^>]*> nop
++0+32a0 <[^>]*> nop
++0+32a4 <[^>]*> nop
++0+32a8 <[^>]*> nop
++0+32ac <[^>]*> nop
++0+32b0 <[^>]*> nop
++0+32b4 <[^>]*> nop
++0+32b8 <[^>]*> nop
++0+32bc <[^>]*> nop
++0+32c0 <[^>]*> nop
++0+32c4 <[^>]*> nop
++0+32c8 <[^>]*> nop
++0+32cc <[^>]*> nop
++0+32d0 <[^>]*> nop
++0+32d4 <[^>]*> nop
++0+32d8 <[^>]*> nop
++0+32dc <[^>]*> nop
++0+32e0 <[^>]*> nop
++0+32e4 <[^>]*> nop
++0+32e8 <[^>]*> nop
++0+32ec <[^>]*> nop
++0+32f0 <[^>]*> nop
++0+32f4 <[^>]*> nop
++0+32f8 <[^>]*> nop
++0+32fc <[^>]*> nop
++0+3300 <[^>]*> nop
++0+3304 <[^>]*> nop
++0+3308 <[^>]*> nop
++0+330c <[^>]*> nop
++0+3310 <[^>]*> nop
++0+3314 <[^>]*> nop
++0+3318 <[^>]*> nop
++0+331c <[^>]*> nop
++0+3320 <[^>]*> nop
++0+3324 <[^>]*> nop
++0+3328 <[^>]*> nop
++0+332c <[^>]*> nop
++0+3330 <[^>]*> nop
++0+3334 <[^>]*> nop
++0+3338 <[^>]*> nop
++0+333c <[^>]*> nop
++0+3340 <[^>]*> nop
++0+3344 <[^>]*> nop
++0+3348 <[^>]*> nop
++0+334c <[^>]*> nop
++0+3350 <[^>]*> nop
++0+3354 <[^>]*> nop
++0+3358 <[^>]*> nop
++0+335c <[^>]*> nop
++0+3360 <[^>]*> nop
++0+3364 <[^>]*> nop
++0+3368 <[^>]*> nop
++0+336c <[^>]*> nop
++0+3370 <[^>]*> nop
++0+3374 <[^>]*> nop
++0+3378 <[^>]*> nop
++0+337c <[^>]*> nop
++0+3380 <[^>]*> nop
++0+3384 <[^>]*> nop
++0+3388 <[^>]*> nop
++0+338c <[^>]*> nop
++0+3390 <[^>]*> nop
++0+3394 <[^>]*> nop
++0+3398 <[^>]*> nop
++0+339c <[^>]*> nop
++0+33a0 <[^>]*> nop
++0+33a4 <[^>]*> nop
++0+33a8 <[^>]*> nop
++0+33ac <[^>]*> nop
++0+33b0 <[^>]*> nop
++0+33b4 <[^>]*> nop
++0+33b8 <[^>]*> nop
++0+33bc <[^>]*> nop
++0+33c0 <[^>]*> nop
++0+33c4 <[^>]*> nop
++0+33c8 <[^>]*> nop
++0+33cc <[^>]*> nop
++0+33d0 <[^>]*> nop
++0+33d4 <[^>]*> nop
++0+33d8 <[^>]*> nop
++0+33dc <[^>]*> nop
++0+33e0 <[^>]*> nop
++0+33e4 <[^>]*> nop
++0+33e8 <[^>]*> nop
++0+33ec <[^>]*> nop
++0+33f0 <[^>]*> nop
++0+33f4 <[^>]*> nop
++0+33f8 <[^>]*> nop
++0+33fc <[^>]*> nop
++0+3400 <[^>]*> nop
++0+3404 <[^>]*> nop
++0+3408 <[^>]*> nop
++0+340c <[^>]*> nop
++0+3410 <[^>]*> nop
++0+3414 <[^>]*> nop
++0+3418 <[^>]*> nop
++0+341c <[^>]*> nop
++0+3420 <[^>]*> nop
++0+3424 <[^>]*> nop
++0+3428 <[^>]*> nop
++0+342c <[^>]*> nop
++0+3430 <[^>]*> nop
++0+3434 <[^>]*> nop
++0+3438 <[^>]*> nop
++0+343c <[^>]*> nop
++0+3440 <[^>]*> nop
++0+3444 <[^>]*> nop
++0+3448 <[^>]*> nop
++0+344c <[^>]*> nop
++0+3450 <[^>]*> nop
++0+3454 <[^>]*> nop
++0+3458 <[^>]*> nop
++0+345c <[^>]*> nop
++0+3460 <[^>]*> nop
++0+3464 <[^>]*> nop
++0+3468 <[^>]*> nop
++0+346c <[^>]*> nop
++0+3470 <[^>]*> nop
++0+3474 <[^>]*> nop
++0+3478 <[^>]*> nop
++0+347c <[^>]*> nop
++0+3480 <[^>]*> nop
++0+3484 <[^>]*> nop
++0+3488 <[^>]*> nop
++0+348c <[^>]*> nop
++0+3490 <[^>]*> nop
++0+3494 <[^>]*> nop
++0+3498 <[^>]*> nop
++0+349c <[^>]*> nop
++0+34a0 <[^>]*> nop
++0+34a4 <[^>]*> nop
++0+34a8 <[^>]*> nop
++0+34ac <[^>]*> nop
++0+34b0 <[^>]*> nop
++0+34b4 <[^>]*> nop
++0+34b8 <[^>]*> nop
++0+34bc <[^>]*> nop
++0+34c0 <[^>]*> nop
++0+34c4 <[^>]*> nop
++0+34c8 <[^>]*> nop
++0+34cc <[^>]*> nop
++0+34d0 <[^>]*> nop
++0+34d4 <[^>]*> nop
++0+34d8 <[^>]*> nop
++0+34dc <[^>]*> nop
++0+34e0 <[^>]*> nop
++0+34e4 <[^>]*> nop
++0+34e8 <[^>]*> nop
++0+34ec <[^>]*> nop
++0+34f0 <[^>]*> nop
++0+34f4 <[^>]*> nop
++0+34f8 <[^>]*> nop
++0+34fc <[^>]*> nop
++0+3500 <[^>]*> nop
++0+3504 <[^>]*> nop
++0+3508 <[^>]*> nop
++0+350c <[^>]*> nop
++0+3510 <[^>]*> nop
++0+3514 <[^>]*> nop
++0+3518 <[^>]*> nop
++0+351c <[^>]*> nop
++0+3520 <[^>]*> nop
++0+3524 <[^>]*> nop
++0+3528 <[^>]*> nop
++0+352c <[^>]*> nop
++0+3530 <[^>]*> nop
++0+3534 <[^>]*> nop
++0+3538 <[^>]*> nop
++0+353c <[^>]*> nop
++0+3540 <[^>]*> nop
++0+3544 <[^>]*> nop
++0+3548 <[^>]*> nop
++0+354c <[^>]*> nop
++0+3550 <[^>]*> nop
++0+3554 <[^>]*> nop
++0+3558 <[^>]*> nop
++0+355c <[^>]*> nop
++0+3560 <[^>]*> nop
++0+3564 <[^>]*> nop
++0+3568 <[^>]*> nop
++0+356c <[^>]*> nop
++0+3570 <[^>]*> nop
++0+3574 <[^>]*> nop
++0+3578 <[^>]*> nop
++0+357c <[^>]*> nop
++0+3580 <[^>]*> nop
++0+3584 <[^>]*> nop
++0+3588 <[^>]*> nop
++0+358c <[^>]*> nop
++0+3590 <[^>]*> nop
++0+3594 <[^>]*> nop
++0+3598 <[^>]*> nop
++0+359c <[^>]*> nop
++0+35a0 <[^>]*> nop
++0+35a4 <[^>]*> nop
++0+35a8 <[^>]*> nop
++0+35ac <[^>]*> nop
++0+35b0 <[^>]*> nop
++0+35b4 <[^>]*> nop
++0+35b8 <[^>]*> nop
++0+35bc <[^>]*> nop
++0+35c0 <[^>]*> nop
++0+35c4 <[^>]*> nop
++0+35c8 <[^>]*> nop
++0+35cc <[^>]*> nop
++0+35d0 <[^>]*> nop
++0+35d4 <[^>]*> nop
++0+35d8 <[^>]*> nop
++0+35dc <[^>]*> nop
++0+35e0 <[^>]*> nop
++0+35e4 <[^>]*> nop
++0+35e8 <[^>]*> nop
++0+35ec <[^>]*> nop
++0+35f0 <[^>]*> nop
++0+35f4 <[^>]*> nop
++0+35f8 <[^>]*> nop
++0+35fc <[^>]*> nop
++0+3600 <[^>]*> nop
++0+3604 <[^>]*> nop
++0+3608 <[^>]*> nop
++0+360c <[^>]*> nop
++0+3610 <[^>]*> nop
++0+3614 <[^>]*> nop
++0+3618 <[^>]*> nop
++0+361c <[^>]*> nop
++0+3620 <[^>]*> nop
++0+3624 <[^>]*> nop
++0+3628 <[^>]*> nop
++0+362c <[^>]*> nop
++0+3630 <[^>]*> nop
++0+3634 <[^>]*> nop
++0+3638 <[^>]*> nop
++0+363c <[^>]*> nop
++0+3640 <[^>]*> nop
++0+3644 <[^>]*> nop
++0+3648 <[^>]*> nop
++0+364c <[^>]*> nop
++0+3650 <[^>]*> nop
++0+3654 <[^>]*> nop
++0+3658 <[^>]*> nop
++0+365c <[^>]*> nop
++0+3660 <[^>]*> nop
++0+3664 <[^>]*> nop
++0+3668 <[^>]*> nop
++0+366c <[^>]*> nop
++0+3670 <[^>]*> nop
++0+3674 <[^>]*> nop
++0+3678 <[^>]*> nop
++0+367c <[^>]*> nop
++0+3680 <[^>]*> nop
++0+3684 <[^>]*> nop
++0+3688 <[^>]*> nop
++0+368c <[^>]*> nop
++0+3690 <[^>]*> nop
++0+3694 <[^>]*> nop
++0+3698 <[^>]*> nop
++0+369c <[^>]*> nop
++0+36a0 <[^>]*> nop
++0+36a4 <[^>]*> nop
++0+36a8 <[^>]*> nop
++0+36ac <[^>]*> nop
++0+36b0 <[^>]*> nop
++0+36b4 <[^>]*> nop
++0+36b8 <[^>]*> nop
++0+36bc <[^>]*> nop
++0+36c0 <[^>]*> nop
++0+36c4 <[^>]*> nop
++0+36c8 <[^>]*> nop
++0+36cc <[^>]*> nop
++0+36d0 <[^>]*> nop
++0+36d4 <[^>]*> nop
++0+36d8 <[^>]*> nop
++0+36dc <[^>]*> nop
++0+36e0 <[^>]*> nop
++0+36e4 <[^>]*> nop
++0+36e8 <[^>]*> nop
++0+36ec <[^>]*> nop
++0+36f0 <[^>]*> nop
++0+36f4 <[^>]*> nop
++0+36f8 <[^>]*> nop
++0+36fc <[^>]*> nop
++0+3700 <[^>]*> nop
++0+3704 <[^>]*> nop
++0+3708 <[^>]*> nop
++0+370c <[^>]*> nop
++0+3710 <[^>]*> nop
++0+3714 <[^>]*> nop
++0+3718 <[^>]*> nop
++0+371c <[^>]*> nop
++0+3720 <[^>]*> nop
++0+3724 <[^>]*> nop
++0+3728 <[^>]*> nop
++0+372c <[^>]*> nop
++0+3730 <[^>]*> nop
++0+3734 <[^>]*> nop
++0+3738 <[^>]*> nop
++0+373c <[^>]*> nop
++0+3740 <[^>]*> nop
++0+3744 <[^>]*> nop
++0+3748 <[^>]*> nop
++0+374c <[^>]*> nop
++0+3750 <[^>]*> nop
++0+3754 <[^>]*> nop
++0+3758 <[^>]*> nop
++0+375c <[^>]*> nop
++0+3760 <[^>]*> nop
++0+3764 <[^>]*> nop
++0+3768 <[^>]*> nop
++0+376c <[^>]*> nop
++0+3770 <[^>]*> nop
++0+3774 <[^>]*> nop
++0+3778 <[^>]*> nop
++0+377c <[^>]*> nop
++0+3780 <[^>]*> nop
++0+3784 <[^>]*> nop
++0+3788 <[^>]*> nop
++0+378c <[^>]*> nop
++0+3790 <[^>]*> nop
++0+3794 <[^>]*> nop
++0+3798 <[^>]*> nop
++0+379c <[^>]*> nop
++0+37a0 <[^>]*> nop
++0+37a4 <[^>]*> nop
++0+37a8 <[^>]*> nop
++0+37ac <[^>]*> nop
++0+37b0 <[^>]*> nop
++0+37b4 <[^>]*> nop
++0+37b8 <[^>]*> nop
++0+37bc <[^>]*> nop
++0+37c0 <[^>]*> nop
++0+37c4 <[^>]*> nop
++0+37c8 <[^>]*> nop
++0+37cc <[^>]*> nop
++0+37d0 <[^>]*> nop
++0+37d4 <[^>]*> nop
++0+37d8 <[^>]*> nop
++0+37dc <[^>]*> nop
++0+37e0 <[^>]*> nop
++0+37e4 <[^>]*> nop
++0+37e8 <[^>]*> nop
++0+37ec <[^>]*> nop
++0+37f0 <[^>]*> nop
++0+37f4 <[^>]*> nop
++0+37f8 <[^>]*> nop
++0+37fc <[^>]*> nop
++0+3800 <[^>]*> nop
++0+3804 <[^>]*> nop
++0+3808 <[^>]*> nop
++0+380c <[^>]*> nop
++0+3810 <[^>]*> nop
++0+3814 <[^>]*> nop
++0+3818 <[^>]*> nop
++0+381c <[^>]*> nop
++0+3820 <[^>]*> nop
++0+3824 <[^>]*> nop
++0+3828 <[^>]*> nop
++0+382c <[^>]*> nop
++0+3830 <[^>]*> nop
++0+3834 <[^>]*> nop
++0+3838 <[^>]*> nop
++0+383c <[^>]*> nop
++0+3840 <[^>]*> nop
++0+3844 <[^>]*> nop
++0+3848 <[^>]*> nop
++0+384c <[^>]*> nop
++0+3850 <[^>]*> nop
++0+3854 <[^>]*> nop
++0+3858 <[^>]*> nop
++0+385c <[^>]*> nop
++0+3860 <[^>]*> nop
++0+3864 <[^>]*> nop
++0+3868 <[^>]*> nop
++0+386c <[^>]*> nop
++0+3870 <[^>]*> nop
++0+3874 <[^>]*> nop
++0+3878 <[^>]*> nop
++0+387c <[^>]*> nop
++0+3880 <[^>]*> nop
++0+3884 <[^>]*> nop
++0+3888 <[^>]*> nop
++0+388c <[^>]*> nop
++0+3890 <[^>]*> nop
++0+3894 <[^>]*> nop
++0+3898 <[^>]*> nop
++0+389c <[^>]*> nop
++0+38a0 <[^>]*> nop
++0+38a4 <[^>]*> nop
++0+38a8 <[^>]*> nop
++0+38ac <[^>]*> nop
++0+38b0 <[^>]*> nop
++0+38b4 <[^>]*> nop
++0+38b8 <[^>]*> nop
++0+38bc <[^>]*> nop
++0+38c0 <[^>]*> nop
++0+38c4 <[^>]*> nop
++0+38c8 <[^>]*> nop
++0+38cc <[^>]*> nop
++0+38d0 <[^>]*> nop
++0+38d4 <[^>]*> nop
++0+38d8 <[^>]*> nop
++0+38dc <[^>]*> nop
++0+38e0 <[^>]*> nop
++0+38e4 <[^>]*> nop
++0+38e8 <[^>]*> nop
++0+38ec <[^>]*> nop
++0+38f0 <[^>]*> nop
++0+38f4 <[^>]*> nop
++0+38f8 <[^>]*> nop
++0+38fc <[^>]*> nop
++0+3900 <[^>]*> nop
++0+3904 <[^>]*> nop
++0+3908 <[^>]*> nop
++0+390c <[^>]*> nop
++0+3910 <[^>]*> nop
++0+3914 <[^>]*> nop
++0+3918 <[^>]*> nop
++0+391c <[^>]*> nop
++0+3920 <[^>]*> nop
++0+3924 <[^>]*> nop
++0+3928 <[^>]*> nop
++0+392c <[^>]*> nop
++0+3930 <[^>]*> nop
++0+3934 <[^>]*> nop
++0+3938 <[^>]*> nop
++0+393c <[^>]*> nop
++0+3940 <[^>]*> nop
++0+3944 <[^>]*> nop
++0+3948 <[^>]*> nop
++0+394c <[^>]*> nop
++0+3950 <[^>]*> nop
++0+3954 <[^>]*> nop
++0+3958 <[^>]*> nop
++0+395c <[^>]*> nop
++0+3960 <[^>]*> nop
++0+3964 <[^>]*> nop
++0+3968 <[^>]*> nop
++0+396c <[^>]*> nop
++0+3970 <[^>]*> nop
++0+3974 <[^>]*> nop
++0+3978 <[^>]*> nop
++0+397c <[^>]*> nop
++0+3980 <[^>]*> nop
++0+3984 <[^>]*> nop
++0+3988 <[^>]*> nop
++0+398c <[^>]*> nop
++0+3990 <[^>]*> nop
++0+3994 <[^>]*> nop
++0+3998 <[^>]*> nop
++0+399c <[^>]*> nop
++0+39a0 <[^>]*> nop
++0+39a4 <[^>]*> nop
++0+39a8 <[^>]*> nop
++0+39ac <[^>]*> nop
++0+39b0 <[^>]*> nop
++0+39b4 <[^>]*> nop
++0+39b8 <[^>]*> nop
++0+39bc <[^>]*> nop
++0+39c0 <[^>]*> nop
++0+39c4 <[^>]*> nop
++0+39c8 <[^>]*> nop
++0+39cc <[^>]*> nop
++0+39d0 <[^>]*> nop
++0+39d4 <[^>]*> nop
++0+39d8 <[^>]*> nop
++0+39dc <[^>]*> nop
++0+39e0 <[^>]*> nop
++0+39e4 <[^>]*> nop
++0+39e8 <[^>]*> nop
++0+39ec <[^>]*> nop
++0+39f0 <[^>]*> nop
++0+39f4 <[^>]*> nop
++0+39f8 <[^>]*> nop
++0+39fc <[^>]*> nop
++0+3a00 <[^>]*> nop
++0+3a04 <[^>]*> nop
++0+3a08 <[^>]*> nop
++0+3a0c <[^>]*> nop
++0+3a10 <[^>]*> nop
++0+3a14 <[^>]*> nop
++0+3a18 <[^>]*> nop
++0+3a1c <[^>]*> nop
++0+3a20 <[^>]*> nop
++0+3a24 <[^>]*> nop
++0+3a28 <[^>]*> nop
++0+3a2c <[^>]*> nop
++0+3a30 <[^>]*> nop
++0+3a34 <[^>]*> nop
++0+3a38 <[^>]*> nop
++0+3a3c <[^>]*> nop
++0+3a40 <[^>]*> nop
++0+3a44 <[^>]*> nop
++0+3a48 <[^>]*> nop
++0+3a4c <[^>]*> nop
++0+3a50 <[^>]*> nop
++0+3a54 <[^>]*> nop
++0+3a58 <[^>]*> nop
++0+3a5c <[^>]*> nop
++0+3a60 <[^>]*> nop
++0+3a64 <[^>]*> nop
++0+3a68 <[^>]*> nop
++0+3a6c <[^>]*> nop
++0+3a70 <[^>]*> nop
++0+3a74 <[^>]*> nop
++0+3a78 <[^>]*> nop
++0+3a7c <[^>]*> nop
++0+3a80 <[^>]*> nop
++0+3a84 <[^>]*> nop
++0+3a88 <[^>]*> nop
++0+3a8c <[^>]*> nop
++0+3a90 <[^>]*> nop
++0+3a94 <[^>]*> nop
++0+3a98 <[^>]*> nop
++0+3a9c <[^>]*> nop
++0+3aa0 <[^>]*> nop
++0+3aa4 <[^>]*> nop
++0+3aa8 <[^>]*> nop
++0+3aac <[^>]*> nop
++0+3ab0 <[^>]*> nop
++0+3ab4 <[^>]*> nop
++0+3ab8 <[^>]*> nop
++0+3abc <[^>]*> nop
++0+3ac0 <[^>]*> nop
++0+3ac4 <[^>]*> nop
++0+3ac8 <[^>]*> nop
++0+3acc <[^>]*> nop
++0+3ad0 <[^>]*> nop
++0+3ad4 <[^>]*> nop
++0+3ad8 <[^>]*> nop
++0+3adc <[^>]*> nop
++0+3ae0 <[^>]*> nop
++0+3ae4 <[^>]*> nop
++0+3ae8 <[^>]*> nop
++0+3aec <[^>]*> nop
++0+3af0 <[^>]*> nop
++0+3af4 <[^>]*> nop
++0+3af8 <[^>]*> nop
++0+3afc <[^>]*> nop
++0+3b00 <[^>]*> nop
++0+3b04 <[^>]*> nop
++0+3b08 <[^>]*> nop
++0+3b0c <[^>]*> nop
++0+3b10 <[^>]*> nop
++0+3b14 <[^>]*> nop
++0+3b18 <[^>]*> nop
++0+3b1c <[^>]*> nop
++0+3b20 <[^>]*> nop
++0+3b24 <[^>]*> nop
++0+3b28 <[^>]*> nop
++0+3b2c <[^>]*> nop
++0+3b30 <[^>]*> nop
++0+3b34 <[^>]*> nop
++0+3b38 <[^>]*> nop
++0+3b3c <[^>]*> nop
++0+3b40 <[^>]*> nop
++0+3b44 <[^>]*> nop
++0+3b48 <[^>]*> nop
++0+3b4c <[^>]*> nop
++0+3b50 <[^>]*> nop
++0+3b54 <[^>]*> nop
++0+3b58 <[^>]*> nop
++0+3b5c <[^>]*> nop
++0+3b60 <[^>]*> nop
++0+3b64 <[^>]*> nop
++0+3b68 <[^>]*> nop
++0+3b6c <[^>]*> nop
++0+3b70 <[^>]*> nop
++0+3b74 <[^>]*> nop
++0+3b78 <[^>]*> nop
++0+3b7c <[^>]*> nop
++0+3b80 <[^>]*> nop
++0+3b84 <[^>]*> nop
++0+3b88 <[^>]*> nop
++0+3b8c <[^>]*> nop
++0+3b90 <[^>]*> nop
++0+3b94 <[^>]*> nop
++0+3b98 <[^>]*> nop
++0+3b9c <[^>]*> nop
++0+3ba0 <[^>]*> nop
++0+3ba4 <[^>]*> nop
++0+3ba8 <[^>]*> nop
++0+3bac <[^>]*> nop
++0+3bb0 <[^>]*> nop
++0+3bb4 <[^>]*> nop
++0+3bb8 <[^>]*> nop
++0+3bbc <[^>]*> nop
++0+3bc0 <[^>]*> nop
++0+3bc4 <[^>]*> nop
++0+3bc8 <[^>]*> nop
++0+3bcc <[^>]*> nop
++0+3bd0 <[^>]*> nop
++0+3bd4 <[^>]*> nop
++0+3bd8 <[^>]*> nop
++0+3bdc <[^>]*> nop
++0+3be0 <[^>]*> nop
++0+3be4 <[^>]*> nop
++0+3be8 <[^>]*> nop
++0+3bec <[^>]*> nop
++0+3bf0 <[^>]*> nop
++0+3bf4 <[^>]*> nop
++0+3bf8 <[^>]*> nop
++0+3bfc <[^>]*> nop
++0+3c00 <[^>]*> nop
++0+3c04 <[^>]*> nop
++0+3c08 <[^>]*> nop
++0+3c0c <[^>]*> nop
++0+3c10 <[^>]*> nop
++0+3c14 <[^>]*> nop
++0+3c18 <[^>]*> nop
++0+3c1c <[^>]*> nop
++0+3c20 <[^>]*> nop
++0+3c24 <[^>]*> nop
++0+3c28 <[^>]*> nop
++0+3c2c <[^>]*> nop
++0+3c30 <[^>]*> nop
++0+3c34 <[^>]*> nop
++0+3c38 <[^>]*> nop
++0+3c3c <[^>]*> nop
++0+3c40 <[^>]*> nop
++0+3c44 <[^>]*> nop
++0+3c48 <[^>]*> nop
++0+3c4c <[^>]*> nop
++0+3c50 <[^>]*> nop
++0+3c54 <[^>]*> nop
++0+3c58 <[^>]*> nop
++0+3c5c <[^>]*> nop
++0+3c60 <[^>]*> nop
++0+3c64 <[^>]*> nop
++0+3c68 <[^>]*> nop
++0+3c6c <[^>]*> nop
++0+3c70 <[^>]*> nop
++0+3c74 <[^>]*> nop
++0+3c78 <[^>]*> nop
++0+3c7c <[^>]*> nop
++0+3c80 <[^>]*> nop
++0+3c84 <[^>]*> nop
++0+3c88 <[^>]*> nop
++0+3c8c <[^>]*> nop
++0+3c90 <[^>]*> nop
++0+3c94 <[^>]*> nop
++0+3c98 <[^>]*> nop
++0+3c9c <[^>]*> nop
++0+3ca0 <[^>]*> nop
++0+3ca4 <[^>]*> nop
++0+3ca8 <[^>]*> nop
++0+3cac <[^>]*> nop
++0+3cb0 <[^>]*> nop
++0+3cb4 <[^>]*> nop
++0+3cb8 <[^>]*> nop
++0+3cbc <[^>]*> nop
++0+3cc0 <[^>]*> nop
++0+3cc4 <[^>]*> nop
++0+3cc8 <[^>]*> nop
++0+3ccc <[^>]*> nop
++0+3cd0 <[^>]*> nop
++0+3cd4 <[^>]*> nop
++0+3cd8 <[^>]*> nop
++0+3cdc <[^>]*> nop
++0+3ce0 <[^>]*> nop
++0+3ce4 <[^>]*> nop
++0+3ce8 <[^>]*> nop
++0+3cec <[^>]*> nop
++0+3cf0 <[^>]*> nop
++0+3cf4 <[^>]*> nop
++0+3cf8 <[^>]*> nop
++0+3cfc <[^>]*> nop
++0+3d00 <[^>]*> nop
++0+3d04 <[^>]*> nop
++0+3d08 <[^>]*> nop
++0+3d0c <[^>]*> nop
++0+3d10 <[^>]*> nop
++0+3d14 <[^>]*> nop
++0+3d18 <[^>]*> nop
++0+3d1c <[^>]*> nop
++0+3d20 <[^>]*> nop
++0+3d24 <[^>]*> nop
++0+3d28 <[^>]*> nop
++0+3d2c <[^>]*> nop
++0+3d30 <[^>]*> nop
++0+3d34 <[^>]*> nop
++0+3d38 <[^>]*> nop
++0+3d3c <[^>]*> nop
++0+3d40 <[^>]*> nop
++0+3d44 <[^>]*> nop
++0+3d48 <[^>]*> nop
++0+3d4c <[^>]*> nop
++0+3d50 <[^>]*> nop
++0+3d54 <[^>]*> nop
++0+3d58 <[^>]*> nop
++0+3d5c <[^>]*> nop
++0+3d60 <[^>]*> nop
++0+3d64 <[^>]*> nop
++0+3d68 <[^>]*> nop
++0+3d6c <[^>]*> nop
++0+3d70 <[^>]*> nop
++0+3d74 <[^>]*> nop
++0+3d78 <[^>]*> nop
++0+3d7c <[^>]*> nop
++0+3d80 <[^>]*> nop
++0+3d84 <[^>]*> nop
++0+3d88 <[^>]*> nop
++0+3d8c <[^>]*> nop
++0+3d90 <[^>]*> nop
++0+3d94 <[^>]*> nop
++0+3d98 <[^>]*> nop
++0+3d9c <[^>]*> nop
++0+3da0 <[^>]*> nop
++0+3da4 <[^>]*> nop
++0+3da8 <[^>]*> nop
++0+3dac <[^>]*> nop
++0+3db0 <[^>]*> nop
++0+3db4 <[^>]*> nop
++0+3db8 <[^>]*> nop
++0+3dbc <[^>]*> nop
++0+3dc0 <[^>]*> nop
++0+3dc4 <[^>]*> nop
++0+3dc8 <[^>]*> nop
++0+3dcc <[^>]*> nop
++0+3dd0 <[^>]*> nop
++0+3dd4 <[^>]*> nop
++0+3dd8 <[^>]*> nop
++0+3ddc <[^>]*> nop
++0+3de0 <[^>]*> nop
++0+3de4 <[^>]*> nop
++0+3de8 <[^>]*> nop
++0+3dec <[^>]*> nop
++0+3df0 <[^>]*> nop
++0+3df4 <[^>]*> nop
++0+3df8 <[^>]*> nop
++0+3dfc <[^>]*> nop
++0+3e00 <[^>]*> nop
++0+3e04 <[^>]*> nop
++0+3e08 <[^>]*> nop
++0+3e0c <[^>]*> nop
++0+3e10 <[^>]*> nop
++0+3e14 <[^>]*> nop
++0+3e18 <[^>]*> nop
++0+3e1c <[^>]*> nop
++0+3e20 <[^>]*> nop
++0+3e24 <[^>]*> nop
++0+3e28 <[^>]*> nop
++0+3e2c <[^>]*> nop
++0+3e30 <[^>]*> nop
++0+3e34 <[^>]*> nop
++0+3e38 <[^>]*> nop
++0+3e3c <[^>]*> nop
++0+3e40 <[^>]*> nop
++0+3e44 <[^>]*> nop
++0+3e48 <[^>]*> nop
++0+3e4c <[^>]*> nop
++0+3e50 <[^>]*> nop
++0+3e54 <[^>]*> nop
++0+3e58 <[^>]*> nop
++0+3e5c <[^>]*> nop
++0+3e60 <[^>]*> nop
++0+3e64 <[^>]*> nop
++0+3e68 <[^>]*> nop
++0+3e6c <[^>]*> nop
++0+3e70 <[^>]*> nop
++0+3e74 <[^>]*> nop
++0+3e78 <[^>]*> nop
++0+3e7c <[^>]*> nop
++0+3e80 <[^>]*> nop
++0+3e84 <[^>]*> nop
++0+3e88 <[^>]*> nop
++0+3e8c <[^>]*> nop
++0+3e90 <[^>]*> nop
++0+3e94 <[^>]*> nop
++0+3e98 <[^>]*> nop
++0+3e9c <[^>]*> nop
++0+3ea0 <[^>]*> nop
++0+3ea4 <[^>]*> nop
++0+3ea8 <[^>]*> nop
++0+3eac <[^>]*> nop
++0+3eb0 <[^>]*> nop
++0+3eb4 <[^>]*> nop
++0+3eb8 <[^>]*> nop
++0+3ebc <[^>]*> nop
++0+3ec0 <[^>]*> nop
++0+3ec4 <[^>]*> nop
++0+3ec8 <[^>]*> nop
++0+3ecc <[^>]*> nop
++0+3ed0 <[^>]*> nop
++0+3ed4 <[^>]*> nop
++0+3ed8 <[^>]*> nop
++0+3edc <[^>]*> nop
++0+3ee0 <[^>]*> nop
++0+3ee4 <[^>]*> nop
++0+3ee8 <[^>]*> nop
++0+3eec <[^>]*> nop
++0+3ef0 <[^>]*> nop
++0+3ef4 <[^>]*> nop
++0+3ef8 <[^>]*> nop
++0+3efc <[^>]*> nop
++0+3f00 <[^>]*> nop
++0+3f04 <[^>]*> nop
++0+3f08 <[^>]*> nop
++0+3f0c <[^>]*> nop
++0+3f10 <[^>]*> nop
++0+3f14 <[^>]*> nop
++0+3f18 <[^>]*> nop
++0+3f1c <[^>]*> nop
++0+3f20 <[^>]*> nop
++0+3f24 <[^>]*> nop
++0+3f28 <[^>]*> nop
++0+3f2c <[^>]*> nop
++0+3f30 <[^>]*> nop
++0+3f34 <[^>]*> nop
++0+3f38 <[^>]*> nop
++0+3f3c <[^>]*> nop
++0+3f40 <[^>]*> nop
++0+3f44 <[^>]*> nop
++0+3f48 <[^>]*> nop
++0+3f4c <[^>]*> nop
++0+3f50 <[^>]*> nop
++0+3f54 <[^>]*> nop
++0+3f58 <[^>]*> nop
++0+3f5c <[^>]*> nop
++0+3f60 <[^>]*> nop
++0+3f64 <[^>]*> nop
++0+3f68 <[^>]*> nop
++0+3f6c <[^>]*> nop
++0+3f70 <[^>]*> nop
++0+3f74 <[^>]*> nop
++0+3f78 <[^>]*> nop
++0+3f7c <[^>]*> nop
++0+3f80 <[^>]*> nop
++0+3f84 <[^>]*> nop
++0+3f88 <[^>]*> nop
++0+3f8c <[^>]*> nop
++0+3f90 <[^>]*> nop
++0+3f94 <[^>]*> nop
++0+3f98 <[^>]*> nop
++0+3f9c <[^>]*> nop
++0+3fa0 <[^>]*> nop
++0+3fa4 <[^>]*> nop
++0+3fa8 <[^>]*> nop
++0+3fac <[^>]*> nop
++0+3fb0 <[^>]*> nop
++0+3fb4 <[^>]*> nop
++0+3fb8 <[^>]*> nop
++0+3fbc <[^>]*> nop
++0+3fc0 <[^>]*> nop
++0+3fc4 <[^>]*> nop
++0+3fc8 <[^>]*> nop
++0+3fcc <[^>]*> nop
++0+3fd0 <[^>]*> nop
++0+3fd4 <[^>]*> nop
++0+3fd8 <[^>]*> nop
++0+3fdc <[^>]*> nop
++0+3fe0 <[^>]*> nop
++0+3fe4 <[^>]*> nop
++0+3fe8 <[^>]*> nop
++0+3fec <[^>]*> nop
++0+3ff0 <[^>]*> nop
++0+3ff4 <[^>]*> nop
++0+3ff8 <[^>]*> nop
++0+3ffc <[^>]*> nop
++0+4000 <[^>]*> nop
++0+4004 <[^>]*> nop
++0+4008 <[^>]*> nop
++0+400c <[^>]*> nop
++0+4010 <[^>]*> nop
++0+4014 <[^>]*> nop
++0+4018 <[^>]*> nop
++0+401c <[^>]*> nop
++0+4020 <[^>]*> nop
++0+4024 <[^>]*> nop
++0+4028 <[^>]*> nop
++0+402c <[^>]*> nop
++0+4030 <[^>]*> nop
++0+4034 <[^>]*> nop
++0+4038 <[^>]*> nop
++0+403c <[^>]*> nop
++0+4040 <[^>]*> nop
++0+4044 <[^>]*> nop
++0+4048 <[^>]*> nop
++0+404c <[^>]*> nop
++0+4050 <[^>]*> nop
++0+4054 <[^>]*> nop
++0+4058 <[^>]*> nop
++0+405c <[^>]*> nop
++0+4060 <[^>]*> nop
++0+4064 <[^>]*> nop
++0+4068 <[^>]*> nop
++0+406c <[^>]*> nop
++0+4070 <[^>]*> nop
++0+4074 <[^>]*> nop
++0+4078 <[^>]*> nop
++0+407c <[^>]*> nop
++0+4080 <[^>]*> nop
++0+4084 <[^>]*> nop
++0+4088 <[^>]*> nop
++0+408c <[^>]*> nop
++0+4090 <[^>]*> nop
++0+4094 <[^>]*> nop
++0+4098 <[^>]*> nop
++0+409c <[^>]*> nop
++0+40a0 <[^>]*> nop
++0+40a4 <[^>]*> nop
++0+40a8 <[^>]*> nop
++0+40ac <[^>]*> nop
++0+40b0 <[^>]*> nop
++0+40b4 <[^>]*> nop
++0+40b8 <[^>]*> nop
++0+40bc <[^>]*> nop
++0+40c0 <[^>]*> nop
++0+40c4 <[^>]*> nop
++0+40c8 <[^>]*> nop
++0+40cc <[^>]*> nop
++0+40d0 <[^>]*> nop
++0+40d4 <[^>]*> nop
++0+40d8 <[^>]*> nop
++0+40dc <[^>]*> nop
++0+40e0 <[^>]*> nop
++0+40e4 <[^>]*> nop
++0+40e8 <[^>]*> nop
++0+40ec <[^>]*> nop
++0+40f0 <[^>]*> nop
++0+40f4 <[^>]*> nop
++0+40f8 <[^>]*> nop
++0+40fc <[^>]*> nop
++0+4100 <[^>]*> nop
++0+4104 <[^>]*> nop
++0+4108 <[^>]*> nop
++0+410c <[^>]*> nop
++0+4110 <[^>]*> nop
++0+4114 <[^>]*> nop
++0+4118 <[^>]*> nop
++0+411c <[^>]*> nop
++0+4120 <[^>]*> nop
++0+4124 <[^>]*> nop
++0+4128 <[^>]*> nop
++0+412c <[^>]*> nop
++0+4130 <[^>]*> nop
++0+4134 <[^>]*> nop
++0+4138 <[^>]*> nop
++0+413c <[^>]*> nop
++0+4140 <[^>]*> nop
++0+4144 <[^>]*> nop
++0+4148 <[^>]*> nop
++0+414c <[^>]*> nop
++0+4150 <[^>]*> nop
++0+4154 <[^>]*> nop
++0+4158 <[^>]*> nop
++0+415c <[^>]*> nop
++0+4160 <[^>]*> nop
++0+4164 <[^>]*> nop
++0+4168 <[^>]*> nop
++0+416c <[^>]*> nop
++0+4170 <[^>]*> nop
++0+4174 <[^>]*> nop
++0+4178 <[^>]*> nop
++0+417c <[^>]*> nop
++0+4180 <[^>]*> nop
++0+4184 <[^>]*> nop
++0+4188 <[^>]*> nop
++0+418c <[^>]*> nop
++0+4190 <[^>]*> nop
++0+4194 <[^>]*> nop
++0+4198 <[^>]*> nop
++0+419c <[^>]*> nop
++0+41a0 <[^>]*> nop
++0+41a4 <[^>]*> nop
++0+41a8 <[^>]*> nop
++0+41ac <[^>]*> nop
++0+41b0 <[^>]*> nop
++0+41b4 <[^>]*> nop
++0+41b8 <[^>]*> nop
++0+41bc <[^>]*> nop
++0+41c0 <[^>]*> nop
++0+41c4 <[^>]*> nop
++0+41c8 <[^>]*> nop
++0+41cc <[^>]*> nop
++0+41d0 <[^>]*> nop
++0+41d4 <[^>]*> nop
++0+41d8 <[^>]*> nop
++0+41dc <[^>]*> nop
++0+41e0 <[^>]*> nop
++0+41e4 <[^>]*> nop
++0+41e8 <[^>]*> nop
++0+41ec <[^>]*> nop
++0+41f0 <[^>]*> nop
++0+41f4 <[^>]*> nop
++0+41f8 <[^>]*> nop
++0+41fc <[^>]*> nop
++0+4200 <[^>]*> nop
++0+4204 <[^>]*> nop
++0+4208 <[^>]*> nop
++0+420c <[^>]*> nop
++0+4210 <[^>]*> nop
++0+4214 <[^>]*> nop
++0+4218 <[^>]*> nop
++0+421c <[^>]*> nop
++0+4220 <[^>]*> nop
++0+4224 <[^>]*> nop
++0+4228 <[^>]*> nop
++0+422c <[^>]*> nop
++0+4230 <[^>]*> nop
++0+4234 <[^>]*> nop
++0+4238 <[^>]*> nop
++0+423c <[^>]*> nop
++0+4240 <[^>]*> nop
++0+4244 <[^>]*> nop
++0+4248 <[^>]*> nop
++0+424c <[^>]*> nop
++0+4250 <[^>]*> nop
++0+4254 <[^>]*> nop
++0+4258 <[^>]*> nop
++0+425c <[^>]*> nop
++0+4260 <[^>]*> nop
++0+4264 <[^>]*> nop
++0+4268 <[^>]*> nop
++0+426c <[^>]*> nop
++0+4270 <[^>]*> nop
++0+4274 <[^>]*> nop
++0+4278 <[^>]*> nop
++0+427c <[^>]*> nop
++0+4280 <[^>]*> nop
++0+4284 <[^>]*> nop
++0+4288 <[^>]*> nop
++0+428c <[^>]*> nop
++0+4290 <[^>]*> nop
++0+4294 <[^>]*> nop
++0+4298 <[^>]*> nop
++0+429c <[^>]*> nop
++0+42a0 <[^>]*> nop
++0+42a4 <[^>]*> nop
++0+42a8 <[^>]*> nop
++0+42ac <[^>]*> nop
++0+42b0 <[^>]*> nop
++0+42b4 <[^>]*> nop
++0+42b8 <[^>]*> nop
++0+42bc <[^>]*> nop
++0+42c0 <[^>]*> nop
++0+42c4 <[^>]*> nop
++0+42c8 <[^>]*> nop
++0+42cc <[^>]*> nop
++0+42d0 <[^>]*> nop
++0+42d4 <[^>]*> nop
++0+42d8 <[^>]*> nop
++0+42dc <[^>]*> nop
++0+42e0 <[^>]*> nop
++0+42e4 <[^>]*> nop
++0+42e8 <[^>]*> nop
++0+42ec <[^>]*> nop
++0+42f0 <[^>]*> nop
++0+42f4 <[^>]*> nop
++0+42f8 <[^>]*> nop
++0+42fc <[^>]*> nop
++0+4300 <[^>]*> nop
++0+4304 <[^>]*> nop
++0+4308 <[^>]*> nop
++0+430c <[^>]*> nop
++0+4310 <[^>]*> nop
++0+4314 <[^>]*> nop
++0+4318 <[^>]*> nop
++0+431c <[^>]*> nop
++0+4320 <[^>]*> nop
++0+4324 <[^>]*> nop
++0+4328 <[^>]*> nop
++0+432c <[^>]*> nop
++0+4330 <[^>]*> nop
++0+4334 <[^>]*> nop
++0+4338 <[^>]*> nop
++0+433c <[^>]*> nop
++0+4340 <[^>]*> nop
++0+4344 <[^>]*> nop
++0+4348 <[^>]*> nop
++0+434c <[^>]*> nop
++0+4350 <[^>]*> nop
++0+4354 <[^>]*> nop
++0+4358 <[^>]*> nop
++0+435c <[^>]*> nop
++0+4360 <[^>]*> nop
++0+4364 <[^>]*> nop
++0+4368 <[^>]*> nop
++0+436c <[^>]*> nop
++0+4370 <[^>]*> nop
++0+4374 <[^>]*> nop
++0+4378 <[^>]*> nop
++0+437c <[^>]*> nop
++0+4380 <[^>]*> nop
++0+4384 <[^>]*> nop
++0+4388 <[^>]*> nop
++0+438c <[^>]*> nop
++0+4390 <[^>]*> nop
++0+4394 <[^>]*> nop
++0+4398 <[^>]*> nop
++0+439c <[^>]*> nop
++0+43a0 <[^>]*> nop
++0+43a4 <[^>]*> nop
++0+43a8 <[^>]*> nop
++0+43ac <[^>]*> nop
++0+43b0 <[^>]*> nop
++0+43b4 <[^>]*> nop
++0+43b8 <[^>]*> nop
++0+43bc <[^>]*> nop
++0+43c0 <[^>]*> nop
++0+43c4 <[^>]*> nop
++0+43c8 <[^>]*> nop
++0+43cc <[^>]*> nop
++0+43d0 <[^>]*> nop
++0+43d4 <[^>]*> nop
++0+43d8 <[^>]*> nop
++0+43dc <[^>]*> nop
++0+43e0 <[^>]*> nop
++0+43e4 <[^>]*> nop
++0+43e8 <[^>]*> nop
++0+43ec <[^>]*> nop
++0+43f0 <[^>]*> nop
++0+43f4 <[^>]*> nop
++0+43f8 <[^>]*> nop
++0+43fc <[^>]*> nop
++0+4400 <[^>]*> nop
++0+4404 <[^>]*> nop
++0+4408 <[^>]*> nop
++0+440c <[^>]*> nop
++0+4410 <[^>]*> nop
++0+4414 <[^>]*> nop
++0+4418 <[^>]*> nop
++0+441c <[^>]*> nop
++0+4420 <[^>]*> nop
++0+4424 <[^>]*> nop
++0+4428 <[^>]*> nop
++0+442c <[^>]*> nop
++0+4430 <[^>]*> nop
++0+4434 <[^>]*> nop
++0+4438 <[^>]*> nop
++0+443c <[^>]*> nop
++0+4440 <[^>]*> nop
++0+4444 <[^>]*> nop
++0+4448 <[^>]*> nop
++0+444c <[^>]*> nop
++0+4450 <[^>]*> nop
++0+4454 <[^>]*> nop
++0+4458 <[^>]*> nop
++0+445c <[^>]*> nop
++0+4460 <[^>]*> nop
++0+4464 <[^>]*> nop
++0+4468 <[^>]*> nop
++0+446c <[^>]*> nop
++0+4470 <[^>]*> nop
++0+4474 <[^>]*> nop
++0+4478 <[^>]*> nop
++0+447c <[^>]*> nop
++0+4480 <[^>]*> nop
++0+4484 <[^>]*> nop
++0+4488 <[^>]*> nop
++0+448c <[^>]*> nop
++0+4490 <[^>]*> nop
++0+4494 <[^>]*> nop
++0+4498 <[^>]*> nop
++0+449c <[^>]*> nop
++0+44a0 <[^>]*> nop
++0+44a4 <[^>]*> nop
++0+44a8 <[^>]*> nop
++0+44ac <[^>]*> nop
++0+44b0 <[^>]*> nop
++0+44b4 <[^>]*> nop
++0+44b8 <[^>]*> nop
++0+44bc <[^>]*> nop
++0+44c0 <[^>]*> nop
++0+44c4 <[^>]*> nop
++0+44c8 <[^>]*> nop
++0+44cc <[^>]*> nop
++0+44d0 <[^>]*> nop
++0+44d4 <[^>]*> nop
++0+44d8 <[^>]*> nop
++0+44dc <[^>]*> nop
++0+44e0 <[^>]*> nop
++0+44e4 <[^>]*> nop
++0+44e8 <[^>]*> nop
++0+44ec <[^>]*> nop
++0+44f0 <[^>]*> nop
++0+44f4 <[^>]*> nop
++0+44f8 <[^>]*> nop
++0+44fc <[^>]*> nop
++0+4500 <[^>]*> nop
++0+4504 <[^>]*> nop
++0+4508 <[^>]*> nop
++0+450c <[^>]*> nop
++0+4510 <[^>]*> nop
++0+4514 <[^>]*> nop
++0+4518 <[^>]*> nop
++0+451c <[^>]*> nop
++0+4520 <[^>]*> nop
++0+4524 <[^>]*> nop
++0+4528 <[^>]*> nop
++0+452c <[^>]*> nop
++0+4530 <[^>]*> nop
++0+4534 <[^>]*> nop
++0+4538 <[^>]*> nop
++0+453c <[^>]*> nop
++0+4540 <[^>]*> nop
++0+4544 <[^>]*> nop
++0+4548 <[^>]*> nop
++0+454c <[^>]*> nop
++0+4550 <[^>]*> nop
++0+4554 <[^>]*> nop
++0+4558 <[^>]*> nop
++0+455c <[^>]*> nop
++0+4560 <[^>]*> nop
++0+4564 <[^>]*> nop
++0+4568 <[^>]*> nop
++0+456c <[^>]*> nop
++0+4570 <[^>]*> nop
++0+4574 <[^>]*> nop
++0+4578 <[^>]*> nop
++0+457c <[^>]*> nop
++0+4580 <[^>]*> nop
++0+4584 <[^>]*> nop
++0+4588 <[^>]*> nop
++0+458c <[^>]*> nop
++0+4590 <[^>]*> nop
++0+4594 <[^>]*> nop
++0+4598 <[^>]*> nop
++0+459c <[^>]*> nop
++0+45a0 <[^>]*> nop
++0+45a4 <[^>]*> nop
++0+45a8 <[^>]*> nop
++0+45ac <[^>]*> nop
++0+45b0 <[^>]*> nop
++0+45b4 <[^>]*> nop
++0+45b8 <[^>]*> nop
++0+45bc <[^>]*> nop
++0+45c0 <[^>]*> nop
++0+45c4 <[^>]*> nop
++0+45c8 <[^>]*> nop
++0+45cc <[^>]*> nop
++0+45d0 <[^>]*> nop
++0+45d4 <[^>]*> nop
++0+45d8 <[^>]*> nop
++0+45dc <[^>]*> nop
++0+45e0 <[^>]*> nop
++0+45e4 <[^>]*> nop
++0+45e8 <[^>]*> nop
++0+45ec <[^>]*> nop
++0+45f0 <[^>]*> nop
++0+45f4 <[^>]*> nop
++0+45f8 <[^>]*> nop
++0+45fc <[^>]*> nop
++0+4600 <[^>]*> nop
++0+4604 <[^>]*> nop
++0+4608 <[^>]*> nop
++0+460c <[^>]*> nop
++0+4610 <[^>]*> nop
++0+4614 <[^>]*> nop
++0+4618 <[^>]*> nop
++0+461c <[^>]*> nop
++0+4620 <[^>]*> nop
++0+4624 <[^>]*> nop
++0+4628 <[^>]*> nop
++0+462c <[^>]*> nop
++0+4630 <[^>]*> nop
++0+4634 <[^>]*> nop
++0+4638 <[^>]*> nop
++0+463c <[^>]*> nop
++0+4640 <[^>]*> nop
++0+4644 <[^>]*> nop
++0+4648 <[^>]*> nop
++0+464c <[^>]*> nop
++0+4650 <[^>]*> nop
++0+4654 <[^>]*> nop
++0+4658 <[^>]*> nop
++0+465c <[^>]*> nop
++0+4660 <[^>]*> nop
++0+4664 <[^>]*> nop
++0+4668 <[^>]*> nop
++0+466c <[^>]*> nop
++0+4670 <[^>]*> nop
++0+4674 <[^>]*> nop
++0+4678 <[^>]*> nop
++0+467c <[^>]*> nop
++0+4680 <[^>]*> nop
++0+4684 <[^>]*> nop
++0+4688 <[^>]*> nop
++0+468c <[^>]*> nop
++0+4690 <[^>]*> nop
++0+4694 <[^>]*> nop
++0+4698 <[^>]*> nop
++0+469c <[^>]*> nop
++0+46a0 <[^>]*> nop
++0+46a4 <[^>]*> nop
++0+46a8 <[^>]*> nop
++0+46ac <[^>]*> nop
++0+46b0 <[^>]*> nop
++0+46b4 <[^>]*> nop
++0+46b8 <[^>]*> nop
++0+46bc <[^>]*> nop
++0+46c0 <[^>]*> nop
++0+46c4 <[^>]*> nop
++0+46c8 <[^>]*> nop
++0+46cc <[^>]*> nop
++0+46d0 <[^>]*> nop
++0+46d4 <[^>]*> nop
++0+46d8 <[^>]*> nop
++0+46dc <[^>]*> nop
++0+46e0 <[^>]*> nop
++0+46e4 <[^>]*> nop
++0+46e8 <[^>]*> nop
++0+46ec <[^>]*> nop
++0+46f0 <[^>]*> nop
++0+46f4 <[^>]*> nop
++0+46f8 <[^>]*> nop
++0+46fc <[^>]*> nop
++0+4700 <[^>]*> nop
++0+4704 <[^>]*> nop
++0+4708 <[^>]*> nop
++0+470c <[^>]*> nop
++0+4710 <[^>]*> nop
++0+4714 <[^>]*> nop
++0+4718 <[^>]*> nop
++0+471c <[^>]*> nop
++0+4720 <[^>]*> nop
++0+4724 <[^>]*> nop
++0+4728 <[^>]*> nop
++0+472c <[^>]*> nop
++0+4730 <[^>]*> nop
++0+4734 <[^>]*> nop
++0+4738 <[^>]*> nop
++0+473c <[^>]*> nop
++0+4740 <[^>]*> nop
++0+4744 <[^>]*> nop
++0+4748 <[^>]*> nop
++0+474c <[^>]*> nop
++0+4750 <[^>]*> nop
++0+4754 <[^>]*> nop
++0+4758 <[^>]*> nop
++0+475c <[^>]*> nop
++0+4760 <[^>]*> nop
++0+4764 <[^>]*> nop
++0+4768 <[^>]*> nop
++0+476c <[^>]*> nop
++0+4770 <[^>]*> nop
++0+4774 <[^>]*> nop
++0+4778 <[^>]*> nop
++0+477c <[^>]*> nop
++0+4780 <[^>]*> nop
++0+4784 <[^>]*> nop
++0+4788 <[^>]*> nop
++0+478c <[^>]*> nop
++0+4790 <[^>]*> nop
++0+4794 <[^>]*> nop
++0+4798 <[^>]*> nop
++0+479c <[^>]*> nop
++0+47a0 <[^>]*> nop
++0+47a4 <[^>]*> nop
++0+47a8 <[^>]*> nop
++0+47ac <[^>]*> nop
++0+47b0 <[^>]*> nop
++0+47b4 <[^>]*> nop
++0+47b8 <[^>]*> nop
++0+47bc <[^>]*> nop
++0+47c0 <[^>]*> nop
++0+47c4 <[^>]*> nop
++0+47c8 <[^>]*> nop
++0+47cc <[^>]*> nop
++0+47d0 <[^>]*> nop
++0+47d4 <[^>]*> nop
++0+47d8 <[^>]*> nop
++0+47dc <[^>]*> nop
++0+47e0 <[^>]*> nop
++0+47e4 <[^>]*> nop
++0+47e8 <[^>]*> nop
++0+47ec <[^>]*> nop
++0+47f0 <[^>]*> nop
++0+47f4 <[^>]*> nop
++0+47f8 <[^>]*> nop
++0+47fc <[^>]*> nop
++0+4800 <[^>]*> nop
++0+4804 <[^>]*> nop
++0+4808 <[^>]*> nop
++0+480c <[^>]*> nop
++0+4810 <[^>]*> nop
++0+4814 <[^>]*> nop
++0+4818 <[^>]*> nop
++0+481c <[^>]*> nop
++0+4820 <[^>]*> nop
++0+4824 <[^>]*> nop
++0+4828 <[^>]*> nop
++0+482c <[^>]*> nop
++0+4830 <[^>]*> nop
++0+4834 <[^>]*> nop
++0+4838 <[^>]*> nop
++0+483c <[^>]*> nop
++0+4840 <[^>]*> nop
++0+4844 <[^>]*> nop
++0+4848 <[^>]*> nop
++0+484c <[^>]*> nop
++0+4850 <[^>]*> nop
++0+4854 <[^>]*> nop
++0+4858 <[^>]*> nop
++0+485c <[^>]*> nop
++0+4860 <[^>]*> nop
++0+4864 <[^>]*> nop
++0+4868 <[^>]*> nop
++0+486c <[^>]*> nop
++0+4870 <[^>]*> nop
++0+4874 <[^>]*> nop
++0+4878 <[^>]*> nop
++0+487c <[^>]*> nop
++0+4880 <[^>]*> nop
++0+4884 <[^>]*> nop
++0+4888 <[^>]*> nop
++0+488c <[^>]*> nop
++0+4890 <[^>]*> nop
++0+4894 <[^>]*> nop
++0+4898 <[^>]*> nop
++0+489c <[^>]*> nop
++0+48a0 <[^>]*> nop
++0+48a4 <[^>]*> nop
++0+48a8 <[^>]*> nop
++0+48ac <[^>]*> nop
++0+48b0 <[^>]*> nop
++0+48b4 <[^>]*> nop
++0+48b8 <[^>]*> nop
++0+48bc <[^>]*> nop
++0+48c0 <[^>]*> nop
++0+48c4 <[^>]*> nop
++0+48c8 <[^>]*> nop
++0+48cc <[^>]*> nop
++0+48d0 <[^>]*> nop
++0+48d4 <[^>]*> nop
++0+48d8 <[^>]*> nop
++0+48dc <[^>]*> nop
++0+48e0 <[^>]*> nop
++0+48e4 <[^>]*> nop
++0+48e8 <[^>]*> nop
++0+48ec <[^>]*> nop
++0+48f0 <[^>]*> nop
++0+48f4 <[^>]*> nop
++0+48f8 <[^>]*> nop
++0+48fc <[^>]*> nop
++0+4900 <[^>]*> nop
++0+4904 <[^>]*> nop
++0+4908 <[^>]*> nop
++0+490c <[^>]*> nop
++0+4910 <[^>]*> nop
++0+4914 <[^>]*> nop
++0+4918 <[^>]*> nop
++0+491c <[^>]*> nop
++0+4920 <[^>]*> nop
++0+4924 <[^>]*> nop
++0+4928 <[^>]*> nop
++0+492c <[^>]*> nop
++0+4930 <[^>]*> nop
++0+4934 <[^>]*> nop
++0+4938 <[^>]*> nop
++0+493c <[^>]*> nop
++0+4940 <[^>]*> nop
++0+4944 <[^>]*> nop
++0+4948 <[^>]*> nop
++0+494c <[^>]*> nop
++0+4950 <[^>]*> nop
++0+4954 <[^>]*> nop
++0+4958 <[^>]*> nop
++0+495c <[^>]*> nop
++0+4960 <[^>]*> nop
++0+4964 <[^>]*> nop
++0+4968 <[^>]*> nop
++0+496c <[^>]*> nop
++0+4970 <[^>]*> nop
++0+4974 <[^>]*> nop
++0+4978 <[^>]*> nop
++0+497c <[^>]*> nop
++0+4980 <[^>]*> nop
++0+4984 <[^>]*> nop
++0+4988 <[^>]*> nop
++0+498c <[^>]*> nop
++0+4990 <[^>]*> nop
++0+4994 <[^>]*> nop
++0+4998 <[^>]*> nop
++0+499c <[^>]*> nop
++0+49a0 <[^>]*> nop
++0+49a4 <[^>]*> nop
++0+49a8 <[^>]*> nop
++0+49ac <[^>]*> nop
++0+49b0 <[^>]*> nop
++0+49b4 <[^>]*> nop
++0+49b8 <[^>]*> nop
++0+49bc <[^>]*> nop
++0+49c0 <[^>]*> nop
++0+49c4 <[^>]*> nop
++0+49c8 <[^>]*> nop
++0+49cc <[^>]*> nop
++0+49d0 <[^>]*> nop
++0+49d4 <[^>]*> nop
++0+49d8 <[^>]*> nop
++0+49dc <[^>]*> nop
++0+49e0 <[^>]*> nop
++0+49e4 <[^>]*> nop
++0+49e8 <[^>]*> nop
++0+49ec <[^>]*> nop
++0+49f0 <[^>]*> nop
++0+49f4 <[^>]*> nop
++0+49f8 <[^>]*> nop
++0+49fc <[^>]*> nop
++0+4a00 <[^>]*> nop
++0+4a04 <[^>]*> nop
++0+4a08 <[^>]*> nop
++0+4a0c <[^>]*> nop
++0+4a10 <[^>]*> nop
++0+4a14 <[^>]*> nop
++0+4a18 <[^>]*> nop
++0+4a1c <[^>]*> nop
++0+4a20 <[^>]*> nop
++0+4a24 <[^>]*> nop
++0+4a28 <[^>]*> nop
++0+4a2c <[^>]*> nop
++0+4a30 <[^>]*> nop
++0+4a34 <[^>]*> nop
++0+4a38 <[^>]*> nop
++0+4a3c <[^>]*> nop
++0+4a40 <[^>]*> nop
++0+4a44 <[^>]*> nop
++0+4a48 <[^>]*> nop
++0+4a4c <[^>]*> nop
++0+4a50 <[^>]*> nop
++0+4a54 <[^>]*> nop
++0+4a58 <[^>]*> nop
++0+4a5c <[^>]*> nop
++0+4a60 <[^>]*> nop
++0+4a64 <[^>]*> nop
++0+4a68 <[^>]*> nop
++0+4a6c <[^>]*> nop
++0+4a70 <[^>]*> nop
++0+4a74 <[^>]*> nop
++0+4a78 <[^>]*> nop
++0+4a7c <[^>]*> nop
++0+4a80 <[^>]*> nop
++0+4a84 <[^>]*> nop
++0+4a88 <[^>]*> nop
++0+4a8c <[^>]*> nop
++0+4a90 <[^>]*> nop
++0+4a94 <[^>]*> nop
++0+4a98 <[^>]*> nop
++0+4a9c <[^>]*> nop
++0+4aa0 <[^>]*> nop
++0+4aa4 <[^>]*> nop
++0+4aa8 <[^>]*> nop
++0+4aac <[^>]*> nop
++0+4ab0 <[^>]*> nop
++0+4ab4 <[^>]*> nop
++0+4ab8 <[^>]*> nop
++0+4abc <[^>]*> nop
++0+4ac0 <[^>]*> nop
++0+4ac4 <[^>]*> nop
++0+4ac8 <[^>]*> nop
++0+4acc <[^>]*> nop
++0+4ad0 <[^>]*> nop
++0+4ad4 <[^>]*> nop
++0+4ad8 <[^>]*> nop
++0+4adc <[^>]*> nop
++0+4ae0 <[^>]*> nop
++0+4ae4 <[^>]*> nop
++0+4ae8 <[^>]*> nop
++0+4aec <[^>]*> nop
++0+4af0 <[^>]*> nop
++0+4af4 <[^>]*> nop
++0+4af8 <[^>]*> nop
++0+4afc <[^>]*> nop
++0+4b00 <[^>]*> nop
++0+4b04 <[^>]*> nop
++0+4b08 <[^>]*> nop
++0+4b0c <[^>]*> nop
++0+4b10 <[^>]*> nop
++0+4b14 <[^>]*> nop
++0+4b18 <[^>]*> nop
++0+4b1c <[^>]*> nop
++0+4b20 <[^>]*> nop
++0+4b24 <[^>]*> nop
++0+4b28 <[^>]*> nop
++0+4b2c <[^>]*> nop
++0+4b30 <[^>]*> nop
++0+4b34 <[^>]*> nop
++0+4b38 <[^>]*> nop
++0+4b3c <[^>]*> nop
++0+4b40 <[^>]*> nop
++0+4b44 <[^>]*> nop
++0+4b48 <[^>]*> nop
++0+4b4c <[^>]*> nop
++0+4b50 <[^>]*> nop
++0+4b54 <[^>]*> nop
++0+4b58 <[^>]*> nop
++0+4b5c <[^>]*> nop
++0+4b60 <[^>]*> nop
++0+4b64 <[^>]*> nop
++0+4b68 <[^>]*> nop
++0+4b6c <[^>]*> nop
++0+4b70 <[^>]*> nop
++0+4b74 <[^>]*> nop
++0+4b78 <[^>]*> nop
++0+4b7c <[^>]*> nop
++0+4b80 <[^>]*> nop
++0+4b84 <[^>]*> nop
++0+4b88 <[^>]*> nop
++0+4b8c <[^>]*> nop
++0+4b90 <[^>]*> nop
++0+4b94 <[^>]*> nop
++0+4b98 <[^>]*> nop
++0+4b9c <[^>]*> nop
++0+4ba0 <[^>]*> nop
++0+4ba4 <[^>]*> nop
++0+4ba8 <[^>]*> nop
++0+4bac <[^>]*> nop
++0+4bb0 <[^>]*> nop
++0+4bb4 <[^>]*> nop
++0+4bb8 <[^>]*> nop
++0+4bbc <[^>]*> nop
++0+4bc0 <[^>]*> nop
++0+4bc4 <[^>]*> nop
++0+4bc8 <[^>]*> nop
++0+4bcc <[^>]*> nop
++0+4bd0 <[^>]*> nop
++0+4bd4 <[^>]*> nop
++0+4bd8 <[^>]*> nop
++0+4bdc <[^>]*> nop
++0+4be0 <[^>]*> nop
++0+4be4 <[^>]*> nop
++0+4be8 <[^>]*> nop
++0+4bec <[^>]*> nop
++0+4bf0 <[^>]*> nop
++0+4bf4 <[^>]*> nop
++0+4bf8 <[^>]*> nop
++0+4bfc <[^>]*> nop
++0+4c00 <[^>]*> nop
++0+4c04 <[^>]*> nop
++0+4c08 <[^>]*> nop
++0+4c0c <[^>]*> nop
++0+4c10 <[^>]*> nop
++0+4c14 <[^>]*> nop
++0+4c18 <[^>]*> nop
++0+4c1c <[^>]*> nop
++0+4c20 <[^>]*> nop
++0+4c24 <[^>]*> nop
++0+4c28 <[^>]*> nop
++0+4c2c <[^>]*> nop
++0+4c30 <[^>]*> nop
++0+4c34 <[^>]*> nop
++0+4c38 <[^>]*> nop
++0+4c3c <[^>]*> nop
++0+4c40 <[^>]*> nop
++0+4c44 <[^>]*> nop
++0+4c48 <[^>]*> nop
++0+4c4c <[^>]*> nop
++0+4c50 <[^>]*> nop
++0+4c54 <[^>]*> nop
++0+4c58 <[^>]*> nop
++0+4c5c <[^>]*> nop
++0+4c60 <[^>]*> nop
++0+4c64 <[^>]*> nop
++0+4c68 <[^>]*> nop
++0+4c6c <[^>]*> nop
++0+4c70 <[^>]*> nop
++0+4c74 <[^>]*> nop
++0+4c78 <[^>]*> nop
++0+4c7c <[^>]*> nop
++0+4c80 <[^>]*> nop
++0+4c84 <[^>]*> nop
++0+4c88 <[^>]*> nop
++0+4c8c <[^>]*> nop
++0+4c90 <[^>]*> nop
++0+4c94 <[^>]*> nop
++0+4c98 <[^>]*> nop
++0+4c9c <[^>]*> nop
++0+4ca0 <[^>]*> nop
++0+4ca4 <[^>]*> nop
++0+4ca8 <[^>]*> nop
++0+4cac <[^>]*> nop
++0+4cb0 <[^>]*> nop
++0+4cb4 <[^>]*> nop
++0+4cb8 <[^>]*> nop
++0+4cbc <[^>]*> nop
++0+4cc0 <[^>]*> nop
++0+4cc4 <[^>]*> nop
++0+4cc8 <[^>]*> nop
++0+4ccc <[^>]*> nop
++0+4cd0 <[^>]*> nop
++0+4cd4 <[^>]*> nop
++0+4cd8 <[^>]*> nop
++0+4cdc <[^>]*> nop
++0+4ce0 <[^>]*> nop
++0+4ce4 <[^>]*> nop
++0+4ce8 <[^>]*> nop
++0+4cec <[^>]*> nop
++0+4cf0 <[^>]*> nop
++0+4cf4 <[^>]*> nop
++0+4cf8 <[^>]*> nop
++0+4cfc <[^>]*> nop
++0+4d00 <[^>]*> nop
++0+4d04 <[^>]*> nop
++0+4d08 <[^>]*> nop
++0+4d0c <[^>]*> nop
++0+4d10 <[^>]*> nop
++0+4d14 <[^>]*> nop
++0+4d18 <[^>]*> nop
++0+4d1c <[^>]*> nop
++0+4d20 <[^>]*> nop
++0+4d24 <[^>]*> nop
++0+4d28 <[^>]*> nop
++0+4d2c <[^>]*> nop
++0+4d30 <[^>]*> nop
++0+4d34 <[^>]*> nop
++0+4d38 <[^>]*> nop
++0+4d3c <[^>]*> nop
++0+4d40 <[^>]*> nop
++0+4d44 <[^>]*> nop
++0+4d48 <[^>]*> nop
++0+4d4c <[^>]*> nop
++0+4d50 <[^>]*> nop
++0+4d54 <[^>]*> nop
++0+4d58 <[^>]*> nop
++0+4d5c <[^>]*> nop
++0+4d60 <[^>]*> nop
++0+4d64 <[^>]*> nop
++0+4d68 <[^>]*> nop
++0+4d6c <[^>]*> nop
++0+4d70 <[^>]*> nop
++0+4d74 <[^>]*> nop
++0+4d78 <[^>]*> nop
++0+4d7c <[^>]*> nop
++0+4d80 <[^>]*> nop
++0+4d84 <[^>]*> nop
++0+4d88 <[^>]*> nop
++0+4d8c <[^>]*> nop
++0+4d90 <[^>]*> nop
++0+4d94 <[^>]*> nop
++0+4d98 <[^>]*> nop
++0+4d9c <[^>]*> nop
++0+4da0 <[^>]*> nop
++0+4da4 <[^>]*> nop
++0+4da8 <[^>]*> nop
++0+4dac <[^>]*> nop
++0+4db0 <[^>]*> nop
++0+4db4 <[^>]*> nop
++0+4db8 <[^>]*> nop
++0+4dbc <[^>]*> nop
++0+4dc0 <[^>]*> nop
++0+4dc4 <[^>]*> nop
++0+4dc8 <[^>]*> nop
++0+4dcc <[^>]*> nop
++0+4dd0 <[^>]*> nop
++0+4dd4 <[^>]*> nop
++0+4dd8 <[^>]*> nop
++0+4ddc <[^>]*> nop
++0+4de0 <[^>]*> nop
++0+4de4 <[^>]*> nop
++0+4de8 <[^>]*> nop
++0+4dec <[^>]*> nop
++0+4df0 <[^>]*> nop
++0+4df4 <[^>]*> nop
++0+4df8 <[^>]*> nop
++0+4dfc <[^>]*> nop
++0+4e00 <[^>]*> nop
++0+4e04 <[^>]*> nop
++0+4e08 <[^>]*> nop
++0+4e0c <[^>]*> nop
++0+4e10 <[^>]*> nop
++0+4e14 <[^>]*> nop
++0+4e18 <[^>]*> nop
++0+4e1c <[^>]*> nop
++0+4e20 <[^>]*> nop
++0+4e24 <[^>]*> nop
++0+4e28 <[^>]*> nop
++0+4e2c <[^>]*> nop
++0+4e30 <[^>]*> nop
++0+4e34 <[^>]*> nop
++0+4e38 <[^>]*> nop
++0+4e3c <[^>]*> nop
++0+4e40 <[^>]*> nop
++0+4e44 <[^>]*> nop
++0+4e48 <[^>]*> nop
++0+4e4c <[^>]*> nop
++0+4e50 <[^>]*> nop
++0+4e54 <[^>]*> nop
++0+4e58 <[^>]*> nop
++0+4e5c <[^>]*> nop
++0+4e60 <[^>]*> nop
++0+4e64 <[^>]*> nop
++0+4e68 <[^>]*> nop
++0+4e6c <[^>]*> nop
++0+4e70 <[^>]*> nop
++0+4e74 <[^>]*> nop
++0+4e78 <[^>]*> nop
++0+4e7c <[^>]*> nop
++0+4e80 <[^>]*> nop
++0+4e84 <[^>]*> nop
++0+4e88 <[^>]*> nop
++0+4e8c <[^>]*> nop
++0+4e90 <[^>]*> nop
++0+4e94 <[^>]*> nop
++0+4e98 <[^>]*> nop
++0+4e9c <[^>]*> nop
++0+4ea0 <[^>]*> nop
++0+4ea4 <[^>]*> nop
++0+4ea8 <[^>]*> nop
++0+4eac <[^>]*> nop
++0+4eb0 <[^>]*> nop
++0+4eb4 <[^>]*> nop
++0+4eb8 <[^>]*> nop
++0+4ebc <[^>]*> nop
++0+4ec0 <[^>]*> nop
++0+4ec4 <[^>]*> nop
++0+4ec8 <[^>]*> nop
++0+4ecc <[^>]*> nop
++0+4ed0 <[^>]*> nop
++0+4ed4 <[^>]*> nop
++0+4ed8 <[^>]*> nop
++0+4edc <[^>]*> nop
++0+4ee0 <[^>]*> nop
++0+4ee4 <[^>]*> nop
++0+4ee8 <[^>]*> nop
++0+4eec <[^>]*> nop
++0+4ef0 <[^>]*> nop
++0+4ef4 <[^>]*> nop
++0+4ef8 <[^>]*> nop
++0+4efc <[^>]*> nop
++0+4f00 <[^>]*> nop
++0+4f04 <[^>]*> nop
++0+4f08 <[^>]*> nop
++0+4f0c <[^>]*> nop
++0+4f10 <[^>]*> nop
++0+4f14 <[^>]*> nop
++0+4f18 <[^>]*> nop
++0+4f1c <[^>]*> nop
++0+4f20 <[^>]*> nop
++0+4f24 <[^>]*> nop
++0+4f28 <[^>]*> nop
++0+4f2c <[^>]*> nop
++0+4f30 <[^>]*> nop
++0+4f34 <[^>]*> nop
++0+4f38 <[^>]*> nop
++0+4f3c <[^>]*> nop
++0+4f40 <[^>]*> nop
++0+4f44 <[^>]*> nop
++0+4f48 <[^>]*> nop
++0+4f4c <[^>]*> nop
++0+4f50 <[^>]*> nop
++0+4f54 <[^>]*> nop
++0+4f58 <[^>]*> nop
++0+4f5c <[^>]*> nop
++0+4f60 <[^>]*> nop
++0+4f64 <[^>]*> nop
++0+4f68 <[^>]*> nop
++0+4f6c <[^>]*> nop
++0+4f70 <[^>]*> nop
++0+4f74 <[^>]*> nop
++0+4f78 <[^>]*> nop
++0+4f7c <[^>]*> nop
++0+4f80 <[^>]*> nop
++0+4f84 <[^>]*> nop
++0+4f88 <[^>]*> nop
++0+4f8c <[^>]*> nop
++0+4f90 <[^>]*> nop
++0+4f94 <[^>]*> nop
++0+4f98 <[^>]*> nop
++0+4f9c <[^>]*> nop
++0+4fa0 <[^>]*> nop
++0+4fa4 <[^>]*> nop
++0+4fa8 <[^>]*> nop
++0+4fac <[^>]*> nop
++0+4fb0 <[^>]*> nop
++0+4fb4 <[^>]*> nop
++0+4fb8 <[^>]*> nop
++0+4fbc <[^>]*> nop
++0+4fc0 <[^>]*> nop
++0+4fc4 <[^>]*> nop
++0+4fc8 <[^>]*> nop
++0+4fcc <[^>]*> nop
++0+4fd0 <[^>]*> nop
++0+4fd4 <[^>]*> nop
++0+4fd8 <[^>]*> nop
++0+4fdc <[^>]*> nop
++0+4fe0 <[^>]*> nop
++0+4fe4 <[^>]*> nop
++0+4fe8 <[^>]*> nop
++0+4fec <[^>]*> nop
++0+4ff0 <[^>]*> nop
++0+4ff4 <[^>]*> nop
++0+4ff8 <[^>]*> nop
++0+4ffc <[^>]*> nop
++0+5000 <[^>]*> nop
++0+5004 <[^>]*> nop
++0+5008 <[^>]*> nop
++0+500c <[^>]*> nop
++0+5010 <[^>]*> nop
++0+5014 <[^>]*> nop
++0+5018 <[^>]*> nop
++0+501c <[^>]*> nop
++0+5020 <[^>]*> nop
++0+5024 <[^>]*> nop
++0+5028 <[^>]*> nop
++0+502c <[^>]*> nop
++0+5030 <[^>]*> nop
++0+5034 <[^>]*> nop
++0+5038 <[^>]*> nop
++0+503c <[^>]*> nop
++0+5040 <[^>]*> nop
++0+5044 <[^>]*> nop
++0+5048 <[^>]*> nop
++0+504c <[^>]*> nop
++0+5050 <[^>]*> nop
++0+5054 <[^>]*> nop
++0+5058 <[^>]*> nop
++0+505c <[^>]*> nop
++0+5060 <[^>]*> nop
++0+5064 <[^>]*> nop
++0+5068 <[^>]*> nop
++0+506c <[^>]*> nop
++0+5070 <[^>]*> nop
++0+5074 <[^>]*> nop
++0+5078 <[^>]*> nop
++0+507c <[^>]*> nop
++0+5080 <[^>]*> nop
++0+5084 <[^>]*> nop
++0+5088 <[^>]*> nop
++0+508c <[^>]*> nop
++0+5090 <[^>]*> nop
++0+5094 <[^>]*> nop
++0+5098 <[^>]*> nop
++0+509c <[^>]*> nop
++0+50a0 <[^>]*> nop
++0+50a4 <[^>]*> nop
++0+50a8 <[^>]*> nop
++0+50ac <[^>]*> nop
++0+50b0 <[^>]*> nop
++0+50b4 <[^>]*> nop
++0+50b8 <[^>]*> nop
++0+50bc <[^>]*> nop
++0+50c0 <[^>]*> nop
++0+50c4 <[^>]*> nop
++0+50c8 <[^>]*> nop
++0+50cc <[^>]*> nop
++0+50d0 <[^>]*> nop
++0+50d4 <[^>]*> nop
++0+50d8 <[^>]*> nop
++0+50dc <[^>]*> nop
++0+50e0 <[^>]*> nop
++0+50e4 <[^>]*> nop
++0+50e8 <[^>]*> nop
++0+50ec <[^>]*> nop
++0+50f0 <[^>]*> nop
++0+50f4 <[^>]*> nop
++0+50f8 <[^>]*> nop
++0+50fc <[^>]*> nop
++0+5100 <[^>]*> nop
++0+5104 <[^>]*> nop
++0+5108 <[^>]*> nop
++0+510c <[^>]*> nop
++0+5110 <[^>]*> nop
++0+5114 <[^>]*> nop
++0+5118 <[^>]*> nop
++0+511c <[^>]*> nop
++0+5120 <[^>]*> nop
++0+5124 <[^>]*> nop
++0+5128 <[^>]*> nop
++0+512c <[^>]*> nop
++0+5130 <[^>]*> nop
++0+5134 <[^>]*> nop
++0+5138 <[^>]*> nop
++0+513c <[^>]*> nop
++0+5140 <[^>]*> nop
++0+5144 <[^>]*> nop
++0+5148 <[^>]*> nop
++0+514c <[^>]*> nop
++0+5150 <[^>]*> nop
++0+5154 <[^>]*> nop
++0+5158 <[^>]*> nop
++0+515c <[^>]*> nop
++0+5160 <[^>]*> nop
++0+5164 <[^>]*> nop
++0+5168 <[^>]*> nop
++0+516c <[^>]*> nop
++0+5170 <[^>]*> nop
++0+5174 <[^>]*> nop
++0+5178 <[^>]*> nop
++0+517c <[^>]*> nop
++0+5180 <[^>]*> nop
++0+5184 <[^>]*> nop
++0+5188 <[^>]*> nop
++0+518c <[^>]*> nop
++0+5190 <[^>]*> nop
++0+5194 <[^>]*> nop
++0+5198 <[^>]*> nop
++0+519c <[^>]*> nop
++0+51a0 <[^>]*> nop
++0+51a4 <[^>]*> nop
++0+51a8 <[^>]*> nop
++0+51ac <[^>]*> nop
++0+51b0 <[^>]*> nop
++0+51b4 <[^>]*> nop
++0+51b8 <[^>]*> nop
++0+51bc <[^>]*> nop
++0+51c0 <[^>]*> nop
++0+51c4 <[^>]*> nop
++0+51c8 <[^>]*> nop
++0+51cc <[^>]*> nop
++0+51d0 <[^>]*> nop
++0+51d4 <[^>]*> nop
++0+51d8 <[^>]*> nop
++0+51dc <[^>]*> nop
++0+51e0 <[^>]*> nop
++0+51e4 <[^>]*> nop
++0+51e8 <[^>]*> nop
++0+51ec <[^>]*> nop
++0+51f0 <[^>]*> nop
++0+51f4 <[^>]*> nop
++0+51f8 <[^>]*> nop
++0+51fc <[^>]*> nop
++0+5200 <[^>]*> nop
++0+5204 <[^>]*> nop
++0+5208 <[^>]*> nop
++0+520c <[^>]*> nop
++0+5210 <[^>]*> nop
++0+5214 <[^>]*> nop
++0+5218 <[^>]*> nop
++0+521c <[^>]*> nop
++0+5220 <[^>]*> nop
++0+5224 <[^>]*> nop
++0+5228 <[^>]*> nop
++0+522c <[^>]*> nop
++0+5230 <[^>]*> nop
++0+5234 <[^>]*> nop
++0+5238 <[^>]*> nop
++0+523c <[^>]*> nop
++0+5240 <[^>]*> nop
++0+5244 <[^>]*> nop
++0+5248 <[^>]*> nop
++0+524c <[^>]*> nop
++0+5250 <[^>]*> nop
++0+5254 <[^>]*> nop
++0+5258 <[^>]*> nop
++0+525c <[^>]*> nop
++0+5260 <[^>]*> nop
++0+5264 <[^>]*> nop
++0+5268 <[^>]*> nop
++0+526c <[^>]*> nop
++0+5270 <[^>]*> nop
++0+5274 <[^>]*> nop
++0+5278 <[^>]*> nop
++0+527c <[^>]*> nop
++0+5280 <[^>]*> nop
++0+5284 <[^>]*> nop
++0+5288 <[^>]*> nop
++0+528c <[^>]*> nop
++0+5290 <[^>]*> nop
++0+5294 <[^>]*> nop
++0+5298 <[^>]*> nop
++0+529c <[^>]*> nop
++0+52a0 <[^>]*> nop
++0+52a4 <[^>]*> nop
++0+52a8 <[^>]*> nop
++0+52ac <[^>]*> nop
++0+52b0 <[^>]*> nop
++0+52b4 <[^>]*> nop
++0+52b8 <[^>]*> nop
++0+52bc <[^>]*> nop
++0+52c0 <[^>]*> nop
++0+52c4 <[^>]*> nop
++0+52c8 <[^>]*> nop
++0+52cc <[^>]*> nop
++0+52d0 <[^>]*> nop
++0+52d4 <[^>]*> nop
++0+52d8 <[^>]*> nop
++0+52dc <[^>]*> nop
++0+52e0 <[^>]*> nop
++0+52e4 <[^>]*> nop
++0+52e8 <[^>]*> nop
++0+52ec <[^>]*> nop
++0+52f0 <[^>]*> nop
++0+52f4 <[^>]*> nop
++0+52f8 <[^>]*> nop
++0+52fc <[^>]*> nop
++0+5300 <[^>]*> nop
++0+5304 <[^>]*> nop
++0+5308 <[^>]*> nop
++0+530c <[^>]*> nop
++0+5310 <[^>]*> nop
++0+5314 <[^>]*> nop
++0+5318 <[^>]*> nop
++0+531c <[^>]*> nop
++0+5320 <[^>]*> nop
++0+5324 <[^>]*> nop
++0+5328 <[^>]*> nop
++0+532c <[^>]*> nop
++0+5330 <[^>]*> nop
++0+5334 <[^>]*> nop
++0+5338 <[^>]*> nop
++0+533c <[^>]*> nop
++0+5340 <[^>]*> nop
++0+5344 <[^>]*> nop
++0+5348 <[^>]*> nop
++0+534c <[^>]*> nop
++0+5350 <[^>]*> nop
++0+5354 <[^>]*> nop
++0+5358 <[^>]*> nop
++0+535c <[^>]*> nop
++0+5360 <[^>]*> nop
++0+5364 <[^>]*> nop
++0+5368 <[^>]*> nop
++0+536c <[^>]*> nop
++0+5370 <[^>]*> nop
++0+5374 <[^>]*> nop
++0+5378 <[^>]*> nop
++0+537c <[^>]*> nop
++0+5380 <[^>]*> nop
++0+5384 <[^>]*> nop
++0+5388 <[^>]*> nop
++0+538c <[^>]*> nop
++0+5390 <[^>]*> nop
++0+5394 <[^>]*> nop
++0+5398 <[^>]*> nop
++0+539c <[^>]*> nop
++0+53a0 <[^>]*> nop
++0+53a4 <[^>]*> nop
++0+53a8 <[^>]*> nop
++0+53ac <[^>]*> nop
++0+53b0 <[^>]*> nop
++0+53b4 <[^>]*> nop
++0+53b8 <[^>]*> nop
++0+53bc <[^>]*> nop
++0+53c0 <[^>]*> nop
++0+53c4 <[^>]*> nop
++0+53c8 <[^>]*> nop
++0+53cc <[^>]*> nop
++0+53d0 <[^>]*> nop
++0+53d4 <[^>]*> nop
++0+53d8 <[^>]*> nop
++0+53dc <[^>]*> nop
++0+53e0 <[^>]*> nop
++0+53e4 <[^>]*> nop
++0+53e8 <[^>]*> nop
++0+53ec <[^>]*> nop
++0+53f0 <[^>]*> nop
++0+53f4 <[^>]*> nop
++0+53f8 <[^>]*> nop
++0+53fc <[^>]*> nop
++0+5400 <[^>]*> nop
++0+5404 <[^>]*> nop
++0+5408 <[^>]*> nop
++0+540c <[^>]*> nop
++0+5410 <[^>]*> nop
++0+5414 <[^>]*> nop
++0+5418 <[^>]*> nop
++0+541c <[^>]*> nop
++0+5420 <[^>]*> nop
++0+5424 <[^>]*> nop
++0+5428 <[^>]*> nop
++0+542c <[^>]*> nop
++0+5430 <[^>]*> nop
++0+5434 <[^>]*> nop
++0+5438 <[^>]*> nop
++0+543c <[^>]*> nop
++0+5440 <[^>]*> nop
++0+5444 <[^>]*> nop
++0+5448 <[^>]*> nop
++0+544c <[^>]*> nop
++0+5450 <[^>]*> nop
++0+5454 <[^>]*> nop
++0+5458 <[^>]*> nop
++0+545c <[^>]*> nop
++0+5460 <[^>]*> nop
++0+5464 <[^>]*> nop
++0+5468 <[^>]*> nop
++0+546c <[^>]*> nop
++0+5470 <[^>]*> nop
++0+5474 <[^>]*> nop
++0+5478 <[^>]*> nop
++0+547c <[^>]*> nop
++0+5480 <[^>]*> nop
++0+5484 <[^>]*> nop
++0+5488 <[^>]*> nop
++0+548c <[^>]*> nop
++0+5490 <[^>]*> nop
++0+5494 <[^>]*> nop
++0+5498 <[^>]*> nop
++0+549c <[^>]*> nop
++0+54a0 <[^>]*> nop
++0+54a4 <[^>]*> nop
++0+54a8 <[^>]*> nop
++0+54ac <[^>]*> nop
++0+54b0 <[^>]*> nop
++0+54b4 <[^>]*> nop
++0+54b8 <[^>]*> nop
++0+54bc <[^>]*> nop
++0+54c0 <[^>]*> nop
++0+54c4 <[^>]*> nop
++0+54c8 <[^>]*> nop
++0+54cc <[^>]*> nop
++0+54d0 <[^>]*> nop
++0+54d4 <[^>]*> nop
++0+54d8 <[^>]*> nop
++0+54dc <[^>]*> nop
++0+54e0 <[^>]*> nop
++0+54e4 <[^>]*> nop
++0+54e8 <[^>]*> nop
++0+54ec <[^>]*> nop
++0+54f0 <[^>]*> nop
++0+54f4 <[^>]*> nop
++0+54f8 <[^>]*> nop
++0+54fc <[^>]*> nop
++0+5500 <[^>]*> nop
++0+5504 <[^>]*> nop
++0+5508 <[^>]*> nop
++0+550c <[^>]*> nop
++0+5510 <[^>]*> nop
++0+5514 <[^>]*> nop
++0+5518 <[^>]*> nop
++0+551c <[^>]*> nop
++0+5520 <[^>]*> nop
++0+5524 <[^>]*> nop
++0+5528 <[^>]*> nop
++0+552c <[^>]*> nop
++0+5530 <[^>]*> nop
++0+5534 <[^>]*> nop
++0+5538 <[^>]*> nop
++0+553c <[^>]*> nop
++0+5540 <[^>]*> nop
++0+5544 <[^>]*> nop
++0+5548 <[^>]*> nop
++0+554c <[^>]*> nop
++0+5550 <[^>]*> nop
++0+5554 <[^>]*> nop
++0+5558 <[^>]*> nop
++0+555c <[^>]*> nop
++0+5560 <[^>]*> nop
++0+5564 <[^>]*> nop
++0+5568 <[^>]*> nop
++0+556c <[^>]*> nop
++0+5570 <[^>]*> nop
++0+5574 <[^>]*> nop
++0+5578 <[^>]*> nop
++0+557c <[^>]*> nop
++0+5580 <[^>]*> nop
++0+5584 <[^>]*> nop
++0+5588 <[^>]*> nop
++0+558c <[^>]*> nop
++0+5590 <[^>]*> nop
++0+5594 <[^>]*> nop
++0+5598 <[^>]*> nop
++0+559c <[^>]*> nop
++0+55a0 <[^>]*> nop
++0+55a4 <[^>]*> nop
++0+55a8 <[^>]*> nop
++0+55ac <[^>]*> nop
++0+55b0 <[^>]*> nop
++0+55b4 <[^>]*> nop
++0+55b8 <[^>]*> nop
++0+55bc <[^>]*> nop
++0+55c0 <[^>]*> nop
++0+55c4 <[^>]*> nop
++0+55c8 <[^>]*> nop
++0+55cc <[^>]*> nop
++0+55d0 <[^>]*> nop
++0+55d4 <[^>]*> nop
++0+55d8 <[^>]*> nop
++0+55dc <[^>]*> nop
++0+55e0 <[^>]*> nop
++0+55e4 <[^>]*> nop
++0+55e8 <[^>]*> nop
++0+55ec <[^>]*> nop
++0+55f0 <[^>]*> nop
++0+55f4 <[^>]*> nop
++0+55f8 <[^>]*> nop
++0+55fc <[^>]*> nop
++0+5600 <[^>]*> nop
++0+5604 <[^>]*> nop
++0+5608 <[^>]*> nop
++0+560c <[^>]*> nop
++0+5610 <[^>]*> nop
++0+5614 <[^>]*> nop
++0+5618 <[^>]*> nop
++0+561c <[^>]*> nop
++0+5620 <[^>]*> nop
++0+5624 <[^>]*> nop
++0+5628 <[^>]*> nop
++0+562c <[^>]*> nop
++0+5630 <[^>]*> nop
++0+5634 <[^>]*> nop
++0+5638 <[^>]*> nop
++0+563c <[^>]*> nop
++0+5640 <[^>]*> nop
++0+5644 <[^>]*> nop
++0+5648 <[^>]*> nop
++0+564c <[^>]*> nop
++0+5650 <[^>]*> nop
++0+5654 <[^>]*> nop
++0+5658 <[^>]*> nop
++0+565c <[^>]*> nop
++0+5660 <[^>]*> nop
++0+5664 <[^>]*> nop
++0+5668 <[^>]*> nop
++0+566c <[^>]*> nop
++0+5670 <[^>]*> nop
++0+5674 <[^>]*> nop
++0+5678 <[^>]*> nop
++0+567c <[^>]*> nop
++0+5680 <[^>]*> nop
++0+5684 <[^>]*> nop
++0+5688 <[^>]*> nop
++0+568c <[^>]*> nop
++0+5690 <[^>]*> nop
++0+5694 <[^>]*> nop
++0+5698 <[^>]*> nop
++0+569c <[^>]*> nop
++0+56a0 <[^>]*> nop
++0+56a4 <[^>]*> nop
++0+56a8 <[^>]*> nop
++0+56ac <[^>]*> nop
++0+56b0 <[^>]*> nop
++0+56b4 <[^>]*> nop
++0+56b8 <[^>]*> nop
++0+56bc <[^>]*> nop
++0+56c0 <[^>]*> nop
++0+56c4 <[^>]*> nop
++0+56c8 <[^>]*> nop
++0+56cc <[^>]*> nop
++0+56d0 <[^>]*> nop
++0+56d4 <[^>]*> nop
++0+56d8 <[^>]*> nop
++0+56dc <[^>]*> nop
++0+56e0 <[^>]*> nop
++0+56e4 <[^>]*> nop
++0+56e8 <[^>]*> nop
++0+56ec <[^>]*> nop
++0+56f0 <[^>]*> nop
++0+56f4 <[^>]*> nop
++0+56f8 <[^>]*> nop
++0+56fc <[^>]*> nop
++0+5700 <[^>]*> nop
++0+5704 <[^>]*> nop
++0+5708 <[^>]*> nop
++0+570c <[^>]*> nop
++0+5710 <[^>]*> nop
++0+5714 <[^>]*> nop
++0+5718 <[^>]*> nop
++0+571c <[^>]*> nop
++0+5720 <[^>]*> nop
++0+5724 <[^>]*> nop
++0+5728 <[^>]*> nop
++0+572c <[^>]*> nop
++0+5730 <[^>]*> nop
++0+5734 <[^>]*> nop
++0+5738 <[^>]*> nop
++0+573c <[^>]*> nop
++0+5740 <[^>]*> nop
++0+5744 <[^>]*> nop
++0+5748 <[^>]*> nop
++0+574c <[^>]*> nop
++0+5750 <[^>]*> nop
++0+5754 <[^>]*> nop
++0+5758 <[^>]*> nop
++0+575c <[^>]*> nop
++0+5760 <[^>]*> nop
++0+5764 <[^>]*> nop
++0+5768 <[^>]*> nop
++0+576c <[^>]*> nop
++0+5770 <[^>]*> nop
++0+5774 <[^>]*> nop
++0+5778 <[^>]*> nop
++0+577c <[^>]*> nop
++0+5780 <[^>]*> nop
++0+5784 <[^>]*> nop
++0+5788 <[^>]*> nop
++0+578c <[^>]*> nop
++0+5790 <[^>]*> nop
++0+5794 <[^>]*> nop
++0+5798 <[^>]*> nop
++0+579c <[^>]*> nop
++0+57a0 <[^>]*> nop
++0+57a4 <[^>]*> nop
++0+57a8 <[^>]*> nop
++0+57ac <[^>]*> nop
++0+57b0 <[^>]*> nop
++0+57b4 <[^>]*> nop
++0+57b8 <[^>]*> nop
++0+57bc <[^>]*> nop
++0+57c0 <[^>]*> nop
++0+57c4 <[^>]*> nop
++0+57c8 <[^>]*> nop
++0+57cc <[^>]*> nop
++0+57d0 <[^>]*> nop
++0+57d4 <[^>]*> nop
++0+57d8 <[^>]*> nop
++0+57dc <[^>]*> nop
++0+57e0 <[^>]*> nop
++0+57e4 <[^>]*> nop
++0+57e8 <[^>]*> nop
++0+57ec <[^>]*> nop
++0+57f0 <[^>]*> nop
++0+57f4 <[^>]*> nop
++0+57f8 <[^>]*> nop
++0+57fc <[^>]*> nop
++0+5800 <[^>]*> nop
++0+5804 <[^>]*> nop
++0+5808 <[^>]*> nop
++0+580c <[^>]*> nop
++0+5810 <[^>]*> nop
++0+5814 <[^>]*> nop
++0+5818 <[^>]*> nop
++0+581c <[^>]*> nop
++0+5820 <[^>]*> nop
++0+5824 <[^>]*> nop
++0+5828 <[^>]*> nop
++0+582c <[^>]*> nop
++0+5830 <[^>]*> nop
++0+5834 <[^>]*> nop
++0+5838 <[^>]*> nop
++0+583c <[^>]*> nop
++0+5840 <[^>]*> nop
++0+5844 <[^>]*> nop
++0+5848 <[^>]*> nop
++0+584c <[^>]*> nop
++0+5850 <[^>]*> nop
++0+5854 <[^>]*> nop
++0+5858 <[^>]*> nop
++0+585c <[^>]*> nop
++0+5860 <[^>]*> nop
++0+5864 <[^>]*> nop
++0+5868 <[^>]*> nop
++0+586c <[^>]*> nop
++0+5870 <[^>]*> nop
++0+5874 <[^>]*> nop
++0+5878 <[^>]*> nop
++0+587c <[^>]*> nop
++0+5880 <[^>]*> nop
++0+5884 <[^>]*> nop
++0+5888 <[^>]*> nop
++0+588c <[^>]*> nop
++0+5890 <[^>]*> nop
++0+5894 <[^>]*> nop
++0+5898 <[^>]*> nop
++0+589c <[^>]*> nop
++0+58a0 <[^>]*> nop
++0+58a4 <[^>]*> nop
++0+58a8 <[^>]*> nop
++0+58ac <[^>]*> nop
++0+58b0 <[^>]*> nop
++0+58b4 <[^>]*> nop
++0+58b8 <[^>]*> nop
++0+58bc <[^>]*> nop
++0+58c0 <[^>]*> nop
++0+58c4 <[^>]*> nop
++0+58c8 <[^>]*> nop
++0+58cc <[^>]*> nop
++0+58d0 <[^>]*> nop
++0+58d4 <[^>]*> nop
++0+58d8 <[^>]*> nop
++0+58dc <[^>]*> nop
++0+58e0 <[^>]*> nop
++0+58e4 <[^>]*> nop
++0+58e8 <[^>]*> nop
++0+58ec <[^>]*> nop
++0+58f0 <[^>]*> nop
++0+58f4 <[^>]*> nop
++0+58f8 <[^>]*> nop
++0+58fc <[^>]*> nop
++0+5900 <[^>]*> nop
++0+5904 <[^>]*> nop
++0+5908 <[^>]*> nop
++0+590c <[^>]*> nop
++0+5910 <[^>]*> nop
++0+5914 <[^>]*> nop
++0+5918 <[^>]*> nop
++0+591c <[^>]*> nop
++0+5920 <[^>]*> nop
++0+5924 <[^>]*> nop
++0+5928 <[^>]*> nop
++0+592c <[^>]*> nop
++0+5930 <[^>]*> nop
++0+5934 <[^>]*> nop
++0+5938 <[^>]*> nop
++0+593c <[^>]*> nop
++0+5940 <[^>]*> nop
++0+5944 <[^>]*> nop
++0+5948 <[^>]*> nop
++0+594c <[^>]*> nop
++0+5950 <[^>]*> nop
++0+5954 <[^>]*> nop
++0+5958 <[^>]*> nop
++0+595c <[^>]*> nop
++0+5960 <[^>]*> nop
++0+5964 <[^>]*> nop
++0+5968 <[^>]*> nop
++0+596c <[^>]*> nop
++0+5970 <[^>]*> nop
++0+5974 <[^>]*> nop
++0+5978 <[^>]*> nop
++0+597c <[^>]*> nop
++0+5980 <[^>]*> nop
++0+5984 <[^>]*> nop
++0+5988 <[^>]*> nop
++0+598c <[^>]*> nop
++0+5990 <[^>]*> nop
++0+5994 <[^>]*> nop
++0+5998 <[^>]*> nop
++0+599c <[^>]*> nop
++0+59a0 <[^>]*> nop
++0+59a4 <[^>]*> nop
++0+59a8 <[^>]*> nop
++0+59ac <[^>]*> nop
++0+59b0 <[^>]*> nop
++0+59b4 <[^>]*> nop
++0+59b8 <[^>]*> nop
++0+59bc <[^>]*> nop
++0+59c0 <[^>]*> nop
++0+59c4 <[^>]*> nop
++0+59c8 <[^>]*> nop
++0+59cc <[^>]*> nop
++0+59d0 <[^>]*> nop
++0+59d4 <[^>]*> nop
++0+59d8 <[^>]*> nop
++0+59dc <[^>]*> nop
++0+59e0 <[^>]*> nop
++0+59e4 <[^>]*> nop
++0+59e8 <[^>]*> nop
++0+59ec <[^>]*> nop
++0+59f0 <[^>]*> nop
++0+59f4 <[^>]*> nop
++0+59f8 <[^>]*> nop
++0+59fc <[^>]*> nop
++0+5a00 <[^>]*> nop
++0+5a04 <[^>]*> nop
++0+5a08 <[^>]*> nop
++0+5a0c <[^>]*> nop
++0+5a10 <[^>]*> nop
++0+5a14 <[^>]*> nop
++0+5a18 <[^>]*> nop
++0+5a1c <[^>]*> nop
++0+5a20 <[^>]*> nop
++0+5a24 <[^>]*> nop
++0+5a28 <[^>]*> nop
++0+5a2c <[^>]*> nop
++0+5a30 <[^>]*> nop
++0+5a34 <[^>]*> nop
++0+5a38 <[^>]*> nop
++0+5a3c <[^>]*> nop
++0+5a40 <[^>]*> nop
++0+5a44 <[^>]*> nop
++0+5a48 <[^>]*> nop
++0+5a4c <[^>]*> nop
++0+5a50 <[^>]*> nop
++0+5a54 <[^>]*> nop
++0+5a58 <[^>]*> nop
++0+5a5c <[^>]*> nop
++0+5a60 <[^>]*> nop
++0+5a64 <[^>]*> nop
++0+5a68 <[^>]*> nop
++0+5a6c <[^>]*> nop
++0+5a70 <[^>]*> nop
++0+5a74 <[^>]*> nop
++0+5a78 <[^>]*> nop
++0+5a7c <[^>]*> nop
++0+5a80 <[^>]*> nop
++0+5a84 <[^>]*> nop
++0+5a88 <[^>]*> nop
++0+5a8c <[^>]*> nop
++0+5a90 <[^>]*> nop
++0+5a94 <[^>]*> nop
++0+5a98 <[^>]*> nop
++0+5a9c <[^>]*> nop
++0+5aa0 <[^>]*> nop
++0+5aa4 <[^>]*> nop
++0+5aa8 <[^>]*> nop
++0+5aac <[^>]*> nop
++0+5ab0 <[^>]*> nop
++0+5ab4 <[^>]*> nop
++0+5ab8 <[^>]*> nop
++0+5abc <[^>]*> nop
++0+5ac0 <[^>]*> nop
++0+5ac4 <[^>]*> nop
++0+5ac8 <[^>]*> nop
++0+5acc <[^>]*> nop
++0+5ad0 <[^>]*> nop
++0+5ad4 <[^>]*> nop
++0+5ad8 <[^>]*> nop
++0+5adc <[^>]*> nop
++0+5ae0 <[^>]*> nop
++0+5ae4 <[^>]*> nop
++0+5ae8 <[^>]*> nop
++0+5aec <[^>]*> nop
++0+5af0 <[^>]*> nop
++0+5af4 <[^>]*> nop
++0+5af8 <[^>]*> nop
++0+5afc <[^>]*> nop
++0+5b00 <[^>]*> nop
++0+5b04 <[^>]*> nop
++0+5b08 <[^>]*> nop
++0+5b0c <[^>]*> nop
++0+5b10 <[^>]*> nop
++0+5b14 <[^>]*> nop
++0+5b18 <[^>]*> nop
++0+5b1c <[^>]*> nop
++0+5b20 <[^>]*> nop
++0+5b24 <[^>]*> nop
++0+5b28 <[^>]*> nop
++0+5b2c <[^>]*> nop
++0+5b30 <[^>]*> nop
++0+5b34 <[^>]*> nop
++0+5b38 <[^>]*> nop
++0+5b3c <[^>]*> nop
++0+5b40 <[^>]*> nop
++0+5b44 <[^>]*> nop
++0+5b48 <[^>]*> nop
++0+5b4c <[^>]*> nop
++0+5b50 <[^>]*> nop
++0+5b54 <[^>]*> nop
++0+5b58 <[^>]*> nop
++0+5b5c <[^>]*> nop
++0+5b60 <[^>]*> nop
++0+5b64 <[^>]*> nop
++0+5b68 <[^>]*> nop
++0+5b6c <[^>]*> nop
++0+5b70 <[^>]*> nop
++0+5b74 <[^>]*> nop
++0+5b78 <[^>]*> nop
++0+5b7c <[^>]*> nop
++0+5b80 <[^>]*> nop
++0+5b84 <[^>]*> nop
++0+5b88 <[^>]*> nop
++0+5b8c <[^>]*> nop
++0+5b90 <[^>]*> nop
++0+5b94 <[^>]*> nop
++0+5b98 <[^>]*> nop
++0+5b9c <[^>]*> nop
++0+5ba0 <[^>]*> nop
++0+5ba4 <[^>]*> nop
++0+5ba8 <[^>]*> nop
++0+5bac <[^>]*> nop
++0+5bb0 <[^>]*> nop
++0+5bb4 <[^>]*> nop
++0+5bb8 <[^>]*> nop
++0+5bbc <[^>]*> nop
++0+5bc0 <[^>]*> nop
++0+5bc4 <[^>]*> nop
++0+5bc8 <[^>]*> nop
++0+5bcc <[^>]*> nop
++0+5bd0 <[^>]*> nop
++0+5bd4 <[^>]*> nop
++0+5bd8 <[^>]*> nop
++0+5bdc <[^>]*> nop
++0+5be0 <[^>]*> nop
++0+5be4 <[^>]*> nop
++0+5be8 <[^>]*> nop
++0+5bec <[^>]*> nop
++0+5bf0 <[^>]*> nop
++0+5bf4 <[^>]*> nop
++0+5bf8 <[^>]*> nop
++0+5bfc <[^>]*> nop
++0+5c00 <[^>]*> nop
++0+5c04 <[^>]*> nop
++0+5c08 <[^>]*> nop
++0+5c0c <[^>]*> nop
++0+5c10 <[^>]*> nop
++0+5c14 <[^>]*> nop
++0+5c18 <[^>]*> nop
++0+5c1c <[^>]*> nop
++0+5c20 <[^>]*> nop
++0+5c24 <[^>]*> nop
++0+5c28 <[^>]*> nop
++0+5c2c <[^>]*> nop
++0+5c30 <[^>]*> nop
++0+5c34 <[^>]*> nop
++0+5c38 <[^>]*> nop
++0+5c3c <[^>]*> nop
++0+5c40 <[^>]*> nop
++0+5c44 <[^>]*> nop
++0+5c48 <[^>]*> nop
++0+5c4c <[^>]*> nop
++0+5c50 <[^>]*> nop
++0+5c54 <[^>]*> nop
++0+5c58 <[^>]*> nop
++0+5c5c <[^>]*> nop
++0+5c60 <[^>]*> nop
++0+5c64 <[^>]*> nop
++0+5c68 <[^>]*> nop
++0+5c6c <[^>]*> nop
++0+5c70 <[^>]*> nop
++0+5c74 <[^>]*> nop
++0+5c78 <[^>]*> nop
++0+5c7c <[^>]*> nop
++0+5c80 <[^>]*> nop
++0+5c84 <[^>]*> nop
++0+5c88 <[^>]*> nop
++0+5c8c <[^>]*> nop
++0+5c90 <[^>]*> nop
++0+5c94 <[^>]*> nop
++0+5c98 <[^>]*> nop
++0+5c9c <[^>]*> nop
++0+5ca0 <[^>]*> nop
++0+5ca4 <[^>]*> nop
++0+5ca8 <[^>]*> nop
++0+5cac <[^>]*> nop
++0+5cb0 <[^>]*> nop
++0+5cb4 <[^>]*> nop
++0+5cb8 <[^>]*> nop
++0+5cbc <[^>]*> nop
++0+5cc0 <[^>]*> nop
++0+5cc4 <[^>]*> nop
++0+5cc8 <[^>]*> nop
++0+5ccc <[^>]*> nop
++0+5cd0 <[^>]*> nop
++0+5cd4 <[^>]*> nop
++0+5cd8 <[^>]*> nop
++0+5cdc <[^>]*> nop
++0+5ce0 <[^>]*> nop
++0+5ce4 <[^>]*> nop
++0+5ce8 <[^>]*> nop
++0+5cec <[^>]*> nop
++0+5cf0 <[^>]*> nop
++0+5cf4 <[^>]*> nop
++0+5cf8 <[^>]*> nop
++0+5cfc <[^>]*> nop
++0+5d00 <[^>]*> nop
++0+5d04 <[^>]*> nop
++0+5d08 <[^>]*> nop
++0+5d0c <[^>]*> nop
++0+5d10 <[^>]*> nop
++0+5d14 <[^>]*> nop
++0+5d18 <[^>]*> nop
++0+5d1c <[^>]*> nop
++0+5d20 <[^>]*> nop
++0+5d24 <[^>]*> nop
++0+5d28 <[^>]*> nop
++0+5d2c <[^>]*> nop
++0+5d30 <[^>]*> nop
++0+5d34 <[^>]*> nop
++0+5d38 <[^>]*> nop
++0+5d3c <[^>]*> nop
++0+5d40 <[^>]*> nop
++0+5d44 <[^>]*> nop
++0+5d48 <[^>]*> nop
++0+5d4c <[^>]*> nop
++0+5d50 <[^>]*> nop
++0+5d54 <[^>]*> nop
++0+5d58 <[^>]*> nop
++0+5d5c <[^>]*> nop
++0+5d60 <[^>]*> nop
++0+5d64 <[^>]*> nop
++0+5d68 <[^>]*> nop
++0+5d6c <[^>]*> nop
++0+5d70 <[^>]*> nop
++0+5d74 <[^>]*> nop
++0+5d78 <[^>]*> nop
++0+5d7c <[^>]*> nop
++0+5d80 <[^>]*> nop
++0+5d84 <[^>]*> nop
++0+5d88 <[^>]*> nop
++0+5d8c <[^>]*> nop
++0+5d90 <[^>]*> nop
++0+5d94 <[^>]*> nop
++0+5d98 <[^>]*> nop
++0+5d9c <[^>]*> nop
++0+5da0 <[^>]*> nop
++0+5da4 <[^>]*> nop
++0+5da8 <[^>]*> nop
++0+5dac <[^>]*> nop
++0+5db0 <[^>]*> nop
++0+5db4 <[^>]*> nop
++0+5db8 <[^>]*> nop
++0+5dbc <[^>]*> nop
++0+5dc0 <[^>]*> nop
++0+5dc4 <[^>]*> nop
++0+5dc8 <[^>]*> nop
++0+5dcc <[^>]*> nop
++0+5dd0 <[^>]*> nop
++0+5dd4 <[^>]*> nop
++0+5dd8 <[^>]*> nop
++0+5ddc <[^>]*> nop
++0+5de0 <[^>]*> nop
++0+5de4 <[^>]*> nop
++0+5de8 <[^>]*> nop
++0+5dec <[^>]*> nop
++0+5df0 <[^>]*> nop
++0+5df4 <[^>]*> nop
++0+5df8 <[^>]*> nop
++0+5dfc <[^>]*> nop
++0+5e00 <[^>]*> nop
++0+5e04 <[^>]*> nop
++0+5e08 <[^>]*> nop
++0+5e0c <[^>]*> nop
++0+5e10 <[^>]*> nop
++0+5e14 <[^>]*> nop
++0+5e18 <[^>]*> nop
++0+5e1c <[^>]*> nop
++0+5e20 <[^>]*> nop
++0+5e24 <[^>]*> nop
++0+5e28 <[^>]*> nop
++0+5e2c <[^>]*> nop
++0+5e30 <[^>]*> nop
++0+5e34 <[^>]*> nop
++0+5e38 <[^>]*> nop
++0+5e3c <[^>]*> nop
++0+5e40 <[^>]*> nop
++0+5e44 <[^>]*> nop
++0+5e48 <[^>]*> nop
++0+5e4c <[^>]*> nop
++0+5e50 <[^>]*> nop
++0+5e54 <[^>]*> nop
++0+5e58 <[^>]*> nop
++0+5e5c <[^>]*> nop
++0+5e60 <[^>]*> nop
++0+5e64 <[^>]*> nop
++0+5e68 <[^>]*> nop
++0+5e6c <[^>]*> nop
++0+5e70 <[^>]*> nop
++0+5e74 <[^>]*> nop
++0+5e78 <[^>]*> nop
++0+5e7c <[^>]*> nop
++0+5e80 <[^>]*> nop
++0+5e84 <[^>]*> nop
++0+5e88 <[^>]*> nop
++0+5e8c <[^>]*> nop
++0+5e90 <[^>]*> nop
++0+5e94 <[^>]*> nop
++0+5e98 <[^>]*> nop
++0+5e9c <[^>]*> nop
++0+5ea0 <[^>]*> nop
++0+5ea4 <[^>]*> nop
++0+5ea8 <[^>]*> nop
++0+5eac <[^>]*> nop
++0+5eb0 <[^>]*> nop
++0+5eb4 <[^>]*> nop
++0+5eb8 <[^>]*> nop
++0+5ebc <[^>]*> nop
++0+5ec0 <[^>]*> nop
++0+5ec4 <[^>]*> nop
++0+5ec8 <[^>]*> nop
++0+5ecc <[^>]*> nop
++0+5ed0 <[^>]*> nop
++0+5ed4 <[^>]*> nop
++0+5ed8 <[^>]*> nop
++0+5edc <[^>]*> nop
++0+5ee0 <[^>]*> nop
++0+5ee4 <[^>]*> nop
++0+5ee8 <[^>]*> nop
++0+5eec <[^>]*> nop
++0+5ef0 <[^>]*> nop
++0+5ef4 <[^>]*> nop
++0+5ef8 <[^>]*> nop
++0+5efc <[^>]*> nop
++0+5f00 <[^>]*> nop
++0+5f04 <[^>]*> nop
++0+5f08 <[^>]*> nop
++0+5f0c <[^>]*> nop
++0+5f10 <[^>]*> nop
++0+5f14 <[^>]*> nop
++0+5f18 <[^>]*> nop
++0+5f1c <[^>]*> nop
++0+5f20 <[^>]*> nop
++0+5f24 <[^>]*> nop
++0+5f28 <[^>]*> nop
++0+5f2c <[^>]*> nop
++0+5f30 <[^>]*> nop
++0+5f34 <[^>]*> nop
++0+5f38 <[^>]*> nop
++0+5f3c <[^>]*> nop
++0+5f40 <[^>]*> nop
++0+5f44 <[^>]*> nop
++0+5f48 <[^>]*> nop
++0+5f4c <[^>]*> nop
++0+5f50 <[^>]*> nop
++0+5f54 <[^>]*> nop
++0+5f58 <[^>]*> nop
++0+5f5c <[^>]*> nop
++0+5f60 <[^>]*> nop
++0+5f64 <[^>]*> nop
++0+5f68 <[^>]*> nop
++0+5f6c <[^>]*> nop
++0+5f70 <[^>]*> nop
++0+5f74 <[^>]*> nop
++0+5f78 <[^>]*> nop
++0+5f7c <[^>]*> nop
++0+5f80 <[^>]*> nop
++0+5f84 <[^>]*> nop
++0+5f88 <[^>]*> nop
++0+5f8c <[^>]*> nop
++0+5f90 <[^>]*> nop
++0+5f94 <[^>]*> nop
++0+5f98 <[^>]*> nop
++0+5f9c <[^>]*> nop
++0+5fa0 <[^>]*> nop
++0+5fa4 <[^>]*> nop
++0+5fa8 <[^>]*> nop
++0+5fac <[^>]*> nop
++0+5fb0 <[^>]*> nop
++0+5fb4 <[^>]*> nop
++0+5fb8 <[^>]*> nop
++0+5fbc <[^>]*> nop
++0+5fc0 <[^>]*> nop
++0+5fc4 <[^>]*> nop
++0+5fc8 <[^>]*> nop
++0+5fcc <[^>]*> nop
++0+5fd0 <[^>]*> nop
++0+5fd4 <[^>]*> nop
++0+5fd8 <[^>]*> nop
++0+5fdc <[^>]*> nop
++0+5fe0 <[^>]*> nop
++0+5fe4 <[^>]*> nop
++0+5fe8 <[^>]*> nop
++0+5fec <[^>]*> nop
++0+5ff0 <[^>]*> nop
++0+5ff4 <[^>]*> nop
++0+5ff8 <[^>]*> nop
++0+5ffc <[^>]*> nop
++0+6000 <[^>]*> nop
++0+6004 <[^>]*> nop
++0+6008 <[^>]*> nop
++0+600c <[^>]*> nop
++0+6010 <[^>]*> nop
++0+6014 <[^>]*> nop
++0+6018 <[^>]*> nop
++0+601c <[^>]*> nop
++0+6020 <[^>]*> nop
++0+6024 <[^>]*> nop
++0+6028 <[^>]*> nop
++0+602c <[^>]*> nop
++0+6030 <[^>]*> nop
++0+6034 <[^>]*> nop
++0+6038 <[^>]*> nop
++0+603c <[^>]*> nop
++0+6040 <[^>]*> nop
++0+6044 <[^>]*> nop
++0+6048 <[^>]*> nop
++0+604c <[^>]*> nop
++0+6050 <[^>]*> nop
++0+6054 <[^>]*> nop
++0+6058 <[^>]*> nop
++0+605c <[^>]*> nop
++0+6060 <[^>]*> nop
++0+6064 <[^>]*> nop
++0+6068 <[^>]*> nop
++0+606c <[^>]*> nop
++0+6070 <[^>]*> nop
++0+6074 <[^>]*> nop
++0+6078 <[^>]*> nop
++0+607c <[^>]*> nop
++0+6080 <[^>]*> nop
++0+6084 <[^>]*> nop
++0+6088 <[^>]*> nop
++0+608c <[^>]*> nop
++0+6090 <[^>]*> nop
++0+6094 <[^>]*> nop
++0+6098 <[^>]*> nop
++0+609c <[^>]*> nop
++0+60a0 <[^>]*> nop
++0+60a4 <[^>]*> nop
++0+60a8 <[^>]*> nop
++0+60ac <[^>]*> nop
++0+60b0 <[^>]*> nop
++0+60b4 <[^>]*> nop
++0+60b8 <[^>]*> nop
++0+60bc <[^>]*> nop
++0+60c0 <[^>]*> nop
++0+60c4 <[^>]*> nop
++0+60c8 <[^>]*> nop
++0+60cc <[^>]*> nop
++0+60d0 <[^>]*> nop
++0+60d4 <[^>]*> nop
++0+60d8 <[^>]*> nop
++0+60dc <[^>]*> nop
++0+60e0 <[^>]*> nop
++0+60e4 <[^>]*> nop
++0+60e8 <[^>]*> nop
++0+60ec <[^>]*> nop
++0+60f0 <[^>]*> nop
++0+60f4 <[^>]*> nop
++0+60f8 <[^>]*> nop
++0+60fc <[^>]*> nop
++0+6100 <[^>]*> nop
++0+6104 <[^>]*> nop
++0+6108 <[^>]*> nop
++0+610c <[^>]*> nop
++0+6110 <[^>]*> nop
++0+6114 <[^>]*> nop
++0+6118 <[^>]*> nop
++0+611c <[^>]*> nop
++0+6120 <[^>]*> nop
++0+6124 <[^>]*> nop
++0+6128 <[^>]*> nop
++0+612c <[^>]*> nop
++0+6130 <[^>]*> nop
++0+6134 <[^>]*> nop
++0+6138 <[^>]*> nop
++0+613c <[^>]*> nop
++0+6140 <[^>]*> nop
++0+6144 <[^>]*> nop
++0+6148 <[^>]*> nop
++0+614c <[^>]*> nop
++0+6150 <[^>]*> nop
++0+6154 <[^>]*> nop
++0+6158 <[^>]*> nop
++0+615c <[^>]*> nop
++0+6160 <[^>]*> nop
++0+6164 <[^>]*> nop
++0+6168 <[^>]*> nop
++0+616c <[^>]*> nop
++0+6170 <[^>]*> nop
++0+6174 <[^>]*> nop
++0+6178 <[^>]*> nop
++0+617c <[^>]*> nop
++0+6180 <[^>]*> nop
++0+6184 <[^>]*> nop
++0+6188 <[^>]*> nop
++0+618c <[^>]*> nop
++0+6190 <[^>]*> nop
++0+6194 <[^>]*> nop
++0+6198 <[^>]*> nop
++0+619c <[^>]*> nop
++0+61a0 <[^>]*> nop
++0+61a4 <[^>]*> nop
++0+61a8 <[^>]*> nop
++0+61ac <[^>]*> nop
++0+61b0 <[^>]*> nop
++0+61b4 <[^>]*> nop
++0+61b8 <[^>]*> nop
++0+61bc <[^>]*> nop
++0+61c0 <[^>]*> nop
++0+61c4 <[^>]*> nop
++0+61c8 <[^>]*> nop
++0+61cc <[^>]*> nop
++0+61d0 <[^>]*> nop
++0+61d4 <[^>]*> nop
++0+61d8 <[^>]*> nop
++0+61dc <[^>]*> nop
++0+61e0 <[^>]*> nop
++0+61e4 <[^>]*> nop
++0+61e8 <[^>]*> nop
++0+61ec <[^>]*> nop
++0+61f0 <[^>]*> nop
++0+61f4 <[^>]*> nop
++0+61f8 <[^>]*> nop
++0+61fc <[^>]*> nop
++0+6200 <[^>]*> nop
++0+6204 <[^>]*> nop
++0+6208 <[^>]*> nop
++0+620c <[^>]*> nop
++0+6210 <[^>]*> nop
++0+6214 <[^>]*> nop
++0+6218 <[^>]*> nop
++0+621c <[^>]*> nop
++0+6220 <[^>]*> nop
++0+6224 <[^>]*> nop
++0+6228 <[^>]*> nop
++0+622c <[^>]*> nop
++0+6230 <[^>]*> nop
++0+6234 <[^>]*> nop
++0+6238 <[^>]*> nop
++0+623c <[^>]*> nop
++0+6240 <[^>]*> nop
++0+6244 <[^>]*> nop
++0+6248 <[^>]*> nop
++0+624c <[^>]*> nop
++0+6250 <[^>]*> nop
++0+6254 <[^>]*> nop
++0+6258 <[^>]*> nop
++0+625c <[^>]*> nop
++0+6260 <[^>]*> nop
++0+6264 <[^>]*> nop
++0+6268 <[^>]*> nop
++0+626c <[^>]*> nop
++0+6270 <[^>]*> nop
++0+6274 <[^>]*> nop
++0+6278 <[^>]*> nop
++0+627c <[^>]*> nop
++0+6280 <[^>]*> nop
++0+6284 <[^>]*> nop
++0+6288 <[^>]*> nop
++0+628c <[^>]*> nop
++0+6290 <[^>]*> nop
++0+6294 <[^>]*> nop
++0+6298 <[^>]*> nop
++0+629c <[^>]*> nop
++0+62a0 <[^>]*> nop
++0+62a4 <[^>]*> nop
++0+62a8 <[^>]*> nop
++0+62ac <[^>]*> nop
++0+62b0 <[^>]*> nop
++0+62b4 <[^>]*> nop
++0+62b8 <[^>]*> nop
++0+62bc <[^>]*> nop
++0+62c0 <[^>]*> nop
++0+62c4 <[^>]*> nop
++0+62c8 <[^>]*> nop
++0+62cc <[^>]*> nop
++0+62d0 <[^>]*> nop
++0+62d4 <[^>]*> nop
++0+62d8 <[^>]*> nop
++0+62dc <[^>]*> nop
++0+62e0 <[^>]*> nop
++0+62e4 <[^>]*> nop
++0+62e8 <[^>]*> nop
++0+62ec <[^>]*> nop
++0+62f0 <[^>]*> nop
++0+62f4 <[^>]*> nop
++0+62f8 <[^>]*> nop
++0+62fc <[^>]*> nop
++0+6300 <[^>]*> nop
++0+6304 <[^>]*> nop
++0+6308 <[^>]*> nop
++0+630c <[^>]*> nop
++0+6310 <[^>]*> nop
++0+6314 <[^>]*> nop
++0+6318 <[^>]*> nop
++0+631c <[^>]*> nop
++0+6320 <[^>]*> nop
++0+6324 <[^>]*> nop
++0+6328 <[^>]*> nop
++0+632c <[^>]*> nop
++0+6330 <[^>]*> nop
++0+6334 <[^>]*> nop
++0+6338 <[^>]*> nop
++0+633c <[^>]*> nop
++0+6340 <[^>]*> nop
++0+6344 <[^>]*> nop
++0+6348 <[^>]*> nop
++0+634c <[^>]*> nop
++0+6350 <[^>]*> nop
++0+6354 <[^>]*> nop
++0+6358 <[^>]*> nop
++0+635c <[^>]*> nop
++0+6360 <[^>]*> nop
++0+6364 <[^>]*> nop
++0+6368 <[^>]*> nop
++0+636c <[^>]*> nop
++0+6370 <[^>]*> nop
++0+6374 <[^>]*> nop
++0+6378 <[^>]*> nop
++0+637c <[^>]*> nop
++0+6380 <[^>]*> nop
++0+6384 <[^>]*> nop
++0+6388 <[^>]*> nop
++0+638c <[^>]*> nop
++0+6390 <[^>]*> nop
++0+6394 <[^>]*> nop
++0+6398 <[^>]*> nop
++0+639c <[^>]*> nop
++0+63a0 <[^>]*> nop
++0+63a4 <[^>]*> nop
++0+63a8 <[^>]*> nop
++0+63ac <[^>]*> nop
++0+63b0 <[^>]*> nop
++0+63b4 <[^>]*> nop
++0+63b8 <[^>]*> nop
++0+63bc <[^>]*> nop
++0+63c0 <[^>]*> nop
++0+63c4 <[^>]*> nop
++0+63c8 <[^>]*> nop
++0+63cc <[^>]*> nop
++0+63d0 <[^>]*> nop
++0+63d4 <[^>]*> nop
++0+63d8 <[^>]*> nop
++0+63dc <[^>]*> nop
++0+63e0 <[^>]*> nop
++0+63e4 <[^>]*> nop
++0+63e8 <[^>]*> nop
++0+63ec <[^>]*> nop
++0+63f0 <[^>]*> nop
++0+63f4 <[^>]*> nop
++0+63f8 <[^>]*> nop
++0+63fc <[^>]*> nop
++0+6400 <[^>]*> nop
++0+6404 <[^>]*> nop
++0+6408 <[^>]*> nop
++0+640c <[^>]*> nop
++0+6410 <[^>]*> nop
++0+6414 <[^>]*> nop
++0+6418 <[^>]*> nop
++0+641c <[^>]*> nop
++0+6420 <[^>]*> nop
++0+6424 <[^>]*> nop
++0+6428 <[^>]*> nop
++0+642c <[^>]*> nop
++0+6430 <[^>]*> nop
++0+6434 <[^>]*> nop
++0+6438 <[^>]*> nop
++0+643c <[^>]*> nop
++0+6440 <[^>]*> nop
++0+6444 <[^>]*> nop
++0+6448 <[^>]*> nop
++0+644c <[^>]*> nop
++0+6450 <[^>]*> nop
++0+6454 <[^>]*> nop
++0+6458 <[^>]*> nop
++0+645c <[^>]*> nop
++0+6460 <[^>]*> nop
++0+6464 <[^>]*> nop
++0+6468 <[^>]*> nop
++0+646c <[^>]*> nop
++0+6470 <[^>]*> nop
++0+6474 <[^>]*> nop
++0+6478 <[^>]*> nop
++0+647c <[^>]*> nop
++0+6480 <[^>]*> nop
++0+6484 <[^>]*> nop
++0+6488 <[^>]*> nop
++0+648c <[^>]*> nop
++0+6490 <[^>]*> nop
++0+6494 <[^>]*> nop
++0+6498 <[^>]*> nop
++0+649c <[^>]*> nop
++0+64a0 <[^>]*> nop
++0+64a4 <[^>]*> nop
++0+64a8 <[^>]*> nop
++0+64ac <[^>]*> nop
++0+64b0 <[^>]*> nop
++0+64b4 <[^>]*> nop
++0+64b8 <[^>]*> nop
++0+64bc <[^>]*> nop
++0+64c0 <[^>]*> nop
++0+64c4 <[^>]*> nop
++0+64c8 <[^>]*> nop
++0+64cc <[^>]*> nop
++0+64d0 <[^>]*> nop
++0+64d4 <[^>]*> nop
++0+64d8 <[^>]*> nop
++0+64dc <[^>]*> nop
++0+64e0 <[^>]*> nop
++0+64e4 <[^>]*> nop
++0+64e8 <[^>]*> nop
++0+64ec <[^>]*> nop
++0+64f0 <[^>]*> nop
++0+64f4 <[^>]*> nop
++0+64f8 <[^>]*> nop
++0+64fc <[^>]*> nop
++0+6500 <[^>]*> nop
++0+6504 <[^>]*> nop
++0+6508 <[^>]*> nop
++0+650c <[^>]*> nop
++0+6510 <[^>]*> nop
++0+6514 <[^>]*> nop
++0+6518 <[^>]*> nop
++0+651c <[^>]*> nop
++0+6520 <[^>]*> nop
++0+6524 <[^>]*> nop
++0+6528 <[^>]*> nop
++0+652c <[^>]*> nop
++0+6530 <[^>]*> nop
++0+6534 <[^>]*> nop
++0+6538 <[^>]*> nop
++0+653c <[^>]*> nop
++0+6540 <[^>]*> nop
++0+6544 <[^>]*> nop
++0+6548 <[^>]*> nop
++0+654c <[^>]*> nop
++0+6550 <[^>]*> nop
++0+6554 <[^>]*> nop
++0+6558 <[^>]*> nop
++0+655c <[^>]*> nop
++0+6560 <[^>]*> nop
++0+6564 <[^>]*> nop
++0+6568 <[^>]*> nop
++0+656c <[^>]*> nop
++0+6570 <[^>]*> nop
++0+6574 <[^>]*> nop
++0+6578 <[^>]*> nop
++0+657c <[^>]*> nop
++0+6580 <[^>]*> nop
++0+6584 <[^>]*> nop
++0+6588 <[^>]*> nop
++0+658c <[^>]*> nop
++0+6590 <[^>]*> nop
++0+6594 <[^>]*> nop
++0+6598 <[^>]*> nop
++0+659c <[^>]*> nop
++0+65a0 <[^>]*> nop
++0+65a4 <[^>]*> nop
++0+65a8 <[^>]*> nop
++0+65ac <[^>]*> nop
++0+65b0 <[^>]*> nop
++0+65b4 <[^>]*> nop
++0+65b8 <[^>]*> nop
++0+65bc <[^>]*> nop
++0+65c0 <[^>]*> nop
++0+65c4 <[^>]*> nop
++0+65c8 <[^>]*> nop
++0+65cc <[^>]*> nop
++0+65d0 <[^>]*> nop
++0+65d4 <[^>]*> nop
++0+65d8 <[^>]*> nop
++0+65dc <[^>]*> nop
++0+65e0 <[^>]*> nop
++0+65e4 <[^>]*> nop
++0+65e8 <[^>]*> nop
++0+65ec <[^>]*> nop
++0+65f0 <[^>]*> nop
++0+65f4 <[^>]*> nop
++0+65f8 <[^>]*> nop
++0+65fc <[^>]*> nop
++0+6600 <[^>]*> nop
++0+6604 <[^>]*> nop
++0+6608 <[^>]*> nop
++0+660c <[^>]*> nop
++0+6610 <[^>]*> nop
++0+6614 <[^>]*> nop
++0+6618 <[^>]*> nop
++0+661c <[^>]*> nop
++0+6620 <[^>]*> nop
++0+6624 <[^>]*> nop
++0+6628 <[^>]*> nop
++0+662c <[^>]*> nop
++0+6630 <[^>]*> nop
++0+6634 <[^>]*> nop
++0+6638 <[^>]*> nop
++0+663c <[^>]*> nop
++0+6640 <[^>]*> nop
++0+6644 <[^>]*> nop
++0+6648 <[^>]*> nop
++0+664c <[^>]*> nop
++0+6650 <[^>]*> nop
++0+6654 <[^>]*> nop
++0+6658 <[^>]*> nop
++0+665c <[^>]*> nop
++0+6660 <[^>]*> nop
++0+6664 <[^>]*> nop
++0+6668 <[^>]*> nop
++0+666c <[^>]*> nop
++0+6670 <[^>]*> nop
++0+6674 <[^>]*> nop
++0+6678 <[^>]*> nop
++0+667c <[^>]*> nop
++0+6680 <[^>]*> nop
++0+6684 <[^>]*> nop
++0+6688 <[^>]*> nop
++0+668c <[^>]*> nop
++0+6690 <[^>]*> nop
++0+6694 <[^>]*> nop
++0+6698 <[^>]*> nop
++0+669c <[^>]*> nop
++0+66a0 <[^>]*> nop
++0+66a4 <[^>]*> nop
++0+66a8 <[^>]*> nop
++0+66ac <[^>]*> nop
++0+66b0 <[^>]*> nop
++0+66b4 <[^>]*> nop
++0+66b8 <[^>]*> nop
++0+66bc <[^>]*> nop
++0+66c0 <[^>]*> nop
++0+66c4 <[^>]*> nop
++0+66c8 <[^>]*> nop
++0+66cc <[^>]*> nop
++0+66d0 <[^>]*> nop
++0+66d4 <[^>]*> nop
++0+66d8 <[^>]*> nop
++0+66dc <[^>]*> nop
++0+66e0 <[^>]*> nop
++0+66e4 <[^>]*> nop
++0+66e8 <[^>]*> nop
++0+66ec <[^>]*> nop
++0+66f0 <[^>]*> nop
++0+66f4 <[^>]*> nop
++0+66f8 <[^>]*> nop
++0+66fc <[^>]*> nop
++0+6700 <[^>]*> nop
++0+6704 <[^>]*> nop
++0+6708 <[^>]*> nop
++0+670c <[^>]*> nop
++0+6710 <[^>]*> nop
++0+6714 <[^>]*> nop
++0+6718 <[^>]*> nop
++0+671c <[^>]*> nop
++0+6720 <[^>]*> nop
++0+6724 <[^>]*> nop
++0+6728 <[^>]*> nop
++0+672c <[^>]*> nop
++0+6730 <[^>]*> nop
++0+6734 <[^>]*> nop
++0+6738 <[^>]*> nop
++0+673c <[^>]*> nop
++0+6740 <[^>]*> nop
++0+6744 <[^>]*> nop
++0+6748 <[^>]*> nop
++0+674c <[^>]*> nop
++0+6750 <[^>]*> nop
++0+6754 <[^>]*> nop
++0+6758 <[^>]*> nop
++0+675c <[^>]*> nop
++0+6760 <[^>]*> nop
++0+6764 <[^>]*> nop
++0+6768 <[^>]*> nop
++0+676c <[^>]*> nop
++0+6770 <[^>]*> nop
++0+6774 <[^>]*> nop
++0+6778 <[^>]*> nop
++0+677c <[^>]*> nop
++0+6780 <[^>]*> nop
++0+6784 <[^>]*> nop
++0+6788 <[^>]*> nop
++0+678c <[^>]*> nop
++0+6790 <[^>]*> nop
++0+6794 <[^>]*> nop
++0+6798 <[^>]*> nop
++0+679c <[^>]*> nop
++0+67a0 <[^>]*> nop
++0+67a4 <[^>]*> nop
++0+67a8 <[^>]*> nop
++0+67ac <[^>]*> nop
++0+67b0 <[^>]*> nop
++0+67b4 <[^>]*> nop
++0+67b8 <[^>]*> nop
++0+67bc <[^>]*> nop
++0+67c0 <[^>]*> nop
++0+67c4 <[^>]*> nop
++0+67c8 <[^>]*> nop
++0+67cc <[^>]*> nop
++0+67d0 <[^>]*> nop
++0+67d4 <[^>]*> nop
++0+67d8 <[^>]*> nop
++0+67dc <[^>]*> nop
++0+67e0 <[^>]*> nop
++0+67e4 <[^>]*> nop
++0+67e8 <[^>]*> nop
++0+67ec <[^>]*> nop
++0+67f0 <[^>]*> nop
++0+67f4 <[^>]*> nop
++0+67f8 <[^>]*> nop
++0+67fc <[^>]*> nop
++0+6800 <[^>]*> nop
++0+6804 <[^>]*> nop
++0+6808 <[^>]*> nop
++0+680c <[^>]*> nop
++0+6810 <[^>]*> nop
++0+6814 <[^>]*> nop
++0+6818 <[^>]*> nop
++0+681c <[^>]*> nop
++0+6820 <[^>]*> nop
++0+6824 <[^>]*> nop
++0+6828 <[^>]*> nop
++0+682c <[^>]*> nop
++0+6830 <[^>]*> nop
++0+6834 <[^>]*> nop
++0+6838 <[^>]*> nop
++0+683c <[^>]*> nop
++0+6840 <[^>]*> nop
++0+6844 <[^>]*> nop
++0+6848 <[^>]*> nop
++0+684c <[^>]*> nop
++0+6850 <[^>]*> nop
++0+6854 <[^>]*> nop
++0+6858 <[^>]*> nop
++0+685c <[^>]*> nop
++0+6860 <[^>]*> nop
++0+6864 <[^>]*> nop
++0+6868 <[^>]*> nop
++0+686c <[^>]*> nop
++0+6870 <[^>]*> nop
++0+6874 <[^>]*> nop
++0+6878 <[^>]*> nop
++0+687c <[^>]*> nop
++0+6880 <[^>]*> nop
++0+6884 <[^>]*> nop
++0+6888 <[^>]*> nop
++0+688c <[^>]*> nop
++0+6890 <[^>]*> nop
++0+6894 <[^>]*> nop
++0+6898 <[^>]*> nop
++0+689c <[^>]*> nop
++0+68a0 <[^>]*> nop
++0+68a4 <[^>]*> nop
++0+68a8 <[^>]*> nop
++0+68ac <[^>]*> nop
++0+68b0 <[^>]*> nop
++0+68b4 <[^>]*> nop
++0+68b8 <[^>]*> nop
++0+68bc <[^>]*> nop
++0+68c0 <[^>]*> nop
++0+68c4 <[^>]*> nop
++0+68c8 <[^>]*> nop
++0+68cc <[^>]*> nop
++0+68d0 <[^>]*> nop
++0+68d4 <[^>]*> nop
++0+68d8 <[^>]*> nop
++0+68dc <[^>]*> nop
++0+68e0 <[^>]*> nop
++0+68e4 <[^>]*> nop
++0+68e8 <[^>]*> nop
++0+68ec <[^>]*> nop
++0+68f0 <[^>]*> nop
++0+68f4 <[^>]*> nop
++0+68f8 <[^>]*> nop
++0+68fc <[^>]*> nop
++0+6900 <[^>]*> nop
++0+6904 <[^>]*> nop
++0+6908 <[^>]*> nop
++0+690c <[^>]*> nop
++0+6910 <[^>]*> nop
++0+6914 <[^>]*> nop
++0+6918 <[^>]*> nop
++0+691c <[^>]*> nop
++0+6920 <[^>]*> nop
++0+6924 <[^>]*> nop
++0+6928 <[^>]*> nop
++0+692c <[^>]*> nop
++0+6930 <[^>]*> nop
++0+6934 <[^>]*> nop
++0+6938 <[^>]*> nop
++0+693c <[^>]*> nop
++0+6940 <[^>]*> nop
++0+6944 <[^>]*> nop
++0+6948 <[^>]*> nop
++0+694c <[^>]*> nop
++0+6950 <[^>]*> nop
++0+6954 <[^>]*> nop
++0+6958 <[^>]*> nop
++0+695c <[^>]*> nop
++0+6960 <[^>]*> nop
++0+6964 <[^>]*> nop
++0+6968 <[^>]*> nop
++0+696c <[^>]*> nop
++0+6970 <[^>]*> nop
++0+6974 <[^>]*> nop
++0+6978 <[^>]*> nop
++0+697c <[^>]*> nop
++0+6980 <[^>]*> nop
++0+6984 <[^>]*> nop
++0+6988 <[^>]*> nop
++0+698c <[^>]*> nop
++0+6990 <[^>]*> nop
++0+6994 <[^>]*> nop
++0+6998 <[^>]*> nop
++0+699c <[^>]*> nop
++0+69a0 <[^>]*> nop
++0+69a4 <[^>]*> nop
++0+69a8 <[^>]*> nop
++0+69ac <[^>]*> nop
++0+69b0 <[^>]*> nop
++0+69b4 <[^>]*> nop
++0+69b8 <[^>]*> nop
++0+69bc <[^>]*> nop
++0+69c0 <[^>]*> nop
++0+69c4 <[^>]*> nop
++0+69c8 <[^>]*> nop
++0+69cc <[^>]*> nop
++0+69d0 <[^>]*> nop
++0+69d4 <[^>]*> nop
++0+69d8 <[^>]*> nop
++0+69dc <[^>]*> nop
++0+69e0 <[^>]*> nop
++0+69e4 <[^>]*> nop
++0+69e8 <[^>]*> nop
++0+69ec <[^>]*> nop
++0+69f0 <[^>]*> nop
++0+69f4 <[^>]*> nop
++0+69f8 <[^>]*> nop
++0+69fc <[^>]*> nop
++0+6a00 <[^>]*> nop
++0+6a04 <[^>]*> nop
++0+6a08 <[^>]*> nop
++0+6a0c <[^>]*> nop
++0+6a10 <[^>]*> nop
++0+6a14 <[^>]*> nop
++0+6a18 <[^>]*> nop
++0+6a1c <[^>]*> nop
++0+6a20 <[^>]*> nop
++0+6a24 <[^>]*> nop
++0+6a28 <[^>]*> nop
++0+6a2c <[^>]*> nop
++0+6a30 <[^>]*> nop
++0+6a34 <[^>]*> nop
++0+6a38 <[^>]*> nop
++0+6a3c <[^>]*> nop
++0+6a40 <[^>]*> nop
++0+6a44 <[^>]*> nop
++0+6a48 <[^>]*> nop
++0+6a4c <[^>]*> nop
++0+6a50 <[^>]*> nop
++0+6a54 <[^>]*> nop
++0+6a58 <[^>]*> nop
++0+6a5c <[^>]*> nop
++0+6a60 <[^>]*> nop
++0+6a64 <[^>]*> nop
++0+6a68 <[^>]*> nop
++0+6a6c <[^>]*> nop
++0+6a70 <[^>]*> nop
++0+6a74 <[^>]*> nop
++0+6a78 <[^>]*> nop
++0+6a7c <[^>]*> nop
++0+6a80 <[^>]*> nop
++0+6a84 <[^>]*> nop
++0+6a88 <[^>]*> nop
++0+6a8c <[^>]*> nop
++0+6a90 <[^>]*> nop
++0+6a94 <[^>]*> nop
++0+6a98 <[^>]*> nop
++0+6a9c <[^>]*> nop
++0+6aa0 <[^>]*> nop
++0+6aa4 <[^>]*> nop
++0+6aa8 <[^>]*> nop
++0+6aac <[^>]*> nop
++0+6ab0 <[^>]*> nop
++0+6ab4 <[^>]*> nop
++0+6ab8 <[^>]*> nop
++0+6abc <[^>]*> nop
++0+6ac0 <[^>]*> nop
++0+6ac4 <[^>]*> nop
++0+6ac8 <[^>]*> nop
++0+6acc <[^>]*> nop
++0+6ad0 <[^>]*> nop
++0+6ad4 <[^>]*> nop
++0+6ad8 <[^>]*> nop
++0+6adc <[^>]*> nop
++0+6ae0 <[^>]*> nop
++0+6ae4 <[^>]*> nop
++0+6ae8 <[^>]*> nop
++0+6aec <[^>]*> nop
++0+6af0 <[^>]*> nop
++0+6af4 <[^>]*> nop
++0+6af8 <[^>]*> nop
++0+6afc <[^>]*> nop
++0+6b00 <[^>]*> nop
++0+6b04 <[^>]*> nop
++0+6b08 <[^>]*> nop
++0+6b0c <[^>]*> nop
++0+6b10 <[^>]*> nop
++0+6b14 <[^>]*> nop
++0+6b18 <[^>]*> nop
++0+6b1c <[^>]*> nop
++0+6b20 <[^>]*> nop
++0+6b24 <[^>]*> nop
++0+6b28 <[^>]*> nop
++0+6b2c <[^>]*> nop
++0+6b30 <[^>]*> nop
++0+6b34 <[^>]*> nop
++0+6b38 <[^>]*> nop
++0+6b3c <[^>]*> nop
++0+6b40 <[^>]*> nop
++0+6b44 <[^>]*> nop
++0+6b48 <[^>]*> nop
++0+6b4c <[^>]*> nop
++0+6b50 <[^>]*> nop
++0+6b54 <[^>]*> nop
++0+6b58 <[^>]*> nop
++0+6b5c <[^>]*> nop
++0+6b60 <[^>]*> nop
++0+6b64 <[^>]*> nop
++0+6b68 <[^>]*> nop
++0+6b6c <[^>]*> nop
++0+6b70 <[^>]*> nop
++0+6b74 <[^>]*> nop
++0+6b78 <[^>]*> nop
++0+6b7c <[^>]*> nop
++0+6b80 <[^>]*> nop
++0+6b84 <[^>]*> nop
++0+6b88 <[^>]*> nop
++0+6b8c <[^>]*> nop
++0+6b90 <[^>]*> nop
++0+6b94 <[^>]*> nop
++0+6b98 <[^>]*> nop
++0+6b9c <[^>]*> nop
++0+6ba0 <[^>]*> nop
++0+6ba4 <[^>]*> nop
++0+6ba8 <[^>]*> nop
++0+6bac <[^>]*> nop
++0+6bb0 <[^>]*> nop
++0+6bb4 <[^>]*> nop
++0+6bb8 <[^>]*> nop
++0+6bbc <[^>]*> nop
++0+6bc0 <[^>]*> nop
++0+6bc4 <[^>]*> nop
++0+6bc8 <[^>]*> nop
++0+6bcc <[^>]*> nop
++0+6bd0 <[^>]*> nop
++0+6bd4 <[^>]*> nop
++0+6bd8 <[^>]*> nop
++0+6bdc <[^>]*> nop
++0+6be0 <[^>]*> nop
++0+6be4 <[^>]*> nop
++0+6be8 <[^>]*> nop
++0+6bec <[^>]*> nop
++0+6bf0 <[^>]*> nop
++0+6bf4 <[^>]*> nop
++0+6bf8 <[^>]*> nop
++0+6bfc <[^>]*> nop
++0+6c00 <[^>]*> nop
++0+6c04 <[^>]*> nop
++0+6c08 <[^>]*> nop
++0+6c0c <[^>]*> nop
++0+6c10 <[^>]*> nop
++0+6c14 <[^>]*> nop
++0+6c18 <[^>]*> nop
++0+6c1c <[^>]*> nop
++0+6c20 <[^>]*> nop
++0+6c24 <[^>]*> nop
++0+6c28 <[^>]*> nop
++0+6c2c <[^>]*> nop
++0+6c30 <[^>]*> nop
++0+6c34 <[^>]*> nop
++0+6c38 <[^>]*> nop
++0+6c3c <[^>]*> nop
++0+6c40 <[^>]*> nop
++0+6c44 <[^>]*> nop
++0+6c48 <[^>]*> nop
++0+6c4c <[^>]*> nop
++0+6c50 <[^>]*> nop
++0+6c54 <[^>]*> nop
++0+6c58 <[^>]*> nop
++0+6c5c <[^>]*> nop
++0+6c60 <[^>]*> nop
++0+6c64 <[^>]*> nop
++0+6c68 <[^>]*> nop
++0+6c6c <[^>]*> nop
++0+6c70 <[^>]*> nop
++0+6c74 <[^>]*> nop
++0+6c78 <[^>]*> nop
++0+6c7c <[^>]*> nop
++0+6c80 <[^>]*> nop
++0+6c84 <[^>]*> nop
++0+6c88 <[^>]*> nop
++0+6c8c <[^>]*> nop
++0+6c90 <[^>]*> nop
++0+6c94 <[^>]*> nop
++0+6c98 <[^>]*> nop
++0+6c9c <[^>]*> nop
++0+6ca0 <[^>]*> nop
++0+6ca4 <[^>]*> nop
++0+6ca8 <[^>]*> nop
++0+6cac <[^>]*> nop
++0+6cb0 <[^>]*> nop
++0+6cb4 <[^>]*> nop
++0+6cb8 <[^>]*> nop
++0+6cbc <[^>]*> nop
++0+6cc0 <[^>]*> nop
++0+6cc4 <[^>]*> nop
++0+6cc8 <[^>]*> nop
++0+6ccc <[^>]*> nop
++0+6cd0 <[^>]*> nop
++0+6cd4 <[^>]*> nop
++0+6cd8 <[^>]*> nop
++0+6cdc <[^>]*> nop
++0+6ce0 <[^>]*> nop
++0+6ce4 <[^>]*> nop
++0+6ce8 <[^>]*> nop
++0+6cec <[^>]*> nop
++0+6cf0 <[^>]*> nop
++0+6cf4 <[^>]*> nop
++0+6cf8 <[^>]*> nop
++0+6cfc <[^>]*> nop
++0+6d00 <[^>]*> nop
++0+6d04 <[^>]*> nop
++0+6d08 <[^>]*> nop
++0+6d0c <[^>]*> nop
++0+6d10 <[^>]*> nop
++0+6d14 <[^>]*> nop
++0+6d18 <[^>]*> nop
++0+6d1c <[^>]*> nop
++0+6d20 <[^>]*> nop
++0+6d24 <[^>]*> nop
++0+6d28 <[^>]*> nop
++0+6d2c <[^>]*> nop
++0+6d30 <[^>]*> nop
++0+6d34 <[^>]*> nop
++0+6d38 <[^>]*> nop
++0+6d3c <[^>]*> nop
++0+6d40 <[^>]*> nop
++0+6d44 <[^>]*> nop
++0+6d48 <[^>]*> nop
++0+6d4c <[^>]*> nop
++0+6d50 <[^>]*> nop
++0+6d54 <[^>]*> nop
++0+6d58 <[^>]*> nop
++0+6d5c <[^>]*> nop
++0+6d60 <[^>]*> nop
++0+6d64 <[^>]*> nop
++0+6d68 <[^>]*> nop
++0+6d6c <[^>]*> nop
++0+6d70 <[^>]*> nop
++0+6d74 <[^>]*> nop
++0+6d78 <[^>]*> nop
++0+6d7c <[^>]*> nop
++0+6d80 <[^>]*> nop
++0+6d84 <[^>]*> nop
++0+6d88 <[^>]*> nop
++0+6d8c <[^>]*> nop
++0+6d90 <[^>]*> nop
++0+6d94 <[^>]*> nop
++0+6d98 <[^>]*> nop
++0+6d9c <[^>]*> nop
++0+6da0 <[^>]*> nop
++0+6da4 <[^>]*> nop
++0+6da8 <[^>]*> nop
++0+6dac <[^>]*> nop
++0+6db0 <[^>]*> nop
++0+6db4 <[^>]*> nop
++0+6db8 <[^>]*> nop
++0+6dbc <[^>]*> nop
++0+6dc0 <[^>]*> nop
++0+6dc4 <[^>]*> nop
++0+6dc8 <[^>]*> nop
++0+6dcc <[^>]*> nop
++0+6dd0 <[^>]*> nop
++0+6dd4 <[^>]*> nop
++0+6dd8 <[^>]*> nop
++0+6ddc <[^>]*> nop
++0+6de0 <[^>]*> nop
++0+6de4 <[^>]*> nop
++0+6de8 <[^>]*> nop
++0+6dec <[^>]*> nop
++0+6df0 <[^>]*> nop
++0+6df4 <[^>]*> nop
++0+6df8 <[^>]*> nop
++0+6dfc <[^>]*> nop
++0+6e00 <[^>]*> nop
++0+6e04 <[^>]*> nop
++0+6e08 <[^>]*> nop
++0+6e0c <[^>]*> nop
++0+6e10 <[^>]*> nop
++0+6e14 <[^>]*> nop
++0+6e18 <[^>]*> nop
++0+6e1c <[^>]*> nop
++0+6e20 <[^>]*> nop
++0+6e24 <[^>]*> nop
++0+6e28 <[^>]*> nop
++0+6e2c <[^>]*> nop
++0+6e30 <[^>]*> nop
++0+6e34 <[^>]*> nop
++0+6e38 <[^>]*> nop
++0+6e3c <[^>]*> nop
++0+6e40 <[^>]*> nop
++0+6e44 <[^>]*> nop
++0+6e48 <[^>]*> nop
++0+6e4c <[^>]*> nop
++0+6e50 <[^>]*> nop
++0+6e54 <[^>]*> nop
++0+6e58 <[^>]*> nop
++0+6e5c <[^>]*> nop
++0+6e60 <[^>]*> nop
++0+6e64 <[^>]*> nop
++0+6e68 <[^>]*> nop
++0+6e6c <[^>]*> nop
++0+6e70 <[^>]*> nop
++0+6e74 <[^>]*> nop
++0+6e78 <[^>]*> nop
++0+6e7c <[^>]*> nop
++0+6e80 <[^>]*> nop
++0+6e84 <[^>]*> nop
++0+6e88 <[^>]*> nop
++0+6e8c <[^>]*> nop
++0+6e90 <[^>]*> nop
++0+6e94 <[^>]*> nop
++0+6e98 <[^>]*> nop
++0+6e9c <[^>]*> nop
++0+6ea0 <[^>]*> nop
++0+6ea4 <[^>]*> nop
++0+6ea8 <[^>]*> nop
++0+6eac <[^>]*> nop
++0+6eb0 <[^>]*> nop
++0+6eb4 <[^>]*> nop
++0+6eb8 <[^>]*> nop
++0+6ebc <[^>]*> nop
++0+6ec0 <[^>]*> nop
++0+6ec4 <[^>]*> nop
++0+6ec8 <[^>]*> nop
++0+6ecc <[^>]*> nop
++0+6ed0 <[^>]*> nop
++0+6ed4 <[^>]*> nop
++0+6ed8 <[^>]*> nop
++0+6edc <[^>]*> nop
++0+6ee0 <[^>]*> nop
++0+6ee4 <[^>]*> nop
++0+6ee8 <[^>]*> nop
++0+6eec <[^>]*> nop
++0+6ef0 <[^>]*> nop
++0+6ef4 <[^>]*> nop
++0+6ef8 <[^>]*> nop
++0+6efc <[^>]*> nop
++0+6f00 <[^>]*> nop
++0+6f04 <[^>]*> nop
++0+6f08 <[^>]*> nop
++0+6f0c <[^>]*> nop
++0+6f10 <[^>]*> nop
++0+6f14 <[^>]*> nop
++0+6f18 <[^>]*> nop
++0+6f1c <[^>]*> nop
++0+6f20 <[^>]*> nop
++0+6f24 <[^>]*> nop
++0+6f28 <[^>]*> nop
++0+6f2c <[^>]*> nop
++0+6f30 <[^>]*> nop
++0+6f34 <[^>]*> nop
++0+6f38 <[^>]*> nop
++0+6f3c <[^>]*> nop
++0+6f40 <[^>]*> nop
++0+6f44 <[^>]*> nop
++0+6f48 <[^>]*> nop
++0+6f4c <[^>]*> nop
++0+6f50 <[^>]*> nop
++0+6f54 <[^>]*> nop
++0+6f58 <[^>]*> nop
++0+6f5c <[^>]*> nop
++0+6f60 <[^>]*> nop
++0+6f64 <[^>]*> nop
++0+6f68 <[^>]*> nop
++0+6f6c <[^>]*> nop
++0+6f70 <[^>]*> nop
++0+6f74 <[^>]*> nop
++0+6f78 <[^>]*> nop
++0+6f7c <[^>]*> nop
++0+6f80 <[^>]*> nop
++0+6f84 <[^>]*> nop
++0+6f88 <[^>]*> nop
++0+6f8c <[^>]*> nop
++0+6f90 <[^>]*> nop
++0+6f94 <[^>]*> nop
++0+6f98 <[^>]*> nop
++0+6f9c <[^>]*> nop
++0+6fa0 <[^>]*> nop
++0+6fa4 <[^>]*> nop
++0+6fa8 <[^>]*> nop
++0+6fac <[^>]*> nop
++0+6fb0 <[^>]*> nop
++0+6fb4 <[^>]*> nop
++0+6fb8 <[^>]*> nop
++0+6fbc <[^>]*> nop
++0+6fc0 <[^>]*> nop
++0+6fc4 <[^>]*> nop
++0+6fc8 <[^>]*> nop
++0+6fcc <[^>]*> nop
++0+6fd0 <[^>]*> nop
++0+6fd4 <[^>]*> nop
++0+6fd8 <[^>]*> nop
++0+6fdc <[^>]*> nop
++0+6fe0 <[^>]*> nop
++0+6fe4 <[^>]*> nop
++0+6fe8 <[^>]*> nop
++0+6fec <[^>]*> nop
++0+6ff0 <[^>]*> nop
++0+6ff4 <[^>]*> nop
++0+6ff8 <[^>]*> nop
++0+6ffc <[^>]*> nop
++0+7000 <[^>]*> nop
++0+7004 <[^>]*> nop
++0+7008 <[^>]*> nop
++0+700c <[^>]*> nop
++0+7010 <[^>]*> nop
++0+7014 <[^>]*> nop
++0+7018 <[^>]*> nop
++0+701c <[^>]*> nop
++0+7020 <[^>]*> nop
++0+7024 <[^>]*> nop
++0+7028 <[^>]*> nop
++0+702c <[^>]*> nop
++0+7030 <[^>]*> nop
++0+7034 <[^>]*> nop
++0+7038 <[^>]*> nop
++0+703c <[^>]*> nop
++0+7040 <[^>]*> nop
++0+7044 <[^>]*> nop
++0+7048 <[^>]*> nop
++0+704c <[^>]*> nop
++0+7050 <[^>]*> nop
++0+7054 <[^>]*> nop
++0+7058 <[^>]*> nop
++0+705c <[^>]*> nop
++0+7060 <[^>]*> nop
++0+7064 <[^>]*> nop
++0+7068 <[^>]*> nop
++0+706c <[^>]*> nop
++0+7070 <[^>]*> nop
++0+7074 <[^>]*> nop
++0+7078 <[^>]*> nop
++0+707c <[^>]*> nop
++0+7080 <[^>]*> nop
++0+7084 <[^>]*> nop
++0+7088 <[^>]*> nop
++0+708c <[^>]*> nop
++0+7090 <[^>]*> nop
++0+7094 <[^>]*> nop
++0+7098 <[^>]*> nop
++0+709c <[^>]*> nop
++0+70a0 <[^>]*> nop
++0+70a4 <[^>]*> nop
++0+70a8 <[^>]*> nop
++0+70ac <[^>]*> nop
++0+70b0 <[^>]*> nop
++0+70b4 <[^>]*> nop
++0+70b8 <[^>]*> nop
++0+70bc <[^>]*> nop
++0+70c0 <[^>]*> nop
++0+70c4 <[^>]*> nop
++0+70c8 <[^>]*> nop
++0+70cc <[^>]*> nop
++0+70d0 <[^>]*> nop
++0+70d4 <[^>]*> nop
++0+70d8 <[^>]*> nop
++0+70dc <[^>]*> nop
++0+70e0 <[^>]*> nop
++0+70e4 <[^>]*> nop
++0+70e8 <[^>]*> nop
++0+70ec <[^>]*> nop
++0+70f0 <[^>]*> nop
++0+70f4 <[^>]*> nop
++0+70f8 <[^>]*> nop
++0+70fc <[^>]*> nop
++0+7100 <[^>]*> nop
++0+7104 <[^>]*> nop
++0+7108 <[^>]*> nop
++0+710c <[^>]*> nop
++0+7110 <[^>]*> nop
++0+7114 <[^>]*> nop
++0+7118 <[^>]*> nop
++0+711c <[^>]*> nop
++0+7120 <[^>]*> nop
++0+7124 <[^>]*> nop
++0+7128 <[^>]*> nop
++0+712c <[^>]*> nop
++0+7130 <[^>]*> nop
++0+7134 <[^>]*> nop
++0+7138 <[^>]*> nop
++0+713c <[^>]*> nop
++0+7140 <[^>]*> nop
++0+7144 <[^>]*> nop
++0+7148 <[^>]*> nop
++0+714c <[^>]*> nop
++0+7150 <[^>]*> nop
++0+7154 <[^>]*> nop
++0+7158 <[^>]*> nop
++0+715c <[^>]*> nop
++0+7160 <[^>]*> nop
++0+7164 <[^>]*> nop
++0+7168 <[^>]*> nop
++0+716c <[^>]*> nop
++0+7170 <[^>]*> nop
++0+7174 <[^>]*> nop
++0+7178 <[^>]*> nop
++0+717c <[^>]*> nop
++0+7180 <[^>]*> nop
++0+7184 <[^>]*> nop
++0+7188 <[^>]*> nop
++0+718c <[^>]*> nop
++0+7190 <[^>]*> nop
++0+7194 <[^>]*> nop
++0+7198 <[^>]*> nop
++0+719c <[^>]*> nop
++0+71a0 <[^>]*> nop
++0+71a4 <[^>]*> nop
++0+71a8 <[^>]*> nop
++0+71ac <[^>]*> nop
++0+71b0 <[^>]*> nop
++0+71b4 <[^>]*> nop
++0+71b8 <[^>]*> nop
++0+71bc <[^>]*> nop
++0+71c0 <[^>]*> nop
++0+71c4 <[^>]*> nop
++0+71c8 <[^>]*> nop
++0+71cc <[^>]*> nop
++0+71d0 <[^>]*> nop
++0+71d4 <[^>]*> nop
++0+71d8 <[^>]*> nop
++0+71dc <[^>]*> nop
++0+71e0 <[^>]*> nop
++0+71e4 <[^>]*> nop
++0+71e8 <[^>]*> nop
++0+71ec <[^>]*> nop
++0+71f0 <[^>]*> nop
++0+71f4 <[^>]*> nop
++0+71f8 <[^>]*> nop
++0+71fc <[^>]*> nop
++0+7200 <[^>]*> nop
++0+7204 <[^>]*> nop
++0+7208 <[^>]*> nop
++0+720c <[^>]*> nop
++0+7210 <[^>]*> nop
++0+7214 <[^>]*> nop
++0+7218 <[^>]*> nop
++0+721c <[^>]*> nop
++0+7220 <[^>]*> nop
++0+7224 <[^>]*> nop
++0+7228 <[^>]*> nop
++0+722c <[^>]*> nop
++0+7230 <[^>]*> nop
++0+7234 <[^>]*> nop
++0+7238 <[^>]*> nop
++0+723c <[^>]*> nop
++0+7240 <[^>]*> nop
++0+7244 <[^>]*> nop
++0+7248 <[^>]*> nop
++0+724c <[^>]*> nop
++0+7250 <[^>]*> nop
++0+7254 <[^>]*> nop
++0+7258 <[^>]*> nop
++0+725c <[^>]*> nop
++0+7260 <[^>]*> nop
++0+7264 <[^>]*> nop
++0+7268 <[^>]*> nop
++0+726c <[^>]*> nop
++0+7270 <[^>]*> nop
++0+7274 <[^>]*> nop
++0+7278 <[^>]*> nop
++0+727c <[^>]*> nop
++0+7280 <[^>]*> nop
++0+7284 <[^>]*> nop
++0+7288 <[^>]*> nop
++0+728c <[^>]*> nop
++0+7290 <[^>]*> nop
++0+7294 <[^>]*> nop
++0+7298 <[^>]*> nop
++0+729c <[^>]*> nop
++0+72a0 <[^>]*> nop
++0+72a4 <[^>]*> nop
++0+72a8 <[^>]*> nop
++0+72ac <[^>]*> nop
++0+72b0 <[^>]*> nop
++0+72b4 <[^>]*> nop
++0+72b8 <[^>]*> nop
++0+72bc <[^>]*> nop
++0+72c0 <[^>]*> nop
++0+72c4 <[^>]*> nop
++0+72c8 <[^>]*> nop
++0+72cc <[^>]*> nop
++0+72d0 <[^>]*> nop
++0+72d4 <[^>]*> nop
++0+72d8 <[^>]*> nop
++0+72dc <[^>]*> nop
++0+72e0 <[^>]*> nop
++0+72e4 <[^>]*> nop
++0+72e8 <[^>]*> nop
++0+72ec <[^>]*> nop
++0+72f0 <[^>]*> nop
++0+72f4 <[^>]*> nop
++0+72f8 <[^>]*> nop
++0+72fc <[^>]*> nop
++0+7300 <[^>]*> nop
++0+7304 <[^>]*> nop
++0+7308 <[^>]*> nop
++0+730c <[^>]*> nop
++0+7310 <[^>]*> nop
++0+7314 <[^>]*> nop
++0+7318 <[^>]*> nop
++0+731c <[^>]*> nop
++0+7320 <[^>]*> nop
++0+7324 <[^>]*> nop
++0+7328 <[^>]*> nop
++0+732c <[^>]*> nop
++0+7330 <[^>]*> nop
++0+7334 <[^>]*> nop
++0+7338 <[^>]*> nop
++0+733c <[^>]*> nop
++0+7340 <[^>]*> nop
++0+7344 <[^>]*> nop
++0+7348 <[^>]*> nop
++0+734c <[^>]*> nop
++0+7350 <[^>]*> nop
++0+7354 <[^>]*> nop
++0+7358 <[^>]*> nop
++0+735c <[^>]*> nop
++0+7360 <[^>]*> nop
++0+7364 <[^>]*> nop
++0+7368 <[^>]*> nop
++0+736c <[^>]*> nop
++0+7370 <[^>]*> nop
++0+7374 <[^>]*> nop
++0+7378 <[^>]*> nop
++0+737c <[^>]*> nop
++0+7380 <[^>]*> nop
++0+7384 <[^>]*> nop
++0+7388 <[^>]*> nop
++0+738c <[^>]*> nop
++0+7390 <[^>]*> nop
++0+7394 <[^>]*> nop
++0+7398 <[^>]*> nop
++0+739c <[^>]*> nop
++0+73a0 <[^>]*> nop
++0+73a4 <[^>]*> nop
++0+73a8 <[^>]*> nop
++0+73ac <[^>]*> nop
++0+73b0 <[^>]*> nop
++0+73b4 <[^>]*> nop
++0+73b8 <[^>]*> nop
++0+73bc <[^>]*> nop
++0+73c0 <[^>]*> nop
++0+73c4 <[^>]*> nop
++0+73c8 <[^>]*> nop
++0+73cc <[^>]*> nop
++0+73d0 <[^>]*> nop
++0+73d4 <[^>]*> nop
++0+73d8 <[^>]*> nop
++0+73dc <[^>]*> nop
++0+73e0 <[^>]*> nop
++0+73e4 <[^>]*> nop
++0+73e8 <[^>]*> nop
++0+73ec <[^>]*> nop
++0+73f0 <[^>]*> nop
++0+73f4 <[^>]*> nop
++0+73f8 <[^>]*> nop
++0+73fc <[^>]*> nop
++0+7400 <[^>]*> nop
++0+7404 <[^>]*> nop
++0+7408 <[^>]*> nop
++0+740c <[^>]*> nop
++0+7410 <[^>]*> nop
++0+7414 <[^>]*> nop
++0+7418 <[^>]*> nop
++0+741c <[^>]*> nop
++0+7420 <[^>]*> nop
++0+7424 <[^>]*> nop
++0+7428 <[^>]*> nop
++0+742c <[^>]*> nop
++0+7430 <[^>]*> nop
++0+7434 <[^>]*> nop
++0+7438 <[^>]*> nop
++0+743c <[^>]*> nop
++0+7440 <[^>]*> nop
++0+7444 <[^>]*> nop
++0+7448 <[^>]*> nop
++0+744c <[^>]*> nop
++0+7450 <[^>]*> nop
++0+7454 <[^>]*> nop
++0+7458 <[^>]*> nop
++0+745c <[^>]*> nop
++0+7460 <[^>]*> nop
++0+7464 <[^>]*> nop
++0+7468 <[^>]*> nop
++0+746c <[^>]*> nop
++0+7470 <[^>]*> nop
++0+7474 <[^>]*> nop
++0+7478 <[^>]*> nop
++0+747c <[^>]*> nop
++0+7480 <[^>]*> nop
++0+7484 <[^>]*> nop
++0+7488 <[^>]*> nop
++0+748c <[^>]*> nop
++0+7490 <[^>]*> nop
++0+7494 <[^>]*> nop
++0+7498 <[^>]*> nop
++0+749c <[^>]*> nop
++0+74a0 <[^>]*> nop
++0+74a4 <[^>]*> nop
++0+74a8 <[^>]*> nop
++0+74ac <[^>]*> nop
++0+74b0 <[^>]*> nop
++0+74b4 <[^>]*> nop
++0+74b8 <[^>]*> nop
++0+74bc <[^>]*> nop
++0+74c0 <[^>]*> nop
++0+74c4 <[^>]*> nop
++0+74c8 <[^>]*> nop
++0+74cc <[^>]*> nop
++0+74d0 <[^>]*> nop
++0+74d4 <[^>]*> nop
++0+74d8 <[^>]*> nop
++0+74dc <[^>]*> nop
++0+74e0 <[^>]*> nop
++0+74e4 <[^>]*> nop
++0+74e8 <[^>]*> nop
++0+74ec <[^>]*> nop
++0+74f0 <[^>]*> nop
++0+74f4 <[^>]*> nop
++0+74f8 <[^>]*> nop
++0+74fc <[^>]*> nop
++0+7500 <[^>]*> nop
++0+7504 <[^>]*> nop
++0+7508 <[^>]*> nop
++0+750c <[^>]*> nop
++0+7510 <[^>]*> nop
++0+7514 <[^>]*> nop
++0+7518 <[^>]*> nop
++0+751c <[^>]*> nop
++0+7520 <[^>]*> nop
++0+7524 <[^>]*> nop
++0+7528 <[^>]*> nop
++0+752c <[^>]*> nop
++0+7530 <[^>]*> nop
++0+7534 <[^>]*> nop
++0+7538 <[^>]*> nop
++0+753c <[^>]*> nop
++0+7540 <[^>]*> nop
++0+7544 <[^>]*> nop
++0+7548 <[^>]*> nop
++0+754c <[^>]*> nop
++0+7550 <[^>]*> nop
++0+7554 <[^>]*> nop
++0+7558 <[^>]*> nop
++0+755c <[^>]*> nop
++0+7560 <[^>]*> nop
++0+7564 <[^>]*> nop
++0+7568 <[^>]*> nop
++0+756c <[^>]*> nop
++0+7570 <[^>]*> nop
++0+7574 <[^>]*> nop
++0+7578 <[^>]*> nop
++0+757c <[^>]*> nop
++0+7580 <[^>]*> nop
++0+7584 <[^>]*> nop
++0+7588 <[^>]*> nop
++0+758c <[^>]*> nop
++0+7590 <[^>]*> nop
++0+7594 <[^>]*> nop
++0+7598 <[^>]*> nop
++0+759c <[^>]*> nop
++0+75a0 <[^>]*> nop
++0+75a4 <[^>]*> nop
++0+75a8 <[^>]*> nop
++0+75ac <[^>]*> nop
++0+75b0 <[^>]*> nop
++0+75b4 <[^>]*> nop
++0+75b8 <[^>]*> nop
++0+75bc <[^>]*> nop
++0+75c0 <[^>]*> nop
++0+75c4 <[^>]*> nop
++0+75c8 <[^>]*> nop
++0+75cc <[^>]*> nop
++0+75d0 <[^>]*> nop
++0+75d4 <[^>]*> nop
++0+75d8 <[^>]*> nop
++0+75dc <[^>]*> nop
++0+75e0 <[^>]*> nop
++0+75e4 <[^>]*> nop
++0+75e8 <[^>]*> nop
++0+75ec <[^>]*> nop
++0+75f0 <[^>]*> nop
++0+75f4 <[^>]*> nop
++0+75f8 <[^>]*> nop
++0+75fc <[^>]*> nop
++0+7600 <[^>]*> nop
++0+7604 <[^>]*> nop
++0+7608 <[^>]*> nop
++0+760c <[^>]*> nop
++0+7610 <[^>]*> nop
++0+7614 <[^>]*> nop
++0+7618 <[^>]*> nop
++0+761c <[^>]*> nop
++0+7620 <[^>]*> nop
++0+7624 <[^>]*> nop
++0+7628 <[^>]*> nop
++0+762c <[^>]*> nop
++0+7630 <[^>]*> nop
++0+7634 <[^>]*> nop
++0+7638 <[^>]*> nop
++0+763c <[^>]*> nop
++0+7640 <[^>]*> nop
++0+7644 <[^>]*> nop
++0+7648 <[^>]*> nop
++0+764c <[^>]*> nop
++0+7650 <[^>]*> nop
++0+7654 <[^>]*> nop
++0+7658 <[^>]*> nop
++0+765c <[^>]*> nop
++0+7660 <[^>]*> nop
++0+7664 <[^>]*> nop
++0+7668 <[^>]*> nop
++0+766c <[^>]*> nop
++0+7670 <[^>]*> nop
++0+7674 <[^>]*> nop
++0+7678 <[^>]*> nop
++0+767c <[^>]*> nop
++0+7680 <[^>]*> nop
++0+7684 <[^>]*> nop
++0+7688 <[^>]*> nop
++0+768c <[^>]*> nop
++0+7690 <[^>]*> nop
++0+7694 <[^>]*> nop
++0+7698 <[^>]*> nop
++0+769c <[^>]*> nop
++0+76a0 <[^>]*> nop
++0+76a4 <[^>]*> nop
++0+76a8 <[^>]*> nop
++0+76ac <[^>]*> nop
++0+76b0 <[^>]*> nop
++0+76b4 <[^>]*> nop
++0+76b8 <[^>]*> nop
++0+76bc <[^>]*> nop
++0+76c0 <[^>]*> nop
++0+76c4 <[^>]*> nop
++0+76c8 <[^>]*> nop
++0+76cc <[^>]*> nop
++0+76d0 <[^>]*> nop
++0+76d4 <[^>]*> nop
++0+76d8 <[^>]*> nop
++0+76dc <[^>]*> nop
++0+76e0 <[^>]*> nop
++0+76e4 <[^>]*> nop
++0+76e8 <[^>]*> nop
++0+76ec <[^>]*> nop
++0+76f0 <[^>]*> nop
++0+76f4 <[^>]*> nop
++0+76f8 <[^>]*> nop
++0+76fc <[^>]*> nop
++0+7700 <[^>]*> nop
++0+7704 <[^>]*> nop
++0+7708 <[^>]*> nop
++0+770c <[^>]*> nop
++0+7710 <[^>]*> nop
++0+7714 <[^>]*> nop
++0+7718 <[^>]*> nop
++0+771c <[^>]*> nop
++0+7720 <[^>]*> nop
++0+7724 <[^>]*> nop
++0+7728 <[^>]*> nop
++0+772c <[^>]*> nop
++0+7730 <[^>]*> nop
++0+7734 <[^>]*> nop
++0+7738 <[^>]*> nop
++0+773c <[^>]*> nop
++0+7740 <[^>]*> nop
++0+7744 <[^>]*> nop
++0+7748 <[^>]*> nop
++0+774c <[^>]*> nop
++0+7750 <[^>]*> nop
++0+7754 <[^>]*> nop
++0+7758 <[^>]*> nop
++0+775c <[^>]*> nop
++0+7760 <[^>]*> nop
++0+7764 <[^>]*> nop
++0+7768 <[^>]*> nop
++0+776c <[^>]*> nop
++0+7770 <[^>]*> nop
++0+7774 <[^>]*> nop
++0+7778 <[^>]*> nop
++0+777c <[^>]*> nop
++0+7780 <[^>]*> nop
++0+7784 <[^>]*> nop
++0+7788 <[^>]*> nop
++0+778c <[^>]*> nop
++0+7790 <[^>]*> nop
++0+7794 <[^>]*> nop
++0+7798 <[^>]*> nop
++0+779c <[^>]*> nop
++0+77a0 <[^>]*> nop
++0+77a4 <[^>]*> nop
++0+77a8 <[^>]*> nop
++0+77ac <[^>]*> nop
++0+77b0 <[^>]*> nop
++0+77b4 <[^>]*> nop
++0+77b8 <[^>]*> nop
++0+77bc <[^>]*> nop
++0+77c0 <[^>]*> nop
++0+77c4 <[^>]*> nop
++0+77c8 <[^>]*> nop
++0+77cc <[^>]*> nop
++0+77d0 <[^>]*> nop
++0+77d4 <[^>]*> nop
++0+77d8 <[^>]*> nop
++0+77dc <[^>]*> nop
++0+77e0 <[^>]*> nop
++0+77e4 <[^>]*> nop
++0+77e8 <[^>]*> nop
++0+77ec <[^>]*> nop
++0+77f0 <[^>]*> nop
++0+77f4 <[^>]*> nop
++0+77f8 <[^>]*> nop
++0+77fc <[^>]*> nop
++0+7800 <[^>]*> nop
++0+7804 <[^>]*> nop
++0+7808 <[^>]*> nop
++0+780c <[^>]*> nop
++0+7810 <[^>]*> nop
++0+7814 <[^>]*> nop
++0+7818 <[^>]*> nop
++0+781c <[^>]*> nop
++0+7820 <[^>]*> nop
++0+7824 <[^>]*> nop
++0+7828 <[^>]*> nop
++0+782c <[^>]*> nop
++0+7830 <[^>]*> nop
++0+7834 <[^>]*> nop
++0+7838 <[^>]*> nop
++0+783c <[^>]*> nop
++0+7840 <[^>]*> nop
++0+7844 <[^>]*> nop
++0+7848 <[^>]*> nop
++0+784c <[^>]*> nop
++0+7850 <[^>]*> nop
++0+7854 <[^>]*> nop
++0+7858 <[^>]*> nop
++0+785c <[^>]*> nop
++0+7860 <[^>]*> nop
++0+7864 <[^>]*> nop
++0+7868 <[^>]*> nop
++0+786c <[^>]*> nop
++0+7870 <[^>]*> nop
++0+7874 <[^>]*> nop
++0+7878 <[^>]*> nop
++0+787c <[^>]*> nop
++0+7880 <[^>]*> nop
++0+7884 <[^>]*> nop
++0+7888 <[^>]*> nop
++0+788c <[^>]*> nop
++0+7890 <[^>]*> nop
++0+7894 <[^>]*> nop
++0+7898 <[^>]*> nop
++0+789c <[^>]*> nop
++0+78a0 <[^>]*> nop
++0+78a4 <[^>]*> nop
++0+78a8 <[^>]*> nop
++0+78ac <[^>]*> nop
++0+78b0 <[^>]*> nop
++0+78b4 <[^>]*> nop
++0+78b8 <[^>]*> nop
++0+78bc <[^>]*> nop
++0+78c0 <[^>]*> nop
++0+78c4 <[^>]*> nop
++0+78c8 <[^>]*> nop
++0+78cc <[^>]*> nop
++0+78d0 <[^>]*> nop
++0+78d4 <[^>]*> nop
++0+78d8 <[^>]*> nop
++0+78dc <[^>]*> nop
++0+78e0 <[^>]*> nop
++0+78e4 <[^>]*> nop
++0+78e8 <[^>]*> nop
++0+78ec <[^>]*> nop
++0+78f0 <[^>]*> nop
++0+78f4 <[^>]*> nop
++0+78f8 <[^>]*> nop
++0+78fc <[^>]*> nop
++0+7900 <[^>]*> nop
++0+7904 <[^>]*> nop
++0+7908 <[^>]*> nop
++0+790c <[^>]*> nop
++0+7910 <[^>]*> nop
++0+7914 <[^>]*> nop
++0+7918 <[^>]*> nop
++0+791c <[^>]*> nop
++0+7920 <[^>]*> nop
++0+7924 <[^>]*> nop
++0+7928 <[^>]*> nop
++0+792c <[^>]*> nop
++0+7930 <[^>]*> nop
++0+7934 <[^>]*> nop
++0+7938 <[^>]*> nop
++0+793c <[^>]*> nop
++0+7940 <[^>]*> nop
++0+7944 <[^>]*> nop
++0+7948 <[^>]*> nop
++0+794c <[^>]*> nop
++0+7950 <[^>]*> nop
++0+7954 <[^>]*> nop
++0+7958 <[^>]*> nop
++0+795c <[^>]*> nop
++0+7960 <[^>]*> nop
++0+7964 <[^>]*> nop
++0+7968 <[^>]*> nop
++0+796c <[^>]*> nop
++0+7970 <[^>]*> nop
++0+7974 <[^>]*> nop
++0+7978 <[^>]*> nop
++0+797c <[^>]*> nop
++0+7980 <[^>]*> nop
++0+7984 <[^>]*> nop
++0+7988 <[^>]*> nop
++0+798c <[^>]*> nop
++0+7990 <[^>]*> nop
++0+7994 <[^>]*> nop
++0+7998 <[^>]*> nop
++0+799c <[^>]*> nop
++0+79a0 <[^>]*> nop
++0+79a4 <[^>]*> nop
++0+79a8 <[^>]*> nop
++0+79ac <[^>]*> nop
++0+79b0 <[^>]*> nop
++0+79b4 <[^>]*> nop
++0+79b8 <[^>]*> nop
++0+79bc <[^>]*> nop
++0+79c0 <[^>]*> nop
++0+79c4 <[^>]*> nop
++0+79c8 <[^>]*> nop
++0+79cc <[^>]*> nop
++0+79d0 <[^>]*> nop
++0+79d4 <[^>]*> nop
++0+79d8 <[^>]*> nop
++0+79dc <[^>]*> nop
++0+79e0 <[^>]*> nop
++0+79e4 <[^>]*> nop
++0+79e8 <[^>]*> nop
++0+79ec <[^>]*> nop
++0+79f0 <[^>]*> nop
++0+79f4 <[^>]*> nop
++0+79f8 <[^>]*> nop
++0+79fc <[^>]*> nop
++0+7a00 <[^>]*> nop
++0+7a04 <[^>]*> nop
++0+7a08 <[^>]*> nop
++0+7a0c <[^>]*> nop
++0+7a10 <[^>]*> nop
++0+7a14 <[^>]*> nop
++0+7a18 <[^>]*> nop
++0+7a1c <[^>]*> nop
++0+7a20 <[^>]*> nop
++0+7a24 <[^>]*> nop
++0+7a28 <[^>]*> nop
++0+7a2c <[^>]*> nop
++0+7a30 <[^>]*> nop
++0+7a34 <[^>]*> nop
++0+7a38 <[^>]*> nop
++0+7a3c <[^>]*> nop
++0+7a40 <[^>]*> nop
++0+7a44 <[^>]*> nop
++0+7a48 <[^>]*> nop
++0+7a4c <[^>]*> nop
++0+7a50 <[^>]*> nop
++0+7a54 <[^>]*> nop
++0+7a58 <[^>]*> nop
++0+7a5c <[^>]*> nop
++0+7a60 <[^>]*> nop
++0+7a64 <[^>]*> nop
++0+7a68 <[^>]*> nop
++0+7a6c <[^>]*> nop
++0+7a70 <[^>]*> nop
++0+7a74 <[^>]*> nop
++0+7a78 <[^>]*> nop
++0+7a7c <[^>]*> nop
++0+7a80 <[^>]*> nop
++0+7a84 <[^>]*> nop
++0+7a88 <[^>]*> nop
++0+7a8c <[^>]*> nop
++0+7a90 <[^>]*> nop
++0+7a94 <[^>]*> nop
++0+7a98 <[^>]*> nop
++0+7a9c <[^>]*> nop
++0+7aa0 <[^>]*> nop
++0+7aa4 <[^>]*> nop
++0+7aa8 <[^>]*> nop
++0+7aac <[^>]*> nop
++0+7ab0 <[^>]*> nop
++0+7ab4 <[^>]*> nop
++0+7ab8 <[^>]*> nop
++0+7abc <[^>]*> nop
++0+7ac0 <[^>]*> nop
++0+7ac4 <[^>]*> nop
++0+7ac8 <[^>]*> nop
++0+7acc <[^>]*> nop
++0+7ad0 <[^>]*> nop
++0+7ad4 <[^>]*> nop
++0+7ad8 <[^>]*> nop
++0+7adc <[^>]*> nop
++0+7ae0 <[^>]*> nop
++0+7ae4 <[^>]*> nop
++0+7ae8 <[^>]*> nop
++0+7aec <[^>]*> nop
++0+7af0 <[^>]*> nop
++0+7af4 <[^>]*> nop
++0+7af8 <[^>]*> nop
++0+7afc <[^>]*> nop
++0+7b00 <[^>]*> nop
++0+7b04 <[^>]*> nop
++0+7b08 <[^>]*> nop
++0+7b0c <[^>]*> nop
++0+7b10 <[^>]*> nop
++0+7b14 <[^>]*> nop
++0+7b18 <[^>]*> nop
++0+7b1c <[^>]*> nop
++0+7b20 <[^>]*> nop
++0+7b24 <[^>]*> nop
++0+7b28 <[^>]*> nop
++0+7b2c <[^>]*> nop
++0+7b30 <[^>]*> nop
++0+7b34 <[^>]*> nop
++0+7b38 <[^>]*> nop
++0+7b3c <[^>]*> nop
++0+7b40 <[^>]*> nop
++0+7b44 <[^>]*> nop
++0+7b48 <[^>]*> nop
++0+7b4c <[^>]*> nop
++0+7b50 <[^>]*> nop
++0+7b54 <[^>]*> nop
++0+7b58 <[^>]*> nop
++0+7b5c <[^>]*> nop
++0+7b60 <[^>]*> nop
++0+7b64 <[^>]*> nop
++0+7b68 <[^>]*> nop
++0+7b6c <[^>]*> nop
++0+7b70 <[^>]*> nop
++0+7b74 <[^>]*> nop
++0+7b78 <[^>]*> nop
++0+7b7c <[^>]*> nop
++0+7b80 <[^>]*> nop
++0+7b84 <[^>]*> nop
++0+7b88 <[^>]*> nop
++0+7b8c <[^>]*> nop
++0+7b90 <[^>]*> nop
++0+7b94 <[^>]*> nop
++0+7b98 <[^>]*> nop
++0+7b9c <[^>]*> nop
++0+7ba0 <[^>]*> nop
++0+7ba4 <[^>]*> nop
++0+7ba8 <[^>]*> nop
++0+7bac <[^>]*> nop
++0+7bb0 <[^>]*> nop
++0+7bb4 <[^>]*> nop
++0+7bb8 <[^>]*> nop
++0+7bbc <[^>]*> nop
++0+7bc0 <[^>]*> nop
++0+7bc4 <[^>]*> nop
++0+7bc8 <[^>]*> nop
++0+7bcc <[^>]*> nop
++0+7bd0 <[^>]*> nop
++0+7bd4 <[^>]*> nop
++0+7bd8 <[^>]*> nop
++0+7bdc <[^>]*> nop
++0+7be0 <[^>]*> nop
++0+7be4 <[^>]*> nop
++0+7be8 <[^>]*> nop
++0+7bec <[^>]*> nop
++0+7bf0 <[^>]*> nop
++0+7bf4 <[^>]*> nop
++0+7bf8 <[^>]*> nop
++0+7bfc <[^>]*> nop
++0+7c00 <[^>]*> nop
++0+7c04 <[^>]*> nop
++0+7c08 <[^>]*> nop
++0+7c0c <[^>]*> nop
++0+7c10 <[^>]*> nop
++0+7c14 <[^>]*> nop
++0+7c18 <[^>]*> nop
++0+7c1c <[^>]*> nop
++0+7c20 <[^>]*> nop
++0+7c24 <[^>]*> nop
++0+7c28 <[^>]*> nop
++0+7c2c <[^>]*> nop
++0+7c30 <[^>]*> nop
++0+7c34 <[^>]*> nop
++0+7c38 <[^>]*> nop
++0+7c3c <[^>]*> nop
++0+7c40 <[^>]*> nop
++0+7c44 <[^>]*> nop
++0+7c48 <[^>]*> nop
++0+7c4c <[^>]*> nop
++0+7c50 <[^>]*> nop
++0+7c54 <[^>]*> nop
++0+7c58 <[^>]*> nop
++0+7c5c <[^>]*> nop
++0+7c60 <[^>]*> nop
++0+7c64 <[^>]*> nop
++0+7c68 <[^>]*> nop
++0+7c6c <[^>]*> nop
++0+7c70 <[^>]*> nop
++0+7c74 <[^>]*> nop
++0+7c78 <[^>]*> nop
++0+7c7c <[^>]*> nop
++0+7c80 <[^>]*> nop
++0+7c84 <[^>]*> nop
++0+7c88 <[^>]*> nop
++0+7c8c <[^>]*> nop
++0+7c90 <[^>]*> nop
++0+7c94 <[^>]*> nop
++0+7c98 <[^>]*> nop
++0+7c9c <[^>]*> nop
++0+7ca0 <[^>]*> nop
++0+7ca4 <[^>]*> nop
++0+7ca8 <[^>]*> nop
++0+7cac <[^>]*> nop
++0+7cb0 <[^>]*> nop
++0+7cb4 <[^>]*> nop
++0+7cb8 <[^>]*> nop
++0+7cbc <[^>]*> nop
++0+7cc0 <[^>]*> nop
++0+7cc4 <[^>]*> nop
++0+7cc8 <[^>]*> nop
++0+7ccc <[^>]*> nop
++0+7cd0 <[^>]*> nop
++0+7cd4 <[^>]*> nop
++0+7cd8 <[^>]*> nop
++0+7cdc <[^>]*> nop
++0+7ce0 <[^>]*> nop
++0+7ce4 <[^>]*> nop
++0+7ce8 <[^>]*> nop
++0+7cec <[^>]*> nop
++0+7cf0 <[^>]*> nop
++0+7cf4 <[^>]*> nop
++0+7cf8 <[^>]*> nop
++0+7cfc <[^>]*> nop
++0+7d00 <[^>]*> nop
++0+7d04 <[^>]*> nop
++0+7d08 <[^>]*> nop
++0+7d0c <[^>]*> nop
++0+7d10 <[^>]*> nop
++0+7d14 <[^>]*> nop
++0+7d18 <[^>]*> nop
++0+7d1c <[^>]*> nop
++0+7d20 <[^>]*> nop
++0+7d24 <[^>]*> nop
++0+7d28 <[^>]*> nop
++0+7d2c <[^>]*> nop
++0+7d30 <[^>]*> nop
++0+7d34 <[^>]*> nop
++0+7d38 <[^>]*> nop
++0+7d3c <[^>]*> nop
++0+7d40 <[^>]*> nop
++0+7d44 <[^>]*> nop
++0+7d48 <[^>]*> nop
++0+7d4c <[^>]*> nop
++0+7d50 <[^>]*> nop
++0+7d54 <[^>]*> nop
++0+7d58 <[^>]*> nop
++0+7d5c <[^>]*> nop
++0+7d60 <[^>]*> nop
++0+7d64 <[^>]*> nop
++0+7d68 <[^>]*> nop
++0+7d6c <[^>]*> nop
++0+7d70 <[^>]*> nop
++0+7d74 <[^>]*> nop
++0+7d78 <[^>]*> nop
++0+7d7c <[^>]*> nop
++0+7d80 <[^>]*> nop
++0+7d84 <[^>]*> nop
++0+7d88 <[^>]*> nop
++0+7d8c <[^>]*> nop
++0+7d90 <[^>]*> nop
++0+7d94 <[^>]*> nop
++0+7d98 <[^>]*> nop
++0+7d9c <[^>]*> nop
++0+7da0 <[^>]*> nop
++0+7da4 <[^>]*> nop
++0+7da8 <[^>]*> nop
++0+7dac <[^>]*> nop
++0+7db0 <[^>]*> nop
++0+7db4 <[^>]*> nop
++0+7db8 <[^>]*> nop
++0+7dbc <[^>]*> nop
++0+7dc0 <[^>]*> nop
++0+7dc4 <[^>]*> nop
++0+7dc8 <[^>]*> nop
++0+7dcc <[^>]*> nop
++0+7dd0 <[^>]*> nop
++0+7dd4 <[^>]*> nop
++0+7dd8 <[^>]*> nop
++0+7ddc <[^>]*> nop
++0+7de0 <[^>]*> nop
++0+7de4 <[^>]*> nop
++0+7de8 <[^>]*> nop
++0+7dec <[^>]*> nop
++0+7df0 <[^>]*> nop
++0+7df4 <[^>]*> nop
++0+7df8 <[^>]*> nop
++0+7dfc <[^>]*> nop
++0+7e00 <[^>]*> nop
++0+7e04 <[^>]*> nop
++0+7e08 <[^>]*> nop
++0+7e0c <[^>]*> nop
++0+7e10 <[^>]*> nop
++0+7e14 <[^>]*> nop
++0+7e18 <[^>]*> nop
++0+7e1c <[^>]*> nop
++0+7e20 <[^>]*> nop
++0+7e24 <[^>]*> nop
++0+7e28 <[^>]*> nop
++0+7e2c <[^>]*> nop
++0+7e30 <[^>]*> nop
++0+7e34 <[^>]*> nop
++0+7e38 <[^>]*> nop
++0+7e3c <[^>]*> nop
++0+7e40 <[^>]*> nop
++0+7e44 <[^>]*> nop
++0+7e48 <[^>]*> nop
++0+7e4c <[^>]*> nop
++0+7e50 <[^>]*> nop
++0+7e54 <[^>]*> nop
++0+7e58 <[^>]*> nop
++0+7e5c <[^>]*> nop
++0+7e60 <[^>]*> nop
++0+7e64 <[^>]*> nop
++0+7e68 <[^>]*> nop
++0+7e6c <[^>]*> nop
++0+7e70 <[^>]*> nop
++0+7e74 <[^>]*> nop
++0+7e78 <[^>]*> nop
++0+7e7c <[^>]*> nop
++0+7e80 <[^>]*> nop
++0+7e84 <[^>]*> nop
++0+7e88 <[^>]*> nop
++0+7e8c <[^>]*> nop
++0+7e90 <[^>]*> nop
++0+7e94 <[^>]*> nop
++0+7e98 <[^>]*> nop
++0+7e9c <[^>]*> nop
++0+7ea0 <[^>]*> nop
++0+7ea4 <[^>]*> nop
++0+7ea8 <[^>]*> nop
++0+7eac <[^>]*> nop
++0+7eb0 <[^>]*> nop
++0+7eb4 <[^>]*> nop
++0+7eb8 <[^>]*> nop
++0+7ebc <[^>]*> nop
++0+7ec0 <[^>]*> nop
++0+7ec4 <[^>]*> nop
++0+7ec8 <[^>]*> nop
++0+7ecc <[^>]*> nop
++0+7ed0 <[^>]*> nop
++0+7ed4 <[^>]*> nop
++0+7ed8 <[^>]*> nop
++0+7edc <[^>]*> nop
++0+7ee0 <[^>]*> nop
++0+7ee4 <[^>]*> nop
++0+7ee8 <[^>]*> nop
++0+7eec <[^>]*> nop
++0+7ef0 <[^>]*> nop
++0+7ef4 <[^>]*> nop
++0+7ef8 <[^>]*> nop
++0+7efc <[^>]*> nop
++0+7f00 <[^>]*> nop
++0+7f04 <[^>]*> nop
++0+7f08 <[^>]*> nop
++0+7f0c <[^>]*> nop
++0+7f10 <[^>]*> nop
++0+7f14 <[^>]*> nop
++0+7f18 <[^>]*> nop
++0+7f1c <[^>]*> nop
++0+7f20 <[^>]*> nop
++0+7f24 <[^>]*> nop
++0+7f28 <[^>]*> nop
++0+7f2c <[^>]*> nop
++0+7f30 <[^>]*> nop
++0+7f34 <[^>]*> nop
++0+7f38 <[^>]*> nop
++0+7f3c <[^>]*> nop
++0+7f40 <[^>]*> nop
++0+7f44 <[^>]*> nop
++0+7f48 <[^>]*> nop
++0+7f4c <[^>]*> nop
++0+7f50 <[^>]*> nop
++0+7f54 <[^>]*> nop
++0+7f58 <[^>]*> nop
++0+7f5c <[^>]*> nop
++0+7f60 <[^>]*> nop
++0+7f64 <[^>]*> nop
++0+7f68 <[^>]*> nop
++0+7f6c <[^>]*> nop
++0+7f70 <[^>]*> nop
++0+7f74 <[^>]*> nop
++0+7f78 <[^>]*> nop
++0+7f7c <[^>]*> nop
++0+7f80 <[^>]*> nop
++0+7f84 <[^>]*> nop
++0+7f88 <[^>]*> nop
++0+7f8c <[^>]*> nop
++0+7f90 <[^>]*> nop
++0+7f94 <[^>]*> nop
++0+7f98 <[^>]*> nop
++0+7f9c <[^>]*> nop
++0+7fa0 <[^>]*> nop
++0+7fa4 <[^>]*> nop
++0+7fa8 <[^>]*> nop
++0+7fac <[^>]*> nop
++0+7fb0 <[^>]*> nop
++0+7fb4 <[^>]*> nop
++0+7fb8 <[^>]*> nop
++0+7fbc <[^>]*> nop
++0+7fc0 <[^>]*> nop
++0+7fc4 <[^>]*> nop
++0+7fc8 <[^>]*> nop
++0+7fcc <[^>]*> nop
++0+7fd0 <[^>]*> nop
++0+7fd4 <[^>]*> nop
++0+7fd8 <[^>]*> nop
++0+7fdc <[^>]*> nop
++0+7fe0 <[^>]*> nop
++0+7fe4 <[^>]*> nop
++0+7fe8 <[^>]*> nop
++0+7fec <[^>]*> nop
++0+7ff0 <[^>]*> nop
++0+7ff4 <[^>]*> nop
++0+7ff8 <[^>]*> nop
++0+7ffc <[^>]*> nop
++0+8000 <[^>]*> movhi at,0
++0+8004 <[^>]*> ori at,at,0
++0+8008 <[^>]*> jmp at
++0+800c <out_of_range> nop
++ ...
++
+diff --git a/gas/testsuite/gas/nios2/relax_section.s b/gas/testsuite/gas/nios2/relax_section.s
+new file mode 100644
+index 0000000..85c8e1d
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_section.s
+@@ -0,0 +1,10 @@
++ beq r2, r3, out_of_range
++ bne r2, r3, in_range
++ nop
++ nop
++in_range:
++ nop
++.align 15
++ br 0
++out_of_range:
++ nop
+diff --git a/gas/testsuite/gas/nios2/relax_ujmp.d b/gas/testsuite/gas/nios2/relax_ujmp.d
+new file mode 100644
+index 0000000..6c9269e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_ujmp.d
+@@ -0,0 +1,8221 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 relax_ujmp
++
++# Test relaxation of unconditional jumps
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section text2:
++00000000 <[^>]*> br 00008000 <[^>]*>
++00000004 <[^>]*> nop
++00000008 <[^>]*> nop
++0000000c <[^>]*> movhi at,1
++00000010 <[^>]*> ori at,at,24
++00000014 <[^>]*> jmp at
++00000018 <[^>]*> br 0000002c <[^>]*>
++0000001c <[^>]*> nop
++00000020 <[^>]*> nop
++00000024 <[^>]*> nop
++00000028 <[^>]*> nop
++0000002c <[^>]*> nop
++Disassembly of section text1:
++00008000 <[^>]*> br 00010000 <[^>]*>
++00008004 <[^>]*> nop
++00008008 <[^>]*> nop
++0000800c <[^>]*> movhi at,1
++00008010 <[^>]*> ori at,at,24
++00008014 <[^>]*> jmp at
++00008018 <[^>]*> nop
++0000801c <[^>]*> nop
++00008020 <[^>]*> nop
++00008024 <[^>]*> nop
++00008028 <[^>]*> nop
++0000802c <[^>]*> nop
++00008030 <[^>]*> nop
++00008034 <[^>]*> nop
++00008038 <[^>]*> nop
++0000803c <[^>]*> nop
++00008040 <[^>]*> nop
++00008044 <[^>]*> nop
++00008048 <[^>]*> nop
++0000804c <[^>]*> nop
++00008050 <[^>]*> nop
++00008054 <[^>]*> nop
++00008058 <[^>]*> nop
++0000805c <[^>]*> nop
++00008060 <[^>]*> nop
++00008064 <[^>]*> nop
++00008068 <[^>]*> nop
++0000806c <[^>]*> nop
++00008070 <[^>]*> nop
++00008074 <[^>]*> nop
++00008078 <[^>]*> nop
++0000807c <[^>]*> nop
++00008080 <[^>]*> nop
++00008084 <[^>]*> nop
++00008088 <[^>]*> nop
++0000808c <[^>]*> nop
++00008090 <[^>]*> nop
++00008094 <[^>]*> nop
++00008098 <[^>]*> nop
++0000809c <[^>]*> nop
++000080a0 <[^>]*> nop
++000080a4 <[^>]*> nop
++000080a8 <[^>]*> nop
++000080ac <[^>]*> nop
++000080b0 <[^>]*> nop
++000080b4 <[^>]*> nop
++000080b8 <[^>]*> nop
++000080bc <[^>]*> nop
++000080c0 <[^>]*> nop
++000080c4 <[^>]*> nop
++000080c8 <[^>]*> nop
++000080cc <[^>]*> nop
++000080d0 <[^>]*> nop
++000080d4 <[^>]*> nop
++000080d8 <[^>]*> nop
++000080dc <[^>]*> nop
++000080e0 <[^>]*> nop
++000080e4 <[^>]*> nop
++000080e8 <[^>]*> nop
++000080ec <[^>]*> nop
++000080f0 <[^>]*> nop
++000080f4 <[^>]*> nop
++000080f8 <[^>]*> nop
++000080fc <[^>]*> nop
++00008100 <[^>]*> nop
++00008104 <[^>]*> nop
++00008108 <[^>]*> nop
++0000810c <[^>]*> nop
++00008110 <[^>]*> nop
++00008114 <[^>]*> nop
++00008118 <[^>]*> nop
++0000811c <[^>]*> nop
++00008120 <[^>]*> nop
++00008124 <[^>]*> nop
++00008128 <[^>]*> nop
++0000812c <[^>]*> nop
++00008130 <[^>]*> nop
++00008134 <[^>]*> nop
++00008138 <[^>]*> nop
++0000813c <[^>]*> nop
++00008140 <[^>]*> nop
++00008144 <[^>]*> nop
++00008148 <[^>]*> nop
++0000814c <[^>]*> nop
++00008150 <[^>]*> nop
++00008154 <[^>]*> nop
++00008158 <[^>]*> nop
++0000815c <[^>]*> nop
++00008160 <[^>]*> nop
++00008164 <[^>]*> nop
++00008168 <[^>]*> nop
++0000816c <[^>]*> nop
++00008170 <[^>]*> nop
++00008174 <[^>]*> nop
++00008178 <[^>]*> nop
++0000817c <[^>]*> nop
++00008180 <[^>]*> nop
++00008184 <[^>]*> nop
++00008188 <[^>]*> nop
++0000818c <[^>]*> nop
++00008190 <[^>]*> nop
++00008194 <[^>]*> nop
++00008198 <[^>]*> nop
++0000819c <[^>]*> nop
++000081a0 <[^>]*> nop
++000081a4 <[^>]*> nop
++000081a8 <[^>]*> nop
++000081ac <[^>]*> nop
++000081b0 <[^>]*> nop
++000081b4 <[^>]*> nop
++000081b8 <[^>]*> nop
++000081bc <[^>]*> nop
++000081c0 <[^>]*> nop
++000081c4 <[^>]*> nop
++000081c8 <[^>]*> nop
++000081cc <[^>]*> nop
++000081d0 <[^>]*> nop
++000081d4 <[^>]*> nop
++000081d8 <[^>]*> nop
++000081dc <[^>]*> nop
++000081e0 <[^>]*> nop
++000081e4 <[^>]*> nop
++000081e8 <[^>]*> nop
++000081ec <[^>]*> nop
++000081f0 <[^>]*> nop
++000081f4 <[^>]*> nop
++000081f8 <[^>]*> nop
++000081fc <[^>]*> nop
++00008200 <[^>]*> nop
++00008204 <[^>]*> nop
++00008208 <[^>]*> nop
++0000820c <[^>]*> nop
++00008210 <[^>]*> nop
++00008214 <[^>]*> nop
++00008218 <[^>]*> nop
++0000821c <[^>]*> nop
++00008220 <[^>]*> nop
++00008224 <[^>]*> nop
++00008228 <[^>]*> nop
++0000822c <[^>]*> nop
++00008230 <[^>]*> nop
++00008234 <[^>]*> nop
++00008238 <[^>]*> nop
++0000823c <[^>]*> nop
++00008240 <[^>]*> nop
++00008244 <[^>]*> nop
++00008248 <[^>]*> nop
++0000824c <[^>]*> nop
++00008250 <[^>]*> nop
++00008254 <[^>]*> nop
++00008258 <[^>]*> nop
++0000825c <[^>]*> nop
++00008260 <[^>]*> nop
++00008264 <[^>]*> nop
++00008268 <[^>]*> nop
++0000826c <[^>]*> nop
++00008270 <[^>]*> nop
++00008274 <[^>]*> nop
++00008278 <[^>]*> nop
++0000827c <[^>]*> nop
++00008280 <[^>]*> nop
++00008284 <[^>]*> nop
++00008288 <[^>]*> nop
++0000828c <[^>]*> nop
++00008290 <[^>]*> nop
++00008294 <[^>]*> nop
++00008298 <[^>]*> nop
++0000829c <[^>]*> nop
++000082a0 <[^>]*> nop
++000082a4 <[^>]*> nop
++000082a8 <[^>]*> nop
++000082ac <[^>]*> nop
++000082b0 <[^>]*> nop
++000082b4 <[^>]*> nop
++000082b8 <[^>]*> nop
++000082bc <[^>]*> nop
++000082c0 <[^>]*> nop
++000082c4 <[^>]*> nop
++000082c8 <[^>]*> nop
++000082cc <[^>]*> nop
++000082d0 <[^>]*> nop
++000082d4 <[^>]*> nop
++000082d8 <[^>]*> nop
++000082dc <[^>]*> nop
++000082e0 <[^>]*> nop
++000082e4 <[^>]*> nop
++000082e8 <[^>]*> nop
++000082ec <[^>]*> nop
++000082f0 <[^>]*> nop
++000082f4 <[^>]*> nop
++000082f8 <[^>]*> nop
++000082fc <[^>]*> nop
++00008300 <[^>]*> nop
++00008304 <[^>]*> nop
++00008308 <[^>]*> nop
++0000830c <[^>]*> nop
++00008310 <[^>]*> nop
++00008314 <[^>]*> nop
++00008318 <[^>]*> nop
++0000831c <[^>]*> nop
++00008320 <[^>]*> nop
++00008324 <[^>]*> nop
++00008328 <[^>]*> nop
++0000832c <[^>]*> nop
++00008330 <[^>]*> nop
++00008334 <[^>]*> nop
++00008338 <[^>]*> nop
++0000833c <[^>]*> nop
++00008340 <[^>]*> nop
++00008344 <[^>]*> nop
++00008348 <[^>]*> nop
++0000834c <[^>]*> nop
++00008350 <[^>]*> nop
++00008354 <[^>]*> nop
++00008358 <[^>]*> nop
++0000835c <[^>]*> nop
++00008360 <[^>]*> nop
++00008364 <[^>]*> nop
++00008368 <[^>]*> nop
++0000836c <[^>]*> nop
++00008370 <[^>]*> nop
++00008374 <[^>]*> nop
++00008378 <[^>]*> nop
++0000837c <[^>]*> nop
++00008380 <[^>]*> nop
++00008384 <[^>]*> nop
++00008388 <[^>]*> nop
++0000838c <[^>]*> nop
++00008390 <[^>]*> nop
++00008394 <[^>]*> nop
++00008398 <[^>]*> nop
++0000839c <[^>]*> nop
++000083a0 <[^>]*> nop
++000083a4 <[^>]*> nop
++000083a8 <[^>]*> nop
++000083ac <[^>]*> nop
++000083b0 <[^>]*> nop
++000083b4 <[^>]*> nop
++000083b8 <[^>]*> nop
++000083bc <[^>]*> nop
++000083c0 <[^>]*> nop
++000083c4 <[^>]*> nop
++000083c8 <[^>]*> nop
++000083cc <[^>]*> nop
++000083d0 <[^>]*> nop
++000083d4 <[^>]*> nop
++000083d8 <[^>]*> nop
++000083dc <[^>]*> nop
++000083e0 <[^>]*> nop
++000083e4 <[^>]*> nop
++000083e8 <[^>]*> nop
++000083ec <[^>]*> nop
++000083f0 <[^>]*> nop
++000083f4 <[^>]*> nop
++000083f8 <[^>]*> nop
++000083fc <[^>]*> nop
++00008400 <[^>]*> nop
++00008404 <[^>]*> nop
++00008408 <[^>]*> nop
++0000840c <[^>]*> nop
++00008410 <[^>]*> nop
++00008414 <[^>]*> nop
++00008418 <[^>]*> nop
++0000841c <[^>]*> nop
++00008420 <[^>]*> nop
++00008424 <[^>]*> nop
++00008428 <[^>]*> nop
++0000842c <[^>]*> nop
++00008430 <[^>]*> nop
++00008434 <[^>]*> nop
++00008438 <[^>]*> nop
++0000843c <[^>]*> nop
++00008440 <[^>]*> nop
++00008444 <[^>]*> nop
++00008448 <[^>]*> nop
++0000844c <[^>]*> nop
++00008450 <[^>]*> nop
++00008454 <[^>]*> nop
++00008458 <[^>]*> nop
++0000845c <[^>]*> nop
++00008460 <[^>]*> nop
++00008464 <[^>]*> nop
++00008468 <[^>]*> nop
++0000846c <[^>]*> nop
++00008470 <[^>]*> nop
++00008474 <[^>]*> nop
++00008478 <[^>]*> nop
++0000847c <[^>]*> nop
++00008480 <[^>]*> nop
++00008484 <[^>]*> nop
++00008488 <[^>]*> nop
++0000848c <[^>]*> nop
++00008490 <[^>]*> nop
++00008494 <[^>]*> nop
++00008498 <[^>]*> nop
++0000849c <[^>]*> nop
++000084a0 <[^>]*> nop
++000084a4 <[^>]*> nop
++000084a8 <[^>]*> nop
++000084ac <[^>]*> nop
++000084b0 <[^>]*> nop
++000084b4 <[^>]*> nop
++000084b8 <[^>]*> nop
++000084bc <[^>]*> nop
++000084c0 <[^>]*> nop
++000084c4 <[^>]*> nop
++000084c8 <[^>]*> nop
++000084cc <[^>]*> nop
++000084d0 <[^>]*> nop
++000084d4 <[^>]*> nop
++000084d8 <[^>]*> nop
++000084dc <[^>]*> nop
++000084e0 <[^>]*> nop
++000084e4 <[^>]*> nop
++000084e8 <[^>]*> nop
++000084ec <[^>]*> nop
++000084f0 <[^>]*> nop
++000084f4 <[^>]*> nop
++000084f8 <[^>]*> nop
++000084fc <[^>]*> nop
++00008500 <[^>]*> nop
++00008504 <[^>]*> nop
++00008508 <[^>]*> nop
++0000850c <[^>]*> nop
++00008510 <[^>]*> nop
++00008514 <[^>]*> nop
++00008518 <[^>]*> nop
++0000851c <[^>]*> nop
++00008520 <[^>]*> nop
++00008524 <[^>]*> nop
++00008528 <[^>]*> nop
++0000852c <[^>]*> nop
++00008530 <[^>]*> nop
++00008534 <[^>]*> nop
++00008538 <[^>]*> nop
++0000853c <[^>]*> nop
++00008540 <[^>]*> nop
++00008544 <[^>]*> nop
++00008548 <[^>]*> nop
++0000854c <[^>]*> nop
++00008550 <[^>]*> nop
++00008554 <[^>]*> nop
++00008558 <[^>]*> nop
++0000855c <[^>]*> nop
++00008560 <[^>]*> nop
++00008564 <[^>]*> nop
++00008568 <[^>]*> nop
++0000856c <[^>]*> nop
++00008570 <[^>]*> nop
++00008574 <[^>]*> nop
++00008578 <[^>]*> nop
++0000857c <[^>]*> nop
++00008580 <[^>]*> nop
++00008584 <[^>]*> nop
++00008588 <[^>]*> nop
++0000858c <[^>]*> nop
++00008590 <[^>]*> nop
++00008594 <[^>]*> nop
++00008598 <[^>]*> nop
++0000859c <[^>]*> nop
++000085a0 <[^>]*> nop
++000085a4 <[^>]*> nop
++000085a8 <[^>]*> nop
++000085ac <[^>]*> nop
++000085b0 <[^>]*> nop
++000085b4 <[^>]*> nop
++000085b8 <[^>]*> nop
++000085bc <[^>]*> nop
++000085c0 <[^>]*> nop
++000085c4 <[^>]*> nop
++000085c8 <[^>]*> nop
++000085cc <[^>]*> nop
++000085d0 <[^>]*> nop
++000085d4 <[^>]*> nop
++000085d8 <[^>]*> nop
++000085dc <[^>]*> nop
++000085e0 <[^>]*> nop
++000085e4 <[^>]*> nop
++000085e8 <[^>]*> nop
++000085ec <[^>]*> nop
++000085f0 <[^>]*> nop
++000085f4 <[^>]*> nop
++000085f8 <[^>]*> nop
++000085fc <[^>]*> nop
++00008600 <[^>]*> nop
++00008604 <[^>]*> nop
++00008608 <[^>]*> nop
++0000860c <[^>]*> nop
++00008610 <[^>]*> nop
++00008614 <[^>]*> nop
++00008618 <[^>]*> nop
++0000861c <[^>]*> nop
++00008620 <[^>]*> nop
++00008624 <[^>]*> nop
++00008628 <[^>]*> nop
++0000862c <[^>]*> nop
++00008630 <[^>]*> nop
++00008634 <[^>]*> nop
++00008638 <[^>]*> nop
++0000863c <[^>]*> nop
++00008640 <[^>]*> nop
++00008644 <[^>]*> nop
++00008648 <[^>]*> nop
++0000864c <[^>]*> nop
++00008650 <[^>]*> nop
++00008654 <[^>]*> nop
++00008658 <[^>]*> nop
++0000865c <[^>]*> nop
++00008660 <[^>]*> nop
++00008664 <[^>]*> nop
++00008668 <[^>]*> nop
++0000866c <[^>]*> nop
++00008670 <[^>]*> nop
++00008674 <[^>]*> nop
++00008678 <[^>]*> nop
++0000867c <[^>]*> nop
++00008680 <[^>]*> nop
++00008684 <[^>]*> nop
++00008688 <[^>]*> nop
++0000868c <[^>]*> nop
++00008690 <[^>]*> nop
++00008694 <[^>]*> nop
++00008698 <[^>]*> nop
++0000869c <[^>]*> nop
++000086a0 <[^>]*> nop
++000086a4 <[^>]*> nop
++000086a8 <[^>]*> nop
++000086ac <[^>]*> nop
++000086b0 <[^>]*> nop
++000086b4 <[^>]*> nop
++000086b8 <[^>]*> nop
++000086bc <[^>]*> nop
++000086c0 <[^>]*> nop
++000086c4 <[^>]*> nop
++000086c8 <[^>]*> nop
++000086cc <[^>]*> nop
++000086d0 <[^>]*> nop
++000086d4 <[^>]*> nop
++000086d8 <[^>]*> nop
++000086dc <[^>]*> nop
++000086e0 <[^>]*> nop
++000086e4 <[^>]*> nop
++000086e8 <[^>]*> nop
++000086ec <[^>]*> nop
++000086f0 <[^>]*> nop
++000086f4 <[^>]*> nop
++000086f8 <[^>]*> nop
++000086fc <[^>]*> nop
++00008700 <[^>]*> nop
++00008704 <[^>]*> nop
++00008708 <[^>]*> nop
++0000870c <[^>]*> nop
++00008710 <[^>]*> nop
++00008714 <[^>]*> nop
++00008718 <[^>]*> nop
++0000871c <[^>]*> nop
++00008720 <[^>]*> nop
++00008724 <[^>]*> nop
++00008728 <[^>]*> nop
++0000872c <[^>]*> nop
++00008730 <[^>]*> nop
++00008734 <[^>]*> nop
++00008738 <[^>]*> nop
++0000873c <[^>]*> nop
++00008740 <[^>]*> nop
++00008744 <[^>]*> nop
++00008748 <[^>]*> nop
++0000874c <[^>]*> nop
++00008750 <[^>]*> nop
++00008754 <[^>]*> nop
++00008758 <[^>]*> nop
++0000875c <[^>]*> nop
++00008760 <[^>]*> nop
++00008764 <[^>]*> nop
++00008768 <[^>]*> nop
++0000876c <[^>]*> nop
++00008770 <[^>]*> nop
++00008774 <[^>]*> nop
++00008778 <[^>]*> nop
++0000877c <[^>]*> nop
++00008780 <[^>]*> nop
++00008784 <[^>]*> nop
++00008788 <[^>]*> nop
++0000878c <[^>]*> nop
++00008790 <[^>]*> nop
++00008794 <[^>]*> nop
++00008798 <[^>]*> nop
++0000879c <[^>]*> nop
++000087a0 <[^>]*> nop
++000087a4 <[^>]*> nop
++000087a8 <[^>]*> nop
++000087ac <[^>]*> nop
++000087b0 <[^>]*> nop
++000087b4 <[^>]*> nop
++000087b8 <[^>]*> nop
++000087bc <[^>]*> nop
++000087c0 <[^>]*> nop
++000087c4 <[^>]*> nop
++000087c8 <[^>]*> nop
++000087cc <[^>]*> nop
++000087d0 <[^>]*> nop
++000087d4 <[^>]*> nop
++000087d8 <[^>]*> nop
++000087dc <[^>]*> nop
++000087e0 <[^>]*> nop
++000087e4 <[^>]*> nop
++000087e8 <[^>]*> nop
++000087ec <[^>]*> nop
++000087f0 <[^>]*> nop
++000087f4 <[^>]*> nop
++000087f8 <[^>]*> nop
++000087fc <[^>]*> nop
++00008800 <[^>]*> nop
++00008804 <[^>]*> nop
++00008808 <[^>]*> nop
++0000880c <[^>]*> nop
++00008810 <[^>]*> nop
++00008814 <[^>]*> nop
++00008818 <[^>]*> nop
++0000881c <[^>]*> nop
++00008820 <[^>]*> nop
++00008824 <[^>]*> nop
++00008828 <[^>]*> nop
++0000882c <[^>]*> nop
++00008830 <[^>]*> nop
++00008834 <[^>]*> nop
++00008838 <[^>]*> nop
++0000883c <[^>]*> nop
++00008840 <[^>]*> nop
++00008844 <[^>]*> nop
++00008848 <[^>]*> nop
++0000884c <[^>]*> nop
++00008850 <[^>]*> nop
++00008854 <[^>]*> nop
++00008858 <[^>]*> nop
++0000885c <[^>]*> nop
++00008860 <[^>]*> nop
++00008864 <[^>]*> nop
++00008868 <[^>]*> nop
++0000886c <[^>]*> nop
++00008870 <[^>]*> nop
++00008874 <[^>]*> nop
++00008878 <[^>]*> nop
++0000887c <[^>]*> nop
++00008880 <[^>]*> nop
++00008884 <[^>]*> nop
++00008888 <[^>]*> nop
++0000888c <[^>]*> nop
++00008890 <[^>]*> nop
++00008894 <[^>]*> nop
++00008898 <[^>]*> nop
++0000889c <[^>]*> nop
++000088a0 <[^>]*> nop
++000088a4 <[^>]*> nop
++000088a8 <[^>]*> nop
++000088ac <[^>]*> nop
++000088b0 <[^>]*> nop
++000088b4 <[^>]*> nop
++000088b8 <[^>]*> nop
++000088bc <[^>]*> nop
++000088c0 <[^>]*> nop
++000088c4 <[^>]*> nop
++000088c8 <[^>]*> nop
++000088cc <[^>]*> nop
++000088d0 <[^>]*> nop
++000088d4 <[^>]*> nop
++000088d8 <[^>]*> nop
++000088dc <[^>]*> nop
++000088e0 <[^>]*> nop
++000088e4 <[^>]*> nop
++000088e8 <[^>]*> nop
++000088ec <[^>]*> nop
++000088f0 <[^>]*> nop
++000088f4 <[^>]*> nop
++000088f8 <[^>]*> nop
++000088fc <[^>]*> nop
++00008900 <[^>]*> nop
++00008904 <[^>]*> nop
++00008908 <[^>]*> nop
++0000890c <[^>]*> nop
++00008910 <[^>]*> nop
++00008914 <[^>]*> nop
++00008918 <[^>]*> nop
++0000891c <[^>]*> nop
++00008920 <[^>]*> nop
++00008924 <[^>]*> nop
++00008928 <[^>]*> nop
++0000892c <[^>]*> nop
++00008930 <[^>]*> nop
++00008934 <[^>]*> nop
++00008938 <[^>]*> nop
++0000893c <[^>]*> nop
++00008940 <[^>]*> nop
++00008944 <[^>]*> nop
++00008948 <[^>]*> nop
++0000894c <[^>]*> nop
++00008950 <[^>]*> nop
++00008954 <[^>]*> nop
++00008958 <[^>]*> nop
++0000895c <[^>]*> nop
++00008960 <[^>]*> nop
++00008964 <[^>]*> nop
++00008968 <[^>]*> nop
++0000896c <[^>]*> nop
++00008970 <[^>]*> nop
++00008974 <[^>]*> nop
++00008978 <[^>]*> nop
++0000897c <[^>]*> nop
++00008980 <[^>]*> nop
++00008984 <[^>]*> nop
++00008988 <[^>]*> nop
++0000898c <[^>]*> nop
++00008990 <[^>]*> nop
++00008994 <[^>]*> nop
++00008998 <[^>]*> nop
++0000899c <[^>]*> nop
++000089a0 <[^>]*> nop
++000089a4 <[^>]*> nop
++000089a8 <[^>]*> nop
++000089ac <[^>]*> nop
++000089b0 <[^>]*> nop
++000089b4 <[^>]*> nop
++000089b8 <[^>]*> nop
++000089bc <[^>]*> nop
++000089c0 <[^>]*> nop
++000089c4 <[^>]*> nop
++000089c8 <[^>]*> nop
++000089cc <[^>]*> nop
++000089d0 <[^>]*> nop
++000089d4 <[^>]*> nop
++000089d8 <[^>]*> nop
++000089dc <[^>]*> nop
++000089e0 <[^>]*> nop
++000089e4 <[^>]*> nop
++000089e8 <[^>]*> nop
++000089ec <[^>]*> nop
++000089f0 <[^>]*> nop
++000089f4 <[^>]*> nop
++000089f8 <[^>]*> nop
++000089fc <[^>]*> nop
++00008a00 <[^>]*> nop
++00008a04 <[^>]*> nop
++00008a08 <[^>]*> nop
++00008a0c <[^>]*> nop
++00008a10 <[^>]*> nop
++00008a14 <[^>]*> nop
++00008a18 <[^>]*> nop
++00008a1c <[^>]*> nop
++00008a20 <[^>]*> nop
++00008a24 <[^>]*> nop
++00008a28 <[^>]*> nop
++00008a2c <[^>]*> nop
++00008a30 <[^>]*> nop
++00008a34 <[^>]*> nop
++00008a38 <[^>]*> nop
++00008a3c <[^>]*> nop
++00008a40 <[^>]*> nop
++00008a44 <[^>]*> nop
++00008a48 <[^>]*> nop
++00008a4c <[^>]*> nop
++00008a50 <[^>]*> nop
++00008a54 <[^>]*> nop
++00008a58 <[^>]*> nop
++00008a5c <[^>]*> nop
++00008a60 <[^>]*> nop
++00008a64 <[^>]*> nop
++00008a68 <[^>]*> nop
++00008a6c <[^>]*> nop
++00008a70 <[^>]*> nop
++00008a74 <[^>]*> nop
++00008a78 <[^>]*> nop
++00008a7c <[^>]*> nop
++00008a80 <[^>]*> nop
++00008a84 <[^>]*> nop
++00008a88 <[^>]*> nop
++00008a8c <[^>]*> nop
++00008a90 <[^>]*> nop
++00008a94 <[^>]*> nop
++00008a98 <[^>]*> nop
++00008a9c <[^>]*> nop
++00008aa0 <[^>]*> nop
++00008aa4 <[^>]*> nop
++00008aa8 <[^>]*> nop
++00008aac <[^>]*> nop
++00008ab0 <[^>]*> nop
++00008ab4 <[^>]*> nop
++00008ab8 <[^>]*> nop
++00008abc <[^>]*> nop
++00008ac0 <[^>]*> nop
++00008ac4 <[^>]*> nop
++00008ac8 <[^>]*> nop
++00008acc <[^>]*> nop
++00008ad0 <[^>]*> nop
++00008ad4 <[^>]*> nop
++00008ad8 <[^>]*> nop
++00008adc <[^>]*> nop
++00008ae0 <[^>]*> nop
++00008ae4 <[^>]*> nop
++00008ae8 <[^>]*> nop
++00008aec <[^>]*> nop
++00008af0 <[^>]*> nop
++00008af4 <[^>]*> nop
++00008af8 <[^>]*> nop
++00008afc <[^>]*> nop
++00008b00 <[^>]*> nop
++00008b04 <[^>]*> nop
++00008b08 <[^>]*> nop
++00008b0c <[^>]*> nop
++00008b10 <[^>]*> nop
++00008b14 <[^>]*> nop
++00008b18 <[^>]*> nop
++00008b1c <[^>]*> nop
++00008b20 <[^>]*> nop
++00008b24 <[^>]*> nop
++00008b28 <[^>]*> nop
++00008b2c <[^>]*> nop
++00008b30 <[^>]*> nop
++00008b34 <[^>]*> nop
++00008b38 <[^>]*> nop
++00008b3c <[^>]*> nop
++00008b40 <[^>]*> nop
++00008b44 <[^>]*> nop
++00008b48 <[^>]*> nop
++00008b4c <[^>]*> nop
++00008b50 <[^>]*> nop
++00008b54 <[^>]*> nop
++00008b58 <[^>]*> nop
++00008b5c <[^>]*> nop
++00008b60 <[^>]*> nop
++00008b64 <[^>]*> nop
++00008b68 <[^>]*> nop
++00008b6c <[^>]*> nop
++00008b70 <[^>]*> nop
++00008b74 <[^>]*> nop
++00008b78 <[^>]*> nop
++00008b7c <[^>]*> nop
++00008b80 <[^>]*> nop
++00008b84 <[^>]*> nop
++00008b88 <[^>]*> nop
++00008b8c <[^>]*> nop
++00008b90 <[^>]*> nop
++00008b94 <[^>]*> nop
++00008b98 <[^>]*> nop
++00008b9c <[^>]*> nop
++00008ba0 <[^>]*> nop
++00008ba4 <[^>]*> nop
++00008ba8 <[^>]*> nop
++00008bac <[^>]*> nop
++00008bb0 <[^>]*> nop
++00008bb4 <[^>]*> nop
++00008bb8 <[^>]*> nop
++00008bbc <[^>]*> nop
++00008bc0 <[^>]*> nop
++00008bc4 <[^>]*> nop
++00008bc8 <[^>]*> nop
++00008bcc <[^>]*> nop
++00008bd0 <[^>]*> nop
++00008bd4 <[^>]*> nop
++00008bd8 <[^>]*> nop
++00008bdc <[^>]*> nop
++00008be0 <[^>]*> nop
++00008be4 <[^>]*> nop
++00008be8 <[^>]*> nop
++00008bec <[^>]*> nop
++00008bf0 <[^>]*> nop
++00008bf4 <[^>]*> nop
++00008bf8 <[^>]*> nop
++00008bfc <[^>]*> nop
++00008c00 <[^>]*> nop
++00008c04 <[^>]*> nop
++00008c08 <[^>]*> nop
++00008c0c <[^>]*> nop
++00008c10 <[^>]*> nop
++00008c14 <[^>]*> nop
++00008c18 <[^>]*> nop
++00008c1c <[^>]*> nop
++00008c20 <[^>]*> nop
++00008c24 <[^>]*> nop
++00008c28 <[^>]*> nop
++00008c2c <[^>]*> nop
++00008c30 <[^>]*> nop
++00008c34 <[^>]*> nop
++00008c38 <[^>]*> nop
++00008c3c <[^>]*> nop
++00008c40 <[^>]*> nop
++00008c44 <[^>]*> nop
++00008c48 <[^>]*> nop
++00008c4c <[^>]*> nop
++00008c50 <[^>]*> nop
++00008c54 <[^>]*> nop
++00008c58 <[^>]*> nop
++00008c5c <[^>]*> nop
++00008c60 <[^>]*> nop
++00008c64 <[^>]*> nop
++00008c68 <[^>]*> nop
++00008c6c <[^>]*> nop
++00008c70 <[^>]*> nop
++00008c74 <[^>]*> nop
++00008c78 <[^>]*> nop
++00008c7c <[^>]*> nop
++00008c80 <[^>]*> nop
++00008c84 <[^>]*> nop
++00008c88 <[^>]*> nop
++00008c8c <[^>]*> nop
++00008c90 <[^>]*> nop
++00008c94 <[^>]*> nop
++00008c98 <[^>]*> nop
++00008c9c <[^>]*> nop
++00008ca0 <[^>]*> nop
++00008ca4 <[^>]*> nop
++00008ca8 <[^>]*> nop
++00008cac <[^>]*> nop
++00008cb0 <[^>]*> nop
++00008cb4 <[^>]*> nop
++00008cb8 <[^>]*> nop
++00008cbc <[^>]*> nop
++00008cc0 <[^>]*> nop
++00008cc4 <[^>]*> nop
++00008cc8 <[^>]*> nop
++00008ccc <[^>]*> nop
++00008cd0 <[^>]*> nop
++00008cd4 <[^>]*> nop
++00008cd8 <[^>]*> nop
++00008cdc <[^>]*> nop
++00008ce0 <[^>]*> nop
++00008ce4 <[^>]*> nop
++00008ce8 <[^>]*> nop
++00008cec <[^>]*> nop
++00008cf0 <[^>]*> nop
++00008cf4 <[^>]*> nop
++00008cf8 <[^>]*> nop
++00008cfc <[^>]*> nop
++00008d00 <[^>]*> nop
++00008d04 <[^>]*> nop
++00008d08 <[^>]*> nop
++00008d0c <[^>]*> nop
++00008d10 <[^>]*> nop
++00008d14 <[^>]*> nop
++00008d18 <[^>]*> nop
++00008d1c <[^>]*> nop
++00008d20 <[^>]*> nop
++00008d24 <[^>]*> nop
++00008d28 <[^>]*> nop
++00008d2c <[^>]*> nop
++00008d30 <[^>]*> nop
++00008d34 <[^>]*> nop
++00008d38 <[^>]*> nop
++00008d3c <[^>]*> nop
++00008d40 <[^>]*> nop
++00008d44 <[^>]*> nop
++00008d48 <[^>]*> nop
++00008d4c <[^>]*> nop
++00008d50 <[^>]*> nop
++00008d54 <[^>]*> nop
++00008d58 <[^>]*> nop
++00008d5c <[^>]*> nop
++00008d60 <[^>]*> nop
++00008d64 <[^>]*> nop
++00008d68 <[^>]*> nop
++00008d6c <[^>]*> nop
++00008d70 <[^>]*> nop
++00008d74 <[^>]*> nop
++00008d78 <[^>]*> nop
++00008d7c <[^>]*> nop
++00008d80 <[^>]*> nop
++00008d84 <[^>]*> nop
++00008d88 <[^>]*> nop
++00008d8c <[^>]*> nop
++00008d90 <[^>]*> nop
++00008d94 <[^>]*> nop
++00008d98 <[^>]*> nop
++00008d9c <[^>]*> nop
++00008da0 <[^>]*> nop
++00008da4 <[^>]*> nop
++00008da8 <[^>]*> nop
++00008dac <[^>]*> nop
++00008db0 <[^>]*> nop
++00008db4 <[^>]*> nop
++00008db8 <[^>]*> nop
++00008dbc <[^>]*> nop
++00008dc0 <[^>]*> nop
++00008dc4 <[^>]*> nop
++00008dc8 <[^>]*> nop
++00008dcc <[^>]*> nop
++00008dd0 <[^>]*> nop
++00008dd4 <[^>]*> nop
++00008dd8 <[^>]*> nop
++00008ddc <[^>]*> nop
++00008de0 <[^>]*> nop
++00008de4 <[^>]*> nop
++00008de8 <[^>]*> nop
++00008dec <[^>]*> nop
++00008df0 <[^>]*> nop
++00008df4 <[^>]*> nop
++00008df8 <[^>]*> nop
++00008dfc <[^>]*> nop
++00008e00 <[^>]*> nop
++00008e04 <[^>]*> nop
++00008e08 <[^>]*> nop
++00008e0c <[^>]*> nop
++00008e10 <[^>]*> nop
++00008e14 <[^>]*> nop
++00008e18 <[^>]*> nop
++00008e1c <[^>]*> nop
++00008e20 <[^>]*> nop
++00008e24 <[^>]*> nop
++00008e28 <[^>]*> nop
++00008e2c <[^>]*> nop
++00008e30 <[^>]*> nop
++00008e34 <[^>]*> nop
++00008e38 <[^>]*> nop
++00008e3c <[^>]*> nop
++00008e40 <[^>]*> nop
++00008e44 <[^>]*> nop
++00008e48 <[^>]*> nop
++00008e4c <[^>]*> nop
++00008e50 <[^>]*> nop
++00008e54 <[^>]*> nop
++00008e58 <[^>]*> nop
++00008e5c <[^>]*> nop
++00008e60 <[^>]*> nop
++00008e64 <[^>]*> nop
++00008e68 <[^>]*> nop
++00008e6c <[^>]*> nop
++00008e70 <[^>]*> nop
++00008e74 <[^>]*> nop
++00008e78 <[^>]*> nop
++00008e7c <[^>]*> nop
++00008e80 <[^>]*> nop
++00008e84 <[^>]*> nop
++00008e88 <[^>]*> nop
++00008e8c <[^>]*> nop
++00008e90 <[^>]*> nop
++00008e94 <[^>]*> nop
++00008e98 <[^>]*> nop
++00008e9c <[^>]*> nop
++00008ea0 <[^>]*> nop
++00008ea4 <[^>]*> nop
++00008ea8 <[^>]*> nop
++00008eac <[^>]*> nop
++00008eb0 <[^>]*> nop
++00008eb4 <[^>]*> nop
++00008eb8 <[^>]*> nop
++00008ebc <[^>]*> nop
++00008ec0 <[^>]*> nop
++00008ec4 <[^>]*> nop
++00008ec8 <[^>]*> nop
++00008ecc <[^>]*> nop
++00008ed0 <[^>]*> nop
++00008ed4 <[^>]*> nop
++00008ed8 <[^>]*> nop
++00008edc <[^>]*> nop
++00008ee0 <[^>]*> nop
++00008ee4 <[^>]*> nop
++00008ee8 <[^>]*> nop
++00008eec <[^>]*> nop
++00008ef0 <[^>]*> nop
++00008ef4 <[^>]*> nop
++00008ef8 <[^>]*> nop
++00008efc <[^>]*> nop
++00008f00 <[^>]*> nop
++00008f04 <[^>]*> nop
++00008f08 <[^>]*> nop
++00008f0c <[^>]*> nop
++00008f10 <[^>]*> nop
++00008f14 <[^>]*> nop
++00008f18 <[^>]*> nop
++00008f1c <[^>]*> nop
++00008f20 <[^>]*> nop
++00008f24 <[^>]*> nop
++00008f28 <[^>]*> nop
++00008f2c <[^>]*> nop
++00008f30 <[^>]*> nop
++00008f34 <[^>]*> nop
++00008f38 <[^>]*> nop
++00008f3c <[^>]*> nop
++00008f40 <[^>]*> nop
++00008f44 <[^>]*> nop
++00008f48 <[^>]*> nop
++00008f4c <[^>]*> nop
++00008f50 <[^>]*> nop
++00008f54 <[^>]*> nop
++00008f58 <[^>]*> nop
++00008f5c <[^>]*> nop
++00008f60 <[^>]*> nop
++00008f64 <[^>]*> nop
++00008f68 <[^>]*> nop
++00008f6c <[^>]*> nop
++00008f70 <[^>]*> nop
++00008f74 <[^>]*> nop
++00008f78 <[^>]*> nop
++00008f7c <[^>]*> nop
++00008f80 <[^>]*> nop
++00008f84 <[^>]*> nop
++00008f88 <[^>]*> nop
++00008f8c <[^>]*> nop
++00008f90 <[^>]*> nop
++00008f94 <[^>]*> nop
++00008f98 <[^>]*> nop
++00008f9c <[^>]*> nop
++00008fa0 <[^>]*> nop
++00008fa4 <[^>]*> nop
++00008fa8 <[^>]*> nop
++00008fac <[^>]*> nop
++00008fb0 <[^>]*> nop
++00008fb4 <[^>]*> nop
++00008fb8 <[^>]*> nop
++00008fbc <[^>]*> nop
++00008fc0 <[^>]*> nop
++00008fc4 <[^>]*> nop
++00008fc8 <[^>]*> nop
++00008fcc <[^>]*> nop
++00008fd0 <[^>]*> nop
++00008fd4 <[^>]*> nop
++00008fd8 <[^>]*> nop
++00008fdc <[^>]*> nop
++00008fe0 <[^>]*> nop
++00008fe4 <[^>]*> nop
++00008fe8 <[^>]*> nop
++00008fec <[^>]*> nop
++00008ff0 <[^>]*> nop
++00008ff4 <[^>]*> nop
++00008ff8 <[^>]*> nop
++00008ffc <[^>]*> nop
++00009000 <[^>]*> nop
++00009004 <[^>]*> nop
++00009008 <[^>]*> nop
++0000900c <[^>]*> nop
++00009010 <[^>]*> nop
++00009014 <[^>]*> nop
++00009018 <[^>]*> nop
++0000901c <[^>]*> nop
++00009020 <[^>]*> nop
++00009024 <[^>]*> nop
++00009028 <[^>]*> nop
++0000902c <[^>]*> nop
++00009030 <[^>]*> nop
++00009034 <[^>]*> nop
++00009038 <[^>]*> nop
++0000903c <[^>]*> nop
++00009040 <[^>]*> nop
++00009044 <[^>]*> nop
++00009048 <[^>]*> nop
++0000904c <[^>]*> nop
++00009050 <[^>]*> nop
++00009054 <[^>]*> nop
++00009058 <[^>]*> nop
++0000905c <[^>]*> nop
++00009060 <[^>]*> nop
++00009064 <[^>]*> nop
++00009068 <[^>]*> nop
++0000906c <[^>]*> nop
++00009070 <[^>]*> nop
++00009074 <[^>]*> nop
++00009078 <[^>]*> nop
++0000907c <[^>]*> nop
++00009080 <[^>]*> nop
++00009084 <[^>]*> nop
++00009088 <[^>]*> nop
++0000908c <[^>]*> nop
++00009090 <[^>]*> nop
++00009094 <[^>]*> nop
++00009098 <[^>]*> nop
++0000909c <[^>]*> nop
++000090a0 <[^>]*> nop
++000090a4 <[^>]*> nop
++000090a8 <[^>]*> nop
++000090ac <[^>]*> nop
++000090b0 <[^>]*> nop
++000090b4 <[^>]*> nop
++000090b8 <[^>]*> nop
++000090bc <[^>]*> nop
++000090c0 <[^>]*> nop
++000090c4 <[^>]*> nop
++000090c8 <[^>]*> nop
++000090cc <[^>]*> nop
++000090d0 <[^>]*> nop
++000090d4 <[^>]*> nop
++000090d8 <[^>]*> nop
++000090dc <[^>]*> nop
++000090e0 <[^>]*> nop
++000090e4 <[^>]*> nop
++000090e8 <[^>]*> nop
++000090ec <[^>]*> nop
++000090f0 <[^>]*> nop
++000090f4 <[^>]*> nop
++000090f8 <[^>]*> nop
++000090fc <[^>]*> nop
++00009100 <[^>]*> nop
++00009104 <[^>]*> nop
++00009108 <[^>]*> nop
++0000910c <[^>]*> nop
++00009110 <[^>]*> nop
++00009114 <[^>]*> nop
++00009118 <[^>]*> nop
++0000911c <[^>]*> nop
++00009120 <[^>]*> nop
++00009124 <[^>]*> nop
++00009128 <[^>]*> nop
++0000912c <[^>]*> nop
++00009130 <[^>]*> nop
++00009134 <[^>]*> nop
++00009138 <[^>]*> nop
++0000913c <[^>]*> nop
++00009140 <[^>]*> nop
++00009144 <[^>]*> nop
++00009148 <[^>]*> nop
++0000914c <[^>]*> nop
++00009150 <[^>]*> nop
++00009154 <[^>]*> nop
++00009158 <[^>]*> nop
++0000915c <[^>]*> nop
++00009160 <[^>]*> nop
++00009164 <[^>]*> nop
++00009168 <[^>]*> nop
++0000916c <[^>]*> nop
++00009170 <[^>]*> nop
++00009174 <[^>]*> nop
++00009178 <[^>]*> nop
++0000917c <[^>]*> nop
++00009180 <[^>]*> nop
++00009184 <[^>]*> nop
++00009188 <[^>]*> nop
++0000918c <[^>]*> nop
++00009190 <[^>]*> nop
++00009194 <[^>]*> nop
++00009198 <[^>]*> nop
++0000919c <[^>]*> nop
++000091a0 <[^>]*> nop
++000091a4 <[^>]*> nop
++000091a8 <[^>]*> nop
++000091ac <[^>]*> nop
++000091b0 <[^>]*> nop
++000091b4 <[^>]*> nop
++000091b8 <[^>]*> nop
++000091bc <[^>]*> nop
++000091c0 <[^>]*> nop
++000091c4 <[^>]*> nop
++000091c8 <[^>]*> nop
++000091cc <[^>]*> nop
++000091d0 <[^>]*> nop
++000091d4 <[^>]*> nop
++000091d8 <[^>]*> nop
++000091dc <[^>]*> nop
++000091e0 <[^>]*> nop
++000091e4 <[^>]*> nop
++000091e8 <[^>]*> nop
++000091ec <[^>]*> nop
++000091f0 <[^>]*> nop
++000091f4 <[^>]*> nop
++000091f8 <[^>]*> nop
++000091fc <[^>]*> nop
++00009200 <[^>]*> nop
++00009204 <[^>]*> nop
++00009208 <[^>]*> nop
++0000920c <[^>]*> nop
++00009210 <[^>]*> nop
++00009214 <[^>]*> nop
++00009218 <[^>]*> nop
++0000921c <[^>]*> nop
++00009220 <[^>]*> nop
++00009224 <[^>]*> nop
++00009228 <[^>]*> nop
++0000922c <[^>]*> nop
++00009230 <[^>]*> nop
++00009234 <[^>]*> nop
++00009238 <[^>]*> nop
++0000923c <[^>]*> nop
++00009240 <[^>]*> nop
++00009244 <[^>]*> nop
++00009248 <[^>]*> nop
++0000924c <[^>]*> nop
++00009250 <[^>]*> nop
++00009254 <[^>]*> nop
++00009258 <[^>]*> nop
++0000925c <[^>]*> nop
++00009260 <[^>]*> nop
++00009264 <[^>]*> nop
++00009268 <[^>]*> nop
++0000926c <[^>]*> nop
++00009270 <[^>]*> nop
++00009274 <[^>]*> nop
++00009278 <[^>]*> nop
++0000927c <[^>]*> nop
++00009280 <[^>]*> nop
++00009284 <[^>]*> nop
++00009288 <[^>]*> nop
++0000928c <[^>]*> nop
++00009290 <[^>]*> nop
++00009294 <[^>]*> nop
++00009298 <[^>]*> nop
++0000929c <[^>]*> nop
++000092a0 <[^>]*> nop
++000092a4 <[^>]*> nop
++000092a8 <[^>]*> nop
++000092ac <[^>]*> nop
++000092b0 <[^>]*> nop
++000092b4 <[^>]*> nop
++000092b8 <[^>]*> nop
++000092bc <[^>]*> nop
++000092c0 <[^>]*> nop
++000092c4 <[^>]*> nop
++000092c8 <[^>]*> nop
++000092cc <[^>]*> nop
++000092d0 <[^>]*> nop
++000092d4 <[^>]*> nop
++000092d8 <[^>]*> nop
++000092dc <[^>]*> nop
++000092e0 <[^>]*> nop
++000092e4 <[^>]*> nop
++000092e8 <[^>]*> nop
++000092ec <[^>]*> nop
++000092f0 <[^>]*> nop
++000092f4 <[^>]*> nop
++000092f8 <[^>]*> nop
++000092fc <[^>]*> nop
++00009300 <[^>]*> nop
++00009304 <[^>]*> nop
++00009308 <[^>]*> nop
++0000930c <[^>]*> nop
++00009310 <[^>]*> nop
++00009314 <[^>]*> nop
++00009318 <[^>]*> nop
++0000931c <[^>]*> nop
++00009320 <[^>]*> nop
++00009324 <[^>]*> nop
++00009328 <[^>]*> nop
++0000932c <[^>]*> nop
++00009330 <[^>]*> nop
++00009334 <[^>]*> nop
++00009338 <[^>]*> nop
++0000933c <[^>]*> nop
++00009340 <[^>]*> nop
++00009344 <[^>]*> nop
++00009348 <[^>]*> nop
++0000934c <[^>]*> nop
++00009350 <[^>]*> nop
++00009354 <[^>]*> nop
++00009358 <[^>]*> nop
++0000935c <[^>]*> nop
++00009360 <[^>]*> nop
++00009364 <[^>]*> nop
++00009368 <[^>]*> nop
++0000936c <[^>]*> nop
++00009370 <[^>]*> nop
++00009374 <[^>]*> nop
++00009378 <[^>]*> nop
++0000937c <[^>]*> nop
++00009380 <[^>]*> nop
++00009384 <[^>]*> nop
++00009388 <[^>]*> nop
++0000938c <[^>]*> nop
++00009390 <[^>]*> nop
++00009394 <[^>]*> nop
++00009398 <[^>]*> nop
++0000939c <[^>]*> nop
++000093a0 <[^>]*> nop
++000093a4 <[^>]*> nop
++000093a8 <[^>]*> nop
++000093ac <[^>]*> nop
++000093b0 <[^>]*> nop
++000093b4 <[^>]*> nop
++000093b8 <[^>]*> nop
++000093bc <[^>]*> nop
++000093c0 <[^>]*> nop
++000093c4 <[^>]*> nop
++000093c8 <[^>]*> nop
++000093cc <[^>]*> nop
++000093d0 <[^>]*> nop
++000093d4 <[^>]*> nop
++000093d8 <[^>]*> nop
++000093dc <[^>]*> nop
++000093e0 <[^>]*> nop
++000093e4 <[^>]*> nop
++000093e8 <[^>]*> nop
++000093ec <[^>]*> nop
++000093f0 <[^>]*> nop
++000093f4 <[^>]*> nop
++000093f8 <[^>]*> nop
++000093fc <[^>]*> nop
++00009400 <[^>]*> nop
++00009404 <[^>]*> nop
++00009408 <[^>]*> nop
++0000940c <[^>]*> nop
++00009410 <[^>]*> nop
++00009414 <[^>]*> nop
++00009418 <[^>]*> nop
++0000941c <[^>]*> nop
++00009420 <[^>]*> nop
++00009424 <[^>]*> nop
++00009428 <[^>]*> nop
++0000942c <[^>]*> nop
++00009430 <[^>]*> nop
++00009434 <[^>]*> nop
++00009438 <[^>]*> nop
++0000943c <[^>]*> nop
++00009440 <[^>]*> nop
++00009444 <[^>]*> nop
++00009448 <[^>]*> nop
++0000944c <[^>]*> nop
++00009450 <[^>]*> nop
++00009454 <[^>]*> nop
++00009458 <[^>]*> nop
++0000945c <[^>]*> nop
++00009460 <[^>]*> nop
++00009464 <[^>]*> nop
++00009468 <[^>]*> nop
++0000946c <[^>]*> nop
++00009470 <[^>]*> nop
++00009474 <[^>]*> nop
++00009478 <[^>]*> nop
++0000947c <[^>]*> nop
++00009480 <[^>]*> nop
++00009484 <[^>]*> nop
++00009488 <[^>]*> nop
++0000948c <[^>]*> nop
++00009490 <[^>]*> nop
++00009494 <[^>]*> nop
++00009498 <[^>]*> nop
++0000949c <[^>]*> nop
++000094a0 <[^>]*> nop
++000094a4 <[^>]*> nop
++000094a8 <[^>]*> nop
++000094ac <[^>]*> nop
++000094b0 <[^>]*> nop
++000094b4 <[^>]*> nop
++000094b8 <[^>]*> nop
++000094bc <[^>]*> nop
++000094c0 <[^>]*> nop
++000094c4 <[^>]*> nop
++000094c8 <[^>]*> nop
++000094cc <[^>]*> nop
++000094d0 <[^>]*> nop
++000094d4 <[^>]*> nop
++000094d8 <[^>]*> nop
++000094dc <[^>]*> nop
++000094e0 <[^>]*> nop
++000094e4 <[^>]*> nop
++000094e8 <[^>]*> nop
++000094ec <[^>]*> nop
++000094f0 <[^>]*> nop
++000094f4 <[^>]*> nop
++000094f8 <[^>]*> nop
++000094fc <[^>]*> nop
++00009500 <[^>]*> nop
++00009504 <[^>]*> nop
++00009508 <[^>]*> nop
++0000950c <[^>]*> nop
++00009510 <[^>]*> nop
++00009514 <[^>]*> nop
++00009518 <[^>]*> nop
++0000951c <[^>]*> nop
++00009520 <[^>]*> nop
++00009524 <[^>]*> nop
++00009528 <[^>]*> nop
++0000952c <[^>]*> nop
++00009530 <[^>]*> nop
++00009534 <[^>]*> nop
++00009538 <[^>]*> nop
++0000953c <[^>]*> nop
++00009540 <[^>]*> nop
++00009544 <[^>]*> nop
++00009548 <[^>]*> nop
++0000954c <[^>]*> nop
++00009550 <[^>]*> nop
++00009554 <[^>]*> nop
++00009558 <[^>]*> nop
++0000955c <[^>]*> nop
++00009560 <[^>]*> nop
++00009564 <[^>]*> nop
++00009568 <[^>]*> nop
++0000956c <[^>]*> nop
++00009570 <[^>]*> nop
++00009574 <[^>]*> nop
++00009578 <[^>]*> nop
++0000957c <[^>]*> nop
++00009580 <[^>]*> nop
++00009584 <[^>]*> nop
++00009588 <[^>]*> nop
++0000958c <[^>]*> nop
++00009590 <[^>]*> nop
++00009594 <[^>]*> nop
++00009598 <[^>]*> nop
++0000959c <[^>]*> nop
++000095a0 <[^>]*> nop
++000095a4 <[^>]*> nop
++000095a8 <[^>]*> nop
++000095ac <[^>]*> nop
++000095b0 <[^>]*> nop
++000095b4 <[^>]*> nop
++000095b8 <[^>]*> nop
++000095bc <[^>]*> nop
++000095c0 <[^>]*> nop
++000095c4 <[^>]*> nop
++000095c8 <[^>]*> nop
++000095cc <[^>]*> nop
++000095d0 <[^>]*> nop
++000095d4 <[^>]*> nop
++000095d8 <[^>]*> nop
++000095dc <[^>]*> nop
++000095e0 <[^>]*> nop
++000095e4 <[^>]*> nop
++000095e8 <[^>]*> nop
++000095ec <[^>]*> nop
++000095f0 <[^>]*> nop
++000095f4 <[^>]*> nop
++000095f8 <[^>]*> nop
++000095fc <[^>]*> nop
++00009600 <[^>]*> nop
++00009604 <[^>]*> nop
++00009608 <[^>]*> nop
++0000960c <[^>]*> nop
++00009610 <[^>]*> nop
++00009614 <[^>]*> nop
++00009618 <[^>]*> nop
++0000961c <[^>]*> nop
++00009620 <[^>]*> nop
++00009624 <[^>]*> nop
++00009628 <[^>]*> nop
++0000962c <[^>]*> nop
++00009630 <[^>]*> nop
++00009634 <[^>]*> nop
++00009638 <[^>]*> nop
++0000963c <[^>]*> nop
++00009640 <[^>]*> nop
++00009644 <[^>]*> nop
++00009648 <[^>]*> nop
++0000964c <[^>]*> nop
++00009650 <[^>]*> nop
++00009654 <[^>]*> nop
++00009658 <[^>]*> nop
++0000965c <[^>]*> nop
++00009660 <[^>]*> nop
++00009664 <[^>]*> nop
++00009668 <[^>]*> nop
++0000966c <[^>]*> nop
++00009670 <[^>]*> nop
++00009674 <[^>]*> nop
++00009678 <[^>]*> nop
++0000967c <[^>]*> nop
++00009680 <[^>]*> nop
++00009684 <[^>]*> nop
++00009688 <[^>]*> nop
++0000968c <[^>]*> nop
++00009690 <[^>]*> nop
++00009694 <[^>]*> nop
++00009698 <[^>]*> nop
++0000969c <[^>]*> nop
++000096a0 <[^>]*> nop
++000096a4 <[^>]*> nop
++000096a8 <[^>]*> nop
++000096ac <[^>]*> nop
++000096b0 <[^>]*> nop
++000096b4 <[^>]*> nop
++000096b8 <[^>]*> nop
++000096bc <[^>]*> nop
++000096c0 <[^>]*> nop
++000096c4 <[^>]*> nop
++000096c8 <[^>]*> nop
++000096cc <[^>]*> nop
++000096d0 <[^>]*> nop
++000096d4 <[^>]*> nop
++000096d8 <[^>]*> nop
++000096dc <[^>]*> nop
++000096e0 <[^>]*> nop
++000096e4 <[^>]*> nop
++000096e8 <[^>]*> nop
++000096ec <[^>]*> nop
++000096f0 <[^>]*> nop
++000096f4 <[^>]*> nop
++000096f8 <[^>]*> nop
++000096fc <[^>]*> nop
++00009700 <[^>]*> nop
++00009704 <[^>]*> nop
++00009708 <[^>]*> nop
++0000970c <[^>]*> nop
++00009710 <[^>]*> nop
++00009714 <[^>]*> nop
++00009718 <[^>]*> nop
++0000971c <[^>]*> nop
++00009720 <[^>]*> nop
++00009724 <[^>]*> nop
++00009728 <[^>]*> nop
++0000972c <[^>]*> nop
++00009730 <[^>]*> nop
++00009734 <[^>]*> nop
++00009738 <[^>]*> nop
++0000973c <[^>]*> nop
++00009740 <[^>]*> nop
++00009744 <[^>]*> nop
++00009748 <[^>]*> nop
++0000974c <[^>]*> nop
++00009750 <[^>]*> nop
++00009754 <[^>]*> nop
++00009758 <[^>]*> nop
++0000975c <[^>]*> nop
++00009760 <[^>]*> nop
++00009764 <[^>]*> nop
++00009768 <[^>]*> nop
++0000976c <[^>]*> nop
++00009770 <[^>]*> nop
++00009774 <[^>]*> nop
++00009778 <[^>]*> nop
++0000977c <[^>]*> nop
++00009780 <[^>]*> nop
++00009784 <[^>]*> nop
++00009788 <[^>]*> nop
++0000978c <[^>]*> nop
++00009790 <[^>]*> nop
++00009794 <[^>]*> nop
++00009798 <[^>]*> nop
++0000979c <[^>]*> nop
++000097a0 <[^>]*> nop
++000097a4 <[^>]*> nop
++000097a8 <[^>]*> nop
++000097ac <[^>]*> nop
++000097b0 <[^>]*> nop
++000097b4 <[^>]*> nop
++000097b8 <[^>]*> nop
++000097bc <[^>]*> nop
++000097c0 <[^>]*> nop
++000097c4 <[^>]*> nop
++000097c8 <[^>]*> nop
++000097cc <[^>]*> nop
++000097d0 <[^>]*> nop
++000097d4 <[^>]*> nop
++000097d8 <[^>]*> nop
++000097dc <[^>]*> nop
++000097e0 <[^>]*> nop
++000097e4 <[^>]*> nop
++000097e8 <[^>]*> nop
++000097ec <[^>]*> nop
++000097f0 <[^>]*> nop
++000097f4 <[^>]*> nop
++000097f8 <[^>]*> nop
++000097fc <[^>]*> nop
++00009800 <[^>]*> nop
++00009804 <[^>]*> nop
++00009808 <[^>]*> nop
++0000980c <[^>]*> nop
++00009810 <[^>]*> nop
++00009814 <[^>]*> nop
++00009818 <[^>]*> nop
++0000981c <[^>]*> nop
++00009820 <[^>]*> nop
++00009824 <[^>]*> nop
++00009828 <[^>]*> nop
++0000982c <[^>]*> nop
++00009830 <[^>]*> nop
++00009834 <[^>]*> nop
++00009838 <[^>]*> nop
++0000983c <[^>]*> nop
++00009840 <[^>]*> nop
++00009844 <[^>]*> nop
++00009848 <[^>]*> nop
++0000984c <[^>]*> nop
++00009850 <[^>]*> nop
++00009854 <[^>]*> nop
++00009858 <[^>]*> nop
++0000985c <[^>]*> nop
++00009860 <[^>]*> nop
++00009864 <[^>]*> nop
++00009868 <[^>]*> nop
++0000986c <[^>]*> nop
++00009870 <[^>]*> nop
++00009874 <[^>]*> nop
++00009878 <[^>]*> nop
++0000987c <[^>]*> nop
++00009880 <[^>]*> nop
++00009884 <[^>]*> nop
++00009888 <[^>]*> nop
++0000988c <[^>]*> nop
++00009890 <[^>]*> nop
++00009894 <[^>]*> nop
++00009898 <[^>]*> nop
++0000989c <[^>]*> nop
++000098a0 <[^>]*> nop
++000098a4 <[^>]*> nop
++000098a8 <[^>]*> nop
++000098ac <[^>]*> nop
++000098b0 <[^>]*> nop
++000098b4 <[^>]*> nop
++000098b8 <[^>]*> nop
++000098bc <[^>]*> nop
++000098c0 <[^>]*> nop
++000098c4 <[^>]*> nop
++000098c8 <[^>]*> nop
++000098cc <[^>]*> nop
++000098d0 <[^>]*> nop
++000098d4 <[^>]*> nop
++000098d8 <[^>]*> nop
++000098dc <[^>]*> nop
++000098e0 <[^>]*> nop
++000098e4 <[^>]*> nop
++000098e8 <[^>]*> nop
++000098ec <[^>]*> nop
++000098f0 <[^>]*> nop
++000098f4 <[^>]*> nop
++000098f8 <[^>]*> nop
++000098fc <[^>]*> nop
++00009900 <[^>]*> nop
++00009904 <[^>]*> nop
++00009908 <[^>]*> nop
++0000990c <[^>]*> nop
++00009910 <[^>]*> nop
++00009914 <[^>]*> nop
++00009918 <[^>]*> nop
++0000991c <[^>]*> nop
++00009920 <[^>]*> nop
++00009924 <[^>]*> nop
++00009928 <[^>]*> nop
++0000992c <[^>]*> nop
++00009930 <[^>]*> nop
++00009934 <[^>]*> nop
++00009938 <[^>]*> nop
++0000993c <[^>]*> nop
++00009940 <[^>]*> nop
++00009944 <[^>]*> nop
++00009948 <[^>]*> nop
++0000994c <[^>]*> nop
++00009950 <[^>]*> nop
++00009954 <[^>]*> nop
++00009958 <[^>]*> nop
++0000995c <[^>]*> nop
++00009960 <[^>]*> nop
++00009964 <[^>]*> nop
++00009968 <[^>]*> nop
++0000996c <[^>]*> nop
++00009970 <[^>]*> nop
++00009974 <[^>]*> nop
++00009978 <[^>]*> nop
++0000997c <[^>]*> nop
++00009980 <[^>]*> nop
++00009984 <[^>]*> nop
++00009988 <[^>]*> nop
++0000998c <[^>]*> nop
++00009990 <[^>]*> nop
++00009994 <[^>]*> nop
++00009998 <[^>]*> nop
++0000999c <[^>]*> nop
++000099a0 <[^>]*> nop
++000099a4 <[^>]*> nop
++000099a8 <[^>]*> nop
++000099ac <[^>]*> nop
++000099b0 <[^>]*> nop
++000099b4 <[^>]*> nop
++000099b8 <[^>]*> nop
++000099bc <[^>]*> nop
++000099c0 <[^>]*> nop
++000099c4 <[^>]*> nop
++000099c8 <[^>]*> nop
++000099cc <[^>]*> nop
++000099d0 <[^>]*> nop
++000099d4 <[^>]*> nop
++000099d8 <[^>]*> nop
++000099dc <[^>]*> nop
++000099e0 <[^>]*> nop
++000099e4 <[^>]*> nop
++000099e8 <[^>]*> nop
++000099ec <[^>]*> nop
++000099f0 <[^>]*> nop
++000099f4 <[^>]*> nop
++000099f8 <[^>]*> nop
++000099fc <[^>]*> nop
++00009a00 <[^>]*> nop
++00009a04 <[^>]*> nop
++00009a08 <[^>]*> nop
++00009a0c <[^>]*> nop
++00009a10 <[^>]*> nop
++00009a14 <[^>]*> nop
++00009a18 <[^>]*> nop
++00009a1c <[^>]*> nop
++00009a20 <[^>]*> nop
++00009a24 <[^>]*> nop
++00009a28 <[^>]*> nop
++00009a2c <[^>]*> nop
++00009a30 <[^>]*> nop
++00009a34 <[^>]*> nop
++00009a38 <[^>]*> nop
++00009a3c <[^>]*> nop
++00009a40 <[^>]*> nop
++00009a44 <[^>]*> nop
++00009a48 <[^>]*> nop
++00009a4c <[^>]*> nop
++00009a50 <[^>]*> nop
++00009a54 <[^>]*> nop
++00009a58 <[^>]*> nop
++00009a5c <[^>]*> nop
++00009a60 <[^>]*> nop
++00009a64 <[^>]*> nop
++00009a68 <[^>]*> nop
++00009a6c <[^>]*> nop
++00009a70 <[^>]*> nop
++00009a74 <[^>]*> nop
++00009a78 <[^>]*> nop
++00009a7c <[^>]*> nop
++00009a80 <[^>]*> nop
++00009a84 <[^>]*> nop
++00009a88 <[^>]*> nop
++00009a8c <[^>]*> nop
++00009a90 <[^>]*> nop
++00009a94 <[^>]*> nop
++00009a98 <[^>]*> nop
++00009a9c <[^>]*> nop
++00009aa0 <[^>]*> nop
++00009aa4 <[^>]*> nop
++00009aa8 <[^>]*> nop
++00009aac <[^>]*> nop
++00009ab0 <[^>]*> nop
++00009ab4 <[^>]*> nop
++00009ab8 <[^>]*> nop
++00009abc <[^>]*> nop
++00009ac0 <[^>]*> nop
++00009ac4 <[^>]*> nop
++00009ac8 <[^>]*> nop
++00009acc <[^>]*> nop
++00009ad0 <[^>]*> nop
++00009ad4 <[^>]*> nop
++00009ad8 <[^>]*> nop
++00009adc <[^>]*> nop
++00009ae0 <[^>]*> nop
++00009ae4 <[^>]*> nop
++00009ae8 <[^>]*> nop
++00009aec <[^>]*> nop
++00009af0 <[^>]*> nop
++00009af4 <[^>]*> nop
++00009af8 <[^>]*> nop
++00009afc <[^>]*> nop
++00009b00 <[^>]*> nop
++00009b04 <[^>]*> nop
++00009b08 <[^>]*> nop
++00009b0c <[^>]*> nop
++00009b10 <[^>]*> nop
++00009b14 <[^>]*> nop
++00009b18 <[^>]*> nop
++00009b1c <[^>]*> nop
++00009b20 <[^>]*> nop
++00009b24 <[^>]*> nop
++00009b28 <[^>]*> nop
++00009b2c <[^>]*> nop
++00009b30 <[^>]*> nop
++00009b34 <[^>]*> nop
++00009b38 <[^>]*> nop
++00009b3c <[^>]*> nop
++00009b40 <[^>]*> nop
++00009b44 <[^>]*> nop
++00009b48 <[^>]*> nop
++00009b4c <[^>]*> nop
++00009b50 <[^>]*> nop
++00009b54 <[^>]*> nop
++00009b58 <[^>]*> nop
++00009b5c <[^>]*> nop
++00009b60 <[^>]*> nop
++00009b64 <[^>]*> nop
++00009b68 <[^>]*> nop
++00009b6c <[^>]*> nop
++00009b70 <[^>]*> nop
++00009b74 <[^>]*> nop
++00009b78 <[^>]*> nop
++00009b7c <[^>]*> nop
++00009b80 <[^>]*> nop
++00009b84 <[^>]*> nop
++00009b88 <[^>]*> nop
++00009b8c <[^>]*> nop
++00009b90 <[^>]*> nop
++00009b94 <[^>]*> nop
++00009b98 <[^>]*> nop
++00009b9c <[^>]*> nop
++00009ba0 <[^>]*> nop
++00009ba4 <[^>]*> nop
++00009ba8 <[^>]*> nop
++00009bac <[^>]*> nop
++00009bb0 <[^>]*> nop
++00009bb4 <[^>]*> nop
++00009bb8 <[^>]*> nop
++00009bbc <[^>]*> nop
++00009bc0 <[^>]*> nop
++00009bc4 <[^>]*> nop
++00009bc8 <[^>]*> nop
++00009bcc <[^>]*> nop
++00009bd0 <[^>]*> nop
++00009bd4 <[^>]*> nop
++00009bd8 <[^>]*> nop
++00009bdc <[^>]*> nop
++00009be0 <[^>]*> nop
++00009be4 <[^>]*> nop
++00009be8 <[^>]*> nop
++00009bec <[^>]*> nop
++00009bf0 <[^>]*> nop
++00009bf4 <[^>]*> nop
++00009bf8 <[^>]*> nop
++00009bfc <[^>]*> nop
++00009c00 <[^>]*> nop
++00009c04 <[^>]*> nop
++00009c08 <[^>]*> nop
++00009c0c <[^>]*> nop
++00009c10 <[^>]*> nop
++00009c14 <[^>]*> nop
++00009c18 <[^>]*> nop
++00009c1c <[^>]*> nop
++00009c20 <[^>]*> nop
++00009c24 <[^>]*> nop
++00009c28 <[^>]*> nop
++00009c2c <[^>]*> nop
++00009c30 <[^>]*> nop
++00009c34 <[^>]*> nop
++00009c38 <[^>]*> nop
++00009c3c <[^>]*> nop
++00009c40 <[^>]*> nop
++00009c44 <[^>]*> nop
++00009c48 <[^>]*> nop
++00009c4c <[^>]*> nop
++00009c50 <[^>]*> nop
++00009c54 <[^>]*> nop
++00009c58 <[^>]*> nop
++00009c5c <[^>]*> nop
++00009c60 <[^>]*> nop
++00009c64 <[^>]*> nop
++00009c68 <[^>]*> nop
++00009c6c <[^>]*> nop
++00009c70 <[^>]*> nop
++00009c74 <[^>]*> nop
++00009c78 <[^>]*> nop
++00009c7c <[^>]*> nop
++00009c80 <[^>]*> nop
++00009c84 <[^>]*> nop
++00009c88 <[^>]*> nop
++00009c8c <[^>]*> nop
++00009c90 <[^>]*> nop
++00009c94 <[^>]*> nop
++00009c98 <[^>]*> nop
++00009c9c <[^>]*> nop
++00009ca0 <[^>]*> nop
++00009ca4 <[^>]*> nop
++00009ca8 <[^>]*> nop
++00009cac <[^>]*> nop
++00009cb0 <[^>]*> nop
++00009cb4 <[^>]*> nop
++00009cb8 <[^>]*> nop
++00009cbc <[^>]*> nop
++00009cc0 <[^>]*> nop
++00009cc4 <[^>]*> nop
++00009cc8 <[^>]*> nop
++00009ccc <[^>]*> nop
++00009cd0 <[^>]*> nop
++00009cd4 <[^>]*> nop
++00009cd8 <[^>]*> nop
++00009cdc <[^>]*> nop
++00009ce0 <[^>]*> nop
++00009ce4 <[^>]*> nop
++00009ce8 <[^>]*> nop
++00009cec <[^>]*> nop
++00009cf0 <[^>]*> nop
++00009cf4 <[^>]*> nop
++00009cf8 <[^>]*> nop
++00009cfc <[^>]*> nop
++00009d00 <[^>]*> nop
++00009d04 <[^>]*> nop
++00009d08 <[^>]*> nop
++00009d0c <[^>]*> nop
++00009d10 <[^>]*> nop
++00009d14 <[^>]*> nop
++00009d18 <[^>]*> nop
++00009d1c <[^>]*> nop
++00009d20 <[^>]*> nop
++00009d24 <[^>]*> nop
++00009d28 <[^>]*> nop
++00009d2c <[^>]*> nop
++00009d30 <[^>]*> nop
++00009d34 <[^>]*> nop
++00009d38 <[^>]*> nop
++00009d3c <[^>]*> nop
++00009d40 <[^>]*> nop
++00009d44 <[^>]*> nop
++00009d48 <[^>]*> nop
++00009d4c <[^>]*> nop
++00009d50 <[^>]*> nop
++00009d54 <[^>]*> nop
++00009d58 <[^>]*> nop
++00009d5c <[^>]*> nop
++00009d60 <[^>]*> nop
++00009d64 <[^>]*> nop
++00009d68 <[^>]*> nop
++00009d6c <[^>]*> nop
++00009d70 <[^>]*> nop
++00009d74 <[^>]*> nop
++00009d78 <[^>]*> nop
++00009d7c <[^>]*> nop
++00009d80 <[^>]*> nop
++00009d84 <[^>]*> nop
++00009d88 <[^>]*> nop
++00009d8c <[^>]*> nop
++00009d90 <[^>]*> nop
++00009d94 <[^>]*> nop
++00009d98 <[^>]*> nop
++00009d9c <[^>]*> nop
++00009da0 <[^>]*> nop
++00009da4 <[^>]*> nop
++00009da8 <[^>]*> nop
++00009dac <[^>]*> nop
++00009db0 <[^>]*> nop
++00009db4 <[^>]*> nop
++00009db8 <[^>]*> nop
++00009dbc <[^>]*> nop
++00009dc0 <[^>]*> nop
++00009dc4 <[^>]*> nop
++00009dc8 <[^>]*> nop
++00009dcc <[^>]*> nop
++00009dd0 <[^>]*> nop
++00009dd4 <[^>]*> nop
++00009dd8 <[^>]*> nop
++00009ddc <[^>]*> nop
++00009de0 <[^>]*> nop
++00009de4 <[^>]*> nop
++00009de8 <[^>]*> nop
++00009dec <[^>]*> nop
++00009df0 <[^>]*> nop
++00009df4 <[^>]*> nop
++00009df8 <[^>]*> nop
++00009dfc <[^>]*> nop
++00009e00 <[^>]*> nop
++00009e04 <[^>]*> nop
++00009e08 <[^>]*> nop
++00009e0c <[^>]*> nop
++00009e10 <[^>]*> nop
++00009e14 <[^>]*> nop
++00009e18 <[^>]*> nop
++00009e1c <[^>]*> nop
++00009e20 <[^>]*> nop
++00009e24 <[^>]*> nop
++00009e28 <[^>]*> nop
++00009e2c <[^>]*> nop
++00009e30 <[^>]*> nop
++00009e34 <[^>]*> nop
++00009e38 <[^>]*> nop
++00009e3c <[^>]*> nop
++00009e40 <[^>]*> nop
++00009e44 <[^>]*> nop
++00009e48 <[^>]*> nop
++00009e4c <[^>]*> nop
++00009e50 <[^>]*> nop
++00009e54 <[^>]*> nop
++00009e58 <[^>]*> nop
++00009e5c <[^>]*> nop
++00009e60 <[^>]*> nop
++00009e64 <[^>]*> nop
++00009e68 <[^>]*> nop
++00009e6c <[^>]*> nop
++00009e70 <[^>]*> nop
++00009e74 <[^>]*> nop
++00009e78 <[^>]*> nop
++00009e7c <[^>]*> nop
++00009e80 <[^>]*> nop
++00009e84 <[^>]*> nop
++00009e88 <[^>]*> nop
++00009e8c <[^>]*> nop
++00009e90 <[^>]*> nop
++00009e94 <[^>]*> nop
++00009e98 <[^>]*> nop
++00009e9c <[^>]*> nop
++00009ea0 <[^>]*> nop
++00009ea4 <[^>]*> nop
++00009ea8 <[^>]*> nop
++00009eac <[^>]*> nop
++00009eb0 <[^>]*> nop
++00009eb4 <[^>]*> nop
++00009eb8 <[^>]*> nop
++00009ebc <[^>]*> nop
++00009ec0 <[^>]*> nop
++00009ec4 <[^>]*> nop
++00009ec8 <[^>]*> nop
++00009ecc <[^>]*> nop
++00009ed0 <[^>]*> nop
++00009ed4 <[^>]*> nop
++00009ed8 <[^>]*> nop
++00009edc <[^>]*> nop
++00009ee0 <[^>]*> nop
++00009ee4 <[^>]*> nop
++00009ee8 <[^>]*> nop
++00009eec <[^>]*> nop
++00009ef0 <[^>]*> nop
++00009ef4 <[^>]*> nop
++00009ef8 <[^>]*> nop
++00009efc <[^>]*> nop
++00009f00 <[^>]*> nop
++00009f04 <[^>]*> nop
++00009f08 <[^>]*> nop
++00009f0c <[^>]*> nop
++00009f10 <[^>]*> nop
++00009f14 <[^>]*> nop
++00009f18 <[^>]*> nop
++00009f1c <[^>]*> nop
++00009f20 <[^>]*> nop
++00009f24 <[^>]*> nop
++00009f28 <[^>]*> nop
++00009f2c <[^>]*> nop
++00009f30 <[^>]*> nop
++00009f34 <[^>]*> nop
++00009f38 <[^>]*> nop
++00009f3c <[^>]*> nop
++00009f40 <[^>]*> nop
++00009f44 <[^>]*> nop
++00009f48 <[^>]*> nop
++00009f4c <[^>]*> nop
++00009f50 <[^>]*> nop
++00009f54 <[^>]*> nop
++00009f58 <[^>]*> nop
++00009f5c <[^>]*> nop
++00009f60 <[^>]*> nop
++00009f64 <[^>]*> nop
++00009f68 <[^>]*> nop
++00009f6c <[^>]*> nop
++00009f70 <[^>]*> nop
++00009f74 <[^>]*> nop
++00009f78 <[^>]*> nop
++00009f7c <[^>]*> nop
++00009f80 <[^>]*> nop
++00009f84 <[^>]*> nop
++00009f88 <[^>]*> nop
++00009f8c <[^>]*> nop
++00009f90 <[^>]*> nop
++00009f94 <[^>]*> nop
++00009f98 <[^>]*> nop
++00009f9c <[^>]*> nop
++00009fa0 <[^>]*> nop
++00009fa4 <[^>]*> nop
++00009fa8 <[^>]*> nop
++00009fac <[^>]*> nop
++00009fb0 <[^>]*> nop
++00009fb4 <[^>]*> nop
++00009fb8 <[^>]*> nop
++00009fbc <[^>]*> nop
++00009fc0 <[^>]*> nop
++00009fc4 <[^>]*> nop
++00009fc8 <[^>]*> nop
++00009fcc <[^>]*> nop
++00009fd0 <[^>]*> nop
++00009fd4 <[^>]*> nop
++00009fd8 <[^>]*> nop
++00009fdc <[^>]*> nop
++00009fe0 <[^>]*> nop
++00009fe4 <[^>]*> nop
++00009fe8 <[^>]*> nop
++00009fec <[^>]*> nop
++00009ff0 <[^>]*> nop
++00009ff4 <[^>]*> nop
++00009ff8 <[^>]*> nop
++00009ffc <[^>]*> nop
++0000a000 <[^>]*> nop
++0000a004 <[^>]*> nop
++0000a008 <[^>]*> nop
++0000a00c <[^>]*> nop
++0000a010 <[^>]*> nop
++0000a014 <[^>]*> nop
++0000a018 <[^>]*> nop
++0000a01c <[^>]*> nop
++0000a020 <[^>]*> nop
++0000a024 <[^>]*> nop
++0000a028 <[^>]*> nop
++0000a02c <[^>]*> nop
++0000a030 <[^>]*> nop
++0000a034 <[^>]*> nop
++0000a038 <[^>]*> nop
++0000a03c <[^>]*> nop
++0000a040 <[^>]*> nop
++0000a044 <[^>]*> nop
++0000a048 <[^>]*> nop
++0000a04c <[^>]*> nop
++0000a050 <[^>]*> nop
++0000a054 <[^>]*> nop
++0000a058 <[^>]*> nop
++0000a05c <[^>]*> nop
++0000a060 <[^>]*> nop
++0000a064 <[^>]*> nop
++0000a068 <[^>]*> nop
++0000a06c <[^>]*> nop
++0000a070 <[^>]*> nop
++0000a074 <[^>]*> nop
++0000a078 <[^>]*> nop
++0000a07c <[^>]*> nop
++0000a080 <[^>]*> nop
++0000a084 <[^>]*> nop
++0000a088 <[^>]*> nop
++0000a08c <[^>]*> nop
++0000a090 <[^>]*> nop
++0000a094 <[^>]*> nop
++0000a098 <[^>]*> nop
++0000a09c <[^>]*> nop
++0000a0a0 <[^>]*> nop
++0000a0a4 <[^>]*> nop
++0000a0a8 <[^>]*> nop
++0000a0ac <[^>]*> nop
++0000a0b0 <[^>]*> nop
++0000a0b4 <[^>]*> nop
++0000a0b8 <[^>]*> nop
++0000a0bc <[^>]*> nop
++0000a0c0 <[^>]*> nop
++0000a0c4 <[^>]*> nop
++0000a0c8 <[^>]*> nop
++0000a0cc <[^>]*> nop
++0000a0d0 <[^>]*> nop
++0000a0d4 <[^>]*> nop
++0000a0d8 <[^>]*> nop
++0000a0dc <[^>]*> nop
++0000a0e0 <[^>]*> nop
++0000a0e4 <[^>]*> nop
++0000a0e8 <[^>]*> nop
++0000a0ec <[^>]*> nop
++0000a0f0 <[^>]*> nop
++0000a0f4 <[^>]*> nop
++0000a0f8 <[^>]*> nop
++0000a0fc <[^>]*> nop
++0000a100 <[^>]*> nop
++0000a104 <[^>]*> nop
++0000a108 <[^>]*> nop
++0000a10c <[^>]*> nop
++0000a110 <[^>]*> nop
++0000a114 <[^>]*> nop
++0000a118 <[^>]*> nop
++0000a11c <[^>]*> nop
++0000a120 <[^>]*> nop
++0000a124 <[^>]*> nop
++0000a128 <[^>]*> nop
++0000a12c <[^>]*> nop
++0000a130 <[^>]*> nop
++0000a134 <[^>]*> nop
++0000a138 <[^>]*> nop
++0000a13c <[^>]*> nop
++0000a140 <[^>]*> nop
++0000a144 <[^>]*> nop
++0000a148 <[^>]*> nop
++0000a14c <[^>]*> nop
++0000a150 <[^>]*> nop
++0000a154 <[^>]*> nop
++0000a158 <[^>]*> nop
++0000a15c <[^>]*> nop
++0000a160 <[^>]*> nop
++0000a164 <[^>]*> nop
++0000a168 <[^>]*> nop
++0000a16c <[^>]*> nop
++0000a170 <[^>]*> nop
++0000a174 <[^>]*> nop
++0000a178 <[^>]*> nop
++0000a17c <[^>]*> nop
++0000a180 <[^>]*> nop
++0000a184 <[^>]*> nop
++0000a188 <[^>]*> nop
++0000a18c <[^>]*> nop
++0000a190 <[^>]*> nop
++0000a194 <[^>]*> nop
++0000a198 <[^>]*> nop
++0000a19c <[^>]*> nop
++0000a1a0 <[^>]*> nop
++0000a1a4 <[^>]*> nop
++0000a1a8 <[^>]*> nop
++0000a1ac <[^>]*> nop
++0000a1b0 <[^>]*> nop
++0000a1b4 <[^>]*> nop
++0000a1b8 <[^>]*> nop
++0000a1bc <[^>]*> nop
++0000a1c0 <[^>]*> nop
++0000a1c4 <[^>]*> nop
++0000a1c8 <[^>]*> nop
++0000a1cc <[^>]*> nop
++0000a1d0 <[^>]*> nop
++0000a1d4 <[^>]*> nop
++0000a1d8 <[^>]*> nop
++0000a1dc <[^>]*> nop
++0000a1e0 <[^>]*> nop
++0000a1e4 <[^>]*> nop
++0000a1e8 <[^>]*> nop
++0000a1ec <[^>]*> nop
++0000a1f0 <[^>]*> nop
++0000a1f4 <[^>]*> nop
++0000a1f8 <[^>]*> nop
++0000a1fc <[^>]*> nop
++0000a200 <[^>]*> nop
++0000a204 <[^>]*> nop
++0000a208 <[^>]*> nop
++0000a20c <[^>]*> nop
++0000a210 <[^>]*> nop
++0000a214 <[^>]*> nop
++0000a218 <[^>]*> nop
++0000a21c <[^>]*> nop
++0000a220 <[^>]*> nop
++0000a224 <[^>]*> nop
++0000a228 <[^>]*> nop
++0000a22c <[^>]*> nop
++0000a230 <[^>]*> nop
++0000a234 <[^>]*> nop
++0000a238 <[^>]*> nop
++0000a23c <[^>]*> nop
++0000a240 <[^>]*> nop
++0000a244 <[^>]*> nop
++0000a248 <[^>]*> nop
++0000a24c <[^>]*> nop
++0000a250 <[^>]*> nop
++0000a254 <[^>]*> nop
++0000a258 <[^>]*> nop
++0000a25c <[^>]*> nop
++0000a260 <[^>]*> nop
++0000a264 <[^>]*> nop
++0000a268 <[^>]*> nop
++0000a26c <[^>]*> nop
++0000a270 <[^>]*> nop
++0000a274 <[^>]*> nop
++0000a278 <[^>]*> nop
++0000a27c <[^>]*> nop
++0000a280 <[^>]*> nop
++0000a284 <[^>]*> nop
++0000a288 <[^>]*> nop
++0000a28c <[^>]*> nop
++0000a290 <[^>]*> nop
++0000a294 <[^>]*> nop
++0000a298 <[^>]*> nop
++0000a29c <[^>]*> nop
++0000a2a0 <[^>]*> nop
++0000a2a4 <[^>]*> nop
++0000a2a8 <[^>]*> nop
++0000a2ac <[^>]*> nop
++0000a2b0 <[^>]*> nop
++0000a2b4 <[^>]*> nop
++0000a2b8 <[^>]*> nop
++0000a2bc <[^>]*> nop
++0000a2c0 <[^>]*> nop
++0000a2c4 <[^>]*> nop
++0000a2c8 <[^>]*> nop
++0000a2cc <[^>]*> nop
++0000a2d0 <[^>]*> nop
++0000a2d4 <[^>]*> nop
++0000a2d8 <[^>]*> nop
++0000a2dc <[^>]*> nop
++0000a2e0 <[^>]*> nop
++0000a2e4 <[^>]*> nop
++0000a2e8 <[^>]*> nop
++0000a2ec <[^>]*> nop
++0000a2f0 <[^>]*> nop
++0000a2f4 <[^>]*> nop
++0000a2f8 <[^>]*> nop
++0000a2fc <[^>]*> nop
++0000a300 <[^>]*> nop
++0000a304 <[^>]*> nop
++0000a308 <[^>]*> nop
++0000a30c <[^>]*> nop
++0000a310 <[^>]*> nop
++0000a314 <[^>]*> nop
++0000a318 <[^>]*> nop
++0000a31c <[^>]*> nop
++0000a320 <[^>]*> nop
++0000a324 <[^>]*> nop
++0000a328 <[^>]*> nop
++0000a32c <[^>]*> nop
++0000a330 <[^>]*> nop
++0000a334 <[^>]*> nop
++0000a338 <[^>]*> nop
++0000a33c <[^>]*> nop
++0000a340 <[^>]*> nop
++0000a344 <[^>]*> nop
++0000a348 <[^>]*> nop
++0000a34c <[^>]*> nop
++0000a350 <[^>]*> nop
++0000a354 <[^>]*> nop
++0000a358 <[^>]*> nop
++0000a35c <[^>]*> nop
++0000a360 <[^>]*> nop
++0000a364 <[^>]*> nop
++0000a368 <[^>]*> nop
++0000a36c <[^>]*> nop
++0000a370 <[^>]*> nop
++0000a374 <[^>]*> nop
++0000a378 <[^>]*> nop
++0000a37c <[^>]*> nop
++0000a380 <[^>]*> nop
++0000a384 <[^>]*> nop
++0000a388 <[^>]*> nop
++0000a38c <[^>]*> nop
++0000a390 <[^>]*> nop
++0000a394 <[^>]*> nop
++0000a398 <[^>]*> nop
++0000a39c <[^>]*> nop
++0000a3a0 <[^>]*> nop
++0000a3a4 <[^>]*> nop
++0000a3a8 <[^>]*> nop
++0000a3ac <[^>]*> nop
++0000a3b0 <[^>]*> nop
++0000a3b4 <[^>]*> nop
++0000a3b8 <[^>]*> nop
++0000a3bc <[^>]*> nop
++0000a3c0 <[^>]*> nop
++0000a3c4 <[^>]*> nop
++0000a3c8 <[^>]*> nop
++0000a3cc <[^>]*> nop
++0000a3d0 <[^>]*> nop
++0000a3d4 <[^>]*> nop
++0000a3d8 <[^>]*> nop
++0000a3dc <[^>]*> nop
++0000a3e0 <[^>]*> nop
++0000a3e4 <[^>]*> nop
++0000a3e8 <[^>]*> nop
++0000a3ec <[^>]*> nop
++0000a3f0 <[^>]*> nop
++0000a3f4 <[^>]*> nop
++0000a3f8 <[^>]*> nop
++0000a3fc <[^>]*> nop
++0000a400 <[^>]*> nop
++0000a404 <[^>]*> nop
++0000a408 <[^>]*> nop
++0000a40c <[^>]*> nop
++0000a410 <[^>]*> nop
++0000a414 <[^>]*> nop
++0000a418 <[^>]*> nop
++0000a41c <[^>]*> nop
++0000a420 <[^>]*> nop
++0000a424 <[^>]*> nop
++0000a428 <[^>]*> nop
++0000a42c <[^>]*> nop
++0000a430 <[^>]*> nop
++0000a434 <[^>]*> nop
++0000a438 <[^>]*> nop
++0000a43c <[^>]*> nop
++0000a440 <[^>]*> nop
++0000a444 <[^>]*> nop
++0000a448 <[^>]*> nop
++0000a44c <[^>]*> nop
++0000a450 <[^>]*> nop
++0000a454 <[^>]*> nop
++0000a458 <[^>]*> nop
++0000a45c <[^>]*> nop
++0000a460 <[^>]*> nop
++0000a464 <[^>]*> nop
++0000a468 <[^>]*> nop
++0000a46c <[^>]*> nop
++0000a470 <[^>]*> nop
++0000a474 <[^>]*> nop
++0000a478 <[^>]*> nop
++0000a47c <[^>]*> nop
++0000a480 <[^>]*> nop
++0000a484 <[^>]*> nop
++0000a488 <[^>]*> nop
++0000a48c <[^>]*> nop
++0000a490 <[^>]*> nop
++0000a494 <[^>]*> nop
++0000a498 <[^>]*> nop
++0000a49c <[^>]*> nop
++0000a4a0 <[^>]*> nop
++0000a4a4 <[^>]*> nop
++0000a4a8 <[^>]*> nop
++0000a4ac <[^>]*> nop
++0000a4b0 <[^>]*> nop
++0000a4b4 <[^>]*> nop
++0000a4b8 <[^>]*> nop
++0000a4bc <[^>]*> nop
++0000a4c0 <[^>]*> nop
++0000a4c4 <[^>]*> nop
++0000a4c8 <[^>]*> nop
++0000a4cc <[^>]*> nop
++0000a4d0 <[^>]*> nop
++0000a4d4 <[^>]*> nop
++0000a4d8 <[^>]*> nop
++0000a4dc <[^>]*> nop
++0000a4e0 <[^>]*> nop
++0000a4e4 <[^>]*> nop
++0000a4e8 <[^>]*> nop
++0000a4ec <[^>]*> nop
++0000a4f0 <[^>]*> nop
++0000a4f4 <[^>]*> nop
++0000a4f8 <[^>]*> nop
++0000a4fc <[^>]*> nop
++0000a500 <[^>]*> nop
++0000a504 <[^>]*> nop
++0000a508 <[^>]*> nop
++0000a50c <[^>]*> nop
++0000a510 <[^>]*> nop
++0000a514 <[^>]*> nop
++0000a518 <[^>]*> nop
++0000a51c <[^>]*> nop
++0000a520 <[^>]*> nop
++0000a524 <[^>]*> nop
++0000a528 <[^>]*> nop
++0000a52c <[^>]*> nop
++0000a530 <[^>]*> nop
++0000a534 <[^>]*> nop
++0000a538 <[^>]*> nop
++0000a53c <[^>]*> nop
++0000a540 <[^>]*> nop
++0000a544 <[^>]*> nop
++0000a548 <[^>]*> nop
++0000a54c <[^>]*> nop
++0000a550 <[^>]*> nop
++0000a554 <[^>]*> nop
++0000a558 <[^>]*> nop
++0000a55c <[^>]*> nop
++0000a560 <[^>]*> nop
++0000a564 <[^>]*> nop
++0000a568 <[^>]*> nop
++0000a56c <[^>]*> nop
++0000a570 <[^>]*> nop
++0000a574 <[^>]*> nop
++0000a578 <[^>]*> nop
++0000a57c <[^>]*> nop
++0000a580 <[^>]*> nop
++0000a584 <[^>]*> nop
++0000a588 <[^>]*> nop
++0000a58c <[^>]*> nop
++0000a590 <[^>]*> nop
++0000a594 <[^>]*> nop
++0000a598 <[^>]*> nop
++0000a59c <[^>]*> nop
++0000a5a0 <[^>]*> nop
++0000a5a4 <[^>]*> nop
++0000a5a8 <[^>]*> nop
++0000a5ac <[^>]*> nop
++0000a5b0 <[^>]*> nop
++0000a5b4 <[^>]*> nop
++0000a5b8 <[^>]*> nop
++0000a5bc <[^>]*> nop
++0000a5c0 <[^>]*> nop
++0000a5c4 <[^>]*> nop
++0000a5c8 <[^>]*> nop
++0000a5cc <[^>]*> nop
++0000a5d0 <[^>]*> nop
++0000a5d4 <[^>]*> nop
++0000a5d8 <[^>]*> nop
++0000a5dc <[^>]*> nop
++0000a5e0 <[^>]*> nop
++0000a5e4 <[^>]*> nop
++0000a5e8 <[^>]*> nop
++0000a5ec <[^>]*> nop
++0000a5f0 <[^>]*> nop
++0000a5f4 <[^>]*> nop
++0000a5f8 <[^>]*> nop
++0000a5fc <[^>]*> nop
++0000a600 <[^>]*> nop
++0000a604 <[^>]*> nop
++0000a608 <[^>]*> nop
++0000a60c <[^>]*> nop
++0000a610 <[^>]*> nop
++0000a614 <[^>]*> nop
++0000a618 <[^>]*> nop
++0000a61c <[^>]*> nop
++0000a620 <[^>]*> nop
++0000a624 <[^>]*> nop
++0000a628 <[^>]*> nop
++0000a62c <[^>]*> nop
++0000a630 <[^>]*> nop
++0000a634 <[^>]*> nop
++0000a638 <[^>]*> nop
++0000a63c <[^>]*> nop
++0000a640 <[^>]*> nop
++0000a644 <[^>]*> nop
++0000a648 <[^>]*> nop
++0000a64c <[^>]*> nop
++0000a650 <[^>]*> nop
++0000a654 <[^>]*> nop
++0000a658 <[^>]*> nop
++0000a65c <[^>]*> nop
++0000a660 <[^>]*> nop
++0000a664 <[^>]*> nop
++0000a668 <[^>]*> nop
++0000a66c <[^>]*> nop
++0000a670 <[^>]*> nop
++0000a674 <[^>]*> nop
++0000a678 <[^>]*> nop
++0000a67c <[^>]*> nop
++0000a680 <[^>]*> nop
++0000a684 <[^>]*> nop
++0000a688 <[^>]*> nop
++0000a68c <[^>]*> nop
++0000a690 <[^>]*> nop
++0000a694 <[^>]*> nop
++0000a698 <[^>]*> nop
++0000a69c <[^>]*> nop
++0000a6a0 <[^>]*> nop
++0000a6a4 <[^>]*> nop
++0000a6a8 <[^>]*> nop
++0000a6ac <[^>]*> nop
++0000a6b0 <[^>]*> nop
++0000a6b4 <[^>]*> nop
++0000a6b8 <[^>]*> nop
++0000a6bc <[^>]*> nop
++0000a6c0 <[^>]*> nop
++0000a6c4 <[^>]*> nop
++0000a6c8 <[^>]*> nop
++0000a6cc <[^>]*> nop
++0000a6d0 <[^>]*> nop
++0000a6d4 <[^>]*> nop
++0000a6d8 <[^>]*> nop
++0000a6dc <[^>]*> nop
++0000a6e0 <[^>]*> nop
++0000a6e4 <[^>]*> nop
++0000a6e8 <[^>]*> nop
++0000a6ec <[^>]*> nop
++0000a6f0 <[^>]*> nop
++0000a6f4 <[^>]*> nop
++0000a6f8 <[^>]*> nop
++0000a6fc <[^>]*> nop
++0000a700 <[^>]*> nop
++0000a704 <[^>]*> nop
++0000a708 <[^>]*> nop
++0000a70c <[^>]*> nop
++0000a710 <[^>]*> nop
++0000a714 <[^>]*> nop
++0000a718 <[^>]*> nop
++0000a71c <[^>]*> nop
++0000a720 <[^>]*> nop
++0000a724 <[^>]*> nop
++0000a728 <[^>]*> nop
++0000a72c <[^>]*> nop
++0000a730 <[^>]*> nop
++0000a734 <[^>]*> nop
++0000a738 <[^>]*> nop
++0000a73c <[^>]*> nop
++0000a740 <[^>]*> nop
++0000a744 <[^>]*> nop
++0000a748 <[^>]*> nop
++0000a74c <[^>]*> nop
++0000a750 <[^>]*> nop
++0000a754 <[^>]*> nop
++0000a758 <[^>]*> nop
++0000a75c <[^>]*> nop
++0000a760 <[^>]*> nop
++0000a764 <[^>]*> nop
++0000a768 <[^>]*> nop
++0000a76c <[^>]*> nop
++0000a770 <[^>]*> nop
++0000a774 <[^>]*> nop
++0000a778 <[^>]*> nop
++0000a77c <[^>]*> nop
++0000a780 <[^>]*> nop
++0000a784 <[^>]*> nop
++0000a788 <[^>]*> nop
++0000a78c <[^>]*> nop
++0000a790 <[^>]*> nop
++0000a794 <[^>]*> nop
++0000a798 <[^>]*> nop
++0000a79c <[^>]*> nop
++0000a7a0 <[^>]*> nop
++0000a7a4 <[^>]*> nop
++0000a7a8 <[^>]*> nop
++0000a7ac <[^>]*> nop
++0000a7b0 <[^>]*> nop
++0000a7b4 <[^>]*> nop
++0000a7b8 <[^>]*> nop
++0000a7bc <[^>]*> nop
++0000a7c0 <[^>]*> nop
++0000a7c4 <[^>]*> nop
++0000a7c8 <[^>]*> nop
++0000a7cc <[^>]*> nop
++0000a7d0 <[^>]*> nop
++0000a7d4 <[^>]*> nop
++0000a7d8 <[^>]*> nop
++0000a7dc <[^>]*> nop
++0000a7e0 <[^>]*> nop
++0000a7e4 <[^>]*> nop
++0000a7e8 <[^>]*> nop
++0000a7ec <[^>]*> nop
++0000a7f0 <[^>]*> nop
++0000a7f4 <[^>]*> nop
++0000a7f8 <[^>]*> nop
++0000a7fc <[^>]*> nop
++0000a800 <[^>]*> nop
++0000a804 <[^>]*> nop
++0000a808 <[^>]*> nop
++0000a80c <[^>]*> nop
++0000a810 <[^>]*> nop
++0000a814 <[^>]*> nop
++0000a818 <[^>]*> nop
++0000a81c <[^>]*> nop
++0000a820 <[^>]*> nop
++0000a824 <[^>]*> nop
++0000a828 <[^>]*> nop
++0000a82c <[^>]*> nop
++0000a830 <[^>]*> nop
++0000a834 <[^>]*> nop
++0000a838 <[^>]*> nop
++0000a83c <[^>]*> nop
++0000a840 <[^>]*> nop
++0000a844 <[^>]*> nop
++0000a848 <[^>]*> nop
++0000a84c <[^>]*> nop
++0000a850 <[^>]*> nop
++0000a854 <[^>]*> nop
++0000a858 <[^>]*> nop
++0000a85c <[^>]*> nop
++0000a860 <[^>]*> nop
++0000a864 <[^>]*> nop
++0000a868 <[^>]*> nop
++0000a86c <[^>]*> nop
++0000a870 <[^>]*> nop
++0000a874 <[^>]*> nop
++0000a878 <[^>]*> nop
++0000a87c <[^>]*> nop
++0000a880 <[^>]*> nop
++0000a884 <[^>]*> nop
++0000a888 <[^>]*> nop
++0000a88c <[^>]*> nop
++0000a890 <[^>]*> nop
++0000a894 <[^>]*> nop
++0000a898 <[^>]*> nop
++0000a89c <[^>]*> nop
++0000a8a0 <[^>]*> nop
++0000a8a4 <[^>]*> nop
++0000a8a8 <[^>]*> nop
++0000a8ac <[^>]*> nop
++0000a8b0 <[^>]*> nop
++0000a8b4 <[^>]*> nop
++0000a8b8 <[^>]*> nop
++0000a8bc <[^>]*> nop
++0000a8c0 <[^>]*> nop
++0000a8c4 <[^>]*> nop
++0000a8c8 <[^>]*> nop
++0000a8cc <[^>]*> nop
++0000a8d0 <[^>]*> nop
++0000a8d4 <[^>]*> nop
++0000a8d8 <[^>]*> nop
++0000a8dc <[^>]*> nop
++0000a8e0 <[^>]*> nop
++0000a8e4 <[^>]*> nop
++0000a8e8 <[^>]*> nop
++0000a8ec <[^>]*> nop
++0000a8f0 <[^>]*> nop
++0000a8f4 <[^>]*> nop
++0000a8f8 <[^>]*> nop
++0000a8fc <[^>]*> nop
++0000a900 <[^>]*> nop
++0000a904 <[^>]*> nop
++0000a908 <[^>]*> nop
++0000a90c <[^>]*> nop
++0000a910 <[^>]*> nop
++0000a914 <[^>]*> nop
++0000a918 <[^>]*> nop
++0000a91c <[^>]*> nop
++0000a920 <[^>]*> nop
++0000a924 <[^>]*> nop
++0000a928 <[^>]*> nop
++0000a92c <[^>]*> nop
++0000a930 <[^>]*> nop
++0000a934 <[^>]*> nop
++0000a938 <[^>]*> nop
++0000a93c <[^>]*> nop
++0000a940 <[^>]*> nop
++0000a944 <[^>]*> nop
++0000a948 <[^>]*> nop
++0000a94c <[^>]*> nop
++0000a950 <[^>]*> nop
++0000a954 <[^>]*> nop
++0000a958 <[^>]*> nop
++0000a95c <[^>]*> nop
++0000a960 <[^>]*> nop
++0000a964 <[^>]*> nop
++0000a968 <[^>]*> nop
++0000a96c <[^>]*> nop
++0000a970 <[^>]*> nop
++0000a974 <[^>]*> nop
++0000a978 <[^>]*> nop
++0000a97c <[^>]*> nop
++0000a980 <[^>]*> nop
++0000a984 <[^>]*> nop
++0000a988 <[^>]*> nop
++0000a98c <[^>]*> nop
++0000a990 <[^>]*> nop
++0000a994 <[^>]*> nop
++0000a998 <[^>]*> nop
++0000a99c <[^>]*> nop
++0000a9a0 <[^>]*> nop
++0000a9a4 <[^>]*> nop
++0000a9a8 <[^>]*> nop
++0000a9ac <[^>]*> nop
++0000a9b0 <[^>]*> nop
++0000a9b4 <[^>]*> nop
++0000a9b8 <[^>]*> nop
++0000a9bc <[^>]*> nop
++0000a9c0 <[^>]*> nop
++0000a9c4 <[^>]*> nop
++0000a9c8 <[^>]*> nop
++0000a9cc <[^>]*> nop
++0000a9d0 <[^>]*> nop
++0000a9d4 <[^>]*> nop
++0000a9d8 <[^>]*> nop
++0000a9dc <[^>]*> nop
++0000a9e0 <[^>]*> nop
++0000a9e4 <[^>]*> nop
++0000a9e8 <[^>]*> nop
++0000a9ec <[^>]*> nop
++0000a9f0 <[^>]*> nop
++0000a9f4 <[^>]*> nop
++0000a9f8 <[^>]*> nop
++0000a9fc <[^>]*> nop
++0000aa00 <[^>]*> nop
++0000aa04 <[^>]*> nop
++0000aa08 <[^>]*> nop
++0000aa0c <[^>]*> nop
++0000aa10 <[^>]*> nop
++0000aa14 <[^>]*> nop
++0000aa18 <[^>]*> nop
++0000aa1c <[^>]*> nop
++0000aa20 <[^>]*> nop
++0000aa24 <[^>]*> nop
++0000aa28 <[^>]*> nop
++0000aa2c <[^>]*> nop
++0000aa30 <[^>]*> nop
++0000aa34 <[^>]*> nop
++0000aa38 <[^>]*> nop
++0000aa3c <[^>]*> nop
++0000aa40 <[^>]*> nop
++0000aa44 <[^>]*> nop
++0000aa48 <[^>]*> nop
++0000aa4c <[^>]*> nop
++0000aa50 <[^>]*> nop
++0000aa54 <[^>]*> nop
++0000aa58 <[^>]*> nop
++0000aa5c <[^>]*> nop
++0000aa60 <[^>]*> nop
++0000aa64 <[^>]*> nop
++0000aa68 <[^>]*> nop
++0000aa6c <[^>]*> nop
++0000aa70 <[^>]*> nop
++0000aa74 <[^>]*> nop
++0000aa78 <[^>]*> nop
++0000aa7c <[^>]*> nop
++0000aa80 <[^>]*> nop
++0000aa84 <[^>]*> nop
++0000aa88 <[^>]*> nop
++0000aa8c <[^>]*> nop
++0000aa90 <[^>]*> nop
++0000aa94 <[^>]*> nop
++0000aa98 <[^>]*> nop
++0000aa9c <[^>]*> nop
++0000aaa0 <[^>]*> nop
++0000aaa4 <[^>]*> nop
++0000aaa8 <[^>]*> nop
++0000aaac <[^>]*> nop
++0000aab0 <[^>]*> nop
++0000aab4 <[^>]*> nop
++0000aab8 <[^>]*> nop
++0000aabc <[^>]*> nop
++0000aac0 <[^>]*> nop
++0000aac4 <[^>]*> nop
++0000aac8 <[^>]*> nop
++0000aacc <[^>]*> nop
++0000aad0 <[^>]*> nop
++0000aad4 <[^>]*> nop
++0000aad8 <[^>]*> nop
++0000aadc <[^>]*> nop
++0000aae0 <[^>]*> nop
++0000aae4 <[^>]*> nop
++0000aae8 <[^>]*> nop
++0000aaec <[^>]*> nop
++0000aaf0 <[^>]*> nop
++0000aaf4 <[^>]*> nop
++0000aaf8 <[^>]*> nop
++0000aafc <[^>]*> nop
++0000ab00 <[^>]*> nop
++0000ab04 <[^>]*> nop
++0000ab08 <[^>]*> nop
++0000ab0c <[^>]*> nop
++0000ab10 <[^>]*> nop
++0000ab14 <[^>]*> nop
++0000ab18 <[^>]*> nop
++0000ab1c <[^>]*> nop
++0000ab20 <[^>]*> nop
++0000ab24 <[^>]*> nop
++0000ab28 <[^>]*> nop
++0000ab2c <[^>]*> nop
++0000ab30 <[^>]*> nop
++0000ab34 <[^>]*> nop
++0000ab38 <[^>]*> nop
++0000ab3c <[^>]*> nop
++0000ab40 <[^>]*> nop
++0000ab44 <[^>]*> nop
++0000ab48 <[^>]*> nop
++0000ab4c <[^>]*> nop
++0000ab50 <[^>]*> nop
++0000ab54 <[^>]*> nop
++0000ab58 <[^>]*> nop
++0000ab5c <[^>]*> nop
++0000ab60 <[^>]*> nop
++0000ab64 <[^>]*> nop
++0000ab68 <[^>]*> nop
++0000ab6c <[^>]*> nop
++0000ab70 <[^>]*> nop
++0000ab74 <[^>]*> nop
++0000ab78 <[^>]*> nop
++0000ab7c <[^>]*> nop
++0000ab80 <[^>]*> nop
++0000ab84 <[^>]*> nop
++0000ab88 <[^>]*> nop
++0000ab8c <[^>]*> nop
++0000ab90 <[^>]*> nop
++0000ab94 <[^>]*> nop
++0000ab98 <[^>]*> nop
++0000ab9c <[^>]*> nop
++0000aba0 <[^>]*> nop
++0000aba4 <[^>]*> nop
++0000aba8 <[^>]*> nop
++0000abac <[^>]*> nop
++0000abb0 <[^>]*> nop
++0000abb4 <[^>]*> nop
++0000abb8 <[^>]*> nop
++0000abbc <[^>]*> nop
++0000abc0 <[^>]*> nop
++0000abc4 <[^>]*> nop
++0000abc8 <[^>]*> nop
++0000abcc <[^>]*> nop
++0000abd0 <[^>]*> nop
++0000abd4 <[^>]*> nop
++0000abd8 <[^>]*> nop
++0000abdc <[^>]*> nop
++0000abe0 <[^>]*> nop
++0000abe4 <[^>]*> nop
++0000abe8 <[^>]*> nop
++0000abec <[^>]*> nop
++0000abf0 <[^>]*> nop
++0000abf4 <[^>]*> nop
++0000abf8 <[^>]*> nop
++0000abfc <[^>]*> nop
++0000ac00 <[^>]*> nop
++0000ac04 <[^>]*> nop
++0000ac08 <[^>]*> nop
++0000ac0c <[^>]*> nop
++0000ac10 <[^>]*> nop
++0000ac14 <[^>]*> nop
++0000ac18 <[^>]*> nop
++0000ac1c <[^>]*> nop
++0000ac20 <[^>]*> nop
++0000ac24 <[^>]*> nop
++0000ac28 <[^>]*> nop
++0000ac2c <[^>]*> nop
++0000ac30 <[^>]*> nop
++0000ac34 <[^>]*> nop
++0000ac38 <[^>]*> nop
++0000ac3c <[^>]*> nop
++0000ac40 <[^>]*> nop
++0000ac44 <[^>]*> nop
++0000ac48 <[^>]*> nop
++0000ac4c <[^>]*> nop
++0000ac50 <[^>]*> nop
++0000ac54 <[^>]*> nop
++0000ac58 <[^>]*> nop
++0000ac5c <[^>]*> nop
++0000ac60 <[^>]*> nop
++0000ac64 <[^>]*> nop
++0000ac68 <[^>]*> nop
++0000ac6c <[^>]*> nop
++0000ac70 <[^>]*> nop
++0000ac74 <[^>]*> nop
++0000ac78 <[^>]*> nop
++0000ac7c <[^>]*> nop
++0000ac80 <[^>]*> nop
++0000ac84 <[^>]*> nop
++0000ac88 <[^>]*> nop
++0000ac8c <[^>]*> nop
++0000ac90 <[^>]*> nop
++0000ac94 <[^>]*> nop
++0000ac98 <[^>]*> nop
++0000ac9c <[^>]*> nop
++0000aca0 <[^>]*> nop
++0000aca4 <[^>]*> nop
++0000aca8 <[^>]*> nop
++0000acac <[^>]*> nop
++0000acb0 <[^>]*> nop
++0000acb4 <[^>]*> nop
++0000acb8 <[^>]*> nop
++0000acbc <[^>]*> nop
++0000acc0 <[^>]*> nop
++0000acc4 <[^>]*> nop
++0000acc8 <[^>]*> nop
++0000accc <[^>]*> nop
++0000acd0 <[^>]*> nop
++0000acd4 <[^>]*> nop
++0000acd8 <[^>]*> nop
++0000acdc <[^>]*> nop
++0000ace0 <[^>]*> nop
++0000ace4 <[^>]*> nop
++0000ace8 <[^>]*> nop
++0000acec <[^>]*> nop
++0000acf0 <[^>]*> nop
++0000acf4 <[^>]*> nop
++0000acf8 <[^>]*> nop
++0000acfc <[^>]*> nop
++0000ad00 <[^>]*> nop
++0000ad04 <[^>]*> nop
++0000ad08 <[^>]*> nop
++0000ad0c <[^>]*> nop
++0000ad10 <[^>]*> nop
++0000ad14 <[^>]*> nop
++0000ad18 <[^>]*> nop
++0000ad1c <[^>]*> nop
++0000ad20 <[^>]*> nop
++0000ad24 <[^>]*> nop
++0000ad28 <[^>]*> nop
++0000ad2c <[^>]*> nop
++0000ad30 <[^>]*> nop
++0000ad34 <[^>]*> nop
++0000ad38 <[^>]*> nop
++0000ad3c <[^>]*> nop
++0000ad40 <[^>]*> nop
++0000ad44 <[^>]*> nop
++0000ad48 <[^>]*> nop
++0000ad4c <[^>]*> nop
++0000ad50 <[^>]*> nop
++0000ad54 <[^>]*> nop
++0000ad58 <[^>]*> nop
++0000ad5c <[^>]*> nop
++0000ad60 <[^>]*> nop
++0000ad64 <[^>]*> nop
++0000ad68 <[^>]*> nop
++0000ad6c <[^>]*> nop
++0000ad70 <[^>]*> nop
++0000ad74 <[^>]*> nop
++0000ad78 <[^>]*> nop
++0000ad7c <[^>]*> nop
++0000ad80 <[^>]*> nop
++0000ad84 <[^>]*> nop
++0000ad88 <[^>]*> nop
++0000ad8c <[^>]*> nop
++0000ad90 <[^>]*> nop
++0000ad94 <[^>]*> nop
++0000ad98 <[^>]*> nop
++0000ad9c <[^>]*> nop
++0000ada0 <[^>]*> nop
++0000ada4 <[^>]*> nop
++0000ada8 <[^>]*> nop
++0000adac <[^>]*> nop
++0000adb0 <[^>]*> nop
++0000adb4 <[^>]*> nop
++0000adb8 <[^>]*> nop
++0000adbc <[^>]*> nop
++0000adc0 <[^>]*> nop
++0000adc4 <[^>]*> nop
++0000adc8 <[^>]*> nop
++0000adcc <[^>]*> nop
++0000add0 <[^>]*> nop
++0000add4 <[^>]*> nop
++0000add8 <[^>]*> nop
++0000addc <[^>]*> nop
++0000ade0 <[^>]*> nop
++0000ade4 <[^>]*> nop
++0000ade8 <[^>]*> nop
++0000adec <[^>]*> nop
++0000adf0 <[^>]*> nop
++0000adf4 <[^>]*> nop
++0000adf8 <[^>]*> nop
++0000adfc <[^>]*> nop
++0000ae00 <[^>]*> nop
++0000ae04 <[^>]*> nop
++0000ae08 <[^>]*> nop
++0000ae0c <[^>]*> nop
++0000ae10 <[^>]*> nop
++0000ae14 <[^>]*> nop
++0000ae18 <[^>]*> nop
++0000ae1c <[^>]*> nop
++0000ae20 <[^>]*> nop
++0000ae24 <[^>]*> nop
++0000ae28 <[^>]*> nop
++0000ae2c <[^>]*> nop
++0000ae30 <[^>]*> nop
++0000ae34 <[^>]*> nop
++0000ae38 <[^>]*> nop
++0000ae3c <[^>]*> nop
++0000ae40 <[^>]*> nop
++0000ae44 <[^>]*> nop
++0000ae48 <[^>]*> nop
++0000ae4c <[^>]*> nop
++0000ae50 <[^>]*> nop
++0000ae54 <[^>]*> nop
++0000ae58 <[^>]*> nop
++0000ae5c <[^>]*> nop
++0000ae60 <[^>]*> nop
++0000ae64 <[^>]*> nop
++0000ae68 <[^>]*> nop
++0000ae6c <[^>]*> nop
++0000ae70 <[^>]*> nop
++0000ae74 <[^>]*> nop
++0000ae78 <[^>]*> nop
++0000ae7c <[^>]*> nop
++0000ae80 <[^>]*> nop
++0000ae84 <[^>]*> nop
++0000ae88 <[^>]*> nop
++0000ae8c <[^>]*> nop
++0000ae90 <[^>]*> nop
++0000ae94 <[^>]*> nop
++0000ae98 <[^>]*> nop
++0000ae9c <[^>]*> nop
++0000aea0 <[^>]*> nop
++0000aea4 <[^>]*> nop
++0000aea8 <[^>]*> nop
++0000aeac <[^>]*> nop
++0000aeb0 <[^>]*> nop
++0000aeb4 <[^>]*> nop
++0000aeb8 <[^>]*> nop
++0000aebc <[^>]*> nop
++0000aec0 <[^>]*> nop
++0000aec4 <[^>]*> nop
++0000aec8 <[^>]*> nop
++0000aecc <[^>]*> nop
++0000aed0 <[^>]*> nop
++0000aed4 <[^>]*> nop
++0000aed8 <[^>]*> nop
++0000aedc <[^>]*> nop
++0000aee0 <[^>]*> nop
++0000aee4 <[^>]*> nop
++0000aee8 <[^>]*> nop
++0000aeec <[^>]*> nop
++0000aef0 <[^>]*> nop
++0000aef4 <[^>]*> nop
++0000aef8 <[^>]*> nop
++0000aefc <[^>]*> nop
++0000af00 <[^>]*> nop
++0000af04 <[^>]*> nop
++0000af08 <[^>]*> nop
++0000af0c <[^>]*> nop
++0000af10 <[^>]*> nop
++0000af14 <[^>]*> nop
++0000af18 <[^>]*> nop
++0000af1c <[^>]*> nop
++0000af20 <[^>]*> nop
++0000af24 <[^>]*> nop
++0000af28 <[^>]*> nop
++0000af2c <[^>]*> nop
++0000af30 <[^>]*> nop
++0000af34 <[^>]*> nop
++0000af38 <[^>]*> nop
++0000af3c <[^>]*> nop
++0000af40 <[^>]*> nop
++0000af44 <[^>]*> nop
++0000af48 <[^>]*> nop
++0000af4c <[^>]*> nop
++0000af50 <[^>]*> nop
++0000af54 <[^>]*> nop
++0000af58 <[^>]*> nop
++0000af5c <[^>]*> nop
++0000af60 <[^>]*> nop
++0000af64 <[^>]*> nop
++0000af68 <[^>]*> nop
++0000af6c <[^>]*> nop
++0000af70 <[^>]*> nop
++0000af74 <[^>]*> nop
++0000af78 <[^>]*> nop
++0000af7c <[^>]*> nop
++0000af80 <[^>]*> nop
++0000af84 <[^>]*> nop
++0000af88 <[^>]*> nop
++0000af8c <[^>]*> nop
++0000af90 <[^>]*> nop
++0000af94 <[^>]*> nop
++0000af98 <[^>]*> nop
++0000af9c <[^>]*> nop
++0000afa0 <[^>]*> nop
++0000afa4 <[^>]*> nop
++0000afa8 <[^>]*> nop
++0000afac <[^>]*> nop
++0000afb0 <[^>]*> nop
++0000afb4 <[^>]*> nop
++0000afb8 <[^>]*> nop
++0000afbc <[^>]*> nop
++0000afc0 <[^>]*> nop
++0000afc4 <[^>]*> nop
++0000afc8 <[^>]*> nop
++0000afcc <[^>]*> nop
++0000afd0 <[^>]*> nop
++0000afd4 <[^>]*> nop
++0000afd8 <[^>]*> nop
++0000afdc <[^>]*> nop
++0000afe0 <[^>]*> nop
++0000afe4 <[^>]*> nop
++0000afe8 <[^>]*> nop
++0000afec <[^>]*> nop
++0000aff0 <[^>]*> nop
++0000aff4 <[^>]*> nop
++0000aff8 <[^>]*> nop
++0000affc <[^>]*> nop
++0000b000 <[^>]*> nop
++0000b004 <[^>]*> nop
++0000b008 <[^>]*> nop
++0000b00c <[^>]*> nop
++0000b010 <[^>]*> nop
++0000b014 <[^>]*> nop
++0000b018 <[^>]*> nop
++0000b01c <[^>]*> nop
++0000b020 <[^>]*> nop
++0000b024 <[^>]*> nop
++0000b028 <[^>]*> nop
++0000b02c <[^>]*> nop
++0000b030 <[^>]*> nop
++0000b034 <[^>]*> nop
++0000b038 <[^>]*> nop
++0000b03c <[^>]*> nop
++0000b040 <[^>]*> nop
++0000b044 <[^>]*> nop
++0000b048 <[^>]*> nop
++0000b04c <[^>]*> nop
++0000b050 <[^>]*> nop
++0000b054 <[^>]*> nop
++0000b058 <[^>]*> nop
++0000b05c <[^>]*> nop
++0000b060 <[^>]*> nop
++0000b064 <[^>]*> nop
++0000b068 <[^>]*> nop
++0000b06c <[^>]*> nop
++0000b070 <[^>]*> nop
++0000b074 <[^>]*> nop
++0000b078 <[^>]*> nop
++0000b07c <[^>]*> nop
++0000b080 <[^>]*> nop
++0000b084 <[^>]*> nop
++0000b088 <[^>]*> nop
++0000b08c <[^>]*> nop
++0000b090 <[^>]*> nop
++0000b094 <[^>]*> nop
++0000b098 <[^>]*> nop
++0000b09c <[^>]*> nop
++0000b0a0 <[^>]*> nop
++0000b0a4 <[^>]*> nop
++0000b0a8 <[^>]*> nop
++0000b0ac <[^>]*> nop
++0000b0b0 <[^>]*> nop
++0000b0b4 <[^>]*> nop
++0000b0b8 <[^>]*> nop
++0000b0bc <[^>]*> nop
++0000b0c0 <[^>]*> nop
++0000b0c4 <[^>]*> nop
++0000b0c8 <[^>]*> nop
++0000b0cc <[^>]*> nop
++0000b0d0 <[^>]*> nop
++0000b0d4 <[^>]*> nop
++0000b0d8 <[^>]*> nop
++0000b0dc <[^>]*> nop
++0000b0e0 <[^>]*> nop
++0000b0e4 <[^>]*> nop
++0000b0e8 <[^>]*> nop
++0000b0ec <[^>]*> nop
++0000b0f0 <[^>]*> nop
++0000b0f4 <[^>]*> nop
++0000b0f8 <[^>]*> nop
++0000b0fc <[^>]*> nop
++0000b100 <[^>]*> nop
++0000b104 <[^>]*> nop
++0000b108 <[^>]*> nop
++0000b10c <[^>]*> nop
++0000b110 <[^>]*> nop
++0000b114 <[^>]*> nop
++0000b118 <[^>]*> nop
++0000b11c <[^>]*> nop
++0000b120 <[^>]*> nop
++0000b124 <[^>]*> nop
++0000b128 <[^>]*> nop
++0000b12c <[^>]*> nop
++0000b130 <[^>]*> nop
++0000b134 <[^>]*> nop
++0000b138 <[^>]*> nop
++0000b13c <[^>]*> nop
++0000b140 <[^>]*> nop
++0000b144 <[^>]*> nop
++0000b148 <[^>]*> nop
++0000b14c <[^>]*> nop
++0000b150 <[^>]*> nop
++0000b154 <[^>]*> nop
++0000b158 <[^>]*> nop
++0000b15c <[^>]*> nop
++0000b160 <[^>]*> nop
++0000b164 <[^>]*> nop
++0000b168 <[^>]*> nop
++0000b16c <[^>]*> nop
++0000b170 <[^>]*> nop
++0000b174 <[^>]*> nop
++0000b178 <[^>]*> nop
++0000b17c <[^>]*> nop
++0000b180 <[^>]*> nop
++0000b184 <[^>]*> nop
++0000b188 <[^>]*> nop
++0000b18c <[^>]*> nop
++0000b190 <[^>]*> nop
++0000b194 <[^>]*> nop
++0000b198 <[^>]*> nop
++0000b19c <[^>]*> nop
++0000b1a0 <[^>]*> nop
++0000b1a4 <[^>]*> nop
++0000b1a8 <[^>]*> nop
++0000b1ac <[^>]*> nop
++0000b1b0 <[^>]*> nop
++0000b1b4 <[^>]*> nop
++0000b1b8 <[^>]*> nop
++0000b1bc <[^>]*> nop
++0000b1c0 <[^>]*> nop
++0000b1c4 <[^>]*> nop
++0000b1c8 <[^>]*> nop
++0000b1cc <[^>]*> nop
++0000b1d0 <[^>]*> nop
++0000b1d4 <[^>]*> nop
++0000b1d8 <[^>]*> nop
++0000b1dc <[^>]*> nop
++0000b1e0 <[^>]*> nop
++0000b1e4 <[^>]*> nop
++0000b1e8 <[^>]*> nop
++0000b1ec <[^>]*> nop
++0000b1f0 <[^>]*> nop
++0000b1f4 <[^>]*> nop
++0000b1f8 <[^>]*> nop
++0000b1fc <[^>]*> nop
++0000b200 <[^>]*> nop
++0000b204 <[^>]*> nop
++0000b208 <[^>]*> nop
++0000b20c <[^>]*> nop
++0000b210 <[^>]*> nop
++0000b214 <[^>]*> nop
++0000b218 <[^>]*> nop
++0000b21c <[^>]*> nop
++0000b220 <[^>]*> nop
++0000b224 <[^>]*> nop
++0000b228 <[^>]*> nop
++0000b22c <[^>]*> nop
++0000b230 <[^>]*> nop
++0000b234 <[^>]*> nop
++0000b238 <[^>]*> nop
++0000b23c <[^>]*> nop
++0000b240 <[^>]*> nop
++0000b244 <[^>]*> nop
++0000b248 <[^>]*> nop
++0000b24c <[^>]*> nop
++0000b250 <[^>]*> nop
++0000b254 <[^>]*> nop
++0000b258 <[^>]*> nop
++0000b25c <[^>]*> nop
++0000b260 <[^>]*> nop
++0000b264 <[^>]*> nop
++0000b268 <[^>]*> nop
++0000b26c <[^>]*> nop
++0000b270 <[^>]*> nop
++0000b274 <[^>]*> nop
++0000b278 <[^>]*> nop
++0000b27c <[^>]*> nop
++0000b280 <[^>]*> nop
++0000b284 <[^>]*> nop
++0000b288 <[^>]*> nop
++0000b28c <[^>]*> nop
++0000b290 <[^>]*> nop
++0000b294 <[^>]*> nop
++0000b298 <[^>]*> nop
++0000b29c <[^>]*> nop
++0000b2a0 <[^>]*> nop
++0000b2a4 <[^>]*> nop
++0000b2a8 <[^>]*> nop
++0000b2ac <[^>]*> nop
++0000b2b0 <[^>]*> nop
++0000b2b4 <[^>]*> nop
++0000b2b8 <[^>]*> nop
++0000b2bc <[^>]*> nop
++0000b2c0 <[^>]*> nop
++0000b2c4 <[^>]*> nop
++0000b2c8 <[^>]*> nop
++0000b2cc <[^>]*> nop
++0000b2d0 <[^>]*> nop
++0000b2d4 <[^>]*> nop
++0000b2d8 <[^>]*> nop
++0000b2dc <[^>]*> nop
++0000b2e0 <[^>]*> nop
++0000b2e4 <[^>]*> nop
++0000b2e8 <[^>]*> nop
++0000b2ec <[^>]*> nop
++0000b2f0 <[^>]*> nop
++0000b2f4 <[^>]*> nop
++0000b2f8 <[^>]*> nop
++0000b2fc <[^>]*> nop
++0000b300 <[^>]*> nop
++0000b304 <[^>]*> nop
++0000b308 <[^>]*> nop
++0000b30c <[^>]*> nop
++0000b310 <[^>]*> nop
++0000b314 <[^>]*> nop
++0000b318 <[^>]*> nop
++0000b31c <[^>]*> nop
++0000b320 <[^>]*> nop
++0000b324 <[^>]*> nop
++0000b328 <[^>]*> nop
++0000b32c <[^>]*> nop
++0000b330 <[^>]*> nop
++0000b334 <[^>]*> nop
++0000b338 <[^>]*> nop
++0000b33c <[^>]*> nop
++0000b340 <[^>]*> nop
++0000b344 <[^>]*> nop
++0000b348 <[^>]*> nop
++0000b34c <[^>]*> nop
++0000b350 <[^>]*> nop
++0000b354 <[^>]*> nop
++0000b358 <[^>]*> nop
++0000b35c <[^>]*> nop
++0000b360 <[^>]*> nop
++0000b364 <[^>]*> nop
++0000b368 <[^>]*> nop
++0000b36c <[^>]*> nop
++0000b370 <[^>]*> nop
++0000b374 <[^>]*> nop
++0000b378 <[^>]*> nop
++0000b37c <[^>]*> nop
++0000b380 <[^>]*> nop
++0000b384 <[^>]*> nop
++0000b388 <[^>]*> nop
++0000b38c <[^>]*> nop
++0000b390 <[^>]*> nop
++0000b394 <[^>]*> nop
++0000b398 <[^>]*> nop
++0000b39c <[^>]*> nop
++0000b3a0 <[^>]*> nop
++0000b3a4 <[^>]*> nop
++0000b3a8 <[^>]*> nop
++0000b3ac <[^>]*> nop
++0000b3b0 <[^>]*> nop
++0000b3b4 <[^>]*> nop
++0000b3b8 <[^>]*> nop
++0000b3bc <[^>]*> nop
++0000b3c0 <[^>]*> nop
++0000b3c4 <[^>]*> nop
++0000b3c8 <[^>]*> nop
++0000b3cc <[^>]*> nop
++0000b3d0 <[^>]*> nop
++0000b3d4 <[^>]*> nop
++0000b3d8 <[^>]*> nop
++0000b3dc <[^>]*> nop
++0000b3e0 <[^>]*> nop
++0000b3e4 <[^>]*> nop
++0000b3e8 <[^>]*> nop
++0000b3ec <[^>]*> nop
++0000b3f0 <[^>]*> nop
++0000b3f4 <[^>]*> nop
++0000b3f8 <[^>]*> nop
++0000b3fc <[^>]*> nop
++0000b400 <[^>]*> nop
++0000b404 <[^>]*> nop
++0000b408 <[^>]*> nop
++0000b40c <[^>]*> nop
++0000b410 <[^>]*> nop
++0000b414 <[^>]*> nop
++0000b418 <[^>]*> nop
++0000b41c <[^>]*> nop
++0000b420 <[^>]*> nop
++0000b424 <[^>]*> nop
++0000b428 <[^>]*> nop
++0000b42c <[^>]*> nop
++0000b430 <[^>]*> nop
++0000b434 <[^>]*> nop
++0000b438 <[^>]*> nop
++0000b43c <[^>]*> nop
++0000b440 <[^>]*> nop
++0000b444 <[^>]*> nop
++0000b448 <[^>]*> nop
++0000b44c <[^>]*> nop
++0000b450 <[^>]*> nop
++0000b454 <[^>]*> nop
++0000b458 <[^>]*> nop
++0000b45c <[^>]*> nop
++0000b460 <[^>]*> nop
++0000b464 <[^>]*> nop
++0000b468 <[^>]*> nop
++0000b46c <[^>]*> nop
++0000b470 <[^>]*> nop
++0000b474 <[^>]*> nop
++0000b478 <[^>]*> nop
++0000b47c <[^>]*> nop
++0000b480 <[^>]*> nop
++0000b484 <[^>]*> nop
++0000b488 <[^>]*> nop
++0000b48c <[^>]*> nop
++0000b490 <[^>]*> nop
++0000b494 <[^>]*> nop
++0000b498 <[^>]*> nop
++0000b49c <[^>]*> nop
++0000b4a0 <[^>]*> nop
++0000b4a4 <[^>]*> nop
++0000b4a8 <[^>]*> nop
++0000b4ac <[^>]*> nop
++0000b4b0 <[^>]*> nop
++0000b4b4 <[^>]*> nop
++0000b4b8 <[^>]*> nop
++0000b4bc <[^>]*> nop
++0000b4c0 <[^>]*> nop
++0000b4c4 <[^>]*> nop
++0000b4c8 <[^>]*> nop
++0000b4cc <[^>]*> nop
++0000b4d0 <[^>]*> nop
++0000b4d4 <[^>]*> nop
++0000b4d8 <[^>]*> nop
++0000b4dc <[^>]*> nop
++0000b4e0 <[^>]*> nop
++0000b4e4 <[^>]*> nop
++0000b4e8 <[^>]*> nop
++0000b4ec <[^>]*> nop
++0000b4f0 <[^>]*> nop
++0000b4f4 <[^>]*> nop
++0000b4f8 <[^>]*> nop
++0000b4fc <[^>]*> nop
++0000b500 <[^>]*> nop
++0000b504 <[^>]*> nop
++0000b508 <[^>]*> nop
++0000b50c <[^>]*> nop
++0000b510 <[^>]*> nop
++0000b514 <[^>]*> nop
++0000b518 <[^>]*> nop
++0000b51c <[^>]*> nop
++0000b520 <[^>]*> nop
++0000b524 <[^>]*> nop
++0000b528 <[^>]*> nop
++0000b52c <[^>]*> nop
++0000b530 <[^>]*> nop
++0000b534 <[^>]*> nop
++0000b538 <[^>]*> nop
++0000b53c <[^>]*> nop
++0000b540 <[^>]*> nop
++0000b544 <[^>]*> nop
++0000b548 <[^>]*> nop
++0000b54c <[^>]*> nop
++0000b550 <[^>]*> nop
++0000b554 <[^>]*> nop
++0000b558 <[^>]*> nop
++0000b55c <[^>]*> nop
++0000b560 <[^>]*> nop
++0000b564 <[^>]*> nop
++0000b568 <[^>]*> nop
++0000b56c <[^>]*> nop
++0000b570 <[^>]*> nop
++0000b574 <[^>]*> nop
++0000b578 <[^>]*> nop
++0000b57c <[^>]*> nop
++0000b580 <[^>]*> nop
++0000b584 <[^>]*> nop
++0000b588 <[^>]*> nop
++0000b58c <[^>]*> nop
++0000b590 <[^>]*> nop
++0000b594 <[^>]*> nop
++0000b598 <[^>]*> nop
++0000b59c <[^>]*> nop
++0000b5a0 <[^>]*> nop
++0000b5a4 <[^>]*> nop
++0000b5a8 <[^>]*> nop
++0000b5ac <[^>]*> nop
++0000b5b0 <[^>]*> nop
++0000b5b4 <[^>]*> nop
++0000b5b8 <[^>]*> nop
++0000b5bc <[^>]*> nop
++0000b5c0 <[^>]*> nop
++0000b5c4 <[^>]*> nop
++0000b5c8 <[^>]*> nop
++0000b5cc <[^>]*> nop
++0000b5d0 <[^>]*> nop
++0000b5d4 <[^>]*> nop
++0000b5d8 <[^>]*> nop
++0000b5dc <[^>]*> nop
++0000b5e0 <[^>]*> nop
++0000b5e4 <[^>]*> nop
++0000b5e8 <[^>]*> nop
++0000b5ec <[^>]*> nop
++0000b5f0 <[^>]*> nop
++0000b5f4 <[^>]*> nop
++0000b5f8 <[^>]*> nop
++0000b5fc <[^>]*> nop
++0000b600 <[^>]*> nop
++0000b604 <[^>]*> nop
++0000b608 <[^>]*> nop
++0000b60c <[^>]*> nop
++0000b610 <[^>]*> nop
++0000b614 <[^>]*> nop
++0000b618 <[^>]*> nop
++0000b61c <[^>]*> nop
++0000b620 <[^>]*> nop
++0000b624 <[^>]*> nop
++0000b628 <[^>]*> nop
++0000b62c <[^>]*> nop
++0000b630 <[^>]*> nop
++0000b634 <[^>]*> nop
++0000b638 <[^>]*> nop
++0000b63c <[^>]*> nop
++0000b640 <[^>]*> nop
++0000b644 <[^>]*> nop
++0000b648 <[^>]*> nop
++0000b64c <[^>]*> nop
++0000b650 <[^>]*> nop
++0000b654 <[^>]*> nop
++0000b658 <[^>]*> nop
++0000b65c <[^>]*> nop
++0000b660 <[^>]*> nop
++0000b664 <[^>]*> nop
++0000b668 <[^>]*> nop
++0000b66c <[^>]*> nop
++0000b670 <[^>]*> nop
++0000b674 <[^>]*> nop
++0000b678 <[^>]*> nop
++0000b67c <[^>]*> nop
++0000b680 <[^>]*> nop
++0000b684 <[^>]*> nop
++0000b688 <[^>]*> nop
++0000b68c <[^>]*> nop
++0000b690 <[^>]*> nop
++0000b694 <[^>]*> nop
++0000b698 <[^>]*> nop
++0000b69c <[^>]*> nop
++0000b6a0 <[^>]*> nop
++0000b6a4 <[^>]*> nop
++0000b6a8 <[^>]*> nop
++0000b6ac <[^>]*> nop
++0000b6b0 <[^>]*> nop
++0000b6b4 <[^>]*> nop
++0000b6b8 <[^>]*> nop
++0000b6bc <[^>]*> nop
++0000b6c0 <[^>]*> nop
++0000b6c4 <[^>]*> nop
++0000b6c8 <[^>]*> nop
++0000b6cc <[^>]*> nop
++0000b6d0 <[^>]*> nop
++0000b6d4 <[^>]*> nop
++0000b6d8 <[^>]*> nop
++0000b6dc <[^>]*> nop
++0000b6e0 <[^>]*> nop
++0000b6e4 <[^>]*> nop
++0000b6e8 <[^>]*> nop
++0000b6ec <[^>]*> nop
++0000b6f0 <[^>]*> nop
++0000b6f4 <[^>]*> nop
++0000b6f8 <[^>]*> nop
++0000b6fc <[^>]*> nop
++0000b700 <[^>]*> nop
++0000b704 <[^>]*> nop
++0000b708 <[^>]*> nop
++0000b70c <[^>]*> nop
++0000b710 <[^>]*> nop
++0000b714 <[^>]*> nop
++0000b718 <[^>]*> nop
++0000b71c <[^>]*> nop
++0000b720 <[^>]*> nop
++0000b724 <[^>]*> nop
++0000b728 <[^>]*> nop
++0000b72c <[^>]*> nop
++0000b730 <[^>]*> nop
++0000b734 <[^>]*> nop
++0000b738 <[^>]*> nop
++0000b73c <[^>]*> nop
++0000b740 <[^>]*> nop
++0000b744 <[^>]*> nop
++0000b748 <[^>]*> nop
++0000b74c <[^>]*> nop
++0000b750 <[^>]*> nop
++0000b754 <[^>]*> nop
++0000b758 <[^>]*> nop
++0000b75c <[^>]*> nop
++0000b760 <[^>]*> nop
++0000b764 <[^>]*> nop
++0000b768 <[^>]*> nop
++0000b76c <[^>]*> nop
++0000b770 <[^>]*> nop
++0000b774 <[^>]*> nop
++0000b778 <[^>]*> nop
++0000b77c <[^>]*> nop
++0000b780 <[^>]*> nop
++0000b784 <[^>]*> nop
++0000b788 <[^>]*> nop
++0000b78c <[^>]*> nop
++0000b790 <[^>]*> nop
++0000b794 <[^>]*> nop
++0000b798 <[^>]*> nop
++0000b79c <[^>]*> nop
++0000b7a0 <[^>]*> nop
++0000b7a4 <[^>]*> nop
++0000b7a8 <[^>]*> nop
++0000b7ac <[^>]*> nop
++0000b7b0 <[^>]*> nop
++0000b7b4 <[^>]*> nop
++0000b7b8 <[^>]*> nop
++0000b7bc <[^>]*> nop
++0000b7c0 <[^>]*> nop
++0000b7c4 <[^>]*> nop
++0000b7c8 <[^>]*> nop
++0000b7cc <[^>]*> nop
++0000b7d0 <[^>]*> nop
++0000b7d4 <[^>]*> nop
++0000b7d8 <[^>]*> nop
++0000b7dc <[^>]*> nop
++0000b7e0 <[^>]*> nop
++0000b7e4 <[^>]*> nop
++0000b7e8 <[^>]*> nop
++0000b7ec <[^>]*> nop
++0000b7f0 <[^>]*> nop
++0000b7f4 <[^>]*> nop
++0000b7f8 <[^>]*> nop
++0000b7fc <[^>]*> nop
++0000b800 <[^>]*> nop
++0000b804 <[^>]*> nop
++0000b808 <[^>]*> nop
++0000b80c <[^>]*> nop
++0000b810 <[^>]*> nop
++0000b814 <[^>]*> nop
++0000b818 <[^>]*> nop
++0000b81c <[^>]*> nop
++0000b820 <[^>]*> nop
++0000b824 <[^>]*> nop
++0000b828 <[^>]*> nop
++0000b82c <[^>]*> nop
++0000b830 <[^>]*> nop
++0000b834 <[^>]*> nop
++0000b838 <[^>]*> nop
++0000b83c <[^>]*> nop
++0000b840 <[^>]*> nop
++0000b844 <[^>]*> nop
++0000b848 <[^>]*> nop
++0000b84c <[^>]*> nop
++0000b850 <[^>]*> nop
++0000b854 <[^>]*> nop
++0000b858 <[^>]*> nop
++0000b85c <[^>]*> nop
++0000b860 <[^>]*> nop
++0000b864 <[^>]*> nop
++0000b868 <[^>]*> nop
++0000b86c <[^>]*> nop
++0000b870 <[^>]*> nop
++0000b874 <[^>]*> nop
++0000b878 <[^>]*> nop
++0000b87c <[^>]*> nop
++0000b880 <[^>]*> nop
++0000b884 <[^>]*> nop
++0000b888 <[^>]*> nop
++0000b88c <[^>]*> nop
++0000b890 <[^>]*> nop
++0000b894 <[^>]*> nop
++0000b898 <[^>]*> nop
++0000b89c <[^>]*> nop
++0000b8a0 <[^>]*> nop
++0000b8a4 <[^>]*> nop
++0000b8a8 <[^>]*> nop
++0000b8ac <[^>]*> nop
++0000b8b0 <[^>]*> nop
++0000b8b4 <[^>]*> nop
++0000b8b8 <[^>]*> nop
++0000b8bc <[^>]*> nop
++0000b8c0 <[^>]*> nop
++0000b8c4 <[^>]*> nop
++0000b8c8 <[^>]*> nop
++0000b8cc <[^>]*> nop
++0000b8d0 <[^>]*> nop
++0000b8d4 <[^>]*> nop
++0000b8d8 <[^>]*> nop
++0000b8dc <[^>]*> nop
++0000b8e0 <[^>]*> nop
++0000b8e4 <[^>]*> nop
++0000b8e8 <[^>]*> nop
++0000b8ec <[^>]*> nop
++0000b8f0 <[^>]*> nop
++0000b8f4 <[^>]*> nop
++0000b8f8 <[^>]*> nop
++0000b8fc <[^>]*> nop
++0000b900 <[^>]*> nop
++0000b904 <[^>]*> nop
++0000b908 <[^>]*> nop
++0000b90c <[^>]*> nop
++0000b910 <[^>]*> nop
++0000b914 <[^>]*> nop
++0000b918 <[^>]*> nop
++0000b91c <[^>]*> nop
++0000b920 <[^>]*> nop
++0000b924 <[^>]*> nop
++0000b928 <[^>]*> nop
++0000b92c <[^>]*> nop
++0000b930 <[^>]*> nop
++0000b934 <[^>]*> nop
++0000b938 <[^>]*> nop
++0000b93c <[^>]*> nop
++0000b940 <[^>]*> nop
++0000b944 <[^>]*> nop
++0000b948 <[^>]*> nop
++0000b94c <[^>]*> nop
++0000b950 <[^>]*> nop
++0000b954 <[^>]*> nop
++0000b958 <[^>]*> nop
++0000b95c <[^>]*> nop
++0000b960 <[^>]*> nop
++0000b964 <[^>]*> nop
++0000b968 <[^>]*> nop
++0000b96c <[^>]*> nop
++0000b970 <[^>]*> nop
++0000b974 <[^>]*> nop
++0000b978 <[^>]*> nop
++0000b97c <[^>]*> nop
++0000b980 <[^>]*> nop
++0000b984 <[^>]*> nop
++0000b988 <[^>]*> nop
++0000b98c <[^>]*> nop
++0000b990 <[^>]*> nop
++0000b994 <[^>]*> nop
++0000b998 <[^>]*> nop
++0000b99c <[^>]*> nop
++0000b9a0 <[^>]*> nop
++0000b9a4 <[^>]*> nop
++0000b9a8 <[^>]*> nop
++0000b9ac <[^>]*> nop
++0000b9b0 <[^>]*> nop
++0000b9b4 <[^>]*> nop
++0000b9b8 <[^>]*> nop
++0000b9bc <[^>]*> nop
++0000b9c0 <[^>]*> nop
++0000b9c4 <[^>]*> nop
++0000b9c8 <[^>]*> nop
++0000b9cc <[^>]*> nop
++0000b9d0 <[^>]*> nop
++0000b9d4 <[^>]*> nop
++0000b9d8 <[^>]*> nop
++0000b9dc <[^>]*> nop
++0000b9e0 <[^>]*> nop
++0000b9e4 <[^>]*> nop
++0000b9e8 <[^>]*> nop
++0000b9ec <[^>]*> nop
++0000b9f0 <[^>]*> nop
++0000b9f4 <[^>]*> nop
++0000b9f8 <[^>]*> nop
++0000b9fc <[^>]*> nop
++0000ba00 <[^>]*> nop
++0000ba04 <[^>]*> nop
++0000ba08 <[^>]*> nop
++0000ba0c <[^>]*> nop
++0000ba10 <[^>]*> nop
++0000ba14 <[^>]*> nop
++0000ba18 <[^>]*> nop
++0000ba1c <[^>]*> nop
++0000ba20 <[^>]*> nop
++0000ba24 <[^>]*> nop
++0000ba28 <[^>]*> nop
++0000ba2c <[^>]*> nop
++0000ba30 <[^>]*> nop
++0000ba34 <[^>]*> nop
++0000ba38 <[^>]*> nop
++0000ba3c <[^>]*> nop
++0000ba40 <[^>]*> nop
++0000ba44 <[^>]*> nop
++0000ba48 <[^>]*> nop
++0000ba4c <[^>]*> nop
++0000ba50 <[^>]*> nop
++0000ba54 <[^>]*> nop
++0000ba58 <[^>]*> nop
++0000ba5c <[^>]*> nop
++0000ba60 <[^>]*> nop
++0000ba64 <[^>]*> nop
++0000ba68 <[^>]*> nop
++0000ba6c <[^>]*> nop
++0000ba70 <[^>]*> nop
++0000ba74 <[^>]*> nop
++0000ba78 <[^>]*> nop
++0000ba7c <[^>]*> nop
++0000ba80 <[^>]*> nop
++0000ba84 <[^>]*> nop
++0000ba88 <[^>]*> nop
++0000ba8c <[^>]*> nop
++0000ba90 <[^>]*> nop
++0000ba94 <[^>]*> nop
++0000ba98 <[^>]*> nop
++0000ba9c <[^>]*> nop
++0000baa0 <[^>]*> nop
++0000baa4 <[^>]*> nop
++0000baa8 <[^>]*> nop
++0000baac <[^>]*> nop
++0000bab0 <[^>]*> nop
++0000bab4 <[^>]*> nop
++0000bab8 <[^>]*> nop
++0000babc <[^>]*> nop
++0000bac0 <[^>]*> nop
++0000bac4 <[^>]*> nop
++0000bac8 <[^>]*> nop
++0000bacc <[^>]*> nop
++0000bad0 <[^>]*> nop
++0000bad4 <[^>]*> nop
++0000bad8 <[^>]*> nop
++0000badc <[^>]*> nop
++0000bae0 <[^>]*> nop
++0000bae4 <[^>]*> nop
++0000bae8 <[^>]*> nop
++0000baec <[^>]*> nop
++0000baf0 <[^>]*> nop
++0000baf4 <[^>]*> nop
++0000baf8 <[^>]*> nop
++0000bafc <[^>]*> nop
++0000bb00 <[^>]*> nop
++0000bb04 <[^>]*> nop
++0000bb08 <[^>]*> nop
++0000bb0c <[^>]*> nop
++0000bb10 <[^>]*> nop
++0000bb14 <[^>]*> nop
++0000bb18 <[^>]*> nop
++0000bb1c <[^>]*> nop
++0000bb20 <[^>]*> nop
++0000bb24 <[^>]*> nop
++0000bb28 <[^>]*> nop
++0000bb2c <[^>]*> nop
++0000bb30 <[^>]*> nop
++0000bb34 <[^>]*> nop
++0000bb38 <[^>]*> nop
++0000bb3c <[^>]*> nop
++0000bb40 <[^>]*> nop
++0000bb44 <[^>]*> nop
++0000bb48 <[^>]*> nop
++0000bb4c <[^>]*> nop
++0000bb50 <[^>]*> nop
++0000bb54 <[^>]*> nop
++0000bb58 <[^>]*> nop
++0000bb5c <[^>]*> nop
++0000bb60 <[^>]*> nop
++0000bb64 <[^>]*> nop
++0000bb68 <[^>]*> nop
++0000bb6c <[^>]*> nop
++0000bb70 <[^>]*> nop
++0000bb74 <[^>]*> nop
++0000bb78 <[^>]*> nop
++0000bb7c <[^>]*> nop
++0000bb80 <[^>]*> nop
++0000bb84 <[^>]*> nop
++0000bb88 <[^>]*> nop
++0000bb8c <[^>]*> nop
++0000bb90 <[^>]*> nop
++0000bb94 <[^>]*> nop
++0000bb98 <[^>]*> nop
++0000bb9c <[^>]*> nop
++0000bba0 <[^>]*> nop
++0000bba4 <[^>]*> nop
++0000bba8 <[^>]*> nop
++0000bbac <[^>]*> nop
++0000bbb0 <[^>]*> nop
++0000bbb4 <[^>]*> nop
++0000bbb8 <[^>]*> nop
++0000bbbc <[^>]*> nop
++0000bbc0 <[^>]*> nop
++0000bbc4 <[^>]*> nop
++0000bbc8 <[^>]*> nop
++0000bbcc <[^>]*> nop
++0000bbd0 <[^>]*> nop
++0000bbd4 <[^>]*> nop
++0000bbd8 <[^>]*> nop
++0000bbdc <[^>]*> nop
++0000bbe0 <[^>]*> nop
++0000bbe4 <[^>]*> nop
++0000bbe8 <[^>]*> nop
++0000bbec <[^>]*> nop
++0000bbf0 <[^>]*> nop
++0000bbf4 <[^>]*> nop
++0000bbf8 <[^>]*> nop
++0000bbfc <[^>]*> nop
++0000bc00 <[^>]*> nop
++0000bc04 <[^>]*> nop
++0000bc08 <[^>]*> nop
++0000bc0c <[^>]*> nop
++0000bc10 <[^>]*> nop
++0000bc14 <[^>]*> nop
++0000bc18 <[^>]*> nop
++0000bc1c <[^>]*> nop
++0000bc20 <[^>]*> nop
++0000bc24 <[^>]*> nop
++0000bc28 <[^>]*> nop
++0000bc2c <[^>]*> nop
++0000bc30 <[^>]*> nop
++0000bc34 <[^>]*> nop
++0000bc38 <[^>]*> nop
++0000bc3c <[^>]*> nop
++0000bc40 <[^>]*> nop
++0000bc44 <[^>]*> nop
++0000bc48 <[^>]*> nop
++0000bc4c <[^>]*> nop
++0000bc50 <[^>]*> nop
++0000bc54 <[^>]*> nop
++0000bc58 <[^>]*> nop
++0000bc5c <[^>]*> nop
++0000bc60 <[^>]*> nop
++0000bc64 <[^>]*> nop
++0000bc68 <[^>]*> nop
++0000bc6c <[^>]*> nop
++0000bc70 <[^>]*> nop
++0000bc74 <[^>]*> nop
++0000bc78 <[^>]*> nop
++0000bc7c <[^>]*> nop
++0000bc80 <[^>]*> nop
++0000bc84 <[^>]*> nop
++0000bc88 <[^>]*> nop
++0000bc8c <[^>]*> nop
++0000bc90 <[^>]*> nop
++0000bc94 <[^>]*> nop
++0000bc98 <[^>]*> nop
++0000bc9c <[^>]*> nop
++0000bca0 <[^>]*> nop
++0000bca4 <[^>]*> nop
++0000bca8 <[^>]*> nop
++0000bcac <[^>]*> nop
++0000bcb0 <[^>]*> nop
++0000bcb4 <[^>]*> nop
++0000bcb8 <[^>]*> nop
++0000bcbc <[^>]*> nop
++0000bcc0 <[^>]*> nop
++0000bcc4 <[^>]*> nop
++0000bcc8 <[^>]*> nop
++0000bccc <[^>]*> nop
++0000bcd0 <[^>]*> nop
++0000bcd4 <[^>]*> nop
++0000bcd8 <[^>]*> nop
++0000bcdc <[^>]*> nop
++0000bce0 <[^>]*> nop
++0000bce4 <[^>]*> nop
++0000bce8 <[^>]*> nop
++0000bcec <[^>]*> nop
++0000bcf0 <[^>]*> nop
++0000bcf4 <[^>]*> nop
++0000bcf8 <[^>]*> nop
++0000bcfc <[^>]*> nop
++0000bd00 <[^>]*> nop
++0000bd04 <[^>]*> nop
++0000bd08 <[^>]*> nop
++0000bd0c <[^>]*> nop
++0000bd10 <[^>]*> nop
++0000bd14 <[^>]*> nop
++0000bd18 <[^>]*> nop
++0000bd1c <[^>]*> nop
++0000bd20 <[^>]*> nop
++0000bd24 <[^>]*> nop
++0000bd28 <[^>]*> nop
++0000bd2c <[^>]*> nop
++0000bd30 <[^>]*> nop
++0000bd34 <[^>]*> nop
++0000bd38 <[^>]*> nop
++0000bd3c <[^>]*> nop
++0000bd40 <[^>]*> nop
++0000bd44 <[^>]*> nop
++0000bd48 <[^>]*> nop
++0000bd4c <[^>]*> nop
++0000bd50 <[^>]*> nop
++0000bd54 <[^>]*> nop
++0000bd58 <[^>]*> nop
++0000bd5c <[^>]*> nop
++0000bd60 <[^>]*> nop
++0000bd64 <[^>]*> nop
++0000bd68 <[^>]*> nop
++0000bd6c <[^>]*> nop
++0000bd70 <[^>]*> nop
++0000bd74 <[^>]*> nop
++0000bd78 <[^>]*> nop
++0000bd7c <[^>]*> nop
++0000bd80 <[^>]*> nop
++0000bd84 <[^>]*> nop
++0000bd88 <[^>]*> nop
++0000bd8c <[^>]*> nop
++0000bd90 <[^>]*> nop
++0000bd94 <[^>]*> nop
++0000bd98 <[^>]*> nop
++0000bd9c <[^>]*> nop
++0000bda0 <[^>]*> nop
++0000bda4 <[^>]*> nop
++0000bda8 <[^>]*> nop
++0000bdac <[^>]*> nop
++0000bdb0 <[^>]*> nop
++0000bdb4 <[^>]*> nop
++0000bdb8 <[^>]*> nop
++0000bdbc <[^>]*> nop
++0000bdc0 <[^>]*> nop
++0000bdc4 <[^>]*> nop
++0000bdc8 <[^>]*> nop
++0000bdcc <[^>]*> nop
++0000bdd0 <[^>]*> nop
++0000bdd4 <[^>]*> nop
++0000bdd8 <[^>]*> nop
++0000bddc <[^>]*> nop
++0000bde0 <[^>]*> nop
++0000bde4 <[^>]*> nop
++0000bde8 <[^>]*> nop
++0000bdec <[^>]*> nop
++0000bdf0 <[^>]*> nop
++0000bdf4 <[^>]*> nop
++0000bdf8 <[^>]*> nop
++0000bdfc <[^>]*> nop
++0000be00 <[^>]*> nop
++0000be04 <[^>]*> nop
++0000be08 <[^>]*> nop
++0000be0c <[^>]*> nop
++0000be10 <[^>]*> nop
++0000be14 <[^>]*> nop
++0000be18 <[^>]*> nop
++0000be1c <[^>]*> nop
++0000be20 <[^>]*> nop
++0000be24 <[^>]*> nop
++0000be28 <[^>]*> nop
++0000be2c <[^>]*> nop
++0000be30 <[^>]*> nop
++0000be34 <[^>]*> nop
++0000be38 <[^>]*> nop
++0000be3c <[^>]*> nop
++0000be40 <[^>]*> nop
++0000be44 <[^>]*> nop
++0000be48 <[^>]*> nop
++0000be4c <[^>]*> nop
++0000be50 <[^>]*> nop
++0000be54 <[^>]*> nop
++0000be58 <[^>]*> nop
++0000be5c <[^>]*> nop
++0000be60 <[^>]*> nop
++0000be64 <[^>]*> nop
++0000be68 <[^>]*> nop
++0000be6c <[^>]*> nop
++0000be70 <[^>]*> nop
++0000be74 <[^>]*> nop
++0000be78 <[^>]*> nop
++0000be7c <[^>]*> nop
++0000be80 <[^>]*> nop
++0000be84 <[^>]*> nop
++0000be88 <[^>]*> nop
++0000be8c <[^>]*> nop
++0000be90 <[^>]*> nop
++0000be94 <[^>]*> nop
++0000be98 <[^>]*> nop
++0000be9c <[^>]*> nop
++0000bea0 <[^>]*> nop
++0000bea4 <[^>]*> nop
++0000bea8 <[^>]*> nop
++0000beac <[^>]*> nop
++0000beb0 <[^>]*> nop
++0000beb4 <[^>]*> nop
++0000beb8 <[^>]*> nop
++0000bebc <[^>]*> nop
++0000bec0 <[^>]*> nop
++0000bec4 <[^>]*> nop
++0000bec8 <[^>]*> nop
++0000becc <[^>]*> nop
++0000bed0 <[^>]*> nop
++0000bed4 <[^>]*> nop
++0000bed8 <[^>]*> nop
++0000bedc <[^>]*> nop
++0000bee0 <[^>]*> nop
++0000bee4 <[^>]*> nop
++0000bee8 <[^>]*> nop
++0000beec <[^>]*> nop
++0000bef0 <[^>]*> nop
++0000bef4 <[^>]*> nop
++0000bef8 <[^>]*> nop
++0000befc <[^>]*> nop
++0000bf00 <[^>]*> nop
++0000bf04 <[^>]*> nop
++0000bf08 <[^>]*> nop
++0000bf0c <[^>]*> nop
++0000bf10 <[^>]*> nop
++0000bf14 <[^>]*> nop
++0000bf18 <[^>]*> nop
++0000bf1c <[^>]*> nop
++0000bf20 <[^>]*> nop
++0000bf24 <[^>]*> nop
++0000bf28 <[^>]*> nop
++0000bf2c <[^>]*> nop
++0000bf30 <[^>]*> nop
++0000bf34 <[^>]*> nop
++0000bf38 <[^>]*> nop
++0000bf3c <[^>]*> nop
++0000bf40 <[^>]*> nop
++0000bf44 <[^>]*> nop
++0000bf48 <[^>]*> nop
++0000bf4c <[^>]*> nop
++0000bf50 <[^>]*> nop
++0000bf54 <[^>]*> nop
++0000bf58 <[^>]*> nop
++0000bf5c <[^>]*> nop
++0000bf60 <[^>]*> nop
++0000bf64 <[^>]*> nop
++0000bf68 <[^>]*> nop
++0000bf6c <[^>]*> nop
++0000bf70 <[^>]*> nop
++0000bf74 <[^>]*> nop
++0000bf78 <[^>]*> nop
++0000bf7c <[^>]*> nop
++0000bf80 <[^>]*> nop
++0000bf84 <[^>]*> nop
++0000bf88 <[^>]*> nop
++0000bf8c <[^>]*> nop
++0000bf90 <[^>]*> nop
++0000bf94 <[^>]*> nop
++0000bf98 <[^>]*> nop
++0000bf9c <[^>]*> nop
++0000bfa0 <[^>]*> nop
++0000bfa4 <[^>]*> nop
++0000bfa8 <[^>]*> nop
++0000bfac <[^>]*> nop
++0000bfb0 <[^>]*> nop
++0000bfb4 <[^>]*> nop
++0000bfb8 <[^>]*> nop
++0000bfbc <[^>]*> nop
++0000bfc0 <[^>]*> nop
++0000bfc4 <[^>]*> nop
++0000bfc8 <[^>]*> nop
++0000bfcc <[^>]*> nop
++0000bfd0 <[^>]*> nop
++0000bfd4 <[^>]*> nop
++0000bfd8 <[^>]*> nop
++0000bfdc <[^>]*> nop
++0000bfe0 <[^>]*> nop
++0000bfe4 <[^>]*> nop
++0000bfe8 <[^>]*> nop
++0000bfec <[^>]*> nop
++0000bff0 <[^>]*> nop
++0000bff4 <[^>]*> nop
++0000bff8 <[^>]*> nop
++0000bffc <[^>]*> nop
++0000c000 <[^>]*> nop
++0000c004 <[^>]*> nop
++0000c008 <[^>]*> nop
++0000c00c <[^>]*> nop
++0000c010 <[^>]*> nop
++0000c014 <[^>]*> nop
++0000c018 <[^>]*> nop
++0000c01c <[^>]*> nop
++0000c020 <[^>]*> nop
++0000c024 <[^>]*> nop
++0000c028 <[^>]*> nop
++0000c02c <[^>]*> nop
++0000c030 <[^>]*> nop
++0000c034 <[^>]*> nop
++0000c038 <[^>]*> nop
++0000c03c <[^>]*> nop
++0000c040 <[^>]*> nop
++0000c044 <[^>]*> nop
++0000c048 <[^>]*> nop
++0000c04c <[^>]*> nop
++0000c050 <[^>]*> nop
++0000c054 <[^>]*> nop
++0000c058 <[^>]*> nop
++0000c05c <[^>]*> nop
++0000c060 <[^>]*> nop
++0000c064 <[^>]*> nop
++0000c068 <[^>]*> nop
++0000c06c <[^>]*> nop
++0000c070 <[^>]*> nop
++0000c074 <[^>]*> nop
++0000c078 <[^>]*> nop
++0000c07c <[^>]*> nop
++0000c080 <[^>]*> nop
++0000c084 <[^>]*> nop
++0000c088 <[^>]*> nop
++0000c08c <[^>]*> nop
++0000c090 <[^>]*> nop
++0000c094 <[^>]*> nop
++0000c098 <[^>]*> nop
++0000c09c <[^>]*> nop
++0000c0a0 <[^>]*> nop
++0000c0a4 <[^>]*> nop
++0000c0a8 <[^>]*> nop
++0000c0ac <[^>]*> nop
++0000c0b0 <[^>]*> nop
++0000c0b4 <[^>]*> nop
++0000c0b8 <[^>]*> nop
++0000c0bc <[^>]*> nop
++0000c0c0 <[^>]*> nop
++0000c0c4 <[^>]*> nop
++0000c0c8 <[^>]*> nop
++0000c0cc <[^>]*> nop
++0000c0d0 <[^>]*> nop
++0000c0d4 <[^>]*> nop
++0000c0d8 <[^>]*> nop
++0000c0dc <[^>]*> nop
++0000c0e0 <[^>]*> nop
++0000c0e4 <[^>]*> nop
++0000c0e8 <[^>]*> nop
++0000c0ec <[^>]*> nop
++0000c0f0 <[^>]*> nop
++0000c0f4 <[^>]*> nop
++0000c0f8 <[^>]*> nop
++0000c0fc <[^>]*> nop
++0000c100 <[^>]*> nop
++0000c104 <[^>]*> nop
++0000c108 <[^>]*> nop
++0000c10c <[^>]*> nop
++0000c110 <[^>]*> nop
++0000c114 <[^>]*> nop
++0000c118 <[^>]*> nop
++0000c11c <[^>]*> nop
++0000c120 <[^>]*> nop
++0000c124 <[^>]*> nop
++0000c128 <[^>]*> nop
++0000c12c <[^>]*> nop
++0000c130 <[^>]*> nop
++0000c134 <[^>]*> nop
++0000c138 <[^>]*> nop
++0000c13c <[^>]*> nop
++0000c140 <[^>]*> nop
++0000c144 <[^>]*> nop
++0000c148 <[^>]*> nop
++0000c14c <[^>]*> nop
++0000c150 <[^>]*> nop
++0000c154 <[^>]*> nop
++0000c158 <[^>]*> nop
++0000c15c <[^>]*> nop
++0000c160 <[^>]*> nop
++0000c164 <[^>]*> nop
++0000c168 <[^>]*> nop
++0000c16c <[^>]*> nop
++0000c170 <[^>]*> nop
++0000c174 <[^>]*> nop
++0000c178 <[^>]*> nop
++0000c17c <[^>]*> nop
++0000c180 <[^>]*> nop
++0000c184 <[^>]*> nop
++0000c188 <[^>]*> nop
++0000c18c <[^>]*> nop
++0000c190 <[^>]*> nop
++0000c194 <[^>]*> nop
++0000c198 <[^>]*> nop
++0000c19c <[^>]*> nop
++0000c1a0 <[^>]*> nop
++0000c1a4 <[^>]*> nop
++0000c1a8 <[^>]*> nop
++0000c1ac <[^>]*> nop
++0000c1b0 <[^>]*> nop
++0000c1b4 <[^>]*> nop
++0000c1b8 <[^>]*> nop
++0000c1bc <[^>]*> nop
++0000c1c0 <[^>]*> nop
++0000c1c4 <[^>]*> nop
++0000c1c8 <[^>]*> nop
++0000c1cc <[^>]*> nop
++0000c1d0 <[^>]*> nop
++0000c1d4 <[^>]*> nop
++0000c1d8 <[^>]*> nop
++0000c1dc <[^>]*> nop
++0000c1e0 <[^>]*> nop
++0000c1e4 <[^>]*> nop
++0000c1e8 <[^>]*> nop
++0000c1ec <[^>]*> nop
++0000c1f0 <[^>]*> nop
++0000c1f4 <[^>]*> nop
++0000c1f8 <[^>]*> nop
++0000c1fc <[^>]*> nop
++0000c200 <[^>]*> nop
++0000c204 <[^>]*> nop
++0000c208 <[^>]*> nop
++0000c20c <[^>]*> nop
++0000c210 <[^>]*> nop
++0000c214 <[^>]*> nop
++0000c218 <[^>]*> nop
++0000c21c <[^>]*> nop
++0000c220 <[^>]*> nop
++0000c224 <[^>]*> nop
++0000c228 <[^>]*> nop
++0000c22c <[^>]*> nop
++0000c230 <[^>]*> nop
++0000c234 <[^>]*> nop
++0000c238 <[^>]*> nop
++0000c23c <[^>]*> nop
++0000c240 <[^>]*> nop
++0000c244 <[^>]*> nop
++0000c248 <[^>]*> nop
++0000c24c <[^>]*> nop
++0000c250 <[^>]*> nop
++0000c254 <[^>]*> nop
++0000c258 <[^>]*> nop
++0000c25c <[^>]*> nop
++0000c260 <[^>]*> nop
++0000c264 <[^>]*> nop
++0000c268 <[^>]*> nop
++0000c26c <[^>]*> nop
++0000c270 <[^>]*> nop
++0000c274 <[^>]*> nop
++0000c278 <[^>]*> nop
++0000c27c <[^>]*> nop
++0000c280 <[^>]*> nop
++0000c284 <[^>]*> nop
++0000c288 <[^>]*> nop
++0000c28c <[^>]*> nop
++0000c290 <[^>]*> nop
++0000c294 <[^>]*> nop
++0000c298 <[^>]*> nop
++0000c29c <[^>]*> nop
++0000c2a0 <[^>]*> nop
++0000c2a4 <[^>]*> nop
++0000c2a8 <[^>]*> nop
++0000c2ac <[^>]*> nop
++0000c2b0 <[^>]*> nop
++0000c2b4 <[^>]*> nop
++0000c2b8 <[^>]*> nop
++0000c2bc <[^>]*> nop
++0000c2c0 <[^>]*> nop
++0000c2c4 <[^>]*> nop
++0000c2c8 <[^>]*> nop
++0000c2cc <[^>]*> nop
++0000c2d0 <[^>]*> nop
++0000c2d4 <[^>]*> nop
++0000c2d8 <[^>]*> nop
++0000c2dc <[^>]*> nop
++0000c2e0 <[^>]*> nop
++0000c2e4 <[^>]*> nop
++0000c2e8 <[^>]*> nop
++0000c2ec <[^>]*> nop
++0000c2f0 <[^>]*> nop
++0000c2f4 <[^>]*> nop
++0000c2f8 <[^>]*> nop
++0000c2fc <[^>]*> nop
++0000c300 <[^>]*> nop
++0000c304 <[^>]*> nop
++0000c308 <[^>]*> nop
++0000c30c <[^>]*> nop
++0000c310 <[^>]*> nop
++0000c314 <[^>]*> nop
++0000c318 <[^>]*> nop
++0000c31c <[^>]*> nop
++0000c320 <[^>]*> nop
++0000c324 <[^>]*> nop
++0000c328 <[^>]*> nop
++0000c32c <[^>]*> nop
++0000c330 <[^>]*> nop
++0000c334 <[^>]*> nop
++0000c338 <[^>]*> nop
++0000c33c <[^>]*> nop
++0000c340 <[^>]*> nop
++0000c344 <[^>]*> nop
++0000c348 <[^>]*> nop
++0000c34c <[^>]*> nop
++0000c350 <[^>]*> nop
++0000c354 <[^>]*> nop
++0000c358 <[^>]*> nop
++0000c35c <[^>]*> nop
++0000c360 <[^>]*> nop
++0000c364 <[^>]*> nop
++0000c368 <[^>]*> nop
++0000c36c <[^>]*> nop
++0000c370 <[^>]*> nop
++0000c374 <[^>]*> nop
++0000c378 <[^>]*> nop
++0000c37c <[^>]*> nop
++0000c380 <[^>]*> nop
++0000c384 <[^>]*> nop
++0000c388 <[^>]*> nop
++0000c38c <[^>]*> nop
++0000c390 <[^>]*> nop
++0000c394 <[^>]*> nop
++0000c398 <[^>]*> nop
++0000c39c <[^>]*> nop
++0000c3a0 <[^>]*> nop
++0000c3a4 <[^>]*> nop
++0000c3a8 <[^>]*> nop
++0000c3ac <[^>]*> nop
++0000c3b0 <[^>]*> nop
++0000c3b4 <[^>]*> nop
++0000c3b8 <[^>]*> nop
++0000c3bc <[^>]*> nop
++0000c3c0 <[^>]*> nop
++0000c3c4 <[^>]*> nop
++0000c3c8 <[^>]*> nop
++0000c3cc <[^>]*> nop
++0000c3d0 <[^>]*> nop
++0000c3d4 <[^>]*> nop
++0000c3d8 <[^>]*> nop
++0000c3dc <[^>]*> nop
++0000c3e0 <[^>]*> nop
++0000c3e4 <[^>]*> nop
++0000c3e8 <[^>]*> nop
++0000c3ec <[^>]*> nop
++0000c3f0 <[^>]*> nop
++0000c3f4 <[^>]*> nop
++0000c3f8 <[^>]*> nop
++0000c3fc <[^>]*> nop
++0000c400 <[^>]*> nop
++0000c404 <[^>]*> nop
++0000c408 <[^>]*> nop
++0000c40c <[^>]*> nop
++0000c410 <[^>]*> nop
++0000c414 <[^>]*> nop
++0000c418 <[^>]*> nop
++0000c41c <[^>]*> nop
++0000c420 <[^>]*> nop
++0000c424 <[^>]*> nop
++0000c428 <[^>]*> nop
++0000c42c <[^>]*> nop
++0000c430 <[^>]*> nop
++0000c434 <[^>]*> nop
++0000c438 <[^>]*> nop
++0000c43c <[^>]*> nop
++0000c440 <[^>]*> nop
++0000c444 <[^>]*> nop
++0000c448 <[^>]*> nop
++0000c44c <[^>]*> nop
++0000c450 <[^>]*> nop
++0000c454 <[^>]*> nop
++0000c458 <[^>]*> nop
++0000c45c <[^>]*> nop
++0000c460 <[^>]*> nop
++0000c464 <[^>]*> nop
++0000c468 <[^>]*> nop
++0000c46c <[^>]*> nop
++0000c470 <[^>]*> nop
++0000c474 <[^>]*> nop
++0000c478 <[^>]*> nop
++0000c47c <[^>]*> nop
++0000c480 <[^>]*> nop
++0000c484 <[^>]*> nop
++0000c488 <[^>]*> nop
++0000c48c <[^>]*> nop
++0000c490 <[^>]*> nop
++0000c494 <[^>]*> nop
++0000c498 <[^>]*> nop
++0000c49c <[^>]*> nop
++0000c4a0 <[^>]*> nop
++0000c4a4 <[^>]*> nop
++0000c4a8 <[^>]*> nop
++0000c4ac <[^>]*> nop
++0000c4b0 <[^>]*> nop
++0000c4b4 <[^>]*> nop
++0000c4b8 <[^>]*> nop
++0000c4bc <[^>]*> nop
++0000c4c0 <[^>]*> nop
++0000c4c4 <[^>]*> nop
++0000c4c8 <[^>]*> nop
++0000c4cc <[^>]*> nop
++0000c4d0 <[^>]*> nop
++0000c4d4 <[^>]*> nop
++0000c4d8 <[^>]*> nop
++0000c4dc <[^>]*> nop
++0000c4e0 <[^>]*> nop
++0000c4e4 <[^>]*> nop
++0000c4e8 <[^>]*> nop
++0000c4ec <[^>]*> nop
++0000c4f0 <[^>]*> nop
++0000c4f4 <[^>]*> nop
++0000c4f8 <[^>]*> nop
++0000c4fc <[^>]*> nop
++0000c500 <[^>]*> nop
++0000c504 <[^>]*> nop
++0000c508 <[^>]*> nop
++0000c50c <[^>]*> nop
++0000c510 <[^>]*> nop
++0000c514 <[^>]*> nop
++0000c518 <[^>]*> nop
++0000c51c <[^>]*> nop
++0000c520 <[^>]*> nop
++0000c524 <[^>]*> nop
++0000c528 <[^>]*> nop
++0000c52c <[^>]*> nop
++0000c530 <[^>]*> nop
++0000c534 <[^>]*> nop
++0000c538 <[^>]*> nop
++0000c53c <[^>]*> nop
++0000c540 <[^>]*> nop
++0000c544 <[^>]*> nop
++0000c548 <[^>]*> nop
++0000c54c <[^>]*> nop
++0000c550 <[^>]*> nop
++0000c554 <[^>]*> nop
++0000c558 <[^>]*> nop
++0000c55c <[^>]*> nop
++0000c560 <[^>]*> nop
++0000c564 <[^>]*> nop
++0000c568 <[^>]*> nop
++0000c56c <[^>]*> nop
++0000c570 <[^>]*> nop
++0000c574 <[^>]*> nop
++0000c578 <[^>]*> nop
++0000c57c <[^>]*> nop
++0000c580 <[^>]*> nop
++0000c584 <[^>]*> nop
++0000c588 <[^>]*> nop
++0000c58c <[^>]*> nop
++0000c590 <[^>]*> nop
++0000c594 <[^>]*> nop
++0000c598 <[^>]*> nop
++0000c59c <[^>]*> nop
++0000c5a0 <[^>]*> nop
++0000c5a4 <[^>]*> nop
++0000c5a8 <[^>]*> nop
++0000c5ac <[^>]*> nop
++0000c5b0 <[^>]*> nop
++0000c5b4 <[^>]*> nop
++0000c5b8 <[^>]*> nop
++0000c5bc <[^>]*> nop
++0000c5c0 <[^>]*> nop
++0000c5c4 <[^>]*> nop
++0000c5c8 <[^>]*> nop
++0000c5cc <[^>]*> nop
++0000c5d0 <[^>]*> nop
++0000c5d4 <[^>]*> nop
++0000c5d8 <[^>]*> nop
++0000c5dc <[^>]*> nop
++0000c5e0 <[^>]*> nop
++0000c5e4 <[^>]*> nop
++0000c5e8 <[^>]*> nop
++0000c5ec <[^>]*> nop
++0000c5f0 <[^>]*> nop
++0000c5f4 <[^>]*> nop
++0000c5f8 <[^>]*> nop
++0000c5fc <[^>]*> nop
++0000c600 <[^>]*> nop
++0000c604 <[^>]*> nop
++0000c608 <[^>]*> nop
++0000c60c <[^>]*> nop
++0000c610 <[^>]*> nop
++0000c614 <[^>]*> nop
++0000c618 <[^>]*> nop
++0000c61c <[^>]*> nop
++0000c620 <[^>]*> nop
++0000c624 <[^>]*> nop
++0000c628 <[^>]*> nop
++0000c62c <[^>]*> nop
++0000c630 <[^>]*> nop
++0000c634 <[^>]*> nop
++0000c638 <[^>]*> nop
++0000c63c <[^>]*> nop
++0000c640 <[^>]*> nop
++0000c644 <[^>]*> nop
++0000c648 <[^>]*> nop
++0000c64c <[^>]*> nop
++0000c650 <[^>]*> nop
++0000c654 <[^>]*> nop
++0000c658 <[^>]*> nop
++0000c65c <[^>]*> nop
++0000c660 <[^>]*> nop
++0000c664 <[^>]*> nop
++0000c668 <[^>]*> nop
++0000c66c <[^>]*> nop
++0000c670 <[^>]*> nop
++0000c674 <[^>]*> nop
++0000c678 <[^>]*> nop
++0000c67c <[^>]*> nop
++0000c680 <[^>]*> nop
++0000c684 <[^>]*> nop
++0000c688 <[^>]*> nop
++0000c68c <[^>]*> nop
++0000c690 <[^>]*> nop
++0000c694 <[^>]*> nop
++0000c698 <[^>]*> nop
++0000c69c <[^>]*> nop
++0000c6a0 <[^>]*> nop
++0000c6a4 <[^>]*> nop
++0000c6a8 <[^>]*> nop
++0000c6ac <[^>]*> nop
++0000c6b0 <[^>]*> nop
++0000c6b4 <[^>]*> nop
++0000c6b8 <[^>]*> nop
++0000c6bc <[^>]*> nop
++0000c6c0 <[^>]*> nop
++0000c6c4 <[^>]*> nop
++0000c6c8 <[^>]*> nop
++0000c6cc <[^>]*> nop
++0000c6d0 <[^>]*> nop
++0000c6d4 <[^>]*> nop
++0000c6d8 <[^>]*> nop
++0000c6dc <[^>]*> nop
++0000c6e0 <[^>]*> nop
++0000c6e4 <[^>]*> nop
++0000c6e8 <[^>]*> nop
++0000c6ec <[^>]*> nop
++0000c6f0 <[^>]*> nop
++0000c6f4 <[^>]*> nop
++0000c6f8 <[^>]*> nop
++0000c6fc <[^>]*> nop
++0000c700 <[^>]*> nop
++0000c704 <[^>]*> nop
++0000c708 <[^>]*> nop
++0000c70c <[^>]*> nop
++0000c710 <[^>]*> nop
++0000c714 <[^>]*> nop
++0000c718 <[^>]*> nop
++0000c71c <[^>]*> nop
++0000c720 <[^>]*> nop
++0000c724 <[^>]*> nop
++0000c728 <[^>]*> nop
++0000c72c <[^>]*> nop
++0000c730 <[^>]*> nop
++0000c734 <[^>]*> nop
++0000c738 <[^>]*> nop
++0000c73c <[^>]*> nop
++0000c740 <[^>]*> nop
++0000c744 <[^>]*> nop
++0000c748 <[^>]*> nop
++0000c74c <[^>]*> nop
++0000c750 <[^>]*> nop
++0000c754 <[^>]*> nop
++0000c758 <[^>]*> nop
++0000c75c <[^>]*> nop
++0000c760 <[^>]*> nop
++0000c764 <[^>]*> nop
++0000c768 <[^>]*> nop
++0000c76c <[^>]*> nop
++0000c770 <[^>]*> nop
++0000c774 <[^>]*> nop
++0000c778 <[^>]*> nop
++0000c77c <[^>]*> nop
++0000c780 <[^>]*> nop
++0000c784 <[^>]*> nop
++0000c788 <[^>]*> nop
++0000c78c <[^>]*> nop
++0000c790 <[^>]*> nop
++0000c794 <[^>]*> nop
++0000c798 <[^>]*> nop
++0000c79c <[^>]*> nop
++0000c7a0 <[^>]*> nop
++0000c7a4 <[^>]*> nop
++0000c7a8 <[^>]*> nop
++0000c7ac <[^>]*> nop
++0000c7b0 <[^>]*> nop
++0000c7b4 <[^>]*> nop
++0000c7b8 <[^>]*> nop
++0000c7bc <[^>]*> nop
++0000c7c0 <[^>]*> nop
++0000c7c4 <[^>]*> nop
++0000c7c8 <[^>]*> nop
++0000c7cc <[^>]*> nop
++0000c7d0 <[^>]*> nop
++0000c7d4 <[^>]*> nop
++0000c7d8 <[^>]*> nop
++0000c7dc <[^>]*> nop
++0000c7e0 <[^>]*> nop
++0000c7e4 <[^>]*> nop
++0000c7e8 <[^>]*> nop
++0000c7ec <[^>]*> nop
++0000c7f0 <[^>]*> nop
++0000c7f4 <[^>]*> nop
++0000c7f8 <[^>]*> nop
++0000c7fc <[^>]*> nop
++0000c800 <[^>]*> nop
++0000c804 <[^>]*> nop
++0000c808 <[^>]*> nop
++0000c80c <[^>]*> nop
++0000c810 <[^>]*> nop
++0000c814 <[^>]*> nop
++0000c818 <[^>]*> nop
++0000c81c <[^>]*> nop
++0000c820 <[^>]*> nop
++0000c824 <[^>]*> nop
++0000c828 <[^>]*> nop
++0000c82c <[^>]*> nop
++0000c830 <[^>]*> nop
++0000c834 <[^>]*> nop
++0000c838 <[^>]*> nop
++0000c83c <[^>]*> nop
++0000c840 <[^>]*> nop
++0000c844 <[^>]*> nop
++0000c848 <[^>]*> nop
++0000c84c <[^>]*> nop
++0000c850 <[^>]*> nop
++0000c854 <[^>]*> nop
++0000c858 <[^>]*> nop
++0000c85c <[^>]*> nop
++0000c860 <[^>]*> nop
++0000c864 <[^>]*> nop
++0000c868 <[^>]*> nop
++0000c86c <[^>]*> nop
++0000c870 <[^>]*> nop
++0000c874 <[^>]*> nop
++0000c878 <[^>]*> nop
++0000c87c <[^>]*> nop
++0000c880 <[^>]*> nop
++0000c884 <[^>]*> nop
++0000c888 <[^>]*> nop
++0000c88c <[^>]*> nop
++0000c890 <[^>]*> nop
++0000c894 <[^>]*> nop
++0000c898 <[^>]*> nop
++0000c89c <[^>]*> nop
++0000c8a0 <[^>]*> nop
++0000c8a4 <[^>]*> nop
++0000c8a8 <[^>]*> nop
++0000c8ac <[^>]*> nop
++0000c8b0 <[^>]*> nop
++0000c8b4 <[^>]*> nop
++0000c8b8 <[^>]*> nop
++0000c8bc <[^>]*> nop
++0000c8c0 <[^>]*> nop
++0000c8c4 <[^>]*> nop
++0000c8c8 <[^>]*> nop
++0000c8cc <[^>]*> nop
++0000c8d0 <[^>]*> nop
++0000c8d4 <[^>]*> nop
++0000c8d8 <[^>]*> nop
++0000c8dc <[^>]*> nop
++0000c8e0 <[^>]*> nop
++0000c8e4 <[^>]*> nop
++0000c8e8 <[^>]*> nop
++0000c8ec <[^>]*> nop
++0000c8f0 <[^>]*> nop
++0000c8f4 <[^>]*> nop
++0000c8f8 <[^>]*> nop
++0000c8fc <[^>]*> nop
++0000c900 <[^>]*> nop
++0000c904 <[^>]*> nop
++0000c908 <[^>]*> nop
++0000c90c <[^>]*> nop
++0000c910 <[^>]*> nop
++0000c914 <[^>]*> nop
++0000c918 <[^>]*> nop
++0000c91c <[^>]*> nop
++0000c920 <[^>]*> nop
++0000c924 <[^>]*> nop
++0000c928 <[^>]*> nop
++0000c92c <[^>]*> nop
++0000c930 <[^>]*> nop
++0000c934 <[^>]*> nop
++0000c938 <[^>]*> nop
++0000c93c <[^>]*> nop
++0000c940 <[^>]*> nop
++0000c944 <[^>]*> nop
++0000c948 <[^>]*> nop
++0000c94c <[^>]*> nop
++0000c950 <[^>]*> nop
++0000c954 <[^>]*> nop
++0000c958 <[^>]*> nop
++0000c95c <[^>]*> nop
++0000c960 <[^>]*> nop
++0000c964 <[^>]*> nop
++0000c968 <[^>]*> nop
++0000c96c <[^>]*> nop
++0000c970 <[^>]*> nop
++0000c974 <[^>]*> nop
++0000c978 <[^>]*> nop
++0000c97c <[^>]*> nop
++0000c980 <[^>]*> nop
++0000c984 <[^>]*> nop
++0000c988 <[^>]*> nop
++0000c98c <[^>]*> nop
++0000c990 <[^>]*> nop
++0000c994 <[^>]*> nop
++0000c998 <[^>]*> nop
++0000c99c <[^>]*> nop
++0000c9a0 <[^>]*> nop
++0000c9a4 <[^>]*> nop
++0000c9a8 <[^>]*> nop
++0000c9ac <[^>]*> nop
++0000c9b0 <[^>]*> nop
++0000c9b4 <[^>]*> nop
++0000c9b8 <[^>]*> nop
++0000c9bc <[^>]*> nop
++0000c9c0 <[^>]*> nop
++0000c9c4 <[^>]*> nop
++0000c9c8 <[^>]*> nop
++0000c9cc <[^>]*> nop
++0000c9d0 <[^>]*> nop
++0000c9d4 <[^>]*> nop
++0000c9d8 <[^>]*> nop
++0000c9dc <[^>]*> nop
++0000c9e0 <[^>]*> nop
++0000c9e4 <[^>]*> nop
++0000c9e8 <[^>]*> nop
++0000c9ec <[^>]*> nop
++0000c9f0 <[^>]*> nop
++0000c9f4 <[^>]*> nop
++0000c9f8 <[^>]*> nop
++0000c9fc <[^>]*> nop
++0000ca00 <[^>]*> nop
++0000ca04 <[^>]*> nop
++0000ca08 <[^>]*> nop
++0000ca0c <[^>]*> nop
++0000ca10 <[^>]*> nop
++0000ca14 <[^>]*> nop
++0000ca18 <[^>]*> nop
++0000ca1c <[^>]*> nop
++0000ca20 <[^>]*> nop
++0000ca24 <[^>]*> nop
++0000ca28 <[^>]*> nop
++0000ca2c <[^>]*> nop
++0000ca30 <[^>]*> nop
++0000ca34 <[^>]*> nop
++0000ca38 <[^>]*> nop
++0000ca3c <[^>]*> nop
++0000ca40 <[^>]*> nop
++0000ca44 <[^>]*> nop
++0000ca48 <[^>]*> nop
++0000ca4c <[^>]*> nop
++0000ca50 <[^>]*> nop
++0000ca54 <[^>]*> nop
++0000ca58 <[^>]*> nop
++0000ca5c <[^>]*> nop
++0000ca60 <[^>]*> nop
++0000ca64 <[^>]*> nop
++0000ca68 <[^>]*> nop
++0000ca6c <[^>]*> nop
++0000ca70 <[^>]*> nop
++0000ca74 <[^>]*> nop
++0000ca78 <[^>]*> nop
++0000ca7c <[^>]*> nop
++0000ca80 <[^>]*> nop
++0000ca84 <[^>]*> nop
++0000ca88 <[^>]*> nop
++0000ca8c <[^>]*> nop
++0000ca90 <[^>]*> nop
++0000ca94 <[^>]*> nop
++0000ca98 <[^>]*> nop
++0000ca9c <[^>]*> nop
++0000caa0 <[^>]*> nop
++0000caa4 <[^>]*> nop
++0000caa8 <[^>]*> nop
++0000caac <[^>]*> nop
++0000cab0 <[^>]*> nop
++0000cab4 <[^>]*> nop
++0000cab8 <[^>]*> nop
++0000cabc <[^>]*> nop
++0000cac0 <[^>]*> nop
++0000cac4 <[^>]*> nop
++0000cac8 <[^>]*> nop
++0000cacc <[^>]*> nop
++0000cad0 <[^>]*> nop
++0000cad4 <[^>]*> nop
++0000cad8 <[^>]*> nop
++0000cadc <[^>]*> nop
++0000cae0 <[^>]*> nop
++0000cae4 <[^>]*> nop
++0000cae8 <[^>]*> nop
++0000caec <[^>]*> nop
++0000caf0 <[^>]*> nop
++0000caf4 <[^>]*> nop
++0000caf8 <[^>]*> nop
++0000cafc <[^>]*> nop
++0000cb00 <[^>]*> nop
++0000cb04 <[^>]*> nop
++0000cb08 <[^>]*> nop
++0000cb0c <[^>]*> nop
++0000cb10 <[^>]*> nop
++0000cb14 <[^>]*> nop
++0000cb18 <[^>]*> nop
++0000cb1c <[^>]*> nop
++0000cb20 <[^>]*> nop
++0000cb24 <[^>]*> nop
++0000cb28 <[^>]*> nop
++0000cb2c <[^>]*> nop
++0000cb30 <[^>]*> nop
++0000cb34 <[^>]*> nop
++0000cb38 <[^>]*> nop
++0000cb3c <[^>]*> nop
++0000cb40 <[^>]*> nop
++0000cb44 <[^>]*> nop
++0000cb48 <[^>]*> nop
++0000cb4c <[^>]*> nop
++0000cb50 <[^>]*> nop
++0000cb54 <[^>]*> nop
++0000cb58 <[^>]*> nop
++0000cb5c <[^>]*> nop
++0000cb60 <[^>]*> nop
++0000cb64 <[^>]*> nop
++0000cb68 <[^>]*> nop
++0000cb6c <[^>]*> nop
++0000cb70 <[^>]*> nop
++0000cb74 <[^>]*> nop
++0000cb78 <[^>]*> nop
++0000cb7c <[^>]*> nop
++0000cb80 <[^>]*> nop
++0000cb84 <[^>]*> nop
++0000cb88 <[^>]*> nop
++0000cb8c <[^>]*> nop
++0000cb90 <[^>]*> nop
++0000cb94 <[^>]*> nop
++0000cb98 <[^>]*> nop
++0000cb9c <[^>]*> nop
++0000cba0 <[^>]*> nop
++0000cba4 <[^>]*> nop
++0000cba8 <[^>]*> nop
++0000cbac <[^>]*> nop
++0000cbb0 <[^>]*> nop
++0000cbb4 <[^>]*> nop
++0000cbb8 <[^>]*> nop
++0000cbbc <[^>]*> nop
++0000cbc0 <[^>]*> nop
++0000cbc4 <[^>]*> nop
++0000cbc8 <[^>]*> nop
++0000cbcc <[^>]*> nop
++0000cbd0 <[^>]*> nop
++0000cbd4 <[^>]*> nop
++0000cbd8 <[^>]*> nop
++0000cbdc <[^>]*> nop
++0000cbe0 <[^>]*> nop
++0000cbe4 <[^>]*> nop
++0000cbe8 <[^>]*> nop
++0000cbec <[^>]*> nop
++0000cbf0 <[^>]*> nop
++0000cbf4 <[^>]*> nop
++0000cbf8 <[^>]*> nop
++0000cbfc <[^>]*> nop
++0000cc00 <[^>]*> nop
++0000cc04 <[^>]*> nop
++0000cc08 <[^>]*> nop
++0000cc0c <[^>]*> nop
++0000cc10 <[^>]*> nop
++0000cc14 <[^>]*> nop
++0000cc18 <[^>]*> nop
++0000cc1c <[^>]*> nop
++0000cc20 <[^>]*> nop
++0000cc24 <[^>]*> nop
++0000cc28 <[^>]*> nop
++0000cc2c <[^>]*> nop
++0000cc30 <[^>]*> nop
++0000cc34 <[^>]*> nop
++0000cc38 <[^>]*> nop
++0000cc3c <[^>]*> nop
++0000cc40 <[^>]*> nop
++0000cc44 <[^>]*> nop
++0000cc48 <[^>]*> nop
++0000cc4c <[^>]*> nop
++0000cc50 <[^>]*> nop
++0000cc54 <[^>]*> nop
++0000cc58 <[^>]*> nop
++0000cc5c <[^>]*> nop
++0000cc60 <[^>]*> nop
++0000cc64 <[^>]*> nop
++0000cc68 <[^>]*> nop
++0000cc6c <[^>]*> nop
++0000cc70 <[^>]*> nop
++0000cc74 <[^>]*> nop
++0000cc78 <[^>]*> nop
++0000cc7c <[^>]*> nop
++0000cc80 <[^>]*> nop
++0000cc84 <[^>]*> nop
++0000cc88 <[^>]*> nop
++0000cc8c <[^>]*> nop
++0000cc90 <[^>]*> nop
++0000cc94 <[^>]*> nop
++0000cc98 <[^>]*> nop
++0000cc9c <[^>]*> nop
++0000cca0 <[^>]*> nop
++0000cca4 <[^>]*> nop
++0000cca8 <[^>]*> nop
++0000ccac <[^>]*> nop
++0000ccb0 <[^>]*> nop
++0000ccb4 <[^>]*> nop
++0000ccb8 <[^>]*> nop
++0000ccbc <[^>]*> nop
++0000ccc0 <[^>]*> nop
++0000ccc4 <[^>]*> nop
++0000ccc8 <[^>]*> nop
++0000cccc <[^>]*> nop
++0000ccd0 <[^>]*> nop
++0000ccd4 <[^>]*> nop
++0000ccd8 <[^>]*> nop
++0000ccdc <[^>]*> nop
++0000cce0 <[^>]*> nop
++0000cce4 <[^>]*> nop
++0000cce8 <[^>]*> nop
++0000ccec <[^>]*> nop
++0000ccf0 <[^>]*> nop
++0000ccf4 <[^>]*> nop
++0000ccf8 <[^>]*> nop
++0000ccfc <[^>]*> nop
++0000cd00 <[^>]*> nop
++0000cd04 <[^>]*> nop
++0000cd08 <[^>]*> nop
++0000cd0c <[^>]*> nop
++0000cd10 <[^>]*> nop
++0000cd14 <[^>]*> nop
++0000cd18 <[^>]*> nop
++0000cd1c <[^>]*> nop
++0000cd20 <[^>]*> nop
++0000cd24 <[^>]*> nop
++0000cd28 <[^>]*> nop
++0000cd2c <[^>]*> nop
++0000cd30 <[^>]*> nop
++0000cd34 <[^>]*> nop
++0000cd38 <[^>]*> nop
++0000cd3c <[^>]*> nop
++0000cd40 <[^>]*> nop
++0000cd44 <[^>]*> nop
++0000cd48 <[^>]*> nop
++0000cd4c <[^>]*> nop
++0000cd50 <[^>]*> nop
++0000cd54 <[^>]*> nop
++0000cd58 <[^>]*> nop
++0000cd5c <[^>]*> nop
++0000cd60 <[^>]*> nop
++0000cd64 <[^>]*> nop
++0000cd68 <[^>]*> nop
++0000cd6c <[^>]*> nop
++0000cd70 <[^>]*> nop
++0000cd74 <[^>]*> nop
++0000cd78 <[^>]*> nop
++0000cd7c <[^>]*> nop
++0000cd80 <[^>]*> nop
++0000cd84 <[^>]*> nop
++0000cd88 <[^>]*> nop
++0000cd8c <[^>]*> nop
++0000cd90 <[^>]*> nop
++0000cd94 <[^>]*> nop
++0000cd98 <[^>]*> nop
++0000cd9c <[^>]*> nop
++0000cda0 <[^>]*> nop
++0000cda4 <[^>]*> nop
++0000cda8 <[^>]*> nop
++0000cdac <[^>]*> nop
++0000cdb0 <[^>]*> nop
++0000cdb4 <[^>]*> nop
++0000cdb8 <[^>]*> nop
++0000cdbc <[^>]*> nop
++0000cdc0 <[^>]*> nop
++0000cdc4 <[^>]*> nop
++0000cdc8 <[^>]*> nop
++0000cdcc <[^>]*> nop
++0000cdd0 <[^>]*> nop
++0000cdd4 <[^>]*> nop
++0000cdd8 <[^>]*> nop
++0000cddc <[^>]*> nop
++0000cde0 <[^>]*> nop
++0000cde4 <[^>]*> nop
++0000cde8 <[^>]*> nop
++0000cdec <[^>]*> nop
++0000cdf0 <[^>]*> nop
++0000cdf4 <[^>]*> nop
++0000cdf8 <[^>]*> nop
++0000cdfc <[^>]*> nop
++0000ce00 <[^>]*> nop
++0000ce04 <[^>]*> nop
++0000ce08 <[^>]*> nop
++0000ce0c <[^>]*> nop
++0000ce10 <[^>]*> nop
++0000ce14 <[^>]*> nop
++0000ce18 <[^>]*> nop
++0000ce1c <[^>]*> nop
++0000ce20 <[^>]*> nop
++0000ce24 <[^>]*> nop
++0000ce28 <[^>]*> nop
++0000ce2c <[^>]*> nop
++0000ce30 <[^>]*> nop
++0000ce34 <[^>]*> nop
++0000ce38 <[^>]*> nop
++0000ce3c <[^>]*> nop
++0000ce40 <[^>]*> nop
++0000ce44 <[^>]*> nop
++0000ce48 <[^>]*> nop
++0000ce4c <[^>]*> nop
++0000ce50 <[^>]*> nop
++0000ce54 <[^>]*> nop
++0000ce58 <[^>]*> nop
++0000ce5c <[^>]*> nop
++0000ce60 <[^>]*> nop
++0000ce64 <[^>]*> nop
++0000ce68 <[^>]*> nop
++0000ce6c <[^>]*> nop
++0000ce70 <[^>]*> nop
++0000ce74 <[^>]*> nop
++0000ce78 <[^>]*> nop
++0000ce7c <[^>]*> nop
++0000ce80 <[^>]*> nop
++0000ce84 <[^>]*> nop
++0000ce88 <[^>]*> nop
++0000ce8c <[^>]*> nop
++0000ce90 <[^>]*> nop
++0000ce94 <[^>]*> nop
++0000ce98 <[^>]*> nop
++0000ce9c <[^>]*> nop
++0000cea0 <[^>]*> nop
++0000cea4 <[^>]*> nop
++0000cea8 <[^>]*> nop
++0000ceac <[^>]*> nop
++0000ceb0 <[^>]*> nop
++0000ceb4 <[^>]*> nop
++0000ceb8 <[^>]*> nop
++0000cebc <[^>]*> nop
++0000cec0 <[^>]*> nop
++0000cec4 <[^>]*> nop
++0000cec8 <[^>]*> nop
++0000cecc <[^>]*> nop
++0000ced0 <[^>]*> nop
++0000ced4 <[^>]*> nop
++0000ced8 <[^>]*> nop
++0000cedc <[^>]*> nop
++0000cee0 <[^>]*> nop
++0000cee4 <[^>]*> nop
++0000cee8 <[^>]*> nop
++0000ceec <[^>]*> nop
++0000cef0 <[^>]*> nop
++0000cef4 <[^>]*> nop
++0000cef8 <[^>]*> nop
++0000cefc <[^>]*> nop
++0000cf00 <[^>]*> nop
++0000cf04 <[^>]*> nop
++0000cf08 <[^>]*> nop
++0000cf0c <[^>]*> nop
++0000cf10 <[^>]*> nop
++0000cf14 <[^>]*> nop
++0000cf18 <[^>]*> nop
++0000cf1c <[^>]*> nop
++0000cf20 <[^>]*> nop
++0000cf24 <[^>]*> nop
++0000cf28 <[^>]*> nop
++0000cf2c <[^>]*> nop
++0000cf30 <[^>]*> nop
++0000cf34 <[^>]*> nop
++0000cf38 <[^>]*> nop
++0000cf3c <[^>]*> nop
++0000cf40 <[^>]*> nop
++0000cf44 <[^>]*> nop
++0000cf48 <[^>]*> nop
++0000cf4c <[^>]*> nop
++0000cf50 <[^>]*> nop
++0000cf54 <[^>]*> nop
++0000cf58 <[^>]*> nop
++0000cf5c <[^>]*> nop
++0000cf60 <[^>]*> nop
++0000cf64 <[^>]*> nop
++0000cf68 <[^>]*> nop
++0000cf6c <[^>]*> nop
++0000cf70 <[^>]*> nop
++0000cf74 <[^>]*> nop
++0000cf78 <[^>]*> nop
++0000cf7c <[^>]*> nop
++0000cf80 <[^>]*> nop
++0000cf84 <[^>]*> nop
++0000cf88 <[^>]*> nop
++0000cf8c <[^>]*> nop
++0000cf90 <[^>]*> nop
++0000cf94 <[^>]*> nop
++0000cf98 <[^>]*> nop
++0000cf9c <[^>]*> nop
++0000cfa0 <[^>]*> nop
++0000cfa4 <[^>]*> nop
++0000cfa8 <[^>]*> nop
++0000cfac <[^>]*> nop
++0000cfb0 <[^>]*> nop
++0000cfb4 <[^>]*> nop
++0000cfb8 <[^>]*> nop
++0000cfbc <[^>]*> nop
++0000cfc0 <[^>]*> nop
++0000cfc4 <[^>]*> nop
++0000cfc8 <[^>]*> nop
++0000cfcc <[^>]*> nop
++0000cfd0 <[^>]*> nop
++0000cfd4 <[^>]*> nop
++0000cfd8 <[^>]*> nop
++0000cfdc <[^>]*> nop
++0000cfe0 <[^>]*> nop
++0000cfe4 <[^>]*> nop
++0000cfe8 <[^>]*> nop
++0000cfec <[^>]*> nop
++0000cff0 <[^>]*> nop
++0000cff4 <[^>]*> nop
++0000cff8 <[^>]*> nop
++0000cffc <[^>]*> nop
++0000d000 <[^>]*> nop
++0000d004 <[^>]*> nop
++0000d008 <[^>]*> nop
++0000d00c <[^>]*> nop
++0000d010 <[^>]*> nop
++0000d014 <[^>]*> nop
++0000d018 <[^>]*> nop
++0000d01c <[^>]*> nop
++0000d020 <[^>]*> nop
++0000d024 <[^>]*> nop
++0000d028 <[^>]*> nop
++0000d02c <[^>]*> nop
++0000d030 <[^>]*> nop
++0000d034 <[^>]*> nop
++0000d038 <[^>]*> nop
++0000d03c <[^>]*> nop
++0000d040 <[^>]*> nop
++0000d044 <[^>]*> nop
++0000d048 <[^>]*> nop
++0000d04c <[^>]*> nop
++0000d050 <[^>]*> nop
++0000d054 <[^>]*> nop
++0000d058 <[^>]*> nop
++0000d05c <[^>]*> nop
++0000d060 <[^>]*> nop
++0000d064 <[^>]*> nop
++0000d068 <[^>]*> nop
++0000d06c <[^>]*> nop
++0000d070 <[^>]*> nop
++0000d074 <[^>]*> nop
++0000d078 <[^>]*> nop
++0000d07c <[^>]*> nop
++0000d080 <[^>]*> nop
++0000d084 <[^>]*> nop
++0000d088 <[^>]*> nop
++0000d08c <[^>]*> nop
++0000d090 <[^>]*> nop
++0000d094 <[^>]*> nop
++0000d098 <[^>]*> nop
++0000d09c <[^>]*> nop
++0000d0a0 <[^>]*> nop
++0000d0a4 <[^>]*> nop
++0000d0a8 <[^>]*> nop
++0000d0ac <[^>]*> nop
++0000d0b0 <[^>]*> nop
++0000d0b4 <[^>]*> nop
++0000d0b8 <[^>]*> nop
++0000d0bc <[^>]*> nop
++0000d0c0 <[^>]*> nop
++0000d0c4 <[^>]*> nop
++0000d0c8 <[^>]*> nop
++0000d0cc <[^>]*> nop
++0000d0d0 <[^>]*> nop
++0000d0d4 <[^>]*> nop
++0000d0d8 <[^>]*> nop
++0000d0dc <[^>]*> nop
++0000d0e0 <[^>]*> nop
++0000d0e4 <[^>]*> nop
++0000d0e8 <[^>]*> nop
++0000d0ec <[^>]*> nop
++0000d0f0 <[^>]*> nop
++0000d0f4 <[^>]*> nop
++0000d0f8 <[^>]*> nop
++0000d0fc <[^>]*> nop
++0000d100 <[^>]*> nop
++0000d104 <[^>]*> nop
++0000d108 <[^>]*> nop
++0000d10c <[^>]*> nop
++0000d110 <[^>]*> nop
++0000d114 <[^>]*> nop
++0000d118 <[^>]*> nop
++0000d11c <[^>]*> nop
++0000d120 <[^>]*> nop
++0000d124 <[^>]*> nop
++0000d128 <[^>]*> nop
++0000d12c <[^>]*> nop
++0000d130 <[^>]*> nop
++0000d134 <[^>]*> nop
++0000d138 <[^>]*> nop
++0000d13c <[^>]*> nop
++0000d140 <[^>]*> nop
++0000d144 <[^>]*> nop
++0000d148 <[^>]*> nop
++0000d14c <[^>]*> nop
++0000d150 <[^>]*> nop
++0000d154 <[^>]*> nop
++0000d158 <[^>]*> nop
++0000d15c <[^>]*> nop
++0000d160 <[^>]*> nop
++0000d164 <[^>]*> nop
++0000d168 <[^>]*> nop
++0000d16c <[^>]*> nop
++0000d170 <[^>]*> nop
++0000d174 <[^>]*> nop
++0000d178 <[^>]*> nop
++0000d17c <[^>]*> nop
++0000d180 <[^>]*> nop
++0000d184 <[^>]*> nop
++0000d188 <[^>]*> nop
++0000d18c <[^>]*> nop
++0000d190 <[^>]*> nop
++0000d194 <[^>]*> nop
++0000d198 <[^>]*> nop
++0000d19c <[^>]*> nop
++0000d1a0 <[^>]*> nop
++0000d1a4 <[^>]*> nop
++0000d1a8 <[^>]*> nop
++0000d1ac <[^>]*> nop
++0000d1b0 <[^>]*> nop
++0000d1b4 <[^>]*> nop
++0000d1b8 <[^>]*> nop
++0000d1bc <[^>]*> nop
++0000d1c0 <[^>]*> nop
++0000d1c4 <[^>]*> nop
++0000d1c8 <[^>]*> nop
++0000d1cc <[^>]*> nop
++0000d1d0 <[^>]*> nop
++0000d1d4 <[^>]*> nop
++0000d1d8 <[^>]*> nop
++0000d1dc <[^>]*> nop
++0000d1e0 <[^>]*> nop
++0000d1e4 <[^>]*> nop
++0000d1e8 <[^>]*> nop
++0000d1ec <[^>]*> nop
++0000d1f0 <[^>]*> nop
++0000d1f4 <[^>]*> nop
++0000d1f8 <[^>]*> nop
++0000d1fc <[^>]*> nop
++0000d200 <[^>]*> nop
++0000d204 <[^>]*> nop
++0000d208 <[^>]*> nop
++0000d20c <[^>]*> nop
++0000d210 <[^>]*> nop
++0000d214 <[^>]*> nop
++0000d218 <[^>]*> nop
++0000d21c <[^>]*> nop
++0000d220 <[^>]*> nop
++0000d224 <[^>]*> nop
++0000d228 <[^>]*> nop
++0000d22c <[^>]*> nop
++0000d230 <[^>]*> nop
++0000d234 <[^>]*> nop
++0000d238 <[^>]*> nop
++0000d23c <[^>]*> nop
++0000d240 <[^>]*> nop
++0000d244 <[^>]*> nop
++0000d248 <[^>]*> nop
++0000d24c <[^>]*> nop
++0000d250 <[^>]*> nop
++0000d254 <[^>]*> nop
++0000d258 <[^>]*> nop
++0000d25c <[^>]*> nop
++0000d260 <[^>]*> nop
++0000d264 <[^>]*> nop
++0000d268 <[^>]*> nop
++0000d26c <[^>]*> nop
++0000d270 <[^>]*> nop
++0000d274 <[^>]*> nop
++0000d278 <[^>]*> nop
++0000d27c <[^>]*> nop
++0000d280 <[^>]*> nop
++0000d284 <[^>]*> nop
++0000d288 <[^>]*> nop
++0000d28c <[^>]*> nop
++0000d290 <[^>]*> nop
++0000d294 <[^>]*> nop
++0000d298 <[^>]*> nop
++0000d29c <[^>]*> nop
++0000d2a0 <[^>]*> nop
++0000d2a4 <[^>]*> nop
++0000d2a8 <[^>]*> nop
++0000d2ac <[^>]*> nop
++0000d2b0 <[^>]*> nop
++0000d2b4 <[^>]*> nop
++0000d2b8 <[^>]*> nop
++0000d2bc <[^>]*> nop
++0000d2c0 <[^>]*> nop
++0000d2c4 <[^>]*> nop
++0000d2c8 <[^>]*> nop
++0000d2cc <[^>]*> nop
++0000d2d0 <[^>]*> nop
++0000d2d4 <[^>]*> nop
++0000d2d8 <[^>]*> nop
++0000d2dc <[^>]*> nop
++0000d2e0 <[^>]*> nop
++0000d2e4 <[^>]*> nop
++0000d2e8 <[^>]*> nop
++0000d2ec <[^>]*> nop
++0000d2f0 <[^>]*> nop
++0000d2f4 <[^>]*> nop
++0000d2f8 <[^>]*> nop
++0000d2fc <[^>]*> nop
++0000d300 <[^>]*> nop
++0000d304 <[^>]*> nop
++0000d308 <[^>]*> nop
++0000d30c <[^>]*> nop
++0000d310 <[^>]*> nop
++0000d314 <[^>]*> nop
++0000d318 <[^>]*> nop
++0000d31c <[^>]*> nop
++0000d320 <[^>]*> nop
++0000d324 <[^>]*> nop
++0000d328 <[^>]*> nop
++0000d32c <[^>]*> nop
++0000d330 <[^>]*> nop
++0000d334 <[^>]*> nop
++0000d338 <[^>]*> nop
++0000d33c <[^>]*> nop
++0000d340 <[^>]*> nop
++0000d344 <[^>]*> nop
++0000d348 <[^>]*> nop
++0000d34c <[^>]*> nop
++0000d350 <[^>]*> nop
++0000d354 <[^>]*> nop
++0000d358 <[^>]*> nop
++0000d35c <[^>]*> nop
++0000d360 <[^>]*> nop
++0000d364 <[^>]*> nop
++0000d368 <[^>]*> nop
++0000d36c <[^>]*> nop
++0000d370 <[^>]*> nop
++0000d374 <[^>]*> nop
++0000d378 <[^>]*> nop
++0000d37c <[^>]*> nop
++0000d380 <[^>]*> nop
++0000d384 <[^>]*> nop
++0000d388 <[^>]*> nop
++0000d38c <[^>]*> nop
++0000d390 <[^>]*> nop
++0000d394 <[^>]*> nop
++0000d398 <[^>]*> nop
++0000d39c <[^>]*> nop
++0000d3a0 <[^>]*> nop
++0000d3a4 <[^>]*> nop
++0000d3a8 <[^>]*> nop
++0000d3ac <[^>]*> nop
++0000d3b0 <[^>]*> nop
++0000d3b4 <[^>]*> nop
++0000d3b8 <[^>]*> nop
++0000d3bc <[^>]*> nop
++0000d3c0 <[^>]*> nop
++0000d3c4 <[^>]*> nop
++0000d3c8 <[^>]*> nop
++0000d3cc <[^>]*> nop
++0000d3d0 <[^>]*> nop
++0000d3d4 <[^>]*> nop
++0000d3d8 <[^>]*> nop
++0000d3dc <[^>]*> nop
++0000d3e0 <[^>]*> nop
++0000d3e4 <[^>]*> nop
++0000d3e8 <[^>]*> nop
++0000d3ec <[^>]*> nop
++0000d3f0 <[^>]*> nop
++0000d3f4 <[^>]*> nop
++0000d3f8 <[^>]*> nop
++0000d3fc <[^>]*> nop
++0000d400 <[^>]*> nop
++0000d404 <[^>]*> nop
++0000d408 <[^>]*> nop
++0000d40c <[^>]*> nop
++0000d410 <[^>]*> nop
++0000d414 <[^>]*> nop
++0000d418 <[^>]*> nop
++0000d41c <[^>]*> nop
++0000d420 <[^>]*> nop
++0000d424 <[^>]*> nop
++0000d428 <[^>]*> nop
++0000d42c <[^>]*> nop
++0000d430 <[^>]*> nop
++0000d434 <[^>]*> nop
++0000d438 <[^>]*> nop
++0000d43c <[^>]*> nop
++0000d440 <[^>]*> nop
++0000d444 <[^>]*> nop
++0000d448 <[^>]*> nop
++0000d44c <[^>]*> nop
++0000d450 <[^>]*> nop
++0000d454 <[^>]*> nop
++0000d458 <[^>]*> nop
++0000d45c <[^>]*> nop
++0000d460 <[^>]*> nop
++0000d464 <[^>]*> nop
++0000d468 <[^>]*> nop
++0000d46c <[^>]*> nop
++0000d470 <[^>]*> nop
++0000d474 <[^>]*> nop
++0000d478 <[^>]*> nop
++0000d47c <[^>]*> nop
++0000d480 <[^>]*> nop
++0000d484 <[^>]*> nop
++0000d488 <[^>]*> nop
++0000d48c <[^>]*> nop
++0000d490 <[^>]*> nop
++0000d494 <[^>]*> nop
++0000d498 <[^>]*> nop
++0000d49c <[^>]*> nop
++0000d4a0 <[^>]*> nop
++0000d4a4 <[^>]*> nop
++0000d4a8 <[^>]*> nop
++0000d4ac <[^>]*> nop
++0000d4b0 <[^>]*> nop
++0000d4b4 <[^>]*> nop
++0000d4b8 <[^>]*> nop
++0000d4bc <[^>]*> nop
++0000d4c0 <[^>]*> nop
++0000d4c4 <[^>]*> nop
++0000d4c8 <[^>]*> nop
++0000d4cc <[^>]*> nop
++0000d4d0 <[^>]*> nop
++0000d4d4 <[^>]*> nop
++0000d4d8 <[^>]*> nop
++0000d4dc <[^>]*> nop
++0000d4e0 <[^>]*> nop
++0000d4e4 <[^>]*> nop
++0000d4e8 <[^>]*> nop
++0000d4ec <[^>]*> nop
++0000d4f0 <[^>]*> nop
++0000d4f4 <[^>]*> nop
++0000d4f8 <[^>]*> nop
++0000d4fc <[^>]*> nop
++0000d500 <[^>]*> nop
++0000d504 <[^>]*> nop
++0000d508 <[^>]*> nop
++0000d50c <[^>]*> nop
++0000d510 <[^>]*> nop
++0000d514 <[^>]*> nop
++0000d518 <[^>]*> nop
++0000d51c <[^>]*> nop
++0000d520 <[^>]*> nop
++0000d524 <[^>]*> nop
++0000d528 <[^>]*> nop
++0000d52c <[^>]*> nop
++0000d530 <[^>]*> nop
++0000d534 <[^>]*> nop
++0000d538 <[^>]*> nop
++0000d53c <[^>]*> nop
++0000d540 <[^>]*> nop
++0000d544 <[^>]*> nop
++0000d548 <[^>]*> nop
++0000d54c <[^>]*> nop
++0000d550 <[^>]*> nop
++0000d554 <[^>]*> nop
++0000d558 <[^>]*> nop
++0000d55c <[^>]*> nop
++0000d560 <[^>]*> nop
++0000d564 <[^>]*> nop
++0000d568 <[^>]*> nop
++0000d56c <[^>]*> nop
++0000d570 <[^>]*> nop
++0000d574 <[^>]*> nop
++0000d578 <[^>]*> nop
++0000d57c <[^>]*> nop
++0000d580 <[^>]*> nop
++0000d584 <[^>]*> nop
++0000d588 <[^>]*> nop
++0000d58c <[^>]*> nop
++0000d590 <[^>]*> nop
++0000d594 <[^>]*> nop
++0000d598 <[^>]*> nop
++0000d59c <[^>]*> nop
++0000d5a0 <[^>]*> nop
++0000d5a4 <[^>]*> nop
++0000d5a8 <[^>]*> nop
++0000d5ac <[^>]*> nop
++0000d5b0 <[^>]*> nop
++0000d5b4 <[^>]*> nop
++0000d5b8 <[^>]*> nop
++0000d5bc <[^>]*> nop
++0000d5c0 <[^>]*> nop
++0000d5c4 <[^>]*> nop
++0000d5c8 <[^>]*> nop
++0000d5cc <[^>]*> nop
++0000d5d0 <[^>]*> nop
++0000d5d4 <[^>]*> nop
++0000d5d8 <[^>]*> nop
++0000d5dc <[^>]*> nop
++0000d5e0 <[^>]*> nop
++0000d5e4 <[^>]*> nop
++0000d5e8 <[^>]*> nop
++0000d5ec <[^>]*> nop
++0000d5f0 <[^>]*> nop
++0000d5f4 <[^>]*> nop
++0000d5f8 <[^>]*> nop
++0000d5fc <[^>]*> nop
++0000d600 <[^>]*> nop
++0000d604 <[^>]*> nop
++0000d608 <[^>]*> nop
++0000d60c <[^>]*> nop
++0000d610 <[^>]*> nop
++0000d614 <[^>]*> nop
++0000d618 <[^>]*> nop
++0000d61c <[^>]*> nop
++0000d620 <[^>]*> nop
++0000d624 <[^>]*> nop
++0000d628 <[^>]*> nop
++0000d62c <[^>]*> nop
++0000d630 <[^>]*> nop
++0000d634 <[^>]*> nop
++0000d638 <[^>]*> nop
++0000d63c <[^>]*> nop
++0000d640 <[^>]*> nop
++0000d644 <[^>]*> nop
++0000d648 <[^>]*> nop
++0000d64c <[^>]*> nop
++0000d650 <[^>]*> nop
++0000d654 <[^>]*> nop
++0000d658 <[^>]*> nop
++0000d65c <[^>]*> nop
++0000d660 <[^>]*> nop
++0000d664 <[^>]*> nop
++0000d668 <[^>]*> nop
++0000d66c <[^>]*> nop
++0000d670 <[^>]*> nop
++0000d674 <[^>]*> nop
++0000d678 <[^>]*> nop
++0000d67c <[^>]*> nop
++0000d680 <[^>]*> nop
++0000d684 <[^>]*> nop
++0000d688 <[^>]*> nop
++0000d68c <[^>]*> nop
++0000d690 <[^>]*> nop
++0000d694 <[^>]*> nop
++0000d698 <[^>]*> nop
++0000d69c <[^>]*> nop
++0000d6a0 <[^>]*> nop
++0000d6a4 <[^>]*> nop
++0000d6a8 <[^>]*> nop
++0000d6ac <[^>]*> nop
++0000d6b0 <[^>]*> nop
++0000d6b4 <[^>]*> nop
++0000d6b8 <[^>]*> nop
++0000d6bc <[^>]*> nop
++0000d6c0 <[^>]*> nop
++0000d6c4 <[^>]*> nop
++0000d6c8 <[^>]*> nop
++0000d6cc <[^>]*> nop
++0000d6d0 <[^>]*> nop
++0000d6d4 <[^>]*> nop
++0000d6d8 <[^>]*> nop
++0000d6dc <[^>]*> nop
++0000d6e0 <[^>]*> nop
++0000d6e4 <[^>]*> nop
++0000d6e8 <[^>]*> nop
++0000d6ec <[^>]*> nop
++0000d6f0 <[^>]*> nop
++0000d6f4 <[^>]*> nop
++0000d6f8 <[^>]*> nop
++0000d6fc <[^>]*> nop
++0000d700 <[^>]*> nop
++0000d704 <[^>]*> nop
++0000d708 <[^>]*> nop
++0000d70c <[^>]*> nop
++0000d710 <[^>]*> nop
++0000d714 <[^>]*> nop
++0000d718 <[^>]*> nop
++0000d71c <[^>]*> nop
++0000d720 <[^>]*> nop
++0000d724 <[^>]*> nop
++0000d728 <[^>]*> nop
++0000d72c <[^>]*> nop
++0000d730 <[^>]*> nop
++0000d734 <[^>]*> nop
++0000d738 <[^>]*> nop
++0000d73c <[^>]*> nop
++0000d740 <[^>]*> nop
++0000d744 <[^>]*> nop
++0000d748 <[^>]*> nop
++0000d74c <[^>]*> nop
++0000d750 <[^>]*> nop
++0000d754 <[^>]*> nop
++0000d758 <[^>]*> nop
++0000d75c <[^>]*> nop
++0000d760 <[^>]*> nop
++0000d764 <[^>]*> nop
++0000d768 <[^>]*> nop
++0000d76c <[^>]*> nop
++0000d770 <[^>]*> nop
++0000d774 <[^>]*> nop
++0000d778 <[^>]*> nop
++0000d77c <[^>]*> nop
++0000d780 <[^>]*> nop
++0000d784 <[^>]*> nop
++0000d788 <[^>]*> nop
++0000d78c <[^>]*> nop
++0000d790 <[^>]*> nop
++0000d794 <[^>]*> nop
++0000d798 <[^>]*> nop
++0000d79c <[^>]*> nop
++0000d7a0 <[^>]*> nop
++0000d7a4 <[^>]*> nop
++0000d7a8 <[^>]*> nop
++0000d7ac <[^>]*> nop
++0000d7b0 <[^>]*> nop
++0000d7b4 <[^>]*> nop
++0000d7b8 <[^>]*> nop
++0000d7bc <[^>]*> nop
++0000d7c0 <[^>]*> nop
++0000d7c4 <[^>]*> nop
++0000d7c8 <[^>]*> nop
++0000d7cc <[^>]*> nop
++0000d7d0 <[^>]*> nop
++0000d7d4 <[^>]*> nop
++0000d7d8 <[^>]*> nop
++0000d7dc <[^>]*> nop
++0000d7e0 <[^>]*> nop
++0000d7e4 <[^>]*> nop
++0000d7e8 <[^>]*> nop
++0000d7ec <[^>]*> nop
++0000d7f0 <[^>]*> nop
++0000d7f4 <[^>]*> nop
++0000d7f8 <[^>]*> nop
++0000d7fc <[^>]*> nop
++0000d800 <[^>]*> nop
++0000d804 <[^>]*> nop
++0000d808 <[^>]*> nop
++0000d80c <[^>]*> nop
++0000d810 <[^>]*> nop
++0000d814 <[^>]*> nop
++0000d818 <[^>]*> nop
++0000d81c <[^>]*> nop
++0000d820 <[^>]*> nop
++0000d824 <[^>]*> nop
++0000d828 <[^>]*> nop
++0000d82c <[^>]*> nop
++0000d830 <[^>]*> nop
++0000d834 <[^>]*> nop
++0000d838 <[^>]*> nop
++0000d83c <[^>]*> nop
++0000d840 <[^>]*> nop
++0000d844 <[^>]*> nop
++0000d848 <[^>]*> nop
++0000d84c <[^>]*> nop
++0000d850 <[^>]*> nop
++0000d854 <[^>]*> nop
++0000d858 <[^>]*> nop
++0000d85c <[^>]*> nop
++0000d860 <[^>]*> nop
++0000d864 <[^>]*> nop
++0000d868 <[^>]*> nop
++0000d86c <[^>]*> nop
++0000d870 <[^>]*> nop
++0000d874 <[^>]*> nop
++0000d878 <[^>]*> nop
++0000d87c <[^>]*> nop
++0000d880 <[^>]*> nop
++0000d884 <[^>]*> nop
++0000d888 <[^>]*> nop
++0000d88c <[^>]*> nop
++0000d890 <[^>]*> nop
++0000d894 <[^>]*> nop
++0000d898 <[^>]*> nop
++0000d89c <[^>]*> nop
++0000d8a0 <[^>]*> nop
++0000d8a4 <[^>]*> nop
++0000d8a8 <[^>]*> nop
++0000d8ac <[^>]*> nop
++0000d8b0 <[^>]*> nop
++0000d8b4 <[^>]*> nop
++0000d8b8 <[^>]*> nop
++0000d8bc <[^>]*> nop
++0000d8c0 <[^>]*> nop
++0000d8c4 <[^>]*> nop
++0000d8c8 <[^>]*> nop
++0000d8cc <[^>]*> nop
++0000d8d0 <[^>]*> nop
++0000d8d4 <[^>]*> nop
++0000d8d8 <[^>]*> nop
++0000d8dc <[^>]*> nop
++0000d8e0 <[^>]*> nop
++0000d8e4 <[^>]*> nop
++0000d8e8 <[^>]*> nop
++0000d8ec <[^>]*> nop
++0000d8f0 <[^>]*> nop
++0000d8f4 <[^>]*> nop
++0000d8f8 <[^>]*> nop
++0000d8fc <[^>]*> nop
++0000d900 <[^>]*> nop
++0000d904 <[^>]*> nop
++0000d908 <[^>]*> nop
++0000d90c <[^>]*> nop
++0000d910 <[^>]*> nop
++0000d914 <[^>]*> nop
++0000d918 <[^>]*> nop
++0000d91c <[^>]*> nop
++0000d920 <[^>]*> nop
++0000d924 <[^>]*> nop
++0000d928 <[^>]*> nop
++0000d92c <[^>]*> nop
++0000d930 <[^>]*> nop
++0000d934 <[^>]*> nop
++0000d938 <[^>]*> nop
++0000d93c <[^>]*> nop
++0000d940 <[^>]*> nop
++0000d944 <[^>]*> nop
++0000d948 <[^>]*> nop
++0000d94c <[^>]*> nop
++0000d950 <[^>]*> nop
++0000d954 <[^>]*> nop
++0000d958 <[^>]*> nop
++0000d95c <[^>]*> nop
++0000d960 <[^>]*> nop
++0000d964 <[^>]*> nop
++0000d968 <[^>]*> nop
++0000d96c <[^>]*> nop
++0000d970 <[^>]*> nop
++0000d974 <[^>]*> nop
++0000d978 <[^>]*> nop
++0000d97c <[^>]*> nop
++0000d980 <[^>]*> nop
++0000d984 <[^>]*> nop
++0000d988 <[^>]*> nop
++0000d98c <[^>]*> nop
++0000d990 <[^>]*> nop
++0000d994 <[^>]*> nop
++0000d998 <[^>]*> nop
++0000d99c <[^>]*> nop
++0000d9a0 <[^>]*> nop
++0000d9a4 <[^>]*> nop
++0000d9a8 <[^>]*> nop
++0000d9ac <[^>]*> nop
++0000d9b0 <[^>]*> nop
++0000d9b4 <[^>]*> nop
++0000d9b8 <[^>]*> nop
++0000d9bc <[^>]*> nop
++0000d9c0 <[^>]*> nop
++0000d9c4 <[^>]*> nop
++0000d9c8 <[^>]*> nop
++0000d9cc <[^>]*> nop
++0000d9d0 <[^>]*> nop
++0000d9d4 <[^>]*> nop
++0000d9d8 <[^>]*> nop
++0000d9dc <[^>]*> nop
++0000d9e0 <[^>]*> nop
++0000d9e4 <[^>]*> nop
++0000d9e8 <[^>]*> nop
++0000d9ec <[^>]*> nop
++0000d9f0 <[^>]*> nop
++0000d9f4 <[^>]*> nop
++0000d9f8 <[^>]*> nop
++0000d9fc <[^>]*> nop
++0000da00 <[^>]*> nop
++0000da04 <[^>]*> nop
++0000da08 <[^>]*> nop
++0000da0c <[^>]*> nop
++0000da10 <[^>]*> nop
++0000da14 <[^>]*> nop
++0000da18 <[^>]*> nop
++0000da1c <[^>]*> nop
++0000da20 <[^>]*> nop
++0000da24 <[^>]*> nop
++0000da28 <[^>]*> nop
++0000da2c <[^>]*> nop
++0000da30 <[^>]*> nop
++0000da34 <[^>]*> nop
++0000da38 <[^>]*> nop
++0000da3c <[^>]*> nop
++0000da40 <[^>]*> nop
++0000da44 <[^>]*> nop
++0000da48 <[^>]*> nop
++0000da4c <[^>]*> nop
++0000da50 <[^>]*> nop
++0000da54 <[^>]*> nop
++0000da58 <[^>]*> nop
++0000da5c <[^>]*> nop
++0000da60 <[^>]*> nop
++0000da64 <[^>]*> nop
++0000da68 <[^>]*> nop
++0000da6c <[^>]*> nop
++0000da70 <[^>]*> nop
++0000da74 <[^>]*> nop
++0000da78 <[^>]*> nop
++0000da7c <[^>]*> nop
++0000da80 <[^>]*> nop
++0000da84 <[^>]*> nop
++0000da88 <[^>]*> nop
++0000da8c <[^>]*> nop
++0000da90 <[^>]*> nop
++0000da94 <[^>]*> nop
++0000da98 <[^>]*> nop
++0000da9c <[^>]*> nop
++0000daa0 <[^>]*> nop
++0000daa4 <[^>]*> nop
++0000daa8 <[^>]*> nop
++0000daac <[^>]*> nop
++0000dab0 <[^>]*> nop
++0000dab4 <[^>]*> nop
++0000dab8 <[^>]*> nop
++0000dabc <[^>]*> nop
++0000dac0 <[^>]*> nop
++0000dac4 <[^>]*> nop
++0000dac8 <[^>]*> nop
++0000dacc <[^>]*> nop
++0000dad0 <[^>]*> nop
++0000dad4 <[^>]*> nop
++0000dad8 <[^>]*> nop
++0000dadc <[^>]*> nop
++0000dae0 <[^>]*> nop
++0000dae4 <[^>]*> nop
++0000dae8 <[^>]*> nop
++0000daec <[^>]*> nop
++0000daf0 <[^>]*> nop
++0000daf4 <[^>]*> nop
++0000daf8 <[^>]*> nop
++0000dafc <[^>]*> nop
++0000db00 <[^>]*> nop
++0000db04 <[^>]*> nop
++0000db08 <[^>]*> nop
++0000db0c <[^>]*> nop
++0000db10 <[^>]*> nop
++0000db14 <[^>]*> nop
++0000db18 <[^>]*> nop
++0000db1c <[^>]*> nop
++0000db20 <[^>]*> nop
++0000db24 <[^>]*> nop
++0000db28 <[^>]*> nop
++0000db2c <[^>]*> nop
++0000db30 <[^>]*> nop
++0000db34 <[^>]*> nop
++0000db38 <[^>]*> nop
++0000db3c <[^>]*> nop
++0000db40 <[^>]*> nop
++0000db44 <[^>]*> nop
++0000db48 <[^>]*> nop
++0000db4c <[^>]*> nop
++0000db50 <[^>]*> nop
++0000db54 <[^>]*> nop
++0000db58 <[^>]*> nop
++0000db5c <[^>]*> nop
++0000db60 <[^>]*> nop
++0000db64 <[^>]*> nop
++0000db68 <[^>]*> nop
++0000db6c <[^>]*> nop
++0000db70 <[^>]*> nop
++0000db74 <[^>]*> nop
++0000db78 <[^>]*> nop
++0000db7c <[^>]*> nop
++0000db80 <[^>]*> nop
++0000db84 <[^>]*> nop
++0000db88 <[^>]*> nop
++0000db8c <[^>]*> nop
++0000db90 <[^>]*> nop
++0000db94 <[^>]*> nop
++0000db98 <[^>]*> nop
++0000db9c <[^>]*> nop
++0000dba0 <[^>]*> nop
++0000dba4 <[^>]*> nop
++0000dba8 <[^>]*> nop
++0000dbac <[^>]*> nop
++0000dbb0 <[^>]*> nop
++0000dbb4 <[^>]*> nop
++0000dbb8 <[^>]*> nop
++0000dbbc <[^>]*> nop
++0000dbc0 <[^>]*> nop
++0000dbc4 <[^>]*> nop
++0000dbc8 <[^>]*> nop
++0000dbcc <[^>]*> nop
++0000dbd0 <[^>]*> nop
++0000dbd4 <[^>]*> nop
++0000dbd8 <[^>]*> nop
++0000dbdc <[^>]*> nop
++0000dbe0 <[^>]*> nop
++0000dbe4 <[^>]*> nop
++0000dbe8 <[^>]*> nop
++0000dbec <[^>]*> nop
++0000dbf0 <[^>]*> nop
++0000dbf4 <[^>]*> nop
++0000dbf8 <[^>]*> nop
++0000dbfc <[^>]*> nop
++0000dc00 <[^>]*> nop
++0000dc04 <[^>]*> nop
++0000dc08 <[^>]*> nop
++0000dc0c <[^>]*> nop
++0000dc10 <[^>]*> nop
++0000dc14 <[^>]*> nop
++0000dc18 <[^>]*> nop
++0000dc1c <[^>]*> nop
++0000dc20 <[^>]*> nop
++0000dc24 <[^>]*> nop
++0000dc28 <[^>]*> nop
++0000dc2c <[^>]*> nop
++0000dc30 <[^>]*> nop
++0000dc34 <[^>]*> nop
++0000dc38 <[^>]*> nop
++0000dc3c <[^>]*> nop
++0000dc40 <[^>]*> nop
++0000dc44 <[^>]*> nop
++0000dc48 <[^>]*> nop
++0000dc4c <[^>]*> nop
++0000dc50 <[^>]*> nop
++0000dc54 <[^>]*> nop
++0000dc58 <[^>]*> nop
++0000dc5c <[^>]*> nop
++0000dc60 <[^>]*> nop
++0000dc64 <[^>]*> nop
++0000dc68 <[^>]*> nop
++0000dc6c <[^>]*> nop
++0000dc70 <[^>]*> nop
++0000dc74 <[^>]*> nop
++0000dc78 <[^>]*> nop
++0000dc7c <[^>]*> nop
++0000dc80 <[^>]*> nop
++0000dc84 <[^>]*> nop
++0000dc88 <[^>]*> nop
++0000dc8c <[^>]*> nop
++0000dc90 <[^>]*> nop
++0000dc94 <[^>]*> nop
++0000dc98 <[^>]*> nop
++0000dc9c <[^>]*> nop
++0000dca0 <[^>]*> nop
++0000dca4 <[^>]*> nop
++0000dca8 <[^>]*> nop
++0000dcac <[^>]*> nop
++0000dcb0 <[^>]*> nop
++0000dcb4 <[^>]*> nop
++0000dcb8 <[^>]*> nop
++0000dcbc <[^>]*> nop
++0000dcc0 <[^>]*> nop
++0000dcc4 <[^>]*> nop
++0000dcc8 <[^>]*> nop
++0000dccc <[^>]*> nop
++0000dcd0 <[^>]*> nop
++0000dcd4 <[^>]*> nop
++0000dcd8 <[^>]*> nop
++0000dcdc <[^>]*> nop
++0000dce0 <[^>]*> nop
++0000dce4 <[^>]*> nop
++0000dce8 <[^>]*> nop
++0000dcec <[^>]*> nop
++0000dcf0 <[^>]*> nop
++0000dcf4 <[^>]*> nop
++0000dcf8 <[^>]*> nop
++0000dcfc <[^>]*> nop
++0000dd00 <[^>]*> nop
++0000dd04 <[^>]*> nop
++0000dd08 <[^>]*> nop
++0000dd0c <[^>]*> nop
++0000dd10 <[^>]*> nop
++0000dd14 <[^>]*> nop
++0000dd18 <[^>]*> nop
++0000dd1c <[^>]*> nop
++0000dd20 <[^>]*> nop
++0000dd24 <[^>]*> nop
++0000dd28 <[^>]*> nop
++0000dd2c <[^>]*> nop
++0000dd30 <[^>]*> nop
++0000dd34 <[^>]*> nop
++0000dd38 <[^>]*> nop
++0000dd3c <[^>]*> nop
++0000dd40 <[^>]*> nop
++0000dd44 <[^>]*> nop
++0000dd48 <[^>]*> nop
++0000dd4c <[^>]*> nop
++0000dd50 <[^>]*> nop
++0000dd54 <[^>]*> nop
++0000dd58 <[^>]*> nop
++0000dd5c <[^>]*> nop
++0000dd60 <[^>]*> nop
++0000dd64 <[^>]*> nop
++0000dd68 <[^>]*> nop
++0000dd6c <[^>]*> nop
++0000dd70 <[^>]*> nop
++0000dd74 <[^>]*> nop
++0000dd78 <[^>]*> nop
++0000dd7c <[^>]*> nop
++0000dd80 <[^>]*> nop
++0000dd84 <[^>]*> nop
++0000dd88 <[^>]*> nop
++0000dd8c <[^>]*> nop
++0000dd90 <[^>]*> nop
++0000dd94 <[^>]*> nop
++0000dd98 <[^>]*> nop
++0000dd9c <[^>]*> nop
++0000dda0 <[^>]*> nop
++0000dda4 <[^>]*> nop
++0000dda8 <[^>]*> nop
++0000ddac <[^>]*> nop
++0000ddb0 <[^>]*> nop
++0000ddb4 <[^>]*> nop
++0000ddb8 <[^>]*> nop
++0000ddbc <[^>]*> nop
++0000ddc0 <[^>]*> nop
++0000ddc4 <[^>]*> nop
++0000ddc8 <[^>]*> nop
++0000ddcc <[^>]*> nop
++0000ddd0 <[^>]*> nop
++0000ddd4 <[^>]*> nop
++0000ddd8 <[^>]*> nop
++0000dddc <[^>]*> nop
++0000dde0 <[^>]*> nop
++0000dde4 <[^>]*> nop
++0000dde8 <[^>]*> nop
++0000ddec <[^>]*> nop
++0000ddf0 <[^>]*> nop
++0000ddf4 <[^>]*> nop
++0000ddf8 <[^>]*> nop
++0000ddfc <[^>]*> nop
++0000de00 <[^>]*> nop
++0000de04 <[^>]*> nop
++0000de08 <[^>]*> nop
++0000de0c <[^>]*> nop
++0000de10 <[^>]*> nop
++0000de14 <[^>]*> nop
++0000de18 <[^>]*> nop
++0000de1c <[^>]*> nop
++0000de20 <[^>]*> nop
++0000de24 <[^>]*> nop
++0000de28 <[^>]*> nop
++0000de2c <[^>]*> nop
++0000de30 <[^>]*> nop
++0000de34 <[^>]*> nop
++0000de38 <[^>]*> nop
++0000de3c <[^>]*> nop
++0000de40 <[^>]*> nop
++0000de44 <[^>]*> nop
++0000de48 <[^>]*> nop
++0000de4c <[^>]*> nop
++0000de50 <[^>]*> nop
++0000de54 <[^>]*> nop
++0000de58 <[^>]*> nop
++0000de5c <[^>]*> nop
++0000de60 <[^>]*> nop
++0000de64 <[^>]*> nop
++0000de68 <[^>]*> nop
++0000de6c <[^>]*> nop
++0000de70 <[^>]*> nop
++0000de74 <[^>]*> nop
++0000de78 <[^>]*> nop
++0000de7c <[^>]*> nop
++0000de80 <[^>]*> nop
++0000de84 <[^>]*> nop
++0000de88 <[^>]*> nop
++0000de8c <[^>]*> nop
++0000de90 <[^>]*> nop
++0000de94 <[^>]*> nop
++0000de98 <[^>]*> nop
++0000de9c <[^>]*> nop
++0000dea0 <[^>]*> nop
++0000dea4 <[^>]*> nop
++0000dea8 <[^>]*> nop
++0000deac <[^>]*> nop
++0000deb0 <[^>]*> nop
++0000deb4 <[^>]*> nop
++0000deb8 <[^>]*> nop
++0000debc <[^>]*> nop
++0000dec0 <[^>]*> nop
++0000dec4 <[^>]*> nop
++0000dec8 <[^>]*> nop
++0000decc <[^>]*> nop
++0000ded0 <[^>]*> nop
++0000ded4 <[^>]*> nop
++0000ded8 <[^>]*> nop
++0000dedc <[^>]*> nop
++0000dee0 <[^>]*> nop
++0000dee4 <[^>]*> nop
++0000dee8 <[^>]*> nop
++0000deec <[^>]*> nop
++0000def0 <[^>]*> nop
++0000def4 <[^>]*> nop
++0000def8 <[^>]*> nop
++0000defc <[^>]*> nop
++0000df00 <[^>]*> nop
++0000df04 <[^>]*> nop
++0000df08 <[^>]*> nop
++0000df0c <[^>]*> nop
++0000df10 <[^>]*> nop
++0000df14 <[^>]*> nop
++0000df18 <[^>]*> nop
++0000df1c <[^>]*> nop
++0000df20 <[^>]*> nop
++0000df24 <[^>]*> nop
++0000df28 <[^>]*> nop
++0000df2c <[^>]*> nop
++0000df30 <[^>]*> nop
++0000df34 <[^>]*> nop
++0000df38 <[^>]*> nop
++0000df3c <[^>]*> nop
++0000df40 <[^>]*> nop
++0000df44 <[^>]*> nop
++0000df48 <[^>]*> nop
++0000df4c <[^>]*> nop
++0000df50 <[^>]*> nop
++0000df54 <[^>]*> nop
++0000df58 <[^>]*> nop
++0000df5c <[^>]*> nop
++0000df60 <[^>]*> nop
++0000df64 <[^>]*> nop
++0000df68 <[^>]*> nop
++0000df6c <[^>]*> nop
++0000df70 <[^>]*> nop
++0000df74 <[^>]*> nop
++0000df78 <[^>]*> nop
++0000df7c <[^>]*> nop
++0000df80 <[^>]*> nop
++0000df84 <[^>]*> nop
++0000df88 <[^>]*> nop
++0000df8c <[^>]*> nop
++0000df90 <[^>]*> nop
++0000df94 <[^>]*> nop
++0000df98 <[^>]*> nop
++0000df9c <[^>]*> nop
++0000dfa0 <[^>]*> nop
++0000dfa4 <[^>]*> nop
++0000dfa8 <[^>]*> nop
++0000dfac <[^>]*> nop
++0000dfb0 <[^>]*> nop
++0000dfb4 <[^>]*> nop
++0000dfb8 <[^>]*> nop
++0000dfbc <[^>]*> nop
++0000dfc0 <[^>]*> nop
++0000dfc4 <[^>]*> nop
++0000dfc8 <[^>]*> nop
++0000dfcc <[^>]*> nop
++0000dfd0 <[^>]*> nop
++0000dfd4 <[^>]*> nop
++0000dfd8 <[^>]*> nop
++0000dfdc <[^>]*> nop
++0000dfe0 <[^>]*> nop
++0000dfe4 <[^>]*> nop
++0000dfe8 <[^>]*> nop
++0000dfec <[^>]*> nop
++0000dff0 <[^>]*> nop
++0000dff4 <[^>]*> nop
++0000dff8 <[^>]*> nop
++0000dffc <[^>]*> nop
++0000e000 <[^>]*> nop
++0000e004 <[^>]*> nop
++0000e008 <[^>]*> nop
++0000e00c <[^>]*> nop
++0000e010 <[^>]*> nop
++0000e014 <[^>]*> nop
++0000e018 <[^>]*> nop
++0000e01c <[^>]*> nop
++0000e020 <[^>]*> nop
++0000e024 <[^>]*> nop
++0000e028 <[^>]*> nop
++0000e02c <[^>]*> nop
++0000e030 <[^>]*> nop
++0000e034 <[^>]*> nop
++0000e038 <[^>]*> nop
++0000e03c <[^>]*> nop
++0000e040 <[^>]*> nop
++0000e044 <[^>]*> nop
++0000e048 <[^>]*> nop
++0000e04c <[^>]*> nop
++0000e050 <[^>]*> nop
++0000e054 <[^>]*> nop
++0000e058 <[^>]*> nop
++0000e05c <[^>]*> nop
++0000e060 <[^>]*> nop
++0000e064 <[^>]*> nop
++0000e068 <[^>]*> nop
++0000e06c <[^>]*> nop
++0000e070 <[^>]*> nop
++0000e074 <[^>]*> nop
++0000e078 <[^>]*> nop
++0000e07c <[^>]*> nop
++0000e080 <[^>]*> nop
++0000e084 <[^>]*> nop
++0000e088 <[^>]*> nop
++0000e08c <[^>]*> nop
++0000e090 <[^>]*> nop
++0000e094 <[^>]*> nop
++0000e098 <[^>]*> nop
++0000e09c <[^>]*> nop
++0000e0a0 <[^>]*> nop
++0000e0a4 <[^>]*> nop
++0000e0a8 <[^>]*> nop
++0000e0ac <[^>]*> nop
++0000e0b0 <[^>]*> nop
++0000e0b4 <[^>]*> nop
++0000e0b8 <[^>]*> nop
++0000e0bc <[^>]*> nop
++0000e0c0 <[^>]*> nop
++0000e0c4 <[^>]*> nop
++0000e0c8 <[^>]*> nop
++0000e0cc <[^>]*> nop
++0000e0d0 <[^>]*> nop
++0000e0d4 <[^>]*> nop
++0000e0d8 <[^>]*> nop
++0000e0dc <[^>]*> nop
++0000e0e0 <[^>]*> nop
++0000e0e4 <[^>]*> nop
++0000e0e8 <[^>]*> nop
++0000e0ec <[^>]*> nop
++0000e0f0 <[^>]*> nop
++0000e0f4 <[^>]*> nop
++0000e0f8 <[^>]*> nop
++0000e0fc <[^>]*> nop
++0000e100 <[^>]*> nop
++0000e104 <[^>]*> nop
++0000e108 <[^>]*> nop
++0000e10c <[^>]*> nop
++0000e110 <[^>]*> nop
++0000e114 <[^>]*> nop
++0000e118 <[^>]*> nop
++0000e11c <[^>]*> nop
++0000e120 <[^>]*> nop
++0000e124 <[^>]*> nop
++0000e128 <[^>]*> nop
++0000e12c <[^>]*> nop
++0000e130 <[^>]*> nop
++0000e134 <[^>]*> nop
++0000e138 <[^>]*> nop
++0000e13c <[^>]*> nop
++0000e140 <[^>]*> nop
++0000e144 <[^>]*> nop
++0000e148 <[^>]*> nop
++0000e14c <[^>]*> nop
++0000e150 <[^>]*> nop
++0000e154 <[^>]*> nop
++0000e158 <[^>]*> nop
++0000e15c <[^>]*> nop
++0000e160 <[^>]*> nop
++0000e164 <[^>]*> nop
++0000e168 <[^>]*> nop
++0000e16c <[^>]*> nop
++0000e170 <[^>]*> nop
++0000e174 <[^>]*> nop
++0000e178 <[^>]*> nop
++0000e17c <[^>]*> nop
++0000e180 <[^>]*> nop
++0000e184 <[^>]*> nop
++0000e188 <[^>]*> nop
++0000e18c <[^>]*> nop
++0000e190 <[^>]*> nop
++0000e194 <[^>]*> nop
++0000e198 <[^>]*> nop
++0000e19c <[^>]*> nop
++0000e1a0 <[^>]*> nop
++0000e1a4 <[^>]*> nop
++0000e1a8 <[^>]*> nop
++0000e1ac <[^>]*> nop
++0000e1b0 <[^>]*> nop
++0000e1b4 <[^>]*> nop
++0000e1b8 <[^>]*> nop
++0000e1bc <[^>]*> nop
++0000e1c0 <[^>]*> nop
++0000e1c4 <[^>]*> nop
++0000e1c8 <[^>]*> nop
++0000e1cc <[^>]*> nop
++0000e1d0 <[^>]*> nop
++0000e1d4 <[^>]*> nop
++0000e1d8 <[^>]*> nop
++0000e1dc <[^>]*> nop
++0000e1e0 <[^>]*> nop
++0000e1e4 <[^>]*> nop
++0000e1e8 <[^>]*> nop
++0000e1ec <[^>]*> nop
++0000e1f0 <[^>]*> nop
++0000e1f4 <[^>]*> nop
++0000e1f8 <[^>]*> nop
++0000e1fc <[^>]*> nop
++0000e200 <[^>]*> nop
++0000e204 <[^>]*> nop
++0000e208 <[^>]*> nop
++0000e20c <[^>]*> nop
++0000e210 <[^>]*> nop
++0000e214 <[^>]*> nop
++0000e218 <[^>]*> nop
++0000e21c <[^>]*> nop
++0000e220 <[^>]*> nop
++0000e224 <[^>]*> nop
++0000e228 <[^>]*> nop
++0000e22c <[^>]*> nop
++0000e230 <[^>]*> nop
++0000e234 <[^>]*> nop
++0000e238 <[^>]*> nop
++0000e23c <[^>]*> nop
++0000e240 <[^>]*> nop
++0000e244 <[^>]*> nop
++0000e248 <[^>]*> nop
++0000e24c <[^>]*> nop
++0000e250 <[^>]*> nop
++0000e254 <[^>]*> nop
++0000e258 <[^>]*> nop
++0000e25c <[^>]*> nop
++0000e260 <[^>]*> nop
++0000e264 <[^>]*> nop
++0000e268 <[^>]*> nop
++0000e26c <[^>]*> nop
++0000e270 <[^>]*> nop
++0000e274 <[^>]*> nop
++0000e278 <[^>]*> nop
++0000e27c <[^>]*> nop
++0000e280 <[^>]*> nop
++0000e284 <[^>]*> nop
++0000e288 <[^>]*> nop
++0000e28c <[^>]*> nop
++0000e290 <[^>]*> nop
++0000e294 <[^>]*> nop
++0000e298 <[^>]*> nop
++0000e29c <[^>]*> nop
++0000e2a0 <[^>]*> nop
++0000e2a4 <[^>]*> nop
++0000e2a8 <[^>]*> nop
++0000e2ac <[^>]*> nop
++0000e2b0 <[^>]*> nop
++0000e2b4 <[^>]*> nop
++0000e2b8 <[^>]*> nop
++0000e2bc <[^>]*> nop
++0000e2c0 <[^>]*> nop
++0000e2c4 <[^>]*> nop
++0000e2c8 <[^>]*> nop
++0000e2cc <[^>]*> nop
++0000e2d0 <[^>]*> nop
++0000e2d4 <[^>]*> nop
++0000e2d8 <[^>]*> nop
++0000e2dc <[^>]*> nop
++0000e2e0 <[^>]*> nop
++0000e2e4 <[^>]*> nop
++0000e2e8 <[^>]*> nop
++0000e2ec <[^>]*> nop
++0000e2f0 <[^>]*> nop
++0000e2f4 <[^>]*> nop
++0000e2f8 <[^>]*> nop
++0000e2fc <[^>]*> nop
++0000e300 <[^>]*> nop
++0000e304 <[^>]*> nop
++0000e308 <[^>]*> nop
++0000e30c <[^>]*> nop
++0000e310 <[^>]*> nop
++0000e314 <[^>]*> nop
++0000e318 <[^>]*> nop
++0000e31c <[^>]*> nop
++0000e320 <[^>]*> nop
++0000e324 <[^>]*> nop
++0000e328 <[^>]*> nop
++0000e32c <[^>]*> nop
++0000e330 <[^>]*> nop
++0000e334 <[^>]*> nop
++0000e338 <[^>]*> nop
++0000e33c <[^>]*> nop
++0000e340 <[^>]*> nop
++0000e344 <[^>]*> nop
++0000e348 <[^>]*> nop
++0000e34c <[^>]*> nop
++0000e350 <[^>]*> nop
++0000e354 <[^>]*> nop
++0000e358 <[^>]*> nop
++0000e35c <[^>]*> nop
++0000e360 <[^>]*> nop
++0000e364 <[^>]*> nop
++0000e368 <[^>]*> nop
++0000e36c <[^>]*> nop
++0000e370 <[^>]*> nop
++0000e374 <[^>]*> nop
++0000e378 <[^>]*> nop
++0000e37c <[^>]*> nop
++0000e380 <[^>]*> nop
++0000e384 <[^>]*> nop
++0000e388 <[^>]*> nop
++0000e38c <[^>]*> nop
++0000e390 <[^>]*> nop
++0000e394 <[^>]*> nop
++0000e398 <[^>]*> nop
++0000e39c <[^>]*> nop
++0000e3a0 <[^>]*> nop
++0000e3a4 <[^>]*> nop
++0000e3a8 <[^>]*> nop
++0000e3ac <[^>]*> nop
++0000e3b0 <[^>]*> nop
++0000e3b4 <[^>]*> nop
++0000e3b8 <[^>]*> nop
++0000e3bc <[^>]*> nop
++0000e3c0 <[^>]*> nop
++0000e3c4 <[^>]*> nop
++0000e3c8 <[^>]*> nop
++0000e3cc <[^>]*> nop
++0000e3d0 <[^>]*> nop
++0000e3d4 <[^>]*> nop
++0000e3d8 <[^>]*> nop
++0000e3dc <[^>]*> nop
++0000e3e0 <[^>]*> nop
++0000e3e4 <[^>]*> nop
++0000e3e8 <[^>]*> nop
++0000e3ec <[^>]*> nop
++0000e3f0 <[^>]*> nop
++0000e3f4 <[^>]*> nop
++0000e3f8 <[^>]*> nop
++0000e3fc <[^>]*> nop
++0000e400 <[^>]*> nop
++0000e404 <[^>]*> nop
++0000e408 <[^>]*> nop
++0000e40c <[^>]*> nop
++0000e410 <[^>]*> nop
++0000e414 <[^>]*> nop
++0000e418 <[^>]*> nop
++0000e41c <[^>]*> nop
++0000e420 <[^>]*> nop
++0000e424 <[^>]*> nop
++0000e428 <[^>]*> nop
++0000e42c <[^>]*> nop
++0000e430 <[^>]*> nop
++0000e434 <[^>]*> nop
++0000e438 <[^>]*> nop
++0000e43c <[^>]*> nop
++0000e440 <[^>]*> nop
++0000e444 <[^>]*> nop
++0000e448 <[^>]*> nop
++0000e44c <[^>]*> nop
++0000e450 <[^>]*> nop
++0000e454 <[^>]*> nop
++0000e458 <[^>]*> nop
++0000e45c <[^>]*> nop
++0000e460 <[^>]*> nop
++0000e464 <[^>]*> nop
++0000e468 <[^>]*> nop
++0000e46c <[^>]*> nop
++0000e470 <[^>]*> nop
++0000e474 <[^>]*> nop
++0000e478 <[^>]*> nop
++0000e47c <[^>]*> nop
++0000e480 <[^>]*> nop
++0000e484 <[^>]*> nop
++0000e488 <[^>]*> nop
++0000e48c <[^>]*> nop
++0000e490 <[^>]*> nop
++0000e494 <[^>]*> nop
++0000e498 <[^>]*> nop
++0000e49c <[^>]*> nop
++0000e4a0 <[^>]*> nop
++0000e4a4 <[^>]*> nop
++0000e4a8 <[^>]*> nop
++0000e4ac <[^>]*> nop
++0000e4b0 <[^>]*> nop
++0000e4b4 <[^>]*> nop
++0000e4b8 <[^>]*> nop
++0000e4bc <[^>]*> nop
++0000e4c0 <[^>]*> nop
++0000e4c4 <[^>]*> nop
++0000e4c8 <[^>]*> nop
++0000e4cc <[^>]*> nop
++0000e4d0 <[^>]*> nop
++0000e4d4 <[^>]*> nop
++0000e4d8 <[^>]*> nop
++0000e4dc <[^>]*> nop
++0000e4e0 <[^>]*> nop
++0000e4e4 <[^>]*> nop
++0000e4e8 <[^>]*> nop
++0000e4ec <[^>]*> nop
++0000e4f0 <[^>]*> nop
++0000e4f4 <[^>]*> nop
++0000e4f8 <[^>]*> nop
++0000e4fc <[^>]*> nop
++0000e500 <[^>]*> nop
++0000e504 <[^>]*> nop
++0000e508 <[^>]*> nop
++0000e50c <[^>]*> nop
++0000e510 <[^>]*> nop
++0000e514 <[^>]*> nop
++0000e518 <[^>]*> nop
++0000e51c <[^>]*> nop
++0000e520 <[^>]*> nop
++0000e524 <[^>]*> nop
++0000e528 <[^>]*> nop
++0000e52c <[^>]*> nop
++0000e530 <[^>]*> nop
++0000e534 <[^>]*> nop
++0000e538 <[^>]*> nop
++0000e53c <[^>]*> nop
++0000e540 <[^>]*> nop
++0000e544 <[^>]*> nop
++0000e548 <[^>]*> nop
++0000e54c <[^>]*> nop
++0000e550 <[^>]*> nop
++0000e554 <[^>]*> nop
++0000e558 <[^>]*> nop
++0000e55c <[^>]*> nop
++0000e560 <[^>]*> nop
++0000e564 <[^>]*> nop
++0000e568 <[^>]*> nop
++0000e56c <[^>]*> nop
++0000e570 <[^>]*> nop
++0000e574 <[^>]*> nop
++0000e578 <[^>]*> nop
++0000e57c <[^>]*> nop
++0000e580 <[^>]*> nop
++0000e584 <[^>]*> nop
++0000e588 <[^>]*> nop
++0000e58c <[^>]*> nop
++0000e590 <[^>]*> nop
++0000e594 <[^>]*> nop
++0000e598 <[^>]*> nop
++0000e59c <[^>]*> nop
++0000e5a0 <[^>]*> nop
++0000e5a4 <[^>]*> nop
++0000e5a8 <[^>]*> nop
++0000e5ac <[^>]*> nop
++0000e5b0 <[^>]*> nop
++0000e5b4 <[^>]*> nop
++0000e5b8 <[^>]*> nop
++0000e5bc <[^>]*> nop
++0000e5c0 <[^>]*> nop
++0000e5c4 <[^>]*> nop
++0000e5c8 <[^>]*> nop
++0000e5cc <[^>]*> nop
++0000e5d0 <[^>]*> nop
++0000e5d4 <[^>]*> nop
++0000e5d8 <[^>]*> nop
++0000e5dc <[^>]*> nop
++0000e5e0 <[^>]*> nop
++0000e5e4 <[^>]*> nop
++0000e5e8 <[^>]*> nop
++0000e5ec <[^>]*> nop
++0000e5f0 <[^>]*> nop
++0000e5f4 <[^>]*> nop
++0000e5f8 <[^>]*> nop
++0000e5fc <[^>]*> nop
++0000e600 <[^>]*> nop
++0000e604 <[^>]*> nop
++0000e608 <[^>]*> nop
++0000e60c <[^>]*> nop
++0000e610 <[^>]*> nop
++0000e614 <[^>]*> nop
++0000e618 <[^>]*> nop
++0000e61c <[^>]*> nop
++0000e620 <[^>]*> nop
++0000e624 <[^>]*> nop
++0000e628 <[^>]*> nop
++0000e62c <[^>]*> nop
++0000e630 <[^>]*> nop
++0000e634 <[^>]*> nop
++0000e638 <[^>]*> nop
++0000e63c <[^>]*> nop
++0000e640 <[^>]*> nop
++0000e644 <[^>]*> nop
++0000e648 <[^>]*> nop
++0000e64c <[^>]*> nop
++0000e650 <[^>]*> nop
++0000e654 <[^>]*> nop
++0000e658 <[^>]*> nop
++0000e65c <[^>]*> nop
++0000e660 <[^>]*> nop
++0000e664 <[^>]*> nop
++0000e668 <[^>]*> nop
++0000e66c <[^>]*> nop
++0000e670 <[^>]*> nop
++0000e674 <[^>]*> nop
++0000e678 <[^>]*> nop
++0000e67c <[^>]*> nop
++0000e680 <[^>]*> nop
++0000e684 <[^>]*> nop
++0000e688 <[^>]*> nop
++0000e68c <[^>]*> nop
++0000e690 <[^>]*> nop
++0000e694 <[^>]*> nop
++0000e698 <[^>]*> nop
++0000e69c <[^>]*> nop
++0000e6a0 <[^>]*> nop
++0000e6a4 <[^>]*> nop
++0000e6a8 <[^>]*> nop
++0000e6ac <[^>]*> nop
++0000e6b0 <[^>]*> nop
++0000e6b4 <[^>]*> nop
++0000e6b8 <[^>]*> nop
++0000e6bc <[^>]*> nop
++0000e6c0 <[^>]*> nop
++0000e6c4 <[^>]*> nop
++0000e6c8 <[^>]*> nop
++0000e6cc <[^>]*> nop
++0000e6d0 <[^>]*> nop
++0000e6d4 <[^>]*> nop
++0000e6d8 <[^>]*> nop
++0000e6dc <[^>]*> nop
++0000e6e0 <[^>]*> nop
++0000e6e4 <[^>]*> nop
++0000e6e8 <[^>]*> nop
++0000e6ec <[^>]*> nop
++0000e6f0 <[^>]*> nop
++0000e6f4 <[^>]*> nop
++0000e6f8 <[^>]*> nop
++0000e6fc <[^>]*> nop
++0000e700 <[^>]*> nop
++0000e704 <[^>]*> nop
++0000e708 <[^>]*> nop
++0000e70c <[^>]*> nop
++0000e710 <[^>]*> nop
++0000e714 <[^>]*> nop
++0000e718 <[^>]*> nop
++0000e71c <[^>]*> nop
++0000e720 <[^>]*> nop
++0000e724 <[^>]*> nop
++0000e728 <[^>]*> nop
++0000e72c <[^>]*> nop
++0000e730 <[^>]*> nop
++0000e734 <[^>]*> nop
++0000e738 <[^>]*> nop
++0000e73c <[^>]*> nop
++0000e740 <[^>]*> nop
++0000e744 <[^>]*> nop
++0000e748 <[^>]*> nop
++0000e74c <[^>]*> nop
++0000e750 <[^>]*> nop
++0000e754 <[^>]*> nop
++0000e758 <[^>]*> nop
++0000e75c <[^>]*> nop
++0000e760 <[^>]*> nop
++0000e764 <[^>]*> nop
++0000e768 <[^>]*> nop
++0000e76c <[^>]*> nop
++0000e770 <[^>]*> nop
++0000e774 <[^>]*> nop
++0000e778 <[^>]*> nop
++0000e77c <[^>]*> nop
++0000e780 <[^>]*> nop
++0000e784 <[^>]*> nop
++0000e788 <[^>]*> nop
++0000e78c <[^>]*> nop
++0000e790 <[^>]*> nop
++0000e794 <[^>]*> nop
++0000e798 <[^>]*> nop
++0000e79c <[^>]*> nop
++0000e7a0 <[^>]*> nop
++0000e7a4 <[^>]*> nop
++0000e7a8 <[^>]*> nop
++0000e7ac <[^>]*> nop
++0000e7b0 <[^>]*> nop
++0000e7b4 <[^>]*> nop
++0000e7b8 <[^>]*> nop
++0000e7bc <[^>]*> nop
++0000e7c0 <[^>]*> nop
++0000e7c4 <[^>]*> nop
++0000e7c8 <[^>]*> nop
++0000e7cc <[^>]*> nop
++0000e7d0 <[^>]*> nop
++0000e7d4 <[^>]*> nop
++0000e7d8 <[^>]*> nop
++0000e7dc <[^>]*> nop
++0000e7e0 <[^>]*> nop
++0000e7e4 <[^>]*> nop
++0000e7e8 <[^>]*> nop
++0000e7ec <[^>]*> nop
++0000e7f0 <[^>]*> nop
++0000e7f4 <[^>]*> nop
++0000e7f8 <[^>]*> nop
++0000e7fc <[^>]*> nop
++0000e800 <[^>]*> nop
++0000e804 <[^>]*> nop
++0000e808 <[^>]*> nop
++0000e80c <[^>]*> nop
++0000e810 <[^>]*> nop
++0000e814 <[^>]*> nop
++0000e818 <[^>]*> nop
++0000e81c <[^>]*> nop
++0000e820 <[^>]*> nop
++0000e824 <[^>]*> nop
++0000e828 <[^>]*> nop
++0000e82c <[^>]*> nop
++0000e830 <[^>]*> nop
++0000e834 <[^>]*> nop
++0000e838 <[^>]*> nop
++0000e83c <[^>]*> nop
++0000e840 <[^>]*> nop
++0000e844 <[^>]*> nop
++0000e848 <[^>]*> nop
++0000e84c <[^>]*> nop
++0000e850 <[^>]*> nop
++0000e854 <[^>]*> nop
++0000e858 <[^>]*> nop
++0000e85c <[^>]*> nop
++0000e860 <[^>]*> nop
++0000e864 <[^>]*> nop
++0000e868 <[^>]*> nop
++0000e86c <[^>]*> nop
++0000e870 <[^>]*> nop
++0000e874 <[^>]*> nop
++0000e878 <[^>]*> nop
++0000e87c <[^>]*> nop
++0000e880 <[^>]*> nop
++0000e884 <[^>]*> nop
++0000e888 <[^>]*> nop
++0000e88c <[^>]*> nop
++0000e890 <[^>]*> nop
++0000e894 <[^>]*> nop
++0000e898 <[^>]*> nop
++0000e89c <[^>]*> nop
++0000e8a0 <[^>]*> nop
++0000e8a4 <[^>]*> nop
++0000e8a8 <[^>]*> nop
++0000e8ac <[^>]*> nop
++0000e8b0 <[^>]*> nop
++0000e8b4 <[^>]*> nop
++0000e8b8 <[^>]*> nop
++0000e8bc <[^>]*> nop
++0000e8c0 <[^>]*> nop
++0000e8c4 <[^>]*> nop
++0000e8c8 <[^>]*> nop
++0000e8cc <[^>]*> nop
++0000e8d0 <[^>]*> nop
++0000e8d4 <[^>]*> nop
++0000e8d8 <[^>]*> nop
++0000e8dc <[^>]*> nop
++0000e8e0 <[^>]*> nop
++0000e8e4 <[^>]*> nop
++0000e8e8 <[^>]*> nop
++0000e8ec <[^>]*> nop
++0000e8f0 <[^>]*> nop
++0000e8f4 <[^>]*> nop
++0000e8f8 <[^>]*> nop
++0000e8fc <[^>]*> nop
++0000e900 <[^>]*> nop
++0000e904 <[^>]*> nop
++0000e908 <[^>]*> nop
++0000e90c <[^>]*> nop
++0000e910 <[^>]*> nop
++0000e914 <[^>]*> nop
++0000e918 <[^>]*> nop
++0000e91c <[^>]*> nop
++0000e920 <[^>]*> nop
++0000e924 <[^>]*> nop
++0000e928 <[^>]*> nop
++0000e92c <[^>]*> nop
++0000e930 <[^>]*> nop
++0000e934 <[^>]*> nop
++0000e938 <[^>]*> nop
++0000e93c <[^>]*> nop
++0000e940 <[^>]*> nop
++0000e944 <[^>]*> nop
++0000e948 <[^>]*> nop
++0000e94c <[^>]*> nop
++0000e950 <[^>]*> nop
++0000e954 <[^>]*> nop
++0000e958 <[^>]*> nop
++0000e95c <[^>]*> nop
++0000e960 <[^>]*> nop
++0000e964 <[^>]*> nop
++0000e968 <[^>]*> nop
++0000e96c <[^>]*> nop
++0000e970 <[^>]*> nop
++0000e974 <[^>]*> nop
++0000e978 <[^>]*> nop
++0000e97c <[^>]*> nop
++0000e980 <[^>]*> nop
++0000e984 <[^>]*> nop
++0000e988 <[^>]*> nop
++0000e98c <[^>]*> nop
++0000e990 <[^>]*> nop
++0000e994 <[^>]*> nop
++0000e998 <[^>]*> nop
++0000e99c <[^>]*> nop
++0000e9a0 <[^>]*> nop
++0000e9a4 <[^>]*> nop
++0000e9a8 <[^>]*> nop
++0000e9ac <[^>]*> nop
++0000e9b0 <[^>]*> nop
++0000e9b4 <[^>]*> nop
++0000e9b8 <[^>]*> nop
++0000e9bc <[^>]*> nop
++0000e9c0 <[^>]*> nop
++0000e9c4 <[^>]*> nop
++0000e9c8 <[^>]*> nop
++0000e9cc <[^>]*> nop
++0000e9d0 <[^>]*> nop
++0000e9d4 <[^>]*> nop
++0000e9d8 <[^>]*> nop
++0000e9dc <[^>]*> nop
++0000e9e0 <[^>]*> nop
++0000e9e4 <[^>]*> nop
++0000e9e8 <[^>]*> nop
++0000e9ec <[^>]*> nop
++0000e9f0 <[^>]*> nop
++0000e9f4 <[^>]*> nop
++0000e9f8 <[^>]*> nop
++0000e9fc <[^>]*> nop
++0000ea00 <[^>]*> nop
++0000ea04 <[^>]*> nop
++0000ea08 <[^>]*> nop
++0000ea0c <[^>]*> nop
++0000ea10 <[^>]*> nop
++0000ea14 <[^>]*> nop
++0000ea18 <[^>]*> nop
++0000ea1c <[^>]*> nop
++0000ea20 <[^>]*> nop
++0000ea24 <[^>]*> nop
++0000ea28 <[^>]*> nop
++0000ea2c <[^>]*> nop
++0000ea30 <[^>]*> nop
++0000ea34 <[^>]*> nop
++0000ea38 <[^>]*> nop
++0000ea3c <[^>]*> nop
++0000ea40 <[^>]*> nop
++0000ea44 <[^>]*> nop
++0000ea48 <[^>]*> nop
++0000ea4c <[^>]*> nop
++0000ea50 <[^>]*> nop
++0000ea54 <[^>]*> nop
++0000ea58 <[^>]*> nop
++0000ea5c <[^>]*> nop
++0000ea60 <[^>]*> nop
++0000ea64 <[^>]*> nop
++0000ea68 <[^>]*> nop
++0000ea6c <[^>]*> nop
++0000ea70 <[^>]*> nop
++0000ea74 <[^>]*> nop
++0000ea78 <[^>]*> nop
++0000ea7c <[^>]*> nop
++0000ea80 <[^>]*> nop
++0000ea84 <[^>]*> nop
++0000ea88 <[^>]*> nop
++0000ea8c <[^>]*> nop
++0000ea90 <[^>]*> nop
++0000ea94 <[^>]*> nop
++0000ea98 <[^>]*> nop
++0000ea9c <[^>]*> nop
++0000eaa0 <[^>]*> nop
++0000eaa4 <[^>]*> nop
++0000eaa8 <[^>]*> nop
++0000eaac <[^>]*> nop
++0000eab0 <[^>]*> nop
++0000eab4 <[^>]*> nop
++0000eab8 <[^>]*> nop
++0000eabc <[^>]*> nop
++0000eac0 <[^>]*> nop
++0000eac4 <[^>]*> nop
++0000eac8 <[^>]*> nop
++0000eacc <[^>]*> nop
++0000ead0 <[^>]*> nop
++0000ead4 <[^>]*> nop
++0000ead8 <[^>]*> nop
++0000eadc <[^>]*> nop
++0000eae0 <[^>]*> nop
++0000eae4 <[^>]*> nop
++0000eae8 <[^>]*> nop
++0000eaec <[^>]*> nop
++0000eaf0 <[^>]*> nop
++0000eaf4 <[^>]*> nop
++0000eaf8 <[^>]*> nop
++0000eafc <[^>]*> nop
++0000eb00 <[^>]*> nop
++0000eb04 <[^>]*> nop
++0000eb08 <[^>]*> nop
++0000eb0c <[^>]*> nop
++0000eb10 <[^>]*> nop
++0000eb14 <[^>]*> nop
++0000eb18 <[^>]*> nop
++0000eb1c <[^>]*> nop
++0000eb20 <[^>]*> nop
++0000eb24 <[^>]*> nop
++0000eb28 <[^>]*> nop
++0000eb2c <[^>]*> nop
++0000eb30 <[^>]*> nop
++0000eb34 <[^>]*> nop
++0000eb38 <[^>]*> nop
++0000eb3c <[^>]*> nop
++0000eb40 <[^>]*> nop
++0000eb44 <[^>]*> nop
++0000eb48 <[^>]*> nop
++0000eb4c <[^>]*> nop
++0000eb50 <[^>]*> nop
++0000eb54 <[^>]*> nop
++0000eb58 <[^>]*> nop
++0000eb5c <[^>]*> nop
++0000eb60 <[^>]*> nop
++0000eb64 <[^>]*> nop
++0000eb68 <[^>]*> nop
++0000eb6c <[^>]*> nop
++0000eb70 <[^>]*> nop
++0000eb74 <[^>]*> nop
++0000eb78 <[^>]*> nop
++0000eb7c <[^>]*> nop
++0000eb80 <[^>]*> nop
++0000eb84 <[^>]*> nop
++0000eb88 <[^>]*> nop
++0000eb8c <[^>]*> nop
++0000eb90 <[^>]*> nop
++0000eb94 <[^>]*> nop
++0000eb98 <[^>]*> nop
++0000eb9c <[^>]*> nop
++0000eba0 <[^>]*> nop
++0000eba4 <[^>]*> nop
++0000eba8 <[^>]*> nop
++0000ebac <[^>]*> nop
++0000ebb0 <[^>]*> nop
++0000ebb4 <[^>]*> nop
++0000ebb8 <[^>]*> nop
++0000ebbc <[^>]*> nop
++0000ebc0 <[^>]*> nop
++0000ebc4 <[^>]*> nop
++0000ebc8 <[^>]*> nop
++0000ebcc <[^>]*> nop
++0000ebd0 <[^>]*> nop
++0000ebd4 <[^>]*> nop
++0000ebd8 <[^>]*> nop
++0000ebdc <[^>]*> nop
++0000ebe0 <[^>]*> nop
++0000ebe4 <[^>]*> nop
++0000ebe8 <[^>]*> nop
++0000ebec <[^>]*> nop
++0000ebf0 <[^>]*> nop
++0000ebf4 <[^>]*> nop
++0000ebf8 <[^>]*> nop
++0000ebfc <[^>]*> nop
++0000ec00 <[^>]*> nop
++0000ec04 <[^>]*> nop
++0000ec08 <[^>]*> nop
++0000ec0c <[^>]*> nop
++0000ec10 <[^>]*> nop
++0000ec14 <[^>]*> nop
++0000ec18 <[^>]*> nop
++0000ec1c <[^>]*> nop
++0000ec20 <[^>]*> nop
++0000ec24 <[^>]*> nop
++0000ec28 <[^>]*> nop
++0000ec2c <[^>]*> nop
++0000ec30 <[^>]*> nop
++0000ec34 <[^>]*> nop
++0000ec38 <[^>]*> nop
++0000ec3c <[^>]*> nop
++0000ec40 <[^>]*> nop
++0000ec44 <[^>]*> nop
++0000ec48 <[^>]*> nop
++0000ec4c <[^>]*> nop
++0000ec50 <[^>]*> nop
++0000ec54 <[^>]*> nop
++0000ec58 <[^>]*> nop
++0000ec5c <[^>]*> nop
++0000ec60 <[^>]*> nop
++0000ec64 <[^>]*> nop
++0000ec68 <[^>]*> nop
++0000ec6c <[^>]*> nop
++0000ec70 <[^>]*> nop
++0000ec74 <[^>]*> nop
++0000ec78 <[^>]*> nop
++0000ec7c <[^>]*> nop
++0000ec80 <[^>]*> nop
++0000ec84 <[^>]*> nop
++0000ec88 <[^>]*> nop
++0000ec8c <[^>]*> nop
++0000ec90 <[^>]*> nop
++0000ec94 <[^>]*> nop
++0000ec98 <[^>]*> nop
++0000ec9c <[^>]*> nop
++0000eca0 <[^>]*> nop
++0000eca4 <[^>]*> nop
++0000eca8 <[^>]*> nop
++0000ecac <[^>]*> nop
++0000ecb0 <[^>]*> nop
++0000ecb4 <[^>]*> nop
++0000ecb8 <[^>]*> nop
++0000ecbc <[^>]*> nop
++0000ecc0 <[^>]*> nop
++0000ecc4 <[^>]*> nop
++0000ecc8 <[^>]*> nop
++0000eccc <[^>]*> nop
++0000ecd0 <[^>]*> nop
++0000ecd4 <[^>]*> nop
++0000ecd8 <[^>]*> nop
++0000ecdc <[^>]*> nop
++0000ece0 <[^>]*> nop
++0000ece4 <[^>]*> nop
++0000ece8 <[^>]*> nop
++0000ecec <[^>]*> nop
++0000ecf0 <[^>]*> nop
++0000ecf4 <[^>]*> nop
++0000ecf8 <[^>]*> nop
++0000ecfc <[^>]*> nop
++0000ed00 <[^>]*> nop
++0000ed04 <[^>]*> nop
++0000ed08 <[^>]*> nop
++0000ed0c <[^>]*> nop
++0000ed10 <[^>]*> nop
++0000ed14 <[^>]*> nop
++0000ed18 <[^>]*> nop
++0000ed1c <[^>]*> nop
++0000ed20 <[^>]*> nop
++0000ed24 <[^>]*> nop
++0000ed28 <[^>]*> nop
++0000ed2c <[^>]*> nop
++0000ed30 <[^>]*> nop
++0000ed34 <[^>]*> nop
++0000ed38 <[^>]*> nop
++0000ed3c <[^>]*> nop
++0000ed40 <[^>]*> nop
++0000ed44 <[^>]*> nop
++0000ed48 <[^>]*> nop
++0000ed4c <[^>]*> nop
++0000ed50 <[^>]*> nop
++0000ed54 <[^>]*> nop
++0000ed58 <[^>]*> nop
++0000ed5c <[^>]*> nop
++0000ed60 <[^>]*> nop
++0000ed64 <[^>]*> nop
++0000ed68 <[^>]*> nop
++0000ed6c <[^>]*> nop
++0000ed70 <[^>]*> nop
++0000ed74 <[^>]*> nop
++0000ed78 <[^>]*> nop
++0000ed7c <[^>]*> nop
++0000ed80 <[^>]*> nop
++0000ed84 <[^>]*> nop
++0000ed88 <[^>]*> nop
++0000ed8c <[^>]*> nop
++0000ed90 <[^>]*> nop
++0000ed94 <[^>]*> nop
++0000ed98 <[^>]*> nop
++0000ed9c <[^>]*> nop
++0000eda0 <[^>]*> nop
++0000eda4 <[^>]*> nop
++0000eda8 <[^>]*> nop
++0000edac <[^>]*> nop
++0000edb0 <[^>]*> nop
++0000edb4 <[^>]*> nop
++0000edb8 <[^>]*> nop
++0000edbc <[^>]*> nop
++0000edc0 <[^>]*> nop
++0000edc4 <[^>]*> nop
++0000edc8 <[^>]*> nop
++0000edcc <[^>]*> nop
++0000edd0 <[^>]*> nop
++0000edd4 <[^>]*> nop
++0000edd8 <[^>]*> nop
++0000eddc <[^>]*> nop
++0000ede0 <[^>]*> nop
++0000ede4 <[^>]*> nop
++0000ede8 <[^>]*> nop
++0000edec <[^>]*> nop
++0000edf0 <[^>]*> nop
++0000edf4 <[^>]*> nop
++0000edf8 <[^>]*> nop
++0000edfc <[^>]*> nop
++0000ee00 <[^>]*> nop
++0000ee04 <[^>]*> nop
++0000ee08 <[^>]*> nop
++0000ee0c <[^>]*> nop
++0000ee10 <[^>]*> nop
++0000ee14 <[^>]*> nop
++0000ee18 <[^>]*> nop
++0000ee1c <[^>]*> nop
++0000ee20 <[^>]*> nop
++0000ee24 <[^>]*> nop
++0000ee28 <[^>]*> nop
++0000ee2c <[^>]*> nop
++0000ee30 <[^>]*> nop
++0000ee34 <[^>]*> nop
++0000ee38 <[^>]*> nop
++0000ee3c <[^>]*> nop
++0000ee40 <[^>]*> nop
++0000ee44 <[^>]*> nop
++0000ee48 <[^>]*> nop
++0000ee4c <[^>]*> nop
++0000ee50 <[^>]*> nop
++0000ee54 <[^>]*> nop
++0000ee58 <[^>]*> nop
++0000ee5c <[^>]*> nop
++0000ee60 <[^>]*> nop
++0000ee64 <[^>]*> nop
++0000ee68 <[^>]*> nop
++0000ee6c <[^>]*> nop
++0000ee70 <[^>]*> nop
++0000ee74 <[^>]*> nop
++0000ee78 <[^>]*> nop
++0000ee7c <[^>]*> nop
++0000ee80 <[^>]*> nop
++0000ee84 <[^>]*> nop
++0000ee88 <[^>]*> nop
++0000ee8c <[^>]*> nop
++0000ee90 <[^>]*> nop
++0000ee94 <[^>]*> nop
++0000ee98 <[^>]*> nop
++0000ee9c <[^>]*> nop
++0000eea0 <[^>]*> nop
++0000eea4 <[^>]*> nop
++0000eea8 <[^>]*> nop
++0000eeac <[^>]*> nop
++0000eeb0 <[^>]*> nop
++0000eeb4 <[^>]*> nop
++0000eeb8 <[^>]*> nop
++0000eebc <[^>]*> nop
++0000eec0 <[^>]*> nop
++0000eec4 <[^>]*> nop
++0000eec8 <[^>]*> nop
++0000eecc <[^>]*> nop
++0000eed0 <[^>]*> nop
++0000eed4 <[^>]*> nop
++0000eed8 <[^>]*> nop
++0000eedc <[^>]*> nop
++0000eee0 <[^>]*> nop
++0000eee4 <[^>]*> nop
++0000eee8 <[^>]*> nop
++0000eeec <[^>]*> nop
++0000eef0 <[^>]*> nop
++0000eef4 <[^>]*> nop
++0000eef8 <[^>]*> nop
++0000eefc <[^>]*> nop
++0000ef00 <[^>]*> nop
++0000ef04 <[^>]*> nop
++0000ef08 <[^>]*> nop
++0000ef0c <[^>]*> nop
++0000ef10 <[^>]*> nop
++0000ef14 <[^>]*> nop
++0000ef18 <[^>]*> nop
++0000ef1c <[^>]*> nop
++0000ef20 <[^>]*> nop
++0000ef24 <[^>]*> nop
++0000ef28 <[^>]*> nop
++0000ef2c <[^>]*> nop
++0000ef30 <[^>]*> nop
++0000ef34 <[^>]*> nop
++0000ef38 <[^>]*> nop
++0000ef3c <[^>]*> nop
++0000ef40 <[^>]*> nop
++0000ef44 <[^>]*> nop
++0000ef48 <[^>]*> nop
++0000ef4c <[^>]*> nop
++0000ef50 <[^>]*> nop
++0000ef54 <[^>]*> nop
++0000ef58 <[^>]*> nop
++0000ef5c <[^>]*> nop
++0000ef60 <[^>]*> nop
++0000ef64 <[^>]*> nop
++0000ef68 <[^>]*> nop
++0000ef6c <[^>]*> nop
++0000ef70 <[^>]*> nop
++0000ef74 <[^>]*> nop
++0000ef78 <[^>]*> nop
++0000ef7c <[^>]*> nop
++0000ef80 <[^>]*> nop
++0000ef84 <[^>]*> nop
++0000ef88 <[^>]*> nop
++0000ef8c <[^>]*> nop
++0000ef90 <[^>]*> nop
++0000ef94 <[^>]*> nop
++0000ef98 <[^>]*> nop
++0000ef9c <[^>]*> nop
++0000efa0 <[^>]*> nop
++0000efa4 <[^>]*> nop
++0000efa8 <[^>]*> nop
++0000efac <[^>]*> nop
++0000efb0 <[^>]*> nop
++0000efb4 <[^>]*> nop
++0000efb8 <[^>]*> nop
++0000efbc <[^>]*> nop
++0000efc0 <[^>]*> nop
++0000efc4 <[^>]*> nop
++0000efc8 <[^>]*> nop
++0000efcc <[^>]*> nop
++0000efd0 <[^>]*> nop
++0000efd4 <[^>]*> nop
++0000efd8 <[^>]*> nop
++0000efdc <[^>]*> nop
++0000efe0 <[^>]*> nop
++0000efe4 <[^>]*> nop
++0000efe8 <[^>]*> nop
++0000efec <[^>]*> nop
++0000eff0 <[^>]*> nop
++0000eff4 <[^>]*> nop
++0000eff8 <[^>]*> nop
++0000effc <[^>]*> nop
++0000f000 <[^>]*> nop
++0000f004 <[^>]*> nop
++0000f008 <[^>]*> nop
++0000f00c <[^>]*> nop
++0000f010 <[^>]*> nop
++0000f014 <[^>]*> nop
++0000f018 <[^>]*> nop
++0000f01c <[^>]*> nop
++0000f020 <[^>]*> nop
++0000f024 <[^>]*> nop
++0000f028 <[^>]*> nop
++0000f02c <[^>]*> nop
++0000f030 <[^>]*> nop
++0000f034 <[^>]*> nop
++0000f038 <[^>]*> nop
++0000f03c <[^>]*> nop
++0000f040 <[^>]*> nop
++0000f044 <[^>]*> nop
++0000f048 <[^>]*> nop
++0000f04c <[^>]*> nop
++0000f050 <[^>]*> nop
++0000f054 <[^>]*> nop
++0000f058 <[^>]*> nop
++0000f05c <[^>]*> nop
++0000f060 <[^>]*> nop
++0000f064 <[^>]*> nop
++0000f068 <[^>]*> nop
++0000f06c <[^>]*> nop
++0000f070 <[^>]*> nop
++0000f074 <[^>]*> nop
++0000f078 <[^>]*> nop
++0000f07c <[^>]*> nop
++0000f080 <[^>]*> nop
++0000f084 <[^>]*> nop
++0000f088 <[^>]*> nop
++0000f08c <[^>]*> nop
++0000f090 <[^>]*> nop
++0000f094 <[^>]*> nop
++0000f098 <[^>]*> nop
++0000f09c <[^>]*> nop
++0000f0a0 <[^>]*> nop
++0000f0a4 <[^>]*> nop
++0000f0a8 <[^>]*> nop
++0000f0ac <[^>]*> nop
++0000f0b0 <[^>]*> nop
++0000f0b4 <[^>]*> nop
++0000f0b8 <[^>]*> nop
++0000f0bc <[^>]*> nop
++0000f0c0 <[^>]*> nop
++0000f0c4 <[^>]*> nop
++0000f0c8 <[^>]*> nop
++0000f0cc <[^>]*> nop
++0000f0d0 <[^>]*> nop
++0000f0d4 <[^>]*> nop
++0000f0d8 <[^>]*> nop
++0000f0dc <[^>]*> nop
++0000f0e0 <[^>]*> nop
++0000f0e4 <[^>]*> nop
++0000f0e8 <[^>]*> nop
++0000f0ec <[^>]*> nop
++0000f0f0 <[^>]*> nop
++0000f0f4 <[^>]*> nop
++0000f0f8 <[^>]*> nop
++0000f0fc <[^>]*> nop
++0000f100 <[^>]*> nop
++0000f104 <[^>]*> nop
++0000f108 <[^>]*> nop
++0000f10c <[^>]*> nop
++0000f110 <[^>]*> nop
++0000f114 <[^>]*> nop
++0000f118 <[^>]*> nop
++0000f11c <[^>]*> nop
++0000f120 <[^>]*> nop
++0000f124 <[^>]*> nop
++0000f128 <[^>]*> nop
++0000f12c <[^>]*> nop
++0000f130 <[^>]*> nop
++0000f134 <[^>]*> nop
++0000f138 <[^>]*> nop
++0000f13c <[^>]*> nop
++0000f140 <[^>]*> nop
++0000f144 <[^>]*> nop
++0000f148 <[^>]*> nop
++0000f14c <[^>]*> nop
++0000f150 <[^>]*> nop
++0000f154 <[^>]*> nop
++0000f158 <[^>]*> nop
++0000f15c <[^>]*> nop
++0000f160 <[^>]*> nop
++0000f164 <[^>]*> nop
++0000f168 <[^>]*> nop
++0000f16c <[^>]*> nop
++0000f170 <[^>]*> nop
++0000f174 <[^>]*> nop
++0000f178 <[^>]*> nop
++0000f17c <[^>]*> nop
++0000f180 <[^>]*> nop
++0000f184 <[^>]*> nop
++0000f188 <[^>]*> nop
++0000f18c <[^>]*> nop
++0000f190 <[^>]*> nop
++0000f194 <[^>]*> nop
++0000f198 <[^>]*> nop
++0000f19c <[^>]*> nop
++0000f1a0 <[^>]*> nop
++0000f1a4 <[^>]*> nop
++0000f1a8 <[^>]*> nop
++0000f1ac <[^>]*> nop
++0000f1b0 <[^>]*> nop
++0000f1b4 <[^>]*> nop
++0000f1b8 <[^>]*> nop
++0000f1bc <[^>]*> nop
++0000f1c0 <[^>]*> nop
++0000f1c4 <[^>]*> nop
++0000f1c8 <[^>]*> nop
++0000f1cc <[^>]*> nop
++0000f1d0 <[^>]*> nop
++0000f1d4 <[^>]*> nop
++0000f1d8 <[^>]*> nop
++0000f1dc <[^>]*> nop
++0000f1e0 <[^>]*> nop
++0000f1e4 <[^>]*> nop
++0000f1e8 <[^>]*> nop
++0000f1ec <[^>]*> nop
++0000f1f0 <[^>]*> nop
++0000f1f4 <[^>]*> nop
++0000f1f8 <[^>]*> nop
++0000f1fc <[^>]*> nop
++0000f200 <[^>]*> nop
++0000f204 <[^>]*> nop
++0000f208 <[^>]*> nop
++0000f20c <[^>]*> nop
++0000f210 <[^>]*> nop
++0000f214 <[^>]*> nop
++0000f218 <[^>]*> nop
++0000f21c <[^>]*> nop
++0000f220 <[^>]*> nop
++0000f224 <[^>]*> nop
++0000f228 <[^>]*> nop
++0000f22c <[^>]*> nop
++0000f230 <[^>]*> nop
++0000f234 <[^>]*> nop
++0000f238 <[^>]*> nop
++0000f23c <[^>]*> nop
++0000f240 <[^>]*> nop
++0000f244 <[^>]*> nop
++0000f248 <[^>]*> nop
++0000f24c <[^>]*> nop
++0000f250 <[^>]*> nop
++0000f254 <[^>]*> nop
++0000f258 <[^>]*> nop
++0000f25c <[^>]*> nop
++0000f260 <[^>]*> nop
++0000f264 <[^>]*> nop
++0000f268 <[^>]*> nop
++0000f26c <[^>]*> nop
++0000f270 <[^>]*> nop
++0000f274 <[^>]*> nop
++0000f278 <[^>]*> nop
++0000f27c <[^>]*> nop
++0000f280 <[^>]*> nop
++0000f284 <[^>]*> nop
++0000f288 <[^>]*> nop
++0000f28c <[^>]*> nop
++0000f290 <[^>]*> nop
++0000f294 <[^>]*> nop
++0000f298 <[^>]*> nop
++0000f29c <[^>]*> nop
++0000f2a0 <[^>]*> nop
++0000f2a4 <[^>]*> nop
++0000f2a8 <[^>]*> nop
++0000f2ac <[^>]*> nop
++0000f2b0 <[^>]*> nop
++0000f2b4 <[^>]*> nop
++0000f2b8 <[^>]*> nop
++0000f2bc <[^>]*> nop
++0000f2c0 <[^>]*> nop
++0000f2c4 <[^>]*> nop
++0000f2c8 <[^>]*> nop
++0000f2cc <[^>]*> nop
++0000f2d0 <[^>]*> nop
++0000f2d4 <[^>]*> nop
++0000f2d8 <[^>]*> nop
++0000f2dc <[^>]*> nop
++0000f2e0 <[^>]*> nop
++0000f2e4 <[^>]*> nop
++0000f2e8 <[^>]*> nop
++0000f2ec <[^>]*> nop
++0000f2f0 <[^>]*> nop
++0000f2f4 <[^>]*> nop
++0000f2f8 <[^>]*> nop
++0000f2fc <[^>]*> nop
++0000f300 <[^>]*> nop
++0000f304 <[^>]*> nop
++0000f308 <[^>]*> nop
++0000f30c <[^>]*> nop
++0000f310 <[^>]*> nop
++0000f314 <[^>]*> nop
++0000f318 <[^>]*> nop
++0000f31c <[^>]*> nop
++0000f320 <[^>]*> nop
++0000f324 <[^>]*> nop
++0000f328 <[^>]*> nop
++0000f32c <[^>]*> nop
++0000f330 <[^>]*> nop
++0000f334 <[^>]*> nop
++0000f338 <[^>]*> nop
++0000f33c <[^>]*> nop
++0000f340 <[^>]*> nop
++0000f344 <[^>]*> nop
++0000f348 <[^>]*> nop
++0000f34c <[^>]*> nop
++0000f350 <[^>]*> nop
++0000f354 <[^>]*> nop
++0000f358 <[^>]*> nop
++0000f35c <[^>]*> nop
++0000f360 <[^>]*> nop
++0000f364 <[^>]*> nop
++0000f368 <[^>]*> nop
++0000f36c <[^>]*> nop
++0000f370 <[^>]*> nop
++0000f374 <[^>]*> nop
++0000f378 <[^>]*> nop
++0000f37c <[^>]*> nop
++0000f380 <[^>]*> nop
++0000f384 <[^>]*> nop
++0000f388 <[^>]*> nop
++0000f38c <[^>]*> nop
++0000f390 <[^>]*> nop
++0000f394 <[^>]*> nop
++0000f398 <[^>]*> nop
++0000f39c <[^>]*> nop
++0000f3a0 <[^>]*> nop
++0000f3a4 <[^>]*> nop
++0000f3a8 <[^>]*> nop
++0000f3ac <[^>]*> nop
++0000f3b0 <[^>]*> nop
++0000f3b4 <[^>]*> nop
++0000f3b8 <[^>]*> nop
++0000f3bc <[^>]*> nop
++0000f3c0 <[^>]*> nop
++0000f3c4 <[^>]*> nop
++0000f3c8 <[^>]*> nop
++0000f3cc <[^>]*> nop
++0000f3d0 <[^>]*> nop
++0000f3d4 <[^>]*> nop
++0000f3d8 <[^>]*> nop
++0000f3dc <[^>]*> nop
++0000f3e0 <[^>]*> nop
++0000f3e4 <[^>]*> nop
++0000f3e8 <[^>]*> nop
++0000f3ec <[^>]*> nop
++0000f3f0 <[^>]*> nop
++0000f3f4 <[^>]*> nop
++0000f3f8 <[^>]*> nop
++0000f3fc <[^>]*> nop
++0000f400 <[^>]*> nop
++0000f404 <[^>]*> nop
++0000f408 <[^>]*> nop
++0000f40c <[^>]*> nop
++0000f410 <[^>]*> nop
++0000f414 <[^>]*> nop
++0000f418 <[^>]*> nop
++0000f41c <[^>]*> nop
++0000f420 <[^>]*> nop
++0000f424 <[^>]*> nop
++0000f428 <[^>]*> nop
++0000f42c <[^>]*> nop
++0000f430 <[^>]*> nop
++0000f434 <[^>]*> nop
++0000f438 <[^>]*> nop
++0000f43c <[^>]*> nop
++0000f440 <[^>]*> nop
++0000f444 <[^>]*> nop
++0000f448 <[^>]*> nop
++0000f44c <[^>]*> nop
++0000f450 <[^>]*> nop
++0000f454 <[^>]*> nop
++0000f458 <[^>]*> nop
++0000f45c <[^>]*> nop
++0000f460 <[^>]*> nop
++0000f464 <[^>]*> nop
++0000f468 <[^>]*> nop
++0000f46c <[^>]*> nop
++0000f470 <[^>]*> nop
++0000f474 <[^>]*> nop
++0000f478 <[^>]*> nop
++0000f47c <[^>]*> nop
++0000f480 <[^>]*> nop
++0000f484 <[^>]*> nop
++0000f488 <[^>]*> nop
++0000f48c <[^>]*> nop
++0000f490 <[^>]*> nop
++0000f494 <[^>]*> nop
++0000f498 <[^>]*> nop
++0000f49c <[^>]*> nop
++0000f4a0 <[^>]*> nop
++0000f4a4 <[^>]*> nop
++0000f4a8 <[^>]*> nop
++0000f4ac <[^>]*> nop
++0000f4b0 <[^>]*> nop
++0000f4b4 <[^>]*> nop
++0000f4b8 <[^>]*> nop
++0000f4bc <[^>]*> nop
++0000f4c0 <[^>]*> nop
++0000f4c4 <[^>]*> nop
++0000f4c8 <[^>]*> nop
++0000f4cc <[^>]*> nop
++0000f4d0 <[^>]*> nop
++0000f4d4 <[^>]*> nop
++0000f4d8 <[^>]*> nop
++0000f4dc <[^>]*> nop
++0000f4e0 <[^>]*> nop
++0000f4e4 <[^>]*> nop
++0000f4e8 <[^>]*> nop
++0000f4ec <[^>]*> nop
++0000f4f0 <[^>]*> nop
++0000f4f4 <[^>]*> nop
++0000f4f8 <[^>]*> nop
++0000f4fc <[^>]*> nop
++0000f500 <[^>]*> nop
++0000f504 <[^>]*> nop
++0000f508 <[^>]*> nop
++0000f50c <[^>]*> nop
++0000f510 <[^>]*> nop
++0000f514 <[^>]*> nop
++0000f518 <[^>]*> nop
++0000f51c <[^>]*> nop
++0000f520 <[^>]*> nop
++0000f524 <[^>]*> nop
++0000f528 <[^>]*> nop
++0000f52c <[^>]*> nop
++0000f530 <[^>]*> nop
++0000f534 <[^>]*> nop
++0000f538 <[^>]*> nop
++0000f53c <[^>]*> nop
++0000f540 <[^>]*> nop
++0000f544 <[^>]*> nop
++0000f548 <[^>]*> nop
++0000f54c <[^>]*> nop
++0000f550 <[^>]*> nop
++0000f554 <[^>]*> nop
++0000f558 <[^>]*> nop
++0000f55c <[^>]*> nop
++0000f560 <[^>]*> nop
++0000f564 <[^>]*> nop
++0000f568 <[^>]*> nop
++0000f56c <[^>]*> nop
++0000f570 <[^>]*> nop
++0000f574 <[^>]*> nop
++0000f578 <[^>]*> nop
++0000f57c <[^>]*> nop
++0000f580 <[^>]*> nop
++0000f584 <[^>]*> nop
++0000f588 <[^>]*> nop
++0000f58c <[^>]*> nop
++0000f590 <[^>]*> nop
++0000f594 <[^>]*> nop
++0000f598 <[^>]*> nop
++0000f59c <[^>]*> nop
++0000f5a0 <[^>]*> nop
++0000f5a4 <[^>]*> nop
++0000f5a8 <[^>]*> nop
++0000f5ac <[^>]*> nop
++0000f5b0 <[^>]*> nop
++0000f5b4 <[^>]*> nop
++0000f5b8 <[^>]*> nop
++0000f5bc <[^>]*> nop
++0000f5c0 <[^>]*> nop
++0000f5c4 <[^>]*> nop
++0000f5c8 <[^>]*> nop
++0000f5cc <[^>]*> nop
++0000f5d0 <[^>]*> nop
++0000f5d4 <[^>]*> nop
++0000f5d8 <[^>]*> nop
++0000f5dc <[^>]*> nop
++0000f5e0 <[^>]*> nop
++0000f5e4 <[^>]*> nop
++0000f5e8 <[^>]*> nop
++0000f5ec <[^>]*> nop
++0000f5f0 <[^>]*> nop
++0000f5f4 <[^>]*> nop
++0000f5f8 <[^>]*> nop
++0000f5fc <[^>]*> nop
++0000f600 <[^>]*> nop
++0000f604 <[^>]*> nop
++0000f608 <[^>]*> nop
++0000f60c <[^>]*> nop
++0000f610 <[^>]*> nop
++0000f614 <[^>]*> nop
++0000f618 <[^>]*> nop
++0000f61c <[^>]*> nop
++0000f620 <[^>]*> nop
++0000f624 <[^>]*> nop
++0000f628 <[^>]*> nop
++0000f62c <[^>]*> nop
++0000f630 <[^>]*> nop
++0000f634 <[^>]*> nop
++0000f638 <[^>]*> nop
++0000f63c <[^>]*> nop
++0000f640 <[^>]*> nop
++0000f644 <[^>]*> nop
++0000f648 <[^>]*> nop
++0000f64c <[^>]*> nop
++0000f650 <[^>]*> nop
++0000f654 <[^>]*> nop
++0000f658 <[^>]*> nop
++0000f65c <[^>]*> nop
++0000f660 <[^>]*> nop
++0000f664 <[^>]*> nop
++0000f668 <[^>]*> nop
++0000f66c <[^>]*> nop
++0000f670 <[^>]*> nop
++0000f674 <[^>]*> nop
++0000f678 <[^>]*> nop
++0000f67c <[^>]*> nop
++0000f680 <[^>]*> nop
++0000f684 <[^>]*> nop
++0000f688 <[^>]*> nop
++0000f68c <[^>]*> nop
++0000f690 <[^>]*> nop
++0000f694 <[^>]*> nop
++0000f698 <[^>]*> nop
++0000f69c <[^>]*> nop
++0000f6a0 <[^>]*> nop
++0000f6a4 <[^>]*> nop
++0000f6a8 <[^>]*> nop
++0000f6ac <[^>]*> nop
++0000f6b0 <[^>]*> nop
++0000f6b4 <[^>]*> nop
++0000f6b8 <[^>]*> nop
++0000f6bc <[^>]*> nop
++0000f6c0 <[^>]*> nop
++0000f6c4 <[^>]*> nop
++0000f6c8 <[^>]*> nop
++0000f6cc <[^>]*> nop
++0000f6d0 <[^>]*> nop
++0000f6d4 <[^>]*> nop
++0000f6d8 <[^>]*> nop
++0000f6dc <[^>]*> nop
++0000f6e0 <[^>]*> nop
++0000f6e4 <[^>]*> nop
++0000f6e8 <[^>]*> nop
++0000f6ec <[^>]*> nop
++0000f6f0 <[^>]*> nop
++0000f6f4 <[^>]*> nop
++0000f6f8 <[^>]*> nop
++0000f6fc <[^>]*> nop
++0000f700 <[^>]*> nop
++0000f704 <[^>]*> nop
++0000f708 <[^>]*> nop
++0000f70c <[^>]*> nop
++0000f710 <[^>]*> nop
++0000f714 <[^>]*> nop
++0000f718 <[^>]*> nop
++0000f71c <[^>]*> nop
++0000f720 <[^>]*> nop
++0000f724 <[^>]*> nop
++0000f728 <[^>]*> nop
++0000f72c <[^>]*> nop
++0000f730 <[^>]*> nop
++0000f734 <[^>]*> nop
++0000f738 <[^>]*> nop
++0000f73c <[^>]*> nop
++0000f740 <[^>]*> nop
++0000f744 <[^>]*> nop
++0000f748 <[^>]*> nop
++0000f74c <[^>]*> nop
++0000f750 <[^>]*> nop
++0000f754 <[^>]*> nop
++0000f758 <[^>]*> nop
++0000f75c <[^>]*> nop
++0000f760 <[^>]*> nop
++0000f764 <[^>]*> nop
++0000f768 <[^>]*> nop
++0000f76c <[^>]*> nop
++0000f770 <[^>]*> nop
++0000f774 <[^>]*> nop
++0000f778 <[^>]*> nop
++0000f77c <[^>]*> nop
++0000f780 <[^>]*> nop
++0000f784 <[^>]*> nop
++0000f788 <[^>]*> nop
++0000f78c <[^>]*> nop
++0000f790 <[^>]*> nop
++0000f794 <[^>]*> nop
++0000f798 <[^>]*> nop
++0000f79c <[^>]*> nop
++0000f7a0 <[^>]*> nop
++0000f7a4 <[^>]*> nop
++0000f7a8 <[^>]*> nop
++0000f7ac <[^>]*> nop
++0000f7b0 <[^>]*> nop
++0000f7b4 <[^>]*> nop
++0000f7b8 <[^>]*> nop
++0000f7bc <[^>]*> nop
++0000f7c0 <[^>]*> nop
++0000f7c4 <[^>]*> nop
++0000f7c8 <[^>]*> nop
++0000f7cc <[^>]*> nop
++0000f7d0 <[^>]*> nop
++0000f7d4 <[^>]*> nop
++0000f7d8 <[^>]*> nop
++0000f7dc <[^>]*> nop
++0000f7e0 <[^>]*> nop
++0000f7e4 <[^>]*> nop
++0000f7e8 <[^>]*> nop
++0000f7ec <[^>]*> nop
++0000f7f0 <[^>]*> nop
++0000f7f4 <[^>]*> nop
++0000f7f8 <[^>]*> nop
++0000f7fc <[^>]*> nop
++0000f800 <[^>]*> nop
++0000f804 <[^>]*> nop
++0000f808 <[^>]*> nop
++0000f80c <[^>]*> nop
++0000f810 <[^>]*> nop
++0000f814 <[^>]*> nop
++0000f818 <[^>]*> nop
++0000f81c <[^>]*> nop
++0000f820 <[^>]*> nop
++0000f824 <[^>]*> nop
++0000f828 <[^>]*> nop
++0000f82c <[^>]*> nop
++0000f830 <[^>]*> nop
++0000f834 <[^>]*> nop
++0000f838 <[^>]*> nop
++0000f83c <[^>]*> nop
++0000f840 <[^>]*> nop
++0000f844 <[^>]*> nop
++0000f848 <[^>]*> nop
++0000f84c <[^>]*> nop
++0000f850 <[^>]*> nop
++0000f854 <[^>]*> nop
++0000f858 <[^>]*> nop
++0000f85c <[^>]*> nop
++0000f860 <[^>]*> nop
++0000f864 <[^>]*> nop
++0000f868 <[^>]*> nop
++0000f86c <[^>]*> nop
++0000f870 <[^>]*> nop
++0000f874 <[^>]*> nop
++0000f878 <[^>]*> nop
++0000f87c <[^>]*> nop
++0000f880 <[^>]*> nop
++0000f884 <[^>]*> nop
++0000f888 <[^>]*> nop
++0000f88c <[^>]*> nop
++0000f890 <[^>]*> nop
++0000f894 <[^>]*> nop
++0000f898 <[^>]*> nop
++0000f89c <[^>]*> nop
++0000f8a0 <[^>]*> nop
++0000f8a4 <[^>]*> nop
++0000f8a8 <[^>]*> nop
++0000f8ac <[^>]*> nop
++0000f8b0 <[^>]*> nop
++0000f8b4 <[^>]*> nop
++0000f8b8 <[^>]*> nop
++0000f8bc <[^>]*> nop
++0000f8c0 <[^>]*> nop
++0000f8c4 <[^>]*> nop
++0000f8c8 <[^>]*> nop
++0000f8cc <[^>]*> nop
++0000f8d0 <[^>]*> nop
++0000f8d4 <[^>]*> nop
++0000f8d8 <[^>]*> nop
++0000f8dc <[^>]*> nop
++0000f8e0 <[^>]*> nop
++0000f8e4 <[^>]*> nop
++0000f8e8 <[^>]*> nop
++0000f8ec <[^>]*> nop
++0000f8f0 <[^>]*> nop
++0000f8f4 <[^>]*> nop
++0000f8f8 <[^>]*> nop
++0000f8fc <[^>]*> nop
++0000f900 <[^>]*> nop
++0000f904 <[^>]*> nop
++0000f908 <[^>]*> nop
++0000f90c <[^>]*> nop
++0000f910 <[^>]*> nop
++0000f914 <[^>]*> nop
++0000f918 <[^>]*> nop
++0000f91c <[^>]*> nop
++0000f920 <[^>]*> nop
++0000f924 <[^>]*> nop
++0000f928 <[^>]*> nop
++0000f92c <[^>]*> nop
++0000f930 <[^>]*> nop
++0000f934 <[^>]*> nop
++0000f938 <[^>]*> nop
++0000f93c <[^>]*> nop
++0000f940 <[^>]*> nop
++0000f944 <[^>]*> nop
++0000f948 <[^>]*> nop
++0000f94c <[^>]*> nop
++0000f950 <[^>]*> nop
++0000f954 <[^>]*> nop
++0000f958 <[^>]*> nop
++0000f95c <[^>]*> nop
++0000f960 <[^>]*> nop
++0000f964 <[^>]*> nop
++0000f968 <[^>]*> nop
++0000f96c <[^>]*> nop
++0000f970 <[^>]*> nop
++0000f974 <[^>]*> nop
++0000f978 <[^>]*> nop
++0000f97c <[^>]*> nop
++0000f980 <[^>]*> nop
++0000f984 <[^>]*> nop
++0000f988 <[^>]*> nop
++0000f98c <[^>]*> nop
++0000f990 <[^>]*> nop
++0000f994 <[^>]*> nop
++0000f998 <[^>]*> nop
++0000f99c <[^>]*> nop
++0000f9a0 <[^>]*> nop
++0000f9a4 <[^>]*> nop
++0000f9a8 <[^>]*> nop
++0000f9ac <[^>]*> nop
++0000f9b0 <[^>]*> nop
++0000f9b4 <[^>]*> nop
++0000f9b8 <[^>]*> nop
++0000f9bc <[^>]*> nop
++0000f9c0 <[^>]*> nop
++0000f9c4 <[^>]*> nop
++0000f9c8 <[^>]*> nop
++0000f9cc <[^>]*> nop
++0000f9d0 <[^>]*> nop
++0000f9d4 <[^>]*> nop
++0000f9d8 <[^>]*> nop
++0000f9dc <[^>]*> nop
++0000f9e0 <[^>]*> nop
++0000f9e4 <[^>]*> nop
++0000f9e8 <[^>]*> nop
++0000f9ec <[^>]*> nop
++0000f9f0 <[^>]*> nop
++0000f9f4 <[^>]*> nop
++0000f9f8 <[^>]*> nop
++0000f9fc <[^>]*> nop
++0000fa00 <[^>]*> nop
++0000fa04 <[^>]*> nop
++0000fa08 <[^>]*> nop
++0000fa0c <[^>]*> nop
++0000fa10 <[^>]*> nop
++0000fa14 <[^>]*> nop
++0000fa18 <[^>]*> nop
++0000fa1c <[^>]*> nop
++0000fa20 <[^>]*> nop
++0000fa24 <[^>]*> nop
++0000fa28 <[^>]*> nop
++0000fa2c <[^>]*> nop
++0000fa30 <[^>]*> nop
++0000fa34 <[^>]*> nop
++0000fa38 <[^>]*> nop
++0000fa3c <[^>]*> nop
++0000fa40 <[^>]*> nop
++0000fa44 <[^>]*> nop
++0000fa48 <[^>]*> nop
++0000fa4c <[^>]*> nop
++0000fa50 <[^>]*> nop
++0000fa54 <[^>]*> nop
++0000fa58 <[^>]*> nop
++0000fa5c <[^>]*> nop
++0000fa60 <[^>]*> nop
++0000fa64 <[^>]*> nop
++0000fa68 <[^>]*> nop
++0000fa6c <[^>]*> nop
++0000fa70 <[^>]*> nop
++0000fa74 <[^>]*> nop
++0000fa78 <[^>]*> nop
++0000fa7c <[^>]*> nop
++0000fa80 <[^>]*> nop
++0000fa84 <[^>]*> nop
++0000fa88 <[^>]*> nop
++0000fa8c <[^>]*> nop
++0000fa90 <[^>]*> nop
++0000fa94 <[^>]*> nop
++0000fa98 <[^>]*> nop
++0000fa9c <[^>]*> nop
++0000faa0 <[^>]*> nop
++0000faa4 <[^>]*> nop
++0000faa8 <[^>]*> nop
++0000faac <[^>]*> nop
++0000fab0 <[^>]*> nop
++0000fab4 <[^>]*> nop
++0000fab8 <[^>]*> nop
++0000fabc <[^>]*> nop
++0000fac0 <[^>]*> nop
++0000fac4 <[^>]*> nop
++0000fac8 <[^>]*> nop
++0000facc <[^>]*> nop
++0000fad0 <[^>]*> nop
++0000fad4 <[^>]*> nop
++0000fad8 <[^>]*> nop
++0000fadc <[^>]*> nop
++0000fae0 <[^>]*> nop
++0000fae4 <[^>]*> nop
++0000fae8 <[^>]*> nop
++0000faec <[^>]*> nop
++0000faf0 <[^>]*> nop
++0000faf4 <[^>]*> nop
++0000faf8 <[^>]*> nop
++0000fafc <[^>]*> nop
++0000fb00 <[^>]*> nop
++0000fb04 <[^>]*> nop
++0000fb08 <[^>]*> nop
++0000fb0c <[^>]*> nop
++0000fb10 <[^>]*> nop
++0000fb14 <[^>]*> nop
++0000fb18 <[^>]*> nop
++0000fb1c <[^>]*> nop
++0000fb20 <[^>]*> nop
++0000fb24 <[^>]*> nop
++0000fb28 <[^>]*> nop
++0000fb2c <[^>]*> nop
++0000fb30 <[^>]*> nop
++0000fb34 <[^>]*> nop
++0000fb38 <[^>]*> nop
++0000fb3c <[^>]*> nop
++0000fb40 <[^>]*> nop
++0000fb44 <[^>]*> nop
++0000fb48 <[^>]*> nop
++0000fb4c <[^>]*> nop
++0000fb50 <[^>]*> nop
++0000fb54 <[^>]*> nop
++0000fb58 <[^>]*> nop
++0000fb5c <[^>]*> nop
++0000fb60 <[^>]*> nop
++0000fb64 <[^>]*> nop
++0000fb68 <[^>]*> nop
++0000fb6c <[^>]*> nop
++0000fb70 <[^>]*> nop
++0000fb74 <[^>]*> nop
++0000fb78 <[^>]*> nop
++0000fb7c <[^>]*> nop
++0000fb80 <[^>]*> nop
++0000fb84 <[^>]*> nop
++0000fb88 <[^>]*> nop
++0000fb8c <[^>]*> nop
++0000fb90 <[^>]*> nop
++0000fb94 <[^>]*> nop
++0000fb98 <[^>]*> nop
++0000fb9c <[^>]*> nop
++0000fba0 <[^>]*> nop
++0000fba4 <[^>]*> nop
++0000fba8 <[^>]*> nop
++0000fbac <[^>]*> nop
++0000fbb0 <[^>]*> nop
++0000fbb4 <[^>]*> nop
++0000fbb8 <[^>]*> nop
++0000fbbc <[^>]*> nop
++0000fbc0 <[^>]*> nop
++0000fbc4 <[^>]*> nop
++0000fbc8 <[^>]*> nop
++0000fbcc <[^>]*> nop
++0000fbd0 <[^>]*> nop
++0000fbd4 <[^>]*> nop
++0000fbd8 <[^>]*> nop
++0000fbdc <[^>]*> nop
++0000fbe0 <[^>]*> nop
++0000fbe4 <[^>]*> nop
++0000fbe8 <[^>]*> nop
++0000fbec <[^>]*> nop
++0000fbf0 <[^>]*> nop
++0000fbf4 <[^>]*> nop
++0000fbf8 <[^>]*> nop
++0000fbfc <[^>]*> nop
++0000fc00 <[^>]*> nop
++0000fc04 <[^>]*> nop
++0000fc08 <[^>]*> nop
++0000fc0c <[^>]*> nop
++0000fc10 <[^>]*> nop
++0000fc14 <[^>]*> nop
++0000fc18 <[^>]*> nop
++0000fc1c <[^>]*> nop
++0000fc20 <[^>]*> nop
++0000fc24 <[^>]*> nop
++0000fc28 <[^>]*> nop
++0000fc2c <[^>]*> nop
++0000fc30 <[^>]*> nop
++0000fc34 <[^>]*> nop
++0000fc38 <[^>]*> nop
++0000fc3c <[^>]*> nop
++0000fc40 <[^>]*> nop
++0000fc44 <[^>]*> nop
++0000fc48 <[^>]*> nop
++0000fc4c <[^>]*> nop
++0000fc50 <[^>]*> nop
++0000fc54 <[^>]*> nop
++0000fc58 <[^>]*> nop
++0000fc5c <[^>]*> nop
++0000fc60 <[^>]*> nop
++0000fc64 <[^>]*> nop
++0000fc68 <[^>]*> nop
++0000fc6c <[^>]*> nop
++0000fc70 <[^>]*> nop
++0000fc74 <[^>]*> nop
++0000fc78 <[^>]*> nop
++0000fc7c <[^>]*> nop
++0000fc80 <[^>]*> nop
++0000fc84 <[^>]*> nop
++0000fc88 <[^>]*> nop
++0000fc8c <[^>]*> nop
++0000fc90 <[^>]*> nop
++0000fc94 <[^>]*> nop
++0000fc98 <[^>]*> nop
++0000fc9c <[^>]*> nop
++0000fca0 <[^>]*> nop
++0000fca4 <[^>]*> nop
++0000fca8 <[^>]*> nop
++0000fcac <[^>]*> nop
++0000fcb0 <[^>]*> nop
++0000fcb4 <[^>]*> nop
++0000fcb8 <[^>]*> nop
++0000fcbc <[^>]*> nop
++0000fcc0 <[^>]*> nop
++0000fcc4 <[^>]*> nop
++0000fcc8 <[^>]*> nop
++0000fccc <[^>]*> nop
++0000fcd0 <[^>]*> nop
++0000fcd4 <[^>]*> nop
++0000fcd8 <[^>]*> nop
++0000fcdc <[^>]*> nop
++0000fce0 <[^>]*> nop
++0000fce4 <[^>]*> nop
++0000fce8 <[^>]*> nop
++0000fcec <[^>]*> nop
++0000fcf0 <[^>]*> nop
++0000fcf4 <[^>]*> nop
++0000fcf8 <[^>]*> nop
++0000fcfc <[^>]*> nop
++0000fd00 <[^>]*> nop
++0000fd04 <[^>]*> nop
++0000fd08 <[^>]*> nop
++0000fd0c <[^>]*> nop
++0000fd10 <[^>]*> nop
++0000fd14 <[^>]*> nop
++0000fd18 <[^>]*> nop
++0000fd1c <[^>]*> nop
++0000fd20 <[^>]*> nop
++0000fd24 <[^>]*> nop
++0000fd28 <[^>]*> nop
++0000fd2c <[^>]*> nop
++0000fd30 <[^>]*> nop
++0000fd34 <[^>]*> nop
++0000fd38 <[^>]*> nop
++0000fd3c <[^>]*> nop
++0000fd40 <[^>]*> nop
++0000fd44 <[^>]*> nop
++0000fd48 <[^>]*> nop
++0000fd4c <[^>]*> nop
++0000fd50 <[^>]*> nop
++0000fd54 <[^>]*> nop
++0000fd58 <[^>]*> nop
++0000fd5c <[^>]*> nop
++0000fd60 <[^>]*> nop
++0000fd64 <[^>]*> nop
++0000fd68 <[^>]*> nop
++0000fd6c <[^>]*> nop
++0000fd70 <[^>]*> nop
++0000fd74 <[^>]*> nop
++0000fd78 <[^>]*> nop
++0000fd7c <[^>]*> nop
++0000fd80 <[^>]*> nop
++0000fd84 <[^>]*> nop
++0000fd88 <[^>]*> nop
++0000fd8c <[^>]*> nop
++0000fd90 <[^>]*> nop
++0000fd94 <[^>]*> nop
++0000fd98 <[^>]*> nop
++0000fd9c <[^>]*> nop
++0000fda0 <[^>]*> nop
++0000fda4 <[^>]*> nop
++0000fda8 <[^>]*> nop
++0000fdac <[^>]*> nop
++0000fdb0 <[^>]*> nop
++0000fdb4 <[^>]*> nop
++0000fdb8 <[^>]*> nop
++0000fdbc <[^>]*> nop
++0000fdc0 <[^>]*> nop
++0000fdc4 <[^>]*> nop
++0000fdc8 <[^>]*> nop
++0000fdcc <[^>]*> nop
++0000fdd0 <[^>]*> nop
++0000fdd4 <[^>]*> nop
++0000fdd8 <[^>]*> nop
++0000fddc <[^>]*> nop
++0000fde0 <[^>]*> nop
++0000fde4 <[^>]*> nop
++0000fde8 <[^>]*> nop
++0000fdec <[^>]*> nop
++0000fdf0 <[^>]*> nop
++0000fdf4 <[^>]*> nop
++0000fdf8 <[^>]*> nop
++0000fdfc <[^>]*> nop
++0000fe00 <[^>]*> nop
++0000fe04 <[^>]*> nop
++0000fe08 <[^>]*> nop
++0000fe0c <[^>]*> nop
++0000fe10 <[^>]*> nop
++0000fe14 <[^>]*> nop
++0000fe18 <[^>]*> nop
++0000fe1c <[^>]*> nop
++0000fe20 <[^>]*> nop
++0000fe24 <[^>]*> nop
++0000fe28 <[^>]*> nop
++0000fe2c <[^>]*> nop
++0000fe30 <[^>]*> nop
++0000fe34 <[^>]*> nop
++0000fe38 <[^>]*> nop
++0000fe3c <[^>]*> nop
++0000fe40 <[^>]*> nop
++0000fe44 <[^>]*> nop
++0000fe48 <[^>]*> nop
++0000fe4c <[^>]*> nop
++0000fe50 <[^>]*> nop
++0000fe54 <[^>]*> nop
++0000fe58 <[^>]*> nop
++0000fe5c <[^>]*> nop
++0000fe60 <[^>]*> nop
++0000fe64 <[^>]*> nop
++0000fe68 <[^>]*> nop
++0000fe6c <[^>]*> nop
++0000fe70 <[^>]*> nop
++0000fe74 <[^>]*> nop
++0000fe78 <[^>]*> nop
++0000fe7c <[^>]*> nop
++0000fe80 <[^>]*> nop
++0000fe84 <[^>]*> nop
++0000fe88 <[^>]*> nop
++0000fe8c <[^>]*> nop
++0000fe90 <[^>]*> nop
++0000fe94 <[^>]*> nop
++0000fe98 <[^>]*> nop
++0000fe9c <[^>]*> nop
++0000fea0 <[^>]*> nop
++0000fea4 <[^>]*> nop
++0000fea8 <[^>]*> nop
++0000feac <[^>]*> nop
++0000feb0 <[^>]*> nop
++0000feb4 <[^>]*> nop
++0000feb8 <[^>]*> nop
++0000febc <[^>]*> nop
++0000fec0 <[^>]*> nop
++0000fec4 <[^>]*> nop
++0000fec8 <[^>]*> nop
++0000fecc <[^>]*> nop
++0000fed0 <[^>]*> nop
++0000fed4 <[^>]*> nop
++0000fed8 <[^>]*> nop
++0000fedc <[^>]*> nop
++0000fee0 <[^>]*> nop
++0000fee4 <[^>]*> nop
++0000fee8 <[^>]*> nop
++0000feec <[^>]*> nop
++0000fef0 <[^>]*> nop
++0000fef4 <[^>]*> nop
++0000fef8 <[^>]*> nop
++0000fefc <[^>]*> nop
++0000ff00 <[^>]*> nop
++0000ff04 <[^>]*> nop
++0000ff08 <[^>]*> nop
++0000ff0c <[^>]*> nop
++0000ff10 <[^>]*> nop
++0000ff14 <[^>]*> nop
++0000ff18 <[^>]*> nop
++0000ff1c <[^>]*> nop
++0000ff20 <[^>]*> nop
++0000ff24 <[^>]*> nop
++0000ff28 <[^>]*> nop
++0000ff2c <[^>]*> nop
++0000ff30 <[^>]*> nop
++0000ff34 <[^>]*> nop
++0000ff38 <[^>]*> nop
++0000ff3c <[^>]*> nop
++0000ff40 <[^>]*> nop
++0000ff44 <[^>]*> nop
++0000ff48 <[^>]*> nop
++0000ff4c <[^>]*> nop
++0000ff50 <[^>]*> nop
++0000ff54 <[^>]*> nop
++0000ff58 <[^>]*> nop
++0000ff5c <[^>]*> nop
++0000ff60 <[^>]*> nop
++0000ff64 <[^>]*> nop
++0000ff68 <[^>]*> nop
++0000ff6c <[^>]*> nop
++0000ff70 <[^>]*> nop
++0000ff74 <[^>]*> nop
++0000ff78 <[^>]*> nop
++0000ff7c <[^>]*> nop
++0000ff80 <[^>]*> nop
++0000ff84 <[^>]*> nop
++0000ff88 <[^>]*> nop
++0000ff8c <[^>]*> nop
++0000ff90 <[^>]*> nop
++0000ff94 <[^>]*> nop
++0000ff98 <[^>]*> nop
++0000ff9c <[^>]*> nop
++0000ffa0 <[^>]*> nop
++0000ffa4 <[^>]*> nop
++0000ffa8 <[^>]*> nop
++0000ffac <[^>]*> nop
++0000ffb0 <[^>]*> nop
++0000ffb4 <[^>]*> nop
++0000ffb8 <[^>]*> nop
++0000ffbc <[^>]*> nop
++0000ffc0 <[^>]*> nop
++0000ffc4 <[^>]*> nop
++0000ffc8 <[^>]*> nop
++0000ffcc <[^>]*> nop
++0000ffd0 <[^>]*> nop
++0000ffd4 <[^>]*> nop
++0000ffd8 <[^>]*> nop
++0000ffdc <[^>]*> nop
++0000ffe0 <[^>]*> nop
++0000ffe4 <[^>]*> nop
++0000ffe8 <[^>]*> nop
++0000ffec <[^>]*> nop
++0000fff0 <[^>]*> nop
++0000fff4 <[^>]*> nop
++0000fff8 <[^>]*> nop
++0000fffc <[^>]*> nop
++00010000 <[^>]*> br 00010018 <[^>]*>
++00010004 <[^>]*> nop
++00010008 <[^>]*> nop
++0001000c <[^>]*> nop
++00010010 <[^>]*> nop
++00010014 <[^>]*> nop
++00010018 <[^>]*> nop
++ ...
+diff --git a/gas/testsuite/gas/nios2/relax_ujmp.s b/gas/testsuite/gas/nios2/relax_ujmp.s
+new file mode 100644
+index 0000000..8982d73
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/relax_ujmp.s
+@@ -0,0 +1,37 @@
++# relaxing unconditional jumps
++
++.globl text1
++.section text1, "ax", @progbits
++
++ br on_border
++ br out_of_range
++ nop
++ nop
++
++
++.align 15
++# nop
++# nop
++on_border:
++ br in_range
++ nop
++ nop
++ nop
++out_of_range:
++in_range:
++ nop
++
++.globl text2
++.section text2, "ax", @progbits
++
++ br text1
++ br out_of_range
++ br sym
++ nop
++ nop
++sym:
++ nop
++
++
++
++
+diff --git a/gas/testsuite/gas/nios2/reloc_symbols.s b/gas/testsuite/gas/nios2/reloc_symbols.s
+new file mode 100644
+index 0000000..532acf3
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/reloc_symbols.s
+@@ -0,0 +1,21 @@
++.text
++# byte aligned
++.align 0
++.byte byte_sym
++
++# short aligned
++.align 1
++.short short_sym
++
++# word aligned
++.align 2
++.long long_sym
++
++# now lets try some unaligned words and halfwords
++.byte byte_sym
++.2byte short_sym
++.4byte long_sym
++
++#.align 2
++#nop
++
+diff --git a/gas/testsuite/gas/nios2/ret.d b/gas/testsuite/gas/nios2/ret.d
+new file mode 100644
+index 0000000..b071931
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ret.d
+@@ -0,0 +1,8 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 ret
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> ret
++
+diff --git a/gas/testsuite/gas/nios2/ret.s b/gas/testsuite/gas/nios2/ret.s
+new file mode 100644
+index 0000000..69b76bc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/ret.s
+@@ -0,0 +1,5 @@
++# Source file used to test the ret instructions
++foo:
++ ret
++
++
+diff --git a/gas/testsuite/gas/nios2/rol.d b/gas/testsuite/gas/nios2/rol.d
+new file mode 100644
+index 0000000..2128dd5
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/rol.d
+@@ -0,0 +1,40 @@
++#objdump: -dr --prefix-addresses -mmips:3000
++#as: -march=r3000 -mtune=r3000
++#name: MIPS R3000 rol
++
++# Test the rol and ror macros.
++
++.*: +file format .*mips.*
++
++Disassembly of section .text:
++0+0000 <[^>]*> negu at,a1
++0+0004 <[^>]*> srlv at,a0,at
++0+0008 <[^>]*> sllv a0,a0,a1
++0+000c <[^>]*> or a0,a0,at
++0+0010 <[^>]*> negu at,a2
++0+0014 <[^>]*> srlv at,a1,at
++0+0018 <[^>]*> sllv a0,a1,a2
++0+001c <[^>]*> or a0,a0,at
++0+0020 <[^>]*> sll at,a0,0x1
++0+0024 <[^>]*> srl a0,a0,0x1f
++0+0028 <[^>]*> or a0,a0,at
++0+002c <[^>]*> sll at,a1,0x1
++0+0030 <[^>]*> srl a0,a1,0x1f
++0+0034 <[^>]*> or a0,a0,at
++0+0038 <[^>]*> srl a0,a1,0x0
++0+003c <[^>]*> negu at,a1
++0+0040 <[^>]*> sllv at,a0,at
++0+0044 <[^>]*> srlv a0,a0,a1
++0+0048 <[^>]*> or a0,a0,at
++0+004c <[^>]*> negu at,a2
++0+0050 <[^>]*> sllv at,a1,at
++0+0054 <[^>]*> srlv a0,a1,a2
++0+0058 <[^>]*> or a0,a0,at
++0+005c <[^>]*> srl at,a0,0x1
++0+0060 <[^>]*> sll a0,a0,0x1f
++0+0064 <[^>]*> or a0,a0,at
++0+0068 <[^>]*> srl at,a1,0x1
++0+006c <[^>]*> sll a0,a1,0x1f
++0+0070 <[^>]*> or a0,a0,at
++0+0074 <[^>]*> srl a0,a1,0x0
++ ...
+diff --git a/gas/testsuite/gas/nios2/rol.s b/gas/testsuite/gas/nios2/rol.s
+new file mode 100644
+index 0000000..988d702
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/rol.s
+@@ -0,0 +1,15 @@
++# Source file used to test the rol and ror macros.
++
++foo:
++ rol $4,$5
++ rol $4,$5,$6
++ rol $4,1
++ rol $4,$5,1
++ rol $4,$5,0
++
++ ror $4,$5
++ ror $4,$5,$6
++ ror $4,1
++ ror $4,$5,1
++ ror $4,$5,0
++ .space 8
+diff --git a/gas/testsuite/gas/nios2/rotate.d b/gas/testsuite/gas/nios2/rotate.d
+new file mode 100644
+index 0000000..0f54f43
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/rotate.d
+@@ -0,0 +1,17 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 rotate
++
++# Test the and macro.
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> rol r4,r4,r4
++0+0004 <[^>]*> roli r4,r4,31
++0+0008 <[^>]*> ror r4,r4,r4
++0+000c <[^>]*> sll r4,r4,r4
++0+0010 <[^>]*> slli r4,r4,24
++0+0014 <[^>]*> sra r4,r4,r4
++0+0018 <[^>]*> srai r4,r4,10
++0+001c <[^>]*> srl r4,r4,r4
++0+0020 <[^>]*> srli r4,r4,5
+diff --git a/gas/testsuite/gas/nios2/rotate.s b/gas/testsuite/gas/nios2/rotate.s
+new file mode 100644
+index 0000000..81c4ee1
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/rotate.s
+@@ -0,0 +1,13 @@
++# test New Jersey rotate instructions
++
++.text
++foo:
++ rol r4,r4,r4
++ roli r4,r4,31
++ ror r4,r4,r4
++ sll r4,r4,r4
++ slli r4,r4,24
++ sra r4,r4,r4
++ srai r4,r4,10
++ srl r4,r4,r4
++ srli r4,r4,5
+diff --git a/gas/testsuite/gas/nios2/s16_symbol.s b/gas/testsuite/gas/nios2/s16_symbol.s
+new file mode 100644
+index 0000000..3902177
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/s16_symbol.s
+@@ -0,0 +1,10 @@
++.global some_sym
++.global some_other_sym
++.global min
++.global max
++
++.set max, 0x7fff
++.set min, -0x8000
++.set some_sym, 0x1000
++
++
+diff --git a/gas/testsuite/gas/nios2/stb.d b/gas/testsuite/gas/nios2/stb.d
+new file mode 100644
+index 0000000..82f04ca
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/stb.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 stb
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> stb r4,0\(zero\)
++0+0004 <[^>]*> stb r4,4\(zero\)
++0+0008 <[^>]*> stb r4,32764\(zero\)
++0+000c <[^>]*> stb r4,-32768\(zero\)
++0+0010 <[^>]*> stb r4,0\(r5\)
++0+0014 <[^>]*> stb r4,4\(r5\)
++0+0018 <[^>]*> stb r4,32764\(r5\)
++0+001c <[^>]*> stb r4,-32768\(r5\)
++0+0020 <[^>]*> stb r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> stb r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> stb r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> stb r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> stb r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> stb r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> stb r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> stb r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> stb r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> stb r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> stb r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> stb r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> stb r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> stb r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> stb r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> stb r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> stb r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> stb r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> stb r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> stb r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> stb r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> stb r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> stb r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> stb r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> stb r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> stb r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> stb r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> stb r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> stb r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> stb r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> stb r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> stb r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> stb r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> stb r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> stb r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> stb r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> stb r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> stb r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> stb r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> stb r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> stb r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> stb r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> stb r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> stbio r4,0\(zero\)
++0+00d0 <[^>]*> stbio r4,4\(zero\)
++0+00d4 <[^>]*> stbio r4,32764\(zero\)
++0+00d8 <[^>]*> stbio r4,-32768\(zero\)
++0+00dc <[^>]*> stbio r4,0\(r5\)
++0+00e0 <[^>]*> stbio r4,4\(r5\)
++0+00e4 <[^>]*> stbio r4,32764\(r5\)
++0+00e8 <[^>]*> stbio r4,-32768\(r5\)
++0+00ec <[^>]*> stbio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> stbio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> stbio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> stbio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> stbio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> stbio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> stbio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> stbio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> stbio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> stbio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> stbio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> stbio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> stbio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> stbio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> stbio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> stbio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> stbio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> stbio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> stbio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> stbio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> stbio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> stbio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> stbio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> stbio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> stbio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> stbio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> stbio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> stbio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> stbio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> stbio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> stbio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> stbio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> stbio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> stbio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> stbio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> stbio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> stbio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> stbio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> stbio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> stbio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> stbio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> stbio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> stbio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/stb.s b/gas/testsuite/gas/nios2/stb.s
+new file mode 100644
+index 0000000..8078e94
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/stb.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ stb r4,0(r0)
++ stb r4,4(r0)
++ stb r4,0x7ffc(r0)
++ stb r4,-0x8000(r0)
++ stb r4,0(r5)
++ stb r4,4(r5)
++ stb r4,0x7ffc(r5)
++ stb r4,-0x8000(r5)
++ stb r4,data_label(r0)
++ stb r4,big_external_data_label(r0)
++ stb r4,small_external_data_label(r0)
++ stb r4,big_external_common(r0)
++ stb r4,small_external_common(r0)
++ stb r4,big_local_common(r0)
++ stb r4,small_local_common(r0)
++ stb r4,data_label+4(r0)
++ stb r4,big_external_data_label+4(r0)
++ stb r4,small_external_data_label+4(r0)
++ stb r4,big_external_common+4(r0)
++ stb r4,small_external_common+4(r0)
++ stb r4,big_local_common+4(r0)
++ stb r4,small_local_common+4(r0)
++ stb r4,data_label-0x8000(r0)
++ stb r4,big_external_data_label-0x8000(r0)
++ stb r4,small_external_data_label-0x8000(r0)
++ stb r4,big_external_common-0x8000(r0)
++ stb r4,small_external_common-0x8000(r0)
++ stb r4,big_local_common-0x8000(r0)
++ stb r4,small_local_common-0x8000(r0)
++ stb r4,data_label+0x10000(r0)
++ stb r4,data_label(r5)
++ stb r4,big_external_data_label(r5)
++ stb r4,small_external_data_label(r5)
++ stb r4,big_external_common(r5)
++ stb r4,small_external_common(r5)
++ stb r4,big_local_common(r5)
++ stb r4,small_local_common(r5)
++ stb r4,data_label+4(r5)
++ stb r4,big_external_data_label+4(r5)
++ stb r4,small_external_data_label+4(r5)
++ stb r4,big_external_common+4(r5)
++ stb r4,small_external_common+4(r5)
++ stb r4,big_local_common+4(r5)
++ stb r4,small_local_common+4(r5)
++ stb r4,data_label-0x8000(r5)
++ stb r4,big_external_data_label-0x8000(r5)
++ stb r4,small_external_data_label-0x8000(r5)
++ stb r4,big_external_common-0x8000(r5)
++ stb r4,small_external_common-0x8000(r5)
++ stb r4,big_local_common-0x8000(r5)
++ stb r4,small_local_common-0x8000(r5)
++
++ stbio r4,0(r0)
++ stbio r4,4(r0)
++ stbio r4,0x7ffc(r0)
++ stbio r4,-0x8000(r0)
++ stbio r4,0(r5)
++ stbio r4,4(r5)
++ stbio r4,0x7ffc(r5)
++ stbio r4,-0x8000(r5)
++ stbio r4,data_label(r0)
++ stbio r4,big_external_data_label(r0)
++ stbio r4,small_external_data_label(r0)
++ stbio r4,big_external_common(r0)
++ stbio r4,small_external_common(r0)
++ stbio r4,big_local_common(r0)
++ stbio r4,small_local_common(r0)
++ stbio r4,data_label+4(r0)
++ stbio r4,big_external_data_label+4(r0)
++ stbio r4,small_external_data_label+4(r0)
++ stbio r4,big_external_common+4(r0)
++ stbio r4,small_external_common+4(r0)
++ stbio r4,big_local_common+4(r0)
++ stbio r4,small_local_common+4(r0)
++ stbio r4,data_label-0x8000(r0)
++ stbio r4,big_external_data_label-0x8000(r0)
++ stbio r4,small_external_data_label-0x8000(r0)
++ stbio r4,big_external_common-0x8000(r0)
++ stbio r4,small_external_common-0x8000(r0)
++ stbio r4,big_local_common-0x8000(r0)
++ stbio r4,small_local_common-0x8000(r0)
++ stbio r4,data_label+0x10000(r0)
++ stbio r4,data_label(r5)
++ stbio r4,big_external_data_label(r5)
++ stbio r4,small_external_data_label(r5)
++ stbio r4,big_external_common(r5)
++ stbio r4,small_external_common(r5)
++ stbio r4,big_local_common(r5)
++ stbio r4,small_local_common(r5)
++ stbio r4,data_label+4(r5)
++ stbio r4,big_external_data_label+4(r5)
++ stbio r4,small_external_data_label+4(r5)
++ stbio r4,big_external_common+4(r5)
++ stbio r4,small_external_common+4(r5)
++ stbio r4,big_local_common+4(r5)
++ stbio r4,small_local_common+4(r5)
++ stbio r4,data_label-0x8000(r5)
++ stbio r4,big_external_data_label-0x8000(r5)
++ stbio r4,small_external_data_label-0x8000(r5)
++ stbio r4,big_external_common-0x8000(r5)
++ stbio r4,small_external_common-0x8000(r5)
++ stbio r4,big_local_common-0x8000(r5)
++ stbio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/sth.d b/gas/testsuite/gas/nios2/sth.d
+new file mode 100644
+index 0000000..dd9ec69
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sth.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 sth
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> sth r4,0\(zero\)
++0+0004 <[^>]*> sth r4,4\(zero\)
++0+0008 <[^>]*> sth r4,32764\(zero\)
++0+000c <[^>]*> sth r4,-32768\(zero\)
++0+0010 <[^>]*> sth r4,0\(r5\)
++0+0014 <[^>]*> sth r4,4\(r5\)
++0+0018 <[^>]*> sth r4,32764\(r5\)
++0+001c <[^>]*> sth r4,-32768\(r5\)
++0+0020 <[^>]*> sth r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> sth r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> sth r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> sth r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> sth r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> sth r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> sth r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> sth r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> sth r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> sth r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> sth r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> sth r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> sth r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> sth r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> sth r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> sth r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> sth r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> sth r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> sth r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> sth r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> sth r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> sth r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> sth r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> sth r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> sth r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> sth r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> sth r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> sth r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> sth r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> sth r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> sth r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> sth r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> sth r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> sth r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> sth r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> sth r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> sth r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> sth r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> sth r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> sth r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> sth r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> sth r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> sth r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> sthio r4,0\(zero\)
++0+00d0 <[^>]*> sthio r4,4\(zero\)
++0+00d4 <[^>]*> sthio r4,32764\(zero\)
++0+00d8 <[^>]*> sthio r4,-32768\(zero\)
++0+00dc <[^>]*> sthio r4,0\(r5\)
++0+00e0 <[^>]*> sthio r4,4\(r5\)
++0+00e4 <[^>]*> sthio r4,32764\(r5\)
++0+00e8 <[^>]*> sthio r4,-32768\(r5\)
++0+00ec <[^>]*> sthio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> sthio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> sthio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> sthio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> sthio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> sthio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> sthio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> sthio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> sthio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> sthio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> sthio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> sthio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> sthio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> sthio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> sthio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> sthio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> sthio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> sthio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> sthio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> sthio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> sthio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> sthio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> sthio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> sthio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> sthio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> sthio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> sthio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> sthio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> sthio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> sthio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> sthio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> sthio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> sthio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> sthio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> sthio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> sthio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> sthio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> sthio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> sthio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> sthio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> sthio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> sthio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> sthio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/sth.s b/gas/testsuite/gas/nios2/sth.s
+new file mode 100644
+index 0000000..4b9390b
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sth.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ sth r4,0(r0)
++ sth r4,4(r0)
++ sth r4,0x7ffc(r0)
++ sth r4,-0x8000(r0)
++ sth r4,0(r5)
++ sth r4,4(r5)
++ sth r4,0x7ffc(r5)
++ sth r4,-0x8000(r5)
++ sth r4,data_label(r0)
++ sth r4,big_external_data_label(r0)
++ sth r4,small_external_data_label(r0)
++ sth r4,big_external_common(r0)
++ sth r4,small_external_common(r0)
++ sth r4,big_local_common(r0)
++ sth r4,small_local_common(r0)
++ sth r4,data_label+4(r0)
++ sth r4,big_external_data_label+4(r0)
++ sth r4,small_external_data_label+4(r0)
++ sth r4,big_external_common+4(r0)
++ sth r4,small_external_common+4(r0)
++ sth r4,big_local_common+4(r0)
++ sth r4,small_local_common+4(r0)
++ sth r4,data_label-0x8000(r0)
++ sth r4,big_external_data_label-0x8000(r0)
++ sth r4,small_external_data_label-0x8000(r0)
++ sth r4,big_external_common-0x8000(r0)
++ sth r4,small_external_common-0x8000(r0)
++ sth r4,big_local_common-0x8000(r0)
++ sth r4,small_local_common-0x8000(r0)
++ sth r4,data_label+0x10000(r0)
++ sth r4,data_label(r5)
++ sth r4,big_external_data_label(r5)
++ sth r4,small_external_data_label(r5)
++ sth r4,big_external_common(r5)
++ sth r4,small_external_common(r5)
++ sth r4,big_local_common(r5)
++ sth r4,small_local_common(r5)
++ sth r4,data_label+4(r5)
++ sth r4,big_external_data_label+4(r5)
++ sth r4,small_external_data_label+4(r5)
++ sth r4,big_external_common+4(r5)
++ sth r4,small_external_common+4(r5)
++ sth r4,big_local_common+4(r5)
++ sth r4,small_local_common+4(r5)
++ sth r4,data_label-0x8000(r5)
++ sth r4,big_external_data_label-0x8000(r5)
++ sth r4,small_external_data_label-0x8000(r5)
++ sth r4,big_external_common-0x8000(r5)
++ sth r4,small_external_common-0x8000(r5)
++ sth r4,big_local_common-0x8000(r5)
++ sth r4,small_local_common-0x8000(r5)
++
++ sthio r4,0(r0)
++ sthio r4,4(r0)
++ sthio r4,0x7ffc(r0)
++ sthio r4,-0x8000(r0)
++ sthio r4,0(r5)
++ sthio r4,4(r5)
++ sthio r4,0x7ffc(r5)
++ sthio r4,-0x8000(r5)
++ sthio r4,data_label(r0)
++ sthio r4,big_external_data_label(r0)
++ sthio r4,small_external_data_label(r0)
++ sthio r4,big_external_common(r0)
++ sthio r4,small_external_common(r0)
++ sthio r4,big_local_common(r0)
++ sthio r4,small_local_common(r0)
++ sthio r4,data_label+4(r0)
++ sthio r4,big_external_data_label+4(r0)
++ sthio r4,small_external_data_label+4(r0)
++ sthio r4,big_external_common+4(r0)
++ sthio r4,small_external_common+4(r0)
++ sthio r4,big_local_common+4(r0)
++ sthio r4,small_local_common+4(r0)
++ sthio r4,data_label-0x8000(r0)
++ sthio r4,big_external_data_label-0x8000(r0)
++ sthio r4,small_external_data_label-0x8000(r0)
++ sthio r4,big_external_common-0x8000(r0)
++ sthio r4,small_external_common-0x8000(r0)
++ sthio r4,big_local_common-0x8000(r0)
++ sthio r4,small_local_common-0x8000(r0)
++ sthio r4,data_label+0x10000(r0)
++ sthio r4,data_label(r5)
++ sthio r4,big_external_data_label(r5)
++ sthio r4,small_external_data_label(r5)
++ sthio r4,big_external_common(r5)
++ sthio r4,small_external_common(r5)
++ sthio r4,big_local_common(r5)
++ sthio r4,small_local_common(r5)
++ sthio r4,data_label+4(r5)
++ sthio r4,big_external_data_label+4(r5)
++ sthio r4,small_external_data_label+4(r5)
++ sthio r4,big_external_common+4(r5)
++ sthio r4,small_external_common+4(r5)
++ sthio r4,big_local_common+4(r5)
++ sthio r4,small_local_common+4(r5)
++ sthio r4,data_label-0x8000(r5)
++ sthio r4,big_external_data_label-0x8000(r5)
++ sthio r4,small_external_data_label-0x8000(r5)
++ sthio r4,big_external_common-0x8000(r5)
++ sthio r4,small_external_common-0x8000(r5)
++ sthio r4,big_local_common-0x8000(r5)
++ sthio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/str2.s b/gas/testsuite/gas/nios2/str2.s
+new file mode 100644
+index 0000000..5310d4e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/str2.s
+@@ -0,0 +1,21 @@
++ .section .rodata.str1.1,"aMS",@progbits,1
++.LC0:
++ .string "DHRYSTONE PROGRAM, 3'RD STRING"
++.LC1:
++ .string "COMMON"
++.LC2:
++ .string "DHRYSTONE PROGRAM, 4'TH STRING"
++
++ .section .text
++ .align 3
++ .global func2
++ .type func2, @function
++func2:
++ #movhi r2, %hiadj(.LC0)
++ addi r2, r2, .LC0
++ #movhi r3, %hiadj(.LC1)
++ addi r3, r3, .LC1
++ #movhi r4, %hiadj(.LC2)
++ addi r4, r4, .LC2
++ .size func2, .-func2
++
+diff --git a/gas/testsuite/gas/nios2/stw.d b/gas/testsuite/gas/nios2/stw.d
+new file mode 100644
+index 0000000..e291bda
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/stw.d
+@@ -0,0 +1,196 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 stw
++
++# Test the ld instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> stw r4,0\(zero\)
++0+0004 <[^>]*> stw r4,4\(zero\)
++0+0008 <[^>]*> stw r4,32764\(zero\)
++0+000c <[^>]*> stw r4,-32768\(zero\)
++0+0010 <[^>]*> stw r4,0\(r5\)
++0+0014 <[^>]*> stw r4,4\(r5\)
++0+0018 <[^>]*> stw r4,32764\(r5\)
++0+001c <[^>]*> stw r4,-32768\(r5\)
++0+0020 <[^>]*> stw r4,0\(zero\)
++[ ]*20: R_NIOS2_S16 .data
++0+0024 <[^>]*> stw r4,0\(zero\)
++[ ]*24: R_NIOS2_S16 big_external_data_label
++0+0028 <[^>]*> stw r4,0\(zero\)
++[ ]*28: R_NIOS2_S16 small_external_data_label
++0+002c <[^>]*> stw r4,0\(zero\)
++[ ]*2c: R_NIOS2_S16 big_external_common
++0+0030 <[^>]*> stw r4,0\(zero\)
++[ ]*30: R_NIOS2_S16 small_external_common
++0+0034 <[^>]*> stw r4,0\(zero\)
++[ ]*34: R_NIOS2_S16 .bss
++0+0038 <[^>]*> stw r4,0\(zero\)
++[ ]*38: R_NIOS2_S16 .bss\+0x4000
++0+003c <[^>]*> stw r4,0\(zero\)
++[ ]*3c: R_NIOS2_S16 .data\+0x4
++0+0040 <[^>]*> stw r4,0\(zero\)
++[ ]*40: R_NIOS2_S16 big_external_data_label\+0x4
++0+0044 <[^>]*> stw r4,0\(zero\)
++[ ]*44: R_NIOS2_S16 small_external_data_label\+0x4
++0+0048 <[^>]*> stw r4,0\(zero\)
++[ ]*48: R_NIOS2_S16 big_external_common\+0x4
++0+004c <[^>]*> stw r4,0\(zero\)
++[ ]*4c: R_NIOS2_S16 small_external_common\+0x4
++0+0050 <[^>]*> stw r4,0\(zero\)
++[ ]*50: R_NIOS2_S16 .bss\+0x4
++0+0054 <[^>]*> stw r4,0\(zero\)
++[ ]*54: R_NIOS2_S16 .bss\+0x4004
++0+0058 <[^>]*> stw r4,0\(zero\)
++[ ]*58: R_NIOS2_S16 .data\+0xffff8000
++0+005c <[^>]*> stw r4,0\(zero\)
++[ ]*5c: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0060 <[^>]*> stw r4,0\(zero\)
++[ ]*60: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0064 <[^>]*> stw r4,0\(zero\)
++[ ]*64: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0068 <[^>]*> stw r4,0\(zero\)
++[ ]*68: R_NIOS2_S16 small_external_common\+0xffff8000
++0+006c <[^>]*> stw r4,0\(zero\)
++[ ]*6c: R_NIOS2_S16 .bss\+0xffff8000
++0+0070 <[^>]*> stw r4,0\(zero\)
++[ ]*70: R_NIOS2_S16 .bss\+0xffffc000
++0+0074 <[^>]*> stw r4,0\(zero\)
++[ ]*74: R_NIOS2_S16 .data\+0x10000
++0+0078 <[^>]*> stw r4,0\(r5\)
++[ ]*78: R_NIOS2_S16 .data
++0+007c <[^>]*> stw r4,0\(r5\)
++[ ]*7c: R_NIOS2_S16 big_external_data_label
++0+0080 <[^>]*> stw r4,0\(r5\)
++[ ]*80: R_NIOS2_S16 small_external_data_label
++0+0084 <[^>]*> stw r4,0\(r5\)
++[ ]*84: R_NIOS2_S16 big_external_common
++0+0088 <[^>]*> stw r4,0\(r5\)
++[ ]*88: R_NIOS2_S16 small_external_common
++0+008c <[^>]*> stw r4,0\(r5\)
++[ ]*8c: R_NIOS2_S16 .bss
++0+0090 <[^>]*> stw r4,0\(r5\)
++[ ]*90: R_NIOS2_S16 .bss\+0x4000
++0+0094 <[^>]*> stw r4,0\(r5\)
++[ ]*94: R_NIOS2_S16 .data\+0x4
++0+0098 <[^>]*> stw r4,0\(r5\)
++[ ]*98: R_NIOS2_S16 big_external_data_label\+0x4
++0+009c <[^>]*> stw r4,0\(r5\)
++[ ]*9c: R_NIOS2_S16 small_external_data_label\+0x4
++0+00a0 <[^>]*> stw r4,0\(r5\)
++[ ]*a0: R_NIOS2_S16 big_external_common\+0x4
++0+00a4 <[^>]*> stw r4,0\(r5\)
++[ ]*a4: R_NIOS2_S16 small_external_common\+0x4
++0+00a8 <[^>]*> stw r4,0\(r5\)
++[ ]*a8: R_NIOS2_S16 .bss\+0x4
++0+00ac <[^>]*> stw r4,0\(r5\)
++[ ]*ac: R_NIOS2_S16 .bss\+0x4004
++0+00b0 <[^>]*> stw r4,0\(r5\)
++[ ]*b0: R_NIOS2_S16 .data\+0xffff8000
++0+00b4 <[^>]*> stw r4,0\(r5\)
++[ ]*b4: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+00b8 <[^>]*> stw r4,0\(r5\)
++[ ]*b8: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+00bc <[^>]*> stw r4,0\(r5\)
++[ ]*bc: R_NIOS2_S16 big_external_common\+0xffff8000
++0+00c0 <[^>]*> stw r4,0\(r5\)
++[ ]*c0: R_NIOS2_S16 small_external_common\+0xffff8000
++0+00c4 <[^>]*> stw r4,0\(r5\)
++[ ]*c4: R_NIOS2_S16 .bss\+0xffff8000
++0+00c8 <[^>]*> stw r4,0\(r5\)
++[ ]*c8: R_NIOS2_S16 .bss\+0xffffc000
++0+00cc <[^>]*> stwio r4,0\(zero\)
++0+00d0 <[^>]*> stwio r4,4\(zero\)
++0+00d4 <[^>]*> stwio r4,32764\(zero\)
++0+00d8 <[^>]*> stwio r4,-32768\(zero\)
++0+00dc <[^>]*> stwio r4,0\(r5\)
++0+00e0 <[^>]*> stwio r4,4\(r5\)
++0+00e4 <[^>]*> stwio r4,32764\(r5\)
++0+00e8 <[^>]*> stwio r4,-32768\(r5\)
++0+00ec <[^>]*> stwio r4,0\(zero\)
++[ ]*ec: R_NIOS2_S16 .data
++0+00f0 <[^>]*> stwio r4,0\(zero\)
++[ ]*f0: R_NIOS2_S16 big_external_data_label
++0+00f4 <[^>]*> stwio r4,0\(zero\)
++[ ]*f4: R_NIOS2_S16 small_external_data_label
++0+00f8 <[^>]*> stwio r4,0\(zero\)
++[ ]*f8: R_NIOS2_S16 big_external_common
++0+00fc <[^>]*> stwio r4,0\(zero\)
++[ ]*fc: R_NIOS2_S16 small_external_common
++0+0100 <[^>]*> stwio r4,0\(zero\)
++[ ]*100: R_NIOS2_S16 .bss
++0+0104 <[^>]*> stwio r4,0\(zero\)
++[ ]*104: R_NIOS2_S16 .bss\+0x4000
++0+0108 <[^>]*> stwio r4,0\(zero\)
++[ ]*108: R_NIOS2_S16 .data\+0x4
++0+010c <[^>]*> stwio r4,0\(zero\)
++[ ]*10c: R_NIOS2_S16 big_external_data_label\+0x4
++0+0110 <[^>]*> stwio r4,0\(zero\)
++[ ]*110: R_NIOS2_S16 small_external_data_label\+0x4
++0+0114 <[^>]*> stwio r4,0\(zero\)
++[ ]*114: R_NIOS2_S16 big_external_common\+0x4
++0+0118 <[^>]*> stwio r4,0\(zero\)
++[ ]*118: R_NIOS2_S16 small_external_common\+0x4
++0+011c <[^>]*> stwio r4,0\(zero\)
++[ ]*11c: R_NIOS2_S16 .bss\+0x4
++0+0120 <[^>]*> stwio r4,0\(zero\)
++[ ]*120: R_NIOS2_S16 .bss\+0x4004
++0+0124 <[^>]*> stwio r4,0\(zero\)
++[ ]*124: R_NIOS2_S16 .data\+0xffff8000
++0+0128 <[^>]*> stwio r4,0\(zero\)
++[ ]*128: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+012c <[^>]*> stwio r4,0\(zero\)
++[ ]*12c: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0130 <[^>]*> stwio r4,0\(zero\)
++[ ]*130: R_NIOS2_S16 big_external_common\+0xffff8000
++0+0134 <[^>]*> stwio r4,0\(zero\)
++[ ]*134: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0138 <[^>]*> stwio r4,0\(zero\)
++[ ]*138: R_NIOS2_S16 .bss\+0xffff8000
++0+013c <[^>]*> stwio r4,0\(zero\)
++[ ]*13c: R_NIOS2_S16 .bss\+0xffffc000
++0+0140 <[^>]*> stwio r4,0\(zero\)
++[ ]*140: R_NIOS2_S16 .data\+0x10000
++0+0144 <[^>]*> stwio r4,0\(r5\)
++[ ]*144: R_NIOS2_S16 .data
++0+0148 <[^>]*> stwio r4,0\(r5\)
++[ ]*148: R_NIOS2_S16 big_external_data_label
++0+014c <[^>]*> stwio r4,0\(r5\)
++[ ]*14c: R_NIOS2_S16 small_external_data_label
++0+0150 <[^>]*> stwio r4,0\(r5\)
++[ ]*150: R_NIOS2_S16 big_external_common
++0+0154 <[^>]*> stwio r4,0\(r5\)
++[ ]*154: R_NIOS2_S16 small_external_common
++0+0158 <[^>]*> stwio r4,0\(r5\)
++[ ]*158: R_NIOS2_S16 .bss
++0+015c <[^>]*> stwio r4,0\(r5\)
++[ ]*15c: R_NIOS2_S16 .bss\+0x4000
++0+0160 <[^>]*> stwio r4,0\(r5\)
++[ ]*160: R_NIOS2_S16 .data\+0x4
++0+0164 <[^>]*> stwio r4,0\(r5\)
++[ ]*164: R_NIOS2_S16 big_external_data_label\+0x4
++0+0168 <[^>]*> stwio r4,0\(r5\)
++[ ]*168: R_NIOS2_S16 small_external_data_label\+0x4
++0+016c <[^>]*> stwio r4,0\(r5\)
++[ ]*16c: R_NIOS2_S16 big_external_common\+0x4
++0+0170 <[^>]*> stwio r4,0\(r5\)
++[ ]*170: R_NIOS2_S16 small_external_common\+0x4
++0+0174 <[^>]*> stwio r4,0\(r5\)
++[ ]*174: R_NIOS2_S16 .bss\+0x4
++0+0178 <[^>]*> stwio r4,0\(r5\)
++[ ]*178: R_NIOS2_S16 .bss\+0x4004
++0+017c <[^>]*> stwio r4,0\(r5\)
++[ ]*17c: R_NIOS2_S16 .data\+0xffff8000
++0+0180 <[^>]*> stwio r4,0\(r5\)
++[ ]*180: R_NIOS2_S16 big_external_data_label\+0xffff8000
++0+0184 <[^>]*> stwio r4,0\(r5\)
++[ ]*184: R_NIOS2_S16 small_external_data_label\+0xffff8000
++0+0188 <[^>]*> stwio r4,0\(r5\)
++[ ]*188: R_NIOS2_S16 big_external_common\+0xffff8000
++0+018c <[^>]*> stwio r4,0\(r5\)
++[ ]*18c: R_NIOS2_S16 small_external_common\+0xffff8000
++0+0190 <[^>]*> stwio r4,0\(r5\)
++[ ]*190: R_NIOS2_S16 .bss\+0xffff8000
++0+0194 <[^>]*> stwio r4,0\(r5\)
++[ ]*194: R_NIOS2_S16 .bss\+0xffffc000
+diff --git a/gas/testsuite/gas/nios2/stw.s b/gas/testsuite/gas/nios2/stw.s
+new file mode 100644
+index 0000000..fa5c72f
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/stw.s
+@@ -0,0 +1,117 @@
++ .data
++data_label:
++ .extern big_external_data_label,0x4000
++ .extern small_external_data_label,4
++ .comm big_external_common,0x4000
++ .comm small_external_common,4
++ .lcomm big_local_common,0x4000
++ .lcomm small_local_common,4
++
++# the small symbols should have space allocated in the sbss section
++# but this is not yet supported in the assembler, so space is allocated
++# in the .bss section and the relocations are not gp-relative. this will
++# be updated when gp-relative relocations are added
++ .text
++ stw r4,0(r0)
++ stw r4,4(r0)
++ stw r4,0x7ffc(r0)
++ stw r4,-0x8000(r0)
++ stw r4,0(r5)
++ stw r4,4(r5)
++ stw r4,0x7ffc(r5)
++ stw r4,-0x8000(r5)
++ stw r4,data_label(r0)
++ stw r4,big_external_data_label(r0)
++ stw r4,small_external_data_label(r0)
++ stw r4,big_external_common(r0)
++ stw r4,small_external_common(r0)
++ stw r4,big_local_common(r0)
++ stw r4,small_local_common(r0)
++ stw r4,data_label+4(r0)
++ stw r4,big_external_data_label+4(r0)
++ stw r4,small_external_data_label+4(r0)
++ stw r4,big_external_common+4(r0)
++ stw r4,small_external_common+4(r0)
++ stw r4,big_local_common+4(r0)
++ stw r4,small_local_common+4(r0)
++ stw r4,data_label-0x8000(r0)
++ stw r4,big_external_data_label-0x8000(r0)
++ stw r4,small_external_data_label-0x8000(r0)
++ stw r4,big_external_common-0x8000(r0)
++ stw r4,small_external_common-0x8000(r0)
++ stw r4,big_local_common-0x8000(r0)
++ stw r4,small_local_common-0x8000(r0)
++ stw r4,data_label+0x10000(r0)
++ stw r4,data_label(r5)
++ stw r4,big_external_data_label(r5)
++ stw r4,small_external_data_label(r5)
++ stw r4,big_external_common(r5)
++ stw r4,small_external_common(r5)
++ stw r4,big_local_common(r5)
++ stw r4,small_local_common(r5)
++ stw r4,data_label+4(r5)
++ stw r4,big_external_data_label+4(r5)
++ stw r4,small_external_data_label+4(r5)
++ stw r4,big_external_common+4(r5)
++ stw r4,small_external_common+4(r5)
++ stw r4,big_local_common+4(r5)
++ stw r4,small_local_common+4(r5)
++ stw r4,data_label-0x8000(r5)
++ stw r4,big_external_data_label-0x8000(r5)
++ stw r4,small_external_data_label-0x8000(r5)
++ stw r4,big_external_common-0x8000(r5)
++ stw r4,small_external_common-0x8000(r5)
++ stw r4,big_local_common-0x8000(r5)
++ stw r4,small_local_common-0x8000(r5)
++
++ stwio r4,0(r0)
++ stwio r4,4(r0)
++ stwio r4,0x7ffc(r0)
++ stwio r4,-0x8000(r0)
++ stwio r4,0(r5)
++ stwio r4,4(r5)
++ stwio r4,0x7ffc(r5)
++ stwio r4,-0x8000(r5)
++ stwio r4,data_label(r0)
++ stwio r4,big_external_data_label(r0)
++ stwio r4,small_external_data_label(r0)
++ stwio r4,big_external_common(r0)
++ stwio r4,small_external_common(r0)
++ stwio r4,big_local_common(r0)
++ stwio r4,small_local_common(r0)
++ stwio r4,data_label+4(r0)
++ stwio r4,big_external_data_label+4(r0)
++ stwio r4,small_external_data_label+4(r0)
++ stwio r4,big_external_common+4(r0)
++ stwio r4,small_external_common+4(r0)
++ stwio r4,big_local_common+4(r0)
++ stwio r4,small_local_common+4(r0)
++ stwio r4,data_label-0x8000(r0)
++ stwio r4,big_external_data_label-0x8000(r0)
++ stwio r4,small_external_data_label-0x8000(r0)
++ stwio r4,big_external_common-0x8000(r0)
++ stwio r4,small_external_common-0x8000(r0)
++ stwio r4,big_local_common-0x8000(r0)
++ stwio r4,small_local_common-0x8000(r0)
++ stwio r4,data_label+0x10000(r0)
++ stwio r4,data_label(r5)
++ stwio r4,big_external_data_label(r5)
++ stwio r4,small_external_data_label(r5)
++ stwio r4,big_external_common(r5)
++ stwio r4,small_external_common(r5)
++ stwio r4,big_local_common(r5)
++ stwio r4,small_local_common(r5)
++ stwio r4,data_label+4(r5)
++ stwio r4,big_external_data_label+4(r5)
++ stwio r4,small_external_data_label+4(r5)
++ stwio r4,big_external_common+4(r5)
++ stwio r4,small_external_common+4(r5)
++ stwio r4,big_local_common+4(r5)
++ stwio r4,small_local_common+4(r5)
++ stwio r4,data_label-0x8000(r5)
++ stwio r4,big_external_data_label-0x8000(r5)
++ stwio r4,small_external_data_label-0x8000(r5)
++ stwio r4,big_external_common-0x8000(r5)
++ stwio r4,small_external_common-0x8000(r5)
++ stwio r4,big_local_common-0x8000(r5)
++ stwio r4,small_local_common-0x8000(r5)
+diff --git a/gas/testsuite/gas/nios2/sub.d b/gas/testsuite/gas/nios2/sub.d
+new file mode 100644
+index 0000000..69b0285
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sub.d
+@@ -0,0 +1,10 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 sub
++
++# Test the add instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> sub r4,r4,r4
++
+diff --git a/gas/testsuite/gas/nios2/sub.s b/gas/testsuite/gas/nios2/sub.s
+new file mode 100644
+index 0000000..34f00da
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sub.s
+@@ -0,0 +1,4 @@
++# Source file used to test the add and addi instructions.
++
++foo:
++ sub r4,r4,r4
+diff --git a/gas/testsuite/gas/nios2/sync.d b/gas/testsuite/gas/nios2/sync.d
+new file mode 100644
+index 0000000..f0949e2
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sync.d
+@@ -0,0 +1,8 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 sync
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section \.text:
++0+0000 <foo> sync
++
+diff --git a/gas/testsuite/gas/nios2/sync.s b/gas/testsuite/gas/nios2/sync.s
+new file mode 100644
+index 0000000..fe05d47
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/sync.s
+@@ -0,0 +1,5 @@
++# Source file used to test the sync instructions
++foo:
++ sync
++
++
+diff --git a/gas/testsuite/gas/nios2/trap.d b/gas/testsuite/gas/nios2/trap.d
+new file mode 100644
+index 0000000..003ff69
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/trap.d
+@@ -0,0 +1,7 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 trap
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> trap
+diff --git a/gas/testsuite/gas/nios2/trap.s b/gas/testsuite/gas/nios2/trap.s
+new file mode 100644
+index 0000000..1eb3c7e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/trap.s
+@@ -0,0 +1,3 @@
++# Source file used to test the ret instructions
++foo:
++ trap
+diff --git a/gas/testsuite/gas/nios2/tret.d b/gas/testsuite/gas/nios2/tret.d
+new file mode 100644
+index 0000000..48e2b51
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/tret.d
+@@ -0,0 +1,8 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 tret
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> eret
++
+diff --git a/gas/testsuite/gas/nios2/tret.s b/gas/testsuite/gas/nios2/tret.s
+new file mode 100644
+index 0000000..42179f1
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/tret.s
+@@ -0,0 +1,5 @@
++# Source file used to test the ret instructions
++foo:
++ eret
++
++
+diff --git a/gas/testsuite/gas/nios2/u16_symbol.s b/gas/testsuite/gas/nios2/u16_symbol.s
+new file mode 100644
+index 0000000..518b4de
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/u16_symbol.s
+@@ -0,0 +1,9 @@
++.global some_sym
++.global min
++.global max
++
++.set max, 0xffff
++.set min, 0
++.set some_sym, 0x1000
++
++
+diff --git a/gas/testsuite/gas/nios2/warn_noat.l b/gas/testsuite/gas/nios2/warn_noat.l
+new file mode 100644
+index 0000000..6bc5150
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/warn_noat.l
+@@ -0,0 +1,5 @@
++.*warn_noat.s: Assembler messages:
++.*warn_noat.s:2: Warning: Register at \(r1\) can sometimes be corrupted by assembler optimizations.
++Use .set noat to turn off those optimizations \(and this warning\).
++.*warn_noat.s:8: Warning: Register at \(r1\) can sometimes be corrupted by assembler optimizations.
++Use .set noat to turn off those optimizations \(and this warning\).
+diff --git a/gas/testsuite/gas/nios2/warn_noat.s b/gas/testsuite/gas/nios2/warn_noat.s
+new file mode 100644
+index 0000000..e99126e
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/warn_noat.s
+@@ -0,0 +1,8 @@
++.set noat, 2 # This should not cause warning for at to be turned off
++add at, r2, r2
++.set noat # this should turn the warnings off
++add at, r2, r2
++.set at, 3 # this should not turn the warnings on
++add at, r2, r2
++.set at # this should turn the warnings on
++add at, r2, r2
+diff --git a/gas/testsuite/gas/nios2/warn_nobreak.l b/gas/testsuite/gas/nios2/warn_nobreak.l
+new file mode 100644
+index 0000000..539813d
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/warn_nobreak.l
+@@ -0,0 +1,9 @@
++.*warn_nobreak.s: Assembler messages:
++.*warn_nobreak.s:2: Warning: The debugger will corrupt ba \(r30\). If you don't need to debug this
++code then use .set nobreak to turn off this warning.
++.*warn_nobreak.s:3: Warning: The debugger will corrupt bt \(r25\). If you don't need to debug this
++code then use .set nobreak to turn off this warning.
++.*warn_nobreak.s:11: Warning: The debugger will corrupt ba \(r30\). If you don't need to debug this
++code then use .set nobreak to turn off this warning.
++.*warn_nobreak.s:12: Warning: The debugger will corrupt bt \(r25\). If you don't need to debug this
++code then use .set nobreak to turn off this warning.
+diff --git a/gas/testsuite/gas/nios2/warn_nobreak.s b/gas/testsuite/gas/nios2/warn_nobreak.s
+new file mode 100644
+index 0000000..8e495c0
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/warn_nobreak.s
+@@ -0,0 +1,12 @@
++.set nobreak , 2 # This should not cause warning for ba, bt to be turned off
++add ba, r2, r2
++add bt, r2, r2
++.set nobreak # this should turn the warnings off
++add ba, r3, r4
++add bt, r3, r4
++.set break, 3 # this should not turn the warnings on
++add ba, r3, r4
++add bt, r3, r4
++.set break # this should turn the warnings on
++add ba, r3, r4
++add bt, r3, r4
+diff --git a/gas/testsuite/gas/nios2/xor.d b/gas/testsuite/gas/nios2/xor.d
+new file mode 100644
+index 0000000..de137dc
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/xor.d
+@@ -0,0 +1,11 @@
++#objdump: -dr --prefix-addresses
++#name: NIOS2 xor
++
++# Test the nor instruction
++
++.*: +file format elf32-littlenios2
++
++Disassembly of section .text:
++0+0000 <[^>]*> xor r6,r8,r10
++0+0004 <[^>]*> xorhi r6,r7,65535
++0+0008 <[^>]*> xori r6,r7,65535
+diff --git a/gas/testsuite/gas/nios2/xor.s b/gas/testsuite/gas/nios2/xor.s
+new file mode 100644
+index 0000000..2c558f7
+--- /dev/null
++++ b/gas/testsuite/gas/nios2/xor.s
+@@ -0,0 +1,7 @@
++# Source file used to test the nor instruction
++
++foo:
++ xor r6,r8,r10
++ xorhi r6,r7,0xffff
++ xori r6,r7,0xffff
++
+diff --git a/gas/testsuite/nios2_as_xfail.lst b/gas/testsuite/nios2_as_xfail.lst
+new file mode 100644
+index 0000000..27a4cd5
+--- /dev/null
++++ b/gas/testsuite/nios2_as_xfail.lst
+@@ -0,0 +1,4 @@
++FAIL: vtable inherit0
++FAIL: vtable entry1
++
++
+diff --git a/include/bfdlink.h b/include/bfdlink.h
+index cc2043e..ee821bf 100644
+--- a/include/bfdlink.h
++++ b/include/bfdlink.h
+@@ -688,4 +688,14 @@ struct bfd_elf_version_tree
+ struct bfd_elf_version_expr *prev, const char *sym);
+ };
+
++/* NG - There seems to be no way of getting link_info from the linker into
++ * bfd so that functions which aren't passed it can use it, and I need
++ * it so that gprel relocations work properly when generating srecs. This isn't
++ * right, but it works, and for the amount of work...*/
++#define bfd_set_link_info _bfd_set_link_info
++extern void _bfd_set_link_info (struct bfd_link_info *info);
++
++#define bfd_set_force_make_executable _bfd_set_force_make_executable
++extern void _bfd_set_force_make_executable (bfd_boolean force);
++
+ #endif
+diff --git a/include/dis-asm.h b/include/dis-asm.h
+index 3670c51..202c511 100644
+--- a/include/dis-asm.h
++++ b/include/dis-asm.h
+@@ -247,6 +247,8 @@ extern int print_insn_sh64 (bfd_vma, disassemble_info *);
+ extern int print_insn_sh64x_media (bfd_vma, disassemble_info *);
+ extern int print_insn_frv (bfd_vma, disassemble_info *);
+ extern int print_insn_iq2000 (bfd_vma, disassemble_info *);
++extern int print_insn_big_nios2 (bfd_vma, disassemble_info *);
++extern int print_insn_little_nios2 (bfd_vma, disassemble_info *);
+
+ extern disassembler_ftype arc_get_disassembler (void *);
+ extern disassembler_ftype cris_get_disassembler (bfd *);
+diff --git a/include/elf/common.h b/include/elf/common.h
+index bf233f6..8c758ca 100644
+--- a/include/elf/common.h
++++ b/include/elf/common.h
+@@ -182,6 +182,8 @@
+ #define EM_IP2K 101 /* Ubicom IP2022 micro controller */
+ #define EM_MSP430 105 /* TI msp430 micro controller */
+
++#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
++
+ /* If it is necessary to assign new unofficial EM_* values, please pick large
+ random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
+ with official or non-GNU unofficial values.
+diff --git a/include/elf/nios2.h b/include/elf/nios2.h
+new file mode 100644
+index 0000000..ef810c5
+--- /dev/null
++++ b/include/elf/nios2.h
+@@ -0,0 +1,65 @@
++/* Altera New Jersey ELF support for BFD
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++/* This file holds definitions specific to the Altera New Jersey ELF ABI. Note
++ that most of this is not actually implemented by BFD. */
++
++#ifndef _ELF_NIOS2_H
++#define _ELF_NIOS2_H
++
++#include "elf/reloc-macros.h"
++
++/* the order of these numbers must match the order in
++ the elf_nios2_howto_table_rel table for the lookup
++ function to work properly */
++
++START_RELOC_NUMBERS (elf_nios2_reloc_type)
++ RELOC_NUMBER (R_NIOS2_NONE, 0)
++ RELOC_NUMBER (R_NIOS2_S16, 1)
++ RELOC_NUMBER (R_NIOS2_U16, 2)
++ RELOC_NUMBER (R_NIOS2_PCREL16, 3)
++ RELOC_NUMBER (R_NIOS2_CALL26, 4)
++ RELOC_NUMBER (R_NIOS2_IMM5, 5)
++ RELOC_NUMBER (R_NIOS2_CACHE_OPX, 6)
++ RELOC_NUMBER (R_NIOS2_IMM6, 7)
++ RELOC_NUMBER (R_NIOS2_IMM8, 8)
++ RELOC_NUMBER (R_NIOS2_HI16, 9)
++ RELOC_NUMBER (R_NIOS2_LO16, 10)
++ RELOC_NUMBER (R_NIOS2_HIADJ16, 11)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_32, 12)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_16, 13)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_8, 14)
++ RELOC_NUMBER (R_NIOS2_GPREL, 15)
++ RELOC_NUMBER (R_NIOS2_GNU_VTINHERIT, 16)
++ RELOC_NUMBER (R_NIOS2_GNU_VTENTRY, 17)
++ RELOC_NUMBER (R_NIOS2_UJMP, 18)
++ RELOC_NUMBER (R_NIOS2_CJMP, 19)
++ RELOC_NUMBER (R_NIOS2_CALLR, 20)
++ RELOC_NUMBER (R_NIOS2_ALIGN, 21)
++ RELOC_NUMBER (R_NIOS2_ILLEGAL, 22)
++END_RELOC_NUMBERS (R_NIOS2_maxext)
++
++/* Processor specific section flags */
++
++/* This is used to mark gp-relative sections */
++#define SHF_NIOS2_GPREL 0x10000000
++
++#endif //_ELF_NIOS2_H
+diff --git a/include/opcode/nios2-isa.h b/include/opcode/nios2-isa.h
+new file mode 100644
+index 0000000..0023880
+--- /dev/null
++++ b/include/opcode/nios2-isa.h
+@@ -0,0 +1,1860 @@
++/*
++ * This file defines Nios II instruction set constants.
++ * To include it in assembly code (.S file), define ALT_ASM_SRC
++ * before including this file.
++ *
++ * This file is automatically generated by gen_isa.pl - do not edit
++ */
++
++#ifndef _NIOS2_ISA_H_
++#define _NIOS2_ISA_H_
++
++/* OP instruction opcode values (index is OP field) */
++#define NUM_OP_INSTS 64
++
++#ifndef ALT_ASM_SRC
++extern const char* op_names[NUM_OP_INSTS];
++#endif /* ALT_ASM_SRC */
++
++/* OPX instruction opcode values (index is OPX field) */
++#define NUM_OPX_INSTS 64
++
++#ifndef ALT_ASM_SRC
++extern const char* opx_names[NUM_OPX_INSTS];
++#endif /* ALT_ASM_SRC */
++
++/* Constants for instruction fields and ISA */
++#define CPU_RESET_EXC_ID 1
++#define DIV_ERROR_EXC_ID 9
++#define DTLB_MISS_EXC_ID 15
++#define DTLB_PERM_EXC_ID 16
++#define FAST_INTR_EXC_ID 3
++#define HBREAK_EXC_ID 0
++#define ITLB_MISS_EXC_ID 13
++#define ITLB_PERM_EXC_ID 14
++#define MISALIGNED_DATA_ADDR_EXC_ID 7
++#define MISALIGNED_TARGET_PC_EXC_ID 8
++#define NMI_EXC_ID 2
++#define NORM_INTR_EXC_ID 4
++#define SBREAK_EXC_ID 6
++#define SLAVE_DATA_ACCESS_ERROR_EXC_ID 18
++#define SLAVE_INST_ACCESS_ERROR_EXC_ID 17
++#define SUPERVISOR_DATA_ADDR_EXC_ID 12
++#define SUPERVISOR_INST_ADDR_EXC_ID 10
++#define SUPERVISOR_INST_EXC_ID 11
++#define TRAP_EXC_ID 5
++#define AT_REGNUM 1
++#define BRETADDR_REGNUM 30
++#define BSTATUS_REG_LSB 2
++#define BSTATUS_REG_MMU_LSB 0
++#define BSTATUS_REG_MMU_MSB 2
++#define BSTATUS_REG_MMU_SZ 3
++#define BSTATUS_REG_MMU_MASK 0x7
++#define BSTATUS_REG_NO_MMU_LSB 0
++#define BSTATUS_REG_NO_MMU_MSB 0
++#define BSTATUS_REG_NO_MMU_SZ 1
++#define BSTATUS_REG_NO_MMU_MASK 0x1
++#define BSTATUS_REG_REGNUM 2
++#define BSTATUS_REG_SZ 3
++#define BSTATUS_REG_MASK 0x7
++#define BT_REGNUM 25
++#define CACHE_MAX_BYTES 65536
++#define CACHE_MAX_LINE_BYTES 32
++#define CACHE_MIN_LINE_BYTES 4
++#define COMPARE_OP_EQ 0x0
++#define COMPARE_OP_GE 0x1
++#define COMPARE_OP_LSB 3
++#define COMPARE_OP_LT 0x2
++#define COMPARE_OP_MSB 4
++#define COMPARE_OP_NE 0x3
++#define COMPARE_OP_SZ 2
++#define COMPARE_OP_MASK 0x3
++#define CPUID_REG_LSB 0
++#define CPUID_REG_MSB 31
++#define CPUID_REG_REGNUM 5
++#define CPUID_REG_SZ 32
++#define CPUID_REG_MASK 0xffffffff
++#define DATAPATH_LOG2_SZ 5
++#define DATAPATH_LOG2_MASK 0x1f
++#define DATAPATH_LSB 0
++#define DATAPATH_MSB 31
++#define DATAPATH_SZ 32
++#define DATAPATH_MASK 0xffffffff
++#define EMPTY_CRST_IW 127034
++#define EMPTY_HBREAK_IW 4040762
++#define EMPTY_INTR_IW 3926074
++#define EMPTY_NOP_IW 100410
++#define EMPTY_RET_IW 4160759866
++#define ERETADDR_REGNUM 29
++#define ESTATUS_REG_LSB 0
++#define ESTATUS_REG_MMU_LSB 0
++#define ESTATUS_REG_MMU_MSB 2
++#define ESTATUS_REG_MMU_SZ 3
++#define ESTATUS_REG_MMU_MASK 0x7
++#define ESTATUS_REG_MSB 2
++#define ESTATUS_REG_NO_MMU_LSB 0
++#define ESTATUS_REG_NO_MMU_MSB 0
++#define ESTATUS_REG_NO_MMU_SZ 1
++#define ESTATUS_REG_NO_MMU_MASK 0x1
++#define ESTATUS_REG_REGNUM 1
++#define ESTATUS_REG_SZ 3
++#define ESTATUS_REG_MASK 0x7
++#define ET_REGNUM 24
++#define EXCEPTION_REG_LSB 0
++#define EXCEPTION_REG_MEA_LSB 0
++#define EXCEPTION_REG_MEA_MSB 0
++#define EXCEPTION_REG_MEA_SZ 1
++#define EXCEPTION_REG_MEA_MASK 0x1
++#define EXCEPTION_REG_MEE_LSB 1
++#define EXCEPTION_REG_MEE_MSB 1
++#define EXCEPTION_REG_MEE_SZ 1
++#define EXCEPTION_REG_MEE_MASK 0x1
++#define EXCEPTION_REG_MSB 1
++#define EXCEPTION_REG_REGNUM 7
++#define EXCEPTION_REG_SZ 2
++#define EXCEPTION_REG_MASK 0x3
++#define FP_REGNUM 28
++#define FSTATUS_REG_REGNUM 11
++#define GP_REGNUM 26
++#define IENABLE_REG_LSB 0
++#define IENABLE_REG_MSB 31
++#define IENABLE_REG_REGNUM 3
++#define IENABLE_REG_SZ 32
++#define IENABLE_REG_MASK 0xffffffff
++#define IPENDING_REG_LSB 0
++#define IPENDING_REG_MSB 31
++#define IPENDING_REG_REGNUM 4
++#define IPENDING_REG_SZ 32
++#define IPENDING_REG_MASK 0xffffffff
++#define IW_A_LSB 27
++#define IW_A_MSB 31
++#define IW_A_SZ 5
++#define IW_A_MASK 0x1f
++#define IW_B_LSB 22
++#define IW_B_MSB 26
++#define IW_B_SZ 5
++#define IW_B_MASK 0x1f
++#define IW_C_LSB 17
++#define IW_C_MSB 21
++#define IW_C_SZ 5
++#define IW_C_MASK 0x1f
++#define IW_CONTROL_REGNUM_BASE 0
++#define IW_CONTROL_REGNUM_LSB 6
++#define IW_CONTROL_REGNUM_MSB 9
++#define IW_CONTROL_REGNUM_SZ 4
++#define IW_CONTROL_REGNUM_MASK 0xf
++#define IW_CUSTOM_N_LSB 6
++#define IW_CUSTOM_N_MSB 13
++#define IW_CUSTOM_N_SZ 8
++#define IW_CUSTOM_N_MASK 0xff
++#define IW_CUSTOM_READRA_LSB 16
++#define IW_CUSTOM_READRA_MSB 16
++#define IW_CUSTOM_READRA_SZ 1
++#define IW_CUSTOM_READRA_MASK 0x1
++#define IW_CUSTOM_READRB_LSB 15
++#define IW_CUSTOM_READRB_MSB 15
++#define IW_CUSTOM_READRB_SZ 1
++#define IW_CUSTOM_READRB_MASK 0x1
++#define IW_CUSTOM_WRITERC_LSB 14
++#define IW_CUSTOM_WRITERC_MSB 14
++#define IW_CUSTOM_WRITERC_SZ 1
++#define IW_CUSTOM_WRITERC_MASK 0x1
++#define IW_IMM16_LSB 6
++#define IW_IMM16_MSB 21
++#define IW_IMM16_SZ 16
++#define IW_IMM16_MASK 0xffff
++#define IW_IMM26_LSB 6
++#define IW_IMM26_MSB 31
++#define IW_IMM26_SZ 26
++#define IW_IMM26_MASK 0x3ffffff
++#define IW_MEMSZ_BYTE 0x0
++#define IW_MEMSZ_HWORD 0x1
++#define IW_MEMSZ_LSB 3
++#define IW_MEMSZ_MSB 4
++#define IW_MEMSZ_SZ 2
++#define IW_MEMSZ_MASK 0x3
++#define IW_MEMSZ_WORD 0x2
++#define IW_MEMSZ_WORD_MSB 0x1
++#define IW_OP_LSB 0
++#define IW_OP_MSB 5
++#define IW_OP_SZ 6
++#define IW_OP_MASK 0x3f
++#define IW_OPX_LSB 11
++#define IW_OPX_MSB 16
++#define IW_OPX_SZ 6
++#define IW_OPX_MASK 0x3f
++#define IW_SHIFT_IMM5_LSB 6
++#define IW_SHIFT_IMM5_MSB 10
++#define IW_SHIFT_IMM5_SZ 5
++#define IW_SHIFT_IMM5_MASK 0x1f
++#define IW_SZ 32
++#define IW_MASK 0xffffffff
++#define IW_TRAP_BREAK_IMM5_LSB 6
++#define IW_TRAP_BREAK_IMM5_MSB 10
++#define IW_TRAP_BREAK_IMM5_SZ 5
++#define IW_TRAP_BREAK_IMM5_MASK 0x1f
++#define JMP_CALLR_VS_RET_IS_RET 0
++#define JMP_CALLR_VS_RET_OPX_BIT 3
++#define LOGIC_OP_AND 0x1
++#define LOGIC_OP_LSB 3
++#define LOGIC_OP_MSB 4
++#define LOGIC_OP_NOR 0x0
++#define LOGIC_OP_OR 0x2
++#define LOGIC_OP_SZ 2
++#define LOGIC_OP_MASK 0x3
++#define LOGIC_OP_XOR 0x3
++#define MMU_ADDR_BYPASS_TLB 0x3
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE 0x0
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB 29
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_MSB 29
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_SZ 1
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK 0x1
++#define MMU_ADDR_BYPASS_TLB_LSB 30
++#define MMU_ADDR_BYPASS_TLB_MSB 31
++#define MMU_ADDR_BYPASS_TLB_PADDR_LSB 0
++#define MMU_ADDR_BYPASS_TLB_PADDR_MSB 28
++#define MMU_ADDR_BYPASS_TLB_PADDR_SZ 29
++#define MMU_ADDR_BYPASS_TLB_PADDR_MASK 0x1fffffff
++#define MMU_ADDR_BYPASS_TLB_SZ 2
++#define MMU_ADDR_BYPASS_TLB_MASK 0x3
++#define MMU_ADDR_IO_REGION 0x7
++#define MMU_ADDR_IO_REGION_LSB 29
++#define MMU_ADDR_IO_REGION_MSB 31
++#define MMU_ADDR_IO_REGION_SZ 3
++#define MMU_ADDR_IO_REGION_MASK 0x7
++#define MMU_ADDR_IO_REGION_VPN 0xe0000
++#define MMU_ADDR_KERNEL_MMU_REGION 0x2
++#define MMU_ADDR_KERNEL_MMU_REGION_LSB 30
++#define MMU_ADDR_KERNEL_MMU_REGION_MSB 31
++#define MMU_ADDR_KERNEL_MMU_REGION_SZ 2
++#define MMU_ADDR_KERNEL_MMU_REGION_MASK 0x3
++#define MMU_ADDR_KERNEL_REGION 0x6
++#define MMU_ADDR_KERNEL_REGION_INT 6
++#define MMU_ADDR_KERNEL_REGION_LSB 29
++#define MMU_ADDR_KERNEL_REGION_MSB 31
++#define MMU_ADDR_KERNEL_REGION_SZ 3
++#define MMU_ADDR_KERNEL_REGION_MASK 0x7
++#define MMU_ADDR_PAGE_OFFSET_LSB 0
++#define MMU_ADDR_PAGE_OFFSET_MSB 11
++#define MMU_ADDR_PAGE_OFFSET_SZ 12
++#define MMU_ADDR_PAGE_OFFSET_MASK 0xfff
++#define MMU_ADDR_PFN_LSB 12
++#define MMU_ADDR_PFN_MSB 31
++#define MMU_ADDR_PFN_SZ 20
++#define MMU_ADDR_PFN_MASK 0xfffff
++#define MMU_ADDR_USER_REGION 0x0
++#define MMU_ADDR_USER_REGION_LSB 31
++#define MMU_ADDR_USER_REGION_MSB 31
++#define MMU_ADDR_USER_REGION_SZ 1
++#define MMU_ADDR_USER_REGION_MASK 0x1
++#define MMU_ADDR_VPN_LSB 12
++#define MMU_ADDR_VPN_MSB 31
++#define MMU_ADDR_VPN_SZ 20
++#define MMU_ADDR_VPN_MASK 0xfffff
++#define PTEADDR_REG_LSB 0
++#define PTEADDR_REG_MSB 31
++#define PTEADDR_REG_PTBASE_LSB 22
++#define PTEADDR_REG_PTBASE_MSB 31
++#define PTEADDR_REG_PTBASE_SZ 10
++#define PTEADDR_REG_PTBASE_MASK 0x3ff
++#define PTEADDR_REG_REGNUM 8
++#define PTEADDR_REG_RSV_LSB 0
++#define PTEADDR_REG_RSV_MSB 1
++#define PTEADDR_REG_RSV_SZ 2
++#define PTEADDR_REG_RSV_MASK 0x3
++#define PTEADDR_REG_SZ 32
++#define PTEADDR_REG_MASK 0xffffffff
++#define PTEADDR_REG_VPN_LSB 2
++#define PTEADDR_REG_VPN_MSB 21
++#define PTEADDR_REG_VPN_SZ 20
++#define PTEADDR_REG_VPN_MASK 0xfffff
++#define REGNUM_SZ 5
++#define REGNUM_MASK 0x1f
++#define RETADDR_REGNUM 31
++#define RF_ADDR_SZ 5
++#define RF_ADDR_MASK 0x1f
++#define RF_NUM_REG 32
++#define SIM_REG_LSB 0
++#define SIM_REG_MSB 3
++#define SIM_REG_PERF_CNT_CLR_LSB 2
++#define SIM_REG_PERF_CNT_CLR_MSB 2
++#define SIM_REG_PERF_CNT_CLR_SZ 1
++#define SIM_REG_PERF_CNT_CLR_MASK 0x1
++#define SIM_REG_PERF_CNT_EN_LSB 1
++#define SIM_REG_PERF_CNT_EN_MSB 1
++#define SIM_REG_PERF_CNT_EN_SZ 1
++#define SIM_REG_PERF_CNT_EN_MASK 0x1
++#define SIM_REG_REGNUM 6
++#define SIM_REG_SHOW_DTLB_LSB 4
++#define SIM_REG_SHOW_DTLB_MSB 4
++#define SIM_REG_SHOW_DTLB_SZ 1
++#define SIM_REG_SHOW_DTLB_MASK 0x1
++#define SIM_REG_SHOW_ITLB_LSB 3
++#define SIM_REG_SHOW_ITLB_MSB 3
++#define SIM_REG_SHOW_ITLB_SZ 1
++#define SIM_REG_SHOW_ITLB_MASK 0x1
++#define SIM_REG_SHOW_MMU_REGS_LSB 5
++#define SIM_REG_SHOW_MMU_REGS_MSB 5
++#define SIM_REG_SHOW_MMU_REGS_SZ 1
++#define SIM_REG_SHOW_MMU_REGS_MASK 0x1
++#define SIM_REG_STOP_LSB 0
++#define SIM_REG_STOP_MSB 0
++#define SIM_REG_STOP_SZ 1
++#define SIM_REG_STOP_MASK 0x1
++#define SIM_REG_SZ 4
++#define SIM_REG_MASK 0xf
++#define SP_REGNUM 27
++#define STATUS_REG_EH_LSB 2
++#define STATUS_REG_EH_MSB 2
++#define STATUS_REG_EH_SZ 1
++#define STATUS_REG_EH_MASK 0x1
++#define STATUS_REG_LSB 0
++#define STATUS_REG_MMU_LSB 0
++#define STATUS_REG_MMU_MSB 2
++#define STATUS_REG_MMU_RSV_LSB 3
++#define STATUS_REG_MMU_RSV_MSB 31
++#define STATUS_REG_MMU_RSV_SZ 29
++#define STATUS_REG_MMU_RSV_MASK 0x1fffffff
++#define STATUS_REG_MMU_SZ 3
++#define STATUS_REG_MMU_MASK 0x7
++#define STATUS_REG_MSB 2
++#define STATUS_REG_NO_MMU_LSB 0
++#define STATUS_REG_NO_MMU_MSB 0
++#define STATUS_REG_NO_MMU_RSV_LSB 1
++#define STATUS_REG_NO_MMU_RSV_MSB 31
++#define STATUS_REG_NO_MMU_RSV_SZ 31
++#define STATUS_REG_NO_MMU_RSV_MASK 0x7fffffff
++#define STATUS_REG_NO_MMU_SZ 1
++#define STATUS_REG_NO_MMU_MASK 0x1
++#define STATUS_REG_PIE_LSB 0
++#define STATUS_REG_PIE_MSB 0
++#define STATUS_REG_PIE_SZ 1
++#define STATUS_REG_PIE_MASK 0x1
++#define STATUS_REG_REGNUM 0
++#define STATUS_REG_SZ 3
++#define STATUS_REG_MASK 0x7
++#define STATUS_REG_U_LSB 1
++#define STATUS_REG_U_MSB 1
++#define STATUS_REG_U_SZ 1
++#define STATUS_REG_U_MASK 0x1
++#define TLB_MAX_ENTRIES 1024
++#define TLB_MAX_LINES 512
++#define TLB_MAX_PID_SZ 14
++#define TLB_MAX_PID_MASK 0x3fff
++#define TLB_MAX_PTR_SZ 10
++#define TLB_MAX_PTR_MASK 0x3ff
++#define TLB_MAX_WAYS 8
++#define TLB_MIN_PID_SZ 1
++#define TLB_MIN_PID_MASK 0x1
++#define TLB_MIN_PTR_SZ 7
++#define TLB_MIN_PTR_MASK 0x7f
++#define TLB_MIN_WAYS 2
++#define TLBACC_REG_C_LSB 24
++#define TLBACC_REG_C_MSB 24
++#define TLBACC_REG_C_SZ 1
++#define TLBACC_REG_C_MASK 0x1
++#define TLBACC_REG_G_LSB 20
++#define TLBACC_REG_G_MSB 20
++#define TLBACC_REG_G_SZ 1
++#define TLBACC_REG_G_MASK 0x1
++#define TLBACC_REG_IG_LSB 25
++#define TLBACC_REG_IG_MSB 31
++#define TLBACC_REG_IG_SZ 7
++#define TLBACC_REG_IG_MASK 0x7f
++#define TLBACC_REG_LSB 0
++#define TLBACC_REG_MSB 24
++#define TLBACC_REG_PFN_LSB 0
++#define TLBACC_REG_PFN_MSB 19
++#define TLBACC_REG_PFN_SZ 20
++#define TLBACC_REG_PFN_MASK 0xfffff
++#define TLBACC_REG_R_LSB 23
++#define TLBACC_REG_R_MSB 23
++#define TLBACC_REG_R_SZ 1
++#define TLBACC_REG_R_MASK 0x1
++#define TLBACC_REG_REGNUM 9
++#define TLBACC_REG_SZ 25
++#define TLBACC_REG_MASK 0x1ffffff
++#define TLBACC_REG_W_LSB 22
++#define TLBACC_REG_W_MSB 22
++#define TLBACC_REG_W_SZ 1
++#define TLBACC_REG_W_MASK 0x1
++#define TLBACC_REG_X_LSB 21
++#define TLBACC_REG_X_MSB 21
++#define TLBACC_REG_X_SZ 1
++#define TLBACC_REG_X_MASK 0x1
++#define TLBMISC_REG_BAD_LSB 2
++#define TLBMISC_REG_BAD_MSB 2
++#define TLBMISC_REG_BAD_SZ 1
++#define TLBMISC_REG_BAD_MASK 0x1
++#define TLBMISC_REG_D_LSB 0
++#define TLBMISC_REG_D_MSB 0
++#define TLBMISC_REG_D_SZ 1
++#define TLBMISC_REG_D_MASK 0x1
++#define TLBMISC_REG_DBL_LSB 3
++#define TLBMISC_REG_DBL_MSB 3
++#define TLBMISC_REG_DBL_SZ 1
++#define TLBMISC_REG_DBL_MASK 0x1
++#define TLBMISC_REG_LSB 0
++#define TLBMISC_REG_MSB 23
++#define TLBMISC_REG_PERM_LSB 1
++#define TLBMISC_REG_PERM_MSB 1
++#define TLBMISC_REG_PERM_SZ 1
++#define TLBMISC_REG_PERM_MASK 0x1
++#define TLBMISC_REG_PID_LSB 4
++#define TLBMISC_REG_PID_MSB 17
++#define TLBMISC_REG_PID_SZ 14
++#define TLBMISC_REG_PID_MASK 0x3fff
++#define TLBMISC_REG_RD_LSB 24
++#define TLBMISC_REG_RD_MSB 24
++#define TLBMISC_REG_RD_SZ 1
++#define TLBMISC_REG_RD_MASK 0x1
++#define TLBMISC_REG_REGNUM 10
++#define TLBMISC_REG_RSV0_LSB 18
++#define TLBMISC_REG_RSV0_MSB 19
++#define TLBMISC_REG_RSV0_SZ 2
++#define TLBMISC_REG_RSV0_MASK 0x3
++#define TLBMISC_REG_RSV1_LSB 25
++#define TLBMISC_REG_RSV1_MSB 31
++#define TLBMISC_REG_RSV1_SZ 7
++#define TLBMISC_REG_RSV1_MASK 0x7f
++#define TLBMISC_REG_SZ 24
++#define TLBMISC_REG_MASK 0xffffff
++#define TLBMISC_REG_WAY_LSB 20
++#define TLBMISC_REG_WAY_MSB 22
++#define TLBMISC_REG_WAY_SZ 3
++#define TLBMISC_REG_WAY_MASK 0x7
++#define TLBMISC_REG_WE_LSB 23
++#define TLBMISC_REG_WE_MSB 23
++#define TLBMISC_REG_WE_SZ 1
++#define TLBMISC_REG_WE_MASK 0x1
++
++/* Macros to extract instruction fields */
++#define GET_IW_A(Iw) \
++ (((Iw) >> IW_A_LSB) & IW_A_MASK)
++#define SET_IW_A(Iw, Val) \
++ Iw = (((Iw) & (~(IW_A_MASK << IW_A_LSB))) | \
++ (((Val) & IW_A_MASK) << IW_A_LSB))
++#define GET_IW_B(Iw) \
++ (((Iw) >> IW_B_LSB) & IW_B_MASK)
++#define SET_IW_B(Iw, Val) \
++ Iw = (((Iw) & (~(IW_B_MASK << IW_B_LSB))) | \
++ (((Val) & IW_B_MASK) << IW_B_LSB))
++#define GET_IW_C(Iw) \
++ (((Iw) >> IW_C_LSB) & IW_C_MASK)
++#define SET_IW_C(Iw, Val) \
++ Iw = (((Iw) & (~(IW_C_MASK << IW_C_LSB))) | \
++ (((Val) & IW_C_MASK) << IW_C_LSB))
++#define GET_IW_CONTROL_REGNUM(Iw) \
++ (((Iw) >> IW_CONTROL_REGNUM_LSB) & IW_CONTROL_REGNUM_MASK)
++#define SET_IW_CONTROL_REGNUM(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CONTROL_REGNUM_MASK << IW_CONTROL_REGNUM_LSB))) | \
++ (((Val) & IW_CONTROL_REGNUM_MASK) << IW_CONTROL_REGNUM_LSB))
++#define GET_IW_CUSTOM_N(Iw) \
++ (((Iw) >> IW_CUSTOM_N_LSB) & IW_CUSTOM_N_MASK)
++#define SET_IW_CUSTOM_N(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_N_MASK << IW_CUSTOM_N_LSB))) | \
++ (((Val) & IW_CUSTOM_N_MASK) << IW_CUSTOM_N_LSB))
++#define GET_IW_CUSTOM_READRA(Iw) \
++ (((Iw) >> IW_CUSTOM_READRA_LSB) & IW_CUSTOM_READRA_MASK)
++#define SET_IW_CUSTOM_READRA(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_READRA_MASK << IW_CUSTOM_READRA_LSB))) | \
++ (((Val) & IW_CUSTOM_READRA_MASK) << IW_CUSTOM_READRA_LSB))
++#define GET_IW_CUSTOM_READRB(Iw) \
++ (((Iw) >> IW_CUSTOM_READRB_LSB) & IW_CUSTOM_READRB_MASK)
++#define SET_IW_CUSTOM_READRB(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_READRB_MASK << IW_CUSTOM_READRB_LSB))) | \
++ (((Val) & IW_CUSTOM_READRB_MASK) << IW_CUSTOM_READRB_LSB))
++#define GET_IW_CUSTOM_WRITERC(Iw) \
++ (((Iw) >> IW_CUSTOM_WRITERC_LSB) & IW_CUSTOM_WRITERC_MASK)
++#define SET_IW_CUSTOM_WRITERC(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_WRITERC_MASK << IW_CUSTOM_WRITERC_LSB))) | \
++ (((Val) & IW_CUSTOM_WRITERC_MASK) << IW_CUSTOM_WRITERC_LSB))
++#define GET_IW_IMM16(Iw) \
++ (((Iw) >> IW_IMM16_LSB) & IW_IMM16_MASK)
++#define SET_IW_IMM16(Iw, Val) \
++ Iw = (((Iw) & (~(IW_IMM16_MASK << IW_IMM16_LSB))) | \
++ (((Val) & IW_IMM16_MASK) << IW_IMM16_LSB))
++#define GET_IW_IMM26(Iw) \
++ (((Iw) >> IW_IMM26_LSB) & IW_IMM26_MASK)
++#define SET_IW_IMM26(Iw, Val) \
++ Iw = (((Iw) & (~(IW_IMM26_MASK << IW_IMM26_LSB))) | \
++ (((Val) & IW_IMM26_MASK) << IW_IMM26_LSB))
++#define GET_IW_MEMSZ(Iw) \
++ (((Iw) >> IW_MEMSZ_LSB) & IW_MEMSZ_MASK)
++#define SET_IW_MEMSZ(Iw, Val) \
++ Iw = (((Iw) & (~(IW_MEMSZ_MASK << IW_MEMSZ_LSB))) | \
++ (((Val) & IW_MEMSZ_MASK) << IW_MEMSZ_LSB))
++#define GET_IW_OP(Iw) \
++ (((Iw) >> IW_OP_LSB) & IW_OP_MASK)
++#define SET_IW_OP(Iw, Val) \
++ Iw = (((Iw) & (~(IW_OP_MASK << IW_OP_LSB))) | \
++ (((Val) & IW_OP_MASK) << IW_OP_LSB))
++#define GET_IW_OPX(Iw) \
++ (((Iw) >> IW_OPX_LSB) & IW_OPX_MASK)
++#define SET_IW_OPX(Iw, Val) \
++ Iw = (((Iw) & (~(IW_OPX_MASK << IW_OPX_LSB))) | \
++ (((Val) & IW_OPX_MASK) << IW_OPX_LSB))
++#define GET_IW_SHIFT_IMM5(Iw) \
++ (((Iw) >> IW_SHIFT_IMM5_LSB) & IW_SHIFT_IMM5_MASK)
++#define SET_IW_SHIFT_IMM5(Iw, Val) \
++ Iw = (((Iw) & (~(IW_SHIFT_IMM5_MASK << IW_SHIFT_IMM5_LSB))) | \
++ (((Val) & IW_SHIFT_IMM5_MASK) << IW_SHIFT_IMM5_LSB))
++#define GET_IW_TRAP_BREAK_IMM5(Iw) \
++ (((Iw) >> IW_TRAP_BREAK_IMM5_LSB) & IW_TRAP_BREAK_IMM5_MASK)
++#define SET_IW_TRAP_BREAK_IMM5(Iw, Val) \
++ Iw = (((Iw) & (~(IW_TRAP_BREAK_IMM5_MASK << IW_TRAP_BREAK_IMM5_LSB))) | \
++ (((Val) & IW_TRAP_BREAK_IMM5_MASK) << IW_TRAP_BREAK_IMM5_LSB))
++
++/* Macros to extract control register fields */
++#define GET_BSTATUS_REG_MMU(Reg) \
++ (((Reg) >> BSTATUS_REG_MMU_LSB) & BSTATUS_REG_MMU_MASK)
++#define SET_BSTATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(BSTATUS_REG_MMU_MASK << BSTATUS_REG_MMU_LSB))) | \
++ (((Val) & BSTATUS_REG_MMU_MASK) << BSTATUS_REG_MMU_LSB))
++#define GET_BSTATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> BSTATUS_REG_NO_MMU_LSB) & BSTATUS_REG_NO_MMU_MASK)
++#define SET_BSTATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(BSTATUS_REG_NO_MMU_MASK << BSTATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & BSTATUS_REG_NO_MMU_MASK) << BSTATUS_REG_NO_MMU_LSB))
++#define GET_ESTATUS_REG_MMU(Reg) \
++ (((Reg) >> ESTATUS_REG_MMU_LSB) & ESTATUS_REG_MMU_MASK)
++#define SET_ESTATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(ESTATUS_REG_MMU_MASK << ESTATUS_REG_MMU_LSB))) | \
++ (((Val) & ESTATUS_REG_MMU_MASK) << ESTATUS_REG_MMU_LSB))
++#define GET_ESTATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> ESTATUS_REG_NO_MMU_LSB) & ESTATUS_REG_NO_MMU_MASK)
++#define SET_ESTATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(ESTATUS_REG_NO_MMU_MASK << ESTATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & ESTATUS_REG_NO_MMU_MASK) << ESTATUS_REG_NO_MMU_LSB))
++#define GET_EXCEPTION_REG_MEA(Reg) \
++ (((Reg) >> EXCEPTION_REG_MEA_LSB) & EXCEPTION_REG_MEA_MASK)
++#define SET_EXCEPTION_REG_MEA(Reg, Val) \
++ Reg = (((Reg) & (~(EXCEPTION_REG_MEA_MASK << EXCEPTION_REG_MEA_LSB))) | \
++ (((Val) & EXCEPTION_REG_MEA_MASK) << EXCEPTION_REG_MEA_LSB))
++#define GET_EXCEPTION_REG_MEE(Reg) \
++ (((Reg) >> EXCEPTION_REG_MEE_LSB) & EXCEPTION_REG_MEE_MASK)
++#define SET_EXCEPTION_REG_MEE(Reg, Val) \
++ Reg = (((Reg) & (~(EXCEPTION_REG_MEE_MASK << EXCEPTION_REG_MEE_LSB))) | \
++ (((Val) & EXCEPTION_REG_MEE_MASK) << EXCEPTION_REG_MEE_LSB))
++#define GET_PTEADDR_REG_PTBASE(Reg) \
++ (((Reg) >> PTEADDR_REG_PTBASE_LSB) & PTEADDR_REG_PTBASE_MASK)
++#define SET_PTEADDR_REG_PTBASE(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_PTBASE_MASK << PTEADDR_REG_PTBASE_LSB))) | \
++ (((Val) & PTEADDR_REG_PTBASE_MASK) << PTEADDR_REG_PTBASE_LSB))
++#define GET_PTEADDR_REG_RSV(Reg) \
++ (((Reg) >> PTEADDR_REG_RSV_LSB) & PTEADDR_REG_RSV_MASK)
++#define SET_PTEADDR_REG_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_RSV_MASK << PTEADDR_REG_RSV_LSB))) | \
++ (((Val) & PTEADDR_REG_RSV_MASK) << PTEADDR_REG_RSV_LSB))
++#define GET_PTEADDR_REG_VPN(Reg) \
++ (((Reg) >> PTEADDR_REG_VPN_LSB) & PTEADDR_REG_VPN_MASK)
++#define SET_PTEADDR_REG_VPN(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_VPN_MASK << PTEADDR_REG_VPN_LSB))) | \
++ (((Val) & PTEADDR_REG_VPN_MASK) << PTEADDR_REG_VPN_LSB))
++#define GET_SIM_REG_PERF_CNT_CLR(Reg) \
++ (((Reg) >> SIM_REG_PERF_CNT_CLR_LSB) & SIM_REG_PERF_CNT_CLR_MASK)
++#define SET_SIM_REG_PERF_CNT_CLR(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_PERF_CNT_CLR_MASK << SIM_REG_PERF_CNT_CLR_LSB))) | \
++ (((Val) & SIM_REG_PERF_CNT_CLR_MASK) << SIM_REG_PERF_CNT_CLR_LSB))
++#define GET_SIM_REG_PERF_CNT_EN(Reg) \
++ (((Reg) >> SIM_REG_PERF_CNT_EN_LSB) & SIM_REG_PERF_CNT_EN_MASK)
++#define SET_SIM_REG_PERF_CNT_EN(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_PERF_CNT_EN_MASK << SIM_REG_PERF_CNT_EN_LSB))) | \
++ (((Val) & SIM_REG_PERF_CNT_EN_MASK) << SIM_REG_PERF_CNT_EN_LSB))
++#define GET_SIM_REG_SHOW_DTLB(Reg) \
++ (((Reg) >> SIM_REG_SHOW_DTLB_LSB) & SIM_REG_SHOW_DTLB_MASK)
++#define SET_SIM_REG_SHOW_DTLB(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_DTLB_MASK << SIM_REG_SHOW_DTLB_LSB))) | \
++ (((Val) & SIM_REG_SHOW_DTLB_MASK) << SIM_REG_SHOW_DTLB_LSB))
++#define GET_SIM_REG_SHOW_ITLB(Reg) \
++ (((Reg) >> SIM_REG_SHOW_ITLB_LSB) & SIM_REG_SHOW_ITLB_MASK)
++#define SET_SIM_REG_SHOW_ITLB(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_ITLB_MASK << SIM_REG_SHOW_ITLB_LSB))) | \
++ (((Val) & SIM_REG_SHOW_ITLB_MASK) << SIM_REG_SHOW_ITLB_LSB))
++#define GET_SIM_REG_SHOW_MMU_REGS(Reg) \
++ (((Reg) >> SIM_REG_SHOW_MMU_REGS_LSB) & SIM_REG_SHOW_MMU_REGS_MASK)
++#define SET_SIM_REG_SHOW_MMU_REGS(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_MMU_REGS_MASK << SIM_REG_SHOW_MMU_REGS_LSB))) | \
++ (((Val) & SIM_REG_SHOW_MMU_REGS_MASK) << SIM_REG_SHOW_MMU_REGS_LSB))
++#define GET_SIM_REG_STOP(Reg) \
++ (((Reg) >> SIM_REG_STOP_LSB) & SIM_REG_STOP_MASK)
++#define SET_SIM_REG_STOP(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_STOP_MASK << SIM_REG_STOP_LSB))) | \
++ (((Val) & SIM_REG_STOP_MASK) << SIM_REG_STOP_LSB))
++#define GET_STATUS_REG_EH(Reg) \
++ (((Reg) >> STATUS_REG_EH_LSB) & STATUS_REG_EH_MASK)
++#define SET_STATUS_REG_EH(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_EH_MASK << STATUS_REG_EH_LSB))) | \
++ (((Val) & STATUS_REG_EH_MASK) << STATUS_REG_EH_LSB))
++#define GET_STATUS_REG_MMU(Reg) \
++ (((Reg) >> STATUS_REG_MMU_LSB) & STATUS_REG_MMU_MASK)
++#define SET_STATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_MMU_MASK << STATUS_REG_MMU_LSB))) | \
++ (((Val) & STATUS_REG_MMU_MASK) << STATUS_REG_MMU_LSB))
++#define GET_STATUS_REG_MMU_RSV(Reg) \
++ (((Reg) >> STATUS_REG_MMU_RSV_LSB) & STATUS_REG_MMU_RSV_MASK)
++#define SET_STATUS_REG_MMU_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_MMU_RSV_MASK << STATUS_REG_MMU_RSV_LSB))) | \
++ (((Val) & STATUS_REG_MMU_RSV_MASK) << STATUS_REG_MMU_RSV_LSB))
++#define GET_STATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> STATUS_REG_NO_MMU_LSB) & STATUS_REG_NO_MMU_MASK)
++#define SET_STATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_NO_MMU_MASK << STATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & STATUS_REG_NO_MMU_MASK) << STATUS_REG_NO_MMU_LSB))
++#define GET_STATUS_REG_NO_MMU_RSV(Reg) \
++ (((Reg) >> STATUS_REG_NO_MMU_RSV_LSB) & STATUS_REG_NO_MMU_RSV_MASK)
++#define SET_STATUS_REG_NO_MMU_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_NO_MMU_RSV_MASK << STATUS_REG_NO_MMU_RSV_LSB))) | \
++ (((Val) & STATUS_REG_NO_MMU_RSV_MASK) << STATUS_REG_NO_MMU_RSV_LSB))
++#define GET_STATUS_REG_PIE(Reg) \
++ (((Reg) >> STATUS_REG_PIE_LSB) & STATUS_REG_PIE_MASK)
++#define SET_STATUS_REG_PIE(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_PIE_MASK << STATUS_REG_PIE_LSB))) | \
++ (((Val) & STATUS_REG_PIE_MASK) << STATUS_REG_PIE_LSB))
++#define GET_STATUS_REG_U(Reg) \
++ (((Reg) >> STATUS_REG_U_LSB) & STATUS_REG_U_MASK)
++#define SET_STATUS_REG_U(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_U_MASK << STATUS_REG_U_LSB))) | \
++ (((Val) & STATUS_REG_U_MASK) << STATUS_REG_U_LSB))
++#define GET_TLBACC_REG_C(Reg) \
++ (((Reg) >> TLBACC_REG_C_LSB) & TLBACC_REG_C_MASK)
++#define SET_TLBACC_REG_C(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_C_MASK << TLBACC_REG_C_LSB))) | \
++ (((Val) & TLBACC_REG_C_MASK) << TLBACC_REG_C_LSB))
++#define GET_TLBACC_REG_G(Reg) \
++ (((Reg) >> TLBACC_REG_G_LSB) & TLBACC_REG_G_MASK)
++#define SET_TLBACC_REG_G(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_G_MASK << TLBACC_REG_G_LSB))) | \
++ (((Val) & TLBACC_REG_G_MASK) << TLBACC_REG_G_LSB))
++#define GET_TLBACC_REG_IG(Reg) \
++ (((Reg) >> TLBACC_REG_IG_LSB) & TLBACC_REG_IG_MASK)
++#define SET_TLBACC_REG_IG(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_IG_MASK << TLBACC_REG_IG_LSB))) | \
++ (((Val) & TLBACC_REG_IG_MASK) << TLBACC_REG_IG_LSB))
++#define GET_TLBACC_REG_PFN(Reg) \
++ (((Reg) >> TLBACC_REG_PFN_LSB) & TLBACC_REG_PFN_MASK)
++#define SET_TLBACC_REG_PFN(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_PFN_MASK << TLBACC_REG_PFN_LSB))) | \
++ (((Val) & TLBACC_REG_PFN_MASK) << TLBACC_REG_PFN_LSB))
++#define GET_TLBACC_REG_R(Reg) \
++ (((Reg) >> TLBACC_REG_R_LSB) & TLBACC_REG_R_MASK)
++#define SET_TLBACC_REG_R(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_R_MASK << TLBACC_REG_R_LSB))) | \
++ (((Val) & TLBACC_REG_R_MASK) << TLBACC_REG_R_LSB))
++#define GET_TLBACC_REG_W(Reg) \
++ (((Reg) >> TLBACC_REG_W_LSB) & TLBACC_REG_W_MASK)
++#define SET_TLBACC_REG_W(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_W_MASK << TLBACC_REG_W_LSB))) | \
++ (((Val) & TLBACC_REG_W_MASK) << TLBACC_REG_W_LSB))
++#define GET_TLBACC_REG_X(Reg) \
++ (((Reg) >> TLBACC_REG_X_LSB) & TLBACC_REG_X_MASK)
++#define SET_TLBACC_REG_X(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_X_MASK << TLBACC_REG_X_LSB))) | \
++ (((Val) & TLBACC_REG_X_MASK) << TLBACC_REG_X_LSB))
++#define GET_TLBMISC_REG_BAD(Reg) \
++ (((Reg) >> TLBMISC_REG_BAD_LSB) & TLBMISC_REG_BAD_MASK)
++#define SET_TLBMISC_REG_BAD(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_BAD_MASK << TLBMISC_REG_BAD_LSB))) | \
++ (((Val) & TLBMISC_REG_BAD_MASK) << TLBMISC_REG_BAD_LSB))
++#define GET_TLBMISC_REG_D(Reg) \
++ (((Reg) >> TLBMISC_REG_D_LSB) & TLBMISC_REG_D_MASK)
++#define SET_TLBMISC_REG_D(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_D_MASK << TLBMISC_REG_D_LSB))) | \
++ (((Val) & TLBMISC_REG_D_MASK) << TLBMISC_REG_D_LSB))
++#define GET_TLBMISC_REG_DBL(Reg) \
++ (((Reg) >> TLBMISC_REG_DBL_LSB) & TLBMISC_REG_DBL_MASK)
++#define SET_TLBMISC_REG_DBL(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_DBL_MASK << TLBMISC_REG_DBL_LSB))) | \
++ (((Val) & TLBMISC_REG_DBL_MASK) << TLBMISC_REG_DBL_LSB))
++#define GET_TLBMISC_REG_PERM(Reg) \
++ (((Reg) >> TLBMISC_REG_PERM_LSB) & TLBMISC_REG_PERM_MASK)
++#define SET_TLBMISC_REG_PERM(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_PERM_MASK << TLBMISC_REG_PERM_LSB))) | \
++ (((Val) & TLBMISC_REG_PERM_MASK) << TLBMISC_REG_PERM_LSB))
++#define GET_TLBMISC_REG_PID(Reg) \
++ (((Reg) >> TLBMISC_REG_PID_LSB) & TLBMISC_REG_PID_MASK)
++#define SET_TLBMISC_REG_PID(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_PID_MASK << TLBMISC_REG_PID_LSB))) | \
++ (((Val) & TLBMISC_REG_PID_MASK) << TLBMISC_REG_PID_LSB))
++#define GET_TLBMISC_REG_RD(Reg) \
++ (((Reg) >> TLBMISC_REG_RD_LSB) & TLBMISC_REG_RD_MASK)
++#define SET_TLBMISC_REG_RD(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RD_MASK << TLBMISC_REG_RD_LSB))) | \
++ (((Val) & TLBMISC_REG_RD_MASK) << TLBMISC_REG_RD_LSB))
++#define GET_TLBMISC_REG_RSV0(Reg) \
++ (((Reg) >> TLBMISC_REG_RSV0_LSB) & TLBMISC_REG_RSV0_MASK)
++#define SET_TLBMISC_REG_RSV0(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RSV0_MASK << TLBMISC_REG_RSV0_LSB))) | \
++ (((Val) & TLBMISC_REG_RSV0_MASK) << TLBMISC_REG_RSV0_LSB))
++#define GET_TLBMISC_REG_RSV1(Reg) \
++ (((Reg) >> TLBMISC_REG_RSV1_LSB) & TLBMISC_REG_RSV1_MASK)
++#define SET_TLBMISC_REG_RSV1(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RSV1_MASK << TLBMISC_REG_RSV1_LSB))) | \
++ (((Val) & TLBMISC_REG_RSV1_MASK) << TLBMISC_REG_RSV1_LSB))
++#define GET_TLBMISC_REG_WAY(Reg) \
++ (((Reg) >> TLBMISC_REG_WAY_LSB) & TLBMISC_REG_WAY_MASK)
++#define SET_TLBMISC_REG_WAY(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_WAY_MASK << TLBMISC_REG_WAY_LSB))) | \
++ (((Val) & TLBMISC_REG_WAY_MASK) << TLBMISC_REG_WAY_LSB))
++#define GET_TLBMISC_REG_WE(Reg) \
++ (((Reg) >> TLBMISC_REG_WE_LSB) & TLBMISC_REG_WE_MASK)
++#define SET_TLBMISC_REG_WE(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_WE_MASK << TLBMISC_REG_WE_LSB))) | \
++ (((Val) & TLBMISC_REG_WE_MASK) << TLBMISC_REG_WE_LSB))
++
++/* Macros to extract MMU fields */
++#define GET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB) & MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK << MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK) << MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB))
++#define GET_MMU_ADDR_BYPASS_TLB(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_LSB) & MMU_ADDR_BYPASS_TLB_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_MASK << MMU_ADDR_BYPASS_TLB_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_MASK) << MMU_ADDR_BYPASS_TLB_LSB))
++#define GET_MMU_ADDR_BYPASS_TLB_PADDR(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_PADDR_LSB) & MMU_ADDR_BYPASS_TLB_PADDR_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB_PADDR(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_PADDR_MASK << MMU_ADDR_BYPASS_TLB_PADDR_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_PADDR_MASK) << MMU_ADDR_BYPASS_TLB_PADDR_LSB))
++#define GET_MMU_ADDR_IO_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_IO_REGION_LSB) & MMU_ADDR_IO_REGION_MASK)
++#define SET_MMU_ADDR_IO_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_IO_REGION_MASK << MMU_ADDR_IO_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_IO_REGION_MASK) << MMU_ADDR_IO_REGION_LSB))
++#define GET_MMU_ADDR_KERNEL_MMU_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_KERNEL_MMU_REGION_LSB) & MMU_ADDR_KERNEL_MMU_REGION_MASK)
++#define SET_MMU_ADDR_KERNEL_MMU_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_KERNEL_MMU_REGION_MASK << MMU_ADDR_KERNEL_MMU_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_KERNEL_MMU_REGION_MASK) << MMU_ADDR_KERNEL_MMU_REGION_LSB))
++#define GET_MMU_ADDR_KERNEL_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_KERNEL_REGION_LSB) & MMU_ADDR_KERNEL_REGION_MASK)
++#define SET_MMU_ADDR_KERNEL_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_KERNEL_REGION_MASK << MMU_ADDR_KERNEL_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_KERNEL_REGION_MASK) << MMU_ADDR_KERNEL_REGION_LSB))
++#define GET_MMU_ADDR_PAGE_OFFSET(Addr) \
++ (((Addr) >> MMU_ADDR_PAGE_OFFSET_LSB) & MMU_ADDR_PAGE_OFFSET_MASK)
++#define SET_MMU_ADDR_PAGE_OFFSET(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_PAGE_OFFSET_MASK << MMU_ADDR_PAGE_OFFSET_LSB))) | \
++ (((Val) & MMU_ADDR_PAGE_OFFSET_MASK) << MMU_ADDR_PAGE_OFFSET_LSB))
++#define GET_MMU_ADDR_PFN(Addr) \
++ (((Addr) >> MMU_ADDR_PFN_LSB) & MMU_ADDR_PFN_MASK)
++#define SET_MMU_ADDR_PFN(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_PFN_MASK << MMU_ADDR_PFN_LSB))) | \
++ (((Val) & MMU_ADDR_PFN_MASK) << MMU_ADDR_PFN_LSB))
++#define GET_MMU_ADDR_USER_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_USER_REGION_LSB) & MMU_ADDR_USER_REGION_MASK)
++#define SET_MMU_ADDR_USER_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_USER_REGION_MASK << MMU_ADDR_USER_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_USER_REGION_MASK) << MMU_ADDR_USER_REGION_LSB))
++#define GET_MMU_ADDR_VPN(Addr) \
++ (((Addr) >> MMU_ADDR_VPN_LSB) & MMU_ADDR_VPN_MASK)
++#define SET_MMU_ADDR_VPN(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_VPN_MASK << MMU_ADDR_VPN_LSB))) | \
++ (((Val) & MMU_ADDR_VPN_MASK) << MMU_ADDR_VPN_LSB))
++
++/* OP instruction values */
++#define OP_ADDI 4
++#define OP_ANDHI 44
++#define OP_ANDI 12
++#define OP_BEQ 38
++#define OP_BGE 14
++#define OP_BGEU 46
++#define OP_BLT 22
++#define OP_BLTU 54
++#define OP_BNE 30
++#define OP_BR 6
++#define OP_CALL 0
++#define OP_CMPEQI 32
++#define OP_CMPGEI 8
++#define OP_CMPGEUI 40
++#define OP_CMPLTI 16
++#define OP_CMPLTUI 48
++#define OP_CMPNEI 24
++#define OP_CUSTOM 50
++#define OP_FLUSHD 59
++#define OP_FLUSHDA 27
++#define OP_INITD 51
++#define OP_JMPI 1
++#define OP_LDB 7
++#define OP_LDBIO 39
++#define OP_LDBU 3
++#define OP_LDBUIO 35
++#define OP_LDH 15
++#define OP_LDHIO 47
++#define OP_LDHU 11
++#define OP_LDHUIO 43
++#define OP_LDW 23
++#define OP_LDWIO 55
++#define OP_MULI 36
++#define OP_OPX 58
++#define OP_ORHI 52
++#define OP_ORI 20
++#define OP_STB 5
++#define OP_STBIO 37
++#define OP_STH 13
++#define OP_STHIO 45
++#define OP_STW 21
++#define OP_STWIO 53
++#define OP_XORHI 60
++#define OP_XORI 28
++
++/* OPX instruction values */
++#define OPX_ADD 49
++#define OPX_AND 14
++#define OPX_BREAK 52
++#define OPX_BRET 9
++#define OPX_CALLR 29
++#define OPX_CMPEQ 32
++#define OPX_CMPGE 8
++#define OPX_CMPGEU 40
++#define OPX_CMPLT 16
++#define OPX_CMPLTU 48
++#define OPX_CMPNE 24
++#define OPX_CRST 62
++#define OPX_DIV 37
++#define OPX_DIVU 36
++#define OPX_ERET 1
++#define OPX_FLUSHI 12
++#define OPX_FLUSHP 4
++#define OPX_HBREAK 53
++#define OPX_INITI 41
++#define OPX_INTR 61
++#define OPX_JMP 13
++#define OPX_MUL 39
++#define OPX_MULXSS 31
++#define OPX_MULXSU 23
++#define OPX_MULXUU 7
++#define OPX_NEXTPC 28
++#define OPX_NOR 6
++#define OPX_OR 22
++#define OPX_RDCTL 38
++#define OPX_RET 5
++#define OPX_ROL 3
++#define OPX_ROLI 2
++#define OPX_ROR 11
++#define OPX_SLL 19
++#define OPX_SLLI 18
++#define OPX_SRA 59
++#define OPX_SRAI 58
++#define OPX_SRL 27
++#define OPX_SRLI 26
++#define OPX_SUB 57
++#define OPX_SYNC 54
++#define OPX_TRAP 45
++#define OPX_WRCTL 46
++#define OPX_XOR 30
++
++/* Macros to detect sub-opcode instructions */
++#define IS_OPX_INST(Iw) (GET_IW_OP(Iw) == OP_OPX)
++#define IS_CUSTOM_INST(Iw) (GET_IW_OP(Iw) == OP_CUSTOM)
++
++/* Instruction property macros */
++#define IW_PROP_RESERVED_OP(Iw) (0)
++
++#define IW_PROP_RESERVED_OPX(Iw) (0)
++
++#define IW_PROP_RESERVED(Iw) (0)
++
++#define IW_PROP_SUPERVISOR_ONLY(Iw) ( \
++ (op_prop_supervisor_only[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_supervisor_only[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_supervisor_only[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_supervisor_only[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_INITI_FLUSHI(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_INITI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_FLUSHI) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSH_PIPE(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_flush_pipe[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_flush_pipe[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_INDIRECT_NON_TRAP(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_jmp_indirect_non_trap[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_jmp_indirect_non_trap[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_INDIRECT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_jmp_indirect[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_jmp_indirect[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_DIRECT(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) || \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_LSW(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_MULI)) || \
++ ((GET_IW_OPX((Iw)) == OPX_MUL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MULX(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_mulx[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mulx[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MUL(Iw) ( \
++ (op_prop_mul[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_mul[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mul[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mul[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DIV_UNSIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIVU) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DIV_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIV) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DIV(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIVU) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_DIV) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_UNIMPLEMENTED(Iw) (0)
++
++#define IW_PROP_IMPLICIT_DST_RETADDR(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) \
++ ) \
++ \
++)
++
++#define IW_PROP_IMPLICIT_DST_ERETADDR(Iw) (0)
++
++#define IW_PROP_EXCEPTION(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_TRAP) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_INTR) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BREAK(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_BREAK) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_HBREAK) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CRST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_CRST) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_WR_CTL_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_wr_ctl_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_wr_ctl_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_UNCOND_CTI_NON_BR(Iw) ( \
++ (op_prop_uncond_cti_non_br[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_uncond_cti_non_br[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_uncond_cti_non_br[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_uncond_cti_non_br[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_RETADDR(Iw) ( \
++ (op_prop_retaddr[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_retaddr[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_retaddr[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_retaddr[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_LEFT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SLLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SLL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_LOGICAL(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_logical[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_logical[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROT_LEFT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_ROLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_ROL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_ROT_LEFT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_left[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_left[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_RIGHT_LOGICAL(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SRLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SRL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_RIGHT_ARITH(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SRAI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SRA) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_RIGHT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_right[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_right[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROT_RIGHT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_ROR) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_ROT_RIGHT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_right[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_right[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_ROT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_ROT_IMM(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_imm[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROTATE(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_rotate[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_rotate[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_logic_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_logic_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_HI_IMM16(Iw) ( \
++ (op_prop_logic_hi_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_hi_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_LO_IMM16(Iw) ( \
++ (op_prop_logic_lo_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_IMM16(Iw) ( \
++ (op_prop_logic_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC(Iw) ( \
++ (op_prop_logic[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_logic[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_logic[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_UNSIGNED_LO_IMM16(Iw) ( \
++ (op_prop_unsigned_lo_imm16[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_unsigned_lo_imm16[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_unsigned_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_unsigned_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ARITH_IMM16(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_ADDI)) || \
++ ((GET_IW_OP((Iw)) == OP_MULI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_IMM16(Iw) ( \
++ (op_prop_cmp_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMPI(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_IMM16_WITH_CALL_JMPI(Iw) ( \
++ (op_prop_cmp_imm16_with_call_jmpi[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_imm16_with_call_jmpi[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC_IMM5(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_src_imm5[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src_imm5[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_LT(Iw) ( \
++ (op_prop_cmp_with_lt[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_lt[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_lt[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_lt[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_EQ(Iw) ( \
++ (op_prop_cmp_with_eq[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_eq[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_GE(Iw) ( \
++ (op_prop_cmp_with_ge[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_ge[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_ge[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_ge[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_NE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CMPNEI)) || \
++ ((GET_IW_OPX((Iw)) == OPX_CMPNE) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_ALU_SIGNED(Iw) ( \
++ (op_prop_cmp_alu_signed[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_alu_signed[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_alu_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_alu_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP(Iw) ( \
++ (op_prop_cmp[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_WITH_LT(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BLT)) || \
++ ((GET_IW_OP((Iw)) == OP_BLTU)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_WITH_GE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BGE)) || \
++ ((GET_IW_OP((Iw)) == OP_BGEU)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_WITH_EQ(Iw) ( \
++ (op_prop_br_with_eq[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_WITH_NE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BNE)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_ALU_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BGE)) || \
++ ((GET_IW_OP((Iw)) == OP_BLT)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_COND(Iw) ( \
++ (op_prop_br_cond[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br_cond[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_UNCOND(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BR)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR(Iw) ( \
++ (op_prop_br[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ALU_SUB(Iw) ( \
++ (op_prop_alu_sub[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_alu_sub[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_alu_sub[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_alu_sub[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_FORCE_XOR(Iw) ( \
++ (op_prop_force_xor[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_force_xor[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_force_xor[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_force_xor[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD8(Iw) ( \
++ (op_prop_load8[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load8[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD16(Iw) ( \
++ (op_prop_load16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD32(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_LDW)) || \
++ ((GET_IW_OP((Iw)) == OP_LDWIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_LOAD_SIGNED(Iw) ( \
++ (op_prop_load_signed[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_UNSIGNED(Iw) ( \
++ (op_prop_load_unsigned[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_unsigned[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD(Iw) ( \
++ (op_prop_load[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_INITD_FLUSHD_FLUSHDA(Iw) ( \
++ (op_prop_load_initd_flushd_flushda[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_initd_flushd_flushda[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_NON_IO(Iw) ( \
++ (op_prop_load_non_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_non_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE8(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STB)) || \
++ ((GET_IW_OP((Iw)) == OP_STBIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE16(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STH)) || \
++ ((GET_IW_OP((Iw)) == OP_STHIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE32(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STW)) || \
++ ((GET_IW_OP((Iw)) == OP_STWIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE(Iw) ( \
++ (op_prop_store[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE_NON_IO(Iw) ( \
++ (op_prop_store_non_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store_non_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MEM(Iw) ( \
++ (op_prop_mem[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mem[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_INITD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_INITD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_INITD_FLUSHD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_INITD)) || \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHDA(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHDA)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHD_FLUSHDA(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) || \
++ ((GET_IW_OP((Iw)) == OP_FLUSHDA)) \
++ ) \
++ \
++)
++
++#define IW_PROP_INITD_FLUSHD_FLUSHDA(Iw) ( \
++ (op_prop_initd_flushd_flushda[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_initd_flushd_flushda[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_IO(Iw) ( \
++ (op_prop_load_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE_IO(Iw) ( \
++ (op_prop_store_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MEM_IO(Iw) ( \
++ (op_prop_mem_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mem_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ARITH(Iw) ( \
++ (op_prop_arith[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_arith[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_arith[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_arith[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_A_NOT_SRC(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) || \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_READRA(Iw)) \
++)
++
++#define IW_PROP_B_NOT_SRC(Iw) ( \
++ (op_prop_b_not_src[GET_IW_OP(Iw)]) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_READRB(Iw)))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_b_not_src[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_IGNORE_DST(Iw) ( \
++ (op_prop_ignore_dst[GET_IW_OP(Iw)]) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_WRITERC(Iw)))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_ignore_dst[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC2_CHOOSE_IMM(Iw) ( \
++ (op_prop_src2_choose_imm[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src2_choose_imm[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src2_choose_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src2_choose_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_WRCTL_INST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_WRCTL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_RDCTL_INST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_RDCTL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SRC1_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSU) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SRC2_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SHIFT_SRC1_SIGNED(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_mul_shift_src1_signed[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mul_shift_src1_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MUL_SHIFT_SRC2_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DONT_DISPLAY_DST_REG(Iw) ( \
++ (op_prop_dont_display_dst_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_dst_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_dst_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_dst_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DONT_DISPLAY_SRC1_REG(Iw) ( \
++ (op_prop_dont_display_src1_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_src1_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_src1_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_src1_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DONT_DISPLAY_SRC2_REG(Iw) ( \
++ (op_prop_dont_display_src2_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_src2_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_src2_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_src2_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC1_NO_X(Iw) ( \
++ (op_prop_src1_no_x[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src1_no_x[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src1_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src1_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC2_NO_X(Iw) ( \
++ (op_prop_src2_no_x[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src2_no_x[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src2_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src2_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++/* Instruction types */
++#define INST_TYPE_OP 0
++#define INST_TYPE_OPX 1
++
++/* Canonical instruction codes independent of encoding */
++#define CALL_INST_CODE 0
++#define JMPI_INST_CODE 1
++#define LDBU_INST_CODE 2
++#define ADDI_INST_CODE 3
++#define STB_INST_CODE 4
++#define BR_INST_CODE 5
++#define LDB_INST_CODE 6
++#define CMPGEI_INST_CODE 7
++#define LDHU_INST_CODE 8
++#define ANDI_INST_CODE 9
++#define STH_INST_CODE 10
++#define BGE_INST_CODE 11
++#define LDH_INST_CODE 12
++#define CMPLTI_INST_CODE 13
++#define ORI_INST_CODE 14
++#define STW_INST_CODE 15
++#define BLT_INST_CODE 16
++#define LDW_INST_CODE 17
++#define CMPNEI_INST_CODE 18
++#define FLUSHDA_INST_CODE 19
++#define XORI_INST_CODE 20
++#define BNE_INST_CODE 21
++#define CMPEQI_INST_CODE 22
++#define LDBUIO_INST_CODE 23
++#define MULI_INST_CODE 24
++#define STBIO_INST_CODE 25
++#define BEQ_INST_CODE 26
++#define LDBIO_INST_CODE 27
++#define CMPGEUI_INST_CODE 28
++#define LDHUIO_INST_CODE 29
++#define ANDHI_INST_CODE 30
++#define STHIO_INST_CODE 31
++#define BGEU_INST_CODE 32
++#define LDHIO_INST_CODE 33
++#define CMPLTUI_INST_CODE 34
++#define CUSTOM_INST_CODE 35
++#define INITD_INST_CODE 36
++#define ORHI_INST_CODE 37
++#define STWIO_INST_CODE 38
++#define BLTU_INST_CODE 39
++#define LDWIO_INST_CODE 40
++#define FLUSHD_INST_CODE 41
++#define XORHI_INST_CODE 42
++#define ERET_INST_CODE 43
++#define ROLI_INST_CODE 44
++#define ROL_INST_CODE 45
++#define FLUSHP_INST_CODE 46
++#define RET_INST_CODE 47
++#define NOR_INST_CODE 48
++#define MULXUU_INST_CODE 49
++#define CMPGE_INST_CODE 50
++#define BRET_INST_CODE 51
++#define ROR_INST_CODE 52
++#define FLUSHI_INST_CODE 53
++#define JMP_INST_CODE 54
++#define AND_INST_CODE 55
++#define CMPLT_INST_CODE 56
++#define SLLI_INST_CODE 57
++#define SLL_INST_CODE 58
++#define OR_INST_CODE 59
++#define MULXSU_INST_CODE 60
++#define CMPNE_INST_CODE 61
++#define SRLI_INST_CODE 62
++#define SRL_INST_CODE 63
++#define NEXTPC_INST_CODE 64
++#define CALLR_INST_CODE 65
++#define XOR_INST_CODE 66
++#define MULXSS_INST_CODE 67
++#define CMPEQ_INST_CODE 68
++#define DIVU_INST_CODE 69
++#define DIV_INST_CODE 70
++#define RDCTL_INST_CODE 71
++#define MUL_INST_CODE 72
++#define CMPGEU_INST_CODE 73
++#define INITI_INST_CODE 74
++#define TRAP_INST_CODE 75
++#define WRCTL_INST_CODE 76
++#define CMPLTU_INST_CODE 77
++#define ADD_INST_CODE 78
++#define BREAK_INST_CODE 79
++#define HBREAK_INST_CODE 80
++#define SYNC_INST_CODE 81
++#define SUB_INST_CODE 82
++#define SRAI_INST_CODE 83
++#define SRA_INST_CODE 84
++#define INTR_INST_CODE 85
++#define CRST_INST_CODE 86
++#define RSV_INST_CODE 87
++#define NUM_NIOS2_INST_CODES 88
++
++#ifndef ALT_ASM_SRC
++/* Instruction information entry */
++typedef struct {
++ const char* name; /* Assembly-language instruction name */
++ int instType; /* INST_TYPE_OP or INST_TYPE_OPX */
++ unsigned opcode; /* Value of instruction word OP/OPX field */
++} Nios2InstInfo;
++
++extern Nios2InstInfo nios2InstInfo[NUM_NIOS2_INST_CODES];
++#endif /* ALT_ASM_SRC */
++
++/* Returns the instruction code given the 32-bit instruction word */
++#define GET_INST_CODE(Iw) \
++ (IS_OPX_INST(Iw) ? opxToInstCode[GET_IW_OPX(Iw)] : opToInstCode[GET_IW_OP(Iw)])
++
++#ifndef ALT_ASM_SRC
++extern int opToInstCode[64];
++extern int opxToInstCode[64];
++#endif /* ALT_ASM_SRC */
++
++/*
++ * MMU Memory Region Macros
++ */
++#define USER_REGION_MIN_VADDR 0x00000000
++#define USER_REGION_MAX_VADDR 0x7fffffff
++#define KERNEL_MMU_REGION_MIN_VADDR 0x80000000
++#define KERNEL_MMU_REGION_MAX_VADDR 0xbfffffff
++#define KERNEL_REGION_MIN_VADDR 0xc0000000
++#define KERNEL_REGION_MAX_VADDR 0xdfffffff
++#define IO_REGION_MIN_VADDR 0xe0000000
++#define IO_REGION_MAX_VADDR 0xffffffff
++
++#define MMU_PAGE_SIZE (0x1 << (MMU_ADDR_PAGE_OFFSET_SZ))
++
++#define isMmuUserRegion(Vaddr) \
++ (GET_MMU_ADDR_USER_REGION(Vaddr) == MMU_ADDR_USER_REGION)
++#define isMmuKernelMmuRegion(Vaddr) \
++ (GET_MMU_ADDR_KERNEL_MMU_REGION(Vaddr) == MMU_ADDR_KERNEL_MMU_REGION)
++#define isMmuKernelRegion(Vaddr) \
++ (GET_MMU_ADDR_KERNEL_REGION(Vaddr) == MMU_ADDR_KERNEL_REGION)
++#define isMmuIORegion(Vaddr) \
++ (GET_MMU_ADDR_IO_REGION(Vaddr) == MMU_ADDR_IO_REGION)
++
++/* Does this virtual address bypass the TLB? */
++#define vaddrBypassTlb(Vaddr) \
++ (GET_MMU_ADDR_BYPASS_TLB(Vaddr) == MMU_ADDR_BYPASS_TLB)
++
++/* If TLB is bypassed, is the address cacheable or uncachable. */
++#define vaddrBypassTlbCacheable(Vaddr) \
++ (GET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Vaddr) == MMU_ADDR_BYPASS_TLB_CACHEABLE)
++
++/*
++ * Compute physical address for regions that bypass the TLB.
++ * Just need to clear some top bits.
++ */
++#define bypassTlbVaddrToPaddr(Vaddr) \
++ ((Vaddr) & (MMU_ADDR_BYPASS_TLB_PADDR_MASK << MMU_ADDR_BYPASS_TLB_PADDR_LSB))
++
++/*
++ * Will the physical address fit in the Kernel/IO region virtual address space?
++ */
++#define fitsInKernelRegion(Paddr) \
++ (GET_MMU_ADDR_KERNEL_REGION(Paddr) == 0)
++#define fitsInIORegion(Paddr) \
++ (GET_MMU_ADDR_IO_REGION(Paddr) == 0)
++
++/* Convert a physical address to a Kernel/IO region virtual address. */
++#define paddrToKernelRegionVaddr(Paddr) \
++ ((Paddr) | (MMU_ADDR_KERNEL_REGION << MMU_ADDR_KERNEL_REGION_LSB))
++#define paddrToIORegionVaddr(Paddr) \
++ ((Paddr) | (MMU_ADDR_IO_REGION << MMU_ADDR_IO_REGION_LSB))
++
++/*
++ * Convert a virtual address to a Kernel/IO region virtual address.
++ * Uses bypassTlbVaddrToPaddr to clear top bits.
++ */
++#define vaddrToKernelRegionVaddr(Vaddr) \
++ paddrToKernelRegionVaddr(bypassTlbVaddrToPaddr(Vaddr))
++#define vaddrToIORegionVaddr(Vaddr) \
++ paddrToIORegionVaddr(bypassTlbVaddrToPaddr(Vaddr))
++
++/* Convert between VPN/PFN and virtual/physical addresses. */
++#define vpnToVaddr(Vpn) ((Vpn) << MMU_ADDR_VPN_LSB)
++#define pfnToPaddr(Pfn) ((Pfn) << MMU_ADDR_PFN_LSB)
++#define vaddrToVpn(Vaddr) GET_MMU_ADDR_VPN(Vaddr)
++#define paddrToPfn(Paddr) GET_MMU_ADDR_PFN(Paddr)
++
++/* Bitwise OR with a KERNEL region address to make it an IO region address */
++#define KERNEL_TO_IO_REGION 0x20000000
++
++#endif /* _NIOS2_ISA_H_ */
+diff --git a/include/opcode/nios2.h b/include/opcode/nios2.h
+new file mode 100644
+index 0000000..992bb80
+--- /dev/null
++++ b/include/opcode/nios2.h
+@@ -0,0 +1,361 @@
++/* nios2.h. Altera New Jersey opcode list for GAS, the GNU assembler.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#ifndef _NIOS2_H_
++#define _NIOS2_H_
++
++
++/****************************************************************************
++ * This file contains structures, bit masks and shift counts used
++ * by the GNU toolchain to define the New Jersey instruction set and
++ * access various opcode fields.
++ ****************************************************************************/
++
++enum overflow_type
++{
++ call_target_overflow = 0,
++ branch_target_overflow,
++ address_offset_overflow,
++ signed_immed16_overflow,
++ unsigned_immed16_overflow,
++ unsigned_immed5_overflow,
++ custom_opcode_overflow,
++ no_overflow
++};
++
++/*---------------------------------------------------------------------------
++ This structure holds information for a particular instruction
++ ---------------------------------------------------------------------------*/
++
++/* match When assembling, this
++ opcode is modified by the arguments to produce the actual opcode
++ that is used. If pinfo is INSN_MACRO, then this is 0. */
++
++/* mask If pinfo is not INSN_MACRO, then this is a bit mask for the
++ relevant portions of the opcode when disassembling. If the
++ actual opcode anded with the match field equals the opcode field,
++ then we have found the correct instruction. If pinfo is
++ INSN_MACRO, then this field is the macro identifier. */
++
++/* For a macro, this is INSN_MACRO. Otherwise, it is a collection
++ of bits describing the instruction, notably any relevant hazard
++ information. */
++
++struct nios2_opcode
++{
++ const char *name; /* The name of the instruction. */
++ const char *args; /* A string describing the arguments for this instruction. */
++ const char *args_test; /* Like args, but with an extra argument for the expected opcode */
++ unsigned long num_args; /* the number of arguments the instruction takes */
++ unsigned long match; /* The basic opcode for the instruction. */
++ unsigned long mask; /* mask for the opcode field of the instruction */
++ unsigned long pinfo; /* is this a real instruction or instruction macro */
++ enum overflow_type overflow_msg; /* msg template used to generate informative message when fixup overflows */
++};
++
++/* This value is used in the nios2_opcode.pinfo field to indicate that the instruction
++ is a macro or pseudo-op. This requires special treatment by the assembler, and is
++ used by the disassembler to determine whether to check for a nop */
++#define NIOS2_INSN_MACRO 0x80000000
++#define NIOS2_INSN_MACRO_MOV 0x80000001
++#define NIOS2_INSN_MACRO_MOVI 0x80000002
++#define NIOS2_INSN_MACRO_MOVIA 0x80000004
++
++#define NIOS2_INSN_RELAXABLE 0x40000000
++#define NIOS2_INSN_UBRANCH 0x00000010
++#define NIOS2_INSN_CBRANCH 0x00000020
++#define NIOS2_INSN_CALL 0x00000040
++
++#define NIOS2_INSN_ADDI 0x00000080
++#define NIOS2_INSN_ANDI 0x00000100
++#define NIOS2_INSN_ORI 0x00000200
++#define NIOS2_INSN_XORI 0x00000400
++
++
++
++/* Associates a register name ($6) with a 5-bit index (eg 6) */
++struct nios2_reg
++{
++ const char *name;
++ const int index;
++};
++
++
++/* -------------------------------------------------------------------------
++ Bitfield masks for New Jersey instructions
++ -------------------------------------------------------------------------*/
++
++/* These are bit masks and shift counts to use to access the various
++ fields of an instruction. */
++
++/* Macros for getting and setting an instruction field */
++#define GET_INSN_FIELD(X, i) ((i) & OP_MASK_##X) >> OP_SH_##X
++#define SET_INSN_FIELD(X, i, j) (i) = ((i) &~ (OP_MASK_##X)) | ((j) << OP_SH_##X)
++
++
++/*
++ We include the auto-generated file nios2-isa.h and define the mask
++ and shifts below in terms of those in nios2-isa.h. This ensures
++ that the binutils and hardware are always in sync
++*/
++
++#include "nios2-isa.h"
++
++#define OP_MASK_OP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_OP IW_OP_LSB
++
++
++/* Masks and shifts for I-type instructions */
++
++#define OP_MASK_IOP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_IOP IW_OP_LSB
++
++#define OP_MASK_IMM16 (IW_IMM16_MASK << IW_IMM16_LSB)
++#define OP_SH_IMM16 IW_IMM16_LSB
++
++#define OP_MASK_IRD (IW_B_MASK << IW_B_LSB) // the same as T for I-type
++#define OP_SH_IRD IW_B_LSB
++
++#define OP_MASK_IRT (IW_B_MASK << IW_B_LSB)
++#define OP_SH_IRT IW_B_LSB
++
++#define OP_MASK_IRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_IRS IW_A_LSB
++
++/* Masks and shifts for R-type instructions */
++
++#define OP_MASK_ROP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_ROP IW_OP_LSB
++
++#define OP_MASK_ROPX (IW_OPX_MASK << IW_OPX_LSB)
++#define OP_SH_ROPX IW_OPX_LSB
++
++#define OP_MASK_RRD (IW_C_MASK << IW_C_LSB)
++#define OP_SH_RRD IW_C_LSB
++
++#define OP_MASK_RRT (IW_B_MASK << IW_B_LSB)
++#define OP_SH_RRT IW_B_LSB
++
++#define OP_MASK_RRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_RRS IW_A_LSB
++
++/* Masks and shifts for J-type instructions */
++
++#define OP_MASK_JOP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_JOP IW_OP_LSB
++
++#define OP_MASK_IMM26 (IW_IMM26_MASK << IW_IMM26_LSB)
++#define OP_SH_IMM26 IW_IMM26_LSB
++
++/* Masks and shifts for CTL instructions */
++
++#define OP_MASK_RCTL 0x000007c0
++#define OP_SH_RCTL 6
++
++/* break instruction imm5 field */
++#define OP_MASK_TRAP_IMM5 0x000007c0
++#define OP_SH_TRAP_IMM5 6
++
++/* instruction imm5 field */
++#define OP_MASK_IMM5 (IW_SHIFT_IMM5_MASK << IW_SHIFT_IMM5_LSB)
++#define OP_SH_IMM5 IW_SHIFT_IMM5_LSB
++
++/* cache operation fields (type j,i(s)) */
++#define OP_MASK_CACHE_OPX (IW_B_MASK << IW_B_LSB)
++#define OP_SH_CACHE_OPX IW_B_LSB
++#define OP_MASK_CACHE_RRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_CACHE_RRS IW_A_LSB
++
++/* custom instruction masks */
++#define OP_MASK_CUSTOM_A 0x00010000
++#define OP_SH_CUSTOM_A 16
++
++#define OP_MASK_CUSTOM_B 0x00008000
++#define OP_SH_CUSTOM_B 15
++
++#define OP_MASK_CUSTOM_C 0x00004000
++#define OP_SH_CUSTOM_C 14
++
++#define OP_MASK_CUSTOM_N 0x00003fc0
++#define OP_SH_CUSTOM_N 6
++#define OP_MAX_CUSTOM_N 255
++
++/*
++ The following macros define the opcode matches for each
++ instruction
++ code & OP_MASK_INST == OP_MATCH_INST
++ */
++
++/* OP instruction matches */
++#define OP_MATCH_ADDI OP_ADDI
++#define OP_MATCH_ANDHI OP_ANDHI
++#define OP_MATCH_ANDI OP_ANDI
++#define OP_MATCH_BEQ OP_BEQ
++#define OP_MATCH_BGE OP_BGE
++#define OP_MATCH_BGEU OP_BGEU
++#define OP_MATCH_BLT OP_BLT
++#define OP_MATCH_BLTU OP_BLTU
++#define OP_MATCH_BNE OP_BNE
++#define OP_MATCH_BR OP_BR
++#define OP_MATCH_FLUSHD OP_FLUSHD
++#define OP_MATCH_FLUSHDA OP_FLUSHDA
++#define OP_MATCH_INITD OP_INITD
++#define OP_MATCH_CALL OP_CALL
++#define OP_MATCH_CMPEQI OP_CMPEQI
++#define OP_MATCH_CMPGEI OP_CMPGEI
++#define OP_MATCH_CMPGEUI OP_CMPGEUI
++#define OP_MATCH_CMPLTI OP_CMPLTI
++#define OP_MATCH_CMPLTUI OP_CMPLTUI
++#define OP_MATCH_CMPNEI OP_CMPNEI
++#define OP_MATCH_JMPI OP_JMPI
++#define OP_MATCH_LDB OP_LDB
++#define OP_MATCH_LDBIO OP_LDBIO
++#define OP_MATCH_LDBU OP_LDBU
++#define OP_MATCH_LDBUIO OP_LDBUIO
++#define OP_MATCH_LDH OP_LDH
++#define OP_MATCH_LDHIO OP_LDHIO
++#define OP_MATCH_LDHU OP_LDHU
++#define OP_MATCH_LDHUIO OP_LDHUIO
++#define OP_MATCH_LDW OP_LDW
++#define OP_MATCH_LDWIO OP_LDWIO
++#define OP_MATCH_MULI OP_MULI
++#define OP_MATCH_OPX OP_OPX
++#define OP_MATCH_ORHI OP_ORHI
++#define OP_MATCH_ORI OP_ORI
++#define OP_MATCH_STB OP_STB
++#define OP_MATCH_STBIO OP_STBIO
++#define OP_MATCH_STH OP_STH
++#define OP_MATCH_STHIO OP_STHIO
++#define OP_MATCH_STW OP_STW
++#define OP_MATCH_STWIO OP_STWIO
++#define OP_MATCH_CUSTOM OP_CUSTOM
++#define OP_MATCH_XORHI OP_XORHI
++#define OP_MATCH_XORI OP_XORI
++#define OP_MATCH_OPX OP_OPX
++
++
++
++/* OPX instruction values */
++#define OP_MATCH_ADD ((OPX_ADD << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_AND ((OPX_AND << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_BREAK ((0x1e << 17) | (OPX_BREAK << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_BRET ((0xf0000000) | (OPX_BRET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CALLR ((0x1f << 17) | (OPX_CALLR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPEQ ((OPX_CMPEQ << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPGE ((OPX_CMPGE << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPGEU ((OPX_CMPGEU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPLT ((OPX_CMPLT << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPLTU ((OPX_CMPLTU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPNE ((OPX_CMPNE << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_DIV ((OPX_DIV << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_DIVU ((OPX_DIVU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_JMP ((OPX_JMP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MUL ((OPX_MUL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXSS ((OPX_MULXSS << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXSU ((OPX_MULXSU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXUU ((OPX_MULXUU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_NEXTPC ((OPX_NEXTPC << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_NOR ((OPX_NOR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_OR ((OPX_OR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_RDCTL ((OPX_RDCTL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_RET ((0xf8000000) | (OPX_RET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROL ((OPX_ROL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROLI ((OPX_ROLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROR ((OPX_ROR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SLL ((OPX_SLL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SLLI ((OPX_SLLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRA ((OPX_SRA << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRAI ((OPX_SRAI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRL ((OPX_SRL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRLI ((OPX_SRLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SUB ((OPX_SUB << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SYNC ((OPX_SYNC << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_TRAP ((0x1d << 17) | (OPX_TRAP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ERET ((0xe8000000) | (OPX_ERET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_WRCTL ((OPX_WRCTL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_XOR ((OPX_XOR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_FLUSHI ((OPX_FLUSHI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_FLUSHP ((OPX_FLUSHP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_INITI ((OPX_INITI << IW_OPX_LSB) | (OP_OPX))
++
++/*
++ Some unusual op masks
++*/
++#define OP_MASK_BREAK ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP) & 0xfffff03f)
++#define OP_MASK_CALLR ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_JMP ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SYNC ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_TRAP ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP) & 0xfffff83f)
++#define OP_MASK_WRCTL ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP)) /*& 0xfffff83f */
++#define OP_MASK_NEXTPC ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_FLUSHI ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_INITI ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++
++#define OP_MASK_ROLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SLLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SRAI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SRLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_RDCTL ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP)) /*& 0xfffff83f */
++
++#ifndef OP_MASK
++#define OP_MASK 0xffffffff
++#endif
++
++/* These are the data structures we use to hold the instruction information */
++
++extern const struct nios2_opcode nios2_builtin_opcodes[];
++extern const int bfd_nios2_num_builtin_opcodes;
++extern struct nios2_opcode *nios2_opcodes;
++extern int bfd_nios2_num_opcodes;
++
++/* These are the data structures used to hold the operand parsing information */
++//extern const struct nios2_arg_parser nios2_arg_parsers[];
++//extern struct nios2_arg_parser* nios2_arg_parsers;
++//extern const int nios2_num_builtin_arg_parsers;
++//extern int nios2_num_arg_parsers;
++
++/* These are the data structures used to hold the register information */
++extern const struct nios2_reg nios2_builtin_regs[];
++extern struct nios2_reg *nios2_regs;
++extern const int nios2_num_builtin_regs;
++extern int nios2_num_regs;
++
++/* Machine-independent macro for number of opcodes */
++
++#define NUMOPCODES bfd_nios2_num_opcodes
++#define NUMREGISTERS nios2_num_regs;
++
++/* these are used in disassembly to get the correct register names */
++#define NUMREGNAMES 32
++#define NUMCTLREGNAMES 32
++#define CTLREGBASE 42
++#define COPROCREGBASE 83
++#define NUMCOPROCREGNAMES 32
++
++
++/* this is made extern so that the assembler can use it to find out
++ what instruction caused an error */
++extern const struct nios2_opcode *nios2_find_opcode_hash (unsigned long);
++
++/* overflow message strings used in the assembler */
++extern char *overflow_msgs[];
++
++#endif // _NIOS2_H
+diff --git a/include/opcode/s-nios2-isa b/include/opcode/s-nios2-isa
+new file mode 100644
+index 0000000..9788f70
+--- /dev/null
++++ b/include/opcode/s-nios2-isa
+@@ -0,0 +1 @@
++timestamp
+diff --git a/ld/Makefile.am b/ld/Makefile.am
+index a2f1ac1..665db8b 100644
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -1440,6 +1440,9 @@ eelf32frvfd.c: $(srcdir)/emulparams/elf32frvfd.sh \
+ $(srcdir)/emulparams/elf32frv.sh \
+ $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} elf32frvfd "$(tdir_frv)"
++enios2elf.c: $(srcdir)/emulparams/nios2elf.sh \
++ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
++ ${GENSCRIPTS} nios2elf "$(tdir_nios2)"
+
+ # We need this for automake to use YLWRAP.
+ EXTRA_ld_new_SOURCES = deffilep.y
+diff --git a/ld/Makefile.in b/ld/Makefile.in
+index 976d5db..1be09a3 100644
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -2166,6 +2166,9 @@ eelf32frvfd.c: $(srcdir)/emulparams/elf32frvfd.sh \
+ $(srcdir)/emulparams/elf32frv.sh \
+ $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} elf32frvfd "$(tdir_frv)"
++enios2elf.c: $(srcdir)/emulparams/nios2elf.sh \
++ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
++ ${GENSCRIPTS} nios2elf "$(tdir_nios2)"
+
+ # The generated emulation files mostly have the same dependencies.
+ $(EMULATION_OFILES): ../bfd/bfd.h sysdep.h config.h $(INCDIR)/bfdlink.h \
+diff --git a/ld/configure.tgt b/ld/configure.tgt
+index 9b29291..3064c1d 100644
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -450,6 +450,7 @@ mn10200-*-*) targ_emul=mn10200 ;;
+ mn10300-*-*) targ_emul=mn10300 ;;
+ msp430-*-*) targ_emul=msp430x110
+ targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449" ;;
++nios2*-*-*) targ_emul=nios2elf ;;
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ targ_emul=elf64alpha_fbsd
+ targ_extra_emuls="elf64alpha alpha"
+diff --git a/ld/emulparams/nios2elf.sh b/ld/emulparams/nios2elf.sh
+new file mode 100644
+index 0000000..9c9e588
+--- /dev/null
++++ b/ld/emulparams/nios2elf.sh
+@@ -0,0 +1,17 @@
++SCRIPT_NAME=elf
++OUTPUT_FORMAT="elf32-littlenios2"
++LITTLE_OUTPUT_FORMAT="elf32-littlenios2"
++BIG_OUTPUT_FORMAT="elf32-bignios2"
++TEXT_START_ADDR=0x0
++OTHER_GOT_SYMBOLS='
++ _gp = ALIGN(16) + 0x7ff0;
++ PROVIDE(gp = _gp);
++'
++ARCH=nios2
++MACHINE=
++MAXPAGESIZE=256
++ENTRY=_start
++EMBEDDED=yes
++DATA_ADDR=.
++NOP=0x0001883a
++
+diff --git a/ld/ldlang.c b/ld/ldlang.c
+index 0c08601..78a2dfe 100644
+--- a/ld/ldlang.c
++++ b/ld/ldlang.c
+@@ -2855,10 +2855,11 @@ os_region_check (lang_output_section_statement_type *os,
+ }
+ else
+ {
+- einfo (_("%X%P: region %s is full (%B section %s)\n"),
++ einfo (_("%X%P: region %s is full (%B section %s). Region needs to be %d bytes larger.\n"),
+ region->name,
+ os->bfd_section->owner,
+- os->bfd_section->name);
++ os->bfd_section->name,
++ region->current - (region->origin + region->length));
+ }
+ /* Reset the region pointer. */
+ region->current = region->origin;
+diff --git a/ld/ldmain.c b/ld/ldmain.c
+index d0e0b12..fe24494 100644
+--- a/ld/ldmain.c
++++ b/ld/ldmain.c
+@@ -397,6 +397,14 @@ main (int argc, char **argv)
+ yyparse ();
+ lex_string = NULL;
+ }
++/* NG horrible hack, but it works and I haven't the time to do this properly */
++#ifdef bfd_set_link_info
++ bfd_set_link_info(&link_info);
++#endif
++#ifdef bfd_set_force_make_executable
++ bfd_set_force_make_executable(force_make_executable);
++#endif
++
+
+ if (trace_file_tries)
+ {
+diff --git a/ld/nios2_ld_xfail.lst b/ld/nios2_ld_xfail.lst
+new file mode 100644
+index 0000000..b28b04f
+--- /dev/null
++++ b/ld/nios2_ld_xfail.lst
+@@ -0,0 +1,3 @@
++
++
++
+diff --git a/ld/testsuite/ld-elf/merge.d b/ld/testsuite/ld-elf/merge.d
+index 4038cc8..13c9e00 100644
+--- a/ld/testsuite/ld-elf/merge.d
++++ b/ld/testsuite/ld-elf/merge.d
+@@ -5,6 +5,7 @@
+ #xfail: "hppa*-*-*" "h8300-*-*" "i960-*-*" "ip2k-*-*" "m32r-*-*" "mcore-*-*"
+ #xfail: "mn10*-*-*" "mips64*-*-linux*" "openrisc-*-*" "pj-*-*" "sparc*-*-*"
+ #xfail: "xtensa-*-*"
++#xfail: "nios2-*-*"
+
+ .*: file format .*elf.*
+
+diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
+index e5bd29b..cbeb00e 100644
+--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
++++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
+@@ -56,6 +56,10 @@ proc dump_common1 { testname } {
+ return 1
+ }
+
++if [istarget nios2*-*-*] {
++ set CFLAGS "$CFLAGS -G0"
++}
++
+ if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
+ || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] } {
+ unresolved $test1
+diff --git a/ld/testsuite/ld-scripts/cross2.t b/ld/testsuite/ld-scripts/cross2.t
+index a0cdcbb..7cb7d6b 100644
+--- a/ld/testsuite/ld-scripts/cross2.t
++++ b/ld/testsuite/ld-scripts/cross2.t
+@@ -2,5 +2,9 @@ NOCROSSREFS ( .text .data )
+ SECTIONS
+ {
+ .text : { *(.text) *(.text.*) *(.pr) }
+- .data : { *(.data) *(.data.*) *(.sdata) *(.rw) *(.tc0) *(.tc) *(.toc) }
++ .data :
++ { *(.data) *(.data.*)
++ _gp = ABSOLUTE(. + 0x7ff0);
++ *(.sdata) *(.rw) *(.tc0) *(.tc) *(.toc)
++ }
+ }
+diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
+index ea621f2..1fe2456 100644
+--- a/opcodes/Makefile.am
++++ b/opcodes/Makefile.am
+@@ -125,6 +125,8 @@ CFILES = \
+ mmix-dis.c \
+ mmix-opc.c \
+ ns32k-dis.c \
++ nios2-opc.c \
++ nios2-dis.c \
+ openrisc-asm.c \
+ openrisc-desc.c \
+ openrisc-dis.c \
+@@ -237,6 +239,8 @@ ALL_MACHINES = \
+ mmix-opc.lo \
+ msp430-dis.lo \
+ ns32k-dis.lo \
++ nios2-opc.lo \
++ nios2-dis.lo \
+ openrisc-asm.lo \
+ openrisc-desc.lo \
+ openrisc-dis.lo \
+@@ -739,6 +743,13 @@ mmix-opc.lo: mmix-opc.c $(INCDIR)/opcode/mmix.h $(INCDIR)/symcat.h
+ ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(INCDIR)/opcode/ns32k.h opintl.h
++nios2-opc.lo: nios2-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/opcode/nios2.h
++nios2-dis.lo: nios2-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/nios2.h \
++ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
++ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
++ $(INCDIR)/elf/nios2.h $(INCDIR)/elf/reloc-macros.h
+ openrisc-asm.lo: openrisc-asm.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(BFD_H) $(INCDIR)/symcat.h openrisc-desc.h $(INCDIR)/opcode/cgen.h \
+ openrisc-opc.h opintl.h $(INCDIR)/xregex.h $(INCDIR)/xregex2.h \
+diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
+index 559194d..dc31a88 100644
+--- a/opcodes/Makefile.in
++++ b/opcodes/Makefile.in
+@@ -236,6 +236,8 @@ CFILES = \
+ mmix-dis.c \
+ mmix-opc.c \
+ ns32k-dis.c \
++ nios2-opc.c \
++ nios2-dis.c \
+ openrisc-asm.c \
+ openrisc-desc.c \
+ openrisc-dis.c \
+@@ -348,6 +350,8 @@ ALL_MACHINES = \
+ mmix-dis.lo \
+ mmix-opc.lo \
+ msp430-dis.lo \
++ nios2-opc.lo \
++ nios2-dis.lo \
+ ns32k-dis.lo \
+ openrisc-asm.lo \
+ openrisc-desc.lo \
+@@ -1232,6 +1236,13 @@ mmix-dis.lo: mmix-dis.c $(INCDIR)/opcode/mmix.h $(INCDIR)/dis-asm.h \
+ $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/libiberty.h \
+ opintl.h
+ mmix-opc.lo: mmix-opc.c $(INCDIR)/opcode/mmix.h $(INCDIR)/symcat.h
++nios2-opc.lo: nios2-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/opcode/nios2.h
++nios2-dis.lo: nios2-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/nios2.h \
++ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
++ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
++ $(INCDIR)/elf/nios2.h $(INCDIR)/elf/reloc-macros.h
+ ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/dis-asm.h \
+ $(INCDIR)/opcode/ns32k.h opintl.h
+diff --git a/opcodes/configure b/opcodes/configure
+index 4a95a9a..561f1e0 100755
+--- a/opcodes/configure
++++ b/opcodes/configure
+@@ -4661,6 +4661,7 @@ if test x${all_targets} = xfalse ; then
+ bfd_mn10200_arch) ta="$ta m10200-dis.lo m10200-opc.lo" ;;
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_msp430_arch) ta="$ta msp430-dis.lo" ;;
++ bfd_nios2_arch) ta="$ta nios2-dis.lo nios2-opc.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
+ bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
+diff --git a/opcodes/configure.in b/opcodes/configure.in
+index 8919924..bfdcabc 100644
+--- a/opcodes/configure.in
++++ b/opcodes/configure.in
+@@ -202,6 +202,7 @@ if test x${all_targets} = xfalse ; then
+ bfd_mn10200_arch) ta="$ta m10200-dis.lo m10200-opc.lo" ;;
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_msp430_arch) ta="$ta msp430-dis.lo" ;;
++ bfd_nios2_arch) ta="$ta nios2-dis.lo nios2-opc.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
+ bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
+diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
+index d5b17be..877e582 100644
+--- a/opcodes/disassemble.c
++++ b/opcodes/disassemble.c
+@@ -72,6 +72,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ #define ARCH_z8k
+ #define ARCH_frv
+ #define ARCH_iq2000
++#define ARCH_nios2
+ #define INCLUDE_SHMEDIA
+ #endif
+
+@@ -375,6 +376,14 @@ disassembler (abfd)
+ disassemble = print_insn_iq2000;
+ break;
+ #endif
++#ifdef ARCH_nios2
++ case bfd_arch_nios2:
++ if (bfd_big_endian (abfd))
++ disassemble = print_insn_big_nios2;
++ else
++ disassemble = print_insn_little_nios2;
++ break;
++#endif
+ default:
+ return 0;
+ }
+diff --git a/opcodes/nios2-dis.c b/opcodes/nios2-dis.c
+new file mode 100644
+index 0000000..c164436
+--- /dev/null
++++ b/opcodes/nios2-dis.c
+@@ -0,0 +1,462 @@
++/* nios2-dis.c -- Altera New Jersey disassemble routines.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include <stdlib.h>
++#include <assert.h>
++#include <string.h>
++#include "dis-asm.h"
++#include "opcode/nios2.h"
++
++/* No symbol table is available when this code runs out in an embedded
++ system as when it is used for disassembler support in a monitor. */
++
++#if !defined(EMBEDDED_ENV)
++#define SYMTAB_AVAILABLE 1
++#include "elf-bfd.h"
++#include "elf/nios2.h"
++#endif
++
++/* length of New Jersey instruction in bytes */
++#define INSNLEN 4
++
++/* helper function prototypes */
++static int nios2_disassemble (bfd_vma, unsigned long, disassemble_info *);
++static void nios2_init_opcode_hash (void);
++
++
++static int nios2_print_insn_arg (const char *argptr, unsigned long opcode,
++ bfd_vma address, disassemble_info * info);
++
++
++/* print_insn_nios2 is the main disassemble function for New Jersey.
++ The function diassembler(abfd) (source in disassemble.c) returns a
++ pointer to this either print_insn_big_nios2 or
++ print_insn_little_nios2, which in turn call this function, when the
++ bfd machine type is New Jersey. print_insn_nios2 reads the
++ instruction word at the address given, and prints the disassembled
++ instruction on the stream info->stream using info->fprintf_func. */
++
++static int
++print_insn_nios2 (bfd_vma address, disassemble_info * info,
++ enum bfd_endian endianness)
++{
++ /* buffer into which the instruction bytes are written */
++ bfd_byte buffer[INSNLEN];
++ /* used to indicate return status from function calls */
++ int status;
++
++ assert (info != NULL);
++
++ status = (*info->read_memory_func) (address, buffer, INSNLEN, info);
++ if (status == 0)
++ {
++ unsigned long insn;
++ if (endianness == BFD_ENDIAN_BIG)
++ insn = (unsigned long) bfd_getb32 (buffer);
++ else
++ insn = (unsigned long) bfd_getl32 (buffer);
++ status = nios2_disassemble (address, insn, info);
++ }
++ else
++ {
++ (*info->memory_error_func) (status, address, info);
++ status = -1;
++ }
++ return status;
++}
++
++int
++print_insn_big_nios2 (bfd_vma address, disassemble_info * info)
++{
++ return print_insn_nios2 (address, info, BFD_ENDIAN_BIG);
++}
++
++int
++print_insn_little_nios2 (bfd_vma address, disassemble_info * info)
++{
++ return print_insn_nios2 (address, info, BFD_ENDIAN_LITTLE);
++}
++
++/* Data structures used by the opcode hash table */
++
++typedef struct _nios2_opcode_hash
++{
++ const struct nios2_opcode *opcode;
++ struct _nios2_opcode_hash *next;
++} nios2_opcode_hash;
++
++static bfd_boolean nios2_hash_init = 0;
++static nios2_opcode_hash *nios2_hash[(OP_MASK_OP) + 1];
++
++/* separate hash table for pseudo-ops */
++static nios2_opcode_hash *nios2_ps_hash[(OP_MASK_OP) + 1];
++
++/* Function to initialize the opcode hash table */
++
++void
++nios2_init_opcode_hash ()
++{
++ unsigned int i;
++ register const struct nios2_opcode *op;
++ nios2_opcode_hash *tmp_hash;
++
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ nios2_hash[0] = NULL;
++ }
++ for (i = 0; i <= OP_MASK_OP; i++)
++ {
++ for (op = nios2_opcodes; op < &nios2_opcodes[NUMOPCODES]; op++)
++ {
++ if ((op->pinfo & NIOS2_INSN_MACRO) == NIOS2_INSN_MACRO)
++ {
++ if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP) &&
++ (op->
++ pinfo & (NIOS2_INSN_MACRO_MOV | NIOS2_INSN_MACRO_MOVI) &
++ 0x7fffffff) != 0)
++ {
++ tmp_hash = nios2_ps_hash[i];
++ if (tmp_hash == NULL)
++ {
++ tmp_hash =
++ (nios2_opcode_hash *)
++ malloc (sizeof (nios2_opcode_hash));
++ nios2_ps_hash[i] = tmp_hash;
++ }
++ else
++ {
++ while (tmp_hash->next != NULL)
++ tmp_hash = tmp_hash->next;
++ tmp_hash->next =
++ (nios2_opcode_hash *)
++ malloc (sizeof (nios2_opcode_hash));
++ tmp_hash = tmp_hash->next;
++ }
++ if (tmp_hash == NULL)
++ {
++ fprintf (stderr,
++ "error allocating memory...broken disassembler\n");
++ abort ();
++ }
++ tmp_hash->opcode = op;
++ tmp_hash->next = NULL;
++ }
++ }
++ else if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP))
++ {
++ tmp_hash = nios2_hash[i];
++ if (tmp_hash == NULL)
++ {
++ tmp_hash =
++ (nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
++ nios2_hash[i] = tmp_hash;
++ }
++ else
++ {
++ while (tmp_hash->next != NULL)
++ tmp_hash = tmp_hash->next;
++ tmp_hash->next =
++ (nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
++ tmp_hash = tmp_hash->next;
++ }
++ if (tmp_hash == NULL)
++ {
++ fprintf (stderr,
++ "error allocating memory...broken disassembler\n");
++ abort ();
++ }
++ tmp_hash->opcode = op;
++ tmp_hash->next = NULL;
++ }
++ }
++ }
++ nios2_hash_init = 1;
++#ifdef DEBUG_HASHTABLE
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ printf ("index: 0x%02X ops: ", i);
++ tmp_hash = nios2_hash[i];
++ if (tmp_hash != NULL)
++ {
++ while (tmp_hash != NULL)
++ {
++ printf ("%s ", tmp_hash->opcode->name);
++ tmp_hash = tmp_hash->next;
++ }
++ }
++ printf ("\n");
++ }
++
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ printf ("index: 0x%02X ops: ", i);
++ tmp_hash = nios2_ps_hash[i];
++ if (tmp_hash != NULL)
++ {
++ while (tmp_hash != NULL)
++ {
++ printf ("%s ", tmp_hash->opcode->name);
++ tmp_hash = tmp_hash->next;
++ }
++ }
++ printf ("\n");
++ }
++#endif
++}
++
++/* Function which returns a pointer to an nios2_opcode struct for
++ a given instruction opcode, or NULL if there is an error */
++
++const struct nios2_opcode *
++nios2_find_opcode_hash (unsigned long opcode)
++{
++ nios2_opcode_hash *entry;
++
++ /* Build a hash table to shorten the search time. */
++ if (!nios2_hash_init)
++ {
++ nios2_init_opcode_hash ();
++ }
++
++ /* first look in the pseudo-op hashtable */
++ entry = nios2_ps_hash[(opcode >> OP_SH_OP) & OP_MASK_OP];
++
++ /* look for a match and if we get one, this is the instruction we decode */
++ while (entry != NULL)
++ {
++ if ((entry->opcode->match) == (opcode & entry->opcode->mask))
++ return entry->opcode;
++ else
++ entry = entry->next;
++ }
++
++ /* if we haven't yet returned, then we need to look in the main
++ hashtable */
++ entry = nios2_hash[(opcode >> OP_SH_OP) & OP_MASK_OP];
++
++ if (entry == NULL)
++ return NULL;
++
++
++ while (entry != NULL)
++ {
++ if ((entry->opcode->match) == (opcode & entry->opcode->mask))
++ return entry->opcode;
++ else
++ entry = entry->next;
++ }
++
++ return NULL;
++}
++
++/* nios2_disassemble does all the work of disassembling a New Jersey
++ instruction opcode */
++
++int
++nios2_disassemble (bfd_vma address, unsigned long opcode,
++ disassemble_info * info)
++{
++ const struct nios2_opcode *op;
++ const char *argstr;
++
++ info->bytes_per_line = INSNLEN;
++ info->bytes_per_chunk = INSNLEN;
++ info->display_endian = info->endian;
++ info->insn_info_valid = 1;
++ info->branch_delay_insns = 0;
++ info->data_size = 0;
++ info->insn_type = dis_nonbranch;
++ info->target = 0;
++ info->target2 = 0;
++
++ /* Find the major opcode and use this to disassemble
++ the instruction and its arguments */
++ op = nios2_find_opcode_hash (opcode);
++
++ if (op != NULL)
++ {
++ bfd_boolean is_nop = FALSE;
++ if (op->pinfo == NIOS2_INSN_MACRO_MOV)
++ {
++ /* check for mov r0, r0 and if it is
++ change to nop */
++ int dst, src;
++ dst = GET_INSN_FIELD (RRD, opcode);
++ src = GET_INSN_FIELD (RRS, opcode);
++ if (dst == 0 && src == 0)
++ {
++ (*info->fprintf_func) (info->stream, "nop");
++ is_nop = TRUE;
++ }
++ else
++ {
++ (*info->fprintf_func) (info->stream, "%s", op->name);
++ }
++ }
++ else
++ {
++ (*info->fprintf_func) (info->stream, "%s", op->name);
++ }
++
++ if (!is_nop)
++ {
++ argstr = op->args;
++ if (argstr != NULL && *argstr != '\0')
++ {
++ (*info->fprintf_func) (info->stream, "\t");
++ while (*argstr != '\0')
++ {
++ nios2_print_insn_arg (argstr, opcode, address, info);
++ ++argstr;
++ }
++ }
++ }
++ }
++ else
++ {
++ /* Handle undefined instructions. */
++ info->insn_type = dis_noninsn;
++ (*info->fprintf_func) (info->stream, "0x%x", opcode);
++ }
++ // this tells the caller how far to advance the program counter
++ return INSNLEN;
++}
++
++/* The function nios2_print_insn_arg uses the character pointed
++ to by argptr to determine how it print the next token or separator
++ character in the arguments to an instruction */
++int
++nios2_print_insn_arg (const char *argptr,
++ unsigned long opcode, bfd_vma address,
++ disassemble_info * info)
++{
++ unsigned long i = 0;
++ unsigned long reg_base;
++
++ assert (argptr != NULL);
++ assert (info != NULL);
++
++ switch (*argptr)
++ {
++ case ',':
++ case '(':
++ case ')':
++ (*info->fprintf_func) (info->stream, "%c", *argptr);
++ break;
++ case 'd':
++ i = GET_INSN_FIELD (RRD, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_C, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 's':
++ i = GET_INSN_FIELD (RRS, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_A, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 't':
++ i = GET_INSN_FIELD (RRT, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_B, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 'i':
++ /* 16-bit signed immediate */
++ i = (signed) (GET_INSN_FIELD (IMM16, opcode) << 16) >> 16;
++ (*info->fprintf_func) (info->stream, "%d", i);
++ break;
++ case 'u':
++ /* 16-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM16, opcode);
++ (*info->fprintf_func) (info->stream, "%d", i);
++ break;
++ case 'o':
++ /* 16-bit signed immediate address offset */
++ i = (signed) (GET_INSN_FIELD (IMM16, opcode) << 16) >> 16;
++ address = address + 4 + i; /* NG changed to byte offset 1/9/03 */
++ (*info->print_address_func) (address, info);
++ break;
++ case 'p':
++ /* 5-bit unsigned immediate */
++ i = GET_INSN_FIELD (CACHE_OPX, opcode);
++ (*info->fprintf_func) (info->stream, "%d", i);
++ break;
++ case 'j':
++ /* 5-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM5, opcode);
++ (*info->fprintf_func) (info->stream, "%d", i);
++ break;
++ case 'l':
++ /* 8-bit unsigned immediate */
++ /* FIXME - not yet implemented */
++ i = GET_INSN_FIELD (CUSTOM_N, opcode);
++ (*info->fprintf_func) (info->stream, "%u", i);
++ break;
++ case 'm':
++ /* 26-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM26, opcode);
++ /* this translates to an address because its only used in call instructions */
++ address = (address & 0xf0000000) | (i << 2);
++ (*info->print_address_func) (address, info);
++ break;
++ case 'c':
++ i = GET_INSN_FIELD (IMM5, opcode); /* ctrl register index */
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[CTLREGBASE + i].name);
++ break;
++ case 'b':
++ i = GET_INSN_FIELD (IMM5, opcode);
++ (*info->fprintf_func) (info->stream, "%d", i);
++ break;
++ default:
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ }
++ return 0;
++}
+diff --git a/opcodes/nios2-opc.c b/opcodes/nios2-opc.c
+new file mode 100644
+index 0000000..c860207
+--- /dev/null
++++ b/opcodes/nios2-opc.c
+@@ -0,0 +1,320 @@
++/* nios2-opc.c -- Altera New Jersey opcode list.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include <stdio.h>
++#include "opcode/nios2.h"
++
++/* Register string table */
++
++const struct nios2_reg nios2_builtin_regs[] = {
++ {"zero", 0},
++ {"at", 1}, // assembler temporary
++ {"r2", 2},
++ {"r3", 3},
++ {"r4", 4},
++ {"r5", 5},
++ {"r6", 6},
++ {"r7", 7},
++ {"r8", 8},
++ {"r9", 9},
++ {"r10", 10},
++ {"r11", 11},
++ {"r12", 12},
++ {"r13", 13},
++ {"r14", 14},
++ {"r15", 15},
++ {"r16", 16},
++ {"r17", 17},
++ {"r18", 18},
++ {"r19", 19},
++ {"r20", 20},
++ {"r21", 21},
++ {"r22", 22},
++ {"r23", 23},
++ {"et", 24},
++ {"bt", 25},
++ {"gp", 26}, /* global pointer */
++ {"sp", 27}, /* stack pointer */
++ {"fp", 28}, /* frame pointer */
++ {"ea", 29}, /* exception return address */
++ {"ba", 30}, /* breakpoint return address */
++ {"ra", 31}, /* return address */
++
++ /* alternative names for special registers */
++ {"r0", 0},
++ {"r1", 1},
++ {"r24", 24},
++ {"r25", 25},
++ {"r26", 26},
++ {"r27", 27},
++ {"r28", 28},
++ {"r29", 29},
++ {"r30", 30},
++ {"r31", 31},
++
++ /* control register names */
++ {"status", 0},
++ {"estatus", 1},
++ {"bstatus", 2},
++ {"ienable", 3},
++ {"ipending", 4},
++ {"cpuid", 5},
++ {"ctl6", 6},
++ {"ctl7", 7},
++ {"pteaddr", 8},
++ {"tlbacc", 9},
++ {"tlbmisc", 10},
++ {"fstatus", 11},
++ {"ctl12", 12},
++ {"ctl13", 13},
++ {"ctl14", 14},
++ {"ctl15", 15},
++ {"ctl16", 16},
++ {"ctl17", 17},
++ {"ctl18", 18},
++ {"ctl19", 19},
++ {"ctl20", 20},
++ {"ctl21", 21},
++ {"ctl22", 22},
++ {"ctl23", 23},
++ {"ctl24", 24},
++ {"ctl25", 25},
++ {"ctl26", 26},
++ {"ctl27", 27},
++ {"ctl28", 28},
++ {"ctl29", 29},
++ {"ctl30", 30},
++ {"ctl31", 31},
++
++ /* alternative names for special control registers */
++ {"ctl0", 0},
++ {"ctl1", 1},
++ {"ctl2", 2},
++ {"ctl3", 3},
++ {"ctl4", 4},
++ {"ctl5", 5},
++ {"ctl8", 8},
++ {"ctl9", 9},
++ {"ctl10", 10},
++ {"ctl11", 11},
++
++ /* coprocessor register names */
++ {"c0", 0},
++ {"c1", 1},
++ {"c2", 2},
++ {"c3", 3},
++ {"c4", 4},
++ {"c5", 5},
++ {"c6", 6},
++ {"c7", 7},
++ {"c8", 8},
++ {"c9", 9},
++ {"c10", 10},
++ {"c11", 11},
++ {"c12", 12},
++ {"c13", 13},
++ {"c14", 14},
++ {"c15", 15},
++ {"c16", 16},
++ {"c17", 17},
++ {"c18", 18},
++ {"c19", 19},
++ {"c20", 20},
++ {"c21", 21},
++ {"c22", 22},
++ {"c23", 23},
++ {"c24", 24},
++ {"c25", 25},
++ {"c26", 26},
++ {"c27", 27},
++ {"c28", 28},
++ {"c29", 29},
++ {"c30", 30},
++ {"c31", 31},
++};
++
++#define NIOS2_NUM_REGS \
++ ((sizeof nios2_builtin_regs) / (sizeof (nios2_builtin_regs[0])))
++const int nios2_num_builtin_regs = NIOS2_NUM_REGS;
++
++/* const removed from the following to allow for dynamic extensions to the
++ * built-in instruction set. */
++struct nios2_reg *nios2_regs = (struct nios2_reg *) nios2_builtin_regs;
++int nios2_num_regs = NIOS2_NUM_REGS;
++#undef NIOS2_NUM_REGS
++
++/* overflow message string templates */
++
++char *overflow_msgs[] = {
++ "call target address 0x%08x out of range 0x%08x to 0x%08x",
++ "branch offset %d out of range %d to %d",
++ "%s offset %d out of range %d to %d",
++ "immediate value %d out of range %d to %d",
++ "immediate value %u out of range %u to %u",
++ "immediate value %u out of range %u to %u",
++ "custom instruction opcode %u out of range %u to %u",
++};
++
++
++
++/*--------------------------------------------------------------------------------
++ This is the opcode table used by the New Jersey GNU as, disassembler and GDB
++ --------------------------------------------------------------------------------*/
++
++/*
++ The following letters can appear in the args field of the nios2_opcode
++ structure:
++
++ c - a 5-bit control register index or break opcode
++ d - a 5-bit destination register index
++ s - a 5-bit left source register index
++ t - a 5-bit right source register index
++ i - a 16-bit signed immediate
++ u - a 16-bit unsigned immediate
++
++ j - a 5-bit unsigned immediate
++ k - a 6-bit unsigned immediate
++ l - an 8-bit unsigned immediate
++ m - a 26-bit unsigned immediate
++*/
++
++/* *INDENT-OFF* */
++/* FIXME: Re-format for GNU standards */
++const struct nios2_opcode nios2_builtin_opcodes[] =
++{
++ /* name, args, args_test num_args, match, mask, pinfo */
++ {"add", "d,s,t", "d,s,t,E", 3, OP_MATCH_ADD, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"addi", "t,s,i", "t,s,i,E", 3, OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_ADDI, signed_immed16_overflow },
++ {"subi", "t,s,i", "t,s,i,E", 3, OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"and", "d,s,t", "d,s,t,E", 3, OP_MATCH_AND, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"andhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ANDHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"andi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ANDI, OP_MASK_IOP, NIOS2_INSN_ANDI, unsigned_immed16_overflow },
++ {"beq", "s,t,o", "s,t,o,E", 3, OP_MATCH_BEQ, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bge", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgeu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgt", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgtu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"ble", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bleu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"blt", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bltu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bne", "s,t,o", "s,t,o,E", 3, OP_MATCH_BNE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"br", "o", "o,E", 1, OP_MATCH_BR, OP_MASK_IOP, NIOS2_INSN_UBRANCH, branch_target_overflow },
++ {"break", "b", "b,E", 1, OP_MATCH_BREAK, OP_MASK_BREAK, 0, no_overflow },
++ {"bret", "", "E", 0, OP_MATCH_BRET, OP_MASK, 0, no_overflow },
++ {"flushd", "i(s)", "i(s)E", 2, OP_MATCH_FLUSHD, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"flushda", "i(s)", "i(s)E", 2, OP_MATCH_FLUSHDA, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"flushi", "s", "s,E", 1, OP_MATCH_FLUSHI, OP_MASK_FLUSHI, 0, no_overflow },
++ {"flushp", "", "E", 0, OP_MATCH_FLUSHP, OP_MASK, 0, no_overflow },
++ {"initd", "i(s)", "i(s)E", 2, OP_MATCH_INITD, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"initi", "s", "s,E", 1, OP_MATCH_INITI, OP_MASK_INITI, 0, no_overflow },
++ {"call", "m", "m,E", 1, OP_MATCH_CALL, OP_MASK_IOP, NIOS2_INSN_CALL, call_target_overflow },
++ {"callr", "s", "s,E", 1, OP_MATCH_CALLR, OP_MASK_CALLR, 0, no_overflow },
++ {"cmpeq", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPEQ, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpeqi", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPEQI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpge", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpgei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPGEI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpgeu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpgeui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPGEUI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"cmpgt", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpgti", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPGEI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"cmpgtu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpgtui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPGEUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow },
++ {"cmple", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmplei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPLTI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"cmpleu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpleui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPLTUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow },
++ {"cmplt", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmplti", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPLTI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpltu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpltui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPLTUI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"cmpne", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPNE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpnei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPNEI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"div", "d,s,t", "d,s,t,E", 3, OP_MATCH_DIV, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"divu", "d,s,t", "d,s,t,E", 3, OP_MATCH_DIVU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"jmp", "s", "s,E", 1, OP_MATCH_JMP, OP_MASK_JMP, 0, no_overflow },
++ {"jmpi", "m", "m,E", 1, OP_MATCH_JMPI, OP_MASK_IOP, 0, no_overflow },
++ {"ldb", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDB, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbu", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBU, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbuio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBUIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldh", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDH, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhu", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHU, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhuio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHUIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldw", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDW, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldwio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDWIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"mov", "d,s", "d,s,E", 2, OP_MATCH_ADD, OP_MASK_RRT|OP_MASK_ROPX|OP_MASK_ROP, NIOS2_INSN_MACRO_MOV, no_overflow },
++ {"movhi", "t,u", "t,u,E", 2, OP_MATCH_ORHI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, unsigned_immed16_overflow },
++ {"movui", "t,u", "t,u,E", 2, OP_MATCH_ORI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, unsigned_immed16_overflow },
++ {"movi", "t,i", "t,i,E", 2, OP_MATCH_ADDI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, signed_immed16_overflow },
++ /* movia expands to two instructions so there is no mask or match */
++ {"movia", "t,o", "t,o,E", 2, OP_MATCH_ORHI, OP_MASK_IOP, NIOS2_INSN_MACRO_MOVIA, no_overflow },
++ {"mul", "d,s,t", "d,s,t,E", 3, OP_MATCH_MUL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"muli", "t,s,i", "t,s,i,E", 3, OP_MATCH_MULI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"mulxss", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXSS, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"mulxsu", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXSU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"mulxuu", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXUU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"nextpc", "d", "d,E", 1, OP_MATCH_NEXTPC, OP_MASK_NEXTPC, 0, no_overflow },
++ {"nop", "", "E", 0, OP_MATCH_ADD, OP_MASK, NIOS2_INSN_MACRO_MOV, no_overflow },
++ {"nor", "d,s,t", "d,s,t,E", 3, OP_MATCH_NOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"or", "d,s,t", "d,s,t,E", 3, OP_MATCH_OR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"orhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"ori", "t,s,u", "t,s,u,E", 3, OP_MATCH_ORI, OP_MASK_IOP, NIOS2_INSN_ORI, unsigned_immed16_overflow },
++ {"rdctl", "d,c", "d,c,E", 2, OP_MATCH_RDCTL, OP_MASK_RDCTL, 0, no_overflow },
++ {"ret", "", "E", 0, OP_MATCH_RET, OP_MASK, 0, no_overflow },
++ {"rol", "d,s,t", "d,s,t,E", 3, OP_MATCH_ROL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"roli", "d,s,j", "d,s,j,E", 3, OP_MATCH_ROLI, OP_MASK_ROLI, 0, unsigned_immed5_overflow },
++ {"ror", "d,s,t", "d,s,t,E", 3, OP_MATCH_ROR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"sll", "d,s,t", "d,s,t,E", 3, OP_MATCH_SLL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"slli", "d,s,j", "d,s,j,E", 3, OP_MATCH_SLLI, OP_MASK_SLLI, 0, unsigned_immed5_overflow },
++ {"sra", "d,s,t", "d,s,t,E", 3, OP_MATCH_SRA, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"srai", "d,s,j", "d,s,j,E", 3, OP_MATCH_SRAI, OP_MASK_SRAI, 0, unsigned_immed5_overflow },
++ {"srl", "d,s,t", "d,s,t,E", 3, OP_MATCH_SRL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"srli", "d,s,j", "d,s,j,E", 3, OP_MATCH_SRLI, OP_MASK_SRLI, 0, unsigned_immed5_overflow },
++ {"stb", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STB, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stbio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STBIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sth", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STH, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sthio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STHIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stw", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STW, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stwio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STWIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sub", "d,s,t", "d,s,t,E", 3, OP_MATCH_SUB, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"sync", "", "E", 0, OP_MATCH_SYNC, OP_MASK_SYNC, 0, no_overflow },
++ {"trap", "", "E", 0, OP_MATCH_TRAP, OP_MASK_TRAP, 0, no_overflow },
++ {"eret", "", "E", 0, OP_MATCH_ERET, OP_MASK, 0, no_overflow },
++ {"custom", "l,d,s,t", "l,d,s,t,E", 4, OP_MATCH_CUSTOM, OP_MASK_ROP, 0, custom_opcode_overflow },
++ {"wrctl", "c,s", "c,s,E", 2, OP_MATCH_WRCTL, OP_MASK_WRCTL, 0, no_overflow },
++ {"xor", "d,s,t", "d,s,t,E", 3, OP_MATCH_XOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"xorhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_XORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"xori", "t,s,u", "t,s,u,E", 3, OP_MATCH_XORI, OP_MASK_IOP, NIOS2_INSN_XORI, unsigned_immed16_overflow }
++};
++/* *INDENT-ON* */
++
++#define NIOS2_NUM_OPCODES \
++ ((sizeof nios2_builtin_opcodes) / (sizeof (nios2_builtin_opcodes[0])))
++const int bfd_nios2_num_builtin_opcodes = NIOS2_NUM_OPCODES;
++
++/* const removed from the following to allow for dynamic extensions to the
++ * built-in instruction set. */
++struct nios2_opcode *nios2_opcodes =
++ (struct nios2_opcode *) nios2_builtin_opcodes;
++int bfd_nios2_num_opcodes = NIOS2_NUM_OPCODES;
++#undef NIOS2_NUM_OPCODES
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/100-uclibc-conf.patch
new file mode 100644
index 0000000000..7c0a72693f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/100-uclibc-conf.patch
@@ -0,0 +1,586 @@
+diff -ur binutils-2.15.97.orig/bfd/config.bfd binutils-2.15.97/bfd/config.bfd
+--- binutils-2.15.97.orig/bfd/config.bfd 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/bfd/config.bfd 2005-04-29 20:53:50.000000000 -0400
+@@ -140,7 +140,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -150,7 +150,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -227,7 +227,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -235,7 +235,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-* | arm*-*-conix* | \
+ arm*-*-uclinux* | arm-*-kfreebsd*-gnu | \
+ arm*-*-eabi* )
+ targ_defvec=bfd_elf32_littlearm_vec
+@@ -385,7 +385,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -396,7 +396,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu*)
++ hppa*-*-linux-*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -529,7 +529,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -543,7 +543,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -719,7 +719,7 @@
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-*)
+ targ_defvec=bfd_elf32_m68k_vec
+ targ_selvecs=m68klinux_vec
+ ;;
+@@ -1005,7 +1005,7 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
++ powerpc-*-solaris2* | powerpc-*-linux-* | powerpc-*-rtems* | \
+ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+@@ -1042,7 +1042,7 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
++ powerpcle-*-solaris2* | powerpcle-*-linux-* | powerpcle-*-vxworks* |\
+ powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+@@ -1213,7 +1213,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1260,7 +1260,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+@@ -1329,7 +1329,7 @@
+ targ_underscore=yes
+ ;;
+
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ targ_defvec=bfd_elf32_vax_vec
+ ;;
+
+diff -ur binutils-2.15.97.orig/bfd/configure binutils-2.15.97/bfd/configure
+--- binutils-2.15.97.orig/bfd/configure 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/bfd/configure 2005-04-29 20:53:50.000000000 -0400
+@@ -9918,7 +9918,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -9982,7 +9982,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -10020,7 +10020,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -10154,7 +10154,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -ur binutils-2.15.97.orig/bfd/configure.in binutils-2.15.97/bfd/configure.in
+--- binutils-2.15.97.orig/bfd/configure.in 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/bfd/configure.in 2005-04-29 20:53:50.000000000 -0400
+@@ -163,7 +163,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -248,7 +248,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -289,7 +289,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -375,7 +375,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -ur binutils-2.15.97.orig/gas/configure binutils-2.15.97/gas/configure
+--- binutils-2.15.97.orig/gas/configure 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/gas/configure 2005-04-29 20:53:50.000000000 -0400
+@@ -4462,7 +4462,7 @@
+ _ACEOF
+
+ ;;
+- ppc-*-linux-gnu*)
++ ppc-*-linux-*)
+ case "$endian" in
+ big) ;;
+ *) { { echo "$as_me:$LINENO: error: GNU/Linux must be configured big endian" >&5
+diff -ur binutils-2.15.97.orig/gas/configure.in binutils-2.15.97/gas/configure.in
+--- binutils-2.15.97.orig/gas/configure.in 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/gas/configure.in 2005-04-29 20:53:50.000000000 -0400
+@@ -161,7 +161,7 @@
+ AC_DEFINE(AIX_WEAK_SUPPORT, 1,
+ [Define if using AIX 5.2 value for C_WEAKEXT.])
+ ;;
+- ppc-*-linux-gnu*)
++ ppc-*-linux-*)
+ case "$endian" in
+ big) ;;
+ *) AC_MSG_ERROR(GNU/Linux must be configured big endian) ;;
+diff -ur binutils-2.15.97.orig/gas/configure.tgt binutils-2.15.97/gas/configure.tgt
+--- binutils-2.15.97.orig/gas/configure.tgt 2005-04-29 20:48:14.000000000 -0400
++++ binutils-2.15.97/gas/configure.tgt 2005-04-29 20:53:50.000000000 -0400
+@@ -100,7 +100,7 @@
+ alpha-*-*vms*) fmt=evax ;;
+ alpha-*-osf*) fmt=ecoff ;;
+ alpha-*-linuxecoff*) fmt=ecoff ;;
+- alpha-*-linux-gnu*) fmt=elf em=linux ;;
++ alpha-*-linux-*) fmt=elf em=linux ;;
+ alpha-*-netbsd*) fmt=elf em=nbsd ;;
+ alpha-*-openbsd*) fmt=elf em=obsd ;;
+
+@@ -116,7 +116,7 @@
+ arm-*-conix*) fmt=elf ;;
+ arm-*-linux*aout*) fmt=aout em=linux ;;
+ arm-*-linux-gnueabi*) fmt=elf em=armlinuxeabi ;;
+- arm-*-linux-gnu*) fmt=elf em=linux ;;
++ arm-*-linux-*) fmt=elf em=linux ;;
+ arm-*-uclinux*) fmt=elf em=linux ;;
+ arm-*-netbsdelf*) fmt=elf em=nbsd ;;
+ arm-*-*n*bsd*) fmt=aout em=nbsd ;;
+@@ -128,7 +128,7 @@
+
+ avr-*-*) fmt=elf ;;
+
+- cris-*-linux-gnu* | crisv32-*-linux-gnu*)
++ cris-*-linux-* | crisv32-*-linux-*)
+ fmt=multi bfd_gas=yes em=linux ;;
+ cris-*-* | crisv32-*-*) fmt=multi bfd_gas=yes ;;
+
+@@ -192,7 +192,7 @@
+ i386-*-linux*aout*) fmt=aout em=linux ;;
+ i386-*-linux*oldld) fmt=aout em=linux ;;
+ i386-*-linux*coff*) fmt=coff em=linux ;;
+- i386-*-linux-gnu*) fmt=elf em=linux ;;
++ i386-*-linux-*) fmt=elf em=linux ;;
+ i386-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+ i386-*-sysv[45]*) fmt=elf ;;
+ i386-*-solaris*) fmt=elf ;;
+@@ -238,7 +238,7 @@
+
+ ia64-*-elf*) fmt=elf ;;
+ ia64-*-aix*) fmt=elf em=ia64aix ;;
+- ia64-*-linux-gnu*) fmt=elf em=linux ;;
++ ia64-*-linux-*) fmt=elf em=linux ;;
+ ia64-*-hpux*) fmt=elf em=hpux ;;
+ ia64-*-netbsd*) fmt=elf em=nbsd ;;
+
+@@ -265,7 +265,7 @@
+ m68k-*-rtems*) fmt=elf ;;
+ m68k-*-hpux*) fmt=hp300 em=hp300 ;;
+ m68k-*-linux*aout*) fmt=aout em=linux ;;
+- m68k-*-linux-gnu*) fmt=elf em=linux ;;
++ m68k-*-linux-*) fmt=elf em=linux ;;
+ m68k-*-uclinux*) fmt=elf ;;
+ m68k-*-gnu*) fmt=elf ;;
+ m68k-*-netbsdelf*) fmt=elf em=nbsd ;;
+@@ -332,7 +332,7 @@
+ ppc-*-beos*) fmt=coff ;;
+ ppc-*-*n*bsd* | ppc-*-elf*) fmt=elf ;;
+ ppc-*-eabi* | ppc-*-sysv4*) fmt=elf ;;
+- ppc-*-linux-gnu*) fmt=elf em=linux ;;
++ ppc-*-linux-*) fmt=elf em=linux ;;
+ ppc-*-solaris*) fmt=elf ;;
+ ppc-*-rtems*) fmt=elf ;;
+ ppc-*-macos*) fmt=coff em=macos ;;
+@@ -340,7 +340,7 @@
+ ppc-*-kaos*) fmt=elf ;;
+ ppc-*-lynxos*) fmt=elf em=lynx bfd_gas=yes ;;
+
+- s390-*-linux-gnu*) fmt=elf em=linux ;;
++ s390-*-linux-*) fmt=elf em=linux ;;
+ s390-*-tpf*) fmt=elf ;;
+
+ sh*-*-linux*) fmt=elf em=linux
+@@ -369,7 +369,7 @@
+ sparc-*-aout | sparc*-*-vxworks*) fmt=aout em=sparcaout ;;
+ sparc-*-coff) fmt=coff ;;
+ sparc-*-linux*aout*) fmt=aout em=linux ;;
+- sparc-*-linux-gnu*) fmt=elf em=linux ;;
++ sparc-*-linux-*) fmt=elf em=linux ;;
+ sparc-fujitsu-none) fmt=aout ;;
+ sparc-*-elf) fmt=elf ;;
+ sparc-*-sysv4*) fmt=elf ;;
+@@ -398,7 +398,7 @@
+ vax-*-netbsdelf*) fmt=elf em=nbsd ;;
+ vax-*-netbsd*) fmt=aout em=nbsd ;;
+ vax-*-bsd* | vax-*-ultrix*) fmt=aout ;;
+- vax-*-linux-gnu*) fmt=elf em=linux bfd_gas=yes ;;
++ vax-*-linux-*) fmt=elf em=linux bfd_gas=yes ;;
+
+ w65-*-*) fmt=coff ;;
+
+diff -ur binutils-2.15.97.orig/ld/configure.host binutils-2.15.97/ld/configure.host
+--- binutils-2.15.97.orig/ld/configure.host 2005-04-29 20:48:15.000000000 -0400
++++ binutils-2.15.97/ld/configure.host 2005-04-29 20:53:50.000000000 -0400
+@@ -83,7 +83,7 @@
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,ld\[^ \]\*,ld-linux,g"`
+ ;;
+
+-arm*-*-linux-gnu*)
++arm*-*-linux-*)
+ HOSTING_CRT0='-p '`echo "$HOSTING_CRT0" | sed -e "s,ld\[^ \]\*,ld-linux,g"`
+ ;;
+
+@@ -141,7 +141,7 @@
+ HOSTING_LIBS="$HOSTING_LIBS"' -lcygwin -L/usr/lib/w32api -luser32 -lkernel32 -ladvapi32 -lshell32 `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else ${CC} -print-libgcc-file-name; fi`'
+ ;;
+
+-ia64-*-linux-gnu*)
++ia64-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,ld\[^ \]*\*,ld-linux-ia64,g"`
+ ;;
+
+@@ -155,11 +155,11 @@
+ HOSTING_LIBS='-L/usr/lib32 '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o ; else ${CC} -print-file-name=crtend.o; fi` /usr/lib32/crtn.o -init __do_global_ctors -fini __do_global_dtors'
+ ;;
+
+-mips*-*-linux-gnu*)
++mips*-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld.so.1,"`
+ ;;
+
+-m68*-*-linux-gnu*)
++m68*-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld.so.1,"`
+ ;;
+
+@@ -183,19 +183,19 @@
+ HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi`'
+ ;;
+
+-powerpc64*-*-linux-gnu*)
++powerpc64*-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib64/ld64.so.1,"`
+ ;;
+
+-powerpc*-*-linux-gnu*)
++powerpc*-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld.so.1,"`
+ ;;
+
+-s390x-*-linux-gnu*)
++s390x-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld64.so.1,"`
+ ;;
+
+-s390-*-linux-gnu*)
++s390-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld.so.1,"`
+ ;;
+
+@@ -209,15 +209,15 @@
+ HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
+ ;;
+
+-sparc-*-linux-gnu*)
++sparc-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib/ld-linux.so.2,"`
+ ;;
+
+-sparc64-*-linux-gnu*)
++sparc64-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib64/ld-linux.so.2,"`
+ ;;
+
+-x86_64-*-linux-gnu*)
++x86_64-*-linux-*)
+ HOSTING_CRT0=`echo "$HOSTING_CRT0" | sed -e "s,\\\`specs.*\"\\\`,/lib64/ld-linux-x86-64.so.2,"`
+ ;;
+
+diff -ur binutils-2.15.97.orig/ld/configure.tgt binutils-2.15.97/ld/configure.tgt
+--- binutils-2.15.97.orig/ld/configure.tgt 2005-04-29 20:48:15.000000000 -0400
++++ binutils-2.15.97/ld/configure.tgt 2005-04-29 20:53:50.000000000 -0400
+@@ -30,7 +30,7 @@
+ cris-*-*aout*) targ_emul=crisaout
+ targ_extra_emuls="criself crislinux"
+ targ_extra_libpath=$targ_extra_emuls ;;
+-cris-*-linux-gnu* | cris-*-linux-gnu*)
++cris-*-linux-* | crisv32-*-linux-*)
+ targ_emul=crislinux ;;
+ cris-*-* | crisv32-*-*) targ_emul=criself
+ targ_extra_emuls="crisaout crislinux"
+@@ -62,14 +62,14 @@
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'`
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc64-*-linux-gnu*) targ_emul=elf64_sparc
++sparc64-*-linux-*) targ_emul=elf64_sparc
+ targ_extra_emuls="elf32_sparc sparclinux sun4"
+ targ_extra_libpath=elf32_sparc
+ tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/64//'`
+ tdir_sparclinux=${tdir_elf32_sparc}aout
+ tdir_sun4=sparc-sun-sunos4
+ ;;
+-sparc*-*-linux-gnu*) targ_emul=elf32_sparc
++sparc*-*-linux-*) targ_emul=elf32_sparc
+ targ_extra_emuls="sparclinux elf64_sparc sun4"
+ targ_extra_libpath=elf64_sparc
+ tdir_sparclinux=${targ_alias}aout
+@@ -119,8 +119,8 @@
+ ia64-*-aix*) targ_emul=elf64_aix ;;
+ m32r*le-*-elf*) targ_emul=m32rlelf ;;
+ m32r*-*-elf*) targ_emul=m32relf ;;
+-m32r*le-*-linux-gnu*) targ_emul=m32rlelf_linux ;;
+-m32r*-*-linux-gnu*) targ_emul=m32relf_linux ;;
++m32r*le-*-linux-*) targ_emul=m32rlelf_linux ;;
++m32r*-*-linux-*) targ_emul=m32relf_linux ;;
+ m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
+ targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
+ m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
+@@ -131,7 +131,7 @@
+ m68*-apple-aux*) targ_emul=m68kaux ;;
+ maxq-*-coff) targ_emul=maxqcoff;;
+ *-tandem-none) targ_emul=st2000 ;;
+-i370-*-elf* | i370-*-linux-gnu*) targ_emul=elf32i370 ;;
++i370-*-elf* | i370-*-linux-*) targ_emul=elf32i370 ;;
+ i[3-7]86-*-nto-qnx*) targ_emul=i386nto ;;
+ i[3-7]86-*-vsta) targ_emul=vsta ;;
+ i[3-7]86-go32-rtems*) targ_emul=i386go32 ;;
+@@ -155,14 +155,14 @@
+ tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+ i[3-7]86-*-linux*oldld) targ_emul=i386linux; targ_extra_emuls=elf_i386 ;;
+-i[3-7]86-*-linux-gnu*) targ_emul=elf_i386
++i[3-7]86-*-linux-*) targ_emul=elf_i386
+ targ_extra_emuls=i386linux
+ if test x${want64} = xtrue; then
+ targ_extra_emuls="$targ_extra_emuls elf_x86_64"
+ fi
+ tdir_i386linux=${targ_alias}aout
+ ;;
+-x86_64-*-linux-gnu*) targ_emul=elf_x86_64
++x86_64-*-linux-*) targ_emul=elf_x86_64
+ targ_extra_emuls="elf_i386 i386linux"
+ targ_extra_libpath=elf_i386
+ tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
+@@ -262,13 +262,13 @@
+ arm-*-kaos*) targ_emul=armelf ;;
+ arm9e-*-elf) targ_emul=armelf ;;
+ arm*b-*-linux-gnueabi) targ_emul=armelfb_linux_eabi ;;
+-arm*b-*-linux-gnu*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
++arm*b-*-linux-*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
+ arm*-*-linux-gnueabi) targ_emul=armelf_linux_eabi ;;
+-arm*-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++arm*-*-linux-*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm*-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ arm-*-vxworks) targ_emul=armelf_vxworks ;;
+ arm*-*-conix*) targ_emul=armelf ;;
+-thumb-*-linux-gnu* | thumb-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
++thumb-*-linux-* | thumb-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
+ strongarm-*-coff) targ_emul=armcoff ;;
+ strongarm-*-elf) targ_emul=armelf ;;
+ strongarm-*-kaos*) targ_emul=armelf ;;
+@@ -372,7 +372,7 @@
+ targ_extra_emuls=m68kelf
+ tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'`
+ ;;
+-m68k-*-linux-gnu*) targ_emul=m68kelf
++m68k-*-linux-*) targ_emul=m68kelf
+ targ_extra_emuls=m68klinux
+ tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'`
+ ;;
+@@ -388,9 +388,9 @@
+ m68*-*-psos*) targ_emul=m68kpsos ;;
+ m68*-*-rtemscoff*) targ_emul=m68kcoff ;;
+ m68*-*-rtems*) targ_emul=m68kelf ;;
+-hppa*64*-*-linux-gnu*) targ_emul=hppa64linux ;;
++hppa*64*-*-linux-*) targ_emul=hppa64linux ;;
+ hppa*64*-*) targ_emul=elf64hppa ;;
+-hppa*-*-linux-gnu*) targ_emul=hppalinux ;;
++hppa*-*-linux-*) targ_emul=hppalinux ;;
+ hppa*-*-*elf*) targ_emul=hppaelf ;;
+ hppa*-*-lites*) targ_emul=hppaelf ;;
+ hppa*-*-netbsd*) targ_emul=hppanbsd ;;
+@@ -402,7 +402,7 @@
+ vax-*-netbsdaout* | vax-*-netbsd*)
+ targ_emul=vaxnbsd
+ targ_extra_emuls=elf32vax ;;
+-vax-*-linux-gnu*) targ_emul=elf32vax ;;
++vax-*-linux-*) targ_emul=elf32vax ;;
+ mips*-*-pe) targ_emul=mipspe ;
+ targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+ mips*-dec-ultrix*) targ_emul=mipslit ;;
+@@ -436,18 +436,18 @@
+ mips*-*-vxworks*) targ_emul=elf32ebmip
+ targ_extra_emuls="elf32elmip" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-gnu*) targ_emul=elf32ltsmipn32
++mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
+ targ_extra_libpath="elf32ltsmip elf64ltsmip"
+ ;;
+-mips64*-*-linux-gnu*) targ_emul=elf32btsmipn32
++mips64*-*-linux-*) targ_emul=elf32btsmipn32
+ targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
+ targ_extra_libpath="elf32btsmip elf64btsmip"
+ ;;
+-mips*el-*-linux-gnu*) targ_emul=elf32ltsmip
++mips*el-*-linux-*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
+ ;;
+-mips*-*-linux-gnu*) targ_emul=elf32btsmip
++mips*-*-linux-*) targ_emul=elf32btsmip
+ targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
+ ;;
+ mips*-*-lnews*) targ_emul=mipslnews ;;
+@@ -467,7 +467,7 @@
+ alpha*-*-linuxecoff*) targ_emul=alpha targ_extra_emuls=elf64alpha
+ tdir_elf64alpha=`echo ${targ_alias} | sed -e 's/ecoff//'`
+ ;;
+-alpha*-*-linux-gnu*) targ_emul=elf64alpha targ_extra_emuls=alpha
++alpha*-*-linux-*) targ_emul=elf64alpha targ_extra_emuls=alpha
+ tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'`
+ ;;
+ alpha*-*-osf*) targ_emul=alpha ;;
+diff -ur binutils-2.15.97.orig/ld/emultempl/elf32.em binutils-2.15.97/ld/emultempl/elf32.em
+--- binutils-2.15.97.orig/ld/emultempl/elf32.em 2005-04-29 20:48:15.000000000 -0400
++++ binutils-2.15.97/ld/emultempl/elf32.em 2005-04-29 20:53:50.000000000 -0400
+@@ -65,7 +65,7 @@
+
+ if [ "x${USE_LIBPATH}" = xyes ] ; then
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ #ifdef HAVE_GLOB
+ #include <glob.h>
+@@ -350,7 +350,7 @@
+
+ EOF
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ {
+ struct bfd_link_needed_list *l;
+@@ -522,7 +522,7 @@
+
+ EOF
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ /* For a native linker, check the file /etc/ld.so.conf for directories
+ in which we may find shared libraries. /etc/ld.so.conf is really
+@@ -932,7 +932,7 @@
+ EOF
+ if [ "x${USE_LIBPATH}" = xyes ] ; then
+ case ${target} in
+- *-*-linux-gnu*)
++ *-*-linux-*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
+ break;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch
new file mode 100644
index 0000000000..ec38caa125
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch
@@ -0,0 +1,218 @@
+diff -urN binutils-2.16.90.0.2-dist/bfd/configure binutils-2.16.90.0.2/bfd/configure
+--- binutils-2.16.90.0.2-dist/bfd/configure 2005-04-29 12:50:24.000000000 -0500
++++ binutils-2.16.90.0.2/bfd/configure 2005-04-30 11:34:59.246377032 -0500
+@@ -3584,6 +3584,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/binutils/configure binutils-2.16.90.0.2/binutils/configure
+--- binutils-2.16.90.0.2-dist/binutils/configure 2005-04-29 12:50:26.000000000 -0500
++++ binutils-2.16.90.0.2/binutils/configure 2005-04-30 11:35:28.900868864 -0500
+@@ -1577,6 +1577,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/configure binutils-2.16.90.0.2/configure
+--- binutils-2.16.90.0.2-dist/configure 2005-04-29 12:50:23.000000000 -0500
++++ binutils-2.16.90.0.2/configure 2005-04-30 11:31:12.525843792 -0500
+@@ -1111,7 +1111,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+diff -urN binutils-2.16.90.0.2-dist/configure.in binutils-2.16.90.0.2/configure.in
+--- binutils-2.16.90.0.2-dist/configure.in 2005-04-29 12:50:23.000000000 -0500
++++ binutils-2.16.90.0.2/configure.in 2005-04-30 11:29:51.643139832 -0500
+@@ -328,7 +328,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+diff -urN binutils-2.16.90.0.2-dist/gas/configure binutils-2.16.90.0.2/gas/configure
+--- binutils-2.16.90.0.2-dist/gas/configure 2005-04-29 12:50:27.000000000 -0500
++++ binutils-2.16.90.0.2/gas/configure 2005-04-30 11:35:21.097055224 -0500
+@@ -3421,6 +3421,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/gas/testsuite/gas/sh/basic.exp binutils-2.16.90.0.2/gas/testsuite/gas/sh/basic.exp
+--- binutils-2.16.90.0.2-dist/gas/testsuite/gas/sh/basic.exp 2005-04-09 14:03:14.000000000 -0500
++++ binutils-2.16.90.0.2/gas/testsuite/gas/sh/basic.exp 2005-04-30 11:41:57.301822944 -0500
+@@ -20,7 +20,7 @@
+
+ # Written by Cygnus Support.
+
+-if [istarget "sh*-*-linux-gnu"] {
++if {[istarget "sh*-*-linux-gnu"] || [istarget "sh*-*-linux-uclibc"]} {
+ global ASFLAGS
+ set ASFLAGS "$ASFLAGS -big"
+ }
+diff -urN binutils-2.16.90.0.2-dist/gprof/configure binutils-2.16.90.0.2/gprof/configure
+--- binutils-2.16.90.0.2-dist/gprof/configure 2005-04-29 12:50:29.000000000 -0500
++++ binutils-2.16.90.0.2/gprof/configure 2005-04-30 11:35:36.880655752 -0500
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/ld/configure binutils-2.16.90.0.2/ld/configure
+--- binutils-2.16.90.0.2-dist/ld/configure 2005-04-29 12:50:30.000000000 -0500
++++ binutils-2.16.90.0.2/ld/configure 2005-04-30 11:46:15.974498720 -0500
+@@ -1581,6 +1581,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/ld/testsuite/ld-sh/sh.exp binutils-2.16.90.0.2/ld/testsuite/ld-sh/sh.exp
+--- binutils-2.16.90.0.2-dist/ld/testsuite/ld-sh/sh.exp 2005-04-09 14:03:29.000000000 -0500
++++ binutils-2.16.90.0.2/ld/testsuite/ld-sh/sh.exp 2005-04-30 11:45:07.890849008 -0500
+@@ -62,7 +62,7 @@
+
+ set testsrec "SH relaxing to S-records"
+
+-if [istarget sh*-linux-gnu] {
++if {[istarget sh*-linux-gnu] || [istarget sh*-*-linux-uclibc]} {
+ # This target needs the explicit entry address.
+ catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
+ set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
+@@ -117,7 +117,7 @@
+ return
+ }
+
+-if [istarget sh*-linux-gnu] {
++if {[istarget sh*-linux-gnu] || [istarget sh*-*-linux-uclibc]} {
+ exec sed -e s/_main/main/ -e s/_trap/trap/ -e s/_stack/stack/ \
+ < $srcdir/$subdir/start.s >tmpdir/start.s
+ } else {
+diff -urN binutils-2.16.90.0.2-dist/ld/testsuite/ld-srec/srec.exp binutils-2.16.90.0.2/ld/testsuite/ld-srec/srec.exp
+--- binutils-2.16.90.0.2-dist/ld/testsuite/ld-srec/srec.exp 2005-04-29 12:50:30.000000000 -0500
++++ binutils-2.16.90.0.2/ld/testsuite/ld-srec/srec.exp 2005-04-30 11:44:26.358162936 -0500
+@@ -385,7 +385,7 @@
+ setup_xfail "v850*-*-elf"
+
+ # The S-record linker doesn't handle Alpha Elf relaxation.
+-setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*"
++setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*" "alpha*-*-linux-uclibc*"
+ setup_xfail "alpha*-*-netbsd*"
+
+ # The S-record linker hasn't any hope of coping with HPPA relocs.
+@@ -424,7 +424,7 @@
+ setup_xfail "thumb-*-*"
+ setup_xfail "powerpc*-*-eabi*"
+ setup_xfail "v850*-*-elf"
+-setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*"
++setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*" "alpha*-*-linux-uclibc*"
+ setup_xfail "alpha*-*-netbsd*"
+ setup_xfail "hppa*-*-*"
+ setup_xfail "ia64-*-*"
+diff -urN binutils-2.16.90.0.2-dist/libtool.m4 binutils-2.16.90.0.2/libtool.m4
+--- binutils-2.16.90.0.2-dist/libtool.m4 2004-07-27 23:36:06.000000000 -0500
++++ binutils-2.16.90.0.2/libtool.m4 2005-04-30 11:35:54.062043784 -0500
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -urN binutils-2.16.90.0.2-dist/ltconfig binutils-2.16.90.0.2/ltconfig
+--- binutils-2.16.90.0.2-dist/ltconfig 2004-11-22 14:33:30.000000000 -0600
++++ binutils-2.16.90.0.2/ltconfig 2005-04-30 11:22:10.594229920 -0500
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1270,6 +1271,23 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -urN binutils-2.16.90.0.2-dist/opcodes/configure binutils-2.16.90.0.2/opcodes/configure
+--- binutils-2.16.90.0.2-dist/opcodes/configure 2005-04-29 12:50:31.000000000 -0500
++++ binutils-2.16.90.0.2/opcodes/configure 2005-04-30 11:17:07.168357664 -0500
+@@ -3588,6 +3588,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..b25d5b7e21
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch
@@ -0,0 +1,52 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am binutils-2.14.90.0.6/ld/Makefile.am
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.am 2003-09-10 23:12:09.000000000 +0100
+@@ -19,7 +19,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in binutils-2.14.90.0.6/ld/Makefile.in
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.in 2003-09-10 23:12:09.000000000 +0100
+@@ -128,7 +128,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.1/sh-flags-off-by-one.patch b/cleopatre/buildroot/toolchain/binutils/2.16.1/sh-flags-off-by-one.patch
new file mode 100644
index 0000000000..19a2f54cab
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.1/sh-flags-off-by-one.patch
@@ -0,0 +1,21 @@
+2005-08-25 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * elf32-sh.c (sh_elf_get_flags_from_mach): Fix off-by-one error.
+
+Index: bfd/elf32-sh.c
+===================================================================
+RCS file: /cvs/src/src/bfd/elf32-sh.c,v
+retrieving revision 1.128
+retrieving revision 1.129
+diff -u -p -r1.128 -r1.129
+--- binutils/bfd/elf32-sh.c 25 Aug 2005 02:32:10 -0000 1.128
++++ binutils/bfd/elf32-sh.c 25 Aug 2005 05:10:22 -0000 1.129
+@@ -6655,7 +6655,7 @@ sh_elf_set_mach_from_flags (bfd *abfd)
+ int
+ sh_elf_get_flags_from_mach (unsigned long mach)
+ {
+- int i = ARRAY_SIZE (sh_ef_bfd_table);
++ int i = ARRAY_SIZE (sh_ef_bfd_table) - 1;
+
+ for (; i>0; i--)
+ if (sh_ef_bfd_table[i] == mach)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch
new file mode 100644
index 0000000000..997284c567
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+diff -urN binutils-2.16.90.0.2-dist/bfd/configure binutils-2.16.90.0.2/bfd/configure
+--- binutils-2.16.90.0.2-dist/bfd/configure 2005-04-29 12:50:24.000000000 -0500
++++ binutils-2.16.90.0.2/bfd/configure 2005-04-30 11:34:59.246377032 -0500
+@@ -3584,6 +3584,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/binutils/configure binutils-2.16.90.0.2/binutils/configure
+--- binutils-2.16.90.0.2-dist/binutils/configure 2005-04-29 12:50:26.000000000 -0500
++++ binutils-2.16.90.0.2/binutils/configure 2005-04-30 11:35:28.900868864 -0500
+@@ -1577,6 +1577,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/configure binutils-2.16.90.0.2/configure
+--- binutils-2.16.90.0.2-dist/configure 2005-04-29 12:50:23.000000000 -0500
++++ binutils-2.16.90.0.2/configure 2005-04-30 11:31:12.525843792 -0500
+@@ -1111,7 +1111,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -1207,7 +1207,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1495,7 +1495,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+diff -urN binutils-2.16.90.0.2-dist/configure.in binutils-2.16.90.0.2/configure.in
+--- binutils-2.16.90.0.2-dist/configure.in 2005-04-29 12:50:23.000000000 -0500
++++ binutils-2.16.90.0.2/configure.in 2005-04-30 11:29:51.643139832 -0500
+@@ -328,7 +328,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -424,7 +424,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -712,7 +712,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+diff -urN binutils-2.16.90.0.2-dist/gas/configure binutils-2.16.90.0.2/gas/configure
+--- binutils-2.16.90.0.2-dist/gas/configure 2005-04-29 12:50:27.000000000 -0500
++++ binutils-2.16.90.0.2/gas/configure 2005-04-30 11:35:21.097055224 -0500
+@@ -3421,6 +3421,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/gprof/configure binutils-2.16.90.0.2/gprof/configure
+--- binutils-2.16.90.0.2-dist/gprof/configure 2005-04-29 12:50:29.000000000 -0500
++++ binutils-2.16.90.0.2/gprof/configure 2005-04-30 11:35:36.880655752 -0500
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/ld/configure binutils-2.16.90.0.2/ld/configure
+--- binutils-2.16.90.0.2-dist/ld/configure 2005-04-29 12:50:30.000000000 -0500
++++ binutils-2.16.90.0.2/ld/configure 2005-04-30 11:46:15.974498720 -0500
+@@ -1581,6 +1581,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN binutils-2.16.90.0.2-dist/libtool.m4 binutils-2.16.90.0.2/libtool.m4
+--- binutils-2.16.90.0.2-dist/libtool.m4 2004-07-27 23:36:06.000000000 -0500
++++ binutils-2.16.90.0.2/libtool.m4 2005-04-30 11:35:54.062043784 -0500
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -urN binutils-2.16.90.0.2-dist/ltconfig binutils-2.16.90.0.2/ltconfig
+--- binutils-2.16.90.0.2-dist/ltconfig 2004-11-22 14:33:30.000000000 -0600
++++ binutils-2.16.90.0.2/ltconfig 2005-04-30 11:22:10.594229920 -0500
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1270,6 +1271,23 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -urN binutils-2.16.90.0.2-dist/opcodes/configure binutils-2.16.90.0.2/opcodes/configure
+--- binutils-2.16.90.0.2-dist/opcodes/configure 2005-04-29 12:50:31.000000000 -0500
++++ binutils-2.16.90.0.2/opcodes/configure 2005-04-30 11:17:07.168357664 -0500
+@@ -3588,6 +3588,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..b25d5b7e21
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch
@@ -0,0 +1,52 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am binutils-2.14.90.0.6/ld/Makefile.am
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.am 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.am 2003-09-10 23:12:09.000000000 +0100
+@@ -19,7 +19,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in binutils-2.14.90.0.6/ld/Makefile.in
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/ld/Makefile.in 2003-08-21 16:28:48.000000000 +0100
++++ binutils-2.14.90.0.6/ld/Makefile.in 2003-09-10 23:12:09.000000000 +0100
+@@ -128,7 +128,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/sh-flags-off-by-one.patch b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/sh-flags-off-by-one.patch
new file mode 100644
index 0000000000..19a2f54cab
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.90.0.3/sh-flags-off-by-one.patch
@@ -0,0 +1,21 @@
+2005-08-25 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * elf32-sh.c (sh_elf_get_flags_from_mach): Fix off-by-one error.
+
+Index: bfd/elf32-sh.c
+===================================================================
+RCS file: /cvs/src/src/bfd/elf32-sh.c,v
+retrieving revision 1.128
+retrieving revision 1.129
+diff -u -p -r1.128 -r1.129
+--- binutils/bfd/elf32-sh.c 25 Aug 2005 02:32:10 -0000 1.128
++++ binutils/bfd/elf32-sh.c 25 Aug 2005 05:10:22 -0000 1.129
+@@ -6655,7 +6655,7 @@ sh_elf_set_mach_from_flags (bfd *abfd)
+ int
+ sh_elf_get_flags_from_mach (unsigned long mach)
+ {
+- int i = ARRAY_SIZE (sh_ef_bfd_table);
++ int i = ARRAY_SIZE (sh_ef_bfd_table) - 1;
+
+ for (; i>0; i--)
+ if (sh_ef_bfd_table[i] == mach)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4c72f330f1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+diff -Nurp binutils-2.16.91.0.2.orig/bfd/configure binutils-2.16.91.0.2/bfd/configure
+--- binutils-2.16.91.0.2.orig/bfd/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/bfd/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3585,6 +3585,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/binutils/configure binutils-2.16.91.0.2/binutils/configure
+--- binutils-2.16.91.0.2.orig/binutils/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/binutils/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3420,6 +3420,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/configure binutils-2.16.91.0.2/configure
+--- binutils-2.16.91.0.2.orig/configure 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -1130,7 +1130,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -1235,7 +1235,7 @@ case "${target}" in
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1530,7 +1530,7 @@ case "${target}" in
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+diff -Nurp binutils-2.16.91.0.2.orig/configure.in binutils-2.16.91.0.2/configure.in
+--- binutils-2.16.91.0.2.orig/configure.in 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/configure.in 2005-08-02 00:17:47.000000000 -0400
+@@ -341,7 +341,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -446,7 +446,7 @@ case "${target}" in
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -741,7 +741,7 @@ case "${target}" in
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+diff -Nurp binutils-2.16.91.0.2.orig/gas/configure binutils-2.16.91.0.2/gas/configure
+--- binutils-2.16.91.0.2.orig/gas/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/gas/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3421,6 +3421,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/gprof/configure binutils-2.16.91.0.2/gprof/configure
+--- binutils-2.16.91.0.2.orig/gprof/configure 2005-04-29 13:50:29.000000000 -0400
++++ binutils-2.16.91.0.2/gprof/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3419,6 +3419,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/ld/configure binutils-2.16.91.0.2/ld/configure
+--- binutils-2.16.91.0.2.orig/ld/configure 2005-06-22 16:53:35.000000000 -0400
++++ binutils-2.16.91.0.2/ld/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3422,6 +3422,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/libtool.m4 binutils-2.16.91.0.2/libtool.m4
+--- binutils-2.16.91.0.2.orig/libtool.m4 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/libtool.m4 2005-08-02 00:17:47.000000000 -0400
+@@ -645,6 +645,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -Nurp binutils-2.16.91.0.2.orig/ltconfig binutils-2.16.91.0.2/ltconfig
+--- binutils-2.16.91.0.2.orig/ltconfig 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/ltconfig 2005-08-02 00:17:47.000000000 -0400
+@@ -602,6 +602,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1270,6 +1271,23 @@ linux-gnu*)
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -Nurp binutils-2.16.91.0.2.orig/opcodes/configure binutils-2.16.91.0.2/opcodes/configure
+--- binutils-2.16.91.0.2.orig/opcodes/configure 2005-07-20 15:27:28.000000000 -0400
++++ binutils-2.16.91.0.2/opcodes/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3588,6 +3588,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.5/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4c72f330f1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+diff -Nurp binutils-2.16.91.0.2.orig/bfd/configure binutils-2.16.91.0.2/bfd/configure
+--- binutils-2.16.91.0.2.orig/bfd/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/bfd/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3585,6 +3585,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/binutils/configure binutils-2.16.91.0.2/binutils/configure
+--- binutils-2.16.91.0.2.orig/binutils/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/binutils/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3420,6 +3420,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/configure binutils-2.16.91.0.2/configure
+--- binutils-2.16.91.0.2.orig/configure 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -1130,7 +1130,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -1235,7 +1235,7 @@ case "${target}" in
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1530,7 +1530,7 @@ case "${target}" in
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+diff -Nurp binutils-2.16.91.0.2.orig/configure.in binutils-2.16.91.0.2/configure.in
+--- binutils-2.16.91.0.2.orig/configure.in 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/configure.in 2005-08-02 00:17:47.000000000 -0400
+@@ -341,7 +341,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+@@ -446,7 +446,7 @@ case "${target}" in
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -741,7 +741,7 @@ case "${target}" in
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+diff -Nurp binutils-2.16.91.0.2.orig/gas/configure binutils-2.16.91.0.2/gas/configure
+--- binutils-2.16.91.0.2.orig/gas/configure 2005-07-20 15:27:27.000000000 -0400
++++ binutils-2.16.91.0.2/gas/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3421,6 +3421,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/gprof/configure binutils-2.16.91.0.2/gprof/configure
+--- binutils-2.16.91.0.2.orig/gprof/configure 2005-04-29 13:50:29.000000000 -0400
++++ binutils-2.16.91.0.2/gprof/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3419,6 +3419,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/ld/configure binutils-2.16.91.0.2/ld/configure
+--- binutils-2.16.91.0.2.orig/ld/configure 2005-06-22 16:53:35.000000000 -0400
++++ binutils-2.16.91.0.2/ld/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3422,6 +3422,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -Nurp binutils-2.16.91.0.2.orig/libtool.m4 binutils-2.16.91.0.2/libtool.m4
+--- binutils-2.16.91.0.2.orig/libtool.m4 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/libtool.m4 2005-08-02 00:17:47.000000000 -0400
+@@ -645,6 +645,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -Nurp binutils-2.16.91.0.2.orig/ltconfig binutils-2.16.91.0.2/ltconfig
+--- binutils-2.16.91.0.2.orig/ltconfig 2005-07-20 15:27:26.000000000 -0400
++++ binutils-2.16.91.0.2/ltconfig 2005-08-02 00:17:47.000000000 -0400
+@@ -602,6 +602,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1270,6 +1271,23 @@ linux-gnu*)
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -Nurp binutils-2.16.91.0.2.orig/opcodes/configure binutils-2.16.91.0.2/opcodes/configure
+--- binutils-2.16.91.0.2.orig/opcodes/configure 2005-07-20 15:27:28.000000000 -0400
++++ binutils-2.16.91.0.2/opcodes/configure 2005-08-02 00:17:47.000000000 -0400
+@@ -3588,6 +3588,11 @@ linux-gnu*)
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.6/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.16.91.0.7/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.10/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-makeinfo-version.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-makeinfo-version.patch
new file mode 100644
index 0000000000..78f7e1a1f6
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-makeinfo-version.patch
@@ -0,0 +1,16 @@
+diff -ur binutils-2.17.50.0.12/configure binutils-2.17.50.0.12-patched/configure
+--- binutils-2.17.50.0.12/configure 2007-01-23 15:37:00.000000000 -0600
++++ binutils-2.17.50.0.12-patched/configure 2008-01-26 15:15:40.018188886 -0600
+@@ -3835,10 +3835,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/320-mips-elf-reloc-regression.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/320-mips-elf-reloc-regression.patch
new file mode 100644
index 0000000000..902bb8836e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.12/320-mips-elf-reloc-regression.patch
@@ -0,0 +1,68 @@
+diff -ur binutils-2.17.50.0.12/bfd/elfxx-mips.c binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c
+--- binutils-2.17.50.0.12/bfd/elfxx-mips.c 2006-11-27 16:21:04.000000000 -0600
++++ binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c 2007-03-20 15:25:42.000000000 -0500
+@@ -3615,7 +3615,6 @@
+ }
+
+ /* We didn't find it. */
+- bfd_set_error (bfd_error_bad_value);
+ return NULL;
+ }
+
+@@ -7849,32 +7848,36 @@
+ several relocations for the same address. In
+ that case, the R_MIPS_LO16 relocation may occur
+ as one of these. We permit a similar extension
+- in general, as that is useful for GCC. */
++ in general, as that is useful for GCC.
++
++ In some cases GCC dead code elimination removes
++ the LO16 but keeps the corresponding HI16. */
+ lo16_relocation = mips_elf_next_relocation (input_bfd,
+ lo16_type,
+ rel, relend);
+- if (lo16_relocation == NULL)
+- return FALSE;
+-
+- lo16_location = contents + lo16_relocation->r_offset;
++ if (lo16_relocation != NULL)
++ {
++ lo16_location = contents + lo16_relocation->r_offset;
+
+- /* Obtain the addend kept there. */
+- lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
+- lo16_type, FALSE);
+- _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type, FALSE,
+- lo16_location);
+- l = mips_elf_obtain_contents (lo16_howto, lo16_relocation,
+- input_bfd, contents);
+- _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type, FALSE,
+- lo16_location);
+- l &= lo16_howto->src_mask;
+- l <<= lo16_howto->rightshift;
+- l = _bfd_mips_elf_sign_extend (l, 16);
++ /* Obtain the addend kept there. */
++ lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
++ lo16_type, FALSE);
++ _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type,
++ FALSE, lo16_location);
++ l = mips_elf_obtain_contents (lo16_howto,
++ lo16_relocation,
++ input_bfd, contents);
++ _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type,
++ FALSE, lo16_location);
++ l &= lo16_howto->src_mask;
++ l <<= lo16_howto->rightshift;
++ l = _bfd_mips_elf_sign_extend (l, 16);
+
+- addend <<= 16;
++ addend <<= 16;
+
+- /* Compute the combined addend. */
+- addend += l;
++ /* Compute the combined addend. */
++ addend += l;
++ }
+ }
+ else
+ addend <<= howto->rightshift;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/100-uclibc-conf.patch
new file mode 100644
index 0000000000..62465c7357
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.ac
++++ binutils-2.16.91.0.7/configure.ac
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..ca586843f2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.ac binutils-2.16.91.0.7/configure.ac
+--- binutils-2.16.91.0.7.orig/configure.ac 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.ac 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.14/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-makeinfo-version.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-makeinfo-version.patch
new file mode 100644
index 0000000000..5cebed3485
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-makeinfo-version.patch
@@ -0,0 +1,32 @@
+diff -ur binutils-2.17.50.0.16/configure binutils-2.17.50.0.16-patched/configure
+--- binutils-2.17.50.0.16/configure 2007-03-23 10:41:48.000000000 -0500
++++ binutils-2.17.50.0.16-patched/configure 2008-01-26 14:26:39.418390940 -0600
+@@ -6111,10 +6111,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
+diff -ur binutils-2.17.50.0.16/configure.ac binutils-2.17.50.0.16-patched/configure.ac
+--- binutils-2.17.50.0.16/configure.ac 2007-03-23 10:41:48.000000000 -0500
++++ binutils-2.17.50.0.16-patched/configure.ac 2008-01-26 14:26:39.422390987 -0600
+@@ -2397,10 +2397,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+ changequote(,)
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-uclibc-conf.patch
new file mode 100644
index 0000000000..62465c7357
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.ac
++++ binutils-2.16.91.0.7/configure.ac
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..ca586843f2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.ac binutils-2.16.91.0.7/configure.ac
+--- binutils-2.16.91.0.7.orig/configure.ac 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.ac 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.16/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-makeinfo-version.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-makeinfo-version.patch
new file mode 100644
index 0000000000..5a39913b09
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-makeinfo-version.patch
@@ -0,0 +1,32 @@
+diff -ur binutils-2.17.50.0.17/configure binutils-2.17.50.0.17-patched/configure
+--- binutils-2.17.50.0.17/configure 2007-06-18 12:29:28.000000000 -0500
++++ binutils-2.17.50.0.17-patched/configure 2008-01-26 14:31:23.477741690 -0600
+@@ -6111,10 +6111,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
+diff -ur binutils-2.17.50.0.17/configure.ac binutils-2.17.50.0.17-patched/configure.ac
+--- binutils-2.17.50.0.17/configure.ac 2007-06-18 12:29:28.000000000 -0500
++++ binutils-2.17.50.0.17-patched/configure.ac 2008-01-26 14:31:23.481741737 -0600
+@@ -2397,10 +2397,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+ changequote(,)
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-uclibc-conf.patch
new file mode 100644
index 0000000000..62465c7357
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.ac
++++ binutils-2.16.91.0.7/configure.ac
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..04e19bea39
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/configure binutils-2.17.50.0.17/configure
+--- binutils-2.17.50.0.17.oorig/configure 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure 2007-06-25 09:58:36.000000000 +0200
+@@ -2224,7 +2224,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -u binutils-2.17.50.0.17.oorig/configure.ac binutils-2.17.50.0.17/configure.ac
+--- binutils-2.17.50.0.17.oorig/configure.ac 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure.ac 2007-06-25 09:58:36.000000000 +0200
+@@ -513,7 +513,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..5cb0f614d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-001_ld_makefile_patch.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.am binutils-2.17.50.0.17/ld/Makefile.am
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.am 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.am 2007-06-25 10:00:36.000000000 +0200
+@@ -18,7 +18,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.in binutils-2.17.50.0.17/ld/Makefile.in
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.in 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.in 2007-06-25 10:00:36.000000000 +0200
+@@ -287,7 +287,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..6e809213d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.17/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,21 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em binutils-2.17.50.0.17/ld/emultempl/elf32.em
+--- binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em 2007-06-18 19:31:40.000000000 +0200
++++ binutils-2.17.50.0.17/ld/emultempl/elf32.em 2007-06-25 10:01:25.000000000 +0200
+@@ -1007,6 +1007,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1191,6 +1193,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.2/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.3/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.4/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.5/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.6/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.7/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.8/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17.50.0.9/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17/100-uclibc-conf.patch
new file mode 100644
index 0000000000..25222e5df2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/100-uclibc-conf.patch
@@ -0,0 +1,139 @@
+--- binutils-2.16.91.0.7/bfd/configure
++++ binutils-2.16.91.0.7/bfd/configure
+@@ -3576,7 +3576,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/binutils/configure
++++ binutils-2.16.91.0.7/binutils/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/configure
++++ binutils-2.16.91.0.7/configure
+@@ -1270,7 +1270,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -1578,7 +1578,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[3456789]86-*-vsta) ;; # don't add gprof back in
+ i[3456789]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/configure.in
++++ binutils-2.16.91.0.7/configure.in
+@@ -468,7 +468,7 @@
+ am33_2.0-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+- sh-*-linux*)
++ sh*-*-linux*)
+ noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+ ;;
+ sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+@@ -776,7 +776,7 @@
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+- sh-*-* | sh64-*-*)
++ sh*-*-* | sh64-*-*)
+ case "${host}" in
+ i[[3456789]]86-*-vsta) ;; # don't add gprof back in
+ i[[3456789]]86-*-go32*) ;; # don't add gprof back in
+--- binutils-2.16.91.0.7/gas/configure
++++ binutils-2.16.91.0.7/gas/configure
+@@ -3411,7 +3411,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/gprof/configure
++++ binutils-2.16.91.0.7/gprof/configure
+@@ -3419,6 +3419,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- binutils-2.16.91.0.7/ld/configure
++++ binutils-2.16.91.0.7/ld/configure
+@@ -3413,7 +3413,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/libtool.m4
++++ binutils-2.16.91.0.7/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- binutils-2.16.91.0.7/ltconfig
++++ binutils-2.16.91.0.7/ltconfig
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1247,7 +1248,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- binutils-2.16.91.0.7/opcodes/configure
++++ binutils-2.16.91.0.7/opcodes/configure
+@@ -3579,7 +3579,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux-gnu*|linux-uclibc*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.17/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..be85ceb109
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -urN binutils-2.16.91.0.7.orig/configure binutils-2.16.91.0.7/configure
+--- binutils-2.16.91.0.7.orig/configure 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure 2006-05-31 14:55:53.000000000 +0300
+@@ -1299,7 +1299,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -urN binutils-2.16.91.0.7.orig/configure.in binutils-2.16.91.0.7/configure.in
+--- binutils-2.16.91.0.7.orig/configure.in 2006-05-31 14:54:24.000000000 +0300
++++ binutils-2.16.91.0.7/configure.in 2006-05-31 14:55:53.000000000 +0300
+@@ -497,7 +497,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.17/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..04a7e61e25
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/300-001_ld_makefile_patch.patch
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils-2.16.91.0.1/ld/Makefile.am
++++ binutils-2.16.91.0.1/ld/Makefile.am
+@@ -20,7 +20,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- binutils-2.16.91.0.1/ld/Makefile.in
++++ binutils-2.16.91.0.1/ld/Makefile.in
+@@ -268,7 +268,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/300-006_better_file_error.patch b/cleopatre/buildroot/toolchain/binutils/2.17/300-006_better_file_error.patch
new file mode 100644
index 0000000000..f337611edf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/300-006_better_file_error.patch
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c 2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c 2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,13 @@
+ {
+ bfd *nbfd;
+ const bfd_target *target_vec;
++ struct stat s;
++
++ if (stat (filename, &s) == 0)
++ if (S_ISDIR(s.st_mode)) {
++ bfd_set_error (bfd_error_file_not_recognized);
++ return NULL;
++ }
+
+ nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.17/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..498651a90c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em binutils-2.15/ld/emultempl/elf32.em
+--- /home/james/debian/packages/binutils/new/binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:58.000000000 +0100
++++ binutils-2.15/ld/emultempl/elf32.em 2004-05-21 23:12:59.000000000 +0100
+@@ -692,6 +692,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -871,6 +873,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.17/400-mips-ELF_MAXPAGESIZE-4K.patch b/cleopatre/buildroot/toolchain/binutils/2.17/400-mips-ELF_MAXPAGESIZE-4K.patch
new file mode 100644
index 0000000000..5959c718d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.17/400-mips-ELF_MAXPAGESIZE-4K.patch
@@ -0,0 +1,26 @@
+--- binutils/bfd/elf32-mips.c~
++++ binutils/bfd/elf32-mips.c
+@@ -1613,7 +1613,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
+--- binutils/bfd/elfn32-mips.c~
++++ binutils/bfd/elfn32-mips.c
+@@ -2399,7 +2399,9 @@
+
+ /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
+ page sizes of up to that limit, so we need to respect it. */
+-#define ELF_MAXPAGESIZE 0x10000
++/*#define ELF_MAXPAGESIZE 0x10000*/
++/* Use 4K to shrink the elf header. NOT for general use! */
++#define ELF_MAXPAGESIZE 0x1000
+ #define elf32_bed elf32_tradbed
+
+ /* Include the target file again for this target. */
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/100-makeinfo-version.patch b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/100-makeinfo-version.patch
new file mode 100644
index 0000000000..d911d6236e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/100-makeinfo-version.patch
@@ -0,0 +1,32 @@
+diff -u binutils-2.18-orig/configure binutils-2.18/configure
+--- binutils-2.18-orig/configure 2007-08-06 16:29:40.000000000 -0400
++++ binutils-2.18/configure 2007-09-27 22:41:51.000000000 -0400
+@@ -6125,10 +6125,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
+diff -u binutils-2.18-orig/configure.ac binutils-2.18/configure.ac
+--- binutils-2.18-orig/configure.ac 2007-08-28 16:24:26.000000000 -0400
++++ binutils-2.18/configure.ac 2007-09-27 22:41:00.000000000 -0400
+@@ -2400,10 +2400,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+ changequote(,)
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..04e19bea39
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/configure binutils-2.17.50.0.17/configure
+--- binutils-2.17.50.0.17.oorig/configure 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure 2007-06-25 09:58:36.000000000 +0200
+@@ -2224,7 +2224,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -u binutils-2.17.50.0.17.oorig/configure.ac binutils-2.17.50.0.17/configure.ac
+--- binutils-2.17.50.0.17.oorig/configure.ac 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure.ac 2007-06-25 09:58:36.000000000 +0200
+@@ -513,7 +513,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..5cb0f614d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-001_ld_makefile_patch.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.am binutils-2.17.50.0.17/ld/Makefile.am
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.am 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.am 2007-06-25 10:00:36.000000000 +0200
+@@ -18,7 +18,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.in binutils-2.17.50.0.17/ld/Makefile.in
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.in 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.in 2007-06-25 10:00:36.000000000 +0200
+@@ -287,7 +287,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..6e809213d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18.50.0.1/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,21 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em binutils-2.17.50.0.17/ld/emultempl/elf32.em
+--- binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em 2007-06-18 19:31:40.000000000 +0200
++++ binutils-2.17.50.0.17/ld/emultempl/elf32.em 2007-06-25 10:01:25.000000000 +0200
+@@ -1007,6 +1007,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1191,6 +1193,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18/100-makeinfo-version.patch b/cleopatre/buildroot/toolchain/binutils/2.18/100-makeinfo-version.patch
new file mode 100644
index 0000000000..d911d6236e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18/100-makeinfo-version.patch
@@ -0,0 +1,32 @@
+diff -u binutils-2.18-orig/configure binutils-2.18/configure
+--- binutils-2.18-orig/configure 2007-08-06 16:29:40.000000000 -0400
++++ binutils-2.18/configure 2007-09-27 22:41:51.000000000 -0400
+@@ -6125,10 +6125,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
+diff -u binutils-2.18-orig/configure.ac binutils-2.18/configure.ac
+--- binutils-2.18-orig/configure.ac 2007-08-28 16:24:26.000000000 -0400
++++ binutils-2.18/configure.ac 2007-09-27 22:41:00.000000000 -0400
+@@ -2400,10 +2400,10 @@
+ *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+ *)
+ changequote(,)
+- # For an installed makeinfo, we require it to be from texinfo 4.4 or
++ # For an installed makeinfo, we require it to be from texinfo 4.6 or
+ # higher, else we use the "missing" dummy.
+ if ${MAKEINFO} --version \
+- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
++ | egrep 'texinfo[^0-9]*(4\.([6-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+ :
+ else
+ MAKEINFO="$MISSING makeinfo"
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18/110-arm-eabi-conf.patch b/cleopatre/buildroot/toolchain/binutils/2.18/110-arm-eabi-conf.patch
new file mode 100644
index 0000000000..04e19bea39
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18/110-arm-eabi-conf.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/configure binutils-2.17.50.0.17/configure
+--- binutils-2.17.50.0.17.oorig/configure 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure 2007-06-25 09:58:36.000000000 +0200
+@@ -2224,7 +2224,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
+diff -u binutils-2.17.50.0.17.oorig/configure.ac binutils-2.17.50.0.17/configure.ac
+--- binutils-2.17.50.0.17.oorig/configure.ac 2007-06-18 19:29:28.000000000 +0200
++++ binutils-2.17.50.0.17/configure.ac 2007-06-25 09:58:36.000000000 +0200
+@@ -513,7 +513,7 @@
+ arm-*-elf* | strongarm-*-elf* | xscale-*-elf* | arm*-*-eabi* )
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ ;;
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ noconfigdirs="$noconfigdirs target-libffi target-qthreads"
+ noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18/300-001_ld_makefile_patch.patch b/cleopatre/buildroot/toolchain/binutils/2.18/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000000..5cb0f614d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18/300-001_ld_makefile_patch.patch
@@ -0,0 +1,24 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.am binutils-2.17.50.0.17/ld/Makefile.am
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.am 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.am 2007-06-25 10:00:36.000000000 +0200
+@@ -18,7 +18,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+diff -u binutils-2.17.50.0.17.oorig/ld/Makefile.in binutils-2.17.50.0.17/ld/Makefile.in
+--- binutils-2.17.50.0.17.oorig/ld/Makefile.in 2007-06-18 19:29:29.000000000 +0200
++++ binutils-2.17.50.0.17/ld/Makefile.in 2007-06-25 10:00:36.000000000 +0200
+@@ -287,7 +287,7 @@
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/cleopatre/buildroot/toolchain/binutils/2.18/300-012_check_ldrunpath_length.patch b/cleopatre/buildroot/toolchain/binutils/2.18/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000000..6e809213d8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/2.18/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,21 @@
+diff -u binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em binutils-2.17.50.0.17/ld/emultempl/elf32.em
+--- binutils-2.17.50.0.17.oorig/ld/emultempl/elf32.em 2007-06-18 19:31:40.000000000 +0200
++++ binutils-2.17.50.0.17/ld/emultempl/elf32.em 2007-06-25 10:01:25.000000000 +0200
+@@ -1007,6 +1007,8 @@
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1191,6 +1193,8 @@
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+ if (! (bfd_elf_size_dynamic_sections
+ (output_bfd, command_line.soname, rpath,
+ command_line.filter_shlib,
diff --git a/cleopatre/buildroot/toolchain/binutils/Config.in b/cleopatre/buildroot/toolchain/binutils/Config.in
new file mode 100644
index 0000000000..8661bd7777
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/Config.in
@@ -0,0 +1,41 @@
+# Choose binutils version.
+
+comment "Binutils Options"
+
+choice
+ prompt "Binutils Version"
+ default BR2_BINUTILS_VERSION_2_18
+ help
+ Select the version of binutils you wish to use.
+
+ config BR2_BINUTILS_VERSION_2_17
+ depends on BR2_avr32 || !BR2_nios2 && BR2_DEPRECATED
+ depends on BR2_EXT_BINUTILS_VERSION_2_17
+ bool "binutils 2.17"
+
+ config BR2_BINUTILS_VERSION_2_17_50_0_17
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "binutils 2.17.50.0.17"
+
+ config BR2_BINUTILS_VERSION_2_18
+ depends on !BR2_avr32 && !BR2_nios2
+ bool "binutils 2.18"
+
+ config BR2_BINUTILS_VERSION_2_18_50_0_1
+ depends on !BR2_avr32 && !BR2_nios2
+ bool "binutils 2.18.50.0.1"
+endchoice
+
+config BR2_BINUTILS_VERSION
+ string
+ default "2.15" if BR2_nios2
+ default "2.17" if BR2_BINUTILS_VERSION_2_17
+ default "2.17.50.0.17" if BR2_BINUTILS_VERSION_2_17_50_0_17
+ default "2.18" if BR2_BINUTILS_VERSION_2_18
+ default "2.18.50.0.1" if BR2_BINUTILS_VERSION_2_18_50_0_1
+
+config BR2_EXTRA_BINUTILS_CONFIG_OPTIONS
+ string "Additional binutils options"
+ default ""
+ help
+ Any additional binutils options you may want to include.
diff --git a/cleopatre/buildroot/toolchain/binutils/binutils.mk b/cleopatre/buildroot/toolchain/binutils/binutils.mk
new file mode 100644
index 0000000000..ab74e9f1f9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/binutils/binutils.mk
@@ -0,0 +1,193 @@
+#############################################################
+#
+# build binutils for use on the host system
+#
+#############################################################
+BINUTILS_VERSION:=$(strip $(subst ",, $(BR2_BINUTILS_VERSION)))
+#"))
+
+EXTRA_BINUTILS_CONFIG_OPTIONS=$(strip $(subst ",, $(BR2_EXTRA_BINUTILS_CONFIG_OPTIONS)))
+#"))
+BINUTILS_SITE:=$(BR2_KERNEL_MIRROR)/linux/devel/binutils
+ifeq ($(BINUTILS_VERSION),2.18)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+endif
+ifeq ($(BINUTILS_VERSION),2.17)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+endif
+ifeq ($(BINUTILS_VERSION),2.16)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(BINUTILS_VERSION),2.16.1)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(BINUTILS_VERSION),2.15)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(BINUTILS_VERSION),2.14)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(BINUTILS_VERSION),2.13)
+BINUTILS_SITE:=$(BR2_GNU_MIRROR)/binutils/
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(BINUTILS_VERSION),2.15.97)
+BINUTILS_SITE:=ftp://sources.redhat.com/pub/binutils/snapshots/
+BINUTILS_NO_MPFR:=y
+endif
+
+# We do not rely on the host's gmp/mpfr but use a known working one
+BINUTILS_HOST_PREREQ:=
+BINUTILS_TARGET_PREREQ:=
+
+ifeq ($(findstring x3.,x$(GCC_VERSION)),x3.)
+BINUTILS_NO_MPFR:=y
+endif
+ifeq ($(findstring x4.0,x$(GCC_VERSION)),x4.0)
+BINUTILS_NO_MPFR:=y
+endif
+
+ifndef BINUTILS_NO_MPFR
+BINUTILS_HOST_PREREQ:=$(TOOL_BUILD_DIR)/gmp/lib/libgmp$(HOST_SHREXT) \
+ $(TOOL_BUILD_DIR)/mpfr/lib/libmpfr$(HOST_SHREXT)
+
+BINUTILS_TARGET_PREREQ:=$(TARGET_DIR)/usr/lib/libgmp$(LIBTGTEXT) \
+ $(TARGET_DIR)/usr/lib/libmpfr$(LIBTGTEXT)
+
+EXTRA_BINUTILS_CONFIG_OPTIONS+=--with-gmp="$(GMP_HOST_DIR)"
+EXTRA_BINUTILS_CONFIG_OPTIONS+=--with-mpfr="$(MPFR_HOST_DIR)"
+
+BINUTILS_TARGET_CONFIG_OPTIONS=--with-gmp="$(GMP_TARGET_DIR)"
+BINUTILS_TARGET_CONFIG_OPTIONS+=--with-mpfr="$(MPFR_TARGET_DIR)"
+endif
+
+BINUTILS_OFFICIAL_VERSION:=$(BINUTILS_VERSION)$(VENDOR_SUFFIX)$(VENDOR_BINUTILS_RELEASE)
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+BINUTILS_PATCH_DIR:=toolchain/binutils/$(BINUTILS_VERSION)
+else # ifeq ($(BR2_TOOLCHAIN_EXTERNAL_SOURCE),)
+BINUTILS_SITE:=$(VENDOR_SITE)
+BINUTILS_PATCH_DIR:=toolchain/binutils/ext_source/$(VENDOR_PATCH_DIR)/$(BINUTILS_OFFICIAL_VERSION)
+endif
+
+BINUTILS_SOURCE:=binutils-$(BINUTILS_OFFICIAL_VERSION).tar.bz2
+BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_OFFICIAL_VERSION)
+BINUTILS_CAT:=$(BZCAT)
+
+BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)-build
+
+$(DL_DIR)/$(BINUTILS_SOURCE):
+ mkdir -p $(DL_DIR)
+ $(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)
+
+binutils-unpacked: $(BINUTILS_DIR)/.patched
+$(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
+ mkdir -p $(TOOL_BUILD_DIR)
+ rm -rf $(BINUTILS_DIR)
+ $(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ $(CONFIG_UPDATE) $(BINUTILS_DIR)
+ touch $@
+
+binutils-patched: $(BINUTILS_DIR)/.patched
+$(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
+ # Apply appropriate binutils patches.
+ toolchain/patch-kernel.sh $(BINUTILS_DIR) $(BINUTILS_PATCH_DIR) \*.patch
+ touch $@
+
+$(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
+ mkdir -p $(BINUTILS_DIR1)
+ (cd $(BINUTILS_DIR1); rm -rf config.cache; \
+ $(HOST_CONFIGURE_OPTS) \
+ $(BINUTILS_DIR)/configure \
+ --prefix=$(BR2_SYSROOT_PREFIX)/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ $(BR2_CONFIGURE_DEVEL_SYSROOT) \
+ $(BR2_CONFIGURE_STAGING_SYSROOT) \
+ $(DISABLE_NLS) \
+ $(MULTILIB) \
+ --disable-werror \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(EXTRA_BINUTILS_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
+ $(MAKE) -C $(BINUTILS_DIR1) all
+
+# Make install will put gettext data in staging_dir/share/locale.
+# Unfortunatey, it isn't configureable.
+$(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-ld: $(BINUTILS_DIR1)/binutils/objdump
+ $(MAKE) -C $(BINUTILS_DIR1) $(BR2_SYSROOT_STAGING_DESTDIR) install
+ # tooldir=/usr build_tooldir=/usr install
+ #rm -f $(STAGING_DIR)/usr/bin/{ar,as,ld,nm,objdump,ranlib,strip}
+
+binutils: uclibc-configured $(BINUTILS_HOST_PREREQ) $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-ld
+
+binutils-source: $(DL_DIR)/$(BINUTILS_SOURCE)
+
+binutils-clean:
+ rm -rf $(STAGING_DIR)/usr/bin/*{ar,as,ld,nm,objdump,ranlib,strip} \
+ $(STAGING_DIR)/usr/lib/{libiberty*,ldscripts}
+ -$(MAKE) -C $(BINUTILS_DIR1) DESTDIR=$(STAGING_DIR) \
+ tooldir=/usr build_tooldir=/usr uninstall
+ -$(MAKE) -C $(BINUTILS_DIR1) clean
+
+binutils-dirclean:
+ rm -rf $(BINUTILS_DIR1)
+
+
+
+#############################################################
+#
+# build binutils for use on the target system
+#
+#############################################################
+BINUTILS_DIR2:=$(BUILD_DIR)/binutils-$(BINUTILS_VERSION)-target
+$(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
+ mkdir -p $(BINUTILS_DIR2)
+ (cd $(BINUTILS_DIR2); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_OPTS) \
+ $(BINUTILS_DIR)/configure \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ $(DISABLE_NLS) \
+ $(MULTILIB) \
+ $(BINUTILS_TARGET_CONFIG_OPTIONS) \
+ --disable-werror \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ )
+ touch $@
+
+$(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
+ PATH=$(TARGET_PATH) $(MAKE) -C $(BINUTILS_DIR2) all
+
+$(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
+ PATH=$(TARGET_PATH) \
+ $(MAKE) DESTDIR=$(TARGET_DIR) \
+ tooldir=/usr build_tooldir=/usr \
+ -C $(BINUTILS_DIR2) install
+ #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
+ # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+ -$(STRIPCMD) $(TARGET_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
+ -$(STRIPCMD) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1
+
+binutils_target: $(BINUTILS_TARGET_PREREQ) $(TARGET_DIR)/usr/bin/ld
+
+binutils_target-clean:
+ (cd $(TARGET_DIR)/usr/bin; \
+ rm -f addr2line ar as gprof ld nm objcopy \
+ objdump ranlib readelf size strings strip; \
+ )
+ rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
+ -$(MAKE) -C $(BINUTILS_DIR2) clean
+
+binutils_target-dirclean:
+ rm -rf $(BINUTILS_DIR2)
diff --git a/cleopatre/buildroot/toolchain/br2_autoreconf b/cleopatre/buildroot/toolchain/br2_autoreconf
new file mode 100755
index 0000000000..bd13da886f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/br2_autoreconf
@@ -0,0 +1,699 @@
+#! /usr/bin/perl -w
+# -*- perl -*-
+# Generated from autoreconf.in; do not edit by hand.
+
+eval 'case $# in 0) exec /usr/bin/perl -S "$0";; *) exec /usr/bin/perl -S "$0" "$@";; esac'
+ if 0;
+
+# autoreconf - install the GNU Build System in a directory tree
+# Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Written by David J. MacKenzie.
+# Extended and rewritten in Perl by Akim Demaille.
+
+BEGIN
+{
+ my $datadir = $ENV{'autom4te_perllibdir'} || '/usr/share/autoconf';
+ unshift @INC, $datadir;
+
+ # Override SHELL. On DJGPP SHELL may not be set to a shell
+ # that can handle redirection and quote arguments correctly,
+ # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
+ # has detected.
+ $ENV{'SHELL'} = '/bin/sh' if ($^O eq 'dos');
+}
+
+use Autom4te::ChannelDefs;
+use Autom4te::Channels;
+use Autom4te::Configure_ac;
+use Autom4te::FileUtils;
+use Autom4te::General;
+use Autom4te::XFile;
+# Do not use Cwd::chdir, since it might hang.
+use Cwd 'cwd';
+use strict;
+
+## ----------- ##
+## Variables. ##
+## ----------- ##
+
+# $HELP
+# -----
+$help = "Usage: $0 [OPTION] ... [DIRECTORY] ...
+
+Run `autoconf' (and `autoheader', `aclocal', `automake', `autopoint'
+(formerly `gettextize'), and `libtoolize' where appropriate)
+repeatedly to remake the GNU Build System files in specified
+DIRECTORIES and their subdirectories (defaulting to `.').
+
+By default, it only remakes those files that are older than their
+sources. If you install new versions of the GNU Build System,
+you can make `autoreconf' remake all of the files by giving it the
+`--force' option.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -v, --verbose verbosely report processing
+ -d, --debug don't remove temporary files
+ -f, --force consider all files obsolete
+ -i, --install copy missing auxiliary files
+ --no-recursive don't rebuild sub-packages
+ -s, --symlink with -i, install symbolic links instead of copies
+ -m, --make when applicable, re-run ./configure && make
+ -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
+
+" . Autom4te::ChannelDefs::usage . "
+
+The environment variable \`WARNINGS\' is honored. Some subtools might
+support other warning types, using \`all' is encouraged.
+
+Library directories:
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
+
+The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
+AUTOPOINT, LIBTOOLIZE, M4 are honored.
+
+Report bugs to <bug-autoconf\@gnu.org>.
+";
+
+# $VERSION
+# --------
+$version = "autoreconf (GNU Autoconf) 2.61
+Copyright (C) 2006 Free Software Foundation, Inc.
+This is free software. You may redistribute copies of it under the terms of
+the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
+There is NO WARRANTY, to the extent permitted by law.
+
+Written by David J. MacKenzie and Akim Demaille.
+";
+
+# Lib files.
+my $autoconf = $ENV{'AUTOCONF'} || '/usr/bin/autoconf';
+my $autoheader = $ENV{'AUTOHEADER'} || '/usr/bin/autoheader';
+my $automake = $ENV{'AUTOMAKE'} || 'automake';
+my $aclocal = $ENV{'ACLOCAL'} || 'aclocal';
+my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
+my $autopoint = $ENV{'AUTOPOINT'} || 'autopoint';
+
+# --install -- as --add-missing in other tools.
+my $install = 0;
+# symlink -- when --install, use symlinks instead.
+my $symlink = 0;
+# Does aclocal support --force?
+my $aclocal_supports_force = 0;
+# Does automake support --force-missing?
+my $automake_supports_force_missing = 0;
+
+my @prepend_include;
+my @include;
+
+# List of command line warning requests.
+my @warning;
+
+# Rerun `./configure && make'?
+my $make = 0;
+
+# Recurse into subpackages
+my $recursive = 1;
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
+
+
+# parse_args ()
+# -------------
+# Process any command line arguments.
+sub parse_args ()
+{
+ my $srcdir;
+
+ getopt ("W|warnings=s" => \@warning,
+ 'I|include=s' => \@include,
+ 'B|prepend-include=s' => \@prepend_include,
+ 'i|install' => \$install,
+ 's|symlink' => \$symlink,
+ 'm|make' => \$make,
+ 'recursive!' => \$recursive);
+
+ # Split the warnings as a list of elements instead of a list of
+ # lists.
+ @warning = map { split /,/ } @warning;
+ parse_WARNINGS;
+ parse_warnings '--warnings', @warning;
+
+ # Even if the user specified a configure.ac, trim to get the
+ # directory, and look for configure.ac again. Because (i) the code
+ # is simpler, and (ii) we are still able to diagnose simultaneous
+ # presence of configure.ac and configure.in.
+ @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
+ push @ARGV, '.' unless @ARGV;
+
+ if ($verbose && $debug)
+ {
+ for my $prog ($autoconf, $autoheader,
+ $automake, $aclocal,
+ $autopoint,
+ $libtoolize)
+ {
+ xsystem ("$prog --version | sed 1q >&2");
+ print STDERR "\n";
+ }
+ }
+
+ $aclocal_supports_force = `$aclocal --help` =~ /--force/;
+ $automake_supports_force_missing = `$automake --help` =~ /--force-missing/;
+
+ # Dispatch autoreconf's option to the tools.
+ # --include;
+ $autoconf .= join (' --include=', '', @include);
+ $autoconf .= join (' --prepend-include=', '', @prepend_include);
+ $autoheader .= join (' --include=', '', @include);
+ $autoheader .= join (' --prepend-include=', '', @prepend_include);
+ $aclocal .= join (' -I', '', @include);
+
+ # --install and --symlink;
+ if ($install)
+ {
+ $automake .= ' --add-missing';
+ $automake .= ' --copy' unless $symlink;
+ $libtoolize .= ' --copy' unless $symlink;
+ }
+ # --force;
+ if ($force)
+ {
+ $aclocal .= ' --force'
+ if $aclocal_supports_force;
+ $autoconf .= ' --force';
+ $autoheader .= ' --force';
+ $automake .= ' --force-missing'
+ if $automake_supports_force_missing;
+ $autopoint .= ' --force';
+ $libtoolize .= ' --force';
+ }
+ else
+ {
+ # The implementation of --no-force is bogus in all implementations
+ # of Automake up to 1.8, so we avoid it in these cases. (Automake
+ # 1.8 is the first version where aclocal supports force, hence
+ # the condition.)
+ $automake .= ' --no-force'
+ if $aclocal_supports_force;
+ }
+ # --verbose --verbose or --debug;
+ if ($verbose > 1 || $debug)
+ {
+ $autoconf .= ' --verbose';
+ $autoheader .= ' --verbose';
+ $automake .= ' --verbose';
+ $aclocal .= ' --verbose';
+ }
+ if ($debug)
+ {
+ $autoconf .= ' --debug';
+ $autoheader .= ' --debug';
+ $libtoolize .= ' --debug';
+ }
+ # --warnings;
+ if (@warning)
+ {
+ my $warn = ' --warnings=' . join (',', @warning);
+ $autoconf .= $warn;
+ $autoheader .= $warn;
+ $automake .= $warn
+ if `$automake --help` =~ /--warnings/;
+ }
+}
+
+
+# &run_aclocal ($ACLOCAL, $FLAGS)
+# -------------------------------
+# Update aclocal.m4 as lazily as possible, as aclocal pre-1.8 always
+# overwrites aclocal.m4, hence triggers autoconf, autoheader, automake
+# etc. uselessly. aclocal 1.8+ does not need this.
+sub run_aclocal ($$)
+{
+ my ($aclocal, $flags) = @_;
+
+ # aclocal 1.8+ does all this for free. It can be recognized by its
+ # --force support.
+ if ($aclocal_supports_force)
+ {
+ xsystem ("$aclocal $flags");
+ }
+ else
+ {
+ xsystem ("$aclocal $flags --output=aclocal.m4t");
+ # aclocal may produce no output.
+ if (-f 'aclocal.m4t')
+ {
+ update_file ('aclocal.m4t', 'aclocal.m4');
+ # Make sure that the local m4 files are older than
+ # aclocal.m4.
+ #
+ # Why is not always the case? Because we already run
+ # aclocal at first (before tracing), which, for instance,
+ # can find Gettext's macros in .../share/aclocal, so we may
+ # have had the right aclocal.m4 already. Then autopoint is
+ # run, and installs locally these M4 files. Then
+ # autoreconf, via update_file, sees it is the _same_
+ # aclocal.m4, and doesn't change its timestamp. But later,
+ # Automake's Makefile expresses that aclocal.m4 depends on
+ # these local files, which are newer, so it triggers aclocal
+ # again.
+ #
+ # To make sure aclocal.m4 is no older, we change the
+ # modification times of the local M4 files to be not newer
+ # than it.
+ #
+ # First, where are the local files?
+ my $aclocal_local_dir = '.';
+ if ($flags =~ /-I\s+(\S+)/)
+ {
+ $aclocal_local_dir = $1;
+ }
+ # All the local files newer than aclocal.m4 are to be
+ # made not newer than it.
+ my $aclocal_m4_mtime = mtime ('aclocal.m4');
+ for my $file (glob ("$aclocal_local_dir/*.m4"), 'acinclude.m4')
+ {
+ if ($aclocal_m4_mtime < mtime ($file))
+ {
+ debug "aging $file to be not newer than aclocal.m4";
+ utime $aclocal_m4_mtime, $aclocal_m4_mtime, $file;
+ }
+ }
+ }
+ }
+}
+
+# &autoreconf_current_directory
+# -----------------------------
+sub autoreconf_current_directory ()
+{
+ my $configure_ac = find_configure_ac;
+
+ # ---------------------- #
+ # Is it using Autoconf? #
+ # ---------------------- #
+
+ my $uses_autoconf;
+ my $uses_gettext;
+ if (-f $configure_ac)
+ {
+ my $configure_ac_file = new Autom4te::XFile $configure_ac;
+ while ($_ = $configure_ac_file->getline)
+ {
+ s/#.*//;
+ s/dnl.*//;
+ $uses_autoconf = 1 if /AC_INIT/;
+ # See below for why we look for gettext here.
+ $uses_gettext = 1 if /^AM_GNU_GETTEXT_VERSION/;
+ }
+ }
+ if (!$uses_autoconf)
+ {
+ verb "$configure_ac: not using Autoconf";
+ return;
+ }
+
+
+ # ------------------- #
+ # Running autopoint. #
+ # ------------------- #
+
+ # Gettext is a bit of a problem: its macros are not necessarily
+ # visible to aclocal, so if we start with a completely striped down
+ # package (think of a fresh CVS checkout), running `aclocal' first
+ # will fail: the Gettext macros are missing.
+ #
+ # Therefore, we can't use the traces to decide if we use Gettext or
+ # not. I guess that once Gettext move to 2.5x we will be able to,
+ # but in the meanwhile forget it.
+ #
+ # We can only grep for AM_GNU_GETTEXT_VERSION in configure.ac. You
+ # might think this approach is naive, and indeed it is, as it
+ # prevents one to embed AM_GNU_GETTEXT_VERSION in another *.m4, but
+ # anyway we don't limit the generality, since... that's what
+ # autopoint does. Actually, it is even more restrictive, as it
+ # greps for `^AM_GNU_GETTEXT_VERSION('. We did this above, while
+ # scanning configure.ac.
+ if (!$uses_gettext)
+ {
+ verb "$configure_ac: not using Gettext";
+ }
+ elsif (!$install)
+ {
+ verb "$configure_ac: not running autopoint: --install not given";
+ }
+ else
+ {
+ xsystem "$autopoint";
+ }
+
+
+ # ----------------- #
+ # Running aclocal. #
+ # ----------------- #
+
+ # Run it first: it might discover new macros to add, e.g.,
+ # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is
+ # used.
+ #
+ # Always run it. Tracking its sources for up-to-dateness is too
+ # complex and too error prone. The best we can do is avoiding
+ # nuking the time stamp.
+ my $uses_aclocal = 1;
+
+ # Nevertheless, if aclocal.m4 exists and is not made by aclocal,
+ # don't run aclocal.
+
+ if (-f 'aclocal.m4')
+ {
+ my $aclocal_m4 = new Autom4te::XFile 'aclocal.m4';
+ $_ = $aclocal_m4->getline;
+ $uses_aclocal = 0
+ unless defined ($_) && /generated.*by aclocal/;
+ }
+
+ # If there are flags for aclocal in Makefile.am, use them.
+ my $aclocal_flags = '';
+ if ($uses_aclocal && -f 'Makefile.am')
+ {
+ my $makefile = new Autom4te::XFile 'Makefile.am';
+ while ($_ = $makefile->getline)
+ {
+ if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
+ {
+ $aclocal_flags = $1;
+ last;
+ }
+ }
+ }
+
+ if (!$uses_aclocal)
+ {
+ verb "$configure_ac: not using aclocal";
+ }
+ else
+ {
+ # Some file systems have sub-second time stamps, and if so we may
+ # run into trouble later, after we rerun autoconf and set the
+ # time stamps of input files to be no greater than aclocal.m4,
+ # because the time-stamp-setting operation (utime) has a
+ # resolution of only 1 second. Work around the problem by
+ # ensuring that there is at least a one-second window before the
+ # time stamp of aclocal.m4t in which no file time stamps can
+ # fall.
+ sleep 1;
+
+ run_aclocal ($aclocal, $aclocal_flags);
+ }
+
+ # We might have to rerun aclocal if Libtool (or others) imports new
+ # macros.
+ my $rerun_aclocal = 0;
+
+
+
+ # ------------------------------- #
+ # See what tools will be needed. #
+ # ------------------------------- #
+
+ # Perform a single trace reading to avoid --force forcing a rerun
+ # between two --trace, that's useless. If there is no AC_INIT, then
+ # we are not interested: it looks like a Cygnus thingy.
+ my $aux_dir;
+ my $uses_gettext_via_traces;
+ my $uses_libtool;
+ my $uses_libltdl;
+ my $uses_autoheader;
+ my $uses_automake;
+ my @subdir;
+ verb "$configure_ac: tracing";
+ my $traces = new Autom4te::XFile
+ ("$autoconf"
+ . join (' --trace=', '',
+ # If you change this list, update the
+ # `Autoreconf-preselections' section of autom4te.in.
+ 'AC_CONFIG_AUX_DIR:AC_CONFIG_AUX_DIR:\$1',
+ 'AC_CONFIG_HEADERS',
+ 'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1',
+ 'AC_INIT',
+ 'AC_PROG_LIBTOOL',
+ 'LT_INIT',
+ 'LT_CONFIG_LTDL_DIR',
+ 'AM_GNU_GETTEXT',
+ 'AM_INIT_AUTOMAKE',
+ )
+ . ' |');
+ while ($_ = $traces->getline)
+ {
+ $aux_dir = $1 if /AC_CONFIG_AUX_DIR:(.*)/;
+ $uses_autoconf = 1 if /AC_INIT/;
+ $uses_gettext_via_traces = 1 if /AM_GNU_GETTEXT/;
+ $uses_libtool = 1 if /(AC_PROG_LIBTOOL|LT_INIT)/;
+ $uses_libltdl = 1 if /LT_CONFIG_LTDL_DIR/;
+ $uses_autoheader = 1 if /AC_CONFIG_HEADERS/;
+ $uses_automake = 1 if /AM_INIT_AUTOMAKE/;
+ push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/ && $recursive;
+ }
+
+ # The subdirs are *optional*, they may not exist.
+ foreach (@subdir)
+ {
+ if (-d)
+ {
+ verb "$configure_ac: adding subdirectory $_ to autoreconf";
+ autoreconf ($_);
+ }
+ else
+ {
+ verb "$configure_ac: subdirectory $_ not present";
+ }
+ }
+
+ # Gettext consistency checks...
+ error "$configure_ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION"
+ if $uses_gettext_via_traces && ! $uses_gettext;
+ error "$configure_ac: AM_GNU_GETTEXT_VERSION is used, but not AM_GNU_GETTEXT"
+ if $uses_gettext && ! $uses_gettext_via_traces;
+
+
+ # ---------------------------- #
+ # Setting up the source tree. #
+ # ---------------------------- #
+
+ # libtoolize, automake --add-missing etc. will drop files in the
+ # $AUX_DIR. But these tools fail to install these files if the
+ # directory itself does not exist, which valid: just imagine a CVS
+ # repository with hand written code only (there is not even a need
+ # for a Makefile.am!).
+
+ if (defined $aux_dir && ! -d $aux_dir)
+ {
+ verb "$configure_ac: creating directory $aux_dir";
+ mkdir $aux_dir, 0755
+ or error "cannot create $aux_dir: $!";
+ }
+
+
+ # -------------------- #
+ # Running libtoolize. #
+ # -------------------- #
+
+ if (!$uses_libtool)
+ {
+ verb "$configure_ac: not using Libtool";
+ }
+ elsif ($install)
+ {
+ if ($uses_libltdl)
+ {
+ $libtoolize .= " --ltdl";
+ }
+ xsystem ($libtoolize);
+ $rerun_aclocal = 1;
+ }
+ else
+ {
+ verb "$configure_ac: not running libtoolize: --install not given";
+ }
+
+
+
+ # ------------------- #
+ # Rerunning aclocal. #
+ # ------------------- #
+
+ # If we re-installed Libtool or Gettext, the macros might have changed.
+ # Automake also needs an up-to-date aclocal.m4.
+ if ($rerun_aclocal)
+ {
+ if (!$uses_aclocal)
+ {
+ verb "$configure_ac: not using aclocal";
+ }
+ else
+ {
+ run_aclocal ($aclocal, $aclocal_flags);
+ }
+ }
+
+
+ # ------------------ #
+ # Running autoconf. #
+ # ------------------ #
+
+ # Don't try to be smarter than `autoconf', which does its own up to
+ # date checks.
+ #
+ # We prefer running autoconf before autoheader, because (i) the
+ # latter runs the former, and (ii) autoconf is stricter than
+ # autoheader. So all in all, autoconf should give better error
+ # messages.
+ xsystem ($autoconf);
+
+
+ # -------------------- #
+ # Running autoheader. #
+ # -------------------- #
+
+ # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
+ # is used too.
+ #
+ # Just as for autoconf, up to date ness is performed by the tool
+ # itself.
+ #
+ # Run it before automake, since the latter checks the presence of
+ # config.h.in when it sees an AC_CONFIG_HEADERS.
+ if (!$uses_autoheader)
+ {
+ verb "$configure_ac: not using Autoheader";
+ }
+ else
+ {
+ xsystem ($autoheader);
+ }
+
+
+ # ------------------ #
+ # Running automake. #
+ # ------------------ #
+
+ if (!$uses_automake)
+ {
+ verb "$configure_ac: not using Automake";
+ }
+ else
+ {
+ # We should always run automake, and let it decide whether it shall
+ # update the file or not. In fact, the effect of `$force' is already
+ # included in `$automake' via `--no-force'.
+ xsystem ($automake);
+ }
+
+
+ # -------------- #
+ # Running make. #
+ # -------------- #
+
+ if ($make)
+ {
+ if (!-f "config.status")
+ {
+ verb "no config.status: cannot re-make";
+ }
+ else
+ {
+ xsystem ("./config.status --recheck");
+ xsystem ("./config.status");
+ if (!-f "Makefile")
+ {
+ verb "no Makefile: cannot re-make";
+ }
+ else
+ {
+ xsystem ("make");
+ }
+ }
+ }
+}
+
+
+# &autoreconf ($DIRECTORY)
+# ------------------------
+# Reconf the $DIRECTORY.
+sub autoreconf ($)
+{
+ my ($directory) = @_;
+ my $cwd = cwd;
+
+ # The format for this message is not free: taken from Emacs, itself
+ # using GNU Make's format.
+ verb "Entering directory `$directory'";
+ chdir $directory
+ or error "cannot chdir to $directory: $!";
+
+ autoreconf_current_directory;
+
+ # The format is not free: taken from Emacs, itself using GNU Make's
+ # format.
+ verb "Leaving directory `$directory'";
+ chdir $cwd
+ or error "cannot chdir to $cwd: $!";
+}
+
+
+## ------ ##
+## Main. ##
+## ------ ##
+
+# When debugging, it is convenient that all the related temporary
+# files be at the same place.
+mktmpdir ('ar');
+$ENV{'TMPDIR'} = $tmp;
+parse_args;
+
+# Autoreconf all the given configure.ac. Unless `--no-recursive' is passed,
+# AC_CONFIG_SUBDIRS will be traversed in &autoreconf_current_directory.
+for my $directory (@ARGV)
+ {
+ require_configure_ac ($directory);
+ autoreconf ($directory);
+ }
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/cleopatre/buildroot/toolchain/ccache/Config.in b/cleopatre/buildroot/toolchain/ccache/Config.in
new file mode 100644
index 0000000000..95f3a9c1ac
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/ccache/Config.in
@@ -0,0 +1,9 @@
+#
+
+comment "Ccache Options"
+
+config BR2_CCACHE
+ bool "Enable ccache support?"
+ help
+ Enable ccache support?
+
diff --git a/cleopatre/buildroot/toolchain/ccache/Config.in.2 b/cleopatre/buildroot/toolchain/ccache/Config.in.2
new file mode 100644
index 0000000000..dc09ac5a6f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/ccache/Config.in.2
@@ -0,0 +1,7 @@
+#
+
+config BR2_PACKAGE_CCACHE_TARGET
+ bool"ccache support in the target filesystem"
+ help
+ Add help text here.
+
diff --git a/cleopatre/buildroot/toolchain/ccache/ccache.mk b/cleopatre/buildroot/toolchain/ccache/ccache.mk
new file mode 100644
index 0000000000..35585713d2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/ccache/ccache.mk
@@ -0,0 +1,201 @@
+#############################################################
+#
+# build ccache to make recompiles faster on the build system
+#
+#############################################################
+CCACHE_VER:=2.4
+CCACHE_SITE:=http://samba.org/ftp/ccache
+CCACHE_SOURCE:=ccache-$(CCACHE_VER).tar.gz
+CCACHE_DIR1:=$(TOOL_BUILD_DIR)/ccache-$(CCACHE_VER)
+CCACHE_DIR2:=$(BUILD_DIR)/ccache-$(CCACHE_VER)
+CCACHE_CAT:=$(ZCAT)
+CCACHE_BINARY:=ccache
+CCACHE_TARGET_BINARY:=usr/bin/ccache
+
+$(DL_DIR)/$(CCACHE_SOURCE):
+ $(WGET) -P $(DL_DIR) $(CCACHE_SITE)/$(CCACHE_SOURCE)
+
+$(CCACHE_DIR1)/.unpacked: $(DL_DIR)/$(CCACHE_SOURCE)
+ $(CCACHE_CAT) $(DL_DIR)/$(CCACHE_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ touch $@
+
+$(CCACHE_DIR1)/.patched: $(CCACHE_DIR1)/.unpacked
+ # WARNING - this will break if the toolchain is moved.
+ # Should probably patch things to use a relative path.
+ $(SED) "s,getenv(\"CCACHE_PATH\"),\"$(STAGING_DIR)/usr/bin-ccache\",g" \
+ $(CCACHE_DIR1)/execute.c
+ # WARNING - this will break if the toolchain build dir is deleted.
+ $(SED) "s,getenv(\"CCACHE_DIR\"),\"$(CCACHE_DIR1)/cache\",g" \
+ $(CCACHE_DIR1)/ccache.c
+ mkdir -p $(CCACHE_DIR1)/cache
+ touch $@
+
+$(CCACHE_DIR1)/.configured: $(CCACHE_DIR1)/.patched
+ mkdir -p $(CCACHE_DIR1)
+ (cd $(CCACHE_DIR1); rm -rf config.cache; \
+ CC="$(HOSTCC)" \
+ $(CCACHE_DIR1)/configure \
+ --target=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ )
+ touch $@
+
+$(CCACHE_DIR1)/$(CCACHE_BINARY): $(CCACHE_DIR1)/.configured
+ $(MAKE) CC="$(HOSTCC)" -C $(CCACHE_DIR1)
+
+$(STAGING_DIR)/$(CCACHE_TARGET_BINARY): $(CCACHE_DIR1)/$(CCACHE_BINARY)
+ mkdir -p $(STAGING_DIR)/usr/bin
+ cp $(CCACHE_DIR1)/ccache $(STAGING_DIR)/usr/bin
+ # Keep the actual toolchain binaries in a directory at the same level.
+ # Otherwise, relative paths for include dirs break.
+ mkdir -p $(STAGING_DIR)/usr/bin-ccache
+ (cd $(STAGING_DIR)/usr/bin-ccache; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-cc; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc $(REAL_GNU_TARGET_NAME)-cc; \
+ )
+ [ -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc ] && \
+ mv $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc \
+ $(STAGING_DIR)/usr/bin-ccache/
+ (cd $(STAGING_DIR)/usr/bin; \
+ ln -fs ccache $(GNU_TARGET_NAME)-cc; \
+ ln -fs ccache $(GNU_TARGET_NAME)-gcc; \
+ ln -fs ccache $(REAL_GNU_TARGET_NAME)-cc; \
+ ln -fs ccache $(REAL_GNU_TARGET_NAME)-gcc; \
+ )
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+ [ -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++ ] && \
+ mv $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++ \
+ $(STAGING_DIR)/usr/bin-ccache/
+ [ -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-g++ ] && \
+ mv $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-g++ \
+ $(STAGING_DIR)/usr/bin-ccache/
+ (cd $(STAGING_DIR)/usr/bin; \
+ ln -fs ccache $(GNU_TARGET_NAME)-c++; \
+ ln -fs ccache $(GNU_TARGET_NAME)-g++;\
+ ln -fs ccache $(REAL_GNU_TARGET_NAME)-c++; \
+ ln -fs ccache $(REAL_GNU_TARGET_NAME)-g++; \
+ )
+ (cd $(STAGING_DIR)/usr/bin-ccache; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-c++ $(GNU_TARGET_NAME)-c++; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-g++ $(GNU_TARGET_NAME)-g++; \
+ )
+endif
+
+ccache: gcc $(STAGING_DIR)/$(CCACHE_TARGET_BINARY)
+
+ccache-clean:
+ rm -rf $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-cc
+ rm -rf $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-gcc
+ rm -rf $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc
+ rm -rf $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc
+ if [ -f $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-gcc ]; then \
+ mv $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-gcc \
+ $(STAGING_DIR)/usr/bin/; \
+ (cd $(STAGING_DIR)/usr/bin; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc \
+ $(REAL_GNU_TARGET_NAME)-cc; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc \
+ $(GNU_TARGET_NAME)-cc; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-gcc \
+ $(GNU_TARGET_NAME)-gcc; \
+ ); \
+ fi
+ if [ -f $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-c++ ]; then \
+ rm -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++; \
+ mv $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-c++ \
+ $(STAGING_DIR)/usr/bin/; \
+ fi
+ if [ -f $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-g++ ]; then \
+ rm -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-g++; \
+ mv $(STAGING_DIR)/usr/bin-ccache/$(REAL_GNU_TARGET_NAME)-g++ \
+ $(STAGING_DIR)/usr/bin/; \
+ fi
+ rm -rf $(STAGING_DIR)/usr/bin-ccache/*
+ (cd $(STAGING_DIR)/usr/bin; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-g++ $(GNU_TARGET_NAME)-c++; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-g++ $(GNU_TARGET_NAME)-g++; \
+ ln -fs $(REAL_GNU_TARGET_NAME)-g++ $(REAL_GNU_TARGET_NAME)-c++; \
+ )
+ -$(MAKE) -C $(CCACHE_DIR1) clean
+
+ccache-dirclean:
+ rm -rf $(CCACHE_DIR1)
+
+
+
+
+#############################################################
+#
+# build ccache for use on the target system
+#
+#############################################################
+
+$(CCACHE_DIR2)/.unpacked: $(DL_DIR)/$(CCACHE_SOURCE)
+ $(CCACHE_CAT) $(DL_DIR)/$(CCACHE_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
+ touch $@
+
+$(CCACHE_DIR2)/.patched: $(CCACHE_DIR2)/.unpacked
+ touch $@
+
+$(CCACHE_DIR2)/.configured: $(CCACHE_DIR2)/.patched
+ mkdir -p $(CCACHE_DIR2)
+ (cd $(CCACHE_DIR2); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_OPTS) \
+ $(CCACHE_DIR2)/configure \
+ --target=$(GNU_TARGET_NAME) \
+ --host=$(GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc \
+ --datadir=/usr/share \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ $(DISABLE_NLS) \
+ )
+ touch $@
+
+$(CCACHE_DIR2)/$(CCACHE_BINARY): $(CCACHE_DIR2)/.configured
+ $(MAKE) -C $(CCACHE_DIR2) CFLAGS="$(TARGET_CFLAGS)"
+
+$(TARGET_DIR)/$(CCACHE_TARGET_BINARY): $(CCACHE_DIR2)/$(CCACHE_BINARY)
+ $(MAKE) DESTDIR=$(TARGET_DIR) -C $(CCACHE_DIR2) install
+ rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
+ $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+ # put a bunch of symlinks into /bin, since that is earlier
+ # in the default PATH than /usr/bin where gcc lives
+ (cd $(TARGET_DIR)/bin; \
+ ln -fs /usr/bin/ccache cc; \
+ ln -fs /usr/bin/ccache gcc; \
+ ln -fs /usr/bin/ccache c++; \
+ ln -fs /usr/bin/ccache g++; \
+ )
+
+ccache_target: uclibc $(TARGET_DIR)/$(CCACHE_TARGET_BINARY)
+
+ccache_target-sources: $(DL_DIR)/$(CCACHE_SOURCE)
+
+ccache_target-clean:
+ rm -f $(TARGET_DIR)/$(CCACHE_TARGET_BINARY)
+ -$(MAKE) -C $(CCACHE_DIR2) clean
+
+ccache_target-dirclean:
+ rm -rf $(CCACHE_DIR2)
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+ifeq ($(strip $(BR2_CCACHE)),y)
+TARGETS+=ccache
+endif
+ifeq ($(strip $(BR2_PACKAGE_CCACHE_TARGET)),y)
+TARGETS+=ccache_target
+endif
diff --git a/cleopatre/buildroot/toolchain/dependencies/check-host-lzma.sh b/cleopatre/buildroot/toolchain/dependencies/check-host-lzma.sh
new file mode 100755
index 0000000000..34e8f03792
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/dependencies/check-host-lzma.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+ok=""
+
+for bin in /usr/bin/lzma $LZMA
+do
+# TODO: add check for proper functionality here..
+ $bin --version > /dev/null 2>&1 && ok="$bin"
+ if test "x$ok" != "x" ; then
+ break
+ fi
+done
+echo "$ok"
diff --git a/cleopatre/buildroot/toolchain/dependencies/check-host-sed.sh b/cleopatre/buildroot/toolchain/dependencies/check-host-sed.sh
new file mode 100755
index 0000000000..71f0eb9e8c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/dependencies/check-host-sed.sh
@@ -0,0 +1,32 @@
+SEDLIST="/usr/bin/sed /bin/sed sed gnused gsed"
+
+for SED in $SEDLIST
+do
+ if ! test -x $SED ; then
+ SED=$(which $SED 2> /dev/null)
+ if ! test -x "$SED" > /dev/null ; then
+ SED=""
+ continue
+ fi
+ fi
+
+ echo "HELLO" > .sedtest
+ $SED -i -e "s/HELLO/GOODBYE/" .sedtest >/dev/null 2>&1
+ RESULT=$(cat .sedtest)
+
+ if test $? != 0 ; then
+ SED=""
+ elif test -e ".sedtest-e" ; then
+ rm -f ".sedtest-e"
+ SED=""
+ elif [ "x$RESULT" = "x" ] || [ "$RESULT" != "GOODBYE" ] > /dev/null ;
+ then
+ SED=""
+ fi
+
+ rm -f .sedtest
+ if [ ! -z "$SED" ] ; then
+ break
+ fi
+done
+echo $SED
diff --git a/cleopatre/buildroot/toolchain/dependencies/dependencies.mk b/cleopatre/buildroot/toolchain/dependencies/dependencies.mk
new file mode 100644
index 0000000000..d50042462c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/dependencies/dependencies.mk
@@ -0,0 +1,35 @@
+######################################################################
+#
+# Check buildroot dependencies and bail out if the user's
+# system is judged to be lacking....
+#
+######################################################################
+
+DEPENDENCIES_HOST_PREREQ:=
+ifeq ($(BR2_STRIP_sstrip),y)
+DEPENDENCIES_HOST_PREREQ+=sstrip_host
+endif
+ifneq ($(findstring y,$(BR2_KERNEL_HEADERS_LZMA)),)
+DEPENDENCIES_HOST_PREREQ+=host-lzma
+endif
+
+dependencies: host-sed $(DEPENDENCIES_HOST_PREREQ)
+ @HOSTCC="$(firstword $(HOSTCC))" MAKE="$(MAKE)" \
+ HOST_SED_DIR="$(HOST_SED_DIR)" \
+ $(TOPDIR)/toolchain/dependencies/dependencies.sh
+
+dependencies-source:
+
+dependencies-clean:
+ rm -f $(SSTRIP_TARGET)
+
+dependencies-dirclean:
+ true
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+.PHONY: dependencies
+
diff --git a/cleopatre/buildroot/toolchain/dependencies/dependencies.sh b/cleopatre/buildroot/toolchain/dependencies/dependencies.sh
new file mode 100755
index 0000000000..170f437286
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/dependencies/dependencies.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+# vi: set sw=4 ts=4:
+#set -x
+
+echo ""
+echo "Checking build system dependencies:"
+export LC_ALL=C
+
+#############################################################
+#
+# check build system 'environment'
+#
+#############################################################
+if test -n "$BUILDROOT_DL_DIR" ; then
+ /bin/echo -e "Overriding \$(DL_DIR) in '.config'. Ok"
+ /bin/echo -e "External download directory: Ok ($BUILDROOT_DL_DIR)"
+else
+ echo "BUILDROOT_DL_DIR clean: Ok"
+fi
+
+if test -n "$CC" ; then
+ echo "CC clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CC' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+echo "CC clean: Ok"
+
+if test -n "$CXX" ; then
+ echo "CXX clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CXX' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+echo "CXX clean: Ok"
+
+
+if test -n "$CPP" ; then
+ echo "CPP clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CPP' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+echo "CPP clean: Ok"
+
+
+if test -n "$CFLAGS" ; then
+ echo "CFLAGS clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CFLAGS' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+echo "CFLAGS clean: Ok"
+
+if test -n "$INCLUDES" ; then
+ echo "INCLUDES clean: FALSE"
+ /bin/echo -e "WARNING: INCLUDES contains:\n\t'$INCLUDES'"
+else
+ echo "INCLUDES clean: Ok"
+fi
+
+if test -n "$CXXFLAGS" ; then
+ echo "CXXFLAGS clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CXXFLAGS' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+echo "CXXFLAGS clean: Ok"
+
+if test -n "$GREP_OPTIONS" ; then
+ echo "GREP_OPTIONS clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset GREP_OPTIONS' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+
+if test -n "$CROSS_COMPILE" ; then
+ echo "CROSS_COMPILE clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset CROSS_COMPILE' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+
+if test -n "$ARCH" ; then
+ echo "ARCH clean: FALSE"
+ /bin/echo -e "\n\nYou must run 'unset ARCH' so buildroot can run with";
+ /bin/echo -e "a clean environment on your build machine\n";
+ exit 1;
+fi;
+
+
+echo "WORKS" | grep "WORKS" >/dev/null 2>&1
+if test $? != 0 ; then
+ echo "grep works: FALSE"
+ exit 1
+fi
+
+# sanity check for CWD in LD_LIBRARY_PATH
+# try not to rely on egrep..
+if test -n "$LD_LIBRARY_PATH" ; then
+ /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep ':.:' >/dev/null 2>&1 ||
+ /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep 'TRiGGER_start:' >/dev/null 2>&1 ||
+ /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep ':TRiGGER_end' >/dev/null 2>&1 ||
+ /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep '::' >/dev/null 2>&1
+ if test $? = 0; then
+ echo "LD_LIBRARY_PATH sane: FALSE"
+ echo "You seem to have the current working directory in your"
+ echo "LD_LIBRARY_PATH environment variable. This doesn't work."
+ exit 1;
+ else
+ echo "LD_LIBRARY_PATH sane: Ok"
+ fi
+fi;
+
+
+
+#############################################################
+#
+# check build system 'which'
+#
+#############################################################
+if ! which which > /dev/null ; then
+ echo "which installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'which' on your build machine\n";
+ exit 1;
+fi;
+echo "which installed: Ok"
+
+
+
+#############################################################
+#
+# check build system 'sed'
+#
+#############################################################
+SED=$(toolchain/dependencies/check-host-sed.sh)
+
+if [ -z "$SED" ] ; then
+ XSED=$HOST_SED_DIR/bin/sed
+ echo "sed works: No, using buildroot version instead"
+else
+ XSED=$SED
+ echo "sed works: Ok ($SED)"
+fi
+
+
+
+
+#############################################################
+#
+# check build system 'make'
+#
+#############################################################
+MAKE=$(which make 2> /dev/null)
+if [ -z "$MAKE" ] ; then
+ echo "make installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'make' on your build machine\n";
+ exit 1;
+fi;
+MAKE_VERSION=$($MAKE --version 2>&1 | $XSED -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
+if [ -z "$MAKE_VERSION" ] ; then
+ echo "make installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'make' on your build machine\n";
+ exit 1;
+fi;
+MAKE_MAJOR=$(echo $MAKE_VERSION | $XSED -e "s/\..*//g")
+MAKE_MINOR=$(echo $MAKE_VERSION | $XSED -e "s/^$MAKE_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
+if [ $MAKE_MAJOR -lt 3 ] || [ $MAKE_MAJOR -eq 3 -a $MAKE_MINOR -lt 80 ] ; then
+ echo "You have make '$MAKE_VERSION' installed. GNU make >=3.80 is required"
+ exit 1;
+fi;
+echo "GNU make version '$MAKE_VERSION': Ok"
+
+
+
+#############################################################
+#
+# check build system 'gcc'
+#
+#############################################################
+COMPILER=$(which $HOSTCC 2> /dev/null)
+if [ -z "$COMPILER" ] ; then
+ COMPILER=$(which cc 2> /dev/null)
+fi;
+if [ -z "$COMPILER" ] ; then
+ echo "C Compiler installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'gcc' on your build machine\n";
+ exit 1;
+fi;
+
+COMPILER_VERSION=$($COMPILER --version 2>&1 | $XSED -e 's/^.*(.CC) \([0-9\.]\)/\1/g' -e "s/[-\ ].*//g" -e '1q')
+if [ -z "$COMPILER_VERSION" ] ; then
+ echo "gcc installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'gcc' on your build machine\n";
+ exit 1;
+fi;
+COMPILER_MAJOR=$(echo $COMPILER_VERSION | $XSED -e "s/\..*//g")
+COMPILER_MINOR=$(echo $COMPILER_VERSION | $XSED -e "s/^$COMPILER_MAJOR\.//g" -e "s/\..*//g")
+if [ $COMPILER_MAJOR -lt 3 -o $COMPILER_MAJOR -eq 2 -a $COMPILER_MINOR -lt 95 ] ; then
+ echo "You have gcc '$COMPILER_VERSION' installed. gcc >= 2.95 is required"
+ exit 1;
+fi;
+echo "C compiler '$COMPILER'"
+echo "C compiler version '$COMPILER_VERSION': Ok"
+
+
+# check for host CXX
+CXXCOMPILER=$(which $HOSTCXX 2> /dev/null)
+if [ -z "$CXXCOMPILER" ] ; then
+ CXXCOMPILER=$(which c++ 2> /dev/null)
+fi
+if [ -z "$CXXCOMPILER" ] ; then
+ echo "C++ Compiler installed: FALSE"
+ /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"
+ #exit 1
+fi
+if [ ! -z "$CXXCOMPILER" ] ; then
+ CXXCOMPILER_VERSION=$($CXXCOMPILER --version 2>&1 | $XSED -e 's/^.*(.CC) \([0-9\.]\)/\1/g' -e "s/[-\ ].*//g" -e '1q')
+ if [ -z "$CXXCOMPILER_VERSION" ] ; then
+ echo "c++ installed: FALSE"
+ /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"
+ #exit 1
+ fi
+
+ CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | $XSED -e "s/\..*//g")
+ CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | $XSED -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")
+ if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then
+ echo "You have g++ '$CXXCOMPILER_VERSION' installed. g++ >= 2.95 is required"
+ exit 1
+ fi
+ echo "C++ compiler '$CXXCOMPILER'"
+ echo "C++ compiler version '$CXXCOMPILER_VERSION': Ok"
+fi
+
+#############################################################
+#
+# check build system 'awk'
+#
+#############################################################
+if ! which awk > /dev/null ; then
+ echo "awk installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'awk' on your build machine\n";
+ exit 1;
+fi;
+echo "awk installed: Ok"
+
+#############################################################
+#
+# check build system 'bison'
+#
+#############################################################
+if ! which bison > /dev/null ; then
+ echo "bison installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'bison' on your build machine\n";
+ exit 1;
+fi;
+echo "bison installed: Ok"
+
+
+#############################################################
+#
+# check build system 'flex'
+#
+#############################################################
+if ! which flex > /dev/null ; then
+ echo "flex installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'flex' on your build machine\n";
+ exit 1;
+fi;
+echo "flex installed: Ok"
+
+
+#############################################################
+#
+# check build system 'gettext'
+#
+#############################################################
+if ! which msgfmt > /dev/null ; then \
+ echo "gettext installed: FALSE"
+ /bin/echo -e "\n\nYou must install 'gettext' on your build machine\n"; \
+ exit 1; \
+fi;
+echo "gettext installed: Ok"
+
+
+if ! which makeinfo > /dev/null ; then \
+ echo "makeinfo installed: FALSE"
+ /bin/echo -e "\n\nMost likely some packages will fail to build their documentation"
+ echo "Either install 'makeinfo' on your host or fix the respective packages."
+ echo "Makeinfo can usually be found in the texinfo package for your host."
+else
+ echo "makeinfo installed: Ok"
+fi
+
+
+#############################################################
+#
+# All done
+#
+#############################################################
+echo "Build system dependencies: Ok"
+echo ""
+
diff --git a/cleopatre/buildroot/toolchain/elf2flt/Config.in b/cleopatre/buildroot/toolchain/elf2flt/Config.in
new file mode 100644
index 0000000000..b4e450a646
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/Config.in
@@ -0,0 +1,10 @@
+config BR2_ELF2FLT
+ bool "Enable elf2flt support?"
+ depends on BR2_arm || BR2_sh || BR2_sparc
+ help
+ uCLinux uses a Binary Flat format commonly known as BFLT. It
+ is a relatively simple and lightweight executable format
+ based on the original a.out format.
+
+ This option compiles the required tools and makes the required
+ modifications on your toolchain (linker).
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt.mk b/cleopatre/buildroot/toolchain/elf2flt/elf2flt.mk
new file mode 100644
index 0000000000..dd89c06099
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt.mk
@@ -0,0 +1,52 @@
+#############################################################
+#
+# elf2flt
+#
+#############################################################
+
+# we keep a local checkout of uClinux CVS
+ELF2FLT_SOURCE:=$(ELF2FLT_DIR)/elf2flt
+ELF2FLT_DIR:=$(TOOL_BUILD_DIR)/elf2flt
+ELF2FLT_BINARY:=elf2flt
+
+$(ELF2FLT_DIR)/.unpacked:
+ cp -r toolchain/elf2flt/elf2flt "$(TOOL_BUILD_DIR)/elf2flt"
+ touch $@
+
+$(ELF2FLT_DIR)/.patched: $(ELF2FLT_DIR)/.unpacked
+ifeq ($(strip $(ARCH)),nios2)
+ $(SED) "s,STAGING_DIR,$(STAGING_DIR),g;" toolchain/elf2flt/elf2flt.nios2.conditional
+ $(SED) "s,CROSS_COMPILE_PREFIX,$(REAL_GNU_TARGET_NAME),g;" toolchain/elf2flt/elf2flt.nios2.conditional
+ toolchain/patch-kernel.sh $(ELF2FLT_DIR) toolchain/elf2flt elf2flt.nios2.conditional
+endif
+ touch $@
+
+$(ELF2FLT_DIR)/.configured: $(ELF2FLT_DIR)/.patched
+ (cd $(ELF2FLT_DIR); rm -rf config.cache; \
+ $(ELF2FLT_DIR)/configure \
+ --with-bfd-include-dir=$(BINUTILS_DIR1)/bfd/ \
+ --with-binutils-include-dir=$(BINUTILS_DIR)/include/ \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --with-libbfd=$(BINUTILS_DIR1)/bfd/libbfd.a \
+ --with-libiberty=$(BINUTILS_DIR1)/libiberty/libiberty.a \
+ --prefix=$(STAGING_DIR))
+ touch $@
+
+$(ELF2FLT_DIR)/$(ELF2FLT_BINARY): $(ELF2FLT_DIR)/.configured
+ $(MAKE) -C $(ELF2FLT_DIR) all
+ $(MAKE) -C $(ELF2FLT_DIR) install
+ ln -snf $(REAL_GNU_TARGET_NAME)-elf2flt $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-elf2flt
+ ln -snf $(REAL_GNU_TARGET_NAME)-flthdr $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-flthdr
+ ln -snf $(REAL_GNU_TARGET_NAME)-ld.real $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-ld.real
+
+elf2flt: uclibc_target uclibc-configured binutils gcc $(ELF2FLT_DIR)/$(ELF2FLT_BINARY)
+
+elf2flt-clean:
+ rm -rf $(ELF2FLT_SOURCE)
+
+elf2flt-dirclean:
+ rm -rf $(ELF2FLT_SOURCE)
+
+ifeq ($(strip $(BR2_ELF2FLT)),y)
+TARGETS+=elf2flt
+endif
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt.nios2.conditional b/cleopatre/buildroot/toolchain/elf2flt/elf2flt.nios2.conditional
new file mode 100644
index 0000000000..96a3a9710d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt.nios2.conditional
@@ -0,0 +1,47 @@
+--- elf2flt/elf2flt.ld
++++ elf2flt/elf2flt.ld
+@@ -63,12 +63,16 @@
+ *(.eh_frame)
+ *(.gcc_except_table)
+
++ /* nios2 need gp */
++ _gp = ABSOLUTE(ALIGN(16) + 0x7ff0);
++ PROVIDE(gp = _gp);
++
+ /* Microblaze has .sdata and .sbss (small bss). They must
+ be contiguous, so please don't move any of this. JW */
+ _ssrw = . ;
+ *(.sdata)
+ *(.sdata.*)
+- *(.sbss) /* Don't move this! */
++ *(.sbss .gnu.linkonce.sb*) /* Don't move this! */
+ _essrw = . ;
+
+ _ssrw_size = _essrw - _ssrw;
+@@ -176,4 +180,6 @@
+ .debug_line 0 : { *(.debug_line) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
++ .debug_frame 0 : { *(.debug_frame) }
++ .debug_str 0 : { *(.debug_str) }
+ }
+--- elf2flt/ld-elf2flt.in
++++ elf2flt/ld-elf2flt.in
+@@ -132,7 +132,7 @@
+ esac
+ ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -4 - 4`"
+ fi
+- if [ "@emit_relocs@" = "yes" ]
++ if [ "no" = "yes" ]
+ then
+ SEDOP="$SEDOP -e s/^SINGLE_LINK://"
+ else
+@@ -155,7 +155,7 @@
+ LDSCRIPT="$NEWLDSCRIPT"
+ fi
+
+- if [ "@emit_relocs@" = "yes" ]
++ if [ "no" = "yes" ]
+ then
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -q -o "$OFILE.gdb" $ARG1 ||exit $?
+ RFILE="$OFILE.gdb"
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/.cvsignore b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/.cvsignore
new file mode 100644
index 0000000000..18cff9ae11
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/.cvsignore
@@ -0,0 +1,3 @@
+.cvsignore
+.svn
+maketarball.sh
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Entries b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Entries
new file mode 100644
index 0000000000..1b3750f10c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Entries
@@ -0,0 +1,17 @@
+/LICENSE.TXT/1.1/Tue Jan 10 04:34:09 2006//
+/README/1.5/Tue Jan 10 04:34:09 2006/-ko/
+/config.guess/1.2/Tue Jan 10 04:34:08 2006/-ko/
+/e1-elf2flt.ld/1.1/Tue Jan 10 04:34:09 2006//
+/flat.h/1.6/Tue Jan 10 04:34:08 2006/-ko/
+/install-sh/1.1.1.1/Tue Jan 10 04:34:08 2006/-ko/
+/stubs.c/1.1/Tue Jan 10 04:34:08 2006//
+/config.sub/1.8/Wed Jan 11 13:36:39 2006/-ko/
+/cygwin-elf.h/1.4/Wed Jan 11 13:36:39 2006//
+/Makefile.in/1.17/Result of merge/-ko/
+/configure/1.12/Sun Jan 28 05:27:28 2007/-ko/
+/configure.in/1.10/Sun Jan 28 05:27:28 2007/-ko/
+/elf2flt.c/1.46/Result of merge/-ko/
+/elf2flt.ld/1.15/Sun Jan 28 05:27:28 2007/-ko/
+/flthdr.c/1.10/Sun Jan 28 05:27:28 2007/-ko/
+/ld-elf2flt.in/1.15/Sun Jan 28 05:27:28 2007//
+D
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Repository b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Repository
new file mode 100644
index 0000000000..61a695f7c2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Repository
@@ -0,0 +1 @@
+elf2flt
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Root b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Root
new file mode 100644
index 0000000000..0b9f52725e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.uclinux.org:/var/cvs
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/LICENSE.TXT b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/LICENSE.TXT
new file mode 100644
index 0000000000..5b6e7c66c2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/LICENSE.TXT
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/Makefile.in b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/Makefile.in
new file mode 100644
index 0000000000..acead9f6f9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/Makefile.in
@@ -0,0 +1,81 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+libdir = @libdir@
+includedir = @includedir@
+
+CC = @CC@
+CPU = @target_cpu@
+TARGET = @target_alias@
+CFLAGS = @CFLAGS@
+INCLUDES = @bfd_include_dir@ @binutils_include_dir@
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+INSTALL = @INSTALL@
+DEFS = @DEFS@ -DTARGET_$(CPU)
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+
+HOST = @host_alias@
+
+ifneq (,$(findstring mingw32,$(HOST)))
+ LIBS := $(LIBS) -lws2_32
+endif
+
+# force link order under cygwin to avoid getopts / libiberty clash
+ifneq ($(strip $(shell gcc -v 2>&1 | grep "cygwin")),)
+ LIBS := -lcygwin $(LIBS)
+endif
+
+CCFLAGS = $(CFLAGS) $(DEFS) $(INCLUDES)
+
+LDFILE= elf2flt.ld
+ifeq ($(strip $(CPU)),e1)
+SRC_LDFILE= $(CPU)-elf2flt.ld
+else
+SRC_LDFILE= elf2flt.ld
+endif
+
+target_bindir = $(prefix)/$(TARGET)/bin
+target_libdir = $(prefix)/$(TARGET)/lib
+
+
+PROG_ELF2FLT = elf2flt$(EXEEXT)
+PROG_FLTHDR = flthdr$(EXEEXT)
+PROGS = $(PROG_ELF2FLT) $(PROG_FLTHDR)
+
+all: $(PROGS)
+
+$(PROG_ELF2FLT): elf2flt.c stubs.c Makefile
+ $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $(srcdir)/elf2flt.c $(srcdir)/stubs.c $(LIBS)
+
+$(PROG_FLTHDR): flthdr.c Makefile
+ $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $(srcdir)/flthdr.c $(LIBS)
+
+clean:
+ -rm -f $(PROGS) *.$(OBJEXT)
+
+distclean: clean
+ -rm -f Makefile config.log config.status config.cache ld-elf2flt
+
+install:
+ $(INSTALL) -d $(bindir)
+ $(INSTALL) -d $(target_bindir)
+ $(INSTALL) -d $(target_libdir)
+ $(INSTALL) -m 755 $(PROG_FLTHDR) $(bindir)/$(TARGET)-$(PROG_FLTHDR)
+ $(INSTALL) -m 755 $(PROG_FLTHDR) $(target_bindir)/$(PROG_FLTHDR)
+ $(INSTALL) -m 755 $(PROG_ELF2FLT) $(bindir)/$(TARGET)-$(PROG_ELF2FLT)
+ $(INSTALL) -m 755 $(PROG_ELF2FLT) $(target_bindir)/$(PROG_ELF2FLT)
+ [ -f $(bindir)/$(TARGET)-ld.real$(EXEEXT) ] || \
+ mv $(bindir)/$(TARGET)-ld$(EXEEXT) $(bindir)/$(TARGET)-ld.real$(EXEEXT)
+ [ -f $(target_bindir)/ld.real$(EXEEXT) ] || \
+ mv $(target_bindir)/ld$(EXEEXT) $(target_bindir)/ld.real$(EXEEXT)
+ $(INSTALL) -m 755 ld-elf2flt $(bindir)/$(TARGET)-ld
+ $(INSTALL) -m 755 ld-elf2flt $(target_bindir)/ld
+ $(INSTALL) -m 644 $(srcdir)/$(SRC_LDFILE) $(target_libdir)/$(LDFILE)
+
+
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/README b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/README
new file mode 100644
index 0000000000..6e8a687e10
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/README
@@ -0,0 +1,62 @@
+
+README - elf2flt
+----------------
+
+Copyright (C) 2001-2003, SnapGear (www.snapgear.com)
+davidm@snapgear.com
+gerg@snapgear.com
+
+This is Free Software, under the GNU Public Licence v2 or greater. See
+LICENSE.TXT for more details.
+
+Elf2flt with PIC, ZFLAT and full reloc support. Currently supported
+targets include: m68k/ColdFire, ARM, Sparc, NEC v850, MicroBlaze,
+h8300 and SuperH.
+
+COMPILING:
+
+You need an appropriate libbfd.a and libiberty.a for your target to
+build this tool. They are normally part of the binutils package.
+
+To compile elf2flt do:
+
+ ./configure --target=<ARCH> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+ make
+ make install
+
+The <ARCH> argument to configure specifies what the target architecture is.
+This should be the same target as you used to build the binutils and gcc
+cross development tools. The --with-libbfd and --with-libiberty arguments
+specify where the libbfd.a and libiberty.a library files are to use.
+
+
+FILES:
+
+README - this file
+configure - autoconf configuration shell script
+configure.in- original autoconf file
+config.* - autoconf support scripts
+Makefile.in - Makefile template used by configure
+elf2flt.c - the source
+flthdr.c - flat header manipulation program
+flat.h - header from uClinux kernel sources
+elf2flt.ld - an example linker script that works for C/C++ and uClinux
+ld-elf2flt - A linker replacement that implements a -elf2flt option for the
+ linker and runs elf2flt automatically for you. It auto
+ detects PIC/non-PIC code and adjusts its option accordingly.
+ It uses the environment variable FLTFLAGS when running
+ elf2flt. It runs /.../m68k-elf-ld.real to do the actual
+ linking.
+
+TIPS:
+
+The ld-elf2flt produces 2 files as output. The binary flat file X, and
+X.gdb which is used for debugging and PIC purposes.
+
+The '-p' option requires an elf executable linked at address 0. The
+elf2flt.ld provided will generate the correct format binary when linked
+with the real linker with *no* '-r' option for the linker.
+
+The '-r' flag can be added to PIC builds to get contiguous code/data. This
+is good for loading application symbols into gdb (add-symbol-file XXX.gdb).
+
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.guess b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.guess
new file mode 100755
index 0000000000..afcb19c1d7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.guess
@@ -0,0 +1,1418 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-10-16'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvmeppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mipseb-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha*:OpenVMS:*:*)
+ echo alpha-hp-vms
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit 0;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit 0 ;;
+ DRS?6000:UNIX_SV:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7 && exit 0 ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c \
+ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && exit 0
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ # avoid double evaluation of $set_cc_for_build
+ test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ *:UNICOS/mp:*:*)
+ echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ # Determine whether the default compiler uses glibc.
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #if __GLIBC__ >= 2
+ LIBC=gnu
+ #else
+ LIBC=
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ # GNU/KFreeBSD systems have a "k" prefix to indicate we are using
+ # FreeBSD's kernel, but not the complete OS.
+ case ${LIBC} in gnu) kernel_only='k' ;; esac
+ echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ x86:Interix*:[34]*)
+ echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+ exit 0 ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit 0 ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit 0 ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit 0 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0 ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0 ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit 0 ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #ifdef __INTEL_COMPILER
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit 0 ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit 0 ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit 0 ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ case `uname -p` in
+ *86) UNAME_PROCESSOR=i686 ;;
+ powerpc) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.sub b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.sub
new file mode 100755
index 0000000000..4279c84913
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/config.sub
@@ -0,0 +1,1577 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-04-22'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | microblaze \
+ | we32k \
+ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m32c)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ m32c-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure
new file mode 100755
index 0000000000..d672662bc6
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure
@@ -0,0 +1,4719 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="elf2flt.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CPP EGREP bfd_include_dir binutils_include_dir binutils_ldscript_dir got_check emit_relocs LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+ --target=TARGET configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-got-check - disable check for GOT (needed on H8)
+ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-libbfd=<file> path to libbfd.a library to use
+ --with-libiberty=<file> path to libiberty.a library to use
+ --with-bfd-include-dir=<dir> include path for correct bfd.h
+ --with-binutils-include-dir=<dir> include path for binutils headers
+ --with-binutils-ldscript-dir=<dir> path to install elf2flt.ld
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-libbfd or --without-libbfd was given.
+if test "${with_libbfd+set}" = set; then
+ withval="$with_libbfd"
+ ac_libbfd=$withval
+else
+ ac_libbfd=NONE
+
+fi;
+
+
+# Check whether --with-libiberty or --without-libiberty was given.
+if test "${with_libiberty+set}" = set; then
+ withval="$with_libiberty"
+ ac_libiberty=$withval
+else
+ ac_libiberty=NONE
+
+fi;
+
+
+# Check whether --with-bfd-include-dir or --without-bfd-include-dir was given.
+if test "${with_bfd_include_dir+set}" = set; then
+ withval="$with_bfd_include_dir"
+ ac_bfd_include_dir=$withval
+else
+ ac_bfd_include_dir=NONE
+
+fi;
+
+
+# Check whether --with-binutils-include-dir or --without-binutils-include-dir was given.
+if test "${with_binutils_include_dir+set}" = set; then
+ withval="$with_binutils_include_dir"
+ ac_binutils_include_dir=$withval
+else
+ ac_binutils_include_dir=NONE
+
+fi;
+
+
+# Check whether --with-binutils-ldscript-dir or --without-binutils-ldscript-dir was given.
+if test "${with_binutils_ldscript_dir+set}" = set; then
+ withval="$with_binutils_ldscript_dir"
+ ac_binutils_ldscript_dir=$withval
+else
+ ac_binutils_ldscript_dir=NONE
+
+fi;
+
+# Check whether --enable-got-check or --disable-got-check was given.
+if test "${enable_got_check+set}" = set; then
+ enableval="$enable_got_check"
+ got_check=$enableval
+else
+ got_check=yes
+
+fi;
+
+# Check whether --enable-emit_relocs or --disable-emit_relocs was given.
+if test "${enable_emit_relocs+set}" = set; then
+ enableval="$enable_emit_relocs"
+ emit_relocs=$enableval
+else
+ emit_relocs=yes
+
+fi;
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6
+if test "${ac_cv_target+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+ ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6
+target=$ac_cv_target
+target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+if test "$ac_libiberty" = "NONE"; then
+
+
+echo "$as_me:$LINENO: checking for objalloc_create in -liberty" >&5
+echo $ECHO_N "checking for objalloc_create in -liberty... $ECHO_C" >&6
+if test "${ac_cv_lib_iberty_objalloc_create+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-liberty $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char objalloc_create ();
+int
+main ()
+{
+objalloc_create ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_iberty_objalloc_create=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_iberty_objalloc_create=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_iberty_objalloc_create" >&5
+echo "${ECHO_T}$ac_cv_lib_iberty_objalloc_create" >&6
+if test $ac_cv_lib_iberty_objalloc_create = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBIBERTY 1
+_ACEOF
+
+ LIBS="-liberty $LIBS"
+
+fi
+
+ ac_libiberty=auto
+else
+ LIBS="$ac_libiberty $LIBS"
+fi
+if test "$ac_libbfd" = "NONE"; then
+
+echo "$as_me:$LINENO: checking for bfd_openr in -lbfd" >&5
+echo $ECHO_N "checking for bfd_openr in -lbfd... $ECHO_C" >&6
+if test "${ac_cv_lib_bfd_bfd_openr+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbfd $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char bfd_openr ();
+int
+main ()
+{
+bfd_openr ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_bfd_bfd_openr=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_bfd_bfd_openr=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_bfd_bfd_openr" >&5
+echo "${ECHO_T}$ac_cv_lib_bfd_bfd_openr" >&6
+if test $ac_cv_lib_bfd_bfd_openr = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBBFD 1
+_ACEOF
+
+ LIBS="-lbfd $LIBS"
+
+fi
+
+ ac_libbfd=auto
+else
+ LIBS="$ac_libbfd $LIBS"
+fi
+
+bfd_include_dir=
+if test "$ac_bfd_include_dir" != "NONE"; then
+ bfd_include_dir="-I$ac_bfd_include_dir"
+fi
+
+binutils_include_dir=
+if test "$ac_binutils_include_dir" != "NONE"; then
+ binutils_include_dir="-I$ac_binutils_include_dir"
+fi
+
+binutils_ldscript_dir=
+if test "$ac_binutils_ldscript_dir" = "NONE"; then
+ ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
+fi
+binutils_ldscript_dir="$ac_binutils_ldscript_dir"
+
+if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
+ { { echo "$as_me:$LINENO: error:
+
+You need to specify the location of the libfd.a and libiberty.a
+host libraries from the binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+" >&5
+echo "$as_me: error:
+
+You need to specify the location of the libfd.a and libiberty.a
+host libraries from the binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+if test "$ac_bfd_include_dir" = "NONE" ; then
+ { { echo "$as_me:$LINENO: error:
+
+You need to specify the location of the bfd.h header from a
+configured/compiled version of the binutils package for your target.
+Without this your elf2flt may crash as it will try to use the
+systems bfd.h which may be from a different binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+" >&5
+echo "$as_me: error:
+
+You need to specify the location of the bfd.h header from a
+configured/compiled version of the binutils package for your target.
+Without this your elf2flt may crash as it will try to use the
+systems bfd.h which may be from a different binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+for ac_header in fcntl.h unistd.h bfd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this. */
+ typedef int charset[2];
+ const charset x;
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *ccp;
+ char **p;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ ccp = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++ccp;
+ p = (char**) ccp;
+ ccp = (char const *const *) p;
+ { /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ }
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_const=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+
+
+for ac_func in vprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+echo "$as_me:$LINENO: checking for _doprnt" >&5
+echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6
+if test "${ac_cv_func__doprnt+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define _doprnt to an innocuous variant, in case <limits.h> declares _doprnt.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define _doprnt innocuous__doprnt
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char _doprnt (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef _doprnt
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char _doprnt ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub__doprnt) || defined (__stub____doprnt)
+choke me
+#else
+char (*f) () = _doprnt;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != _doprnt;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func__doprnt=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func__doprnt=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5
+echo "${ECHO_T}$ac_cv_func__doprnt" >&6
+if test $ac_cv_func__doprnt = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DOPRNT 1
+_ACEOF
+
+fi
+
+fi
+done
+
+
+
+
+for ac_func in dcgettext
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_files="$ac_config_files Makefile ld-elf2flt"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then we branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+cat >confdef2opt.sed <<\_ACEOF
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
+t quote
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
+t quote
+d
+: quote
+s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
+s,\[,\\&,g
+s,\],\\&,g
+s,\$,$$,g
+p
+_ACEOF
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT=`echo; echo .`
+DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
+rm -f confdef2opt.sed
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Report bugs to <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "ld-elf2flt" ) CONFIG_FILES="$CONFIG_FILES ld-elf2flt" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@target@,$target,;t t
+s,@target_cpu@,$target_cpu,;t t
+s,@target_vendor@,$target_vendor,;t t
+s,@target_os@,$target_os,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
+s,@bfd_include_dir@,$bfd_include_dir,;t t
+s,@binutils_include_dir@,$binutils_include_dir,;t t
+s,@binutils_ldscript_dir@,$binutils_ldscript_dir,;t t
+s,@got_check@,$got_check,;t t
+s,@emit_relocs@,$emit_relocs,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure.in b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure.in
new file mode 100644
index 0000000000..73443c6a3b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/configure.in
@@ -0,0 +1,134 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(elf2flt.c)
+
+AC_ARG_WITH(libbfd,
+ [ --with-libbfd=<file> path to libbfd.a library to use ],
+ [ ac_libbfd=$withval ],
+ [ ac_libbfd=NONE ]
+)
+
+AC_ARG_WITH(libiberty,
+ [ --with-libiberty=<file> path to libiberty.a library to use ],
+ [ ac_libiberty=$withval ],
+ [ ac_libiberty=NONE ]
+)
+
+AC_ARG_WITH(bfd-include-dir,
+ [ --with-bfd-include-dir=<dir> include path for correct bfd.h ],
+ [ ac_bfd_include_dir=$withval ],
+ [ ac_bfd_include_dir=NONE ]
+)
+
+AC_ARG_WITH(binutils-include-dir,
+ [ --with-binutils-include-dir=<dir> include path for binutils headers ],
+ [ ac_binutils_include_dir=$withval ],
+ [ ac_binutils_include_dir=NONE ]
+)
+
+AC_ARG_WITH(binutils-ldscript-dir,
+ [ --with-binutils-ldscript-dir=<dir> path to install elf2flt.ld ],
+ [ ac_binutils_ldscript_dir=$withval ],
+ [ ac_binutils_ldscript_dir=NONE ]
+)
+
+AC_ARG_ENABLE(got-check,
+ [ --disable-got-check - disable check for GOT (needed on H8) ],
+ [ got_check=$enableval ],
+ [ got_check=yes ]
+)
+
+AC_ARG_ENABLE(emit_relocs,
+ [ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
+ [ emit_relocs=$enableval ],
+ [ emit_relocs=yes ]
+)
+
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+
+dnl Checks for libraries.
+if test "$ac_libiberty" = "NONE"; then
+ AC_CHECK_LIB(iberty, objalloc_create)
+ ac_libiberty=auto
+else
+ LIBS="$ac_libiberty $LIBS"
+fi
+if test "$ac_libbfd" = "NONE"; then
+ AC_CHECK_LIB(bfd, bfd_openr)
+ ac_libbfd=auto
+else
+ LIBS="$ac_libbfd $LIBS"
+fi
+
+bfd_include_dir=
+if test "$ac_bfd_include_dir" != "NONE"; then
+ bfd_include_dir="-I$ac_bfd_include_dir"
+fi
+
+binutils_include_dir=
+if test "$ac_binutils_include_dir" != "NONE"; then
+ binutils_include_dir="-I$ac_binutils_include_dir"
+fi
+
+binutils_ldscript_dir=
+if test "$ac_binutils_ldscript_dir" = "NONE"; then
+ ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
+fi
+binutils_ldscript_dir="$ac_binutils_ldscript_dir"
+
+if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
+ AC_MSG_ERROR([
+
+You need to specify the location of the libfd.a and libiberty.a
+host libraries from the binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+])
+fi
+
+if test "$ac_bfd_include_dir" = "NONE" ; then
+ AC_MSG_ERROR([
+
+You need to specify the location of the bfd.h header from a
+configured/compiled version of the binutils package for your target.
+Without this your elf2flt may crash as it will try to use the
+systems bfd.h which may be from a different binutils package.
+
+Run configure again specifying these options:
+
+ ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
+])
+fi
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+
+dnl Checks for library functions.
+AC_FUNC_VPRINTF
+
+AC_CHECK_FUNCS(dcgettext)
+
+dnl Subsitute values
+AC_SUBST(target)
+AC_SUBST(target_alias)
+AC_SUBST(target_cpu)
+AC_SUBST(target_os)
+AC_SUBST(target_vendor)
+AC_SUBST(bfd_include_dir)
+AC_SUBST(binutils_include_dir)
+AC_SUBST(binutils_ldscript_dir)
+AC_SUBST(got_check)
+AC_SUBST(emit_relocs)
+
+AC_OUTPUT(Makefile ld-elf2flt)
+
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/cygwin-elf.h b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/cygwin-elf.h
new file mode 100644
index 0000000000..2523c0e04b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/cygwin-elf.h
@@ -0,0 +1,2171 @@
+/* This file defines standard ELF types, structures, and macros.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ELF_H
+#define _ELF_H 1
+
+#if defined(__MINGW32__)
+#include <stdint.h>
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+#else
+#include <features.h>
+#endif
+/* Standard ELF types. */
+
+#include <sys/types.h>
+
+/* Type for a 16-bit quantity. */
+typedef u_int16_t Elf32_Half;
+typedef u_int16_t Elf64_Half;
+
+/* Types for signed and unsigned 32-bit quantities. */
+typedef u_int32_t Elf32_Word;
+typedef int32_t Elf32_Sword;
+typedef u_int32_t Elf64_Word;
+typedef int32_t Elf64_Sword;
+
+/* Types for signed and unsigned 64-bit quantities. */
+typedef u_int64_t Elf32_Xword;
+typedef int64_t Elf32_Sxword;
+typedef u_int64_t Elf64_Xword;
+typedef int64_t Elf64_Sxword;
+
+/* Type of addresses. */
+typedef u_int32_t Elf32_Addr;
+typedef u_int64_t Elf64_Addr;
+
+/* Type of file offsets. */
+typedef u_int32_t Elf32_Off;
+typedef u_int64_t Elf64_Off;
+
+/* Type for section indices, which are 16-bit quantities. */
+typedef u_int16_t Elf32_Section;
+typedef u_int16_t Elf64_Section;
+
+/* Type for version symbol information. */
+typedef Elf32_Half Elf32_Versym;
+typedef Elf64_Half Elf64_Versym;
+
+
+/* The ELF file header. This appears at the start of every ELF file. */
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf32_Half e_type; /* Object file type */
+ Elf32_Half e_machine; /* Architecture */
+ Elf32_Word e_version; /* Object file version */
+ Elf32_Addr e_entry; /* Entry point virtual address */
+ Elf32_Off e_phoff; /* Program header table file offset */
+ Elf32_Off e_shoff; /* Section header table file offset */
+ Elf32_Word e_flags; /* Processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size in bytes */
+ Elf32_Half e_phentsize; /* Program header table entry size */
+ Elf32_Half e_phnum; /* Program header table entry count */
+ Elf32_Half e_shentsize; /* Section header table entry size */
+ Elf32_Half e_shnum; /* Section header table entry count */
+ Elf32_Half e_shstrndx; /* Section header string table index */
+} Elf32_Ehdr;
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf64_Half e_type; /* Object file type */
+ Elf64_Half e_machine; /* Architecture */
+ Elf64_Word e_version; /* Object file version */
+ Elf64_Addr e_entry; /* Entry point virtual address */
+ Elf64_Off e_phoff; /* Program header table file offset */
+ Elf64_Off e_shoff; /* Section header table file offset */
+ Elf64_Word e_flags; /* Processor-specific flags */
+ Elf64_Half e_ehsize; /* ELF header size in bytes */
+ Elf64_Half e_phentsize; /* Program header table entry size */
+ Elf64_Half e_phnum; /* Program header table entry count */
+ Elf64_Half e_shentsize; /* Section header table entry size */
+ Elf64_Half e_shnum; /* Section header table entry count */
+ Elf64_Half e_shstrndx; /* Section header string table index */
+} Elf64_Ehdr;
+
+/* Fields in the e_ident array. The EI_* macros are indices into the
+ array. The macros under each EI_* macro are the values the byte
+ may have. */
+
+#define EI_MAG0 0 /* File identification byte 0 index */
+#define ELFMAG0 0x7f /* Magic number byte 0 */
+
+#define EI_MAG1 1 /* File identification byte 1 index */
+#define ELFMAG1 'E' /* Magic number byte 1 */
+
+#define EI_MAG2 2 /* File identification byte 2 index */
+#define ELFMAG2 'L' /* Magic number byte 2 */
+
+#define EI_MAG3 3 /* File identification byte 3 index */
+#define ELFMAG3 'F' /* Magic number byte 3 */
+
+/* Conglomeration of the identification bytes, for easy testing as a word. */
+#define ELFMAG "\177ELF"
+#define SELFMAG 4
+
+#define EI_CLASS 4 /* File class byte index */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+#define ELFCLASSNUM 3
+
+#define EI_DATA 5 /* Data encoding byte index */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* 2's complement, little endian */
+#define ELFDATA2MSB 2 /* 2's complement, big endian */
+#define ELFDATANUM 3
+
+#define EI_VERSION 6 /* File version byte index */
+ /* Value must be EV_CURRENT */
+
+#define EI_OSABI 7 /* OS ABI identification */
+#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
+#define ELFOSABI_HPUX 1 /* HP-UX */
+#define ELFOSABI_ARM 97 /* ARM */
+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
+
+#define EI_ABIVERSION 8 /* ABI version */
+
+#define EI_PAD 9 /* Byte index of padding bytes */
+
+/* Legal values for e_type (object file type). */
+
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* Relocatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_NUM 5 /* Number of defined types */
+#define ET_LOOS 0xfe00 /* OS-specific range start */
+#define ET_HIOS 0xfeff /* OS-specific range end */
+#define ET_LOPROC 0xff00 /* Processor-specific range start */
+#define ET_HIPROC 0xffff /* Processor-specific range end */
+
+/* Legal values for e_machine (architecture). */
+
+#define EM_NONE 0 /* No machine */
+#define EM_M32 1 /* AT&T WE 32100 */
+#define EM_SPARC 2 /* SUN SPARC */
+#define EM_386 3 /* Intel 80386 */
+#define EM_68K 4 /* Motorola m68k family */
+#define EM_88K 5 /* Motorola m88k family */
+#define EM_860 7 /* Intel 80860 */
+#define EM_MIPS 8 /* MIPS R3000 big-endian */
+#define EM_S370 9 /* IBM System/370 */
+#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
+
+#define EM_PARISC 15 /* HPPA */
+#define EM_VPP500 17 /* Fujitsu VPP500 */
+#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
+#define EM_960 19 /* Intel 80960 */
+#define EM_PPC 20 /* PowerPC */
+#define EM_PPC64 21 /* PowerPC 64-bit */
+#define EM_S390 22 /* IBM S390 */
+
+#define EM_V800 36 /* NEC V800 series */
+#define EM_FR20 37 /* Fujitsu FR20 */
+#define EM_RH32 38 /* TRW RH-32 */
+#define EM_RCE 39 /* Motorola RCE */
+#define EM_ARM 40 /* ARM */
+#define EM_FAKE_ALPHA 41 /* Digital Alpha */
+#define EM_SH 42 /* Hitachi SH */
+#define EM_SPARCV9 43 /* SPARC v9 64-bit */
+#define EM_TRICORE 44 /* Siemens Tricore */
+#define EM_ARC 45 /* Argonaut RISC Core */
+#define EM_H8_300 46 /* Hitachi H8/300 */
+#define EM_H8_300H 47 /* Hitachi H8/300H */
+#define EM_H8S 48 /* Hitachi H8S */
+#define EM_H8_500 49 /* Hitachi H8/500 */
+#define EM_IA_64 50 /* Intel Merced */
+#define EM_MIPS_X 51 /* Stanford MIPS-X */
+#define EM_COLDFIRE 52 /* Motorola Coldfire */
+#define EM_68HC12 53 /* Motorola M68HC12 */
+#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
+#define EM_PCP 55 /* Siemens PCP */
+#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
+#define EM_NDR1 57 /* Denso NDR1 microprocessor */
+#define EM_STARCORE 58 /* Motorola Start*Core processor */
+#define EM_ME16 59 /* Toyota ME16 processor */
+#define EM_ST100 60 /* STMicroelectronic ST100 processor */
+#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
+#define EM_X86_64 62 /* AMD x86-64 architecture */
+#define EM_PDSP 63 /* Sony DSP Processor */
+
+#define EM_FX66 66 /* Siemens FX66 microcontroller */
+#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
+#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
+#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
+#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
+#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
+#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
+#define EM_SVX 73 /* Silicon Graphics SVx */
+#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
+#define EM_VAX 75 /* Digital VAX */
+#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
+#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
+#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
+#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
+#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
+#define EM_HUANY 81 /* Harvard University machine-independent object files */
+#define EM_PRISM 82 /* SiTera Prism */
+#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
+#define EM_FR30 84 /* Fujitsu FR30 */
+#define EM_D10V 85 /* Mitsubishi D10V */
+#define EM_D30V 86 /* Mitsubishi D30V */
+#define EM_V850 87 /* NEC v850 */
+#define EM_M32R 88 /* Mitsubishi M32R */
+#define EM_MN10300 89 /* Matsushita MN10300 */
+#define EM_MN10200 90 /* Matsushita MN10200 */
+#define EM_PJ 91 /* picoJava */
+#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
+#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
+#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
+#define EM_NUM 95
+
+/* If it is necessary to assign new unofficial EM_* values, please
+ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
+ chances of collision with official or non-GNU unofficial values. */
+
+#define EM_ALPHA 0x9026
+
+/* Legal values for e_version (version). */
+
+#define EV_NONE 0 /* Invalid ELF version */
+#define EV_CURRENT 1 /* Current version */
+#define EV_NUM 2
+
+/* Section header. */
+
+typedef struct
+{
+ Elf32_Word sh_name; /* Section name (string tbl index) */
+ Elf32_Word sh_type; /* Section type */
+ Elf32_Word sh_flags; /* Section flags */
+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
+ Elf32_Off sh_offset; /* Section file offset */
+ Elf32_Word sh_size; /* Section size in bytes */
+ Elf32_Word sh_link; /* Link to another section */
+ Elf32_Word sh_info; /* Additional section information */
+ Elf32_Word sh_addralign; /* Section alignment */
+ Elf32_Word sh_entsize; /* Entry size if section holds table */
+} Elf32_Shdr;
+
+typedef struct
+{
+ Elf64_Word sh_name; /* Section name (string tbl index) */
+ Elf64_Word sh_type; /* Section type */
+ Elf64_Xword sh_flags; /* Section flags */
+ Elf64_Addr sh_addr; /* Section virtual addr at execution */
+ Elf64_Off sh_offset; /* Section file offset */
+ Elf64_Xword sh_size; /* Section size in bytes */
+ Elf64_Word sh_link; /* Link to another section */
+ Elf64_Word sh_info; /* Additional section information */
+ Elf64_Xword sh_addralign; /* Section alignment */
+ Elf64_Xword sh_entsize; /* Entry size if section holds table */
+} Elf64_Shdr;
+
+/* Special section indices. */
+
+#define SHN_UNDEF 0 /* Undefined section */
+#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
+#define SHN_LOPROC 0xff00 /* Start of processor-specific */
+#define SHN_HIPROC 0xff1f /* End of processor-specific */
+#define SHN_LOOS 0xff20 /* Start of OS-specific */
+#define SHN_HIOS 0xff3f /* End of OS-specific */
+#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
+#define SHN_COMMON 0xfff2 /* Associated symbol is common */
+#define SHN_XINDEX 0xffff /* Index is in extra table. */
+#define SHN_HIRESERVE 0xffff /* End of reserved indices */
+
+/* Legal values for sh_type (section type). */
+
+#define SHT_NULL 0 /* Section header table entry unused */
+#define SHT_PROGBITS 1 /* Program data */
+#define SHT_SYMTAB 2 /* Symbol table */
+#define SHT_STRTAB 3 /* String table */
+#define SHT_RELA 4 /* Relocation entries with addends */
+#define SHT_HASH 5 /* Symbol hash table */
+#define SHT_DYNAMIC 6 /* Dynamic linking information */
+#define SHT_NOTE 7 /* Notes */
+#define SHT_NOBITS 8 /* Program space with no data (bss) */
+#define SHT_REL 9 /* Relocation entries, no addends */
+#define SHT_SHLIB 10 /* Reserved */
+#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
+#define SHT_INIT_ARRAY 14 /* Array of constructors */
+#define SHT_FINI_ARRAY 15 /* Array of destructors */
+#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
+#define SHT_GROUP 17 /* Section group */
+#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
+#define SHT_NUM 19 /* Number of defined types. */
+#define SHT_LOOS 0x60000000 /* Start OS-specific */
+#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
+#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
+#define SHT_SUNW_move 0x6ffffffa
+#define SHT_SUNW_COMDAT 0x6ffffffb
+#define SHT_SUNW_syminfo 0x6ffffffc
+#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
+#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
+#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
+#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
+#define SHT_HIOS 0x6fffffff /* End OS-specific type */
+#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
+#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
+#define SHT_LOUSER 0x80000000 /* Start of application-specific */
+#define SHT_HIUSER 0x8fffffff /* End of application-specific */
+
+/* Legal values for sh_flags (section flags). */
+
+#define SHF_WRITE (1 << 0) /* Writable */
+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
+#define SHF_EXECINSTR (1 << 2) /* Executable */
+#define SHF_MERGE (1 << 4) /* Might be merged */
+#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
+#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
+#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
+#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
+ required */
+#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
+#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
+
+/* Section group handling. */
+#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
+
+/* Symbol table entry. */
+
+typedef struct
+{
+ Elf32_Word st_name; /* Symbol name (string tbl index) */
+ Elf32_Addr st_value; /* Symbol value */
+ Elf32_Word st_size; /* Symbol size */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* Symbol visibility */
+ Elf32_Section st_shndx; /* Section index */
+} Elf32_Sym;
+
+typedef struct
+{
+ Elf64_Word st_name; /* Symbol name (string tbl index) */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* Symbol visibility */
+ Elf64_Section st_shndx; /* Section index */
+ Elf64_Addr st_value; /* Symbol value */
+ Elf64_Xword st_size; /* Symbol size */
+} Elf64_Sym;
+
+/* The syminfo section if available contains additional information about
+ every dynamic symbol. */
+
+typedef struct
+{
+ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
+ Elf32_Half si_flags; /* Per symbol flags */
+} Elf32_Syminfo;
+
+typedef struct
+{
+ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
+ Elf64_Half si_flags; /* Per symbol flags */
+} Elf64_Syminfo;
+
+/* Possible values for si_boundto. */
+#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
+#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
+#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
+
+/* Possible bitmasks for si_flags. */
+#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
+#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
+#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
+ loaded */
+/* Syminfo version values. */
+#define SYMINFO_NONE 0
+#define SYMINFO_CURRENT 1
+#define SYMINFO_NUM 2
+
+
+/* Special section index. */
+
+#define SHN_UNDEF 0 /* No section, undefined symbol. */
+
+/* How to extract and insert information held in the st_info field. */
+
+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val) ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+
+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
+
+/* Legal values for ST_BIND subfield of st_info (symbol binding). */
+
+#define STB_LOCAL 0 /* Local symbol */
+#define STB_GLOBAL 1 /* Global symbol */
+#define STB_WEAK 2 /* Weak symbol */
+#define STB_NUM 3 /* Number of defined types. */
+#define STB_LOOS 10 /* Start of OS-specific */
+#define STB_HIOS 12 /* End of OS-specific */
+#define STB_LOPROC 13 /* Start of processor-specific */
+#define STB_HIPROC 15 /* End of processor-specific */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
+#define STT_SECTION 3 /* Symbol associated with a section */
+#define STT_FILE 4 /* Symbol's name is file name */
+#define STT_COMMON 5 /* Symbol is a common data object */
+#define STT_NUM 6 /* Number of defined types. */
+#define STT_LOOS 10 /* Start of OS-specific */
+#define STT_HIOS 12 /* End of OS-specific */
+#define STT_LOPROC 13 /* Start of processor-specific */
+#define STT_HIPROC 15 /* End of processor-specific */
+
+
+/* Symbol table indices are found in the hash buckets and chain table
+ of a symbol hash table section. This special index value indicates
+ the end of a chain, meaning no further symbols are found in that bucket. */
+
+#define STN_UNDEF 0 /* End of a chain. */
+
+
+/* How to extract and insert information held in the st_other field. */
+
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
+
+/* For ELF64 the definitions are the same. */
+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
+
+/* Symbol visibility specification encoded in the st_other field. */
+#define STV_DEFAULT 0 /* Default symbol visibility rules */
+#define STV_INTERNAL 1 /* Processor specific hidden class */
+#define STV_HIDDEN 2 /* Sym unavailable in other modules */
+#define STV_PROTECTED 3 /* Not preemptible, not exported */
+
+
+/* Relocation table entry without addend (in section of type SHT_REL). */
+
+typedef struct
+{
+ Elf32_Addr r_offset; /* Address */
+ Elf32_Word r_info; /* Relocation type and symbol index */
+} Elf32_Rel;
+
+/* I have seen two different definitions of the Elf64_Rel and
+ Elf64_Rela structures, so we'll leave them out until Novell (or
+ whoever) gets their act together. */
+/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ Elf64_Xword r_info; /* Relocation type and symbol index */
+} Elf64_Rel;
+
+/* Relocation table entry with addend (in section of type SHT_RELA). */
+
+typedef struct
+{
+ Elf32_Addr r_offset; /* Address */
+ Elf32_Word r_info; /* Relocation type and symbol index */
+ Elf32_Sword r_addend; /* Addend */
+} Elf32_Rela;
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ Elf64_Xword r_info; /* Relocation type and symbol index */
+ Elf64_Sxword r_addend; /* Addend */
+} Elf64_Rela;
+
+/* How to extract and insert information held in the r_info field. */
+
+#define ELF32_R_SYM(val) ((val) >> 8)
+#define ELF32_R_TYPE(val) ((val) & 0xff)
+#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
+
+#define ELF64_R_SYM(i) ((i) >> 32)
+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
+#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
+
+/* Program segment header. */
+
+typedef struct
+{
+ Elf32_Word p_type; /* Segment type */
+ Elf32_Off p_offset; /* Segment file offset */
+ Elf32_Addr p_vaddr; /* Segment virtual address */
+ Elf32_Addr p_paddr; /* Segment physical address */
+ Elf32_Word p_filesz; /* Segment size in file */
+ Elf32_Word p_memsz; /* Segment size in memory */
+ Elf32_Word p_flags; /* Segment flags */
+ Elf32_Word p_align; /* Segment alignment */
+} Elf32_Phdr;
+
+typedef struct
+{
+ Elf64_Word p_type; /* Segment type */
+ Elf64_Word p_flags; /* Segment flags */
+ Elf64_Off p_offset; /* Segment file offset */
+ Elf64_Addr p_vaddr; /* Segment virtual address */
+ Elf64_Addr p_paddr; /* Segment physical address */
+ Elf64_Xword p_filesz; /* Segment size in file */
+ Elf64_Xword p_memsz; /* Segment size in memory */
+ Elf64_Xword p_align; /* Segment alignment */
+} Elf64_Phdr;
+
+/* Legal values for p_type (segment type). */
+
+#define PT_NULL 0 /* Program header table entry unused */
+#define PT_LOAD 1 /* Loadable program segment */
+#define PT_DYNAMIC 2 /* Dynamic linking information */
+#define PT_INTERP 3 /* Program interpreter */
+#define PT_NOTE 4 /* Auxiliary information */
+#define PT_SHLIB 5 /* Reserved */
+#define PT_PHDR 6 /* Entry for header table itself */
+#define PT_NUM 7 /* Number of defined types */
+#define PT_LOOS 0x60000000 /* Start of OS-specific */
+#define PT_HIOS 0x6fffffff /* End of OS-specific */
+#define PT_LOPROC 0x70000000 /* Start of processor-specific */
+#define PT_HIPROC 0x7fffffff /* End of processor-specific */
+
+/* Legal values for p_flags (segment flags). */
+
+#define PF_X (1 << 0) /* Segment is executable */
+#define PF_W (1 << 1) /* Segment is writable */
+#define PF_R (1 << 2) /* Segment is readable */
+#define PF_MASKOS 0x0ff00000 /* OS-specific */
+#define PF_MASKPROC 0xf0000000 /* Processor-specific */
+
+/* Legal values for note segment descriptor types for core files. */
+
+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
+#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
+#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
+#define NT_PRXREG 4 /* Contains copy of prxregset struct */
+#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
+#define NT_AUXV 6 /* Contains copy of auxv array */
+#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
+#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
+#define NT_PSINFO 13 /* Contains copy of psinfo struct */
+#define NT_PRCRED 14 /* Contains copy of prcred struct */
+#define NT_UTSNAME 15 /* Contains copy of utsname struct */
+#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
+#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
+#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/
+
+/* Legal values for the note segment descriptor types for object files. */
+
+#define NT_VERSION 1 /* Contains a version string. */
+
+
+/* Dynamic section entry. */
+
+typedef struct
+{
+ Elf32_Sword d_tag; /* Dynamic entry type */
+ union
+ {
+ Elf32_Word d_val; /* Integer value */
+ Elf32_Addr d_ptr; /* Address value */
+ } d_un;
+} Elf32_Dyn;
+
+typedef struct
+{
+ Elf64_Sxword d_tag; /* Dynamic entry type */
+ union
+ {
+ Elf64_Xword d_val; /* Integer value */
+ Elf64_Addr d_ptr; /* Address value */
+ } d_un;
+} Elf64_Dyn;
+
+/* Legal values for d_tag (dynamic entry type). */
+
+#define DT_NULL 0 /* Marks end of dynamic section */
+#define DT_NEEDED 1 /* Name of needed library */
+#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
+#define DT_PLTGOT 3 /* Processor defined value */
+#define DT_HASH 4 /* Address of symbol hash table */
+#define DT_STRTAB 5 /* Address of string table */
+#define DT_SYMTAB 6 /* Address of symbol table */
+#define DT_RELA 7 /* Address of Rela relocs */
+#define DT_RELASZ 8 /* Total size of Rela relocs */
+#define DT_RELAENT 9 /* Size of one Rela reloc */
+#define DT_STRSZ 10 /* Size of string table */
+#define DT_SYMENT 11 /* Size of one symbol table entry */
+#define DT_INIT 12 /* Address of init function */
+#define DT_FINI 13 /* Address of termination function */
+#define DT_SONAME 14 /* Name of shared object */
+#define DT_RPATH 15 /* Library search path (deprecated) */
+#define DT_SYMBOLIC 16 /* Start symbol search here */
+#define DT_REL 17 /* Address of Rel relocs */
+#define DT_RELSZ 18 /* Total size of Rel relocs */
+#define DT_RELENT 19 /* Size of one Rel reloc */
+#define DT_PLTREL 20 /* Type of reloc in PLT */
+#define DT_DEBUG 21 /* For debugging; unspecified */
+#define DT_TEXTREL 22 /* Reloc might modify .text */
+#define DT_JMPREL 23 /* Address of PLT relocs */
+#define DT_BIND_NOW 24 /* Process relocations of object */
+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
+#define DT_RUNPATH 29 /* Library search path */
+#define DT_FLAGS 30 /* Flags for the object being loaded */
+#define DT_ENCODING 32 /* Start of encoded range */
+#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
+#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
+#define DT_NUM 34 /* Number used */
+#define DT_LOOS 0x60000000 /* Start of OS-specific */
+#define DT_HIOS 0x6fffffff /* End of OS-specific */
+#define DT_LOPROC 0x70000000 /* Start of processor-specific */
+#define DT_HIPROC 0x7fffffff /* End of processor-specific */
+#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
+
+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
+ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
+ approach. */
+#define DT_VALRNGLO 0x6ffffd00
+#define DT_CHECKSUM 0x6ffffdf8
+#define DT_PLTPADSZ 0x6ffffdf9
+#define DT_MOVEENT 0x6ffffdfa
+#define DT_MOVESZ 0x6ffffdfb
+#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
+#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
+ the following DT_* entry. */
+#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
+#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
+#define DT_VALRNGHI 0x6ffffdff
+
+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
+ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
+
+ If any adjustment is made to the ELF object after it has been
+ built these entries will need to be adjusted. */
+#define DT_ADDRRNGLO 0x6ffffe00
+#define DT_CONFIG 0x6ffffefa /* Configuration information. */
+#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
+#define DT_AUDIT 0x6ffffefc /* Object auditing. */
+#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
+#define DT_MOVETAB 0x6ffffefe /* Move table. */
+#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
+#define DT_ADDRRNGHI 0x6ffffeff
+
+/* The versioning entry types. The next are defined as part of the
+ GNU extension. */
+#define DT_VERSYM 0x6ffffff0
+
+#define DT_RELACOUNT 0x6ffffff9
+#define DT_RELCOUNT 0x6ffffffa
+
+/* These were chosen by Sun. */
+#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
+#define DT_VERDEF 0x6ffffffc /* Address of version definition
+ table */
+#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
+#define DT_VERNEED 0x6ffffffe /* Address of table with needed
+ versions */
+#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
+#define DT_VERSIONTAGNUM 16
+
+/* Sun added these machine-independent extensions in the "processor-specific"
+ range. Be compatible. */
+#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
+#define DT_FILTER 0x7fffffff /* Shared object to get values from */
+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM 3
+
+/* Values of `d_un.d_val' in the DT_FLAGS entry. */
+#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
+#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
+#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
+#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
+
+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
+ entry in the dynamic section. */
+#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
+#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
+#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
+#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
+#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
+#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
+#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
+#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
+#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
+#define DF_1_TRANS 0x00000200
+#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
+#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
+#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
+#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
+#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
+#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
+#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
+
+/* Flags for the feature selection in DT_FEATURE_1. */
+#define DTF_1_PARINIT 0x00000001
+#define DTF_1_CONFEXP 0x00000002
+
+/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
+#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
+#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
+ generally available. */
+
+/* Version definition sections. */
+
+typedef struct
+{
+ Elf32_Half vd_version; /* Version revision */
+ Elf32_Half vd_flags; /* Version information */
+ Elf32_Half vd_ndx; /* Version Index */
+ Elf32_Half vd_cnt; /* Number of associated aux entries */
+ Elf32_Word vd_hash; /* Version name hash value */
+ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
+ Elf32_Word vd_next; /* Offset in bytes to next verdef
+ entry */
+} Elf32_Verdef;
+
+typedef struct
+{
+ Elf64_Half vd_version; /* Version revision */
+ Elf64_Half vd_flags; /* Version information */
+ Elf64_Half vd_ndx; /* Version Index */
+ Elf64_Half vd_cnt; /* Number of associated aux entries */
+ Elf64_Word vd_hash; /* Version name hash value */
+ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
+ Elf64_Word vd_next; /* Offset in bytes to next verdef
+ entry */
+} Elf64_Verdef;
+
+
+/* Legal values for vd_version (version revision). */
+#define VER_DEF_NONE 0 /* No version */
+#define VER_DEF_CURRENT 1 /* Current version */
+#define VER_DEF_NUM 2 /* Given version number */
+
+/* Legal values for vd_flags (version information flags). */
+#define VER_FLG_BASE 0x1 /* Version definition of file itself */
+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
+
+/* Versym symbol index values. */
+#define VER_NDX_LOCAL 0 /* Symbol is local. */
+#define VER_NDX_GLOBAL 1 /* Symbol is global. */
+#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
+#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
+
+/* Auxialiary version information. */
+
+typedef struct
+{
+ Elf32_Word vda_name; /* Version or dependency names */
+ Elf32_Word vda_next; /* Offset in bytes to next verdaux
+ entry */
+} Elf32_Verdaux;
+
+typedef struct
+{
+ Elf64_Word vda_name; /* Version or dependency names */
+ Elf64_Word vda_next; /* Offset in bytes to next verdaux
+ entry */
+} Elf64_Verdaux;
+
+
+/* Version dependency section. */
+
+typedef struct
+{
+ Elf32_Half vn_version; /* Version of structure */
+ Elf32_Half vn_cnt; /* Number of associated aux entries */
+ Elf32_Word vn_file; /* Offset of filename for this
+ dependency */
+ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
+ Elf32_Word vn_next; /* Offset in bytes to next verneed
+ entry */
+} Elf32_Verneed;
+
+typedef struct
+{
+ Elf64_Half vn_version; /* Version of structure */
+ Elf64_Half vn_cnt; /* Number of associated aux entries */
+ Elf64_Word vn_file; /* Offset of filename for this
+ dependency */
+ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
+ Elf64_Word vn_next; /* Offset in bytes to next verneed
+ entry */
+} Elf64_Verneed;
+
+
+/* Legal values for vn_version (version revision). */
+#define VER_NEED_NONE 0 /* No version */
+#define VER_NEED_CURRENT 1 /* Current version */
+#define VER_NEED_NUM 2 /* Given version number */
+
+/* Auxiliary needed version information. */
+
+typedef struct
+{
+ Elf32_Word vna_hash; /* Hash value of dependency name */
+ Elf32_Half vna_flags; /* Dependency specific information */
+ Elf32_Half vna_other; /* Unused */
+ Elf32_Word vna_name; /* Dependency name string offset */
+ Elf32_Word vna_next; /* Offset in bytes to next vernaux
+ entry */
+} Elf32_Vernaux;
+
+typedef struct
+{
+ Elf64_Word vna_hash; /* Hash value of dependency name */
+ Elf64_Half vna_flags; /* Dependency specific information */
+ Elf64_Half vna_other; /* Unused */
+ Elf64_Word vna_name; /* Dependency name string offset */
+ Elf64_Word vna_next; /* Offset in bytes to next vernaux
+ entry */
+} Elf64_Vernaux;
+
+
+/* Legal values for vna_flags. */
+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
+
+
+/* Auxiliary vector. */
+
+/* This vector is normally only used by the program interpreter. The
+ usual definition in an ABI supplement uses the name auxv_t. The
+ vector is not usually defined in a standard <elf.h> file, but it
+ can't hurt. We rename it to avoid conflicts. The sizes of these
+ types are an arrangement between the exec server and the program
+ interpreter, so we don't fully specify them here. */
+
+typedef struct
+{
+ int a_type; /* Entry type */
+ union
+ {
+ long int a_val; /* Integer value */
+ void *a_ptr; /* Pointer value */
+ void (*a_fcn) (void); /* Function pointer value */
+ } a_un;
+} Elf32_auxv_t;
+
+typedef struct
+{
+ long int a_type; /* Entry type */
+ union
+ {
+ long int a_val; /* Integer value */
+ void *a_ptr; /* Pointer value */
+ void (*a_fcn) (void); /* Function pointer value */
+ } a_un;
+} Elf64_auxv_t;
+
+/* Legal values for a_type (entry type). */
+
+#define AT_NULL 0 /* End of vector */
+#define AT_IGNORE 1 /* Entry should be ignored */
+#define AT_EXECFD 2 /* File descriptor of program */
+#define AT_PHDR 3 /* Program headers for program */
+#define AT_PHENT 4 /* Size of program header entry */
+#define AT_PHNUM 5 /* Number of program headers */
+#define AT_PAGESZ 6 /* System page size */
+#define AT_BASE 7 /* Base address of interpreter */
+#define AT_FLAGS 8 /* Flags */
+#define AT_ENTRY 9 /* Entry point of program */
+#define AT_NOTELF 10 /* Program is not ELF */
+#define AT_UID 11 /* Real uid */
+#define AT_EUID 12 /* Effective uid */
+#define AT_GID 13 /* Real gid */
+#define AT_EGID 14 /* Effective gid */
+#define AT_CLKTCK 17 /* Frequency of times() */
+
+/* Some more special a_type values describing the hardware. */
+#define AT_PLATFORM 15 /* String identifying platform. */
+#define AT_HWCAP 16 /* Machine dependent hints about
+ processor capabilities. */
+
+/* This entry gives some information about the FPU initialization
+ performed by the kernel. */
+#define AT_FPUCW 18 /* Used FPU control word. */
+
+/* Cache block sizes. */
+#define AT_DCACHEBSIZE 19 /* Data cache block size. */
+#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
+#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
+
+/* A special ignored value for PPC, used by the kernel to control the
+ interpretation of the AUXV. Must be > 16. */
+#define AT_IGNOREPPC 22 /* Entry should be ignored */
+
+
+/* Note section contents. Each entry in the note section begins with
+ a header of a fixed form. */
+
+typedef struct
+{
+ Elf32_Word n_namesz; /* Length of the note's name. */
+ Elf32_Word n_descsz; /* Length of the note's descriptor. */
+ Elf32_Word n_type; /* Type of the note. */
+} Elf32_Nhdr;
+
+typedef struct
+{
+ Elf64_Word n_namesz; /* Length of the note's name. */
+ Elf64_Word n_descsz; /* Length of the note's descriptor. */
+ Elf64_Word n_type; /* Type of the note. */
+} Elf64_Nhdr;
+
+/* Known names of notes. */
+
+/* Solaris entries in the note section have this name. */
+#define ELF_NOTE_SOLARIS "SUNW Solaris"
+
+/* Note entries for GNU systems have this name. */
+#define ELF_NOTE_GNU "GNU"
+
+
+/* Defined types of notes for Solaris. */
+
+/* Value of descriptor (one word) is desired pagesize for the binary. */
+#define ELF_NOTE_PAGESIZE_HINT 1
+
+
+/* Defined note types for GNU systems. */
+
+/* ABI information. The descriptor consists of words:
+ word 0: OS descriptor
+ word 1: major version of the ABI
+ word 2: minor version of the ABI
+ word 3: subminor version of the ABI
+*/
+#define ELF_NOTE_ABI 1
+
+/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI
+ note section entry. */
+#define ELF_NOTE_OS_LINUX 0
+#define ELF_NOTE_OS_GNU 1
+#define ELF_NOTE_OS_SOLARIS2 2
+
+
+/* Move records. */
+typedef struct
+{
+ Elf32_Xword m_value; /* Symbol value. */
+ Elf32_Word m_info; /* Size and index. */
+ Elf32_Word m_poffset; /* Symbol offset. */
+ Elf32_Half m_repeat; /* Repeat count. */
+ Elf32_Half m_stride; /* Stride info. */
+} Elf32_Move;
+
+typedef struct
+{
+ Elf64_Xword m_value; /* Symbol value. */
+ Elf64_Xword m_info; /* Size and index. */
+ Elf64_Xword m_poffset; /* Symbol offset. */
+ Elf64_Half m_repeat; /* Repeat count. */
+ Elf64_Half m_stride; /* Stride info. */
+} Elf64_Move;
+
+/* Macro to construct move records. */
+#define ELF32_M_SYM(info) ((info) >> 8)
+#define ELF32_M_SIZE(info) ((unsigned char) (info))
+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
+
+#define ELF64_M_SYM(info) ELF32_M_SYM (info)
+#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
+#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
+
+
+/* Motorola 68k specific definitions. */
+
+/* Values for Elf32_Ehdr.e_flags. */
+#define EF_CPU32 0x00810000
+
+/* m68k relocs. */
+
+#define R_68K_NONE 0 /* No reloc */
+#define R_68K_32 1 /* Direct 32 bit */
+#define R_68K_16 2 /* Direct 16 bit */
+#define R_68K_8 3 /* Direct 8 bit */
+#define R_68K_PC32 4 /* PC relative 32 bit */
+#define R_68K_PC16 5 /* PC relative 16 bit */
+#define R_68K_PC8 6 /* PC relative 8 bit */
+#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
+#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
+#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
+#define R_68K_GOT32O 10 /* 32 bit GOT offset */
+#define R_68K_GOT16O 11 /* 16 bit GOT offset */
+#define R_68K_GOT8O 12 /* 8 bit GOT offset */
+#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
+#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
+#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
+#define R_68K_PLT32O 16 /* 32 bit PLT offset */
+#define R_68K_PLT16O 17 /* 16 bit PLT offset */
+#define R_68K_PLT8O 18 /* 8 bit PLT offset */
+#define R_68K_COPY 19 /* Copy symbol at runtime */
+#define R_68K_GLOB_DAT 20 /* Create GOT entry */
+#define R_68K_JMP_SLOT 21 /* Create PLT entry */
+#define R_68K_RELATIVE 22 /* Adjust by program base */
+/* Keep this the last entry. */
+#define R_68K_NUM 23
+
+/* Intel 80386 specific definitions. */
+
+/* i386 relocs. */
+
+#define R_386_NONE 0 /* No reloc */
+#define R_386_32 1 /* Direct 32 bit */
+#define R_386_PC32 2 /* PC relative 32 bit */
+#define R_386_GOT32 3 /* 32 bit GOT entry */
+#define R_386_PLT32 4 /* 32 bit PLT address */
+#define R_386_COPY 5 /* Copy symbol at runtime */
+#define R_386_GLOB_DAT 6 /* Create GOT entry */
+#define R_386_JMP_SLOT 7 /* Create PLT entry */
+#define R_386_RELATIVE 8 /* Adjust by program base */
+#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
+#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
+/* Keep this the last entry. */
+#define R_386_NUM 11
+
+/* SUN SPARC specific definitions. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_REGISTER 13 /* Global register reserved to app. */
+
+/* Values for Elf64_Ehdr.e_flags. */
+
+#define EF_SPARCV9_MM 3
+#define EF_SPARCV9_TSO 0
+#define EF_SPARCV9_PSO 1
+#define EF_SPARCV9_RMO 2
+#define EF_SPARC_LEDATA 0x800000 /* little endian data */
+#define EF_SPARC_EXT_MASK 0xFFFF00
+#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
+#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
+#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
+#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
+
+/* SPARC relocs. */
+
+#define R_SPARC_NONE 0 /* No reloc */
+#define R_SPARC_8 1 /* Direct 8 bit */
+#define R_SPARC_16 2 /* Direct 16 bit */
+#define R_SPARC_32 3 /* Direct 32 bit */
+#define R_SPARC_DISP8 4 /* PC relative 8 bit */
+#define R_SPARC_DISP16 5 /* PC relative 16 bit */
+#define R_SPARC_DISP32 6 /* PC relative 32 bit */
+#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
+#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
+#define R_SPARC_HI22 9 /* High 22 bit */
+#define R_SPARC_22 10 /* Direct 22 bit */
+#define R_SPARC_13 11 /* Direct 13 bit */
+#define R_SPARC_LO10 12 /* Truncated 10 bit */
+#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
+#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
+#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
+#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
+#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
+#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
+#define R_SPARC_COPY 19 /* Copy symbol at runtime */
+#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
+#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
+#define R_SPARC_RELATIVE 22 /* Adjust by program base */
+#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
+
+/* Additional Sparc64 relocs. */
+
+#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
+#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
+#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
+#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
+#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
+#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
+#define R_SPARC_10 30 /* Direct 10 bit */
+#define R_SPARC_11 31 /* Direct 11 bit */
+#define R_SPARC_64 32 /* Direct 64 bit */
+#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
+#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
+#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
+#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
+#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
+#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
+#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
+#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
+#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
+#define R_SPARC_7 43 /* Direct 7 bit */
+#define R_SPARC_5 44 /* Direct 5 bit */
+#define R_SPARC_6 45 /* Direct 6 bit */
+#define R_SPARC_DISP64 46 /* PC relative 64 bit */
+#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
+#define R_SPARC_HIX22 48 /* High 22 bit complemented */
+#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
+#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
+#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
+#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
+#define R_SPARC_REGISTER 53 /* Global register usage */
+#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
+#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
+/* Keep this the last entry. */
+#define R_SPARC_NUM 56
+
+/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
+
+#define DT_SPARC_REGISTER 0x70000001
+#define DT_SPARC_NUM 2
+
+/* Bits present in AT_HWCAP, primarily for Sparc32. */
+
+#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */
+#define HWCAP_SPARC_STBAR 2
+#define HWCAP_SPARC_SWAP 4
+#define HWCAP_SPARC_MULDIV 8
+#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */
+#define HWCAP_SPARC_ULTRA3 32
+
+/* MIPS R3000 specific definitions. */
+
+/* Legal values for e_flags field of Elf32_Ehdr. */
+
+#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
+#define EF_MIPS_PIC 2 /* Contains PIC code */
+#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
+#define EF_MIPS_XGOT 8
+#define EF_MIPS_64BIT_WHIRL 16
+#define EF_MIPS_ABI2 32
+#define EF_MIPS_ABI_ON32 64
+#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
+
+/* Legal values for MIPS architecture level. */
+
+#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
+#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
+#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
+#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
+#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
+#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
+#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
+
+/* The following are non-official names and should not be used. */
+
+#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
+#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
+#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
+#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
+#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
+#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
+#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
+
+/* Special section indices. */
+
+#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
+#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
+#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
+#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
+#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
+
+/* Legal values for sh_type field of Elf32_Shdr. */
+
+#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
+#define SHT_MIPS_MSYM 0x70000001
+#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
+#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
+#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
+#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
+#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
+#define SHT_MIPS_PACKAGE 0x70000007
+#define SHT_MIPS_PACKSYM 0x70000008
+#define SHT_MIPS_RELD 0x70000009
+#define SHT_MIPS_IFACE 0x7000000b
+#define SHT_MIPS_CONTENT 0x7000000c
+#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
+#define SHT_MIPS_SHDR 0x70000010
+#define SHT_MIPS_FDESC 0x70000011
+#define SHT_MIPS_EXTSYM 0x70000012
+#define SHT_MIPS_DENSE 0x70000013
+#define SHT_MIPS_PDESC 0x70000014
+#define SHT_MIPS_LOCSYM 0x70000015
+#define SHT_MIPS_AUXSYM 0x70000016
+#define SHT_MIPS_OPTSYM 0x70000017
+#define SHT_MIPS_LOCSTR 0x70000018
+#define SHT_MIPS_LINE 0x70000019
+#define SHT_MIPS_RFDESC 0x7000001a
+#define SHT_MIPS_DELTASYM 0x7000001b
+#define SHT_MIPS_DELTAINST 0x7000001c
+#define SHT_MIPS_DELTACLASS 0x7000001d
+#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
+#define SHT_MIPS_DELTADECL 0x7000001f
+#define SHT_MIPS_SYMBOL_LIB 0x70000020
+#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
+#define SHT_MIPS_TRANSLATE 0x70000022
+#define SHT_MIPS_PIXIE 0x70000023
+#define SHT_MIPS_XLATE 0x70000024
+#define SHT_MIPS_XLATE_DEBUG 0x70000025
+#define SHT_MIPS_WHIRL 0x70000026
+#define SHT_MIPS_EH_REGION 0x70000027
+#define SHT_MIPS_XLATE_OLD 0x70000028
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+/* Legal values for sh_flags field of Elf32_Shdr. */
+
+#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
+#define SHF_MIPS_MERGE 0x20000000
+#define SHF_MIPS_ADDR 0x40000000
+#define SHF_MIPS_STRINGS 0x80000000
+#define SHF_MIPS_NOSTRIP 0x08000000
+#define SHF_MIPS_LOCAL 0x04000000
+#define SHF_MIPS_NAMES 0x02000000
+#define SHF_MIPS_NODUPE 0x01000000
+
+
+/* Symbol tables. */
+
+/* MIPS specific values for `st_other'. */
+#define STO_MIPS_DEFAULT 0x0
+#define STO_MIPS_INTERNAL 0x1
+#define STO_MIPS_HIDDEN 0x2
+#define STO_MIPS_PROTECTED 0x3
+#define STO_MIPS_SC_ALIGN_UNUSED 0xff
+
+/* MIPS specific values for `st_info'. */
+#define STB_MIPS_SPLIT_COMMON 13
+
+/* Entries found in sections of type SHT_MIPS_GPTAB. */
+
+typedef union
+{
+ struct
+ {
+ Elf32_Word gt_current_g_value; /* -G value used for compilation */
+ Elf32_Word gt_unused; /* Not used */
+ } gt_header; /* First entry in section */
+ struct
+ {
+ Elf32_Word gt_g_value; /* If this value were used for -G */
+ Elf32_Word gt_bytes; /* This many bytes would be used */
+ } gt_entry; /* Subsequent entries in section */
+} Elf32_gptab;
+
+/* Entry found in sections of type SHT_MIPS_REGINFO. */
+
+typedef struct
+{
+ Elf32_Word ri_gprmask; /* General registers used */
+ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
+ Elf32_Sword ri_gp_value; /* $gp register value */
+} Elf32_RegInfo;
+
+/* Entries found in sections of type SHT_MIPS_OPTIONS. */
+
+typedef struct
+{
+ unsigned char kind; /* Determines interpretation of the
+ variable part of descriptor. */
+ unsigned char size; /* Size of descriptor, including header. */
+ Elf32_Section section; /* Section header index of section affected,
+ 0 for global options. */
+ Elf32_Word info; /* Kind-specific information. */
+} Elf_Options;
+
+/* Values for `kind' field in Elf_Options. */
+
+#define ODK_NULL 0 /* Undefined. */
+#define ODK_REGINFO 1 /* Register usage information. */
+#define ODK_EXCEPTIONS 2 /* Exception processing options. */
+#define ODK_PAD 3 /* Section padding options. */
+#define ODK_HWPATCH 4 /* Hardware workarounds performed */
+#define ODK_FILL 5 /* record the fill value used by the linker. */
+#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
+#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
+#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
+
+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
+
+#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
+#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
+#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
+#define OEX_SMM 0x20000 /* Force sequential memory mode? */
+#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
+#define OEX_PRECISEFP OEX_FPDBUG
+#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
+
+#define OEX_FPU_INVAL 0x10
+#define OEX_FPU_DIV0 0x08
+#define OEX_FPU_OFLO 0x04
+#define OEX_FPU_UFLO 0x02
+#define OEX_FPU_INEX 0x01
+
+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
+
+#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
+#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
+#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
+#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
+
+#define OPAD_PREFIX 0x1
+#define OPAD_POSTFIX 0x2
+#define OPAD_SYMBOL 0x4
+
+/* Entry found in `.options' section. */
+
+typedef struct
+{
+ Elf32_Word hwp_flags1; /* Extra flags. */
+ Elf32_Word hwp_flags2; /* Extra flags. */
+} Elf_Options_Hw;
+
+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
+
+#define OHWA0_R4KEOP_CHECKED 0x00000001
+#define OHWA1_R4KEOP_CLEAN 0x00000002
+
+/* MIPS relocs. */
+
+#define R_MIPS_NONE 0 /* No reloc */
+#define R_MIPS_16 1 /* Direct 16 bit */
+#define R_MIPS_32 2 /* Direct 32 bit */
+#define R_MIPS_REL32 3 /* PC relative 32 bit */
+#define R_MIPS_26 4 /* Direct 26 bit shifted */
+#define R_MIPS_HI16 5 /* High 16 bit */
+#define R_MIPS_LO16 6 /* Low 16 bit */
+#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
+#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
+#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
+#define R_MIPS_PC16 10 /* PC relative 16 bit */
+#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
+#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
+
+#define R_MIPS_SHIFT5 16
+#define R_MIPS_SHIFT6 17
+#define R_MIPS_64 18
+#define R_MIPS_GOT_DISP 19
+#define R_MIPS_GOT_PAGE 20
+#define R_MIPS_GOT_OFST 21
+#define R_MIPS_GOT_HI16 22
+#define R_MIPS_GOT_LO16 23
+#define R_MIPS_SUB 24
+#define R_MIPS_INSERT_A 25
+#define R_MIPS_INSERT_B 26
+#define R_MIPS_DELETE 27
+#define R_MIPS_HIGHER 28
+#define R_MIPS_HIGHEST 29
+#define R_MIPS_CALL_HI16 30
+#define R_MIPS_CALL_LO16 31
+#define R_MIPS_SCN_DISP 32
+#define R_MIPS_REL16 33
+#define R_MIPS_ADD_IMMEDIATE 34
+#define R_MIPS_PJUMP 35
+#define R_MIPS_RELGOT 36
+#define R_MIPS_JALR 37
+/* Keep this the last entry. */
+#define R_MIPS_NUM 38
+
+/* Legal values for p_type field of Elf32_Phdr. */
+
+#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
+#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
+#define PT_MIPS_OPTIONS 0x70000002
+
+/* Special program header types. */
+
+#define PF_MIPS_LOCAL 0x10000000
+
+/* Legal values for d_tag field of Elf32_Dyn. */
+
+#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
+#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
+#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
+#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
+#define DT_MIPS_FLAGS 0x70000005 /* Flags */
+#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
+#define DT_MIPS_MSYM 0x70000007
+#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
+#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
+#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
+#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
+#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
+#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
+#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
+#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
+#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
+#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
+#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
+#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
+ DT_MIPS_DELTA_CLASS. */
+#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
+ DT_MIPS_DELTA_INSTANCE. */
+#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
+ DT_MIPS_DELTA_RELOC. */
+#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
+ relocations refer to. */
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
+ DT_MIPS_DELTA_SYM. */
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
+ class declaration. */
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
+ DT_MIPS_DELTA_CLASSSYM. */
+#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
+#define DT_MIPS_PIXIE_INIT 0x70000023
+#define DT_MIPS_SYMBOL_LIB 0x70000024
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
+#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
+ function stored in GOT. */
+#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
+ by rld on dlopen() calls. */
+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
+#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
+#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
+#define DT_MIPS_NUM 0x32
+
+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
+
+#define RHF_NONE 0 /* No flags */
+#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
+#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
+#define RHF_NO_MOVE (1 << 3)
+#define RHF_SGI_ONLY (1 << 4)
+#define RHF_GUARANTEE_INIT (1 << 5)
+#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
+#define RHF_GUARANTEE_START_INIT (1 << 7)
+#define RHF_PIXIE (1 << 8)
+#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
+#define RHF_REQUICKSTART (1 << 10)
+#define RHF_REQUICKSTARTED (1 << 11)
+#define RHF_CORD (1 << 12)
+#define RHF_NO_UNRES_UNDEF (1 << 13)
+#define RHF_RLD_ORDER_SAFE (1 << 14)
+
+/* Entries found in sections of type SHT_MIPS_LIBLIST. */
+
+typedef struct
+{
+ Elf32_Word l_name; /* Name (string table index) */
+ Elf32_Word l_time_stamp; /* Timestamp */
+ Elf32_Word l_checksum; /* Checksum */
+ Elf32_Word l_version; /* Interface version */
+ Elf32_Word l_flags; /* Flags */
+} Elf32_Lib;
+
+typedef struct
+{
+ Elf64_Word l_name; /* Name (string table index) */
+ Elf64_Word l_time_stamp; /* Timestamp */
+ Elf64_Word l_checksum; /* Checksum */
+ Elf64_Word l_version; /* Interface version */
+ Elf64_Word l_flags; /* Flags */
+} Elf64_Lib;
+
+
+/* Legal values for l_flags. */
+
+#define LL_NONE 0
+#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
+#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
+#define LL_REQUIRE_MINOR (1 << 2)
+#define LL_EXPORTS (1 << 3)
+#define LL_DELAY_LOAD (1 << 4)
+#define LL_DELTA (1 << 5)
+
+/* Entries found in sections of type SHT_MIPS_CONFLICT. */
+
+typedef Elf32_Addr Elf32_Conflict;
+
+
+/* HPPA specific definitions. */
+
+/* Legal values for e_flags field of Elf32_Ehdr. */
+
+#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
+#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
+#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
+#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
+#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
+ prediction. */
+#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
+#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
+
+/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
+
+#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
+#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
+#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
+
+/* Additional section indeces. */
+
+#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
+ symbols in ANSI C. */
+#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
+
+/* Legal values for sh_type field of Elf32_Shdr. */
+
+#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
+#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
+#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
+
+/* Legal values for sh_flags field of Elf32_Shdr. */
+
+#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
+#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
+#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
+
+#define STT_HP_OPAQUE (STT_LOOS + 0x1)
+#define STT_HP_STUB (STT_LOOS + 0x2)
+
+/* HPPA relocs. */
+
+#define R_PARISC_NONE 0 /* No reloc. */
+#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
+#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
+#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
+#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
+#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
+#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
+#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
+#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
+#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
+#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
+#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
+#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
+#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
+#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
+#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
+#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
+#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
+#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
+#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
+#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
+#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
+#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
+#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
+#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
+#define R_PARISC_FPTR64 64 /* 64 bits function address. */
+#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
+#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
+#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
+#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
+#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
+#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
+#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
+#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
+#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
+#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
+#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
+#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
+#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
+#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
+#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
+#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
+#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
+#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
+#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
+#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
+#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
+#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
+#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
+#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
+#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
+#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
+#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
+#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
+#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
+#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
+#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
+#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LORESERVE 128
+#define R_PARISC_COPY 128 /* Copy relocation. */
+#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
+#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
+#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
+#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
+#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
+#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
+#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
+#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
+#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
+#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
+#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_HIRESERVE 255
+
+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
+
+#define PT_HP_TLS (PT_LOOS + 0x0)
+#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
+#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
+#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
+#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
+#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
+#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
+#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
+#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
+#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
+#define PT_HP_PARALLEL (PT_LOOS + 0x10)
+#define PT_HP_FASTBIND (PT_LOOS + 0x11)
+#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
+#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
+#define PT_HP_STACK (PT_LOOS + 0x14)
+
+#define PT_PARISC_ARCHEXT 0x70000000
+#define PT_PARISC_UNWIND 0x70000001
+
+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
+
+#define PF_PARISC_SBP 0x08000000
+
+#define PF_HP_PAGE_SIZE 0x00100000
+#define PF_HP_FAR_SHARED 0x00200000
+#define PF_HP_NEAR_SHARED 0x00400000
+#define PF_HP_CODE 0x01000000
+#define PF_HP_MODIFY 0x02000000
+#define PF_HP_LAZYSWAP 0x04000000
+#define PF_HP_SBP 0x08000000
+
+
+/* Alpha specific definitions. */
+
+/* Legal values for e_flags field of Elf64_Ehdr. */
+
+#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
+#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
+
+/* Legal values for sh_type field of Elf64_Shdr. */
+
+/* These two are primerily concerned with ECOFF debugging info. */
+#define SHT_ALPHA_DEBUG 0x70000001
+#define SHT_ALPHA_REGINFO 0x70000002
+
+/* Legal values for sh_flags field of Elf64_Shdr. */
+
+#define SHF_ALPHA_GPREL 0x10000000
+
+/* Legal values for st_other field of Elf64_Sym. */
+#define STO_ALPHA_NOPV 0x80 /* No PV required. */
+#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
+
+/* Alpha relocs. */
+
+#define R_ALPHA_NONE 0 /* No reloc */
+#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
+#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
+#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
+#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
+#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
+#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
+#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
+#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
+#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
+#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
+#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
+#define R_ALPHA_OP_PUSH 12 /* OP stack push */
+#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */
+#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */
+#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */
+#define R_ALPHA_GPVALUE 16
+#define R_ALPHA_GPRELHIGH 17
+#define R_ALPHA_GPRELLOW 18
+#define R_ALPHA_IMMED_GP_16 19
+#define R_ALPHA_IMMED_GP_HI32 20
+#define R_ALPHA_IMMED_SCN_HI32 21
+#define R_ALPHA_IMMED_BR_HI32 22
+#define R_ALPHA_IMMED_LO32 23
+#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
+#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
+#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
+#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
+/* Keep this the last entry. */
+#define R_ALPHA_NUM 28
+
+
+/* PowerPC specific declarations */
+
+/* Values for Elf32/64_Ehdr.e_flags. */
+#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
+
+/* Cygnus local bits below */
+#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
+#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
+ flag */
+
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE 0
+#define R_PPC_ADDR32 1 /* 32bit absolute address */
+#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
+#define R_PPC_ADDR16 3 /* 16bit absolute address */
+#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
+#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN 8
+#define R_PPC_ADDR14_BRNTAKEN 9
+#define R_PPC_REL24 10 /* PC relative 26 bit */
+#define R_PPC_REL14 11 /* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN 12
+#define R_PPC_REL14_BRNTAKEN 13
+#define R_PPC_GOT16 14
+#define R_PPC_GOT16_LO 15
+#define R_PPC_GOT16_HI 16
+#define R_PPC_GOT16_HA 17
+#define R_PPC_PLTREL24 18
+#define R_PPC_COPY 19
+#define R_PPC_GLOB_DAT 20
+#define R_PPC_JMP_SLOT 21
+#define R_PPC_RELATIVE 22
+#define R_PPC_LOCAL24PC 23
+#define R_PPC_UADDR32 24
+#define R_PPC_UADDR16 25
+#define R_PPC_REL32 26
+#define R_PPC_PLT32 27
+#define R_PPC_PLTREL32 28
+#define R_PPC_PLT16_LO 29
+#define R_PPC_PLT16_HI 30
+#define R_PPC_PLT16_HA 31
+#define R_PPC_SDAREL16 32
+#define R_PPC_SECTOFF 33
+#define R_PPC_SECTOFF_LO 34
+#define R_PPC_SECTOFF_HI 35
+#define R_PPC_SECTOFF_HA 36
+/* Keep this the last entry. */
+#define R_PPC_NUM 37
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+ in the SVR4 ELF ABI. */
+#define R_PPC_EMB_NADDR32 101
+#define R_PPC_EMB_NADDR16 102
+#define R_PPC_EMB_NADDR16_LO 103
+#define R_PPC_EMB_NADDR16_HI 104
+#define R_PPC_EMB_NADDR16_HA 105
+#define R_PPC_EMB_SDAI16 106
+#define R_PPC_EMB_SDA2I16 107
+#define R_PPC_EMB_SDA2REL 108
+#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
+#define R_PPC_EMB_MRKREF 110
+#define R_PPC_EMB_RELSEC16 111
+#define R_PPC_EMB_RELST_LO 112
+#define R_PPC_EMB_RELST_HI 113
+#define R_PPC_EMB_RELST_HA 114
+#define R_PPC_EMB_BIT_FLD 115
+#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
+
+/* Diab tool relocations. */
+#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
+#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
+#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
+#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
+#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
+#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+ that may still be in object files. */
+#define R_PPC_TOC16 255
+
+
+/* ARM specific declarations */
+
+/* Processor specific flags for the ELF header e_flags field. */
+#define EF_ARM_RELEXEC 0x01
+#define EF_ARM_HASENTRY 0x02
+#define EF_ARM_INTERWORK 0x04
+#define EF_ARM_APCS_26 0x08
+#define EF_ARM_APCS_FLOAT 0x10
+#define EF_ARM_PIC 0x20
+#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
+#define EF_ARM_NEW_ABI 0x80
+#define EF_ARM_OLD_ABI 0x100
+
+/* Other constants defined in the ARM ELF spec. version B-01. */
+/* NB. These conflict with values defined above. */
+#define EF_ARM_SYMSARESORTED 0x04
+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
+#define EF_ARM_MAPSYMSFIRST 0x10
+#define EF_ARM_EABIMASK 0XFF000000
+
+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
+#define EF_ARM_EABI_UNKNOWN 0x00000000
+#define EF_ARM_EABI_VER1 0x01000000
+#define EF_ARM_EABI_VER2 0x02000000
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC 0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
+#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
+ in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB 0x10000000 /* Segment contains the location
+ addressed by the static base */
+
+/* ARM relocs. */
+#define R_ARM_NONE 0 /* No reloc */
+#define R_ARM_PC24 1 /* PC relative 26 bit branch */
+#define R_ARM_ABS32 2 /* Direct 32 bit */
+#define R_ARM_REL32 3 /* PC relative 32 bit */
+#define R_ARM_PC13 4
+#define R_ARM_ABS16 5 /* Direct 16 bit */
+#define R_ARM_ABS12 6 /* Direct 12 bit */
+#define R_ARM_THM_ABS5 7
+#define R_ARM_ABS8 8 /* Direct 8 bit */
+#define R_ARM_SBREL32 9
+#define R_ARM_THM_PC22 10
+#define R_ARM_THM_PC8 11
+#define R_ARM_AMP_VCALL9 12
+#define R_ARM_SWI24 13
+#define R_ARM_THM_SWI8 14
+#define R_ARM_XPC25 15
+#define R_ARM_THM_XPC22 16
+#define R_ARM_COPY 20 /* Copy symbol at runtime */
+#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
+#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
+#define R_ARM_RELATIVE 23 /* Adjust by program base */
+#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
+#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
+#define R_ARM_GOT32 26 /* 32 bit GOT entry */
+#define R_ARM_PLT32 27 /* 32 bit PLT address */
+#define R_ARM_ALU_PCREL_7_0 32
+#define R_ARM_ALU_PCREL_15_8 33
+#define R_ARM_ALU_PCREL_23_15 34
+#define R_ARM_LDR_SBREL_11_0 35
+#define R_ARM_ALU_SBREL_19_12 36
+#define R_ARM_ALU_SBREL_27_20 37
+#define R_ARM_GNU_VTENTRY 100
+#define R_ARM_GNU_VTINHERIT 101
+#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
+#define R_ARM_THM_PC9 103 /* thumb conditional branch */
+#define R_ARM_RXPC25 249
+#define R_ARM_RSBREL32 250
+#define R_ARM_THM_RPC22 251
+#define R_ARM_RREL32 252
+#define R_ARM_RABS22 253
+#define R_ARM_RPC24 254
+#define R_ARM_RBASE 255
+/* Keep this the last entry. */
+#define R_ARM_NUM 256
+
+/* IA-64 specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
+#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
+#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
+
+/* Processor specific values for the Phdr p_type field. */
+#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
+#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
+
+/* Processor specific flags for the Phdr p_flags field. */
+#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
+
+/* Processor specific values for the Shdr sh_type field. */
+#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
+#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
+
+/* Processor specific flags for the Shdr sh_flags field. */
+#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
+#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
+
+/* Processor specific values for the Dyn d_tag field. */
+#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
+#define DT_IA_64_NUM 1
+
+/* IA-64 relocations. */
+#define R_IA64_NONE 0x00 /* none */
+#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
+#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
+#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
+#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
+#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
+#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
+#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
+#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
+#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
+#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
+#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
+#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
+#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
+#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
+#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
+#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
+#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
+#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
+#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
+#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
+#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
+#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
+#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
+#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
+#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
+#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
+#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
+#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
+#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
+#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
+#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
+#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
+#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
+#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
+#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
+#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
+#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
+#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
+#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
+#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
+#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
+#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
+#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
+#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
+#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
+#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
+#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
+#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
+#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
+#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
+#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
+#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
+#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
+#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
+#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
+#define R_IA64_COPY 0x84 /* copy relocation */
+#define R_IA64_SUB 0x85 /* Addend and symbol difference */
+#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
+#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
+#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
+#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
+#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
+#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
+#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
+#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
+#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
+#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
+#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
+#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
+#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
+#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
+#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
+#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
+
+/* SH specific declarations */
+
+/* SH relocs. */
+#define R_SH_NONE 0
+#define R_SH_DIR32 1
+#define R_SH_REL32 2
+#define R_SH_DIR8WPN 3
+#define R_SH_IND12W 4
+#define R_SH_DIR8WPL 5
+#define R_SH_DIR8WPZ 6
+#define R_SH_DIR8BP 7
+#define R_SH_DIR8W 8
+#define R_SH_DIR8L 9
+#define R_SH_SWITCH16 25
+#define R_SH_SWITCH32 26
+#define R_SH_USES 27
+#define R_SH_COUNT 28
+#define R_SH_ALIGN 29
+#define R_SH_CODE 30
+#define R_SH_DATA 31
+#define R_SH_LABEL 32
+#define R_SH_SWITCH8 33
+#define R_SH_GNU_VTINHERIT 34
+#define R_SH_GNU_VTENTRY 35
+#define R_SH_GOT32 160
+#define R_SH_PLT32 161
+#define R_SH_COPY 162
+#define R_SH_GLOB_DAT 163
+#define R_SH_JMP_SLOT 164
+#define R_SH_RELATIVE 165
+#define R_SH_GOTOFF 166
+#define R_SH_GOTPC 167
+/* Keep this the last entry. */
+#define R_SH_NUM 256
+
+/* Additional s390 relocs */
+
+#define R_390_NONE 0 /* No reloc. */
+#define R_390_8 1 /* Direct 8 bit. */
+#define R_390_12 2 /* Direct 12 bit. */
+#define R_390_16 3 /* Direct 16 bit. */
+#define R_390_32 4 /* Direct 32 bit. */
+#define R_390_PC32 5 /* PC relative 32 bit. */
+#define R_390_GOT12 6 /* 12 bit GOT offset. */
+#define R_390_GOT32 7 /* 32 bit GOT offset. */
+#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
+#define R_390_COPY 9 /* Copy symbol at runtime. */
+#define R_390_GLOB_DAT 10 /* Create GOT entry. */
+#define R_390_JMP_SLOT 11 /* Create PLT entry. */
+#define R_390_RELATIVE 12 /* Adjust by program base. */
+#define R_390_GOTOFF 13 /* 32 bit offset to GOT. */
+#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
+#define R_390_GOT16 15 /* 16 bit GOT offset. */
+#define R_390_PC16 16 /* PC relative 16 bit. */
+#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
+#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
+#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
+#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
+#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
+#define R_390_64 22 /* Direct 64 bit. */
+#define R_390_PC64 23 /* PC relative 64 bit. */
+#define R_390_GOT64 24 /* 64 bit GOT offset. */
+#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
+#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
+
+/* Keep this the last entry. */
+#define R_390_NUM 19
+
+/* CRIS relocations. */
+#define R_CRIS_NONE 0
+#define R_CRIS_8 1
+#define R_CRIS_16 2
+#define R_CRIS_32 3
+#define R_CRIS_8_PCREL 4
+#define R_CRIS_16_PCREL 5
+#define R_CRIS_32_PCREL 6
+#define R_CRIS_GNU_VTINHERIT 7
+#define R_CRIS_GNU_VTENTRY 8
+#define R_CRIS_COPY 9
+#define R_CRIS_GLOB_DAT 10
+#define R_CRIS_JUMP_SLOT 11
+#define R_CRIS_RELATIVE 12
+#define R_CRIS_16_GOT 13
+#define R_CRIS_32_GOT 14
+#define R_CRIS_16_GOTPLT 15
+#define R_CRIS_32_GOTPLT 16
+#define R_CRIS_32_GOTREL 17
+#define R_CRIS_32_PLT_GOTREL 18
+#define R_CRIS_32_PLT_PCREL 19
+
+#define R_CRIS_NUM 20
+
+#define R_MICROBLAZE_NONE 0
+#define R_MICROBLAZE_32 1
+#define R_MICROBLAZE_32_PCREL 2
+#define R_MICROBLAZE_64_PCREL 3
+#define R_MICROBLAZE_32_PCREL_LO 4
+#define R_MICROBLAZE_64 5
+#define R_MICROBLAZE_32_LO 6
+#define R_MICROBLAZE_SRO32 7
+#define R_MICROBLAZE_SRW32 8
+#define R_MICROBLAZE_64_NONE 9
+#define R_MICROBLAZE_32_SYM_OP_SYM 10
+#define R_MICROBLAZE_GNU_VTINHERIT 11
+#define R_MICROBLAZE_GNU_VTENTRY 12
+
+#define R_MICROBLAZE_NUM 13
+
+/* Altera NIOS specific definitions. */
+
+#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
+#define FLAT_NIOS2_R_HI_LO 1
+#define FLAT_NIOS2_R_HIADJ_LO 2
+#define FLAT_NIOS2_R_CALL26 4
+
+/* NIOS relocations. */
+#define R_NIOS_NONE 0
+#define R_NIOS_32 1 /* A 32 bit absolute relocation.*/
+#define R_NIOS_LO16_LO5 2 /* A LO-16 5 bit absolute relocation. */
+#define R_NIOS_LO16_HI11 3 /* A LO-16 top 11 bit absolute relocation. */
+#define R_NIOS_HI16_LO5 4 /* A HI-16 5 bit absolute relocation. */
+#define R_NIOS_HI16_HI11 5 /* A HI-16 top 11 bit absolute relocation. */
+#define R_NIOS_PCREL6 6 /* A 6 bit relative relocation. */
+#define R_NIOS_PCREL8 7 /* An 8 bit relative relocation. */
+#define R_NIOS_PCREL11 8 /* An 11 bit relative relocation. */
+#define R_NIOS_16 9 /* A 16 bit absolute relocation. */
+#define R_NIOS_H_LO5 10 /* Low 5-bits of absolute relocation in halfwords. */
+#define R_NIOS_H_HI11 11 /* Top 11 bits of 16-bit absolute relocation in halfwords. */
+#define R_NIOS_H_XLO5 12 /* Low 5 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
+#define R_NIOS_H_XHI11 13 /* Top 11 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
+#define R_NIOS_H_16 14 /* Half-word @h value */
+#define R_NIOS_H_32 15 /* Word @h value */
+#define R_NIOS_GNU_VTINHERIT 200 /* GNU extension to record C++ vtable hierarchy */
+#define R_NIOS_GNU_VTENTRY 201 /* GNU extension to record C++ vtable member usage */
+/* Keep this the last entry. */
+#define R_NIOS_NUM 202
+
+/* NIOS II relocations */
+#define R_NIOS2_NONE 0
+#define R_NIOS2_S16 1
+#define R_NIOS2_U16 2
+#define R_NIOS2_PCREL16 3
+#define R_NIOS2_CALL26 4
+#define R_NIOS2_IMM5 5
+#define R_NIOS2_CACHE_OPX 6
+#define R_NIOS2_IMM6 7
+#define R_NIOS2_IMM8 8
+#define R_NIOS2_HI16 9
+#define R_NIOS2_LO16 10
+#define R_NIOS2_HIADJ16 11
+#define R_NIOS2_BFD_RELOC_32 12
+#define R_NIOS2_BFD_RELOC_16 13
+#define R_NIOS2_BFD_RELOC_8 14
+#define R_NIOS2_GPREL 15
+#define R_NIOS2_GNU_VTINHERIT 16
+#define R_NIOS2_GNU_VTENTRY 17
+#define R_NIOS2_UJMP 18
+#define R_NIOS2_CJMP 19
+#define R_NIOS2_CALLR 20
+#define R_NIOS2_ALIGN 21
+/* Keep this the last entry. */
+#define R_NIOS2_NUM 22
+
+#endif /* elf.h */
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/e1-elf2flt.ld b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/e1-elf2flt.ld
new file mode 100644
index 0000000000..a88fc4ffeb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/e1-elf2flt.ld
@@ -0,0 +1,161 @@
+
+ENTRY (__start)
+
+MEMORY {
+ flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff
+}
+
+SECTIONS {
+ .G6 (DEFINED(G6Base) ? G6Base : 0x0) : {
+ *(.G6)
+ }
+ .G7 (DEFINED(G7Base) ? G7Base : 0x0) : {
+ *(.G7)
+ }
+ .G8 (DEFINED(G8Base) ? G8Base : 0x0) : {
+ *(.G8)
+ }
+ .G9 (DEFINED(G9Base) ? G9Base : 0) : {
+ *(.G9)
+ }
+ .G10 (DEFINED(G10Base) ? G10Base : 0) : {
+ *(.G10)
+ }
+ .G11 (DEFINED(G11Base) ? G11Base : 0) : {
+ *(.G11)
+ }
+ .G12 (DEFINED(G12Base) ? G12Base : 0) : {
+ *(.G12)
+ }
+ .G13 (DEFINED(G13Base) ? G13Base : 0) : {
+ *(.G13)
+ }
+ .text 0x0 : {
+ . = . + 4;
+ . = ALIGN(0x4) ;
+ _stext = . ;
+ *(.text)
+ *(.text.*)
+ *(.gnu.warning)
+ *(.stub)
+ *(.gnu.linkonce.t*)
+ *(.glue_7t)
+ *(.glue_7)
+ *(.jcr)
+ *(.init)
+ *(.fini)
+
+W_RODAT *(.rodata)
+W_RODAT *(.rodata1)
+W_RODAT *(.rodata.*)
+
+ /* This is special code area at the end of the normal
+ text section. It contains a small lookup table at
+ the start followed by the code pointed to by entries
+ in the lookup table. */
+ . = ALIGN (4) ;
+ PROVIDE(__ctbp = .);
+ *(.call_table_data)
+ *(.call_table_text)
+
+ . = ALIGN(0x20) ;
+ _etext = . ;
+ } > flatmem
+ .data : {
+ . = ALIGN(0x4) ;
+ _sdata = . ;
+ __data_start = . ;
+ data_start = . ;
+ *(.got.plt)
+ *(.got)
+ FILL(0) ;
+ . = ALIGN(0x20) ;
+ LONG(-1)
+ . = ALIGN(0x20) ;
+R_RODAT *(.rodata)
+R_RODAT *(.rodata1)
+R_RODAT *(.rodata.*)
+ *(.gnu.linkonce.r*)
+ *(.data)
+ *(.data1)
+ *(.data.*)
+ *(.gnu.linkonce.d*)
+ *(.data1)
+ *(.eh_frame)
+ *(.gcc_except_table)
+
+ /* Microblaze has .sdata and .sbss (small bss). They must
+ be contiguous, so please don't move any of this. JW */
+ _ssrw = . ;
+ *(.sdata)
+ *(.sdata.*)
+ *(.sbss) /* Don't move this! */
+ _essrw = . ;
+
+ _ssrw_size = _essrw - _ssrw;
+ PROVIDE(_SDA_BASE_ = _ssrw + (_ssrw_size / 2));
+
+ *(.gnu.linkonce.s.*)
+ *(__libc_atexit)
+ *(__libc_subinit)
+ *(__libc_subfreeres)
+ *(.note.ABI-tag)
+
+ /* microblaze-specific read-only small data area
+ and associated locating symbols */
+ _ssro = . ;
+ *(.sdata2)
+ _essro = . ;
+ _ssro_size = _essro - _ssro;
+ PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2));
+
+ . = ALIGN(4) ;
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
+ *(.ctors)
+ LONG(0)
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
+ *(.dtors)
+ LONG(0)
+ __DTOR_END__ = .;
+
+ . = ALIGN(0x10) ;
+ _edata = . ;
+ } > flatmem
+ .bss : {
+ . = ALIGN(0x4) ;
+ _sbss = ALIGN(0x4) ;
+ __bss_start = . ;
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(.bss.*)
+ *(.bss*)
+ *(.gnu.linkonce.b*)
+ *(COMMON)
+ . = ALIGN(0x10) ;
+ _ebss = . ;
+ _end = . ;
+ end = . ;
+ } > flatmem
+
+ .junk 0 : { *(.rel*) *(.rela*) }
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.c b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.c
new file mode 100644
index 0000000000..65a116c6c5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.c
@@ -0,0 +1,2152 @@
+/*
+ * elf2flt.c: Convert ELF (or any BFD format) to FLAT binary format
+ *
+ * (c) 1999-2002, Greg Ungerer <gerg@snapgear.com>
+ * Created elf2flt from coff2flt (see copyrights below). Added all the
+ * ELF format file handling. Extended relocation support for all of
+ * text and data.
+ *
+ * (c) 2006 Support the -a (use_resolved) option for TARGET_arm.
+ * Shaun Jackman <sjackman@gmail.com>
+ * (c) 2004, Nios II support, Wentao Xu <wentao@microtronix.com>
+ * (c) 2003, H8 support, ktrace <davidm@snapgear.com>
+ * (c) 2003-2004, MicroBlaze support, John Williams <jwilliams@itee.uq.edu.au>
+ * (c) 2001-2003, arm/arm-pic/arm-big-endian support <davidm@snapgear.com>
+ * (c) 2001, v850 changes, Mile Bader <miles@lsi.nec.co.jp>
+ * (c) 2003, SuperH support, Paul Mundt <lethal@linux-sh.org>
+ * (c) 2001, zflat support <davidm@snapgear.com>
+ * (c) 2001, Changes for GOT entries Paul Dale <pauli@snapgear.com> and
+ * David McCullough <davidm@snapgear.com>
+ *
+ * Now supports PIC with GOT tables. This works by taking a '.elf' file
+ * and a fully linked elf executable (at address 0) and produces a flat
+ * file that can be loaded with some fixups. It still supports the old
+ * style fully relocatable elf format files.
+ *
+ * Originally obj-res.c
+ *
+ * (c) 1998, Kenneth Albanowski <kjahds@kjahds.com>
+ * (c) 1998, D. Jeff Dionne
+ * (c) 1998, The Silver Hammer Group Ltd.
+ * (c) 1996, 1997 Dionne & Associates <jeff@ryeham.ee.ryerson.ca>
+ *
+ * This is Free Software, under the GNU Public Licence v2 or greater.
+ *
+ * Relocation added March 1997, Kresten Krab Thorup
+ * krab@california.daimi.aau.dk
+ */
+
+#include <stdio.h> /* Userland pieces of the ANSI C standard I/O package */
+#include <stdlib.h> /* Userland prototypes of the ANSI C std lib functions */
+#include <stdarg.h> /* Allows va_list to exist in the these namespaces */
+#include <string.h> /* Userland prototypes of the string handling funcs */
+#include <strings.h>
+#include <unistd.h> /* Userland prototypes of the Unix std system calls */
+#include <fcntl.h> /* Flag value for file handling functions */
+#include <time.h>
+#ifndef WIN32
+#include <netinet/in.h> /* Consts and structs defined by the internet system */
+#define BINARY_FILE_OPTS
+#else
+#include <winsock2.h>
+#define BINARY_FILE_OPTS "b"
+#endif
+
+/* from $(INSTALLDIR)/include */
+#include <bfd.h> /* Main header file for the BFD library */
+
+#if defined(TARGET_h8300)
+#include <elf/h8.h> /* TARGET_* ELF support for the BFD library */
+#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(TARGET_nios) || defined(TARGET_nios2)
+#include "cygwin-elf.h" /* Cygwin uses a local copy */
+#elif defined(TARGET_microblaze)
+#include <elf/microblaze.h> /* TARGET_* ELF support for the BFD library */
+#elif defined(TARGET_bfin)
+#include "elf/bfin.h"
+#else
+#include <elf.h> /* TARGET_* ELF support for the BFD library */
+#endif
+
+#if defined(__MINGW32__)
+#include <getopt.h>
+#endif
+
+/* from uClinux-x.x.x/include/linux */
+#include "flat.h" /* Binary flat header description */
+
+#ifdef TARGET_e1
+#include <e1.h>
+#endif
+
+#ifdef TARGET_v850e
+#define TARGET_v850
+#endif
+
+#if defined(TARGET_m68k)
+#define ARCH "m68k/coldfire"
+#elif defined(TARGET_arm)
+#define ARCH "arm"
+#elif defined(TARGET_sparc)
+#define ARCH "sparc"
+#elif defined(TARGET_v850)
+#define ARCH "v850"
+#elif defined(TARGET_sh)
+#define ARCH "sh"
+#elif defined(TARGET_h8300)
+#define ARCH "h8300"
+#elif defined(TARGET_microblaze)
+#define ARCH "microblaze"
+#elif defined(TARGET_e1)
+#define ARCH "e1-coff"
+#elif defined(TARGET_bfin)
+#define ARCH "bfin"
+#define FLAT_RELOC_TYPE_TEXT 0
+#define FLAT_RELOC_TYPE_DATA 1
+#define FLAT_RELOC_TYPE_BSS 2
+#define FLAT_RELOC_TYPE_STACK 3
+#define FLAT_RELOC_PART_LO 0
+#define FLAT_RELOC_PART_HI 1
+#define PCREL24_MAGIC_OFFSET -1
+#elif defined(TARGET_nios)
+#define ARCH "nios"
+#elif defined(TARGET_nios2)
+#define ARCH "nios2"
+#else
+#error "Don't know how to support your CPU architecture??"
+#endif
+
+#if defined(TARGET_m68k) || defined(TARGET_h8300) || defined(TARGET_bfin)
+/*
+ * Define a maximum number of bytes allowed in the offset table.
+ * We'll fail if the table is larger than this.
+ *
+ * This limit may be different for platforms other than m68k, but
+ * 8000 entries is a lot, trust me :-) (davidm)
+ */
+#define GOT_LIMIT 32767
+/*
+ * we have to mask out the shared library id here and there, this gives
+ * us the real address bits when needed
+ */
+#define real_address_bits(x) (pic_with_got ? ((x) & 0xffffff) : (x))
+#else
+#define real_address_bits(x) (x)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
+int verbose = 0; /* extra output when running */
+int pic_with_got = 0; /* do elf/got processing with PIC code */
+int load_to_ram = 0; /* instruct loader to allocate everything into RAM */
+int ktrace = 0; /* instruct loader output kernel trace on load */
+int compress = 0; /* 1 = compress everything, 2 = compress data only */
+int use_resolved = 0; /* If true, get the value of symbol references from */
+ /* the program contents, not from the relocation table. */
+ /* In this case, the input ELF file must be already */
+ /* fully resolved (using the `-q' flag with recent */
+ /* versions of GNU ld will give you a fully resolved */
+ /* output file with relocation entries). */
+
+const char *progname, *filename;
+int lineno;
+
+int nerrors = 0;
+int nwarnings = 0;
+
+static char where[200];
+
+enum {
+ /* Use exactly one of these: */
+ E_NOFILE = 0, /* "progname: " */
+ E_FILE = 1, /* "filename: " */
+ E_FILELINE = 2, /* "filename:lineno: " */
+ E_FILEWHERE = 3, /* "filename:%s: " -- set %s with ewhere() */
+
+ /* Add in any of these with |': */
+ E_WARNING = 0x10,
+ E_PERROR = 0x20
+};
+
+void ewhere (const char *format, ...);
+void einfo (int type, const char *format, ...);
+
+
+void
+ewhere (const char *format, ...) {
+ va_list args;
+ va_start (args, format);
+ vsprintf (where, format, args);
+ va_end (args);
+}
+
+
+void
+einfo (int type, const char *format, ...) {
+ va_list args;
+
+ switch (type & 0x0f) {
+ case E_NOFILE:
+ fprintf (stderr, "%s: ", progname);
+ break;
+ case E_FILE:
+ fprintf (stderr, "%s: ", filename);
+ break;
+ case E_FILELINE:
+ ewhere ("%d", lineno);
+ /* fall-through */
+ case E_FILEWHERE:
+ fprintf (stderr, "%s:%s: ", filename, where);
+ break;
+ }
+
+ if (type & E_WARNING) {
+ fprintf (stderr, "warning: ");
+ nwarnings++;
+ } else {
+ nerrors++;
+ }
+
+ va_start (args, format);
+ vfprintf (stderr, format, args);
+ va_end (args);
+
+ if (type & E_PERROR)
+ perror ("");
+ else
+ fprintf (stderr, "\n");
+}
+
+
+asymbol**
+get_symbols (bfd *abfd, long *num)
+{
+ long storage_needed;
+ asymbol **symbol_table;
+ long number_of_symbols;
+
+ storage_needed = bfd_get_symtab_upper_bound (abfd);
+
+ if (storage_needed < 0)
+ abort ();
+
+ if (storage_needed == 0)
+ return NULL;
+
+ symbol_table = (asymbol **) malloc (storage_needed);
+
+ number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+
+ if (number_of_symbols < 0)
+ abort ();
+
+ *num = number_of_symbols;
+ return symbol_table;
+}
+
+
+
+int
+dump_symbols(asymbol **symbol_table, long number_of_symbols)
+{
+ long i;
+ printf("SYMBOL TABLE:\n");
+ for (i=0; i<number_of_symbols; i++) {
+ printf(" NAME=%s VALUE=0x%x\n", symbol_table[i]->name,
+ symbol_table[i]->value);
+ }
+ printf("\n");
+ return(0);
+}
+
+
+
+long
+get_symbol_offset(char *name, asection *sec, asymbol **symbol_table, long number_of_symbols)
+{
+ long i;
+ for (i=0; i<number_of_symbols; i++) {
+ if (symbol_table[i]->section == sec) {
+ if (!strcmp(symbol_table[i]->name, name)) {
+ return symbol_table[i]->value;
+ }
+ }
+ }
+ return -1;
+}
+
+
+
+long
+get_gp_value(asymbol **symbol_table, long number_of_symbols)
+{
+ long i;
+ for (i=0; i<number_of_symbols; i++) {
+ if (!strcmp(symbol_table[i]->name, "_gp"))
+ return symbol_table[i]->value;
+ }
+ return -1;
+}
+
+
+
+long
+add_com_to_bss(asymbol **symbol_table, long number_of_symbols, long bss_len)
+{
+ long i, comsize;
+ long offset;
+
+ comsize = 0;
+ for (i=0; i<number_of_symbols; i++) {
+ if (strcmp("*COM*", symbol_table[i]->section->name) == 0) {
+ offset = bss_len + comsize;
+ comsize += symbol_table[i]->value;
+ symbol_table[i]->value = offset;
+ }
+ }
+ return comsize;
+}
+
+#ifdef TARGET_bfin
+/* FUNCTION : weak_und_symbol
+ ABSTRACT : return true if symbol is weak and undefined.
+*/
+static int
+weak_und_symbol(const char *reloc_section_name,
+ struct bfd_symbol *symbol)
+{
+ if (!(strstr (reloc_section_name, "text")
+ || strstr (reloc_section_name, "data")
+ || strstr (reloc_section_name, "bss"))) {
+ if (symbol->flags & BSF_WEAK) {
+#ifdef DEBUG_BFIN
+ fprintf(stderr, "found weak undefined symbol %s\n", symbol->name);
+#endif
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static int
+bfin_set_reloc (uint32_t *reloc,
+ const char *reloc_section_name,
+ const char *sym_name,
+ struct bfd_symbol *symbol,
+ int sp, int hilo, int32_t offset)
+{
+ unsigned int type;
+ uint32_t val;
+
+ if (strstr (reloc_section_name, "text"))
+ type = FLAT_RELOC_TYPE_TEXT;
+ else if (strstr (reloc_section_name, "data"))
+ type = FLAT_RELOC_TYPE_DATA;
+ else if (strstr (reloc_section_name, "bss"))
+ type = FLAT_RELOC_TYPE_BSS;
+ else if (strstr (reloc_section_name, "stack"))
+ type = FLAT_RELOC_TYPE_STACK;
+ else if (symbol->flags & BSF_WEAK){
+ /* weak symbol support ... if a weak symbol is undefined at the
+ end of a final link, it should return 0 rather than error
+ We will assume text section for the moment.
+ */
+ type = FLAT_RELOC_TYPE_TEXT;
+ } else if (strstr (reloc_section_name, "*ABS*")){
+ /* (A data section initialization of something in the shared libc's text section
+ does not resolve - i.e. a global pointer to function initialized with
+ a libc function).
+ The text section here is appropriate as the section information
+ of the shared library is lost. The loader will do some calcs.
+ */
+ type = FLAT_RELOC_TYPE_TEXT;
+ } else {
+ printf ("Unknown Type - relocation for %s in bad section - %s\n", sym_name, reloc_section_name);
+ return 1;
+ }
+
+ val = (offset & ((1 << 26) - 1)) << 6;
+ val |= (sp & (1 << 3) - 1) << 3;
+ val |= (hilo & 1) << 2;
+ val |= (type & (1 << 2) - 1);
+ *reloc = val;
+ return 0;
+}
+#endif
+
+
+uint32_t *
+output_relocs (
+ bfd *abs_bfd,
+ asymbol **symbols,
+ int number_of_symbols,
+ unsigned long *n_relocs,
+ unsigned char *text, int text_len, unsigned long text_vma,
+ unsigned char *data, int data_len, unsigned long data_vma,
+ bfd *rel_bfd)
+{
+ uint32_t *flat_relocs;
+ asection *a, *sym_section, *r;
+ arelent **relpp, **p, *q;
+ const char *sym_name, *section_name;
+ unsigned char *sectionp;
+ unsigned long pflags;
+ char addstr[16];
+ long sym_addr, sym_vma, section_vma;
+ int relsize, relcount;
+ int flat_reloc_count;
+ int sym_reloc_size, rc;
+ int got_size = 0;
+ int bad_relocs = 0;
+ asymbol **symb;
+ long nsymb;
+
+#if 0
+ printf("%s(%d): output_relocs(abs_bfd=%d,synbols=0x%x,number_of_symbols=%d"
+ "n_relocs=0x%x,text=0x%x,text_len=%d,data=0x%x,data_len=%d)\n",
+ __FILE__, __LINE__, abs_bfd, symbols, number_of_symbols, n_relocs,
+ text, text_len, data, data_len);
+#endif
+
+#if 0
+dump_symbols(symbols, number_of_symbols);
+#endif
+
+ *n_relocs = 0;
+ flat_relocs = NULL;
+ flat_reloc_count = 0;
+ rc = 0;
+ pflags = 0;
+
+ /* Determine how big our offset table is in bytes.
+ * This isn't too difficult as we've terminated the table with -1.
+ * Also note that both the relocatable and absolute versions have this
+ * terminator even though the relocatable one doesn't have the GOT!
+ */
+ if (pic_with_got && !use_resolved) {
+ unsigned long *lp = (unsigned long *)data;
+ /* Should call ntohl(*lp) here but is isn't going to matter */
+ while (*lp != 0xffffffff) lp++;
+ got_size = ((unsigned char *)lp) - data;
+ if (verbose)
+ printf("GOT table contains %d entries (%d bytes)\n",
+ got_size/sizeof(unsigned long), got_size);
+#ifdef TARGET_m68k
+ if (got_size > GOT_LIMIT) {
+ fprintf(stderr, "GOT too large: %d bytes (limit = %d bytes)\n",
+ got_size, GOT_LIMIT);
+ exit(1);
+ }
+#endif
+ }
+
+ for (a = abs_bfd->sections; (a != (asection *) NULL); a = a->next) {
+ section_vma = bfd_section_vma(abs_bfd, a);
+
+ if (verbose)
+ printf("SECTION: %s [0x%x]: flags=0x%x vma=0x%x\n", a->name, a,
+ a->flags, section_vma);
+
+// if (bfd_is_abs_section(a))
+// continue;
+ if (bfd_is_und_section(a))
+ continue;
+ if (bfd_is_com_section(a))
+ continue;
+// if ((a->flags & SEC_RELOC) == 0)
+// continue;
+
+ /*
+ * Only relocate things in the data sections if we are PIC/GOT.
+ * otherwise do text as well
+ */
+ if (!pic_with_got && (a->flags & SEC_CODE))
+ sectionp = text + (a->vma - text_vma);
+ else if (a->flags & SEC_DATA)
+ sectionp = data + (a->vma - data_vma);
+ else
+ continue;
+
+ /* Now search for the equivalent section in the relocation binary
+ * and use that relocation information to build reloc entries
+ * for this one.
+ */
+ for (r=rel_bfd->sections; r != NULL; r=r->next)
+ if (strcmp(a->name, r->name) == 0)
+ break;
+ if (r == NULL)
+ continue;
+ if (verbose)
+ printf(" RELOCS: %s [0x%x]: flags=0x%x vma=0x%x\n", r->name, r,
+ r->flags, bfd_section_vma(abs_bfd, r));
+ if ((r->flags & SEC_RELOC) == 0)
+ continue;
+ relsize = bfd_get_reloc_upper_bound(rel_bfd, r);
+ if (relsize <= 0) {
+ if (verbose)
+ printf("%s(%d): no relocation entries section=0x%x\n",
+ __FILE__, __LINE__, r->name);
+ continue;
+ }
+
+ symb = get_symbols(rel_bfd, &nsymb);
+ relpp = (arelent **) xmalloc(relsize);
+ relcount = bfd_canonicalize_reloc(rel_bfd, r, relpp, symb);
+ if (relcount <= 0) {
+ if (verbose)
+ printf("%s(%d): no relocation entries section=%s\n",
+ __FILE__, __LINE__, r->name);
+ continue;
+ } else {
+ for (p = relpp; (relcount && (*p != NULL)); p++, relcount--) {
+ unsigned char *r_mem;
+ int relocation_needed = 0;
+
+#ifdef TARGET_microblaze
+ /* The MICROBLAZE_XX_NONE relocs can be skipped.
+ They represent PC relative branches that the
+ linker has already resolved */
+
+ switch ((*p)->howto->type)
+ {
+ case R_MICROBLAZE_NONE:
+ case R_MICROBLAZE_64_NONE:
+ continue;
+ }
+#endif /* TARGET_microblaze */
+
+#ifdef TARGET_v850
+ /* Skip this relocation entirely if possible (we
+ do this early, before doing any other
+ processing on it). */
+ switch ((*p)->howto->type) {
+#ifdef R_V850_9_PCREL
+ case R_V850_9_PCREL:
+#endif
+#ifdef R_V850_22_PCREL
+ case R_V850_22_PCREL:
+#endif
+#ifdef R_V850_SDA_16_16_OFFSET
+ case R_V850_SDA_16_16_OFFSET:
+#endif
+#ifdef R_V850_SDA_15_16_OFFSET
+ case R_V850_SDA_15_16_OFFSET:
+#endif
+#ifdef R_V850_ZDA_15_16_OFFSET
+ case R_V850_ZDA_15_16_OFFSET:
+#endif
+#ifdef R_V850_TDA_6_8_OFFSET
+ case R_V850_TDA_6_8_OFFSET:
+#endif
+#ifdef R_V850_TDA_7_8_OFFSET
+ case R_V850_TDA_7_8_OFFSET:
+#endif
+#ifdef R_V850_TDA_7_7_OFFSET
+ case R_V850_TDA_7_7_OFFSET:
+#endif
+#ifdef R_V850_TDA_16_16_OFFSET
+ case R_V850_TDA_16_16_OFFSET:
+#endif
+#ifdef R_V850_TDA_4_5_OFFSET
+ case R_V850_TDA_4_5_OFFSET:
+#endif
+#ifdef R_V850_TDA_4_4_OFFSET
+ case R_V850_TDA_4_4_OFFSET:
+#endif
+#ifdef R_V850_SDA_16_16_SPLIT_OFFSET
+ case R_V850_SDA_16_16_SPLIT_OFFSET:
+#endif
+#ifdef R_V850_CALLT_6_7_OFFSET
+ case R_V850_CALLT_6_7_OFFSET:
+#endif
+#ifdef R_V850_CALLT_16_16_OFFSET
+ case R_V850_CALLT_16_16_OFFSET:
+#endif
+ /* These are relative relocations, which
+ have already been fixed up by the
+ linker at this point, so just ignore
+ them. */
+ continue;
+ }
+#endif /* USE_V850_RELOCS */
+
+ q = *p;
+ if (q->sym_ptr_ptr && *q->sym_ptr_ptr) {
+ sym_name = (*(q->sym_ptr_ptr))->name;
+ sym_section = (*(q->sym_ptr_ptr))->section;
+ section_name=(*(q->sym_ptr_ptr))->section->name;
+ } else {
+ printf("ERROR: undefined relocation entry\n");
+ rc = -1;
+ continue;
+ }
+#ifndef TARGET_bfin
+ /* Adjust the address to account for the GOT table which wasn't
+ * present in the relative file link.
+ */
+ if (pic_with_got && !use_resolved)
+ q->address += got_size;
+#endif
+
+ /* A pointer to what's being relocated, used often
+ below. */
+ r_mem = sectionp + q->address;
+
+ /*
+ * Fixup offset in the actual section.
+ */
+ addstr[0] = 0;
+#ifndef TARGET_e1
+ if ((sym_addr = get_symbol_offset((char *) sym_name,
+ sym_section, symbols, number_of_symbols)) == -1) {
+ sym_addr = 0;
+ }
+#else
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+#endif
+ if (use_resolved) {
+ /* Use the address of the symbol already in
+ the program text. How this is handled may
+ still depend on the particular relocation
+ though. */
+ switch (q->howto->type) {
+ int r2_type;
+#ifdef TARGET_v850
+ case R_V850_HI16_S:
+ /* We specially handle adjacent
+ HI16_S/ZDA_15_16_OFFSET and
+ HI16_S/LO16 pairs that reference the
+ same address (these are usually
+ movhi/ld and movhi/movea pairs,
+ respectively). */
+ if (relcount == 0)
+ r2_type = R_V850_NONE;
+ else
+ r2_type = p[1]->howto->type;
+ if ((r2_type == R_V850_ZDA_15_16_OFFSET
+ || r2_type == R_V850_LO16)
+ && (p[0]->sym_ptr_ptr
+ == p[1]->sym_ptr_ptr)
+ && (p[0]->addend == p[1]->addend))
+ {
+ relocation_needed = 1;
+
+ switch (r2_type) {
+ case R_V850_ZDA_15_16_OFFSET:
+ pflags = 0x10000000;
+ break;
+ case R_V850_LO16:
+ pflags = 0x20000000;
+ break;
+ }
+
+ /* We don't really need the
+ actual value -- the bits
+ produced by the linker are
+ what we want in the final
+ flat file -- but get it
+ anyway if useful for
+ debugging. */
+ if (verbose) {
+ unsigned char *r2_mem =
+ sectionp
+ + p[1]->address;
+ /* little-endian */
+ int hi = r_mem[0]
+ + (r_mem[1] << 8);
+ int lo = r2_mem[0]
+ + (r2_mem[1] << 8);
+ /* Sign extend LO. */
+ lo = (lo ^ 0x8000)
+ - 0x8000;
+
+ /* Maybe ignore the LSB
+ of LO, which is
+ actually part of the
+ instruction. */
+ if (r2_type != R_V850_LO16)
+ lo &= ~1;
+
+ sym_addr =
+ (hi << 16)
+ + lo;
+ }
+ } else
+ goto bad_resolved_reloc;
+ break;
+
+ case R_V850_LO16:
+ /* See if this is actually the
+ 2nd half of a pair. */
+ if (p > relpp
+ && (p[-1]->howto->type
+ == R_V850_HI16_S)
+ && (p[-1]->sym_ptr_ptr
+ == p[0]->sym_ptr_ptr)
+ && (p[-1]->addend == p[0]->addend))
+ break; /* not an error */
+ else
+ goto bad_resolved_reloc;
+
+ case R_V850_HI16:
+ goto bad_resolved_reloc;
+ default:
+ goto good_32bit_resolved_reloc;
+#elif defined(TARGET_arm)
+ case R_ARM_ABS32:
+ relocation_needed = 1;
+ break;
+ case R_ARM_REL32:
+ case R_ARM_THM_PC11:
+ case R_ARM_THM_PC22:
+ relocation_needed = 0;
+ break;
+ default:
+ goto bad_resolved_reloc;
+#elif defined(TARGET_m68k)
+ case R_68K_32:
+ goto good_32bit_resolved_reloc;
+ case R_68K_PC32:
+ case R_68K_PC16:
+ /* The linker has already resolved
+ PC relocs for us. In PIC links,
+ the symbol must be in the data
+ segment. */
+ case R_68K_NONE:
+ continue;
+ default:
+ goto bad_resolved_reloc;
+#else
+ default:
+ /* The default is to assume that the
+ relocation is relative and has
+ already been fixed up by the
+ linker (perhaps we ought to make
+ give an error by default, and
+ require `safe' relocations to be
+ enumberated explicitly?). */
+ goto good_32bit_resolved_reloc;
+#endif
+ good_32bit_resolved_reloc:
+ if (bfd_big_endian (abs_bfd))
+ sym_addr =
+ (r_mem[0] << 24)
+ + (r_mem[1] << 16)
+ + (r_mem[2] << 8)
+ + r_mem[3];
+ else
+ sym_addr =
+ r_mem[0]
+ + (r_mem[1] << 8)
+ + (r_mem[2] << 16)
+ + (r_mem[3] << 24);
+ relocation_needed = 1;
+ break;
+
+ bad_resolved_reloc:
+ printf("ERROR: reloc type %s unsupported in this context\n",
+ q->howto->name);
+ bad_relocs++;
+ break;
+ }
+ } else {
+ /* Calculate the sym address ourselves. */
+ sym_reloc_size = bfd_get_reloc_size(q->howto);
+
+#if !defined(TARGET_h8300) && !defined(TARGET_e1) && !defined(TARGET_bfin) && !defined(TARGET_m68k)
+ if (sym_reloc_size != 4) {
+ printf("ERROR: bad reloc type %d size=%d for symbol=%s\n",
+ (*p)->howto->type, sym_reloc_size, sym_name);
+ bad_relocs++;
+ rc = -1;
+ continue;
+ }
+#endif
+
+ switch ((*p)->howto->type) {
+
+#if defined(TARGET_m68k)
+ case R_68K_32:
+ relocation_needed = 1;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_68K_PC16:
+ case R_68K_PC32:
+ sym_vma = 0;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= q->address;
+ break;
+#endif
+
+#if defined(TARGET_arm)
+ case R_ARM_ABS32:
+ relocation_needed = 1;
+ if (verbose)
+ fprintf(stderr,
+ "%s vma=0x%x, value=0x%x, address=0x%x "
+ "sym_addr=0x%x rs=0x%x, opcode=0x%x\n",
+ "ABS32",
+ sym_vma, (*(q->sym_ptr_ptr))->value,
+ q->address, sym_addr,
+ (*p)->howto->rightshift,
+ *(unsigned long *)r_mem);
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_ARM_GOT32:
+ case R_ARM_GOTPC:
+ /* Should be fine as is */
+ break;
+ case R_ARM_PLT32:
+ if (verbose)
+ fprintf(stderr,
+ "%s vma=0x%x, value=0x%x, address=0x%x "
+ "sym_addr=0x%x rs=0x%x, opcode=0x%x\n",
+ "PLT32",
+ sym_vma, (*(q->sym_ptr_ptr))->value,
+ q->address, sym_addr,
+ (*p)->howto->rightshift,
+ *(unsigned long *)r_mem);
+ case R_ARM_PC24:
+ sym_vma = 0;
+ sym_addr = (sym_addr-q->address)>>(*p)->howto->rightshift;
+ break;
+#endif
+
+#ifdef TARGET_v850
+ case R_V850_32:
+ relocation_needed = 1;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+#if defined(R_V850_ZDA_16_16_OFFSET) || defined(R_V850_ZDA_16_16_SPLIT_OFFSET)
+#ifdef R_V850_ZDA_16_16_OFFSET
+ case R_V850_ZDA_16_16_OFFSET:
+#endif
+#ifdef R_V850_ZDA_16_16_SPLIT_OFFSET
+ case R_V850_ZDA_16_16_SPLIT_OFFSET:
+#endif
+ /* Can't support zero-relocations. */
+ printf ("ERROR: %s+0x%x: zero relocations not supported\n",
+ sym_name, q->addend);
+ continue;
+#endif /* R_V850_ZDA_16_16_OFFSET || R_V850_ZDA_16_16_SPLIT_OFFSET */
+#endif /* TARGET_v850 */
+
+#ifdef TARGET_h8300
+ case R_H8_DIR24R8:
+ if (sym_reloc_size != 4) {
+ printf("R_H8_DIR24R8 size %d\n", sym_reloc_size);
+ bad_relocs++;
+ continue;
+ }
+ relocation_needed = 1;
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+ q->address -= 1;
+ r_mem -= 1; /* tracks q->address */
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ sym_addr |= (*(unsigned char *)r_mem<<24);
+ break;
+ case R_H8_DIR24A8:
+ if (sym_reloc_size != 4) {
+ printf("R_H8_DIR24A8 size %d\n", sym_reloc_size);
+ bad_relocs++;
+ continue;
+ }
+ /* Absolute symbol done not relocation */
+ relocation_needed = !bfd_is_abs_section(sym_section);
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_H8_DIR32:
+ case R_H8_DIR32A16: /* currently 32, could be made 16 */
+ if (sym_reloc_size != 4) {
+ printf("R_H8_DIR32 size %d\n", sym_reloc_size);
+ bad_relocs++;
+ continue;
+ }
+ relocation_needed = 1;
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_H8_PCREL16:
+ sym_vma = 0;
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= (q->address + 2);
+ if (bfd_big_endian(abs_bfd))
+ *(unsigned short *)r_mem =
+ bfd_big_endian(abs_bfd) ? htons(sym_addr) : sym_addr;
+ continue;
+ case R_H8_PCREL8:
+ sym_vma = 0;
+ sym_addr = (*(q->sym_ptr_ptr))->value;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= (q->address + 1);
+ *(unsigned char *)r_mem = sym_addr;
+ continue;
+#endif
+
+#ifdef TARGET_microblaze
+ case R_MICROBLAZE_64:
+ /* The symbol is split over two consecutive instructions.
+ Flag this to the flat loader by setting the high bit of
+ the relocation symbol. */
+ {
+ unsigned char *p = r_mem;
+ unsigned long offset;
+ pflags=0x80000000;
+
+ /* work out the relocation */
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ /* grab any offset from the text */
+ offset = (p[2]<<24) + (p[3] << 16) + (p[6] << 8) + (p[7]);
+ /* Update the address */
+ sym_addr += offset + sym_vma + q->addend;
+ /* Write relocated pointer back */
+ p[2] = (sym_addr >> 24) & 0xff;
+ p[3] = (sym_addr >> 16) & 0xff;
+ p[6] = (sym_addr >> 8) & 0xff;
+ p[7] = sym_addr & 0xff;
+
+ /* create a new reloc entry */
+ flat_relocs = realloc(flat_relocs,
+ (flat_reloc_count + 1) * sizeof(uint32_t));
+ flat_relocs[flat_reloc_count] = pflags | (section_vma + q->address);
+ flat_reloc_count++;
+ relocation_needed = 0;
+ pflags = 0;
+ sprintf(&addstr[0], "+0x%x", sym_addr - (*(q->sym_ptr_ptr))->value -
+ bfd_section_vma(abs_bfd, sym_section));
+ if (verbose)
+ printf(" RELOC[%d]: offset=0x%x symbol=%s%s "
+ "section=%s size=%d "
+ "fixup=0x%x (reloc=0x%x)\n", flat_reloc_count,
+ q->address, sym_name, addstr,
+ section_name, sym_reloc_size,
+ sym_addr, section_vma + q->address);
+ if (verbose)
+ printf("reloc[%d] = 0x%x\n", flat_reloc_count,
+ section_vma + q->address);
+
+ continue;
+ }
+ case R_MICROBLAZE_32:
+ {
+ unsigned char *p = r_mem;
+ unsigned long offset;
+
+ /* grab any offset from the text */
+ offset = (p[0]<<24) + (p[1] << 16) + (p[2] << 8) + (p[3]);
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ /* This is a horrible kludge. For some
+ reason, *sometimes* the offset is in
+ both addend and the code. Detect
+ it, and cancel the effect. Otherwise
+ the offset gets added twice - ouch.
+ There should be a better test
+ for this condition, based on the
+ BFD data structures */
+ if(offset==q->addend)
+ offset=0;
+
+ sym_addr += offset + sym_vma + q->addend;
+ relocation_needed = 1;
+ break;
+ }
+ case R_MICROBLAZE_64_PCREL:
+ sym_vma = 0;
+ //sym_addr = (*(q->sym_ptr_ptr))->value;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= (q->address + 4);
+ sym_addr = htonl(sym_addr);
+ /* insert 16 MSB */
+ * ((unsigned short *) (r_mem+2)) |= (sym_addr) & 0xFFFF;
+ /* then 16 LSB */
+ * ((unsigned short *) (r_mem+6)) |= (sym_addr >> 16) & 0xFFFF;
+ /* We've done all the work, so continue
+ to next reloc instead of break */
+ continue;
+
+#endif /* TARGET_microblaze */
+
+#ifdef TARGET_nios2
+#define htoniosl(x) (x)
+#define niostohl(x) (x)
+ case R_NIOS2_BFD_RELOC_32:
+ relocation_needed = 1;
+ pflags = (FLAT_NIOS2_R_32 << 28);
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ /* modify target, in target order */
+ *(unsigned long *)r_mem = htoniosl(sym_addr);
+ break;
+ case R_NIOS2_CALL26:
+ {
+ unsigned long exist_val;
+ relocation_needed = 1;
+ pflags = (FLAT_NIOS2_R_CALL26 << 28);
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+
+ /* modify target, in target order */
+ // exist_val = niostohl(*(unsigned long *)r_mem);
+ exist_val = ((sym_addr >> 2) << 6);
+ *(unsigned long *)r_mem = htoniosl(exist_val);
+ break;
+ }
+ case R_NIOS2_HIADJ16:
+ case R_NIOS2_HI16:
+ {
+ unsigned long exist_val;
+ int r2_type;
+ /* handle the adjacent HI/LO pairs */
+ if (relcount == 0)
+ r2_type = R_NIOS2_NONE;
+ else
+ r2_type = p[1]->howto->type;
+ if ((r2_type == R_NIOS2_LO16)
+ && (p[0]->sym_ptr_ptr == p[1]->sym_ptr_ptr)
+ && (p[0]->addend == p[1]->addend))
+ {
+ unsigned char * r2_mem = sectionp + p[1]->address;
+ if (p[1]->address - q->address!=4)
+ printf("Err: HI/LO not adjacent %d\n", p[1]->address - q->address);
+ relocation_needed = 1;
+ pflags = (q->howto->type == R_NIOS2_HIADJ16)
+ ? FLAT_NIOS2_R_HIADJ_LO : FLAT_NIOS2_R_HI_LO;
+ pflags <<= 28;
+
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+
+ /* modify high 16 bits, in target order */
+ exist_val = niostohl(*(unsigned long *)r_mem);
+ exist_val = ((exist_val >> 22) << 22) | (exist_val & 0x3f);
+ if (q->howto->type == R_NIOS2_HIADJ16)
+ exist_val |= ((((sym_addr >> 16) + ((sym_addr >> 15) & 1)) & 0xFFFF) << 6);
+ else
+ exist_val |= (((sym_addr >> 16) & 0xFFFF) << 6);
+ *(unsigned long *)r_mem = htoniosl(exist_val);
+
+ /* modify low 16 bits, in target order */
+ exist_val = niostohl(*(unsigned long *)r2_mem);
+ exist_val = ((exist_val >> 22) << 22) | (exist_val & 0x3f);
+ exist_val |= ((sym_addr & 0xFFFF) << 6);
+ *(unsigned long *)r2_mem = htoniosl(exist_val);
+
+ } else
+ goto NIOS2_RELOC_ERR;
+ }
+ break;
+
+ case R_NIOS2_GPREL:
+ {
+ unsigned long exist_val, temp;
+ //long gp = get_symbol_offset("_gp", sym_section, symbols, number_of_symbols);
+ long gp = get_gp_value(symbols, number_of_symbols);
+ if (gp == -1) {
+ printf("Err: unresolved symbol _gp when relocating %s\n", sym_name);
+ goto NIOS2_RELOC_ERR;
+ }
+ /* _gp holds a absolute value, otherwise the ld cannot generate correct code */
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ //printf("sym=%x, %d, _gp=%x, %d\n", sym_addr+sym_vma, sym_addr+sym_vma, gp, gp);
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= gp;
+ //printf("sym - _gp=%x, %d\n", sym_addr, sym_addr);
+ /* modify the target, in target order (little_endian) */
+ exist_val = niostohl(*(unsigned long *)r_mem);
+ temp = ((exist_val >> 6) & 0x3ff0000) | (sym_addr & 0xffff);
+ temp <<= 6;
+ temp |= (exist_val & 0x3f);
+ *(unsigned long *)r_mem = htoniosl(temp);
+ if (verbose)
+ printf("omit: offset=0x%x symbol=%s%s "
+ "section=%s size=%d "
+ "fixup=0x%x (reloc=0x%x) GPREL\n",
+ q->address, sym_name, addstr,
+ section_name, sym_reloc_size,
+ sym_addr, section_vma + q->address);
+ continue;
+ }
+ case R_NIOS2_PCREL16:
+ {
+ unsigned long exist_val;
+ sym_vma = 0;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= (q->address + 4);
+ /* modify the target, in target order (little_endian) */
+ exist_val = niostohl(*(unsigned long *)r_mem);
+ exist_val = ((exist_val >> 22) << 22) | (exist_val & 0x3f);
+ exist_val |= ((sym_addr & 0xFFFF) << 6);
+ *(unsigned long *)r_mem = htoniosl(exist_val);
+ if (verbose)
+ printf("omit: offset=0x%x symbol=%s%s "
+ "section=%s size=%d "
+ "fixup=0x%x (reloc=0x%x) PCREL\n",
+ q->address, sym_name, addstr,
+ section_name, sym_reloc_size,
+ sym_addr, section_vma + q->address);
+ continue;
+ }
+
+ case R_NIOS2_LO16:
+ /* check if this is actually the 2nd half of a pair */
+ if ((p > relpp)
+ && ((p[-1]->howto->type == R_NIOS2_HIADJ16)
+ || (p[-1]->howto->type == R_NIOS2_HI16))
+ && (p[-1]->sym_ptr_ptr == p[0]->sym_ptr_ptr)
+ && (p[-1]->addend == p[0]->addend)) {
+ if (verbose)
+ printf("omit: offset=0x%x symbol=%s%s "
+ "section=%s size=%d LO16\n",
+ q->address, sym_name, addstr,
+ section_name, sym_reloc_size);
+ continue;
+ }
+
+ /* error, fall through */
+
+ case R_NIOS2_S16:
+ case R_NIOS2_U16:
+ case R_NIOS2_CACHE_OPX:
+ case R_NIOS2_IMM5:
+ case R_NIOS2_IMM6:
+ case R_NIOS2_IMM8:
+ case R_NIOS2_BFD_RELOC_16:
+ case R_NIOS2_BFD_RELOC_8:
+ case R_NIOS2_GNU_VTINHERIT:
+ case R_NIOS2_GNU_VTENTRY:
+ case R_NIOS2_UJMP:
+ case R_NIOS2_CJMP:
+ case R_NIOS2_CALLR:
+NIOS2_RELOC_ERR:
+ printf("Err: unexpected reloc type %s(%d)\n", q->howto->name, q->howto->type);
+ bad_relocs++;
+ continue;
+#endif /* TARGET_nios2 */
+
+#ifdef TARGET_sparc
+ case R_SPARC_32:
+ case R_SPARC_UA32:
+ relocation_needed = 1;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_SPARC_PC22:
+ sym_vma = 0;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= q->address;
+ break;
+ case R_SPARC_WDISP30:
+ sym_addr = (((*(q->sym_ptr_ptr))->value-
+ q->address) >> 2) & 0x3fffffff;
+ sym_addr |= (
+ ntohl(*(unsigned long *)r_mem)
+ & 0xc0000000
+ );
+ break;
+ case R_SPARC_HI22:
+ relocation_needed = 1;
+ pflags = 0x80000000;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ sym_addr |= (
+ htonl(*(unsigned long *)r_mem)
+ & 0xffc00000
+ );
+ break;
+ case R_SPARC_LO10:
+ relocation_needed = 1;
+ pflags = 0x40000000;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ sym_addr &= 0x000003ff;
+ sym_addr |= (
+ htonl(*(unsigned long *)r_mem)
+ & 0xfffffc00
+ );
+ break;
+#endif /* TARGET_sparc */
+
+#ifdef TARGET_bfin
+ case R_pcrel12_jump:
+ case R_pcrel12_jump_s:
+ case R_pcrel24:
+ case R_pcrel24_jump_l:
+ case R_pcrel24_jump_x:
+ case R_pcrel24_call_x:
+ case R_pcrel10:
+ case R_pcrel11:
+ case R_pcrel5m2:
+ sym_addr += q->addend;// get the symbol addr
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr -= q->address; // make it PC relative
+ // implicitly assumes code section and symbol section are same
+ break;
+ case R_got:
+ /* Ignore these. */
+ break;
+
+ case R_rimm16:
+ sym_addr += q->addend;
+ if(weak_und_symbol(sym_section->name, (*(q->sym_ptr_ptr))))
+ continue;
+ if(0xFFFF0000 & sym_addr){
+ fprintf (stderr, "Relocation overflow for rN = %s\n",sym_name);
+ bad_relocs++;
+ }
+ flat_relocs = (uint32_t *)
+ (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t)));
+ if (bfin_set_reloc (flat_relocs + flat_reloc_count,
+ sym_section->name, sym_name,
+ (*(q->sym_ptr_ptr)),
+ 0, FLAT_RELOC_PART_LO,
+ section_vma + q->address))
+ bad_relocs++;
+ flat_reloc_count++;
+ break;
+
+ case R_luimm16:
+ case R_huimm16:
+ {
+ unsigned int sp;
+ unsigned int reloc_count_incr;
+ unsigned int hi_lo;
+
+ if (q->howto->type == R_luimm16)
+ hi_lo = FLAT_RELOC_PART_LO;
+ else
+ hi_lo = FLAT_RELOC_PART_HI;
+
+ sym_addr += q->addend;
+
+ flat_relocs = (uint32_t *)
+ (realloc (flat_relocs, (flat_reloc_count + 2) * sizeof (uint32_t)));
+ reloc_count_incr = 1;
+ if (weak_und_symbol (sym_section->name, (*(q->sym_ptr_ptr))))
+ continue;
+ if (0xFFFF0000 & sym_addr) {
+ /* value is > 16 bits - use an extra field */
+ /* see if we have already output that symbol */
+ /* reloc may be addend from symbol and */
+ /* we can only store 16 bit offsets */
+ sp = 1;
+ if ((*(q->sym_ptr_ptr))->udata.i == 0
+ || flat_relocs[(*(q->sym_ptr_ptr))->udata.i] != sym_addr
+ || ((*(q->sym_ptr_ptr))->udata.i & 0xFFFF0000))
+ {
+ reloc_count_incr = 2;
+ flat_relocs[flat_reloc_count + 1] = sym_addr;
+ (*(q->sym_ptr_ptr))->udata.i = flat_reloc_count + 1;
+ sym_addr = 0; // indication to loader to read next
+ } else{
+ sym_addr = (*(q->sym_ptr_ptr))->udata.i;
+ }
+ } else {
+ sp = 0;
+ }
+
+ if (bfin_set_reloc (flat_relocs + flat_reloc_count,
+ sym_section->name, sym_name,
+ (*(q->sym_ptr_ptr)),
+ sp, hi_lo,
+ section_vma + q->address))
+ bad_relocs++;
+ flat_reloc_count += reloc_count_incr;
+ break;
+ }
+ case R_byte4_data:
+ sym_addr += q->addend;
+
+ if (weak_und_symbol (sym_section->name, *q->sym_ptr_ptr))
+ continue;
+
+ flat_relocs = (uint32_t *)
+ (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t)));
+ if (bfin_set_reloc (flat_relocs + flat_reloc_count,
+ sym_section->name, sym_name,
+ (*(q->sym_ptr_ptr)),
+ 2, FLAT_RELOC_PART_LO,
+ section_vma + q->address))
+ bad_relocs++;
+
+ flat_reloc_count++;
+ break;
+
+#endif //TARGET_bfin
+
+#ifdef TARGET_sh
+ case R_SH_DIR32:
+ relocation_needed = 1;
+ sym_vma = bfd_section_vma(abs_bfd, sym_section);
+ sym_addr += sym_vma + q->addend;
+ break;
+ case R_SH_REL32:
+ sym_vma = 0;
+ sym_addr += sym_vma + q->addend;
+ sym_addr -= q->address;
+ break;
+#endif /* TARGET_sh */
+
+#ifdef TARGET_e1
+#define htoe1l(x) htonl(x)
+
+#if 0
+#define DEBUG_E1
+#endif
+
+#ifdef DEBUG_E1
+#define DBG_E1 printf
+#else
+#define DBG_E1(x, ... )
+#endif
+
+#define _32BITS_RELOC 0x00000000
+#define _30BITS_RELOC 0x80000000
+#define _28BITS_RELOC 0x40000000
+ {
+ char *p;
+ unsigned long sec_vma, exist_val, S;
+ case R_E1_CONST31:
+ relocation_needed = 1;
+ DBG_E1("Handling Reloc <CONST31>\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x], q->address : [0x%x]\n",
+ sec_vma, sym_addr, q->address);
+ sym_addr = sec_vma + sym_addr;
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Orig:exist_val : [0x%08x]\n", exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n", exist_val);
+ sym_addr += exist_val;
+ pflags = _30BITS_RELOC;
+ break;
+ case R_E1_CONST31_PCREL:
+ relocation_needed = 0;
+ DBG_E1("Handling Reloc <CONST31_PCREL>\n");
+ DBG_E1("DONT RELOCATE AT LOADING\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x], q->address : [0x%x]\n",
+ sec_vma, sym_addr, q->address);
+ sym_addr = sec_vma + sym_addr;
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%x]\n", sym_addr );
+
+ DBG_E1("q->address : 0x%x, section_vma : 0x%x\n", q->address,
+ section_vma );
+ q->address = q->address + section_vma;
+ DBG_E1("q->address += section_vma : 0x%x\n", q->address );
+
+ if( (sym_addr = (sym_addr - q->address - 6)) < 0 )
+ DBG_E1("NEGATIVE OFFSET in PC Relative instruction\n");
+ DBG_E1( "sym_addr := sym_addr - q->address - "
+ "sizeof(CONST31_PCREL): [0x%x]\n",
+ sym_addr );
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Orig:exist_val : [0x%08x]\n", exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n", exist_val);
+ sym_addr |= exist_val;
+ DBG_E1("sym_addr |= exist_val) : [0x%x]\n", sym_addr );
+ break;
+ case R_E1_DIS29W_PCREL:
+ relocation_needed = 0;
+ DBG_E1("Handling Reloc <DIS29W_PCREL>\n");
+ DBG_E1("DONT RELOCATE AT LOADING\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x], q->address : [0x%x]\n",
+ sec_vma, sym_addr, q->address);
+ sym_addr = sec_vma + sym_addr;
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%x]\n", sym_addr );
+
+ DBG_E1("q->address : 0x%x, section_vma : 0x%x\n", q->address,
+ section_vma );
+ q->address = q->address + section_vma;
+ DBG_E1("q->address += section_vma : 0x%x\n", q->address );
+
+ if( (sym_addr = (sym_addr - q->address - 6)) < 0 )
+ DBG_E1("NEGATIVE OFFSET in PC Relative instruction\n");
+ DBG_E1( "sym_addr := sym_addr - q->address - "
+ "sizeof(CONST31_PCREL): [0x%x]\n",
+ sym_addr );
+ DBG_E1("sectionp:[0x%x], q->address:[0x%x]\n", sectionp, q->address );
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Original:exist_val : [0x%08x]\n",exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n",exist_val);
+ sym_addr += exist_val;
+ break;
+ case R_E1_DIS29W:
+ DBG_E1("Handling Reloc <DIS29W>\n");
+ goto DIS29_RELOCATION;
+ case R_E1_DIS29H:
+ DBG_E1("Handling Reloc <DIS29H>\n");
+ goto DIS29_RELOCATION;
+ case R_E1_DIS29B:
+ DBG_E1("Handling Reloc <DIS29B>\n");
+DIS29_RELOCATION:
+ relocation_needed = 1;
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%08x]\n",
+ sec_vma, sym_addr);
+ sym_addr = sec_vma + sym_addr;
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%08x]\n", sym_addr);
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Orig:exist_val : [0x%08x]\n", exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n", exist_val);
+ sym_addr += exist_val;
+ DBG_E1("sym_addr += exist_val : [0x%08x]\n", sym_addr);
+ pflags = _28BITS_RELOC;
+ break;
+ case R_E1_IMM32_PCREL:
+ relocation_needed = 0;
+ DBG_E1("Handling Reloc <IMM32_PCREL>\n");
+ DBG_E1("DONT RELOCATE AT LOADING\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x]\n",
+ sec_vma, sym_addr);
+ sym_addr = sec_vma + sym_addr;
+
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%x]\n", sym_addr );
+ DBG_E1("q->address : 0x%x, section_vma : 0x%x\n", q->address,
+ section_vma );
+ q->address = q->address + section_vma;
+ DBG_E1("q->address += section_vma : 0x%x\n", q->address );
+
+ if( (sym_addr = (sym_addr - q->address - 6 )) < 0 )
+ DBG_E1("NEGATIVE OFFSET in PC Relative instruction\n");
+ DBG_E1( "sym_addr := sym_addr - q->address - "
+ "sizeof(CONST31_PCREL): [0x%x]\n",
+ sym_addr );
+ DBG_E1("sectionp:[0x%x], q->address:[0x%x]\n", sectionp, q->address );
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Original:exist_val : [0x%08x]\n",exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n",exist_val);
+ sym_addr += exist_val;
+ break;
+ case R_E1_IMM32:
+ relocation_needed = 1;
+ DBG_E1("Handling Reloc <IMM32>\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x]\n",
+ sec_vma, sym_addr);
+ sym_addr = sec_vma + sym_addr;
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%x]\n", sym_addr );
+ DBG_E1("sectionp:[0x%x], q->address:[0x%x]\n", sectionp, q->address );
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address + 2);
+ DBG_E1("Original:exist_val : [0x%08x]\n",exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n",exist_val);
+ sym_addr += exist_val;
+ pflags = _32BITS_RELOC;
+ break;
+ case R_E1_WORD:
+ relocation_needed = 1;
+ DBG_E1("Handling Reloc <WORD>\n");
+ sec_vma = bfd_section_vma(abs_bfd, sym_section);
+ DBG_E1("sec_vma : [0x%x], sym_addr : [0x%x]\n",
+ sec_vma, sym_addr);
+ sym_addr = sec_vma + sym_addr;
+ DBG_E1("sym_addr = sec_vma + sym_addr : [0x%x]\n", sym_addr );
+ exist_val = *(unsigned long*)((unsigned long)sectionp + q->address );
+ DBG_E1("Orig:exist_val : [0x%08x]\n", exist_val);
+ exist_val = htoe1l(exist_val);
+ DBG_E1("HtoBE:exist_val : [0x%08x]\n", exist_val);
+ sym_addr += exist_val;
+ DBG_E1("sym_addr += exist_val : [0x%08x]\n", sym_addr);
+ pflags = _32BITS_RELOC;
+ break;
+ }
+#undef _32BITS_RELOC
+#undef _30BITS_RELOC
+#undef _28BITS_RELOC
+#endif
+ default:
+ /* missing support for other types of relocs */
+ printf("ERROR: bad reloc type %d\n", (*p)->howto->type);
+ bad_relocs++;
+ continue;
+ }
+ }
+
+ sprintf(&addstr[0], "+0x%x", sym_addr - (*(q->sym_ptr_ptr))->value -
+ bfd_section_vma(abs_bfd, sym_section));
+
+
+ /*
+ * for full elf relocation we have to write back the
+ * start_code relative value to use.
+ */
+ if (!pic_with_got) {
+#if defined(TARGET_arm)
+ union {
+ unsigned char c[4];
+ unsigned long l;
+ } tmp;
+ long hl;
+ int i0, i1, i2, i3;
+
+ /*
+ * horrible nasty hack to support different endianess
+ */
+ if (!bfd_big_endian(abs_bfd)) {
+ i0 = 0;
+ i1 = 1;
+ i2 = 2;
+ i3 = 3;
+ } else {
+ i0 = 3;
+ i1 = 2;
+ i2 = 1;
+ i3 = 0;
+ }
+
+ tmp.l = *(unsigned long *)r_mem;
+ hl = tmp.c[i0] | (tmp.c[i1] << 8) | (tmp.c[i2] << 16);
+ if (use_resolved ||
+ (((*p)->howto->type != R_ARM_PC24) &&
+ ((*p)->howto->type != R_ARM_PLT32)))
+ hl |= (tmp.c[i3] << 24);
+ else if (tmp.c[i2] & 0x80)
+ hl |= 0xff000000; /* sign extend */
+ if (!use_resolved)
+ hl += sym_addr;
+ tmp.c[i0] = hl & 0xff;
+ tmp.c[i1] = (hl >> 8) & 0xff;
+ tmp.c[i2] = (hl >> 16) & 0xff;
+ if (use_resolved ||
+ (((*p)->howto->type != R_ARM_PC24) &&
+ ((*p)->howto->type != R_ARM_PLT32)))
+ tmp.c[i3] = (hl >> 24) & 0xff;
+ if ((*p)->howto->type == R_ARM_ABS32)
+ *(unsigned long *)r_mem = htonl(hl);
+ else
+ *(unsigned long *)r_mem = tmp.l;
+
+#elif defined(TARGET_bfin)
+ if ((*p)->howto->type == R_pcrel24
+ || (*p)->howto->type == R_pcrel24_jump_l
+ || (*p)->howto->type == R_pcrel24_jump_x
+ || (*p)->howto->type == R_pcrel24_call_x)
+ {
+ sym_addr += 2*-1*PCREL24_MAGIC_OFFSET;
+ *((unsigned short *)(sectionp + q->address) + 1 + PCREL24_MAGIC_OFFSET)
+ = (sym_addr >> 1) & 0xffff;
+ *((unsigned short *)(sectionp + q->address) + PCREL24_MAGIC_OFFSET)
+ = (0xff00 & *((unsigned short *) (sectionp + q->address) + PCREL24_MAGIC_OFFSET)
+ | ((sym_addr >> 17) & 0xff));
+ } else if ((*p)->howto->type == R_byte4_data) {
+ *((uint32_t *)(sectionp + q->address)) = sym_addr;
+ } else if ((*p)->howto->type == R_pcrel12_jump
+ || (*p)->howto->type == R_pcrel12_jump_s) {
+ *((unsigned short *)(sectionp + q->address))
+ = (0xf000 & *((unsigned short *)(sectionp + q->address))
+ | ((sym_addr >> 1) & 0xfff));
+ } else if ((*p)->howto->type == R_pcrel10) {
+ *((unsigned short *)(sectionp + q->address))
+ = (~0x3ff & *((unsigned short *)(sectionp + q->address))
+ | ((sym_addr >> 1) & 0x3ff));
+ } else if ((*p)->howto->type == R_rimm16
+ || (*p)->howto->type == R_huimm16
+ || (*p)->howto->type == R_luimm16) {
+ /* for l and h we set the lower 16 bits which is only when it will be used */
+ *((unsigned short *) (sectionp + q->address)) = (unsigned short) sym_addr;
+ } else if ((*p)->howto->type == R_pcrel5m2) {
+ *((unsigned short *)(sectionp + q->address))
+ = (0xfff0 & *((unsigned short *)(sectionp + q->address))
+ | ((sym_addr >> 1) & 0xf));
+ } else if ((*p)->howto->type == R_pcrel11){
+ *((unsigned short *)(sectionp + q->address))
+ = (0xfc00 & *((unsigned short *)(sectionp + q->address))
+ | ((sym_addr >> 1) & 0x3ff));
+ } else if (0xE0 <= (*p)->howto->type && 0xF3 >= (*p)->howto->type) {
+ //arith relocs dont generate a real relocation
+ } else {
+ printf("Blackfin relocation fail for reloc type: 0x%x\n", (*p)->howto->type);
+ }
+#elif defined(TARGET_e1)
+#define OPCODE_SIZE 2 /* Add 2 bytes, counting the opcode size*/
+ switch ((*p)->howto->type) {
+ case R_E1_CONST31:
+ case R_E1_CONST31_PCREL:
+ case R_E1_DIS29W_PCREL:
+ case R_E1_DIS29W:
+ case R_E1_DIS29H:
+ case R_E1_DIS29B:
+ case R_E1_IMM32_PCREL:
+ case R_E1_IMM32:
+ DBG_E1("In addr + 2:[0x%x] <- write [0x%x]\n",
+ (sectionp + q->address + 2), sym_addr );
+ *((unsigned long *) (sectionp + q->address + OPCODE_SIZE)) =
+ htonl(sym_addr);
+ break;
+ case R_E1_WORD:
+ DBG_E1("In addr : [0x%x] <- write [0x%x]\n",
+ (sectionp + q->address), sym_addr );
+ *((unsigned long *) (sectionp + q->address )) = htonl(sym_addr);
+ break;
+ default:
+ printf("ERROR:Unhandled Relocation. Exiting...\n");
+ exit(0);
+ break;
+ }
+#else /* ! TARGET_arm && ! TARGET_e1 */
+
+ switch (q->howto->type) {
+#ifdef TARGET_v850
+ case R_V850_HI16_S:
+ case R_V850_HI16:
+ case R_V850_LO16:
+ /* Do nothing -- for cases we handle,
+ the bits produced by the linker are
+ what we want in the final flat file
+ (and other cases are errors). Note
+ that unlike most relocated values,
+ it is stored in little-endian order,
+ but this is necessary to avoid
+ trashing the low-bit, and the float
+ loaders knows about it. */
+ break;
+#endif /* TARGET_V850 */
+
+#ifdef TARGET_nios2
+ case R_NIOS2_BFD_RELOC_32:
+ case R_NIOS2_CALL26:
+ case R_NIOS2_HIADJ16:
+ case R_NIOS2_HI16:
+ /* do nothing */
+ break;
+#endif /* TARGET_nios2 */
+
+#if defined(TARGET_m68k)
+ case R_68K_PC16:
+ if (sym_addr < -0x8000 || sym_addr > 0x7fff) {
+ fprintf (stderr, "Relocation overflow for R_68K_PC16 relocation against %s\n", sym_name);
+ bad_relocs++;
+ } else {
+ r_mem[0] = (sym_addr >> 8) & 0xff;
+ r_mem[1] = sym_addr & 0xff;
+ }
+ break;
+#endif
+
+ default:
+ /* The alignment of the build host
+ might be stricter than that of the
+ target, so be careful. We store in
+ network byte order. */
+ r_mem[0] = (sym_addr >> 24) & 0xff;
+ r_mem[1] = (sym_addr >> 16) & 0xff;
+ r_mem[2] = (sym_addr >> 8) & 0xff;
+ r_mem[3] = sym_addr & 0xff;
+ }
+#endif /* !TARGET_arm */
+ }
+
+#ifdef TARGET_bfin
+ else {
+ if ((*p)->howto->type == R_rimm16
+ || (*p)->howto->type == R_huimm16
+ || (*p)->howto->type == R_luimm16)
+ {
+ /* for l and h we set the lower 16 bits which is only when it will be used */
+ *((unsigned short *) (sectionp + q->address)) = (unsigned short) sym_addr;
+ } else if ((*p)->howto->type == R_byte4_data) {
+ *((uint32_t *)(sectionp + q->address)) = sym_addr;
+ }
+ }
+#endif
+ if (verbose)
+ printf(" RELOC[%d]: offset=0x%x symbol=%s%s "
+ "section=%s size=%d "
+ "fixup=0x%x (reloc=0x%x)\n", flat_reloc_count,
+ q->address, sym_name, addstr,
+ section_name, sym_reloc_size,
+ sym_addr, section_vma + q->address);
+
+ /*
+ * Create relocation entry (PC relative doesn't need this).
+ */
+ if (relocation_needed) {
+#ifndef TARGET_bfin
+ flat_relocs = realloc(flat_relocs,
+ (flat_reloc_count + 1) * sizeof(uint32_t));
+#ifndef TARGET_e1
+ flat_relocs[flat_reloc_count] = pflags |
+ (section_vma + q->address);
+
+ if (verbose)
+ printf("reloc[%d] = 0x%x\n", flat_reloc_count,
+ section_vma + q->address);
+#else
+ switch ((*p)->howto->type) {
+ case R_E1_CONST31:
+ case R_E1_CONST31_PCREL:
+ case R_E1_DIS29W_PCREL:
+ case R_E1_DIS29W:
+ case R_E1_DIS29H:
+ case R_E1_DIS29B:
+ case R_E1_IMM32_PCREL:
+ case R_E1_IMM32:
+ flat_relocs[flat_reloc_count] = pflags |
+ (section_vma + q->address + OPCODE_SIZE);
+ if (verbose)
+ printf("RELOCATION TABLE : reloc[%d] = [0x%x]\n", flat_reloc_count,
+ flat_relocs[flat_reloc_count] );
+ break;
+ case R_E1_WORD:
+ flat_relocs[flat_reloc_count] = pflags |
+ (section_vma + q->address);
+ if (verbose)
+ printf("RELOCATION TABLE : reloc[%d] = [0x%x]\n", flat_reloc_count,
+ flat_relocs[flat_reloc_count] );
+ break;
+ }
+#endif
+ flat_reloc_count++;
+#endif
+ relocation_needed = 0;
+ pflags = 0;
+ }
+
+#if 0
+printf("%s(%d): symbol name=%s address=0x%x section=%s -> RELOC=0x%x\n",
+ __FILE__, __LINE__, sym_name, q->address, section_name,
+ flat_relocs[flat_reloc_count]);
+#endif
+ }
+ }
+ }
+
+ if (bad_relocs) {
+ printf("%d bad relocs\n", bad_relocs);
+ exit(1);
+ }
+
+ if (rc < 0)
+ return(0);
+
+ *n_relocs = flat_reloc_count;
+ return flat_relocs;
+}
+
+
+
+static char * program;
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: %s [vrzd] [-p <abs-pic-file>] [-s stack-size] "
+ "[-o <output-file>] <elf-file>\n\n"
+ " -v : verbose operation\n"
+ " -r : force load to RAM\n"
+ " -k : enable kernel trace on load (for debug)\n"
+ " -z : compress code/data/relocs\n"
+ " -d : compress data/relocs\n"
+ " -a : use existing symbol references\n"
+ " instead of recalculating from\n"
+ " relocation info\n"
+ " -R reloc-file : read relocations from a separate file\n"
+ " -p abs-pic-file : GOT/PIC processing with files\n"
+ " -s stacksize : set application stack size\n"
+ " -o output-file : output file name\n\n",
+ program);
+ fprintf(stderr, "Compiled for " ARCH " architecture\n\n");
+ exit(2);
+}
+
+
+/* Write NUM zeroes to STREAM. */
+static void write_zeroes (unsigned long num, FILE *stream)
+{
+ char zeroes[1024];
+ if (num > 0) {
+ /* It'd be nice if we could just use fseek, but that doesn't seem to
+ work for stdio output files. */
+ memset(zeroes, 0x00, 1024);
+ while (num > sizeof(zeroes)) {
+ fwrite(zeroes, sizeof(zeroes), 1, stream);
+ num -= sizeof(zeroes);
+ }
+ if (num > 0)
+ fwrite(zeroes, num, 1, stream);
+ }
+}
+
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ bfd *rel_bfd, *abs_bfd;
+ asection *s;
+ char *ofile=NULL, *pfile=NULL, *abs_file = NULL, *rel_file = NULL;
+ char *fname = NULL;
+ int opt;
+ int i;
+ int stack;
+ char cmd[1024];
+ FILE *gf = NULL;
+
+ asymbol **symbol_table;
+ long number_of_symbols;
+
+ unsigned long data_len = 0;
+ unsigned long bss_len = 0;
+ unsigned long text_len = 0;
+ unsigned long reloc_len;
+
+ unsigned long data_vma = ~0;
+ unsigned long bss_vma = ~0;
+ unsigned long text_vma = ~0;
+
+ unsigned long text_offs;
+
+ void *text;
+ void *data;
+ uint32_t *reloc;
+
+ struct flat_hdr hdr;
+
+ int gf_is_pipe = 0;
+
+ program = argv[0];
+ progname = argv[0];
+
+ if (argc < 2)
+ usage();
+
+ if (sizeof(hdr) != 64) {
+ fprintf(stderr,
+ "Potential flat header incompatibility detected\n"
+ "header size should be 64 but is %d\n",
+ sizeof(hdr));
+ exit(64);
+ }
+
+#ifndef TARGET_e1
+ stack = 4096;
+#else /* We need plenty of stack for both of them (Aggregate and Register) */
+ stack = 0x2020;
+#endif
+
+ while ((opt = getopt(argc, argv, "avzdrkp:s:o:R:")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose++;
+ break;
+ case 'r':
+ load_to_ram++;
+ break;
+ case 'k':
+ ktrace++;
+ break;
+ case 'z':
+ compress = 1;
+ break;
+ case 'd':
+ compress = 2;
+ break;
+ case 'p':
+ pfile = optarg;
+ break;
+ case 'o':
+ ofile = optarg;
+ break;
+ case 'a':
+ use_resolved = 1;
+ break;
+ case 's':
+ stack = atoi(optarg);
+ break;
+ case 'R':
+ rel_file = optarg;
+ break;
+ default:
+ fprintf(stderr, "%s Unknown option\n", argv[0]);
+ usage();
+ break;
+ }
+ }
+
+ /*
+ * if neither the -r or -p options was given, default to
+ * a RAM load as that is the only option that makes sense.
+ */
+ if (!load_to_ram && !pfile)
+ load_to_ram = 1;
+
+ filename = fname = argv[argc-1];
+
+ if (pfile) {
+ pic_with_got = 1;
+ abs_file = pfile;
+ } else
+ abs_file = fname;
+
+ if (! rel_file)
+ rel_file = fname;
+
+ if (!(rel_bfd = bfd_openr(rel_file, 0))) {
+ fprintf(stderr, "Can't open %s\n", rel_file);
+ exit(1);
+ }
+
+ if (bfd_check_format (rel_bfd, bfd_object) == 0) {
+ fprintf(stderr, "File is not an object file\n");
+ exit(2);
+ }
+
+ if (abs_file == rel_file)
+ abs_bfd = rel_bfd; /* one file does all */
+ else {
+ if (!(abs_bfd = bfd_openr(abs_file, 0))) {
+ fprintf(stderr, "Can't open %s\n", abs_file);
+ exit(1);
+ }
+
+ if (bfd_check_format (abs_bfd, bfd_object) == 0) {
+ fprintf(stderr, "File is not an object file\n");
+ exit(2);
+ }
+ }
+
+ if (! (bfd_get_file_flags(rel_bfd) & HAS_RELOC)) {
+ fprintf (stderr, "%s: Input file contains no relocation info\n", rel_file);
+ exit (2);
+ }
+
+ if (use_resolved && !(bfd_get_file_flags(abs_bfd) & EXEC_P)) {
+ /* `Absolute' file is not absolute, so neither are address
+ contained therein. */
+ fprintf (stderr,
+ "%s: `-a' option specified with non-fully-resolved input file\n",
+ bfd_get_filename (abs_bfd));
+ exit (2);
+ }
+
+ symbol_table = get_symbols(abs_bfd, &number_of_symbols);
+
+ /* Group output sections into text, data, and bss, and calc their sizes. */
+ for (s = abs_bfd->sections; s != NULL; s = s->next) {
+ unsigned long *vma, *len;
+ bfd_size_type sec_size;
+ bfd_vma sec_vma;
+
+ if (s->flags & SEC_CODE) {
+ vma = &text_vma;
+ len = &text_len;
+ } else if (s->flags & SEC_DATA) {
+ vma = &data_vma;
+ len = &data_len;
+ } else if (s->flags & SEC_ALLOC) {
+ vma = &bss_vma;
+ len = &bss_len;
+ } else
+ continue;
+
+ sec_size = bfd_section_size(abs_bfd, s);
+ sec_vma = bfd_section_vma(abs_bfd, s);
+
+ if (sec_vma < *vma) {
+ if (*len > 0)
+ *len += sec_vma - *vma;
+ else
+ *len = sec_size;
+ *vma = sec_vma;
+ } else if (sec_vma + sec_size > *vma + *len)
+ *len = sec_vma + sec_size - *vma;
+ }
+
+ if (text_len == 0) {
+ fprintf (stderr, "%s: no .text section", abs_file);
+ exit (2);
+ }
+
+ text = malloc(text_len);
+
+ if (verbose)
+ printf("TEXT -> vma=0x%x len=0x%x\n", text_vma, text_len);
+
+ /* Read in all text sections. */
+ for (s = abs_bfd->sections; s != NULL; s = s->next)
+ if (s->flags & SEC_CODE)
+ if (!bfd_get_section_contents(abs_bfd, s,
+ text + (s->vma - text_vma), 0,
+ bfd_section_size(abs_bfd, s)))
+ {
+ fprintf(stderr, "read error section %s\n", s->name);
+ exit(2);
+ }
+
+ if (data_len == 0) {
+ fprintf (stderr, "%s: no .data section", abs_file);
+ exit (2);
+ }
+ data = malloc(data_len);
+
+ if (verbose)
+ printf("DATA -> vma=0x%x len=0x%x\n", data_vma, data_len);
+
+ if ((text_vma + text_len) != data_vma) {
+ if ((text_vma + text_len) > data_vma) {
+ printf("ERROR: text=0x%x overlaps data=0x%x ?\n", text_len, data_vma);
+ exit(1);
+ }
+ if (verbose)
+ printf("WARNING: data=0x%x does not directly follow text=0x%x\n",
+ data_vma, text_len);
+ text_len = data_vma - text_vma;
+ }
+
+ /* Read in all data sections. */
+ for (s = abs_bfd->sections; s != NULL; s = s->next)
+ if (s->flags & SEC_DATA)
+ if (!bfd_get_section_contents(abs_bfd, s,
+ data + (s->vma - data_vma), 0,
+ bfd_section_size(abs_bfd, s)))
+ {
+ fprintf(stderr, "read error section %s\n", s->name);
+ exit(2);
+ }
+
+ /* Put common symbols in bss. */
+ bss_len += add_com_to_bss(symbol_table, number_of_symbols, bss_len);
+
+ if (verbose)
+ printf("BSS -> vma=0x%x len=0x%x\n", bss_vma, bss_len);
+
+ if ((data_vma + data_len) != bss_vma) {
+ if ((data_vma + data_len) > bss_vma) {
+ printf("ERROR: text=0x%x + data=0x%x overlaps bss=0x%x ?\n", text_len,
+ data_len, bss_vma);
+ exit(1);
+ }
+ if (verbose)
+ printf("WARNING: bss=0x%x does not directly follow text=0x%x + data=0x%x(0x%x)\n",
+ bss_vma, text_len, data_len, text_len + data_len);
+ data_len = bss_vma - data_vma;
+ }
+
+ reloc = output_relocs(abs_bfd, symbol_table, number_of_symbols, &reloc_len,
+ text, text_len, text_vma, data, data_len, data_vma,
+ rel_bfd);
+
+ if (reloc == NULL)
+ printf("No relocations in code!\n");
+
+ text_offs = real_address_bits(text_vma);
+
+ /* Fill in the binflt_flat header */
+ memcpy(hdr.magic,"bFLT",4);
+ hdr.rev = htonl(FLAT_VERSION);
+ hdr.entry = htonl(sizeof(hdr) + bfd_get_start_address(abs_bfd));
+ hdr.data_start = htonl(sizeof(hdr) + text_offs + text_len);
+ hdr.data_end = htonl(sizeof(hdr) + text_offs + text_len +data_len);
+ hdr.bss_end = htonl(sizeof(hdr) + text_offs + text_len +data_len+bss_len);
+ hdr.stack_size = htonl(stack); /* FIXME */
+ hdr.reloc_start = htonl(sizeof(hdr) + text_offs + text_len +data_len);
+ hdr.reloc_count = htonl(reloc_len);
+ hdr.flags = htonl(0
+ | (load_to_ram ? FLAT_FLAG_RAM : 0)
+ | (ktrace ? FLAT_FLAG_KTRACE : 0)
+ | (pic_with_got ? FLAT_FLAG_GOTPIC : 0)
+ | (compress ? (compress == 2 ? FLAT_FLAG_GZDATA : FLAT_FLAG_GZIP) : 0)
+ );
+ hdr.build_date = htonl((unsigned long)time(NULL));
+ memset(hdr.filler, 0x00, sizeof(hdr.filler));
+
+ for (i=0; i<reloc_len; i++) reloc[i] = htonl(reloc[i]);
+
+ if (verbose) {
+ printf("SIZE: .text=0x%04x, .data=0x%04x, .bss=0x%04x",
+ text_len, data_len, bss_len);
+ if (reloc)
+ printf(", relocs=0x%04x", reloc_len);
+ printf("\n");
+ }
+
+ if (!ofile) {
+ ofile = malloc(strlen(fname) + 5 + 1); /* 5 to add suffix */
+ strcpy(ofile, fname);
+ strcat(ofile, ".bflt");
+ }
+
+ if ((fd = open (ofile, O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, 0744)) < 0) {
+ fprintf (stderr, "Can't open output file %s\n", ofile);
+ exit(4);
+ }
+
+ write(fd, &hdr, sizeof(hdr));
+ close(fd);
+
+ /*
+ * get the compression command ready
+ */
+ sprintf(cmd, "gzip -f -9 >> %s", ofile);
+
+#define START_COMPRESSOR do { \
+ if (gf) \
+ if (gf_is_pipe) \
+ pclose(gf); \
+ else \
+ fclose(gf); \
+ if (!(gf = popen(cmd, "w" BINARY_FILE_OPTS))) { \
+ fprintf(stderr, "Can't run cmd %s\n", cmd); \
+ exit(4); \
+ } \
+ gf_is_pipe = 1; \
+ } while (0)
+
+ gf = fopen(ofile, "ab"); /* Add 'b' to support non-posix (ie windows) */
+ if (!gf) {
+ fprintf(stderr, "Can't open file %s for writing\n", ofile); \
+ exit(4);
+ }
+
+ if (compress == 1)
+ START_COMPRESSOR;
+
+ /* Fill in any hole at the beginning of the text segment. */
+ if (verbose)
+ printf("ZERO before text len=0x%x\n", text_offs);
+ write_zeroes(text_offs, gf);
+
+ /* Write the text segment. */
+ fwrite(text, text_len, 1, gf);
+
+ if (compress == 2)
+ START_COMPRESSOR;
+
+ /* Write the data segment. */
+ fwrite(data, data_len, 1, gf);
+
+ if (reloc)
+ fwrite(reloc, reloc_len * 4, 1, gf);
+
+ if(gf_is_pipe)
+ pclose(gf);
+ else
+ fclose(gf);
+
+ exit(0);
+}
+
+
+/*
+ * this __MUST__ be at the VERY end of the file - do NOT move!!
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * end:
+ * vi: tabstop=8 shiftwidth=4 textwidth=79 noexpandtab
+ */
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.ld b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.ld
new file mode 100644
index 0000000000..cd4e652c30
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/elf2flt.ld
@@ -0,0 +1,179 @@
+
+ENTRY (_start)
+
+MEMORY {
+ flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff
+}
+
+SECTIONS {
+
+ .text 0x0 : {
+ . = . + 4;
+ . = ALIGN(0x4) ;
+ _stext = . ;
+ *(.text)
+ *(.text.*)
+ *(.gnu.warning)
+ *(.stub)
+ *(.gnu.linkonce.t*)
+ *(.glue_7t)
+ *(.glue_7)
+ *(.jcr)
+ *(.init)
+ *(.fini)
+
+W_RODAT *(.rodata)
+W_RODAT *(.rodata1)
+W_RODAT *(.rodata.*)
+W_RODAT *(.gnu.linkonce.r*)
+
+ /* This is special code area at the end of the normal
+ text section. It contains a small lookup table at
+ the start followed by the code pointed to by entries
+ in the lookup table. */
+ . = ALIGN (4) ;
+ PROVIDE(__ctbp = .);
+ *(.call_table_data)
+ *(.call_table_text)
+
+ . = ALIGN(0x20) ;
+ _etext = . ;
+ } > flatmem
+
+ .data : {
+ . = ALIGN(0x4) ;
+ _sdata = . ;
+ __data_start = . ;
+ data_start = . ;
+ *(.got.plt)
+ *(.got)
+ FILL(0) ;
+ . = ALIGN(0x20) ;
+ LONG(-1)
+ . = ALIGN(0x20) ;
+R_RODAT *(.rodata)
+R_RODAT *(.rodata1)
+R_RODAT *(.rodata.*)
+R_RODAT *(.gnu.linkonce.r*)
+ *(.data)
+ *(.data1)
+ *(.data.*)
+ *(.gnu.linkonce.d*)
+ *(.data1)
+ *(.eh_frame)
+ *(.gcc_except_table)
+
+ /* Microblaze has .sdata and .sbss (small bss). They must
+ be contiguous, so please don't move any of this. JW */
+ _ssrw = . ;
+ *(.sdata)
+ *(.sdata.*)
+ *(.sbss) /* Don't move this! */
+ _essrw = . ;
+
+ _ssrw_size = _essrw - _ssrw;
+ PROVIDE(_SDA_BASE_ = _ssrw + (_ssrw_size / 2));
+
+ *(.gnu.linkonce.s.*)
+ *(__libc_atexit)
+ *(__libc_subinit)
+ *(__libc_subfreeres)
+ *(.note.ABI-tag)
+
+ /* microblaze-specific read-only small data area
+ and associated locating symbols */
+ _ssro = . ;
+ *(.sdata2)
+ _essro = . ;
+ _ssro_size = _essro - _ssro;
+ PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2));
+
+ . = ALIGN(4) ;
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
+SINGLE_LINK: /* gcc uses crtbegin.o to find the start of
+SINGLE_LINK: the constructors, so we make sure it is
+SINGLE_LINK: first. Because this is a wildcard, it
+SINGLE_LINK: doesn't matter if the user does not
+SINGLE_LINK: actually link against crtbegin.o; the
+SINGLE_LINK: linker won't look for a file to match a
+SINGLE_LINK: wildcard. The wildcard also means that it
+SINGLE_LINK: doesn't matter which directory crtbegin.o
+SINGLE_LINK: is in. */
+SINGLE_LINK: KEEP (*crtbegin*.o(.ctors))
+SINGLE_LINK: /* We don't want to include the .ctor section from
+SINGLE_LINK: from the crtend.o file until after the sorted ctors.
+SINGLE_LINK: The .ctor section from the crtend file contains the
+SINGLE_LINK: end of ctors marker and it must be last */
+SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+SINGLE_LINK: KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ LONG(0)
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
+SINGLE_LINK: KEEP (*crtbegin*.o(.dtors))
+SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+SINGLE_LINK: KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ LONG(0)
+ __DTOR_END__ = .;
+
+ PROVIDE (__preinit_array_start = .);
+ KEEP (*(.preinit_array))
+ PROVIDE (__preinit_array_end = .);
+
+ PROVIDE (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ PROVIDE (__init_array_end = .);
+
+ PROVIDE (__fini_array_start = .);
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ PROVIDE (__fini_array_end = .);
+
+ . = ALIGN(0x10) ;
+ _edata = . ;
+ } > flatmem
+
+ .bss : {
+ . = ALIGN(0x4) ;
+ _sbss = ALIGN(0x4) ;
+ __bss_start = . ;
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(.bss.*)
+ *(.bss*)
+ *(.gnu.linkonce.b*)
+ *(COMMON)
+ . = ALIGN(0x10) ;
+ _ebss = . ;
+ _end = . ;
+ end = . ;
+ } > flatmem
+
+ .stack : {
+ . = ALIGN(0x4);
+ __stack_start = .;
+ }
+
+ .junk 0 : { *(.rel*) *(.rela*) }
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flat.h b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flat.h
new file mode 100644
index 0000000000..3cc502d7c7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flat.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2002-2005 David McCullough <davidm@snapgear.com>
+ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
+ * The Silver Hammer Group, Ltd.
+ *
+ * This file provides the definitions and structures needed to
+ * support uClinux flat-format executables.
+ *
+ * This is Free Software, under the GNU Public Licence v2 or greater.
+ *
+ */
+
+#ifndef _LINUX_FLAT_H
+#define _LINUX_FLAT_H
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <asm/flat.h>
+#endif
+
+#define FLAT_VERSION 0x00000004L
+
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define MAX_SHARED_LIBS (4)
+#else
+#define MAX_SHARED_LIBS (1)
+#endif
+
+/*
+ * To make everything easier to port and manage cross platform
+ * development, all fields are in network byte order.
+ */
+
+struct flat_hdr {
+ char magic[4];
+ uint32_t rev; /* version (as above) */
+ uint32_t entry; /* Offset of first executable instruction
+ with text segment from beginning of file */
+ uint32_t data_start; /* Offset of data segment from beginning of
+ file */
+ uint32_t data_end; /* Offset of end of data segment from beginning
+ of file */
+ uint32_t bss_end; /* Offset of end of bss segment from beginning
+ of file */
+
+ /* (It is assumed that data_end through bss_end forms the bss segment.) */
+
+ uint32_t stack_size; /* Size of stack, in bytes */
+ uint32_t reloc_start; /* Offset of relocation records from beginning
+ of file */
+ uint32_t reloc_count; /* Number of relocation records */
+ uint32_t flags;
+ uint32_t build_date; /* When the program/library was built */
+ uint32_t filler[5]; /* Reservered, set to zero */
+};
+
+#define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */
+#define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
+#define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */
+#define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
+#define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
+
+#ifdef __KERNEL__ /* so systems without linux headers can compile the apps */
+/*
+ * While it would be nice to keep this header clean, users of older
+ * tools still need this support in the kernel. So this section is
+ * purely for compatibility with old tool chains.
+ *
+ * DO NOT make changes or enhancements to the old format please, just work
+ * with the format above, except to fix bugs with old format support.
+ */
+
+#include <asm/byteorder.h>
+
+#define OLD_FLAT_VERSION 0x00000002L
+#define OLD_FLAT_RELOC_TYPE_TEXT 0
+#define OLD_FLAT_RELOC_TYPE_DATA 1
+#define OLD_FLAT_RELOC_TYPE_BSS 2
+
+typedef union {
+ uint32_t value;
+ struct {
+# if defined(mc68000) && !defined(CONFIG_COLDFIRE)
+ int32_t offset : 30;
+ uint32_t type : 2;
+# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
+# elif defined(__BIG_ENDIAN_BITFIELD)
+ uint32_t type : 2;
+ int32_t offset : 30;
+# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
+# elif defined(__LITTLE_ENDIAN_BITFIELD)
+ int32_t offset : 30;
+ uint32_t type : 2;
+# define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
+# else
+# error "Unknown bitfield order for flat files."
+# endif
+ } reloc;
+} flat_v2_reloc_t;
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_FLAT_H */
+
+/* this __MUST__ be at the VERY end of the file - do NOT move!!
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * end:
+ * vi: tabstop=8 shiftwidth=4 textwidth=79 noexpandtab
+ */
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flthdr.c b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flthdr.c
new file mode 100644
index 0000000000..967d64063a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/flthdr.c
@@ -0,0 +1,382 @@
+/****************************************************************************/
+/*
+ * A simple program to manipulate flat files
+ *
+ * Copyright (C) 2001-2003 SnapGear Inc, davidm@snapgear.com
+ * Copyright (C) 2001 Lineo, davidm@lineo.com
+ *
+ * This is Free Software, under the GNU Public Licence v2 or greater.
+ *
+ */
+/****************************************************************************/
+
+#include <stdio.h> /* Userland pieces of the ANSI C standard I/O package */
+#include <unistd.h> /* Userland prototypes of the Unix std system calls */
+#include <time.h>
+#include <stdlib.h> /* exit() */
+#include <string.h> /* strcat(), strcpy() */
+
+/* macros for conversion between host and (internet) network byte order */
+#ifndef WIN32
+#include <netinet/in.h> /* Consts and structs defined by the internet system */
+#define BINARY_FILE_OPTS
+#else
+#include <winsock2.h>
+#define BINARY_FILE_OPTS "b"
+#endif
+
+/* from uClinux-x.x.x/include/linux */
+#include "flat.h" /* Binary flat header description */
+
+#if defined(__MINGW32__)
+#include <getopt.h>
+
+#define mkstemp(p) mktemp(p)
+
+#endif
+
+/****************************************************************************/
+
+char *program_name;
+
+static char cmd[1024];
+static int print = 0, compress = 0, ramload = 0, stacksize = 0, ktrace = 0;
+static int short_format = 0;
+
+/****************************************************************************/
+
+void
+transferr(FILE *ifp, FILE *ofp, int count)
+{
+ int n, num;
+
+ while (count == -1 || count > 0) {
+ if (count == -1 || count > sizeof(cmd))
+ num = sizeof(cmd);
+ else
+ num = count;
+ n = fread(cmd, 1, num, ifp);
+ if (n == 0)
+ break;
+ if (fwrite(cmd, n, 1, ofp) != 1) {
+ fprintf(stderr, "Write failed :-(\n");
+ exit(1);
+ }
+ if (count != -1)
+ count -= n;
+ }
+ if (count > 0) {
+ fprintf(stderr, "Failed to transferr %d bytes\n", count);
+ exit(1);
+ }
+}
+
+/****************************************************************************/
+
+void
+process_file(char *ifile, char *ofile)
+{
+ int old_flags, old_stack, new_flags, new_stack;
+ FILE *ifp, *ofp;
+ int ofp_is_pipe = 0;
+ struct flat_hdr old_hdr, new_hdr;
+ char tfile[256];
+ char tfile2[256];
+
+ *tfile = *tfile2 = '\0';
+
+ if ((ifp = fopen(ifile, "r" BINARY_FILE_OPTS)) == NULL) {
+ fprintf(stderr, "Cannot open %s\n", ifile);
+ return;
+ }
+
+ if (fread(&old_hdr, sizeof(old_hdr), 1, ifp) != 1) {
+ fprintf(stderr, "Cannot read header of %s\n", ifile);
+ return;
+ }
+
+ if (strncmp(old_hdr.magic, "bFLT", 4) != 0) {
+ fprintf(stderr, "Cannot read header of %s\n", ifile);
+ return;
+ }
+
+ new_flags = old_flags = ntohl(old_hdr.flags);
+ new_stack = old_stack = ntohl(old_hdr.stack_size);
+ new_hdr = old_hdr;
+
+ if (compress == 1) {
+ new_flags |= FLAT_FLAG_GZIP;
+ new_flags &= ~FLAT_FLAG_GZDATA;
+ } else if (compress == 2) {
+ new_flags |= FLAT_FLAG_GZDATA;
+ new_flags &= ~FLAT_FLAG_GZIP;
+ } else if (compress < 0)
+ new_flags &= ~(FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA);
+
+ if (ramload > 0)
+ new_flags |= FLAT_FLAG_RAM;
+ else if (ramload < 0)
+ new_flags &= ~FLAT_FLAG_RAM;
+
+ if (ktrace > 0)
+ new_flags |= FLAT_FLAG_KTRACE;
+ else if (ktrace < 0)
+ new_flags &= ~FLAT_FLAG_KTRACE;
+
+ if (stacksize)
+ new_stack = stacksize;
+
+ if (print == 1) {
+ time_t t;
+
+ printf("%s\n", ifile);
+ printf(" Magic: %4.4s\n", old_hdr.magic);
+ printf(" Rev: %d\n", ntohl(old_hdr.rev));
+ t = (time_t) htonl(old_hdr.build_date);
+ printf(" Build Date: %s", t?ctime(&t):"not specified\n");
+ printf(" Entry: 0x%x\n", ntohl(old_hdr.entry));
+ printf(" Data Start: 0x%x\n", ntohl(old_hdr.data_start));
+ printf(" Data End: 0x%x\n", ntohl(old_hdr.data_end));
+ printf(" BSS End: 0x%x\n", ntohl(old_hdr.bss_end));
+ printf(" Stack Size: 0x%x\n", ntohl(old_hdr.stack_size));
+ printf(" Reloc Start: 0x%x\n", ntohl(old_hdr.reloc_start));
+ printf(" Reloc Count: 0x%x\n", ntohl(old_hdr.reloc_count));
+ printf(" Flags: 0x%x ( ", ntohl(old_hdr.flags));
+ if (old_flags) {
+ if (old_flags & FLAT_FLAG_RAM)
+ printf("Load-to-Ram ");
+ if (old_flags & FLAT_FLAG_GOTPIC)
+ printf("Has-PIC-GOT ");
+ if (old_flags & FLAT_FLAG_GZIP)
+ printf("Gzip-Compressed ");
+ if (old_flags & FLAT_FLAG_GZDATA)
+ printf("Gzip-Data-Compressed ");
+ if (old_flags & FLAT_FLAG_KTRACE)
+ printf("Kernel-Traced-Load ");
+ printf(")\n");
+ }
+ } else if (print > 1) {
+ static int first = 1;
+ unsigned int text, data, bss, stk, rel, tot;
+
+ if (first) {
+ printf("Flag Rev Text Data BSS Stack Relocs RAM Filename\n");
+ printf("-----------------------------------------------------------\n");
+ first = 0;
+ }
+ *tfile = '\0';
+ strcat(tfile, (old_flags & FLAT_FLAG_KTRACE) ? "k" : "");
+ strcat(tfile, (old_flags & FLAT_FLAG_RAM) ? "r" : "");
+ strcat(tfile, (old_flags & FLAT_FLAG_GOTPIC) ? "p" : "");
+ strcat(tfile, (old_flags & FLAT_FLAG_GZIP) ? "z" :
+ ((old_flags & FLAT_FLAG_GZDATA) ? "d" : ""));
+ printf("-%-3.3s ", tfile);
+ printf("%3d ", ntohl(old_hdr.rev));
+ printf("%6d ", text=ntohl(old_hdr.data_start)-sizeof(struct flat_hdr));
+ printf("%6d ", data=ntohl(old_hdr.data_end)-ntohl(old_hdr.data_start));
+ printf("%6d ", bss=ntohl(old_hdr.bss_end)-ntohl(old_hdr.data_end));
+ printf("%6d ", stk=ntohl(old_hdr.stack_size));
+ printf("%6d ", rel=ntohl(old_hdr.reloc_count) * 4);
+ /*
+ * work out how much RAM is needed per invocation, this
+ * calculation is dependent on the binfmt_flat implementation
+ */
+ tot = data; /* always need data */
+
+ if (old_flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP))
+ tot += text + sizeof(struct flat_hdr);
+
+ if (bss + stk > rel) /* which is bigger ? */
+ tot += bss + stk;
+ else
+ tot += rel;
+
+ printf("%6d ", tot);
+ /*
+ * the total depends on whether the relocs are smaller/bigger than
+ * the BSS
+ */
+ printf("%s\n", ifile);
+ }
+
+ /* if there is nothing else to do, leave */
+ if (new_flags == old_flags && new_stack == old_stack)
+ return;
+
+ new_hdr.flags = htonl(new_flags);
+ new_hdr.stack_size = htonl(new_stack);
+
+ strcpy(tfile, "/tmp/flatXXXXXX");
+ mkstemp(tfile);
+ if ((ofp = fopen(tfile, "w" BINARY_FILE_OPTS)) == NULL) {
+ fprintf(stderr, "Failed to open %s for writing\n", tfile);
+ unlink(tfile);
+ unlink(tfile2);
+ exit(1);
+ }
+
+ if (fwrite(&new_hdr, sizeof(new_hdr), 1, ofp) != 1) {
+ fprintf(stderr, "Failed to write to %s\n", tfile);
+ unlink(tfile);
+ unlink(tfile2);
+ exit(1);
+ }
+
+ /*
+ * get ourselves a fully uncompressed copy of the text/data/relocs
+ * so that we can manipulate it more easily
+ */
+ if (old_flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
+ FILE *tfp;
+
+ strcpy(tfile2, "/tmp/flat2XXXXXX");
+ mkstemp(tfile2);
+
+ if (old_flags & FLAT_FLAG_GZDATA) {
+ tfp = fopen(tfile2, "w" BINARY_FILE_OPTS);
+ if (!tfp) {
+ fprintf(stderr, "Failed to open %s for writing\n", tfile2);
+ exit(1);
+ }
+ transferr(ifp, tfp, ntohl(old_hdr.data_start) -
+ sizeof(struct flat_hdr));
+ fclose(tfp);
+ }
+
+ sprintf(cmd, "gunzip >> %s", tfile2);
+ tfp = popen(cmd, "w" BINARY_FILE_OPTS);
+ if(!tfp) {
+ perror("popen");
+ exit(1);
+ }
+ transferr(ifp, tfp, -1);
+ pclose(tfp);
+
+ fclose(ifp);
+ ifp = fopen(tfile2, "r" BINARY_FILE_OPTS);
+ if (!ifp) {
+ fprintf(stderr, "Failed to open %s for reading\n", tfile2);
+ unlink(tfile);
+ unlink(tfile2);
+ exit(1);
+ }
+ }
+
+ if (new_flags & FLAT_FLAG_GZIP) {
+ printf("zflat %s --> %s\n", ifile, ofile);
+ fclose(ofp);
+ sprintf(cmd, "gzip -9 -f >> %s", tfile);
+ ofp = popen(cmd, "w" BINARY_FILE_OPTS);
+ ofp_is_pipe = 1;
+ } else if (new_flags & FLAT_FLAG_GZDATA) {
+ printf("zflat-data %s --> %s\n", ifile, ofile);
+ transferr(ifp, ofp, ntohl(new_hdr.data_start) -
+ sizeof(struct flat_hdr));
+ fclose(ofp);
+ sprintf(cmd, "gzip -9 -f >> %s", tfile);
+ ofp = popen(cmd, "w" BINARY_FILE_OPTS);
+ ofp_is_pipe = 1;
+ }
+
+ if (!ofp) { /* can only happen if using gzip/gunzip */
+ fprintf(stderr, "Can't run cmd %s\n", cmd);
+ unlink(tfile);
+ unlink(tfile2);
+ exit(1);
+ }
+
+ transferr(ifp, ofp, -1);
+
+ if (ferror(ifp) || ferror(ofp)) {
+ fprintf(stderr, "Error on file pointer%s%s\n",
+ ferror(ifp) ? " input" : "", ferror(ofp) ? " output" : "");
+ unlink(tfile);
+ unlink(tfile2);
+ exit(1);
+ }
+
+ fclose(ifp);
+ if (ofp_is_pipe)
+ pclose(ofp);
+ else
+ fclose(ofp);
+
+ /* cheat a little here to preserve file permissions */
+ sprintf(cmd, "cp %s %s", tfile, ofile);
+ system(cmd);
+ unlink(tfile);
+ unlink(tfile2);
+}
+
+/****************************************************************************/
+
+void
+usage(char *s)
+{
+ if (s)
+ fprintf(stderr, "%s\n", s);
+ fprintf(stderr, "usage: %s [options] flat-file\n", program_name);
+ fprintf(stderr, " Allows you to change an existing flat file\n\n");
+ fprintf(stderr, " -p : print current settings\n");
+ fprintf(stderr, " -z : compressed flat file\n");
+ fprintf(stderr, " -d : compressed data-only flat file\n");
+ fprintf(stderr, " -Z : un-compressed flat file\n");
+ fprintf(stderr, " -r : ram load\n");
+ fprintf(stderr, " -R : do not RAM load\n");
+ fprintf(stderr, " -k : kernel traced load (for debug)\n");
+ fprintf(stderr, " -K : normal non-kernel traced load\n");
+ fprintf(stderr, " -s size : stack size\n");
+ fprintf(stderr, " -o file : output-file\n"
+ " (default is to modify input file)\n");
+ exit(1);
+}
+
+/****************************************************************************/
+
+int
+main(int argc, char *argv[])
+{
+ int c;
+ char *ofile = NULL, *ifile;
+
+ program_name = argv[0];
+
+ while ((c = getopt(argc, argv, "pdzZrRkKs:o:")) != EOF) {
+ switch (c) {
+ case 'p': print = 1; break;
+ case 'z': compress = 1; break;
+ case 'd': compress = 2; break;
+ case 'Z': compress = -1; break;
+ case 'r': ramload = 1; break;
+ case 'R': ramload = -1; break;
+ case 'k': ktrace = 1; break;
+ case 'K': ktrace = -1; break;
+ case 's': stacksize = atoi(optarg); break;
+ case 'o': ofile = optarg; break;
+ default:
+ usage("invalid option");
+ break;
+ }
+ }
+
+ if (optind >= argc)
+ usage("No input files provided");
+
+ if (ofile && argc - optind > 1)
+ usage("-o can only be used with a single file");
+
+ if (!print && !compress && !ramload && !stacksize) /* no args == print */
+ print = argc - optind; /* greater than 1 is short format */
+
+ for (c = optind; c < argc; c++) {
+ ifile = argv[c];
+ if (!ofile)
+ ofile = ifile;
+ process_file(ifile, ofile);
+ ofile = NULL;
+ }
+
+ exit(0);
+}
+
+/****************************************************************************/
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/install-sh b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/install-sh
new file mode 100755
index 0000000000..398a88e142
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/install-sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ :
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ :
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ :
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/ld-elf2flt.in b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/ld-elf2flt.in
new file mode 100644
index 0000000000..b876636007
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/ld-elf2flt.in
@@ -0,0 +1,219 @@
+#!/bin/sh
+#
+# allow us to do flat processing if the flag -Wl,-elf2flt or -elf2flt to
+# the 'C' compiler or linker respectively
+#
+# uses the env. var FLTFLAGS as extra parameters to pass to elf2flt
+# arguments given like -Wl,-elf2flt="-b 10000 -v" are given before FLTFLAGS
+#
+# Copyright (C) 2002,2003 David McCullough <davidm@snapgear.com>
+# Copyright (C) 2000, Lineo. davidm@lineo.com
+#
+# This is Free Software, under the GNU Public Licence v2 or greater.
+#
+
+LINKER="$0.real" # the original renamed-linker
+ELF2FLT="`expr $0 : '\(.*\)ld'`elf2flt"
+NM="`expr $0 : '\(.*\)ld'`nm"
+TOOLDIR="`dirname $0`" # let gcc find the tools for us
+OBJCOPY="`expr $0 : '\(.*\)ld'`objcopy"
+[ -f "$OBJCOPY" ] || OBJCOPY="$TOOLDIR/../../bin/@target_alias@-objcopy"
+OBJDUMP="`expr $OBJCOPY : '\(.*\)objcopy'`objdump"
+LDSCRIPTPATH="@binutils_ldscript_dir@" # and the scripts
+SHARED_ID=""
+NEWLDSCRIPT=""
+
+# check TOOLDIR from prefix/bin/ or prefix/target-alias/bin/
+[ -d "${LDSCRIPTPATH}" ] || LDSCRIPTPATH="${TOOLDIR}/../lib"
+
+#
+# if we have the elf2flt options, run it
+#
+
+if expr "$*" : ".*-elf2flt.*" > /dev/null
+then
+ ARG1=
+ ARG2=
+ OFILE="a.out"
+ PIC=
+ SDIRS=
+ LDSCRIPT=
+ FINAL="yes"
+ FINAL_ONLY=
+ MOVDAT=
+ VERBOSE=
+
+ while [ $# -ne 0 ]
+ do
+ case "$1" in
+
+ -elf2flt) ;; # we already know this
+ -elf2flt*)FLTFLAGS="`expr \"$1\" : '-elf2flt=\(.*\)'` $FLTFLAGS";;
+
+ -move-rodata)
+ MOVDAT="y";; # Put rodata in ROM if possible
+
+ -shared-lib-id)
+ shift; SHARED_ID="$1";; # Shared library ID
+
+ -o) shift; OFILE="$1";; # the final outfile
+ -o*) OFILE="`expr \"$1\" : '-o\(.*\)'`";;
+
+ -T) shift; LDSCRIPT="$1";; # they have a linker script
+ -c) shift; LDSCRIPT="$1";;
+
+ -L) ARG1="$ARG1 $1" # remember search dirs
+ shift;
+ ARG1="$ARG1 $1"
+ SDIRS="$SDIRS -L$1"
+ ;;
+ -L*) ARG1="$ARG1 $1"; SDIRS="$SDIRS $1";;
+
+ -EB) ARG1="$ARG1 $1"; SDIRS="$SDIRS $1";; # arm big endian
+
+ -relax) ;; # eat this for microblaze
+
+ -r|-Ur) FINAL="" # this is not a final link
+ ARG1="$ARG1 $1"
+ ;;
+
+ -v) ARG1="$ARG1 $1"
+ VERBOSE="y"
+ ;;
+
+ -m) shift; EMUL="-m $1";; # ld emulations for h8300
+ -m*) EMUL=$1;;
+
+ *) ARG1="$ARG1 $1"
+ ;;
+ esac
+ shift
+ done
+
+ if [ "$FINAL" = "yes" ]
+ then
+ [ "$VERBOSE" = "y" ] && set -x
+ ARG1="$ARG1 $FINAL_ONLY"
+ NEWLDSCRIPT=`mktemp /tmp/flt-XXXXXX`
+ SEDOP=" -e s/^R_RODAT// -e /^W_RODAT/d"
+ OBJCOPYOP=""
+ if [ "$MOVDAT" ]
+ then
+ $LINKER -r -d -o "$OFILE.elf2flt" $ARG1 || exit $?
+ if [ "`$OBJDUMP -h "$OFILE.elf2flt" | \
+ egrep -A1 '[.]rodata' | grep RELOC`" ]
+ then
+ echo "warning: .rodata section contains relocations"
+ else
+ SEDOP="-e /^R_RODAT/d -e s/^W_RODAT//"
+ fi
+ fi
+ if [ "$SHARED_ID" ]
+ then
+ # Massage the linker script into something useful. These
+ # regexps are ugly due to some bizzare shell quoting rules.
+ # SEDOP="$SEDOP -e \"s/ORIGIN = 0x0,/ORIGIN = 0x${SHARED_ID}000000,/\""
+ # SEDOP="$SEDOP -e \"s/.text 0x0 :/.text 0x${SHARED_ID}000000 :/\""
+ SEDOP="$SEDOP -e s/\\(ORIGIN.=.0\\)x0,/\\1x${SHARED_ID}000000,/"
+ SEDOP="$SEDOP -e s/\\([.]text.0\\)x0[^0-9]:/\\1x${SHARED_ID}000000:/"
+
+ if [ "$SHARED_ID" -gt 0 ]
+ then
+ # Non application modules enter via main not _start
+ # SEDOP="$SEDOP -e 's/ENTRY (_start)/ENTRY (main)/'"
+ SEDOP="$SEDOP -e s/\\(ENTRY.\\)(_start)/\1(lib_main)/"
+ OBJCOPYOP="--localize-hidden --weaken"
+ fi
+
+ # Provide the magic parameter that defines the library data segment pointer offset
+ case "@target_cpu@" in
+ h8300) GOT_OFFSET="__current_shared_library_er5_offset_";;
+ *) GOT_OFFSET="_current_shared_library_a5_offset_";;
+ esac
+ ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -4 - 4`"
+ fi
+ if [ "@emit_relocs@" = "yes" ]
+ then
+ SEDOP="$SEDOP -e s/^SINGLE_LINK://"
+ else
+ SEDOP="$SEDOP -e /^SINGLE_LINK:/d"
+ fi
+
+ # provide a default linker script, we usually need one
+ [ -z "$LDSCRIPT" ] && LDSCRIPT="${LDSCRIPTPATH}/elf2flt.ld"
+
+ # if we can find the linker script we preprocess it, otherwise
+ # we assume the user knows what they are doing
+ if [ -f "$LDSCRIPT" ]; then
+ sed $SEDOP < "$LDSCRIPT" > "$NEWLDSCRIPT"
+ LDSCRIPT="$NEWLDSCRIPT"
+ elif [ -f "${LDSCRIPTPATH}/$LDSCRIPT" ]; then
+ sed $SEDOP < "${LDSCRIPTPATH}/$LDSCRIPT" > "$NEWLDSCRIPT"
+ LDSCRIPT="$NEWLDSCRIPT"
+ elif [ -f "${LDSCRIPTPATH}/ldscripts/$LDSCRIPT" ]; then
+ sed $SEDOP < "${LDSCRIPTPATH}/ldscripts/$LDSCRIPT" > "$NEWLDSCRIPT"
+ LDSCRIPT="$NEWLDSCRIPT"
+ fi
+
+ if [ "@emit_relocs@" = "yes" ]
+ then
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -q -o "$OFILE.gdb" $ARG1 ||exit $?
+ RFILE="$OFILE.gdb"
+ FLTFLAGS="$FLTFLAGS -a"
+ else
+ if [ "@got_check@" = "no" ]
+ then
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $?
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $?
+ else
+ $LINKER $EMUL -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $?
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $?
+ $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $?
+ rm -f "$OFILE.elf2flt"
+ fi
+ RFILE="$OFILE.elf"
+ fi
+ if $NM "$OFILE.gdb" | grep _GLOBAL_OFFSET_TABLE_ > /dev/null
+ then
+ $ELF2FLT $FLTFLAGS -o "$OFILE" -p "$OFILE.gdb" "$RFILE" || exit $?
+ else
+ $ELF2FLT $FLTFLAGS -o "$OFILE" -r "$RFILE" || exit $?
+ fi
+ if [ "$OBJCOPYOP" ]
+ then
+ if $OBJCOPY $OBJCOPYOP --help > /dev/null 2>&1
+ then
+ $OBJCOPY $OBJCOPYOP "$OFILE.gdb" ||exit $?
+ else
+ case " $OBJCOPYOP " in
+ *" --localize-hidden "*)
+ SYMS=`mktemp /tmp/flt-XXXXXX`
+ $OBJDUMP --syms "$OFILE.gdb" > "$SYMS" ||exit $?
+ sed -n 's/.*\(\.hidden\|\.internal\) \(.*\)/-L \2/p' < "$SYMS" > "$SYMS.hidden" ||exit $?
+ if [ -s "$SYMS.hidden" ]
+ then
+ xargs ${VERBOSE:+-t} $OBJCOPY "$OFILE.gdb" < "$SYMS.hidden" ||exit $?
+ fi
+ rm -f "$SYMS" "$SYMS.hidden"
+ ;;
+ esac
+ case " $OBJCOPYOP " in
+ *" --weaken "*)
+ $OBJCOPY --weaken "$OFILE.gdb" ||exit $?
+ ;;
+ esac
+ fi
+ fi
+ [ "$RFILE" = "$OFILE.gdb" ] || rm -f "$RFILE" # not needed for any reason
+ rm -f "$NEWLDSCRIPT"
+ exit 0
+ fi
+
+ exec $LINKER -o "$OFILE" $ARG1
+fi
+
+#
+# otherwise pretend we aren't here
+#
+
+exec $LINKER "$@"
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/maketarball.sh b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/maketarball.sh
new file mode 100755
index 0000000000..10148608aa
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/maketarball.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+cvs_stamp=$(cut -d/ -f4 CVS/Entries | sort | tail -n 1)
+stamp=$(date +%Y%m%d --date="${cvs_stamp}")
+
+p="elf2flt-${stamp}"
+rm -f elf2flt-*.tar.bz2
+mkdir ../${p}
+cp -r * ../${p}/ || exit 1
+tar jcf ${p}.tar.bz2 --exclude .svn -C .. ${p}
+rm -r ../${p} || exit 1
+du -b ${p}.tar.bz2
diff --git a/cleopatre/buildroot/toolchain/elf2flt/elf2flt/stubs.c b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/stubs.c
new file mode 100644
index 0000000000..fb14d6319b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/elf2flt/elf2flt/stubs.c
@@ -0,0 +1,6 @@
+#ifndef HAVE_DCGETTEXT
+const char *dcgettext (const char *domain, const char *msg, int category)
+{
+ return msg;
+}
+#endif /* !HAVE_DCGETTEXT */
diff --git a/cleopatre/buildroot/toolchain/external-toolchain/Config.in b/cleopatre/buildroot/toolchain/external-toolchain/Config.in
new file mode 100644
index 0000000000..e73090af0c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/external-toolchain/Config.in
@@ -0,0 +1,105 @@
+#
+
+if BR2_TOOLCHAIN_EXTERNAL
+comment "External Toolchain Options"
+
+
+config BR2_TOOLCHAIN_EXTERNAL_LIB_C
+ string "The core C library from the external toolchain"
+ default "libc.so.0"
+ help
+ Specify the core C shared library found in the external
+ toolchain. This is required in addition to any other
+ libraries to be copied.
+
+config BR2_TOOLCHAIN_EXTERNAL_LIBS
+ string "Libraries to copy from the external toolchain"
+ default "ld-uClibc.so.0 libcrypt.so.0 libdl.so.0 libgcc_s.so libm.so.0 libnsl.so.0 libpthread.so.0 libresolv.so.0 librt.so.0 libutil.so.0"
+ help
+ A space separated list of the shared libraries to be copied
+ from the external toolchain into the root filesystem. Only
+ the top-level name is needed, i.e. libc.so, libpthread.so as
+ the actual shared library symlinked to will be copied also.
+
+config BR2_TOOLCHAIN_EXTERNAL_STRIP
+ bool
+ default y
+ prompt "Strip shared libraries"
+ help
+ Strip shared libraries copied from the external toolchain.
+
+comment "Common Toolchain Options"
+
+source "toolchain/gdb/Config.in.2"
+
+config BR2_TOOLCHAIN_EXTERNAL_PATH
+ string "External toolchain path"
+ default "/path/to/staging_dir/usr"
+ help
+ Path to where the external toolchain is installed.
+
+config BR2_TOOLCHAIN_EXTERNAL_PREFIX
+ string "External toolchain prefix"
+ default "$(ARCH)-linux"
+ help
+ This the the external toolchain prefix. For example:
+ armeb-unknown-linux-gnu, mipsel-unknown-linux-gnu, etc.
+
+choice
+ prompt "Thread library implementation"
+ default BR2_EXT_PTHREADS_OLD
+ help
+ Select the version of libpthreads used in the external toolchain.
+
+ config BR2_EXT_PTHREADS_NONE
+ bool
+ prompt "none"
+
+ config BR2_EXT_PTHREADS
+ bool
+ prompt "linuxthreads"
+
+ config BR2_EXT_PTHREADS_OLD
+ bool
+ prompt "linuxthreads (stable/old)"
+
+ config BR2_EXT_PTHREADS_NATIVE
+ bool
+ prompt "Native POSIX Threading (NPTL)"
+endchoice
+
+config BR2_LARGEFILE
+ bool "Enable large file (files > 2 GB) support?"
+ depends on !BR2_cris
+ default y
+ help
+ Enable large file (files > 2 GB) support
+
+config BR2_INET_IPV6
+ bool "Enable IPv6"
+ help
+ Enable IPv6.
+
+config BR2_INET_RPC
+ bool "Enable RPC"
+ help
+ Enable RPC. RPC support is needed for nfs.
+
+config BR2_SOFT_FLOAT
+ bool "Use software floating point by default"
+ depends on BR2_arm || BR2_armeb || BR2_mips || BR2_mipsel || BR2_powerpc
+ help
+ If your target CPU does not have a Floating Point Unit (FPU) or a
+ kernel FPU emulator, but you still wish to support floating point
+ functions, then everything will need to be compiled with soft
+ floating point support (-msoft-float).
+
+ Most people will answer N.
+
+config BR2_TARGET_OPTIMIZATION
+ string "Target Optimizations"
+ default "-Os -pipe"
+ help
+ Optimizations to use when building for the target host.
+
+endif
diff --git a/cleopatre/buildroot/toolchain/external-toolchain/ext-tool.mk b/cleopatre/buildroot/toolchain/external-toolchain/ext-tool.mk
new file mode 100644
index 0000000000..a8303296fd
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/external-toolchain/ext-tool.mk
@@ -0,0 +1,56 @@
+#
+# copy_toolchain_lib_root
+#
+# $1: source
+# $2: destination
+# $2: strip (y|n) default is to strip
+#
+copy_toolchain_lib_root = \
+ LIB="$(strip $1)"; \
+ DST="$(strip $2)"; \
+ STRIP="$(strip $3)"; \
+ \
+ LIB_DIR=`$(TARGET_CC) -print-file-name=$${LIB} | sed -e "s,/$${LIB}\$$,,"`; \
+ \
+ if test -z "$${LIB_DIR}"; then \
+ echo "copy_toolchain_lib_root: lib=$${LIB} not found"; \
+ exit -1; \
+ fi; \
+ \
+ LIB="$(strip $1)"; \
+ for FILE in `find $${LIB_DIR} -maxdepth 1 -type l -name "$${LIB}*"`; do \
+ LIB=`basename $${FILE}`; \
+ while test \! -z "$${LIB}"; do \
+ echo "copy_toolchain_lib_root lib=$${LIB} dst=$${DST}"; \
+ rm -fr $(TARGET_DIR)$${DST}/$${LIB}; \
+ mkdir -p $(TARGET_DIR)$${DST}; \
+ if test -h $${LIB_DIR}/$${LIB}; then \
+ cp -d $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/; \
+ elif test -f $${LIB_DIR}/$${LIB}; then \
+ cp $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/$${LIB}; \
+ case "$${STRIP}" in \
+ (0 | n | no) \
+;; \
+ (*) \
+ $(TARGET_CROSS)strip "$(TARGET_DIR)$${DST}/$${LIB}"; \
+;; \
+ esac; \
+ else \
+ exit -1; \
+ fi; \
+ LIB="`readlink $${LIB_DIR}/$${LIB}`"; \
+ done; \
+ done; \
+ \
+ echo -n
+
+uclibc: dependencies $(TARGET_DIR)/lib/$(strip $(subst ",, $(BR2_TOOLCHAIN_EXTERNAL_LIB_C)))
+
+$(TARGET_DIR)/lib/$(strip $(subst ",, $(BR2_TOOLCHAIN_EXTERNAL_LIB_C))):
+#"))
+ mkdir -p $(TARGET_DIR)/lib
+ @$(call copy_toolchain_lib_root, $(strip $(subst ",, $(BR2_TOOLCHAIN_EXTERNAL_LIB_C))), /lib, $(BR2_TOOLCHAIN_EXTERNAL_STRIP))
+#")))
+ for libs in $(strip $(subst ",, $(BR2_TOOLCHAIN_EXTERNAL_LIBS))); do \
+ $(call copy_toolchain_lib_root, $$libs, /lib, $(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
+ done
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/100-uclibc-conf.patch
new file mode 100644
index 0000000000..00ea4eeb57
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/100-uclibc-conf.patch
@@ -0,0 +1,470 @@
+--- gcc-3.4.1/gcc/config/t-linux-uclibc
++++ gcc-3.4.1/gcc/config/t-linux-uclibc
+@@ -0,0 +1,5 @@
++# Remove glibc specific files added in t-linux
++SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES))
++
++# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc
++LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH))
+--- gcc-3.4.1/gcc/config.gcc
++++ gcc-3.4.1/gcc/config.gcc
+@@ -2310,10 +2310,16 @@
+ *)
+ echo "*** Configuration ${target} not supported" 1>&2
+ exit 1
+ ;;
+ esac
++
++# Rather than hook into each target, just do it after all the linux
++# targets have been processed
++case ${target} in
++*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc"
++esac
+
+ # Support for --with-cpu and related options (and a few unrelated options,
+ # too).
+ case ${with_cpu} in
+ yes | no)
+--- gcc-3.4.4/gcc/config/alpha/linux-elf.h
++++ gcc-3.4.4/gcc/config/alpha/linux-elf.h
+@@ -27,7 +27,11 @@
+ #define SUBTARGET_EXTRA_SPECS \
+ { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
+ #define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+
+ #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+--- gcc-3.4.1-dist/gcc/config/arm/linux-elf.h 2004-01-31 00:18:11.000000000 -0600
++++ gcc-3.4.1/gcc/config/arm/linux-elf.h 2004-08-12 15:54:42.000000000 -0500
+@@ -80,14 +80,19 @@
+ #define ENDFILE_SPEC \
+ "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "%{h*} %{version:-v} \
+ %{b} %{Wl,*:%*} \
+ %{static:-Bstatic} \
+ %{shared:-shared} \
+ %{symbolic:-Bsymbolic} \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "} \
+ -X \
+ %{mbig-endian:-EB}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+--- gcc-3.4.1-dist/gcc/config/cris/linux.h 2003-11-28 21:08:09.000000000 -0600
++++ gcc-3.4.1/gcc/config/cris/linux.h 2004-08-12 15:54:43.000000000 -0500
+@@ -79,6 +79,25 @@
+ #undef CRIS_DEFAULT_CPU_VERSION
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
++#ifdef USE_UCLIBC
++
++#undef CRIS_SUBTARGET_VERSION
++#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++
++#undef CRIS_LINK_SUBTARGET_SPEC
++#define CRIS_LINK_SUBTARGET_SPEC \
++ "-mcrislinux\
++ -rpath-link include/asm/../..%s\
++ %{shared} %{static}\
++ %{symbolic:-Bdynamic} %{shlib:-Bdynamic} %{static:-Bstatic}\
++ %{!shared: \
++ %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}} \
++ %{!r:%{O2|O3: --gc-sections}}"
++
++#else /* USE_UCLIBC */
++
+ #undef CRIS_SUBTARGET_VERSION
+ #define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
+
+@@ -93,6 +112,8 @@
+ %{!shared:%{!static:%{rdynamic:-export-dynamic}}}\
+ %{!r:%{O2|O3: --gc-sections}}"
+
++#endif /* USE_UCLIBC */
++
+
+ /* Node: Run-time Target */
+
+--- gcc-3.4.1-dist/gcc/config/i386/linux.h 2003-11-28 21:08:10.000000000 -0600
++++ gcc-3.4.1/gcc/config/i386/linux.h 2004-08-12 15:54:43.000000000 -0500
+@@ -110,22 +110,21 @@
+
+ #undef LINK_SPEC
+ #ifdef USE_GNULIBC_1
+-#define LINK_SPEC "-m elf_i386 %{shared:-shared} \
+- %{!shared: \
+- %{!ibcs: \
+- %{!static: \
+- %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
+- %{static:-static}}}"
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.1"
++#else
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+ #else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
++#endif
+ #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+-#endif
+
+ /* A C statement (sans semicolon) to output to the stdio stream
+ FILE the assembler definition of uninitialized global DECL named
+--- gcc-3.4.4/gcc/config/i386/linux64.h
++++ gcc-3.4.4/gcc/config/i386/linux64.h
+@@ -54,14 +54,21 @@
+ When the -shared link option is used a final link is not being
+ done. */
+
++#ifdef USE_UCLIBC
++#define ELF32_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF32_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define ELF64_DYNAMIC_LINKER "/lib64/ld-linux-x86-64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
+- %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
++ %{m32:%{!dynamic-linker:-dynamic-linker " ELF32_DYNAMIC_LINKER "}} \
++ %{!m32:%{!dynamic-linker:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}} \
+ %{static:-static}}"
+
+ #define MULTILIB_DEFAULTS { "m64" }
+--- gcc-3.4.4/gcc/config/ia64/linux.h
++++ gcc-3.4.4/gcc/config/ia64/linux.h
+@@ -37,13 +37,18 @@
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+
+--- gcc-3.4.4/gcc/config/m68k/linux.h
++++ gcc-3.4.4/gcc/config/m68k/linux.h
+@@ -131,12 +131,17 @@
+
+ /* If ELF is the default format, we should not use /lib/elf. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m m68kelf %{shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker*:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static}}"
+
+ /* For compatibility with linux/a.out */
+--- gcc-3.4.1-dist/gcc/config/mips/linux.h 2004-06-15 20:42:24.000000000 -0500
++++ gcc-3.4.1/gcc/config/mips/linux.h 2004-08-12 15:54:43.000000000 -0500
+@@ -109,14 +109,19 @@
+
+ /* Borrowed from sparc/linux.h */
+ #undef LINK_SPEC
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #define LINK_SPEC \
+ "%(endian_spec) \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+
+ #undef SUBTARGET_ASM_SPEC
+--- gcc-3.4.4/gcc/config/pa/pa-linux.h
++++ gcc-3.4.4/gcc/config/pa/pa-linux.h
+@@ -77,13 +77,18 @@
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+ /* glibc's profiling functions don't need gcc to allocate counters. */
+--- gcc-3.4.1-dist/gcc/config/rs6000/linux.h 2004-02-25 09:11:19.000000000 -0600
++++ gcc-3.4.1/gcc/config/rs6000/linux.h 2004-08-12 15:54:43.000000000 -0500
+@@ -69,7 +69,11 @@
+ #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
+
+ #undef LINK_OS_DEFAULT_SPEC
++#ifdef USE_UCLIBC
++#define LINK_OS_DEFAULT_SPEC "%(link_os_linux_uclibc)"
++#else
+ #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
++#endif
+
+ #define LINK_GCC_C_SEQUENCE_SPEC \
+ "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
+--- gcc-3.4.1-dist/gcc/config/rs6000/sysv4.h 2004-06-10 01:39:50.000000000 -0500
++++ gcc-3.4.1/gcc/config/rs6000/sysv4.h 2004-08-12 15:54:43.000000000 -0500
+@@ -947,6 +947,7 @@
+ mcall-linux : %(link_os_linux) ; \
+ mcall-gnu : %(link_os_gnu) ; \
+ mcall-netbsd : %(link_os_netbsd) ; \
++ mcall-linux-uclibc : %(link_os_linux_uclibc); \
+ mcall-openbsd: %(link_os_openbsd) ; \
+ : %(link_os_default) }"
+
+@@ -1125,6 +1126,10 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
+
++#define LINK_OS_LINUX_UCLIBC_SPEC "-m elf32ppclinux %{!shared: %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}}"
++
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+ # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+ #endif
+@@ -1291,6 +1296,7 @@
+ { "link_os_sim", LINK_OS_SIM_SPEC }, \
+ { "link_os_freebsd", LINK_OS_FREEBSD_SPEC }, \
+ { "link_os_linux", LINK_OS_LINUX_SPEC }, \
++ { "link_os_linux_uclibc", LINK_OS_LINUX_UCLIBC_SPEC }, \
+ { "link_os_gnu", LINK_OS_GNU_SPEC }, \
+ { "link_os_netbsd", LINK_OS_NETBSD_SPEC }, \
+ { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
+--- gcc-3.4.4/gcc/config/s390/linux.h
++++ gcc-3.4.4/gcc/config/s390/linux.h
+@@ -77,6 +77,13 @@
+ #define MULTILIB_DEFAULTS { "m31" }
+ #endif
+
++#ifdef USE_UCLIBC
++#define ELF31_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF31_DYNAMIC_LINKER "/lib/ld.so.1"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+ "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
+@@ -86,8 +93,8 @@
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker: \
+- %{m31:-dynamic-linker /lib/ld.so.1} \
+- %{m64:-dynamic-linker /lib/ld64.so.1}}}}"
++ %{m31:-dynamic-linker " ELF31_DYNAMIC_LINKER "} \
++ %{m64:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}}}"
+
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+--- gcc-3.4.1-dist/gcc/config/sh/linux.h 2004-01-11 20:29:13.000000000 -0600
++++ gcc-3.4.1/gcc/config/sh/linux.h 2004-08-12 15:54:43.000000000 -0500
+@@ -73,11 +73,16 @@
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
+ #undef SUBTARGET_LINK_SPEC
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define SUBTARGET_LINK_SPEC \
+ "%{shared:-shared} \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}"
+
+ #undef LIB_SPEC
+--- gcc-3.4.4/gcc/config/sparc/linux.h
++++ gcc-3.4.4/gcc/config/sparc/linux.h
+@@ -162,13 +162,18 @@
+ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
+ %{static:-static}}}"
+ #else
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!mno-relax:%{!r:-relax}} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+ #endif
+
+--- gcc-3.4.4/gcc/config/sparc/linux64.h
++++ gcc-3.4.4/gcc/config/sparc/linux64.h
+@@ -167,12 +166,17 @@
+ { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
+ { "link_arch", LINK_ARCH_SPEC },
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}} \
+ "
+
+--- gcc-3.4.1-dist/libtool.m4 2004-05-18 04:08:37.000000000 -0500
++++ gcc-3.4.1/libtool.m4 2004-08-12 15:54:43.000000000 -0500
+@@ -689,6 +689,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+--- gcc-3.4.1-dist/ltconfig 2004-03-05 15:05:41.000000000 -0600
++++ gcc-3.4.1/ltconfig 2004-08-12 15:55:48.000000000 -0500
+@@ -602,6 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1262,6 +1263,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- gcc-3.4.1-dist/boehm-gc/configure 2004-07-01 14:14:03.000000000 -0500
++++ gcc-3.4.1/boehm-gc/configure 2004-08-12 16:22:57.000000000 -0500
+@@ -1947,6 +1947,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-3.4.1-dist/boehm-gc/ltconfig 2002-11-20 09:59:06.000000000 -0600
++++ gcc-3.4.1/boehm-gc/ltconfig 2004-08-12 15:54:42.000000000 -0500
+@@ -1981,6 +1981,23 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
++ file_magic_cmd=/usr/bin/file
++ file_magic_test_file=`echo /lib/libuClibc-*.so`
++
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ version_type=sunos
+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/200-uclibc-locale.patch
new file mode 100644
index 0000000000..a97f22b49a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/200-uclibc-locale.patch
@@ -0,0 +1,3255 @@
+diff -urN gcc-3.4.2-dist/libstdc++-v3/acinclude.m4 gcc-3.4.2/libstdc++-v3/acinclude.m4
+--- gcc-3.4.2-dist/libstdc++-v3/acinclude.m4 2004-07-15 12:42:45.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/acinclude.m4 2004-09-10 10:47:40.000000000 -0500
+@@ -996,7 +996,7 @@
+ AC_MSG_CHECKING([for C locale to use])
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # If they didn't use this option switch, or if they specified --enable
+ # with no specific model, we'll have to look for one. If they
+@@ -1012,6 +1012,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case x${target_os} in
++ x*-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1138,6 +1141,41 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+diff -urN gcc-3.4.2-dist/libstdc++-v3/aclocal.m4 gcc-3.4.2/libstdc++-v3/aclocal.m4
+--- gcc-3.4.2-dist/libstdc++-v3/aclocal.m4 2004-08-13 15:44:03.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/aclocal.m4 2004-09-10 10:47:40.000000000 -0500
+@@ -1025,6 +1025,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case x${target_os} in
++ x*-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1151,6 +1154,41 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c++locale_internal.h gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,59 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#endif // GLIBC 2.3 and later
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c_locale.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c_locale.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c_locale.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c_locale.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c_locale.h gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c_locale.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/c_locale.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2004-09-10 10:48:08.000000000 -0500
+@@ -0,0 +1,115 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out, const int __size, const char* __fmt,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/codecvt_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/codecvt_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/codecvt_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/collate_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/collate_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/collate_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/collate_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/ctype_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/ctype_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = 0;
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/messages_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/messages_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/messages_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/messages_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-3.4.2/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/messages_members.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/monetary_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/monetary_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,698 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ ;
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ unsigned char uc;
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ {
++ uc = static_cast<unsigned char>(money_base::_S_atoms[__i]);
++ _M_data->_M_atoms[__i] = btowc(uc);
++ }
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union __s_and_w { const char *__s; unsigned int __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ unsigned char uc;
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ {
++ uc = static_cast<unsigned char>(money_base::_S_atoms[__i]);
++ _M_data->_M_atoms[__i] = btowc(uc);
++ }
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union __s_and_w { const char *__s; unsigned int __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/numeric_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/numeric_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,183 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = strlen(_M_data->_M_truename);
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = strlen(_M_data->_M_falsename);
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_S_get_c_locale());
++#endif
++ // Use ctype::widen code without the facet...
++ unsigned char uc;
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ {
++ uc = static_cast<unsigned char>(__num_base::_S_atoms_out[__i]);
++ _M_data->_M_atoms_out[__i] = btowc(uc);
++ }
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ {
++ uc = static_cast<unsigned char>(__num_base::_S_atoms_in[__j]);
++ _M_data->_M_atoms_in[__j] = btowc(uc);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union __s_and_w { const char *__s; unsigned int __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
++#endif
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = wcslen(_M_data->_M_truename);
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = wcslen(_M_data->_M_falsename);
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/time_members.cc gcc-3.4.2/libstdc++-v3/config/locale/uclibc/time_members.cc
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/time_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/time_members.cc 2004-09-10 10:48:00.000000000 -0500
+@@ -0,0 +1,356 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc));
++ _M_data->_M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc));
++ _M_data->_M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc));
++ _M_data->_M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc));
++ _M_data->_M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc));
++ _M_data->_M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc));
++ _M_data->_M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc));
++ _M_data->_M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc));
++ _M_data->_M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc));
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc));
++ _M_data->_M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc));
++ _M_data->_M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc));
++ _M_data->_M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc));
++ _M_data->_M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc));
++ _M_data->_M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc));
++ _M_data->_M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc));
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc));
++ _M_data->_M_aday2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc));
++ _M_data->_M_aday3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc));
++ _M_data->_M_aday4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc));
++ _M_data->_M_aday5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc));
++ _M_data->_M_aday6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc));
++ _M_data->_M_aday7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc));
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc));
++ _M_data->_M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc));
++ _M_data->_M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc));
++ _M_data->_M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc));
++ _M_data->_M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc));
++ _M_data->_M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc));
++ _M_data->_M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc));
++ _M_data->_M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc));
++ _M_data->_M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc));
++ _M_data->_M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc));
++ _M_data->_M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc));
++ _M_data->_M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc));
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc));
++ _M_data->_M_amonth02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc));
++ _M_data->_M_amonth03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc));
++ _M_data->_M_amonth04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc));
++ _M_data->_M_amonth05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc));
++ _M_data->_M_amonth06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc));
++ _M_data->_M_amonth07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc));
++ _M_data->_M_amonth08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc));
++ _M_data->_M_amonth09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc));
++ _M_data->_M_amonth10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc));
++ _M_data->_M_amonth11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc));
++ _M_data->_M_amonth12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc));
++ }
++#endif // 0
++ }
++#endif
++}
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/time_members.h gcc-3.4.2/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/locale/uclibc/time_members.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/locale/uclibc/time_members.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_base.h gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_base.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_base.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_base.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,58 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// Information as gleaned from /usr/include/ctype.h
++
++ struct ctype_base
++ {
++ // Note: In uClibc, the following two types depend on configuration.
++
++ // Non-standard typedefs.
++ typedef const __ctype_touplow_t* __to_type;
++
++ // NB: Offsets into ctype<char>::_M_table force a particular size
++ // on the mask type. Because of this, we don't use an enum.
++ typedef __ctype_mask_t mask;
++ static const mask upper = _ISupper;
++ static const mask lower = _ISlower;
++ static const mask alpha = _ISalpha;
++ static const mask digit = _ISdigit;
++ static const mask xdigit = _ISxdigit;
++ static const mask space = _ISspace;
++ static const mask print = _ISprint;
++ static const mask graph = _ISalpha | _ISdigit | _ISpunct;
++ static const mask cntrl = _IScntrl;
++ static const mask punct = _ISpunct;
++ static const mask alnum = _ISalpha | _ISdigit;
++ };
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_inline.h gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_inline.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_inline.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_inline.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,69 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
++// functions go in ctype.cc
++
++ bool
++ ctype<char>::
++ is(mask __m, char __c) const
++ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
++
++ const char*
++ ctype<char>::
++ is(const char* __low, const char* __high, mask* __vec) const
++ {
++ while (__low < __high)
++ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
++ return __high;
++ }
++
++ const char*
++ ctype<char>::
++ scan_is(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++ ++__low;
++ return __low;
++ }
++
++ const char*
++ ctype<char>::
++ scan_not(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++ ++__low;
++ return __low;
++ }
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_noninline.h gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_noninline.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/ctype_noninline.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/os/uclibc/ctype_noninline.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,92 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// Information as gleaned from /usr/include/ctype.h
++
++ const ctype_base::mask*
++ ctype<char>::classic_table() throw()
++ { return __C_ctype_b; }
++
++ ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ char
++ ctype<char>::do_toupper(char __c) const
++ { return _M_toupper[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_toupper(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
++
++ char
++ ctype<char>::do_tolower(char __c) const
++ { return _M_tolower[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_tolower(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
+diff -urN gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/os_defines.h gcc-3.4.2/libstdc++-v3/config/os/uclibc/os_defines.h
+--- gcc-3.4.2-dist/libstdc++-v3/config/os/uclibc/os_defines.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/config/os/uclibc/os_defines.h 2004-09-10 10:47:40.000000000 -0500
+@@ -0,0 +1,44 @@
++// Specific definitions for GNU/Linux -*- C++ -*-
++
++// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++#ifndef _GLIBCXX_OS_DEFINES
++#define _GLIBCXX_OS_DEFINES 1
++
++// System-specific #define, typedefs, corrections, etc, go here. This
++// file will come before all others.
++
++// This keeps isanum, et al from being propagated as macros.
++#define __NO_CTYPE 1
++
++#include <features.h>
++
++// We must not see the optimized string functions GNU libc defines.
++#define __NO_STRING_INLINES
++
++#endif
+diff -urN gcc-3.4.2-dist/libstdc++-v3/configure gcc-3.4.2/libstdc++-v3/configure
+--- gcc-3.4.2-dist/libstdc++-v3/configure 2004-08-13 15:44:04.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/configure 2004-09-10 10:47:40.000000000 -0500
+@@ -3878,6 +3878,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5479,7 +5479,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5545,6 +5550,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case x${target_os} in
++ xlinux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+@@ -5759,6 +5767,77 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+diff -urN gcc-3.4.2-dist/libstdc++-v3/configure.host gcc-3.4.2/libstdc++-v3/configure.host
+--- gcc-3.4.2-dist/libstdc++-v3/configure.host 2004-08-27 14:52:30.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/configure.host 2004-09-10 10:47:40.000000000 -0500
+@@ -217,6 +217,12 @@
+ ;;
+ esac
+
++# Override for uClibc since linux-uclibc gets mishandled above.
++case "${host_os}" in
++ *-uclibc*)
++ os_include_dir="os/uclibc"
++ ;;
++esac
+
+ # Set any OS-dependent and CPU-dependent bits.
+ # THIS TABLE IS SORTED. KEEP IT THAT WAY.
+diff -urN gcc-3.4.2-dist/libstdc++-v3/crossconfig.m4 gcc-3.4.2/libstdc++-v3/crossconfig.m4
+--- gcc-3.4.2-dist/libstdc++-v3/crossconfig.m4 2004-07-06 20:23:49.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/crossconfig.m4 2004-09-10 10:47:40.000000000 -0500
+@@ -138,6 +138,99 @@
+ ;;
+ esac
+ ;;
++ *-uclibc*)
++# Temporary hack until we implement the float versions of the libm funcs
++ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
++ machine/endian.h machine/param.h sys/machine.h sys/types.h \
++ fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
++ SECTION_FLAGS='-ffunction-sections -fdata-sections'
++ AC_SUBST(SECTION_FLAGS)
++ GLIBCXX_CHECK_LINKER_FEATURES
++ GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
++ GLIBCXX_CHECK_WCHAR_T_SUPPORT
++
++ # For LFS.
++ AC_DEFINE(HAVE_INT64_T)
++ case "$target" in
++ *-uclinux*)
++ # Don't enable LFS with uClinux
++ ;;
++ *)
++ AC_DEFINE(_GLIBCXX_USE_LFS)
++ esac
++
++ # For showmanyc_helper().
++ AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
++ GLIBCXX_CHECK_POLL
++ GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
++
++ # For xsputn_2().
++ AC_CHECK_HEADERS(sys/uio.h)
++ GLIBCXX_CHECK_WRITEV
++
++# AC_DEFINE(HAVE_ACOSF)
++# AC_DEFINE(HAVE_ASINF)
++# AC_DEFINE(HAVE_ATANF)
++# AC_DEFINE(HAVE_ATAN2F)
++ AC_DEFINE(HAVE_CEILF)
++ AC_DEFINE(HAVE_COPYSIGN)
++# AC_DEFINE(HAVE_COPYSIGNF)
++# AC_DEFINE(HAVE_COSF)
++# AC_DEFINE(HAVE_COSHF)
++# AC_DEFINE(HAVE_EXPF)
++# AC_DEFINE(HAVE_FABSF)
++ AC_DEFINE(HAVE_FINITE)
++ AC_DEFINE(HAVE_FINITEF)
++ AC_DEFINE(HAVE_FLOORF)
++# AC_DEFINE(HAVE_FMODF)
++# AC_DEFINE(HAVE_FREXPF)
++ AC_DEFINE(HAVE_HYPOT)
++# AC_DEFINE(HAVE_HYPOTF)
++ AC_DEFINE(HAVE_ISINF)
++ AC_DEFINE(HAVE_ISINFF)
++ AC_DEFINE(HAVE_ISNAN)
++ AC_DEFINE(HAVE_ISNANF)
++# AC_DEFINE(HAVE_LOGF)
++# AC_DEFINE(HAVE_LOG10F)
++# AC_DEFINE(HAVE_MODFF)
++# AC_DEFINE(HAVE_SINF)
++# AC_DEFINE(HAVE_SINHF)
++# AC_DEFINE(HAVE_SINCOS)
++# AC_DEFINE(HAVE_SINCOSF)
++ AC_DEFINE(HAVE_SQRTF)
++# AC_DEFINE(HAVE_TANF)
++# AC_DEFINE(HAVE_TANHF)
++ if test x"long_double_math_on_this_cpu" = x"yes"; then
++ AC_MSG_ERROR([long_double_math_on_this_cpu is yes!])
++# AC_DEFINE(HAVE_ACOSL)
++# AC_DEFINE(HAVE_ASINL)
++# AC_DEFINE(HAVE_ATANL)
++# AC_DEFINE(HAVE_ATAN2L)
++# AC_DEFINE(HAVE_CEILL)
++# AC_DEFINE(HAVE_COPYSIGNL)
++# AC_DEFINE(HAVE_COSL)
++# AC_DEFINE(HAVE_COSHL)
++# AC_DEFINE(HAVE_EXPL)
++# AC_DEFINE(HAVE_FABSL)
++# AC_DEFINE(HAVE_FINITEL)
++# AC_DEFINE(HAVE_FLOORL)
++# AC_DEFINE(HAVE_FMODL)
++# AC_DEFINE(HAVE_FREXPL)
++# AC_DEFINE(HAVE_HYPOTL)
++# AC_DEFINE(HAVE_ISINFL)
++# AC_DEFINE(HAVE_ISNANL)
++# AC_DEFINE(HAVE_LOGL)
++# AC_DEFINE(HAVE_LOG10L)
++# AC_DEFINE(HAVE_MODFL)
++# AC_DEFINE(HAVE_POWL)
++# AC_DEFINE(HAVE_SINL)
++# AC_DEFINE(HAVE_SINHL)
++# AC_DEFINE(HAVE_SINCOSL)
++# AC_DEFINE(HAVE_SQRTL)
++# AC_DEFINE(HAVE_TANL)
++# AC_DEFINE(HAVE_TANHL)
++ fi
++ ;;
+ *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu)
+ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
+ machine/endian.h machine/param.h sys/machine.h sys/types.h \
+@@ -152,7 +245,7 @@
+ AC_DEFINE(HAVE_INT64_T)
+ case "$target" in
+ *-uclinux*)
+- # Don't enable LFS with uClibc
++ # Don't enable LFS with uClinux
+ ;;
+ *)
+ AC_DEFINE(_GLIBCXX_USE_LFS)
+diff -urN gcc-3.4.2-dist/libstdc++-v3/include/c_compatibility/wchar.h gcc-3.4.2/libstdc++-v3/include/c_compatibility/wchar.h
+--- gcc-3.4.2-dist/libstdc++-v3/include/c_compatibility/wchar.h 2003-12-08 21:51:45.000000000 -0600
++++ gcc-3.4.2/libstdc++-v3/include/c_compatibility/wchar.h 2004-09-10 10:47:40.000000000 -0500
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+diff -urN gcc-3.4.2-dist/libstdc++-v3/include/c_std/std_cwchar.h gcc-3.4.2/libstdc++-v3/include/c_std/std_cwchar.h
+--- gcc-3.4.2-dist/libstdc++-v3/include/c_std/std_cwchar.h 2004-07-20 03:52:12.000000000 -0500
++++ gcc-3.4.2/libstdc++-v3/include/c_std/std_cwchar.h 2004-09-10 10:47:40.000000000 -0500
+@@ -179,7 +179,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..e8c9ed4150
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/300-libstdc++-pic.patch
@@ -0,0 +1,51 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -209,6 +209,11 @@
+ CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
+
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+--- gcc-3.4.6/libstdc++-v3/src/Makefile.in 2004-04-16 21:08:35.000000000 +0200
++++ gcc-3.4.6-patched/libstdc++-v3/src/Makefile.in 2007-11-30 13:33:26.000000000 +0100
+@@ -592,7 +592,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -625,6 +625,7 @@
+ distclean-tags distdir dvi dvi-am info info-am install \
+ install-am install-data install-data-am install-data-local \
+ install-exec install-exec-am install-info install-info-am \
++ install-exec-local \
+ install-man install-strip install-toolexeclibLTLIBRARIES \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+@@ -709,6 +710,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/304-index_macro.patch
new file mode 100644
index 0000000000..1fac112fa9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ namespace __gnu_cxx
+ {
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch
new file mode 100644
index 0000000000..0c370502c8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch
@@ -0,0 +1,65 @@
+--- gcc-3.4.0/gcc/config/arm/arm.md.arm-ldm-peephole 2004-01-13 08:24:37.000000000 -0500
++++ gcc-3.4.0/gcc/config/arm/arm.md 2004-04-24 18:18:04.000000000 -0400
+@@ -8810,13 +8810,16 @@
+ (set_attr "length" "4,8,8")]
+ )
+
++; Try to convert LDR+LDR+arith into [add+]LDM+arith
++; On XScale, LDM is always slower than two LDRs, so only do this if
++; optimising for size.
+ (define_insn "*arith_adjacentmem"
+ [(set (match_operand:SI 0 "s_register_operand" "=r")
+ (match_operator:SI 1 "shiftable_operator"
+ [(match_operand:SI 2 "memory_operand" "m")
+ (match_operand:SI 3 "memory_operand" "m")]))
+ (clobber (match_scratch:SI 4 "=r"))]
+- "TARGET_ARM && adjacent_mem_locations (operands[2], operands[3])"
++ "TARGET_ARM && (!arm_tune_xscale || optimize_size) && adjacent_mem_locations (operands[2], operands[3])"
+ "*
+ {
+ rtx ldm[3];
+@@ -8851,6 +8854,8 @@
+ }
+ if (val1 && val2)
+ {
++ /* This would be a loss on a Harvard core, but adjacent_mem_locations()
++ will prevent it from happening. */
+ rtx ops[3];
+ ldm[0] = ops[0] = operands[4];
+ ops[1] = XEXP (XEXP (operands[2], 0), 0);
+--- gcc-3.4.0/gcc/config/arm/arm.c.arm-ldm-peephole 2004-04-24 18:16:25.000000000 -0400
++++ gcc-3.4.0/gcc/config/arm/arm.c 2004-04-24 18:18:04.000000000 -0400
+@@ -4838,6 +4841,11 @@
+ *load_offset = unsorted_offsets[order[0]];
+ }
+
++ /* For XScale a two-word LDM is a performance loss, so only do this if
++ size is more important. See comments in arm_gen_load_multiple. */
++ if (nops == 2 && arm_tune_xscale && !optimize_size)
++ return 0;
++
+ if (unsorted_offsets[order[0]] == 0)
+ return 1; /* ldmia */
+
+@@ -5064,6 +5072,11 @@
+ *load_offset = unsorted_offsets[order[0]];
+ }
+
++ /* For XScale a two-word LDM is a performance loss, so only do this if
++ size is more important. See comments in arm_gen_load_multiple. */
++ if (nops == 2 && arm_tune_xscale && !optimize_size)
++ return 0;
++
+ if (unsorted_offsets[order[0]] == 0)
+ return 1; /* stmia */
+
+--- gcc-3.4.0/gcc/genpeep.c.arm-ldm-peephole 2003-07-05 01:27:22.000000000 -0400
++++ gcc-3.4.0/gcc/genpeep.c 2004-04-24 18:18:04.000000000 -0400
+@@ -381,6 +381,7 @@
+ printf ("#include \"recog.h\"\n");
+ printf ("#include \"except.h\"\n\n");
+ printf ("#include \"function.h\"\n\n");
++ printf ("#include \"flags.h\"\n\n");
+
+ printf ("#ifdef HAVE_peephole\n");
+ printf ("extern rtx peep_operand[];\n\n");
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch
new file mode 100644
index 0000000000..27f7c07db9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch
@@ -0,0 +1,42 @@
+The 30_all_gcc34-arm-ldm-peephole.patch from Debian was conflicting
+with the newer 36_all_pr16201-fix.patch, so i cut out the hunk from
+it that was causing problems and grabbed an updated version from
+upstream cvs.
+
+Index: gcc/config/arm/arm.c
+===================================================================
+RCS file: /cvsroot/gcc/gcc/gcc/config/arm/arm.c,v
+retrieving revision 1.432
+retrieving revision 1.433
+diff -u -r1.432 -r1.433
+--- gcc-3.4.4/gcc/config/arm/arm.c 29 Mar 2005 03:00:23 -0000 1.432
++++ gcc-3.4.4/gcc/config/arm/arm.c 1 Apr 2005 11:02:22 -0000 1.433
+@@ -5139,6 +5139,10 @@
+ int
+ adjacent_mem_locations (rtx a, rtx b)
+ {
++ /* We don't guarantee to preserve the order of these memory refs. */
++ if (volatile_refs_p (a) || volatile_refs_p (b))
++ return 0;
++
+ if ((GET_CODE (XEXP (a, 0)) == REG
+ || (GET_CODE (XEXP (a, 0)) == PLUS
+ && GET_CODE (XEXP (XEXP (a, 0), 1)) == CONST_INT))
+@@ -5178,6 +5182,17 @@
+ return 0;
+
+ val_diff = val1 - val0;
++
++ if (arm_ld_sched)
++ {
++ /* If the target has load delay slots, then there's no benefit
++ to using an ldm instruction unless the offset is zero and
++ we are optimizing for size. */
++ return (optimize_size && (REGNO (reg0) == REGNO (reg1))
++ && (val0 == 0 || val1 == 0 || val0 == 4 || val1 == 4)
++ && (val_diff == 4 || val_diff == -4));
++ }
++
+ return ((REGNO (reg0) == REGNO (reg1))
+ && (val_diff == 4 || val_diff == -4));
+ }
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch
new file mode 100644
index 0000000000..142052fdf0
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch
@@ -0,0 +1,119 @@
+--- gcc-3.4.0/gcc/config/arm/arm.c.arm-ldm 2004-02-27 09:51:05.000000000 -0500
++++ gcc-3.4.0/gcc/config/arm/arm.c 2004-04-24 18:16:25.000000000 -0400
+@@ -8520,6 +8520,26 @@
+ return_used_this_function = 0;
+ }
+
++/* Return the number (counting from 0) of
++ the least significant set bit in MASK. */
++
++#ifdef __GNUC__
++inline
++#endif
++static int
++number_of_first_bit_set (mask)
++ int mask;
++{
++ int bit;
++
++ for (bit = 0;
++ (mask & (1 << bit)) == 0;
++ ++bit)
++ continue;
++
++ return bit;
++}
++
+ const char *
+ arm_output_epilogue (rtx sibling)
+ {
+@@ -8753,27 +8773,47 @@
+ saved_regs_mask |= (1 << PC_REGNUM);
+ }
+
+- /* Load the registers off the stack. If we only have one register
+- to load use the LDR instruction - it is faster. */
+- if (saved_regs_mask == (1 << LR_REGNUM))
+- {
+- /* The exception handler ignores the LR, so we do
+- not really need to load it off the stack. */
+- if (eh_ofs)
+- asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
+- else
+- asm_fprintf (f, "\tldr\t%r, [%r], #4\n", LR_REGNUM, SP_REGNUM);
+- }
+- else if (saved_regs_mask)
++ if (saved_regs_mask)
+ {
+- if (saved_regs_mask & (1 << SP_REGNUM))
+- /* Note - write back to the stack register is not enabled
+- (ie "ldmfd sp!..."). We know that the stack pointer is
+- in the list of registers and if we add writeback the
+- instruction becomes UNPREDICTABLE. */
+- print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
++ /* Load the registers off the stack. If we only have one register
++ to load use the LDR instruction - it is faster. */
++ if (bit_count (saved_regs_mask) == 1)
++ {
++ int reg = number_of_first_bit_set (saved_regs_mask);
++
++ switch (reg)
++ {
++ case SP_REGNUM:
++ /* Mustn't use base writeback when loading SP. */
++ asm_fprintf (f, "\tldr\t%r, [%r]\n", SP_REGNUM, SP_REGNUM);
++ break;
++
++ case LR_REGNUM:
++ if (eh_ofs)
++ {
++ /* The exception handler ignores the LR, so we do
++ not really need to load it off the stack. */
++ asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
++ break;
++ }
++ /* else fall through */
++
++ default:
++ asm_fprintf (f, "\tldr\t%r, [%r], #4\n", reg, SP_REGNUM);
++ break;
++ }
++ }
+ else
+- print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
++ {
++ if (saved_regs_mask & (1 << SP_REGNUM))
++ /* Note - write back to the stack register is not enabled
++ (ie "ldmfd sp!..."). We know that the stack pointer is
++ in the list of registers and if we add writeback the
++ instruction becomes UNPREDICTABLE. */
++ print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
++ else
++ print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
++ }
+ }
+
+ if (current_function_pretend_args_size)
+@@ -11401,22 +11441,6 @@
+ }
+ }
+
+-/* Return the number (counting from 0) of
+- the least significant set bit in MASK. */
+-
+-inline static int
+-number_of_first_bit_set (int mask)
+-{
+- int bit;
+-
+- for (bit = 0;
+- (mask & (1 << bit)) == 0;
+- ++bit)
+- continue;
+-
+- return bit;
+-}
+-
+ /* Generate code to return from a thumb function.
+ If 'reg_containing_return_addr' is -1, then the return address is
+ actually on the stack, at the stack pointer. */
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch
new file mode 100644
index 0000000000..4377c2143b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch
@@ -0,0 +1,22 @@
+--- gcc-3.4.1/libstdc++-v3/libmath/Makefile.am~ 2003-08-27 22:29:42.000000000 +0100
++++ gcc-3.4.1/libstdc++-v3/libmath/Makefile.am 2004-07-22 16:41:45.152130128 +0100
+@@ -32,7 +32,7 @@
+
+ libmath_la_SOURCES = stubs.c
+
+-AM_CPPFLAGS = $(CANADIAN_INCLUDES)
++AM_CPPFLAGS = $(CANADIAN_INCLUDES) -I$(toplevel_srcdir)/include
+
+ # Only compiling "C" sources in this directory.
+ LIBTOOL = @LIBTOOL@ --tag CC
+--- gcc-3.4.1/libstdc++-v3/fragment.am.old 2004-07-22 18:24:58.024083656 +0100
++++ gcc-3.4.1/libstdc++-v3/fragment.am 2004-07-22 18:24:59.019932264 +0100
+@@ -18,7 +18,7 @@
+ $(WARN_FLAGS) $(WERROR) -fdiagnostics-show-location=once
+
+ # -I/-D flags to pass when compiling.
+-AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
++AM_CPPFLAGS = $(GLIBCXX_INCLUDES) -I$(toplevel_srcdir)/include
+
+
+
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/700-pr15068-fix.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/700-pr15068-fix.patch
new file mode 100644
index 0000000000..2977765c5f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/700-pr15068-fix.patch
@@ -0,0 +1,44 @@
+See http://gcc.gnu.org/PR15068
+
+Fixes error
+
+../sysdeps/generic/s_fmax.c: In function `__fmax':
+../sysdeps/generic/s_fmax.c:28: internal compiler error: in elim_reg_cond, at flow.c:3257
+Please submit a full bug report,
+with preprocessed source if appropriate.
+See <URL:http://gcc.gnu.org/bugs.html> for instructions.
+make[2]: *** [/home/dank/wk/crosstool-0.28-rc35/build/arm-unknown-linux-gnu/gcc-3.4.1-glibc-20040822/build-glibc/math/s_fmax.o] Error 1
+make[2]: Leaving directory `/home/dank/wk/crosstool-0.28-rc35/build/arm-unknown-linux-gnu/gcc-3.4.1-glibc-20040822/glibc-20040822/math'
+make[1]: *** [math/others] Error 2
+make[1]: Leaving directory `/home/dank/wk/crosstool-0.28-rc35/build/arm-unknown-linux-gnu/gcc-3.4.1-glibc-20040822/glibc-20040822'
+make: *** [all] Error 2
+
+[ rediffed against gcc-3.4.1, with elbow grease, ending up with same thing as
+http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/flow.c.diff?cvsroot=gcc&only_with_tag=csl-arm-branch&r1=1.563.4.2&r2=1.563.4.3 ]
+
+--- gcc-3.4.1/gcc/flow.c.old 2004-02-27 19:39:19.000000000 -0800
++++ gcc-3.4.1/gcc/flow.c 2004-08-26 07:29:46.000000000 -0700
+@@ -1878,6 +1878,7 @@
+ rtx set_src = SET_SRC (pc_set (BB_END (bb)));
+ rtx cond_true = XEXP (set_src, 0);
+ rtx reg = XEXP (cond_true, 0);
++ enum rtx_code inv_cond;
+
+ if (GET_CODE (reg) == SUBREG)
+ reg = SUBREG_REG (reg);
+@@ -1886,11 +1887,13 @@
+ in the form of a comparison of a register against zero.
+ If the condition is more complex than that, then it is safe
+ not to record any information. */
+- if (GET_CODE (reg) == REG
++ inv_cond = reversed_comparison_code (cond_true, BB_END (bb));
++ if (inv_cond != UNKNOWN
++ && GET_CODE (reg) == REG
+ && XEXP (cond_true, 1) == const0_rtx)
+ {
+ rtx cond_false
+- = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond_true)),
++ = gen_rtx_fmt_ee (inv_cond,
+ GET_MODE (cond_true), XEXP (cond_true, 0),
+ XEXP (cond_true, 1));
+ if (GET_CODE (XEXP (set_src, 1)) == PC)
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/71_all_sh-pr16665-fix.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/71_all_sh-pr16665-fix.patch
new file mode 100644
index 0000000000..680bb3978d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/71_all_sh-pr16665-fix.patch
@@ -0,0 +1,43 @@
+--- gcc/gcc/config/sh/sh.c
++++ gcc/gcc/config/sh/sh.c
+@@ -9106,6 +9106,15 @@ sh_output_mi_thunk (FILE *file, tree thu
+ }
+ this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
+
++ /* In PIC case, we set PIC register to compute the target address. We
++ can use a scratch register to save and restore the original value
++ except for SHcompact. For SHcompact, use stack. */
++ if (flag_pic && TARGET_SHCOMPACT)
++ {
++ push (PIC_OFFSET_TABLE_REGNUM);
++ emit_insn (gen_GOTaddr2picreg ());
++ }
++
+ /* For SHcompact, we only have r0 for a scratch register: r1 is the
+ static chain pointer (even if you can't have nested virtual functions
+ right now, someone might implement them sometime), and the rest of the
+@@ -9188,8 +9197,24 @@ sh_output_mi_thunk (FILE *file, tree thu
+ assemble_external (function);
+ TREE_USED (function) = 1;
+ }
++ /* We can use scratch1 to save and restore the original value of
++ PIC register except for SHcompact. */
++ if (flag_pic && ! TARGET_SHCOMPACT)
++ {
++ emit_move_insn (scratch1,
++ gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
++ emit_insn (gen_GOTaddr2picreg ());
++ }
+ funexp = XEXP (DECL_RTL (function), 0);
+ emit_move_insn (scratch2, funexp);
++ if (flag_pic)
++ {
++ if (! TARGET_SHCOMPACT)
++ emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
++ scratch1);
++ else
++ pop (PIC_OFFSET_TABLE_REGNUM);
++ }
+ funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
+ sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
+ SIBLING_CALL_P (sibcall) = 1;
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch
new file mode 100644
index 0000000000..8b9826831b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch
@@ -0,0 +1,13 @@
+--- g/gcc/config/sh/sh.h
++++ g/gcc/config/sh/sh.h
+@@ -422,6 +422,10 @@
+ do { \
+ if (LEVEL) \
+ flag_omit_frame_pointer = -1; \
++ if (LEVEL <= 2) \
++ { \
++ flag_reorder_blocks = 0; \
++ } \
+ if (SIZE) \
+ target_flags |= SPACE_BIT; \
+ if (TARGET_SHMEDIA && LEVEL > 1) \
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/73_all_sh-pr20617.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/73_all_sh-pr20617.patch
new file mode 100644
index 0000000000..6d8021cc70
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/73_all_sh-pr20617.patch
@@ -0,0 +1,28 @@
+2005-03-24 J"orn Rennecke <joern.rennecke@st.com>
+
+ Band aid for PR target/20617:
+ * config/sh/lib1funcs.asm (FUNC, ALIAS): Add .hidden directive.
+
+--- g/gcc/config/sh/lib1funcs.asm
++++ g/gcc/config/sh/lib1funcs.asm
+@@ -37,9 +37,19 @@ Boston, MA 02111-1307, USA. */
+ ELF local label prefixes by J"orn Rennecke
+ amylaar@cygnus.com */
+
++#define ALIAS(X,Y) .global GLOBAL(X); .set GLOBAL(X),GLOBAL(Y)
++
+ #ifdef __ELF__
+ #define LOCAL(X) .L_##X
+-#define FUNC(X) .type X,@function
++
++#if 1 /* ??? The export list mechanism is broken, everything that is not
++ hidden is exported. */
++#undef FUNC
++#define FUNC(X) .type X,@function; .hidden X
++#undef ALIAS
++#define ALIAS(X,Y) .global GLOBAL(X); .set GLOBAL(X),GLOBAL(Y); .hidden GLOBAL(X)
++#endif
++
+ #define ENDFUNC0(X) .Lfe_##X: .size X,.Lfe_##X-X
+ #define ENDFUNC(X) ENDFUNC0(X)
+ #else
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/800-arm-bigendian.patch
new file mode 100644
index 0000000000..04e9984196
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/800-arm-bigendian.patch
@@ -0,0 +1,68 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-3.4.1-dist/gcc/config/arm/linux-elf.h
++++ gcc-3.4.1/gcc/config/arm/linux-elf.h
+@@ -30,17 +30,34 @@
+ /* Do not assume anything about header files. */
+ #define NO_IMPLICIT_EXTERN_C
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT ARM_FLAG_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ /* Default is to use APCS-32 mode. */
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
++#define TARGET_DEFAULT \
++ ( ARM_FLAG_APCS_32 | \
++ ARM_FLAG_MMU_TRAPS | \
++ TARGET_ENDIAN_DEFAULT )
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mapcs-32", "mno-thumb-interwork" }
+
+ #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
+
+@@ -101,7 +118,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+ #endif
+
+--- gcc-3.4.1-dist/gcc/config.gcc
++++ gcc-3.4.1/gcc/config.gcc
+@@ -672,6 +672,11 @@
+ ;;
+ arm*-*-linux*) # ARM GNU/Linux with ELF
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h arm/aout.h arm/arm.h"
++ case $target in
++ arm*b-*)
++ tm_defines="TARGET_BIG_ENDIAN_DEFAULT=1 $tm_defines"
++ ;;
++ esac
+ tmake_file="t-slibgcc-elf-ver t-linux arm/t-linux"
+ extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+ gnu_ld=yes
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch
new file mode 100644
index 0000000000..a209470f7a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch
@@ -0,0 +1,15 @@
+--- gcc-3.4.4/gcc/config/rs6000/linux-unwind.h.org 2005-06-23 17:50:34.000000000 -0600
++++ gcc-3.4.4/gcc/config/rs6000/linux-unwind.h 2005-06-23 17:52:02.000000000 -0600
+@@ -32,6 +32,7 @@
+ these structs elsewhere; Many fields are missing, particularly
+ from the end of the structures. */
+
++#ifndef inhibit_libc
+ struct gcc_vregs
+ {
+ __attribute__ ((vector_size (16))) int vr[32];
+@@ -320,3 +321,4 @@
+ \
+ goto SUCCESS; \
+ } while (0)
++#endif
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/810-mips-xgot.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/810-mips-xgot.patch
new file mode 100644
index 0000000000..14e8d126e0
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/810-mips-xgot.patch
@@ -0,0 +1,6 @@
+--- gcc.orig/gcc/config/mips/t-linux 1970-01-01 01:00:00.000000000 +0100
++++ gcc/gcc/config/mips/t-linux 2004-08-26 18:28:12.000000000 +0200
+@@ -0,0 +1,3 @@
++# Compile crtbegin/end with xgot so it works for both
++# normal and large GOTs.
++CRTSTUFF_T_CFLAGS = -mxgot
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/900-nios2.patch b/cleopatre/buildroot/toolchain/gcc/3.4.6/900-nios2.patch
new file mode 100644
index 0000000000..3a84d01ab7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/900-nios2.patch
@@ -0,0 +1,14377 @@
+diff --git a/config.sub b/config.sub
+index d2e3557..2297c30 100755
+--- a/config.sub
++++ b/config.sub
+@@ -276,6 +276,15 @@ case $basic_machine in
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
++ # JBG
++ nios2 | nios2-* | nios2el | nios2el-*)
++ basic_machine=nios2-altera
++ os=-none_el
++ ;;
++ nios2eb | nios2eb-*)
++ basic_machine=nios2-altera
++ os=-none_eb
++ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+
+diff --git a/gcc/combine.c b/gcc/combine.c
+index 8f43c23..02648b1 100644
+--- a/gcc/combine.c
++++ b/gcc/combine.c
+@@ -4381,6 +4381,14 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int last,
+ mode);
+ }
+
++#ifndef __nios2__
++/* This screws up Nios II in this test case:
++
++if (x & 1)
++ return 2;
++else
++ return 3;
++*/
+ else if (STORE_FLAG_VALUE == 1
+ && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
+ && op1 == const0_rtx
+@@ -4392,6 +4400,7 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int last,
+ gen_lowpart_for_combine (mode, op0),
+ const1_rtx);
+ }
++#endif
+
+ else if (STORE_FLAG_VALUE == 1
+ && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index d22f34b..4ecb6e9 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1337,6 +1337,17 @@ m32rle-*-linux*)
+ thread_file='posix'
+ fi
+ ;;
++# JBG
++nios2-*-elf*_eb)
++ tm_file="elfos.h nios2/big.h ${tm_file}"
++ ;;
++nios2-*-elf*)
++ tm_file="elfos.h ${tm_file}"
++ ;;
++nios2-*-uclibc*) # Altera Nios2 running uClinux with uClibc
++ tm_file="elfos.h ${tm_file} nios2/nios2-uclibc.h"
++ tmake_file=nios2/t-nios2-uclibc
++ ;;
+ # m68hc11 and m68hc12 share the same machine description.
+ m68hc11-*-*|m6811-*-*)
+ tm_file="dbxelf.h elfos.h m68hc11/m68hc11.h"
+diff --git a/gcc/config/nios2/big.h b/gcc/config/nios2/big.h
+new file mode 100644
+index 0000000..b7b1731
+--- /dev/null
++++ b/gcc/config/nios2/big.h
+@@ -0,0 +1,23 @@
++/*
++ big.h - Additional definitions for nios2 targets that default to big-endian
++
++ Copyright (C) 2006 Altera
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++#define TARGET_ENDIAN_DEFAULT BIG_ENDIAN_FLAG
+diff --git a/gcc/config/nios2/crti.asm b/gcc/config/nios2/crti.asm
+new file mode 100644
+index 0000000..1fcfeb2
+--- /dev/null
++++ b/gcc/config/nios2/crti.asm
+@@ -0,0 +1,88 @@
++/*
++ Copyright (C) 2003
++ by Jonah Graham (jgraham@altera.com)
++
++This file is free software; you can redistribute it and/or modify it
++under the terms of the GNU General Public License as published by the
++Free Software Foundation; either version 2, or (at your option) any
++later version.
++
++In addition to the permissions in the GNU General Public License, the
++Free Software Foundation gives you unlimited permission to link the
++compiled version of this file with other programs, and to distribute
++those programs without any restriction coming from the use of this
++file. (The General Public License restrictions do apply in other
++respects; for example, they cover modification of the file, and
++distribution when not linked into another program.)
++
++This file is distributed in the hope that it will be useful, but
++WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA.
++
++ As a special exception, if you link this library with files
++ compiled with GCC to produce an executable, this does not cause
++ the resulting executable to be covered by the GNU General Public License.
++ This exception does not however invalidate any other reasons why
++ the executable file might be covered by the GNU General Public License.
++
++
++This file just make a stack frame for the contents of the .fini and
++.init sections. Users may put any desired instructions in those
++sections.
++
++
++While technically any code can be put in the init and fini sections
++most stuff will not work other than stuff which obeys the call frame
++and ABI. All the call-preserved registers are saved, the call clobbered
++registers should have been saved by the code calling init and fini.
++
++See crtstuff.c for an example of code that inserts itself in the
++init and fini sections.
++
++See crt0.s for the code that calls init and fini.
++*/
++
++ .file "crti.asm"
++
++ .section ".init"
++ .align 2
++ .global _init
++_init:
++ addi sp, sp, -48
++ stw ra, 44(sp)
++ stw r23, 40(sp)
++ stw r22, 36(sp)
++ stw r21, 32(sp)
++ stw r20, 28(sp)
++ stw r19, 24(sp)
++ stw r18, 20(sp)
++ stw r17, 16(sp)
++ stw r16, 12(sp)
++ stw fp, 8(sp)
++ mov fp, sp
++
++
++ .section ".fini"
++ .align 2
++ .global _fini
++_fini:
++ addi sp, sp, -48
++ stw ra, 44(sp)
++ stw r23, 40(sp)
++ stw r22, 36(sp)
++ stw r21, 32(sp)
++ stw r20, 28(sp)
++ stw r19, 24(sp)
++ stw r18, 20(sp)
++ stw r17, 16(sp)
++ stw r16, 12(sp)
++ stw fp, 8(sp)
++ mov fp, sp
++
++
+diff --git a/gcc/config/nios2/crtn.asm b/gcc/config/nios2/crtn.asm
+new file mode 100644
+index 0000000..e337480
+--- /dev/null
++++ b/gcc/config/nios2/crtn.asm
+@@ -0,0 +1,70 @@
++/*
++ Copyright (C) 2003
++ by Jonah Graham (jgraham@altera.com)
++
++This file is free software; you can redistribute it and/or modify it
++under the terms of the GNU General Public License as published by the
++Free Software Foundation; either version 2, or (at your option) any
++later version.
++
++In addition to the permissions in the GNU General Public License, the
++Free Software Foundation gives you unlimited permission to link the
++compiled version of this file with other programs, and to distribute
++those programs without any restriction coming from the use of this
++file. (The General Public License restrictions do apply in other
++respects; for example, they cover modification of the file, and
++distribution when not linked into another program.)
++
++This file is distributed in the hope that it will be useful, but
++WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA.
++
++ As a special exception, if you link this library with files
++ compiled with GCC to produce an executable, this does not cause
++ the resulting executable to be covered by the GNU General Public License.
++ This exception does not however invalidate any other reasons why
++ the executable file might be covered by the GNU General Public License.
++
++
++This file just makes sure that the .fini and .init sections do in
++fact return. Users may put any desired instructions in those sections.
++This file is the last thing linked into any executable.
++*/
++ .file "crtn.asm"
++
++
++
++ .section ".init"
++ ldw ra, 44(sp)
++ ldw r23, 40(sp)
++ ldw r22, 36(sp)
++ ldw r21, 32(sp)
++ ldw r20, 28(sp)
++ ldw r19, 24(sp)
++ ldw r18, 20(sp)
++ ldw r17, 16(sp)
++ ldw r16, 12(sp)
++ ldw fp, 8(sp)
++ addi sp, sp, -48
++ ret
++
++ .section ".fini"
++ ldw ra, 44(sp)
++ ldw r23, 40(sp)
++ ldw r22, 36(sp)
++ ldw r21, 32(sp)
++ ldw r20, 28(sp)
++ ldw r19, 24(sp)
++ ldw r18, 20(sp)
++ ldw r17, 16(sp)
++ ldw r16, 12(sp)
++ ldw fp, 8(sp)
++ addi sp, sp, -48
++ ret
++
+diff --git a/gcc/config/nios2/lib2-divmod-hi.c b/gcc/config/nios2/lib2-divmod-hi.c
+new file mode 100644
+index 0000000..10bd6e4
+--- /dev/null
++++ b/gcc/config/nios2/lib2-divmod-hi.c
+@@ -0,0 +1,123 @@
++
++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
++ supposedly valid even though this is a "target" file. */
++#include "auto-host.h"
++
++
++#include "tconfig.h"
++#include "tsystem.h"
++#include "coretypes.h"
++#include "tm.h"
++
++
++/* Don't use `fancy_abort' here even if config.h says to use it. */
++#ifdef abort
++#undef abort
++#endif
++
++
++#ifdef HAVE_GAS_HIDDEN
++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
++#else
++#define ATTRIBUTE_HIDDEN
++#endif
++
++#include "libgcc2.h"
++
++extern HItype __modhi3 (HItype, HItype);
++extern HItype __divhi3 (HItype, HItype);
++extern HItype __umodhi3 (HItype, HItype);
++extern HItype __udivhi3 (HItype, HItype);
++
++static UHItype udivmodhi4(UHItype, UHItype, word_type);
++
++static UHItype
++udivmodhi4(UHItype num, UHItype den, word_type modwanted)
++{
++ UHItype bit = 1;
++ UHItype res = 0;
++
++ while (den < num && bit && !(den & (1L<<15)))
++ {
++ den <<=1;
++ bit <<=1;
++ }
++ while (bit)
++ {
++ if (num >= den)
++ {
++ num -= den;
++ res |= bit;
++ }
++ bit >>=1;
++ den >>=1;
++ }
++ if (modwanted) return num;
++ return res;
++}
++
++
++HItype
++__divhi3 (HItype a, HItype b)
++{
++ word_type neg = 0;
++ HItype res;
++
++ if (a < 0)
++ {
++ a = -a;
++ neg = !neg;
++ }
++
++ if (b < 0)
++ {
++ b = -b;
++ neg = !neg;
++ }
++
++ res = udivmodhi4 (a, b, 0);
++
++ if (neg)
++ res = -res;
++
++ return res;
++}
++
++
++HItype
++__modhi3 (HItype a, HItype b)
++{
++ word_type neg = 0;
++ HItype res;
++
++ if (a < 0)
++ {
++ a = -a;
++ neg = 1;
++ }
++
++ if (b < 0)
++ b = -b;
++
++ res = udivmodhi4 (a, b, 1);
++
++ if (neg)
++ res = -res;
++
++ return res;
++}
++
++
++HItype
++__udivhi3 (HItype a, HItype b)
++{
++ return udivmodhi4 (a, b, 0);
++}
++
++
++HItype
++__umodhi3 (HItype a, HItype b)
++{
++ return udivmodhi4 (a, b, 1);
++}
++
+diff --git a/gcc/config/nios2/lib2-divmod.c b/gcc/config/nios2/lib2-divmod.c
+new file mode 100644
+index 0000000..00e730d
+--- /dev/null
++++ b/gcc/config/nios2/lib2-divmod.c
+@@ -0,0 +1,126 @@
++
++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
++ supposedly valid even though this is a "target" file. */
++#include "auto-host.h"
++
++
++#include "tconfig.h"
++#include "tsystem.h"
++#include "coretypes.h"
++#include "tm.h"
++
++
++/* Don't use `fancy_abort' here even if config.h says to use it. */
++#ifdef abort
++#undef abort
++#endif
++
++
++#ifdef HAVE_GAS_HIDDEN
++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
++#else
++#define ATTRIBUTE_HIDDEN
++#endif
++
++#include "libgcc2.h"
++
++extern SItype __modsi3 (SItype, SItype);
++extern SItype __divsi3 (SItype, SItype);
++extern SItype __umodsi3 (SItype, SItype);
++extern SItype __udivsi3 (SItype, SItype);
++
++static USItype udivmodsi4(USItype, USItype, word_type);
++
++/* 16-bit SI divide and modulo as used in NIOS */
++
++
++static USItype
++udivmodsi4(USItype num, USItype den, word_type modwanted)
++{
++ USItype bit = 1;
++ USItype res = 0;
++
++ while (den < num && bit && !(den & (1L<<31)))
++ {
++ den <<=1;
++ bit <<=1;
++ }
++ while (bit)
++ {
++ if (num >= den)
++ {
++ num -= den;
++ res |= bit;
++ }
++ bit >>=1;
++ den >>=1;
++ }
++ if (modwanted) return num;
++ return res;
++}
++
++
++SItype
++__divsi3 (SItype a, SItype b)
++{
++ word_type neg = 0;
++ SItype res;
++
++ if (a < 0)
++ {
++ a = -a;
++ neg = !neg;
++ }
++
++ if (b < 0)
++ {
++ b = -b;
++ neg = !neg;
++ }
++
++ res = udivmodsi4 (a, b, 0);
++
++ if (neg)
++ res = -res;
++
++ return res;
++}
++
++
++SItype
++__modsi3 (SItype a, SItype b)
++{
++ word_type neg = 0;
++ SItype res;
++
++ if (a < 0)
++ {
++ a = -a;
++ neg = 1;
++ }
++
++ if (b < 0)
++ b = -b;
++
++ res = udivmodsi4 (a, b, 1);
++
++ if (neg)
++ res = -res;
++
++ return res;
++}
++
++
++SItype
++__udivsi3 (SItype a, SItype b)
++{
++ return udivmodsi4 (a, b, 0);
++}
++
++
++SItype
++__umodsi3 (SItype a, SItype b)
++{
++ return udivmodsi4 (a, b, 1);
++}
++
+diff --git a/gcc/config/nios2/lib2-divtable.c b/gcc/config/nios2/lib2-divtable.c
+new file mode 100644
+index 0000000..48a7bd7
+--- /dev/null
++++ b/gcc/config/nios2/lib2-divtable.c
+@@ -0,0 +1,46 @@
++
++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
++ supposedly valid even though this is a "target" file. */
++#include "auto-host.h"
++
++
++#include "tconfig.h"
++#include "tsystem.h"
++#include "coretypes.h"
++#include "tm.h"
++
++
++/* Don't use `fancy_abort' here even if config.h says to use it. */
++#ifdef abort
++#undef abort
++#endif
++
++
++#ifdef HAVE_GAS_HIDDEN
++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
++#else
++#define ATTRIBUTE_HIDDEN
++#endif
++
++#include "libgcc2.h"
++
++UQItype __divsi3_table[] =
++{
++ 0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7, 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
++ 0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
++ 0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7, 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
++ 0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7, 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
++ 0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7, 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
++ 0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7, 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
++ 0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7, 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
++ 0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7, 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
++ 0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7, 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
++ 0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7, 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
++ 0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7, 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
++ 0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7, 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
++ 0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7, 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
++ 0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7, 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
++ 0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7, 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
++ 0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7, 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
++};
++
+diff --git a/gcc/config/nios2/lib2-mul.c b/gcc/config/nios2/lib2-mul.c
+new file mode 100644
+index 0000000..8511b33
+--- /dev/null
++++ b/gcc/config/nios2/lib2-mul.c
+@@ -0,0 +1,103 @@
++/* while we are debugging (ie compile outside of gcc build)
++ disable gcc specific headers */
++#ifndef DEBUG_MULSI3
++
++
++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
++ supposedly valid even though this is a "target" file. */
++#include "auto-host.h"
++
++
++#include "tconfig.h"
++#include "tsystem.h"
++#include "coretypes.h"
++#include "tm.h"
++
++
++/* Don't use `fancy_abort' here even if config.h says to use it. */
++#ifdef abort
++#undef abort
++#endif
++
++
++#ifdef HAVE_GAS_HIDDEN
++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
++#else
++#define ATTRIBUTE_HIDDEN
++#endif
++
++#include "libgcc2.h"
++
++#else
++#define SItype int
++#define USItype unsigned int
++#endif
++
++
++extern SItype __mulsi3 (SItype, SItype);
++
++SItype
++__mulsi3 (SItype a, SItype b)
++{
++ SItype res = 0;
++ USItype cnt = a;
++
++ while (cnt)
++ {
++ if (cnt & 1)
++ {
++ res += b;
++ }
++ b <<= 1;
++ cnt >>= 1;
++ }
++
++ return res;
++}
++/*
++TODO: Choose best alternative implementation.
++
++SItype
++__divsi3 (SItype a, SItype b)
++{
++ SItype res = 0;
++ USItype cnt = 0;
++
++ while (cnt < 32)
++ {
++ if (a & (1L << cnt))
++ {
++ res += b;
++ }
++ b <<= 1;
++ cnt++;
++ }
++
++ return res;
++}
++*/
++
++
++#ifdef DEBUG_MULSI3
++
++int
++main ()
++{
++ int i, j;
++ int error = 0;
++
++ for (i = -1000; i < 1000; i++)
++ for (j = -1000; j < 1000; j++)
++ {
++ int expect = i * j;
++ int actual = A__divsi3 (i, j);
++ if (expect != actual)
++ {
++ printf ("error: %d * %d = %d not %d\n", i, j, expect, actual);
++ error = 1;
++ }
++ }
++
++ return error;
++}
++#endif
+diff --git a/gcc/config/nios2/nios2-dp-bit.c b/gcc/config/nios2/nios2-dp-bit.c
+new file mode 100644
+index 0000000..4d63748
+--- /dev/null
++++ b/gcc/config/nios2/nios2-dp-bit.c
+@@ -0,0 +1,1655 @@
++
++#ifndef __nios2_big_endian__
++#define FLOAT_BIT_ORDER_MISMATCH
++#endif
++/* This is a software floating point library which can be used
++ for targets without hardware floating point.
++ Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
++ Free Software Foundation, Inc.
++
++This file is free software; you can redistribute it and/or modify it
++under the terms of the GNU General Public License as published by the
++Free Software Foundation; either version 2, or (at your option) any
++later version.
++
++In addition to the permissions in the GNU General Public License, the
++Free Software Foundation gives you unlimited permission to link the
++compiled version of this file with other programs, and to distribute
++those programs without any restriction coming from the use of this
++file. (The General Public License restrictions do apply in other
++respects; for example, they cover modification of the file, and
++distribution when not linked into another program.)
++
++This file is distributed in the hope that it will be useful, but
++WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++/* As a special exception, if you link this library with other files,
++ some of which are compiled with GCC, to produce an executable,
++ this library does not by itself cause the resulting executable
++ to be covered by the GNU General Public License.
++ This exception does not however invalidate any other reasons why
++ the executable file might be covered by the GNU General Public License. */
++
++/* This implements IEEE 754 format arithmetic, but does not provide a
++ mechanism for setting the rounding mode, or for generating or handling
++ exceptions.
++
++ The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
++ Wilson, all of Cygnus Support. */
++
++/* The intended way to use this file is to make two copies, add `#define FLOAT'
++ to one copy, then compile both copies and add them to libgcc.a. */
++
++#include "tconfig.h"
++#include "coretypes.h"
++#include "tm.h"
++#include "config/fp-bit.h"
++
++/* The following macros can be defined to change the behavior of this file:
++ FLOAT: Implement a `float', aka SFmode, fp library. If this is not
++ defined, then this file implements a `double', aka DFmode, fp library.
++ FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
++ don't include float->double conversion which requires the double library.
++ This is useful only for machines which can't support doubles, e.g. some
++ 8-bit processors.
++ CMPtype: Specify the type that floating point compares should return.
++ This defaults to SItype, aka int.
++ US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
++ US Software goFast library.
++ _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
++ two integers to the FLO_union_type.
++ NO_DENORMALS: Disable handling of denormals.
++ NO_NANS: Disable nan and infinity handling
++ SMALL_MACHINE: Useful when operations on QIs and HIs are faster
++ than on an SI */
++
++/* We don't currently support extended floats (long doubles) on machines
++ without hardware to deal with them.
++
++ These stubs are just to keep the linker from complaining about unresolved
++ references which can be pulled in from libio & libstdc++, even if the
++ user isn't using long doubles. However, they may generate an unresolved
++ external to abort if abort is not used by the function, and the stubs
++ are referenced from within libc, since libgcc goes before and after the
++ system library. */
++
++#ifdef DECLARE_LIBRARY_RENAMES
++ DECLARE_LIBRARY_RENAMES
++#endif
++
++#ifdef EXTENDED_FLOAT_STUBS
++extern void abort (void);
++void __extendsfxf2 (void) { abort(); }
++void __extenddfxf2 (void) { abort(); }
++void __truncxfdf2 (void) { abort(); }
++void __truncxfsf2 (void) { abort(); }
++void __fixxfsi (void) { abort(); }
++void __floatsixf (void) { abort(); }
++void __addxf3 (void) { abort(); }
++void __subxf3 (void) { abort(); }
++void __mulxf3 (void) { abort(); }
++void __divxf3 (void) { abort(); }
++void __negxf2 (void) { abort(); }
++void __eqxf2 (void) { abort(); }
++void __nexf2 (void) { abort(); }
++void __gtxf2 (void) { abort(); }
++void __gexf2 (void) { abort(); }
++void __lexf2 (void) { abort(); }
++void __ltxf2 (void) { abort(); }
++
++void __extendsftf2 (void) { abort(); }
++void __extenddftf2 (void) { abort(); }
++void __trunctfdf2 (void) { abort(); }
++void __trunctfsf2 (void) { abort(); }
++void __fixtfsi (void) { abort(); }
++void __floatsitf (void) { abort(); }
++void __addtf3 (void) { abort(); }
++void __subtf3 (void) { abort(); }
++void __multf3 (void) { abort(); }
++void __divtf3 (void) { abort(); }
++void __negtf2 (void) { abort(); }
++void __eqtf2 (void) { abort(); }
++void __netf2 (void) { abort(); }
++void __gttf2 (void) { abort(); }
++void __getf2 (void) { abort(); }
++void __letf2 (void) { abort(); }
++void __lttf2 (void) { abort(); }
++#else /* !EXTENDED_FLOAT_STUBS, rest of file */
++
++/* IEEE "special" number predicates */
++
++#ifdef NO_NANS
++
++#define nan() 0
++#define isnan(x) 0
++#define isinf(x) 0
++#else
++
++#if defined L_thenan_sf
++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined L_thenan_df
++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined L_thenan_tf
++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined TFLOAT
++extern const fp_number_type __thenan_tf;
++#elif defined FLOAT
++extern const fp_number_type __thenan_sf;
++#else
++extern const fp_number_type __thenan_df;
++#endif
++
++INLINE
++static fp_number_type *
++nan (void)
++{
++ /* Discard the const qualifier... */
++#ifdef TFLOAT
++ return (fp_number_type *) (& __thenan_tf);
++#elif defined FLOAT
++ return (fp_number_type *) (& __thenan_sf);
++#else
++ return (fp_number_type *) (& __thenan_df);
++#endif
++}
++
++INLINE
++static int
++isnan ( fp_number_type * x)
++{
++ return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
++}
++
++INLINE
++static int
++isinf ( fp_number_type * x)
++{
++ return x->class == CLASS_INFINITY;
++}
++
++#endif /* NO_NANS */
++
++INLINE
++static int
++iszero ( fp_number_type * x)
++{
++ return x->class == CLASS_ZERO;
++}
++
++INLINE
++static void
++flip_sign ( fp_number_type * x)
++{
++ x->sign = !x->sign;
++}
++
++extern FLO_type pack_d ( fp_number_type * );
++
++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
++FLO_type
++pack_d ( fp_number_type * src)
++{
++ FLO_union_type dst;
++ fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
++ int sign = src->sign;
++ int exp = 0;
++
++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
++ {
++ /* We can't represent these values accurately. By using the
++ largest possible magnitude, we guarantee that the conversion
++ of infinity is at least as big as any finite number. */
++ exp = EXPMAX;
++ fraction = ((fractype) 1 << FRACBITS) - 1;
++ }
++ else if (isnan (src))
++ {
++ exp = EXPMAX;
++ if (src->class == CLASS_QNAN || 1)
++ {
++#ifdef QUIET_NAN_NEGATED
++ fraction |= QUIET_NAN - 1;
++#else
++ fraction |= QUIET_NAN;
++#endif
++ }
++ }
++ else if (isinf (src))
++ {
++ exp = EXPMAX;
++ fraction = 0;
++ }
++ else if (iszero (src))
++ {
++ exp = 0;
++ fraction = 0;
++ }
++ else if (fraction == 0)
++ {
++ exp = 0;
++ }
++ else
++ {
++ if (src->normal_exp < NORMAL_EXPMIN)
++ {
++#ifdef NO_DENORMALS
++ /* Go straight to a zero representation if denormals are not
++ supported. The denormal handling would be harmless but
++ isn't unnecessary. */
++ exp = 0;
++ fraction = 0;
++#else /* NO_DENORMALS */
++ /* This number's exponent is too low to fit into the bits
++ available in the number, so we'll store 0 in the exponent and
++ shift the fraction to the right to make up for it. */
++
++ int shift = NORMAL_EXPMIN - src->normal_exp;
++
++ exp = 0;
++
++ if (shift > FRAC_NBITS - NGARDS)
++ {
++ /* No point shifting, since it's more that 64 out. */
++ fraction = 0;
++ }
++ else
++ {
++ int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
++ fraction = (fraction >> shift) | lowbit;
++ }
++ if ((fraction & GARDMASK) == GARDMSB)
++ {
++ if ((fraction & (1 << NGARDS)))
++ fraction += GARDROUND + 1;
++ }
++ else
++ {
++ /* Add to the guards to round up. */
++ fraction += GARDROUND;
++ }
++ /* Perhaps the rounding means we now need to change the
++ exponent, because the fraction is no longer denormal. */
++ if (fraction >= IMPLICIT_1)
++ {
++ exp += 1;
++ }
++ fraction >>= NGARDS;
++#endif /* NO_DENORMALS */
++ }
++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
++ && src->normal_exp > EXPBIAS)
++ {
++ exp = EXPMAX;
++ fraction = 0;
++ }
++ else
++ {
++ exp = src->normal_exp + EXPBIAS;
++ if (!ROUND_TOWARDS_ZERO)
++ {
++ /* IF the gard bits are the all zero, but the first, then we're
++ half way between two numbers, choose the one which makes the
++ lsb of the answer 0. */
++ if ((fraction & GARDMASK) == GARDMSB)
++ {
++ if (fraction & (1 << NGARDS))
++ fraction += GARDROUND + 1;
++ }
++ else
++ {
++ /* Add a one to the guards to round up */
++ fraction += GARDROUND;
++ }
++ if (fraction >= IMPLICIT_2)
++ {
++ fraction >>= 1;
++ exp += 1;
++ }
++ }
++ fraction >>= NGARDS;
++
++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
++ {
++ /* Saturate on overflow. */
++ exp = EXPMAX;
++ fraction = ((fractype) 1 << FRACBITS) - 1;
++ }
++ }
++ }
++
++ /* We previously used bitfields to store the number, but this doesn't
++ handle little/big endian systems conveniently, so use shifts and
++ masks */
++#ifdef FLOAT_BIT_ORDER_MISMATCH
++ dst.bits.fraction = fraction;
++ dst.bits.exp = exp;
++ dst.bits.sign = sign;
++#else
++# if defined TFLOAT && defined HALFFRACBITS
++ {
++ halffractype high, low, unity;
++ int lowsign, lowexp;
++
++ unity = (halffractype) 1 << HALFFRACBITS;
++
++ /* Set HIGH to the high double's significand, masking out the implicit 1.
++ Set LOW to the low double's full significand. */
++ high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
++ low = fraction & (unity * 2 - 1);
++
++ /* Get the initial sign and exponent of the low double. */
++ lowexp = exp - HALFFRACBITS - 1;
++ lowsign = sign;
++
++ /* HIGH should be rounded like a normal double, making |LOW| <=
++ 0.5 ULP of HIGH. Assume round-to-nearest. */
++ if (exp < EXPMAX)
++ if (low > unity || (low == unity && (high & 1) == 1))
++ {
++ /* Round HIGH up and adjust LOW to match. */
++ high++;
++ if (high == unity)
++ {
++ /* May make it infinite, but that's OK. */
++ high = 0;
++ exp++;
++ }
++ low = unity * 2 - low;
++ lowsign ^= 1;
++ }
++
++ high |= (halffractype) exp << HALFFRACBITS;
++ high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
++
++ if (exp == EXPMAX || exp == 0 || low == 0)
++ low = 0;
++ else
++ {
++ while (lowexp > 0 && low < unity)
++ {
++ low <<= 1;
++ lowexp--;
++ }
++
++ if (lowexp <= 0)
++ {
++ halffractype roundmsb, round;
++ int shift;
++
++ shift = 1 - lowexp;
++ roundmsb = (1 << (shift - 1));
++ round = low & ((roundmsb << 1) - 1);
++
++ low >>= shift;
++ lowexp = 0;
++
++ if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
++ {
++ low++;
++ if (low == unity)
++ /* LOW rounds up to the smallest normal number. */
++ lowexp++;
++ }
++ }
++
++ low &= unity - 1;
++ low |= (halffractype) lowexp << HALFFRACBITS;
++ low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
++ }
++ dst.value_raw = ((fractype) high << HALFSHIFT) | low;
++ }
++# else
++ dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
++ dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
++ dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
++# endif
++#endif
++
++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
++#ifdef TFLOAT
++ {
++ qrtrfractype tmp1 = dst.words[0];
++ qrtrfractype tmp2 = dst.words[1];
++ dst.words[0] = dst.words[3];
++ dst.words[1] = dst.words[2];
++ dst.words[2] = tmp2;
++ dst.words[3] = tmp1;
++ }
++#else
++ {
++ halffractype tmp = dst.words[0];
++ dst.words[0] = dst.words[1];
++ dst.words[1] = tmp;
++ }
++#endif
++#endif
++
++ return dst.value;
++}
++#endif
++
++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
++void
++unpack_d (FLO_union_type * src, fp_number_type * dst)
++{
++ /* We previously used bitfields to store the number, but this doesn't
++ handle little/big endian systems conveniently, so use shifts and
++ masks */
++ fractype fraction;
++ int exp;
++ int sign;
++
++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
++ FLO_union_type swapped;
++
++#ifdef TFLOAT
++ swapped.words[0] = src->words[3];
++ swapped.words[1] = src->words[2];
++ swapped.words[2] = src->words[1];
++ swapped.words[3] = src->words[0];
++#else
++ swapped.words[0] = src->words[1];
++ swapped.words[1] = src->words[0];
++#endif
++ src = &swapped;
++#endif
++
++#ifdef FLOAT_BIT_ORDER_MISMATCH
++ fraction = src->bits.fraction;
++ exp = src->bits.exp;
++ sign = src->bits.sign;
++#else
++# if defined TFLOAT && defined HALFFRACBITS
++ {
++ halffractype high, low;
++
++ high = src->value_raw >> HALFSHIFT;
++ low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
++
++ fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
++ fraction <<= FRACBITS - HALFFRACBITS;
++ exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
++ sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
++
++ if (exp != EXPMAX && exp != 0 && low != 0)
++ {
++ int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
++ int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
++ int shift;
++ fractype xlow;
++
++ xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
++ if (lowexp)
++ xlow |= (((halffractype)1) << HALFFRACBITS);
++ else
++ lowexp = 1;
++ shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
++ if (shift > 0)
++ xlow <<= shift;
++ else if (shift < 0)
++ xlow >>= -shift;
++ if (sign == lowsign)
++ fraction += xlow;
++ else if (fraction >= xlow)
++ fraction -= xlow;
++ else
++ {
++ /* The high part is a power of two but the full number is lower.
++ This code will leave the implicit 1 in FRACTION, but we'd
++ have added that below anyway. */
++ fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
++ exp--;
++ }
++ }
++ }
++# else
++ fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
++ exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
++ sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
++# endif
++#endif
++
++ dst->sign = sign;
++ if (exp == 0)
++ {
++ /* Hmm. Looks like 0 */
++ if (fraction == 0
++#ifdef NO_DENORMALS
++ || 1
++#endif
++ )
++ {
++ /* tastes like zero */
++ dst->class = CLASS_ZERO;
++ }
++ else
++ {
++ /* Zero exponent with nonzero fraction - it's denormalized,
++ so there isn't a leading implicit one - we'll shift it so
++ it gets one. */
++ dst->normal_exp = exp - EXPBIAS + 1;
++ fraction <<= NGARDS;
++
++ dst->class = CLASS_NUMBER;
++#if 1
++ while (fraction < IMPLICIT_1)
++ {
++ fraction <<= 1;
++ dst->normal_exp--;
++ }
++#endif
++ dst->fraction.ll = fraction;
++ }
++ }
++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
++ {
++ /* Huge exponent*/
++ if (fraction == 0)
++ {
++ /* Attached to a zero fraction - means infinity */
++ dst->class = CLASS_INFINITY;
++ }
++ else
++ {
++ /* Nonzero fraction, means nan */
++#ifdef QUIET_NAN_NEGATED
++ if ((fraction & QUIET_NAN) == 0)
++#else
++ if (fraction & QUIET_NAN)
++#endif
++ {
++ dst->class = CLASS_QNAN;
++ }
++ else
++ {
++ dst->class = CLASS_SNAN;
++ }
++ /* Keep the fraction part as the nan number */
++ dst->fraction.ll = fraction;
++ }
++ }
++ else
++ {
++ /* Nothing strange about this number */
++ dst->normal_exp = exp - EXPBIAS;
++ dst->class = CLASS_NUMBER;
++ dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
++ }
++}
++#endif /* L_unpack_df || L_unpack_sf */
++
++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
++static fp_number_type *
++_fpadd_parts (fp_number_type * a,
++ fp_number_type * b,
++ fp_number_type * tmp)
++{
++ intfrac tfraction;
++
++ /* Put commonly used fields in local variables. */
++ int a_normal_exp;
++ int b_normal_exp;
++ fractype a_fraction;
++ fractype b_fraction;
++
++ if (isnan (a))
++ {
++ return a;
++ }
++ if (isnan (b))
++ {
++ return b;
++ }
++ if (isinf (a))
++ {
++ /* Adding infinities with opposite signs yields a NaN. */
++ if (isinf (b) && a->sign != b->sign)
++ return nan ();
++ return a;
++ }
++ if (isinf (b))
++ {
++ return b;
++ }
++ if (iszero (b))
++ {
++ if (iszero (a))
++ {
++ *tmp = *a;
++ tmp->sign = a->sign & b->sign;
++ return tmp;
++ }
++ return a;
++ }
++ if (iszero (a))
++ {
++ return b;
++ }
++
++ /* Got two numbers. shift the smaller and increment the exponent till
++ they're the same */
++ {
++ int diff;
++
++ a_normal_exp = a->normal_exp;
++ b_normal_exp = b->normal_exp;
++ a_fraction = a->fraction.ll;
++ b_fraction = b->fraction.ll;
++
++ diff = a_normal_exp - b_normal_exp;
++
++ if (diff < 0)
++ diff = -diff;
++ if (diff < FRAC_NBITS)
++ {
++ /* ??? This does shifts one bit at a time. Optimize. */
++ while (a_normal_exp > b_normal_exp)
++ {
++ b_normal_exp++;
++ LSHIFT (b_fraction);
++ }
++ while (b_normal_exp > a_normal_exp)
++ {
++ a_normal_exp++;
++ LSHIFT (a_fraction);
++ }
++ }
++ else
++ {
++ /* Somethings's up.. choose the biggest */
++ if (a_normal_exp > b_normal_exp)
++ {
++ b_normal_exp = a_normal_exp;
++ b_fraction = 0;
++ }
++ else
++ {
++ a_normal_exp = b_normal_exp;
++ a_fraction = 0;
++ }
++ }
++ }
++
++ if (a->sign != b->sign)
++ {
++ if (a->sign)
++ {
++ tfraction = -a_fraction + b_fraction;
++ }
++ else
++ {
++ tfraction = a_fraction - b_fraction;
++ }
++ if (tfraction >= 0)
++ {
++ tmp->sign = 0;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = tfraction;
++ }
++ else
++ {
++ tmp->sign = 1;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = -tfraction;
++ }
++ /* and renormalize it */
++
++ while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
++ {
++ tmp->fraction.ll <<= 1;
++ tmp->normal_exp--;
++ }
++ }
++ else
++ {
++ tmp->sign = a->sign;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = a_fraction + b_fraction;
++ }
++ tmp->class = CLASS_NUMBER;
++ /* Now the fraction is added, we have to shift down to renormalize the
++ number */
++
++ if (tmp->fraction.ll >= IMPLICIT_2)
++ {
++ LSHIFT (tmp->fraction.ll);
++ tmp->normal_exp++;
++ }
++ return tmp;
++
++}
++
++FLO_type
++add (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpadd_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++
++FLO_type
++sub (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ b.sign ^= 1;
++
++ res = _fpadd_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++#endif /* L_addsub_sf || L_addsub_df */
++
++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
++static inline __attribute__ ((__always_inline__)) fp_number_type *
++_fpmul_parts ( fp_number_type * a,
++ fp_number_type * b,
++ fp_number_type * tmp)
++{
++ fractype low = 0;
++ fractype high = 0;
++
++ if (isnan (a))
++ {
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (isnan (b))
++ {
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++ if (isinf (a))
++ {
++ if (iszero (b))
++ return nan ();
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (isinf (b))
++ {
++ if (iszero (a))
++ {
++ return nan ();
++ }
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++ if (iszero (a))
++ {
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (iszero (b))
++ {
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++
++ /* Calculate the mantissa by multiplying both numbers to get a
++ twice-as-wide number. */
++ {
++#if defined(NO_DI_MODE) || defined(TFLOAT)
++ {
++ fractype x = a->fraction.ll;
++ fractype ylow = b->fraction.ll;
++ fractype yhigh = 0;
++ int bit;
++
++ /* ??? This does multiplies one bit at a time. Optimize. */
++ for (bit = 0; bit < FRAC_NBITS; bit++)
++ {
++ int carry;
++
++ if (x & 1)
++ {
++ carry = (low += ylow) < ylow;
++ high += yhigh + carry;
++ }
++ yhigh <<= 1;
++ if (ylow & FRACHIGH)
++ {
++ yhigh |= 1;
++ }
++ ylow <<= 1;
++ x >>= 1;
++ }
++ }
++#elif defined(FLOAT)
++ /* Multiplying two USIs to get a UDI, we're safe. */
++ {
++ UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
++
++ high = answer >> BITS_PER_SI;
++ low = answer;
++ }
++#else
++ /* fractype is DImode, but we need the result to be twice as wide.
++ Assuming a widening multiply from DImode to TImode is not
++ available, build one by hand. */
++ {
++ USItype nl = a->fraction.ll;
++ USItype nh = a->fraction.ll >> BITS_PER_SI;
++ USItype ml = b->fraction.ll;
++ USItype mh = b->fraction.ll >> BITS_PER_SI;
++ UDItype pp_ll = (UDItype) ml * nl;
++ UDItype pp_hl = (UDItype) mh * nl;
++ UDItype pp_lh = (UDItype) ml * nh;
++ UDItype pp_hh = (UDItype) mh * nh;
++ UDItype res2 = 0;
++ UDItype res0 = 0;
++ UDItype ps_hh__ = pp_hl + pp_lh;
++ if (ps_hh__ < pp_hl)
++ res2 += (UDItype)1 << BITS_PER_SI;
++ pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
++ res0 = pp_ll + pp_hl;
++ if (res0 < pp_ll)
++ res2++;
++ res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
++ high = res2;
++ low = res0;
++ }
++#endif
++ }
++
++ tmp->normal_exp = a->normal_exp + b->normal_exp
++ + FRAC_NBITS - (FRACBITS + NGARDS);
++ tmp->sign = a->sign != b->sign;
++ while (high >= IMPLICIT_2)
++ {
++ tmp->normal_exp++;
++ if (high & 1)
++ {
++ low >>= 1;
++ low |= FRACHIGH;
++ }
++ high >>= 1;
++ }
++ while (high < IMPLICIT_1)
++ {
++ tmp->normal_exp--;
++
++ high <<= 1;
++ if (low & FRACHIGH)
++ high |= 1;
++ low <<= 1;
++ }
++ /* rounding is tricky. if we only round if it won't make us round later. */
++#if 0
++ if (low & FRACHIGH2)
++ {
++ if (((high & GARDMASK) != GARDMSB)
++ && (((high + 1) & GARDMASK) == GARDMSB))
++ {
++ /* don't round, it gets done again later. */
++ }
++ else
++ {
++ high++;
++ }
++ }
++#endif
++ if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
++ {
++ if (high & (1 << NGARDS))
++ {
++ /* half way, so round to even */
++ high += GARDROUND + 1;
++ }
++ else if (low)
++ {
++ /* but we really weren't half way */
++ high += GARDROUND + 1;
++ }
++ }
++ tmp->fraction.ll = high;
++ tmp->class = CLASS_NUMBER;
++ return tmp;
++}
++
++FLO_type
++multiply (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpmul_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++#endif /* L_mul_sf || L_mul_df */
++
++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
++static inline __attribute__ ((__always_inline__)) fp_number_type *
++_fpdiv_parts (fp_number_type * a,
++ fp_number_type * b)
++{
++ fractype bit;
++ fractype numerator;
++ fractype denominator;
++ fractype quotient;
++
++ if (isnan (a))
++ {
++ return a;
++ }
++ if (isnan (b))
++ {
++ return b;
++ }
++
++ a->sign = a->sign ^ b->sign;
++
++ if (isinf (a) || iszero (a))
++ {
++ if (a->class == b->class)
++ return nan ();
++ return a;
++ }
++
++ if (isinf (b))
++ {
++ a->fraction.ll = 0;
++ a->normal_exp = 0;
++ return a;
++ }
++ if (iszero (b))
++ {
++ a->class = CLASS_INFINITY;
++ return a;
++ }
++
++ /* Calculate the mantissa by multiplying both 64bit numbers to get a
++ 128 bit number */
++ {
++ /* quotient =
++ ( numerator / denominator) * 2^(numerator exponent - denominator exponent)
++ */
++
++ a->normal_exp = a->normal_exp - b->normal_exp;
++ numerator = a->fraction.ll;
++ denominator = b->fraction.ll;
++
++ if (numerator < denominator)
++ {
++ /* Fraction will be less than 1.0 */
++ numerator *= 2;
++ a->normal_exp--;
++ }
++ bit = IMPLICIT_1;
++ quotient = 0;
++ /* ??? Does divide one bit at a time. Optimize. */
++ while (bit)
++ {
++ if (numerator >= denominator)
++ {
++ quotient |= bit;
++ numerator -= denominator;
++ }
++ bit >>= 1;
++ numerator *= 2;
++ }
++
++ if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
++ {
++ if (quotient & (1 << NGARDS))
++ {
++ /* half way, so round to even */
++ quotient += GARDROUND + 1;
++ }
++ else if (numerator)
++ {
++ /* but we really weren't half way, more bits exist */
++ quotient += GARDROUND + 1;
++ }
++ }
++
++ a->fraction.ll = quotient;
++ return (a);
++ }
++}
++
++FLO_type
++divide (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpdiv_parts (&a, &b);
++
++ return pack_d (res);
++}
++#endif /* L_div_sf || L_div_df */
++
++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
++ || defined(L_fpcmp_parts_tf)
++/* according to the demo, fpcmp returns a comparison with 0... thus
++ a<b -> -1
++ a==b -> 0
++ a>b -> +1
++ */
++
++int
++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
++{
++#if 0
++ /* either nan -> unordered. Must be checked outside of this routine. */
++ if (isnan (a) && isnan (b))
++ {
++ return 1; /* still unordered! */
++ }
++#endif
++
++ if (isnan (a) || isnan (b))
++ {
++ return 1; /* how to indicate unordered compare? */
++ }
++ if (isinf (a) && isinf (b))
++ {
++ /* +inf > -inf, but +inf != +inf */
++ /* b \a| +inf(0)| -inf(1)
++ ______\+--------+--------
++ +inf(0)| a==b(0)| a<b(-1)
++ -------+--------+--------
++ -inf(1)| a>b(1) | a==b(0)
++ -------+--------+--------
++ So since unordered must be nonzero, just line up the columns...
++ */
++ return b->sign - a->sign;
++ }
++ /* but not both... */
++ if (isinf (a))
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (isinf (b))
++ {
++ return b->sign ? 1 : -1;
++ }
++ if (iszero (a) && iszero (b))
++ {
++ return 0;
++ }
++ if (iszero (a))
++ {
++ return b->sign ? 1 : -1;
++ }
++ if (iszero (b))
++ {
++ return a->sign ? -1 : 1;
++ }
++ /* now both are "normal". */
++ if (a->sign != b->sign)
++ {
++ /* opposite signs */
++ return a->sign ? -1 : 1;
++ }
++ /* same sign; exponents? */
++ if (a->normal_exp > b->normal_exp)
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (a->normal_exp < b->normal_exp)
++ {
++ return a->sign ? 1 : -1;
++ }
++ /* same exponents; check size. */
++ if (a->fraction.ll > b->fraction.ll)
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (a->fraction.ll < b->fraction.ll)
++ {
++ return a->sign ? 1 : -1;
++ }
++ /* after all that, they're equal. */
++ return 0;
++}
++#endif
++
++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
++CMPtype
++compare (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_compare_sf || L_compare_df */
++
++#ifndef US_SOFTWARE_GOFAST
++
++/* These should be optimized for their specific tasks someday. */
++
++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
++CMPtype
++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth == 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_eq_sf || L_eq_df */
++
++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
++CMPtype
++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* true, truth != 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_ne_sf || L_ne_df */
++
++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
++CMPtype
++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return -1; /* false, truth > 0 */
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_gt_sf || L_gt_df */
++
++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
++CMPtype
++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return -1; /* false, truth >= 0 */
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_ge_sf || L_ge_df */
++
++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
++CMPtype
++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth < 0 */
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_lt_sf || L_lt_df */
++
++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
++CMPtype
++_le_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth <= 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_le_sf || L_le_df */
++
++#endif /* ! US_SOFTWARE_GOFAST */
++
++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
++CMPtype
++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ return (isnan (&a) || isnan (&b));
++}
++#endif /* L_unord_sf || L_unord_df */
++
++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
++FLO_type
++si_to_float (SItype arg_a)
++{
++ fp_number_type in;
++
++ in.class = CLASS_NUMBER;
++ in.sign = arg_a < 0;
++ if (!arg_a)
++ {
++ in.class = CLASS_ZERO;
++ }
++ else
++ {
++ in.normal_exp = FRACBITS + NGARDS;
++ if (in.sign)
++ {
++ /* Special case for minint, since there is no +ve integer
++ representation for it */
++ if (arg_a == (- MAX_SI_INT - 1))
++ {
++ return (FLO_type)(- MAX_SI_INT - 1);
++ }
++ in.fraction.ll = (-arg_a);
++ }
++ else
++ in.fraction.ll = arg_a;
++
++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll <<= 1;
++ in.normal_exp -= 1;
++ }
++ }
++ return pack_d (&in);
++}
++#endif /* L_si_to_sf || L_si_to_df */
++
++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
++FLO_type
++usi_to_float (USItype arg_a)
++{
++ fp_number_type in;
++
++ in.sign = 0;
++ if (!arg_a)
++ {
++ in.class = CLASS_ZERO;
++ }
++ else
++ {
++ in.class = CLASS_NUMBER;
++ in.normal_exp = FRACBITS + NGARDS;
++ in.fraction.ll = arg_a;
++
++ while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll >>= 1;
++ in.normal_exp += 1;
++ }
++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll <<= 1;
++ in.normal_exp -= 1;
++ }
++ }
++ return pack_d (&in);
++}
++#endif
++
++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
++SItype
++float_to_si (FLO_type arg_a)
++{
++ fp_number_type a;
++ SItype tmp;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ if (iszero (&a))
++ return 0;
++ if (isnan (&a))
++ return 0;
++ /* get reasonable MAX_SI_INT... */
++ if (isinf (&a))
++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
++ /* it is a number, but a small one */
++ if (a.normal_exp < 0)
++ return 0;
++ if (a.normal_exp > BITS_PER_SI - 2)
++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
++ tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
++ return a.sign ? (-tmp) : (tmp);
++}
++#endif /* L_sf_to_si || L_df_to_si */
++
++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
++ we also define them for GOFAST because the ones in libgcc2.c have the
++ wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
++ out of libgcc2.c. We can't define these here if not GOFAST because then
++ there'd be duplicate copies. */
++
++USItype
++float_to_usi (FLO_type arg_a)
++{
++ fp_number_type a;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ if (iszero (&a))
++ return 0;
++ if (isnan (&a))
++ return 0;
++ /* it is a negative number */
++ if (a.sign)
++ return 0;
++ /* get reasonable MAX_USI_INT... */
++ if (isinf (&a))
++ return MAX_USI_INT;
++ /* it is a number, but a small one */
++ if (a.normal_exp < 0)
++ return 0;
++ if (a.normal_exp > BITS_PER_SI - 1)
++ return MAX_USI_INT;
++ else if (a.normal_exp > (FRACBITS + NGARDS))
++ return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
++ else
++ return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
++}
++#endif /* US_SOFTWARE_GOFAST */
++#endif /* L_sf_to_usi || L_df_to_usi */
++
++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
++FLO_type
++negate (FLO_type arg_a)
++{
++ fp_number_type a;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ flip_sign (&a);
++ return pack_d (&a);
++}
++#endif /* L_negate_sf || L_negate_df */
++
++#ifdef FLOAT
++
++#if defined(L_make_sf)
++SFtype
++__make_fp(fp_class_type class,
++ unsigned int sign,
++ int exp,
++ USItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_sf */
++
++#ifndef FLOAT_ONLY
++
++/* This enables one to build an fp library that supports float but not double.
++ Otherwise, we would get an undefined reference to __make_dp.
++ This is needed for some 8-bit ports that can't handle well values that
++ are 8-bytes in size, so we just don't support double for them at all. */
++
++#if defined(L_sf_to_df)
++DFtype
++sf_to_df (SFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_dp (in.class, in.sign, in.normal_exp,
++ ((UDItype) in.fraction.ll) << F_D_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#if defined(L_sf_to_tf) && defined(TMODES)
++TFtype
++sf_to_tf (SFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_tp (in.class, in.sign, in.normal_exp,
++ ((UTItype) in.fraction.ll) << F_T_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#endif /* ! FLOAT_ONLY */
++#endif /* FLOAT */
++
++#ifndef FLOAT
++
++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
++
++#if defined(L_make_df)
++DFtype
++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_df */
++
++#if defined(L_df_to_sf)
++SFtype
++df_to_sf (DFtype arg_a)
++{
++ fp_number_type in;
++ USItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> F_D_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_df_to_sf */
++
++#if defined(L_df_to_tf) && defined(TMODES) \
++ && !defined(FLOAT) && !defined(TFLOAT)
++TFtype
++df_to_tf (DFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_tp (in.class, in.sign, in.normal_exp,
++ ((UTItype) in.fraction.ll) << D_T_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#ifdef TFLOAT
++#if defined(L_make_tf)
++TFtype
++__make_tp(fp_class_type class,
++ unsigned int sign,
++ int exp,
++ UTItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_tf */
++
++#if defined(L_tf_to_df)
++DFtype
++tf_to_df (TFtype arg_a)
++{
++ fp_number_type in;
++ UDItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> D_T_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_tf_to_df */
++
++#if defined(L_tf_to_sf)
++SFtype
++tf_to_sf (TFtype arg_a)
++{
++ fp_number_type in;
++ USItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> F_T_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_tf_to_sf */
++#endif /* TFLOAT */
++
++#endif /* ! FLOAT */
++#endif /* !EXTENDED_FLOAT_STUBS */
+diff --git a/gcc/config/nios2/nios2-fp-bit.c b/gcc/config/nios2/nios2-fp-bit.c
+new file mode 100644
+index 0000000..839ffcc
+--- /dev/null
++++ b/gcc/config/nios2/nios2-fp-bit.c
+@@ -0,0 +1,1655 @@
++#define FLOAT
++#ifndef __nios2_big_endian__
++#define FLOAT_BIT_ORDER_MISMATCH
++#endif
++/* This is a software floating point library which can be used
++ for targets without hardware floating point.
++ Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
++ Free Software Foundation, Inc.
++
++This file is free software; you can redistribute it and/or modify it
++under the terms of the GNU General Public License as published by the
++Free Software Foundation; either version 2, or (at your option) any
++later version.
++
++In addition to the permissions in the GNU General Public License, the
++Free Software Foundation gives you unlimited permission to link the
++compiled version of this file with other programs, and to distribute
++those programs without any restriction coming from the use of this
++file. (The General Public License restrictions do apply in other
++respects; for example, they cover modification of the file, and
++distribution when not linked into another program.)
++
++This file is distributed in the hope that it will be useful, but
++WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++/* As a special exception, if you link this library with other files,
++ some of which are compiled with GCC, to produce an executable,
++ this library does not by itself cause the resulting executable
++ to be covered by the GNU General Public License.
++ This exception does not however invalidate any other reasons why
++ the executable file might be covered by the GNU General Public License. */
++
++/* This implements IEEE 754 format arithmetic, but does not provide a
++ mechanism for setting the rounding mode, or for generating or handling
++ exceptions.
++
++ The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
++ Wilson, all of Cygnus Support. */
++
++/* The intended way to use this file is to make two copies, add `#define FLOAT'
++ to one copy, then compile both copies and add them to libgcc.a. */
++
++#include "tconfig.h"
++#include "coretypes.h"
++#include "tm.h"
++#include "config/fp-bit.h"
++
++/* The following macros can be defined to change the behavior of this file:
++ FLOAT: Implement a `float', aka SFmode, fp library. If this is not
++ defined, then this file implements a `double', aka DFmode, fp library.
++ FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
++ don't include float->double conversion which requires the double library.
++ This is useful only for machines which can't support doubles, e.g. some
++ 8-bit processors.
++ CMPtype: Specify the type that floating point compares should return.
++ This defaults to SItype, aka int.
++ US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
++ US Software goFast library.
++ _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
++ two integers to the FLO_union_type.
++ NO_DENORMALS: Disable handling of denormals.
++ NO_NANS: Disable nan and infinity handling
++ SMALL_MACHINE: Useful when operations on QIs and HIs are faster
++ than on an SI */
++
++/* We don't currently support extended floats (long doubles) on machines
++ without hardware to deal with them.
++
++ These stubs are just to keep the linker from complaining about unresolved
++ references which can be pulled in from libio & libstdc++, even if the
++ user isn't using long doubles. However, they may generate an unresolved
++ external to abort if abort is not used by the function, and the stubs
++ are referenced from within libc, since libgcc goes before and after the
++ system library. */
++
++#ifdef DECLARE_LIBRARY_RENAMES
++ DECLARE_LIBRARY_RENAMES
++#endif
++
++#ifdef EXTENDED_FLOAT_STUBS
++extern void abort (void);
++void __extendsfxf2 (void) { abort(); }
++void __extenddfxf2 (void) { abort(); }
++void __truncxfdf2 (void) { abort(); }
++void __truncxfsf2 (void) { abort(); }
++void __fixxfsi (void) { abort(); }
++void __floatsixf (void) { abort(); }
++void __addxf3 (void) { abort(); }
++void __subxf3 (void) { abort(); }
++void __mulxf3 (void) { abort(); }
++void __divxf3 (void) { abort(); }
++void __negxf2 (void) { abort(); }
++void __eqxf2 (void) { abort(); }
++void __nexf2 (void) { abort(); }
++void __gtxf2 (void) { abort(); }
++void __gexf2 (void) { abort(); }
++void __lexf2 (void) { abort(); }
++void __ltxf2 (void) { abort(); }
++
++void __extendsftf2 (void) { abort(); }
++void __extenddftf2 (void) { abort(); }
++void __trunctfdf2 (void) { abort(); }
++void __trunctfsf2 (void) { abort(); }
++void __fixtfsi (void) { abort(); }
++void __floatsitf (void) { abort(); }
++void __addtf3 (void) { abort(); }
++void __subtf3 (void) { abort(); }
++void __multf3 (void) { abort(); }
++void __divtf3 (void) { abort(); }
++void __negtf2 (void) { abort(); }
++void __eqtf2 (void) { abort(); }
++void __netf2 (void) { abort(); }
++void __gttf2 (void) { abort(); }
++void __getf2 (void) { abort(); }
++void __letf2 (void) { abort(); }
++void __lttf2 (void) { abort(); }
++#else /* !EXTENDED_FLOAT_STUBS, rest of file */
++
++/* IEEE "special" number predicates */
++
++#ifdef NO_NANS
++
++#define nan() 0
++#define isnan(x) 0
++#define isinf(x) 0
++#else
++
++#if defined L_thenan_sf
++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined L_thenan_df
++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined L_thenan_tf
++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
++#elif defined TFLOAT
++extern const fp_number_type __thenan_tf;
++#elif defined FLOAT
++extern const fp_number_type __thenan_sf;
++#else
++extern const fp_number_type __thenan_df;
++#endif
++
++INLINE
++static fp_number_type *
++nan (void)
++{
++ /* Discard the const qualifier... */
++#ifdef TFLOAT
++ return (fp_number_type *) (& __thenan_tf);
++#elif defined FLOAT
++ return (fp_number_type *) (& __thenan_sf);
++#else
++ return (fp_number_type *) (& __thenan_df);
++#endif
++}
++
++INLINE
++static int
++isnan ( fp_number_type * x)
++{
++ return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
++}
++
++INLINE
++static int
++isinf ( fp_number_type * x)
++{
++ return x->class == CLASS_INFINITY;
++}
++
++#endif /* NO_NANS */
++
++INLINE
++static int
++iszero ( fp_number_type * x)
++{
++ return x->class == CLASS_ZERO;
++}
++
++INLINE
++static void
++flip_sign ( fp_number_type * x)
++{
++ x->sign = !x->sign;
++}
++
++extern FLO_type pack_d ( fp_number_type * );
++
++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
++FLO_type
++pack_d ( fp_number_type * src)
++{
++ FLO_union_type dst;
++ fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
++ int sign = src->sign;
++ int exp = 0;
++
++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
++ {
++ /* We can't represent these values accurately. By using the
++ largest possible magnitude, we guarantee that the conversion
++ of infinity is at least as big as any finite number. */
++ exp = EXPMAX;
++ fraction = ((fractype) 1 << FRACBITS) - 1;
++ }
++ else if (isnan (src))
++ {
++ exp = EXPMAX;
++ if (src->class == CLASS_QNAN || 1)
++ {
++#ifdef QUIET_NAN_NEGATED
++ fraction |= QUIET_NAN - 1;
++#else
++ fraction |= QUIET_NAN;
++#endif
++ }
++ }
++ else if (isinf (src))
++ {
++ exp = EXPMAX;
++ fraction = 0;
++ }
++ else if (iszero (src))
++ {
++ exp = 0;
++ fraction = 0;
++ }
++ else if (fraction == 0)
++ {
++ exp = 0;
++ }
++ else
++ {
++ if (src->normal_exp < NORMAL_EXPMIN)
++ {
++#ifdef NO_DENORMALS
++ /* Go straight to a zero representation if denormals are not
++ supported. The denormal handling would be harmless but
++ isn't unnecessary. */
++ exp = 0;
++ fraction = 0;
++#else /* NO_DENORMALS */
++ /* This number's exponent is too low to fit into the bits
++ available in the number, so we'll store 0 in the exponent and
++ shift the fraction to the right to make up for it. */
++
++ int shift = NORMAL_EXPMIN - src->normal_exp;
++
++ exp = 0;
++
++ if (shift > FRAC_NBITS - NGARDS)
++ {
++ /* No point shifting, since it's more that 64 out. */
++ fraction = 0;
++ }
++ else
++ {
++ int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
++ fraction = (fraction >> shift) | lowbit;
++ }
++ if ((fraction & GARDMASK) == GARDMSB)
++ {
++ if ((fraction & (1 << NGARDS)))
++ fraction += GARDROUND + 1;
++ }
++ else
++ {
++ /* Add to the guards to round up. */
++ fraction += GARDROUND;
++ }
++ /* Perhaps the rounding means we now need to change the
++ exponent, because the fraction is no longer denormal. */
++ if (fraction >= IMPLICIT_1)
++ {
++ exp += 1;
++ }
++ fraction >>= NGARDS;
++#endif /* NO_DENORMALS */
++ }
++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
++ && src->normal_exp > EXPBIAS)
++ {
++ exp = EXPMAX;
++ fraction = 0;
++ }
++ else
++ {
++ exp = src->normal_exp + EXPBIAS;
++ if (!ROUND_TOWARDS_ZERO)
++ {
++ /* IF the gard bits are the all zero, but the first, then we're
++ half way between two numbers, choose the one which makes the
++ lsb of the answer 0. */
++ if ((fraction & GARDMASK) == GARDMSB)
++ {
++ if (fraction & (1 << NGARDS))
++ fraction += GARDROUND + 1;
++ }
++ else
++ {
++ /* Add a one to the guards to round up */
++ fraction += GARDROUND;
++ }
++ if (fraction >= IMPLICIT_2)
++ {
++ fraction >>= 1;
++ exp += 1;
++ }
++ }
++ fraction >>= NGARDS;
++
++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
++ {
++ /* Saturate on overflow. */
++ exp = EXPMAX;
++ fraction = ((fractype) 1 << FRACBITS) - 1;
++ }
++ }
++ }
++
++ /* We previously used bitfields to store the number, but this doesn't
++ handle little/big endian systems conveniently, so use shifts and
++ masks */
++#ifdef FLOAT_BIT_ORDER_MISMATCH
++ dst.bits.fraction = fraction;
++ dst.bits.exp = exp;
++ dst.bits.sign = sign;
++#else
++# if defined TFLOAT && defined HALFFRACBITS
++ {
++ halffractype high, low, unity;
++ int lowsign, lowexp;
++
++ unity = (halffractype) 1 << HALFFRACBITS;
++
++ /* Set HIGH to the high double's significand, masking out the implicit 1.
++ Set LOW to the low double's full significand. */
++ high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
++ low = fraction & (unity * 2 - 1);
++
++ /* Get the initial sign and exponent of the low double. */
++ lowexp = exp - HALFFRACBITS - 1;
++ lowsign = sign;
++
++ /* HIGH should be rounded like a normal double, making |LOW| <=
++ 0.5 ULP of HIGH. Assume round-to-nearest. */
++ if (exp < EXPMAX)
++ if (low > unity || (low == unity && (high & 1) == 1))
++ {
++ /* Round HIGH up and adjust LOW to match. */
++ high++;
++ if (high == unity)
++ {
++ /* May make it infinite, but that's OK. */
++ high = 0;
++ exp++;
++ }
++ low = unity * 2 - low;
++ lowsign ^= 1;
++ }
++
++ high |= (halffractype) exp << HALFFRACBITS;
++ high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
++
++ if (exp == EXPMAX || exp == 0 || low == 0)
++ low = 0;
++ else
++ {
++ while (lowexp > 0 && low < unity)
++ {
++ low <<= 1;
++ lowexp--;
++ }
++
++ if (lowexp <= 0)
++ {
++ halffractype roundmsb, round;
++ int shift;
++
++ shift = 1 - lowexp;
++ roundmsb = (1 << (shift - 1));
++ round = low & ((roundmsb << 1) - 1);
++
++ low >>= shift;
++ lowexp = 0;
++
++ if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
++ {
++ low++;
++ if (low == unity)
++ /* LOW rounds up to the smallest normal number. */
++ lowexp++;
++ }
++ }
++
++ low &= unity - 1;
++ low |= (halffractype) lowexp << HALFFRACBITS;
++ low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
++ }
++ dst.value_raw = ((fractype) high << HALFSHIFT) | low;
++ }
++# else
++ dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
++ dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
++ dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
++# endif
++#endif
++
++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
++#ifdef TFLOAT
++ {
++ qrtrfractype tmp1 = dst.words[0];
++ qrtrfractype tmp2 = dst.words[1];
++ dst.words[0] = dst.words[3];
++ dst.words[1] = dst.words[2];
++ dst.words[2] = tmp2;
++ dst.words[3] = tmp1;
++ }
++#else
++ {
++ halffractype tmp = dst.words[0];
++ dst.words[0] = dst.words[1];
++ dst.words[1] = tmp;
++ }
++#endif
++#endif
++
++ return dst.value;
++}
++#endif
++
++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
++void
++unpack_d (FLO_union_type * src, fp_number_type * dst)
++{
++ /* We previously used bitfields to store the number, but this doesn't
++ handle little/big endian systems conveniently, so use shifts and
++ masks */
++ fractype fraction;
++ int exp;
++ int sign;
++
++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
++ FLO_union_type swapped;
++
++#ifdef TFLOAT
++ swapped.words[0] = src->words[3];
++ swapped.words[1] = src->words[2];
++ swapped.words[2] = src->words[1];
++ swapped.words[3] = src->words[0];
++#else
++ swapped.words[0] = src->words[1];
++ swapped.words[1] = src->words[0];
++#endif
++ src = &swapped;
++#endif
++
++#ifdef FLOAT_BIT_ORDER_MISMATCH
++ fraction = src->bits.fraction;
++ exp = src->bits.exp;
++ sign = src->bits.sign;
++#else
++# if defined TFLOAT && defined HALFFRACBITS
++ {
++ halffractype high, low;
++
++ high = src->value_raw >> HALFSHIFT;
++ low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
++
++ fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
++ fraction <<= FRACBITS - HALFFRACBITS;
++ exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
++ sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
++
++ if (exp != EXPMAX && exp != 0 && low != 0)
++ {
++ int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
++ int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
++ int shift;
++ fractype xlow;
++
++ xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
++ if (lowexp)
++ xlow |= (((halffractype)1) << HALFFRACBITS);
++ else
++ lowexp = 1;
++ shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
++ if (shift > 0)
++ xlow <<= shift;
++ else if (shift < 0)
++ xlow >>= -shift;
++ if (sign == lowsign)
++ fraction += xlow;
++ else if (fraction >= xlow)
++ fraction -= xlow;
++ else
++ {
++ /* The high part is a power of two but the full number is lower.
++ This code will leave the implicit 1 in FRACTION, but we'd
++ have added that below anyway. */
++ fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
++ exp--;
++ }
++ }
++ }
++# else
++ fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
++ exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
++ sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
++# endif
++#endif
++
++ dst->sign = sign;
++ if (exp == 0)
++ {
++ /* Hmm. Looks like 0 */
++ if (fraction == 0
++#ifdef NO_DENORMALS
++ || 1
++#endif
++ )
++ {
++ /* tastes like zero */
++ dst->class = CLASS_ZERO;
++ }
++ else
++ {
++ /* Zero exponent with nonzero fraction - it's denormalized,
++ so there isn't a leading implicit one - we'll shift it so
++ it gets one. */
++ dst->normal_exp = exp - EXPBIAS + 1;
++ fraction <<= NGARDS;
++
++ dst->class = CLASS_NUMBER;
++#if 1
++ while (fraction < IMPLICIT_1)
++ {
++ fraction <<= 1;
++ dst->normal_exp--;
++ }
++#endif
++ dst->fraction.ll = fraction;
++ }
++ }
++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
++ {
++ /* Huge exponent*/
++ if (fraction == 0)
++ {
++ /* Attached to a zero fraction - means infinity */
++ dst->class = CLASS_INFINITY;
++ }
++ else
++ {
++ /* Nonzero fraction, means nan */
++#ifdef QUIET_NAN_NEGATED
++ if ((fraction & QUIET_NAN) == 0)
++#else
++ if (fraction & QUIET_NAN)
++#endif
++ {
++ dst->class = CLASS_QNAN;
++ }
++ else
++ {
++ dst->class = CLASS_SNAN;
++ }
++ /* Keep the fraction part as the nan number */
++ dst->fraction.ll = fraction;
++ }
++ }
++ else
++ {
++ /* Nothing strange about this number */
++ dst->normal_exp = exp - EXPBIAS;
++ dst->class = CLASS_NUMBER;
++ dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
++ }
++}
++#endif /* L_unpack_df || L_unpack_sf */
++
++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
++static fp_number_type *
++_fpadd_parts (fp_number_type * a,
++ fp_number_type * b,
++ fp_number_type * tmp)
++{
++ intfrac tfraction;
++
++ /* Put commonly used fields in local variables. */
++ int a_normal_exp;
++ int b_normal_exp;
++ fractype a_fraction;
++ fractype b_fraction;
++
++ if (isnan (a))
++ {
++ return a;
++ }
++ if (isnan (b))
++ {
++ return b;
++ }
++ if (isinf (a))
++ {
++ /* Adding infinities with opposite signs yields a NaN. */
++ if (isinf (b) && a->sign != b->sign)
++ return nan ();
++ return a;
++ }
++ if (isinf (b))
++ {
++ return b;
++ }
++ if (iszero (b))
++ {
++ if (iszero (a))
++ {
++ *tmp = *a;
++ tmp->sign = a->sign & b->sign;
++ return tmp;
++ }
++ return a;
++ }
++ if (iszero (a))
++ {
++ return b;
++ }
++
++ /* Got two numbers. shift the smaller and increment the exponent till
++ they're the same */
++ {
++ int diff;
++
++ a_normal_exp = a->normal_exp;
++ b_normal_exp = b->normal_exp;
++ a_fraction = a->fraction.ll;
++ b_fraction = b->fraction.ll;
++
++ diff = a_normal_exp - b_normal_exp;
++
++ if (diff < 0)
++ diff = -diff;
++ if (diff < FRAC_NBITS)
++ {
++ /* ??? This does shifts one bit at a time. Optimize. */
++ while (a_normal_exp > b_normal_exp)
++ {
++ b_normal_exp++;
++ LSHIFT (b_fraction);
++ }
++ while (b_normal_exp > a_normal_exp)
++ {
++ a_normal_exp++;
++ LSHIFT (a_fraction);
++ }
++ }
++ else
++ {
++ /* Somethings's up.. choose the biggest */
++ if (a_normal_exp > b_normal_exp)
++ {
++ b_normal_exp = a_normal_exp;
++ b_fraction = 0;
++ }
++ else
++ {
++ a_normal_exp = b_normal_exp;
++ a_fraction = 0;
++ }
++ }
++ }
++
++ if (a->sign != b->sign)
++ {
++ if (a->sign)
++ {
++ tfraction = -a_fraction + b_fraction;
++ }
++ else
++ {
++ tfraction = a_fraction - b_fraction;
++ }
++ if (tfraction >= 0)
++ {
++ tmp->sign = 0;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = tfraction;
++ }
++ else
++ {
++ tmp->sign = 1;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = -tfraction;
++ }
++ /* and renormalize it */
++
++ while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
++ {
++ tmp->fraction.ll <<= 1;
++ tmp->normal_exp--;
++ }
++ }
++ else
++ {
++ tmp->sign = a->sign;
++ tmp->normal_exp = a_normal_exp;
++ tmp->fraction.ll = a_fraction + b_fraction;
++ }
++ tmp->class = CLASS_NUMBER;
++ /* Now the fraction is added, we have to shift down to renormalize the
++ number */
++
++ if (tmp->fraction.ll >= IMPLICIT_2)
++ {
++ LSHIFT (tmp->fraction.ll);
++ tmp->normal_exp++;
++ }
++ return tmp;
++
++}
++
++FLO_type
++add (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpadd_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++
++FLO_type
++sub (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ b.sign ^= 1;
++
++ res = _fpadd_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++#endif /* L_addsub_sf || L_addsub_df */
++
++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
++static inline __attribute__ ((__always_inline__)) fp_number_type *
++_fpmul_parts ( fp_number_type * a,
++ fp_number_type * b,
++ fp_number_type * tmp)
++{
++ fractype low = 0;
++ fractype high = 0;
++
++ if (isnan (a))
++ {
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (isnan (b))
++ {
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++ if (isinf (a))
++ {
++ if (iszero (b))
++ return nan ();
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (isinf (b))
++ {
++ if (iszero (a))
++ {
++ return nan ();
++ }
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++ if (iszero (a))
++ {
++ a->sign = a->sign != b->sign;
++ return a;
++ }
++ if (iszero (b))
++ {
++ b->sign = a->sign != b->sign;
++ return b;
++ }
++
++ /* Calculate the mantissa by multiplying both numbers to get a
++ twice-as-wide number. */
++ {
++#if defined(NO_DI_MODE) || defined(TFLOAT)
++ {
++ fractype x = a->fraction.ll;
++ fractype ylow = b->fraction.ll;
++ fractype yhigh = 0;
++ int bit;
++
++ /* ??? This does multiplies one bit at a time. Optimize. */
++ for (bit = 0; bit < FRAC_NBITS; bit++)
++ {
++ int carry;
++
++ if (x & 1)
++ {
++ carry = (low += ylow) < ylow;
++ high += yhigh + carry;
++ }
++ yhigh <<= 1;
++ if (ylow & FRACHIGH)
++ {
++ yhigh |= 1;
++ }
++ ylow <<= 1;
++ x >>= 1;
++ }
++ }
++#elif defined(FLOAT)
++ /* Multiplying two USIs to get a UDI, we're safe. */
++ {
++ UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
++
++ high = answer >> BITS_PER_SI;
++ low = answer;
++ }
++#else
++ /* fractype is DImode, but we need the result to be twice as wide.
++ Assuming a widening multiply from DImode to TImode is not
++ available, build one by hand. */
++ {
++ USItype nl = a->fraction.ll;
++ USItype nh = a->fraction.ll >> BITS_PER_SI;
++ USItype ml = b->fraction.ll;
++ USItype mh = b->fraction.ll >> BITS_PER_SI;
++ UDItype pp_ll = (UDItype) ml * nl;
++ UDItype pp_hl = (UDItype) mh * nl;
++ UDItype pp_lh = (UDItype) ml * nh;
++ UDItype pp_hh = (UDItype) mh * nh;
++ UDItype res2 = 0;
++ UDItype res0 = 0;
++ UDItype ps_hh__ = pp_hl + pp_lh;
++ if (ps_hh__ < pp_hl)
++ res2 += (UDItype)1 << BITS_PER_SI;
++ pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
++ res0 = pp_ll + pp_hl;
++ if (res0 < pp_ll)
++ res2++;
++ res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
++ high = res2;
++ low = res0;
++ }
++#endif
++ }
++
++ tmp->normal_exp = a->normal_exp + b->normal_exp
++ + FRAC_NBITS - (FRACBITS + NGARDS);
++ tmp->sign = a->sign != b->sign;
++ while (high >= IMPLICIT_2)
++ {
++ tmp->normal_exp++;
++ if (high & 1)
++ {
++ low >>= 1;
++ low |= FRACHIGH;
++ }
++ high >>= 1;
++ }
++ while (high < IMPLICIT_1)
++ {
++ tmp->normal_exp--;
++
++ high <<= 1;
++ if (low & FRACHIGH)
++ high |= 1;
++ low <<= 1;
++ }
++ /* rounding is tricky. if we only round if it won't make us round later. */
++#if 0
++ if (low & FRACHIGH2)
++ {
++ if (((high & GARDMASK) != GARDMSB)
++ && (((high + 1) & GARDMASK) == GARDMSB))
++ {
++ /* don't round, it gets done again later. */
++ }
++ else
++ {
++ high++;
++ }
++ }
++#endif
++ if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
++ {
++ if (high & (1 << NGARDS))
++ {
++ /* half way, so round to even */
++ high += GARDROUND + 1;
++ }
++ else if (low)
++ {
++ /* but we really weren't half way */
++ high += GARDROUND + 1;
++ }
++ }
++ tmp->fraction.ll = high;
++ tmp->class = CLASS_NUMBER;
++ return tmp;
++}
++
++FLO_type
++multiply (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type tmp;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpmul_parts (&a, &b, &tmp);
++
++ return pack_d (res);
++}
++#endif /* L_mul_sf || L_mul_df */
++
++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
++static inline __attribute__ ((__always_inline__)) fp_number_type *
++_fpdiv_parts (fp_number_type * a,
++ fp_number_type * b)
++{
++ fractype bit;
++ fractype numerator;
++ fractype denominator;
++ fractype quotient;
++
++ if (isnan (a))
++ {
++ return a;
++ }
++ if (isnan (b))
++ {
++ return b;
++ }
++
++ a->sign = a->sign ^ b->sign;
++
++ if (isinf (a) || iszero (a))
++ {
++ if (a->class == b->class)
++ return nan ();
++ return a;
++ }
++
++ if (isinf (b))
++ {
++ a->fraction.ll = 0;
++ a->normal_exp = 0;
++ return a;
++ }
++ if (iszero (b))
++ {
++ a->class = CLASS_INFINITY;
++ return a;
++ }
++
++ /* Calculate the mantissa by multiplying both 64bit numbers to get a
++ 128 bit number */
++ {
++ /* quotient =
++ ( numerator / denominator) * 2^(numerator exponent - denominator exponent)
++ */
++
++ a->normal_exp = a->normal_exp - b->normal_exp;
++ numerator = a->fraction.ll;
++ denominator = b->fraction.ll;
++
++ if (numerator < denominator)
++ {
++ /* Fraction will be less than 1.0 */
++ numerator *= 2;
++ a->normal_exp--;
++ }
++ bit = IMPLICIT_1;
++ quotient = 0;
++ /* ??? Does divide one bit at a time. Optimize. */
++ while (bit)
++ {
++ if (numerator >= denominator)
++ {
++ quotient |= bit;
++ numerator -= denominator;
++ }
++ bit >>= 1;
++ numerator *= 2;
++ }
++
++ if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
++ {
++ if (quotient & (1 << NGARDS))
++ {
++ /* half way, so round to even */
++ quotient += GARDROUND + 1;
++ }
++ else if (numerator)
++ {
++ /* but we really weren't half way, more bits exist */
++ quotient += GARDROUND + 1;
++ }
++ }
++
++ a->fraction.ll = quotient;
++ return (a);
++ }
++}
++
++FLO_type
++divide (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ fp_number_type *res;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ res = _fpdiv_parts (&a, &b);
++
++ return pack_d (res);
++}
++#endif /* L_div_sf || L_div_df */
++
++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
++ || defined(L_fpcmp_parts_tf)
++/* according to the demo, fpcmp returns a comparison with 0... thus
++ a<b -> -1
++ a==b -> 0
++ a>b -> +1
++ */
++
++int
++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
++{
++#if 0
++ /* either nan -> unordered. Must be checked outside of this routine. */
++ if (isnan (a) && isnan (b))
++ {
++ return 1; /* still unordered! */
++ }
++#endif
++
++ if (isnan (a) || isnan (b))
++ {
++ return 1; /* how to indicate unordered compare? */
++ }
++ if (isinf (a) && isinf (b))
++ {
++ /* +inf > -inf, but +inf != +inf */
++ /* b \a| +inf(0)| -inf(1)
++ ______\+--------+--------
++ +inf(0)| a==b(0)| a<b(-1)
++ -------+--------+--------
++ -inf(1)| a>b(1) | a==b(0)
++ -------+--------+--------
++ So since unordered must be nonzero, just line up the columns...
++ */
++ return b->sign - a->sign;
++ }
++ /* but not both... */
++ if (isinf (a))
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (isinf (b))
++ {
++ return b->sign ? 1 : -1;
++ }
++ if (iszero (a) && iszero (b))
++ {
++ return 0;
++ }
++ if (iszero (a))
++ {
++ return b->sign ? 1 : -1;
++ }
++ if (iszero (b))
++ {
++ return a->sign ? -1 : 1;
++ }
++ /* now both are "normal". */
++ if (a->sign != b->sign)
++ {
++ /* opposite signs */
++ return a->sign ? -1 : 1;
++ }
++ /* same sign; exponents? */
++ if (a->normal_exp > b->normal_exp)
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (a->normal_exp < b->normal_exp)
++ {
++ return a->sign ? 1 : -1;
++ }
++ /* same exponents; check size. */
++ if (a->fraction.ll > b->fraction.ll)
++ {
++ return a->sign ? -1 : 1;
++ }
++ if (a->fraction.ll < b->fraction.ll)
++ {
++ return a->sign ? 1 : -1;
++ }
++ /* after all that, they're equal. */
++ return 0;
++}
++#endif
++
++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
++CMPtype
++compare (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_compare_sf || L_compare_df */
++
++#ifndef US_SOFTWARE_GOFAST
++
++/* These should be optimized for their specific tasks someday. */
++
++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
++CMPtype
++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth == 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_eq_sf || L_eq_df */
++
++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
++CMPtype
++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* true, truth != 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_ne_sf || L_ne_df */
++
++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
++CMPtype
++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return -1; /* false, truth > 0 */
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_gt_sf || L_gt_df */
++
++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
++CMPtype
++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return -1; /* false, truth >= 0 */
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_ge_sf || L_ge_df */
++
++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
++CMPtype
++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth < 0 */
++
++ return __fpcmp_parts (&a, &b);
++}
++#endif /* L_lt_sf || L_lt_df */
++
++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
++CMPtype
++_le_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ if (isnan (&a) || isnan (&b))
++ return 1; /* false, truth <= 0 */
++
++ return __fpcmp_parts (&a, &b) ;
++}
++#endif /* L_le_sf || L_le_df */
++
++#endif /* ! US_SOFTWARE_GOFAST */
++
++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
++CMPtype
++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
++{
++ fp_number_type a;
++ fp_number_type b;
++ FLO_union_type au, bu;
++
++ au.value = arg_a;
++ bu.value = arg_b;
++
++ unpack_d (&au, &a);
++ unpack_d (&bu, &b);
++
++ return (isnan (&a) || isnan (&b));
++}
++#endif /* L_unord_sf || L_unord_df */
++
++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
++FLO_type
++si_to_float (SItype arg_a)
++{
++ fp_number_type in;
++
++ in.class = CLASS_NUMBER;
++ in.sign = arg_a < 0;
++ if (!arg_a)
++ {
++ in.class = CLASS_ZERO;
++ }
++ else
++ {
++ in.normal_exp = FRACBITS + NGARDS;
++ if (in.sign)
++ {
++ /* Special case for minint, since there is no +ve integer
++ representation for it */
++ if (arg_a == (- MAX_SI_INT - 1))
++ {
++ return (FLO_type)(- MAX_SI_INT - 1);
++ }
++ in.fraction.ll = (-arg_a);
++ }
++ else
++ in.fraction.ll = arg_a;
++
++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll <<= 1;
++ in.normal_exp -= 1;
++ }
++ }
++ return pack_d (&in);
++}
++#endif /* L_si_to_sf || L_si_to_df */
++
++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
++FLO_type
++usi_to_float (USItype arg_a)
++{
++ fp_number_type in;
++
++ in.sign = 0;
++ if (!arg_a)
++ {
++ in.class = CLASS_ZERO;
++ }
++ else
++ {
++ in.class = CLASS_NUMBER;
++ in.normal_exp = FRACBITS + NGARDS;
++ in.fraction.ll = arg_a;
++
++ while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll >>= 1;
++ in.normal_exp += 1;
++ }
++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
++ {
++ in.fraction.ll <<= 1;
++ in.normal_exp -= 1;
++ }
++ }
++ return pack_d (&in);
++}
++#endif
++
++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
++SItype
++float_to_si (FLO_type arg_a)
++{
++ fp_number_type a;
++ SItype tmp;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ if (iszero (&a))
++ return 0;
++ if (isnan (&a))
++ return 0;
++ /* get reasonable MAX_SI_INT... */
++ if (isinf (&a))
++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
++ /* it is a number, but a small one */
++ if (a.normal_exp < 0)
++ return 0;
++ if (a.normal_exp > BITS_PER_SI - 2)
++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
++ tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
++ return a.sign ? (-tmp) : (tmp);
++}
++#endif /* L_sf_to_si || L_df_to_si */
++
++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
++ we also define them for GOFAST because the ones in libgcc2.c have the
++ wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
++ out of libgcc2.c. We can't define these here if not GOFAST because then
++ there'd be duplicate copies. */
++
++USItype
++float_to_usi (FLO_type arg_a)
++{
++ fp_number_type a;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ if (iszero (&a))
++ return 0;
++ if (isnan (&a))
++ return 0;
++ /* it is a negative number */
++ if (a.sign)
++ return 0;
++ /* get reasonable MAX_USI_INT... */
++ if (isinf (&a))
++ return MAX_USI_INT;
++ /* it is a number, but a small one */
++ if (a.normal_exp < 0)
++ return 0;
++ if (a.normal_exp > BITS_PER_SI - 1)
++ return MAX_USI_INT;
++ else if (a.normal_exp > (FRACBITS + NGARDS))
++ return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
++ else
++ return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
++}
++#endif /* US_SOFTWARE_GOFAST */
++#endif /* L_sf_to_usi || L_df_to_usi */
++
++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
++FLO_type
++negate (FLO_type arg_a)
++{
++ fp_number_type a;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &a);
++
++ flip_sign (&a);
++ return pack_d (&a);
++}
++#endif /* L_negate_sf || L_negate_df */
++
++#ifdef FLOAT
++
++#if defined(L_make_sf)
++SFtype
++__make_fp(fp_class_type class,
++ unsigned int sign,
++ int exp,
++ USItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_sf */
++
++#ifndef FLOAT_ONLY
++
++/* This enables one to build an fp library that supports float but not double.
++ Otherwise, we would get an undefined reference to __make_dp.
++ This is needed for some 8-bit ports that can't handle well values that
++ are 8-bytes in size, so we just don't support double for them at all. */
++
++#if defined(L_sf_to_df)
++DFtype
++sf_to_df (SFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_dp (in.class, in.sign, in.normal_exp,
++ ((UDItype) in.fraction.ll) << F_D_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#if defined(L_sf_to_tf) && defined(TMODES)
++TFtype
++sf_to_tf (SFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_tp (in.class, in.sign, in.normal_exp,
++ ((UTItype) in.fraction.ll) << F_T_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#endif /* ! FLOAT_ONLY */
++#endif /* FLOAT */
++
++#ifndef FLOAT
++
++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
++
++#if defined(L_make_df)
++DFtype
++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_df */
++
++#if defined(L_df_to_sf)
++SFtype
++df_to_sf (DFtype arg_a)
++{
++ fp_number_type in;
++ USItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> F_D_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_df_to_sf */
++
++#if defined(L_df_to_tf) && defined(TMODES) \
++ && !defined(FLOAT) && !defined(TFLOAT)
++TFtype
++df_to_tf (DFtype arg_a)
++{
++ fp_number_type in;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ return __make_tp (in.class, in.sign, in.normal_exp,
++ ((UTItype) in.fraction.ll) << D_T_BITOFF);
++}
++#endif /* L_sf_to_df */
++
++#ifdef TFLOAT
++#if defined(L_make_tf)
++TFtype
++__make_tp(fp_class_type class,
++ unsigned int sign,
++ int exp,
++ UTItype frac)
++{
++ fp_number_type in;
++
++ in.class = class;
++ in.sign = sign;
++ in.normal_exp = exp;
++ in.fraction.ll = frac;
++ return pack_d (&in);
++}
++#endif /* L_make_tf */
++
++#if defined(L_tf_to_df)
++DFtype
++tf_to_df (TFtype arg_a)
++{
++ fp_number_type in;
++ UDItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> D_T_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_tf_to_df */
++
++#if defined(L_tf_to_sf)
++SFtype
++tf_to_sf (TFtype arg_a)
++{
++ fp_number_type in;
++ USItype sffrac;
++ FLO_union_type au;
++
++ au.value = arg_a;
++ unpack_d (&au, &in);
++
++ sffrac = in.fraction.ll >> F_T_BITOFF;
++
++ /* We set the lowest guard bit in SFFRAC if we discarded any non
++ zero bits. */
++ if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
++ sffrac |= 1;
++
++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
++}
++#endif /* L_tf_to_sf */
++#endif /* TFLOAT */
++
++#endif /* ! FLOAT */
++#endif /* !EXTENDED_FLOAT_STUBS */
+diff --git a/gcc/config/nios2/nios2-protos.h b/gcc/config/nios2/nios2-protos.h
+new file mode 100644
+index 0000000..dc75c4f
+--- /dev/null
++++ b/gcc/config/nios2/nios2-protos.h
+@@ -0,0 +1,78 @@
++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
++ Copyright (C) 2003 Altera
++ Contributed by Jonah Graham (jgraham@altera.com).
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++extern void dump_frame_size (FILE *);
++extern HOST_WIDE_INT compute_frame_size (void);
++extern int nios2_initial_elimination_offset (int, int);
++extern void override_options (void);
++extern void optimization_options (int, int);
++extern int nios2_can_use_return_insn (void);
++extern void expand_prologue (void);
++extern void expand_epilogue (bool);
++extern void function_profiler (FILE *, int);
++extern enum reg_class reg_class_from_constraint (char, const char *);
++extern void nios2_register_target_pragmas (void);
++
++#ifdef RTX_CODE
++extern int nios2_legitimate_address (rtx, enum machine_mode, int);
++extern void nios2_print_operand (FILE *, rtx, int);
++extern void nios2_print_operand_address (FILE *, rtx);
++
++extern int nios2_emit_move_sequence (rtx *, enum machine_mode);
++extern int nios2_emit_expensive_div (rtx *, enum machine_mode);
++
++extern void gen_int_relational (enum rtx_code, rtx, rtx, rtx, rtx);
++extern void gen_conditional_move (rtx *, enum machine_mode);
++extern const char *asm_output_opcode (FILE *, const char *);
++
++/* predicates */
++extern int arith_operand (rtx, enum machine_mode);
++extern int uns_arith_operand (rtx, enum machine_mode);
++extern int logical_operand (rtx, enum machine_mode);
++extern int shift_operand (rtx, enum machine_mode);
++extern int reg_or_0_operand (rtx, enum machine_mode);
++extern int equality_op (rtx, enum machine_mode);
++extern int custom_insn_opcode (rtx, enum machine_mode);
++extern int rdwrctl_operand (rtx, enum machine_mode);
++
++/* custom fpu instruction output */
++extern const char *nios2_output_fpu_insn_cmps (rtx, enum rtx_code);
++extern const char *nios2_output_fpu_insn_cmpd (rtx, enum rtx_code);
++
++# ifdef HAVE_MACHINE_MODES
++# if defined TREE_CODE
++extern rtx function_arg (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
++extern int nios2_must_pass_in_stack (enum machine_mode, tree);
++extern int function_arg_partial_nregs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
++extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
++extern int nios2_function_arg_padding (enum machine_mode, tree);
++extern int nios2_block_reg_padding (enum machine_mode, tree, int);
++extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int);
++extern int nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
++
++# endif /* TREE_CODE */
++# endif /* HAVE_MACHINE_MODES */
++#endif
++
++#ifdef TREE_CODE
++extern int nios2_return_in_memory (tree);
++
++#endif /* TREE_CODE */
+diff --git a/gcc/config/nios2/nios2-uclibc.h b/gcc/config/nios2/nios2-uclibc.h
+new file mode 100644
+index 0000000..af98cdd
+--- /dev/null
++++ b/gcc/config/nios2/nios2-uclibc.h
+@@ -0,0 +1,75 @@
++#ifdef USE_UCLIBC
++
++#undef TARGET_SWITCHES
++#define TARGET_SWITCHES \
++{ \
++ { "hw-div", HAS_DIV_FLAG, \
++ N_("Enable DIV, DIVU") }, \
++ { "no-hw-div", -HAS_DIV_FLAG, \
++ N_("Disable DIV, DIVU (default)") }, \
++ { "hw-mul", HAS_MUL_FLAG, \
++ N_("Enable MUL instructions (default)") }, \
++ { "hw-mulx", HAS_MULX_FLAG, \
++ N_("Enable MULX instructions, assume fast shifter") }, \
++ { "no-hw-mul", -HAS_MUL_FLAG, \
++ N_("Disable MUL instructions") }, \
++ { "no-hw-mulx", -HAS_MULX_FLAG, \
++ N_("Disable MULX instructions, assume slow shifter (default and implied by -mno-hw-mul)") }, \
++ { "fast-sw-div", FAST_SW_DIV_FLAG, \
++ N_("Use table based fast divide (default at -O3)") }, \
++ { "no-fast-sw-div", -FAST_SW_DIV_FLAG, \
++ N_("Don't use table based fast divide ever") }, \
++ { "inline-memcpy", INLINE_MEMCPY_FLAG, \
++ N_("Inline small memcpy (default when optimizing)") }, \
++ { "no-inline-memcpy", -INLINE_MEMCPY_FLAG, \
++ N_("Don't Inline small memcpy") }, \
++ { "cache-volatile", CACHE_VOLATILE_FLAG, \
++ N_("Volatile accesses use non-io variants of instructions (default)") }, \
++ { "no-cache-volatile", -CACHE_VOLATILE_FLAG, \
++ N_("Volatile accesses use io variants of instructions") }, \
++ { "bypass-cache", BYPASS_CACHE_FLAG, \
++ N_("All ld/st instructins use io variants") }, \
++ { "no-bypass-cache", -BYPASS_CACHE_FLAG, \
++ N_("All ld/st instructins do not use io variants (default)") }, \
++ { "smallc", 0, \
++ N_("Link with a limited version of the C library") }, \
++ { "stack-check", STACK_CHECK_FLAG, \
++ N_("Enable stack limit checking.") }, \
++ { "no-stack-check", -STACK_CHECK_FLAG, \
++ N_("Disable stack limit checking (default).") }, \
++ { "reverse-bitfields", REVERSE_BITFIELDS_FLAG, \
++ N_("Reverse the order of bitfields in a struct.") }, \
++ { "no-reverse-bitfields", -REVERSE_BITFIELDS_FLAG, \
++ N_("Use the normal order of bitfields in a struct (default).") }, \
++ { "eb", BIG_ENDIAN_FLAG, \
++ N_("Use big-endian byte order") }, \
++ { "el", -BIG_ENDIAN_FLAG, \
++ N_("Use little-endian byte order") }, \
++ { "", TARGET_DEFAULT, 0 } \
++}
++
++/* The GNU C++ standard library requires that these macros be defined. */
++#undef CPLUSPLUS_CPP_SPEC
++#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
++
++#undef LIB_SPEC
++#define LIB_SPEC \
++"--start-group %{msmallc: -lsmallc} %{!msmallc: -lc} -lgcc \
++ %{msys-lib=*: -l%*} \
++ %{!msys-lib=*: -lc} \
++ --end-group \
++ %{msys-lib=: %eYou need a library name for -msys-lib=} \
++"
++
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC \
++"%{msys-crt0=*: %*} %{!msys-crt0=*: crt1%O%s} \
++ %{msys-crt0=: %eYou need a C startup file for -msys-crt0=} \
++ crti%O%s crtbegin%O%s \
++"
++
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC \
++ " crtend%O%s crtn%O%s"
++
++#endif /* USE_UCLIBC */
+diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
+new file mode 100644
+index 0000000..8723a86
+--- /dev/null
++++ b/gcc/config/nios2/nios2.c
+@@ -0,0 +1,4694 @@
++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
++ Copyright (C) 2005 Altera
++ Contributed by Jonah Graham (jgraham@altera.com) and Will Reece (wreece@altera.com).
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++
++#include <stdio.h>
++#include "config.h"
++#include "system.h"
++#include "coretypes.h"
++#include "tm.h"
++#include "rtl.h"
++#include "tree.h"
++#include "tm_p.h"
++#include "regs.h"
++#include "hard-reg-set.h"
++#include "real.h"
++#include "insn-config.h"
++#include "conditions.h"
++#include "output.h"
++#include "insn-attr.h"
++#include "flags.h"
++#include "recog.h"
++#include "expr.h"
++#include "toplev.h"
++#include "basic-block.h"
++#include "function.h"
++#include "ggc.h"
++#include "reload.h"
++#include "debug.h"
++#include "optabs.h"
++#include "target.h"
++#include "target-def.h"
++#include "c-pragma.h" /* for c_register_pragma */
++#include "cpplib.h" /* for CPP_NUMBER */
++
++/* local prototypes */
++static bool nios2_rtx_costs (rtx, int, int, int *);
++
++static void nios2_asm_function_prologue (FILE *, HOST_WIDE_INT);
++static int nios2_use_dfa_pipeline_interface (void);
++static int nios2_issue_rate (void);
++static struct machine_function *nios2_init_machine_status (void);
++static bool nios2_in_small_data_p (tree);
++static rtx save_reg (int, HOST_WIDE_INT, rtx);
++static rtx restore_reg (int, HOST_WIDE_INT);
++static unsigned int nios2_section_type_flags (tree, const char *, int);
++
++/* 0 --> no #pragma seen
++ 1 --> in scope of #pragma reverse_bitfields
++ -1 --> in scope of #pragma no_reverse_bitfields */
++static int nios2_pragma_reverse_bitfields_flag = 0;
++static void nios2_pragma_reverse_bitfields (struct cpp_reader *);
++static void nios2_pragma_no_reverse_bitfields (struct cpp_reader *);
++static tree nios2_handle_struct_attribute (tree *, tree, tree, int, bool *);
++static void nios2_insert_attributes (tree, tree *);
++static bool nios2_reverse_bitfield_layout_p (tree record_type);
++static void nios2_init_builtins (void);
++static rtx nios2_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
++static bool nios2_function_ok_for_sibcall (tree, tree);
++static void nios2_encode_section_info (tree, rtx, int);
++
++/* Initialize the GCC target structure. */
++#undef TARGET_ASM_FUNCTION_PROLOGUE
++#define TARGET_ASM_FUNCTION_PROLOGUE nios2_asm_function_prologue
++
++#undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
++#define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE \
++ nios2_use_dfa_pipeline_interface
++#undef TARGET_SCHED_ISSUE_RATE
++#define TARGET_SCHED_ISSUE_RATE nios2_issue_rate
++#undef TARGET_IN_SMALL_DATA_P
++#define TARGET_IN_SMALL_DATA_P nios2_in_small_data_p
++#undef TARGET_ENCODE_SECTION_INFO
++#define TARGET_ENCODE_SECTION_INFO nios2_encode_section_info
++#undef TARGET_SECTION_TYPE_FLAGS
++#define TARGET_SECTION_TYPE_FLAGS nios2_section_type_flags
++
++#undef TARGET_REVERSE_BITFIELD_LAYOUT_P
++#define TARGET_REVERSE_BITFIELD_LAYOUT_P nios2_reverse_bitfield_layout_p
++
++#undef TARGET_INIT_BUILTINS
++#define TARGET_INIT_BUILTINS nios2_init_builtins
++#undef TARGET_EXPAND_BUILTIN
++#define TARGET_EXPAND_BUILTIN nios2_expand_builtin
++
++#undef TARGET_FUNCTION_OK_FOR_SIBCALL
++#define TARGET_FUNCTION_OK_FOR_SIBCALL nios2_function_ok_for_sibcall
++
++#undef TARGET_RTX_COSTS
++#define TARGET_RTX_COSTS nios2_rtx_costs
++
++const struct attribute_spec nios2_attribute_table[] =
++{
++ /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
++ { "reverse_bitfields", 0, 0, false, false, false, nios2_handle_struct_attribute },
++ { "no_reverse_bitfields", 0, 0, false, false, false, nios2_handle_struct_attribute },
++ { "pragma_reverse_bitfields", 0, 0, false, false, false, NULL },
++ { "pragma_no_reverse_bitfields", 0, 0, false, false, false, NULL },
++ { NULL, 0, 0, false, false, false, NULL }
++};
++
++#undef TARGET_ATTRIBUTE_TABLE
++#define TARGET_ATTRIBUTE_TABLE nios2_attribute_table
++
++#undef TARGET_INSERT_ATTRIBUTES
++#define TARGET_INSERT_ATTRIBUTES nios2_insert_attributes
++
++/* ??? Might want to redefine TARGET_RETURN_IN_MSB here to handle
++ big-endian case; depends on what ABI we choose. */
++
++struct gcc_target targetm = TARGET_INITIALIZER;
++
++
++
++/* Threshold for data being put into the small data/bss area, instead
++ of the normal data area (references to the small data/bss area take
++ 1 instruction, and use the global pointer, references to the normal
++ data area takes 2 instructions). */
++unsigned HOST_WIDE_INT nios2_section_threshold = NIOS2_DEFAULT_GVALUE;
++
++
++/* Structure to be filled in by compute_frame_size with register
++ save masks, and offsets for the current function. */
++
++struct nios2_frame_info
++GTY (())
++{
++ long total_size; /* # bytes that the entire frame takes up */
++ long var_size; /* # bytes that variables take up */
++ long args_size; /* # bytes that outgoing arguments take up */
++ int save_reg_size; /* # bytes needed to store gp regs */
++ int save_reg_rounded; /* # bytes needed to store gp regs */
++ long save_regs_offset; /* offset from new sp to store gp registers */
++ int initialized; /* != 0 if frame size already calculated */
++ int num_regs; /* number of gp registers saved */
++};
++
++struct machine_function
++GTY (())
++{
++
++ /* Current frame information, calculated by compute_frame_size. */
++ struct nios2_frame_info frame;
++};
++
++
++/***************************************
++ * Register Classes
++ ***************************************/
++
++enum reg_class
++reg_class_from_constraint (char chr, const char *str)
++{
++ if (chr == 'D' && ISDIGIT (str[1]) && ISDIGIT (str[2]))
++ {
++ int regno;
++ int ones = str[2] - '0';
++ int tens = str[1] - '0';
++
++ regno = ones + (10 * tens);
++ if (regno < 0 || regno > 31)
++ return NO_REGS;
++
++ return D00_REG + regno;
++ }
++
++ return NO_REGS;
++}
++
++
++/***************************************
++ * Stack Layout and Calling Conventions
++ ***************************************/
++
++
++#define TOO_BIG_OFFSET(X) ((X) > ((1 << 15) - 1))
++#define TEMP_REG_NUM 8
++
++static void
++nios2_asm_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
++{
++ if (flag_verbose_asm || flag_debug_asm)
++ {
++ compute_frame_size ();
++ dump_frame_size (file);
++ }
++}
++
++static rtx
++save_reg (int regno, HOST_WIDE_INT offset, rtx cfa_store_reg)
++{
++ rtx insn, stack_slot;
++
++ stack_slot = gen_rtx_PLUS (SImode,
++ cfa_store_reg,
++ GEN_INT (offset));
++
++ insn = emit_insn (gen_rtx_SET (SImode,
++ gen_rtx_MEM (SImode, stack_slot),
++ gen_rtx_REG (SImode, regno)));
++
++ RTX_FRAME_RELATED_P (insn) = 1;
++
++ return insn;
++}
++
++static rtx
++restore_reg (int regno, HOST_WIDE_INT offset)
++{
++ rtx insn, stack_slot;
++
++ if (TOO_BIG_OFFSET (offset))
++ {
++ stack_slot = gen_rtx_REG (SImode, TEMP_REG_NUM);
++ insn = emit_insn (gen_rtx_SET (SImode,
++ stack_slot,
++ GEN_INT (offset)));
++
++ insn = emit_insn (gen_rtx_SET (SImode,
++ stack_slot,
++ gen_rtx_PLUS (SImode,
++ stack_slot,
++ stack_pointer_rtx)));
++ }
++ else
++ {
++ stack_slot = gen_rtx_PLUS (SImode,
++ stack_pointer_rtx,
++ GEN_INT (offset));
++ }
++
++ stack_slot = gen_rtx_MEM (SImode, stack_slot);
++
++ insn = emit_move_insn (gen_rtx_REG (SImode, regno), stack_slot);
++
++ return insn;
++}
++
++
++/* There are two possible paths for prologue expansion,
++- the first is if the total frame size is < 2^15-1. In that
++case all the immediates will fit into the 16-bit immediate
++fields.
++- the second is when the frame size is too big, in that
++case an additional temporary register is used, first
++as a cfa_temp to offset the sp, second as the cfa_store
++register.
++
++See the comment above dwarf2out_frame_debug_expr in
++dwarf2out.c for more explanation of the "rules."
++
++
++Case 1:
++Rule # Example Insn Effect
++2 addi sp, sp, -total_frame_size cfa.reg=sp, cfa.offset=total_frame_size
++ cfa_store.reg=sp, cfa_store.offset=total_frame_size
++12 stw ra, offset(sp)
++12 stw r16, offset(sp)
++1 mov fp, sp
++
++Case 2:
++Rule # Example Insn Effect
++6 movi r8, total_frame_size cfa_temp.reg=r8, cfa_temp.offset=total_frame_size
++2 sub sp, sp, r8 cfa.reg=sp, cfa.offset=total_frame_size
++ cfa_store.reg=sp, cfa_store.offset=total_frame_size
++5 add r8, r8, sp cfa_store.reg=r8, cfa_store.offset=0
++12 stw ra, offset(r8)
++12 stw r16, offset(r8)
++1 mov fp, sp
++
++*/
++
++void
++expand_prologue ()
++{
++ int i;
++ HOST_WIDE_INT total_frame_size;
++ int cfa_store_offset = 0;
++ rtx insn;
++ rtx cfa_store_reg = 0;
++
++ total_frame_size = compute_frame_size ();
++
++ if (total_frame_size)
++ {
++
++ if (TOO_BIG_OFFSET (total_frame_size))
++ {
++ /* cfa_temp and cfa_store_reg are the same register,
++ cfa_store_reg overwrites cfa_temp */
++ cfa_store_reg = gen_rtx_REG (SImode, TEMP_REG_NUM);
++ insn = emit_insn (gen_rtx_SET (SImode,
++ cfa_store_reg,
++ GEN_INT (total_frame_size)));
++
++ RTX_FRAME_RELATED_P (insn) = 1;
++
++
++ insn = gen_rtx_SET (SImode,
++ stack_pointer_rtx,
++ gen_rtx_MINUS (SImode,
++ stack_pointer_rtx,
++ cfa_store_reg));
++
++ insn = emit_insn (insn);
++ RTX_FRAME_RELATED_P (insn) = 1;
++
++
++ /* if there are no registers to save, I don't need to
++ create a cfa_store */
++ if (cfun->machine->frame.save_reg_size)
++ {
++ insn = gen_rtx_SET (SImode,
++ cfa_store_reg,
++ gen_rtx_PLUS (SImode,
++ cfa_store_reg,
++ stack_pointer_rtx));
++
++ insn = emit_insn (insn);
++ RTX_FRAME_RELATED_P (insn) = 1;
++ }
++
++ cfa_store_offset
++ = total_frame_size
++ - (cfun->machine->frame.save_regs_offset
++ + cfun->machine->frame.save_reg_rounded);
++ }
++ else
++ {
++ insn = gen_rtx_SET (SImode,
++ stack_pointer_rtx,
++ gen_rtx_PLUS (SImode,
++ stack_pointer_rtx,
++ GEN_INT (-total_frame_size)));
++ insn = emit_insn (insn);
++ RTX_FRAME_RELATED_P (insn) = 1;
++
++ cfa_store_reg = stack_pointer_rtx;
++ cfa_store_offset
++ = cfun->machine->frame.save_regs_offset
++ + cfun->machine->frame.save_reg_rounded;
++ }
++
++ if (current_function_limit_stack)
++ {
++ emit_insn (gen_stack_overflow_detect_and_trap ());
++ }
++ }
++
++ if (MUST_SAVE_REGISTER (RA_REGNO))
++ {
++ cfa_store_offset -= 4;
++ save_reg (RA_REGNO, cfa_store_offset, cfa_store_reg);
++ }
++ if (MUST_SAVE_REGISTER (FP_REGNO))
++ {
++ cfa_store_offset -= 4;
++ save_reg (FP_REGNO, cfa_store_offset, cfa_store_reg);
++ }
++
++ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
++ {
++ if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
++ {
++ cfa_store_offset -= 4;
++ save_reg (i, cfa_store_offset, cfa_store_reg);
++ }
++ }
++
++ if (frame_pointer_needed)
++ {
++ insn = emit_insn (gen_rtx_SET (SImode,
++ gen_rtx_REG (SImode, FP_REGNO),
++ gen_rtx_REG (SImode, SP_REGNO)));
++
++ RTX_FRAME_RELATED_P (insn) = 1;
++ }
++
++ /* If we are profiling, make sure no instructions are scheduled before
++ the call to mcount. */
++ if (current_function_profile)
++ emit_insn (gen_blockage ());
++}
++
++void
++expand_epilogue (bool sibcall_p)
++{
++ rtx insn;
++ int i;
++ HOST_WIDE_INT total_frame_size;
++ int register_store_offset;
++
++ total_frame_size = compute_frame_size ();
++
++ if (!sibcall_p && nios2_can_use_return_insn ())
++ {
++ insn = emit_jump_insn (gen_return ());
++ return;
++ }
++
++ emit_insn (gen_blockage ());
++
++ register_store_offset =
++ cfun->machine->frame.save_regs_offset +
++ cfun->machine->frame.save_reg_rounded;
++
++ if (MUST_SAVE_REGISTER (RA_REGNO))
++ {
++ register_store_offset -= 4;
++ restore_reg (RA_REGNO, register_store_offset);
++ }
++
++ if (MUST_SAVE_REGISTER (FP_REGNO))
++ {
++ register_store_offset -= 4;
++ restore_reg (FP_REGNO, register_store_offset);
++ }
++
++ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
++ {
++ if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
++ {
++ register_store_offset -= 4;
++ restore_reg (i, register_store_offset);
++ }
++ }
++
++ if (total_frame_size)
++ {
++ rtx sp_adjust;
++
++ if (TOO_BIG_OFFSET (total_frame_size))
++ {
++ sp_adjust = gen_rtx_REG (SImode, TEMP_REG_NUM);
++ insn = emit_insn (gen_rtx_SET (SImode,
++ sp_adjust,
++ GEN_INT (total_frame_size)));
++
++ }
++ else
++ {
++ sp_adjust = GEN_INT (total_frame_size);
++ }
++
++ insn = gen_rtx_SET (SImode,
++ stack_pointer_rtx,
++ gen_rtx_PLUS (SImode,
++ stack_pointer_rtx,
++ sp_adjust));
++ insn = emit_insn (insn);
++ }
++
++
++ if (!sibcall_p)
++ {
++ insn = emit_jump_insn (gen_return_from_epilogue (gen_rtx (REG, Pmode,
++ RA_REGNO)));
++ }
++}
++
++
++bool
++nios2_function_ok_for_sibcall (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
++{
++ return true;
++}
++
++
++
++
++
++/* ----------------------- *
++ * Profiling
++ * ----------------------- */
++
++void
++function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
++{
++ fprintf (file, "\tmov\tr8, ra\n");
++ fprintf (file, "\tcall\tmcount\n");
++ fprintf (file, "\tmov\tra, r8\n");
++}
++
++
++/***************************************
++ * Stack Layout
++ ***************************************/
++
++
++void
++dump_frame_size (FILE *file)
++{
++ fprintf (file, "\t%s Current Frame Info\n", ASM_COMMENT_START);
++
++ fprintf (file, "\t%s total_size = %ld\n", ASM_COMMENT_START,
++ cfun->machine->frame.total_size);
++ fprintf (file, "\t%s var_size = %ld\n", ASM_COMMENT_START,
++ cfun->machine->frame.var_size);
++ fprintf (file, "\t%s args_size = %ld\n", ASM_COMMENT_START,
++ cfun->machine->frame.args_size);
++ fprintf (file, "\t%s save_reg_size = %d\n", ASM_COMMENT_START,
++ cfun->machine->frame.save_reg_size);
++ fprintf (file, "\t%s save_reg_rounded = %d\n", ASM_COMMENT_START,
++ cfun->machine->frame.save_reg_rounded);
++ fprintf (file, "\t%s initialized = %d\n", ASM_COMMENT_START,
++ cfun->machine->frame.initialized);
++ fprintf (file, "\t%s num_regs = %d\n", ASM_COMMENT_START,
++ cfun->machine->frame.num_regs);
++ fprintf (file, "\t%s save_regs_offset = %ld\n", ASM_COMMENT_START,
++ cfun->machine->frame.save_regs_offset);
++ fprintf (file, "\t%s current_function_is_leaf = %d\n", ASM_COMMENT_START,
++ current_function_is_leaf);
++ fprintf (file, "\t%s frame_pointer_needed = %d\n", ASM_COMMENT_START,
++ frame_pointer_needed);
++ fprintf (file, "\t%s pretend_args_size = %d\n", ASM_COMMENT_START,
++ current_function_pretend_args_size);
++
++}
++
++
++/* Return the bytes needed to compute the frame pointer from the current
++ stack pointer.
++*/
++
++HOST_WIDE_INT
++compute_frame_size ()
++{
++ unsigned int regno;
++ HOST_WIDE_INT var_size; /* # of var. bytes allocated */
++ HOST_WIDE_INT total_size; /* # bytes that the entire frame takes up */
++ HOST_WIDE_INT save_reg_size; /* # bytes needed to store callee save regs */
++ HOST_WIDE_INT save_reg_rounded;
++ /* # bytes needed to store callee save regs (rounded) */
++ HOST_WIDE_INT out_args_size; /* # bytes needed for outgoing args */
++
++ save_reg_size = 0;
++ var_size = STACK_ALIGN (get_frame_size ());
++ out_args_size = STACK_ALIGN (current_function_outgoing_args_size);
++
++ total_size = var_size + out_args_size;
++
++ /* Calculate space needed for gp registers. */
++ for (regno = 0; regno <= FIRST_PSEUDO_REGISTER; regno++)
++ {
++ if (MUST_SAVE_REGISTER (regno))
++ {
++ save_reg_size += 4;
++ }
++ }
++
++ save_reg_rounded = STACK_ALIGN (save_reg_size);
++ total_size += save_reg_rounded;
++
++ total_size += STACK_ALIGN (current_function_pretend_args_size);
++
++ /* Save other computed information. */
++ cfun->machine->frame.total_size = total_size;
++ cfun->machine->frame.var_size = var_size;
++ cfun->machine->frame.args_size = current_function_outgoing_args_size;
++ cfun->machine->frame.save_reg_size = save_reg_size;
++ cfun->machine->frame.save_reg_rounded = save_reg_rounded;
++ cfun->machine->frame.initialized = reload_completed;
++ cfun->machine->frame.num_regs = save_reg_size / UNITS_PER_WORD;
++
++ cfun->machine->frame.save_regs_offset
++ = save_reg_rounded ? current_function_outgoing_args_size + var_size : 0;
++
++ return total_size;
++}
++
++
++int
++nios2_initial_elimination_offset (int from, int to ATTRIBUTE_UNUSED)
++{
++ int offset;
++
++ /* Set OFFSET to the offset from the stack pointer. */
++ switch (from)
++ {
++ case FRAME_POINTER_REGNUM:
++ offset = 0;
++ break;
++
++ case ARG_POINTER_REGNUM:
++ compute_frame_size ();
++ offset = cfun->machine->frame.total_size;
++ offset -= current_function_pretend_args_size;
++ break;
++
++ case RETURN_ADDRESS_POINTER_REGNUM:
++ compute_frame_size ();
++ /* since the return address is always the first of the
++ saved registers, return the offset to the beginning
++ of the saved registers block */
++ offset = cfun->machine->frame.save_regs_offset;
++ break;
++
++ default:
++ abort ();
++ }
++
++ return offset;
++}
++
++/* Return nonzero if this function is known to have a null epilogue.
++ This allows the optimizer to omit jumps to jumps if no stack
++ was created. */
++int
++nios2_can_use_return_insn ()
++{
++ if (!reload_completed)
++ return 0;
++
++ if (regs_ever_live[RA_REGNO] || current_function_profile)
++ return 0;
++
++ if (cfun->machine->frame.initialized)
++ return cfun->machine->frame.total_size == 0;
++
++ return compute_frame_size () == 0;
++}
++
++
++
++
++
++/***************************************
++ *
++ ***************************************/
++
++/*
++ * Try to take a bit of tedium out of the __builtin_custom_<blah>
++ * builtin functions, too.
++ */
++
++#define NIOS2_FOR_ALL_CUSTOM_BUILTINS \
++ NIOS2_DO_BUILTIN (N, n, n ) \
++ NIOS2_DO_BUILTIN (NI, ni, nX ) \
++ NIOS2_DO_BUILTIN (NF, nf, nX ) \
++ NIOS2_DO_BUILTIN (NP, np, nX ) \
++ NIOS2_DO_BUILTIN (NII, nii, nXX ) \
++ NIOS2_DO_BUILTIN (NIF, nif, nXX ) \
++ NIOS2_DO_BUILTIN (NIP, nip, nXX ) \
++ NIOS2_DO_BUILTIN (NFI, nfi, nXX ) \
++ NIOS2_DO_BUILTIN (NFF, nff, nXX ) \
++ NIOS2_DO_BUILTIN (NFP, nfp, nXX ) \
++ NIOS2_DO_BUILTIN (NPI, npi, nXX ) \
++ NIOS2_DO_BUILTIN (NPF, npf, nXX ) \
++ NIOS2_DO_BUILTIN (NPP, npp, nXX ) \
++ NIOS2_DO_BUILTIN (IN, in, Xn ) \
++ NIOS2_DO_BUILTIN (INI, ini, XnX ) \
++ NIOS2_DO_BUILTIN (INF, inf, XnX ) \
++ NIOS2_DO_BUILTIN (INP, inp, XnX ) \
++ NIOS2_DO_BUILTIN (INII, inii, XnXX ) \
++ NIOS2_DO_BUILTIN (INIF, inif, XnXX ) \
++ NIOS2_DO_BUILTIN (INIP, inip, XnXX ) \
++ NIOS2_DO_BUILTIN (INFI, infi, XnXX ) \
++ NIOS2_DO_BUILTIN (INFF, inff, XnXX ) \
++ NIOS2_DO_BUILTIN (INFP, infp, XnXX ) \
++ NIOS2_DO_BUILTIN (INPI, inpi, XnXX ) \
++ NIOS2_DO_BUILTIN (INPF, inpf, XnXX ) \
++ NIOS2_DO_BUILTIN (INPP, inpp, XnXX ) \
++ NIOS2_DO_BUILTIN (FN, fn, Xn ) \
++ NIOS2_DO_BUILTIN (FNI, fni, XnX ) \
++ NIOS2_DO_BUILTIN (FNF, fnf, XnX ) \
++ NIOS2_DO_BUILTIN (FNP, fnp, XnX ) \
++ NIOS2_DO_BUILTIN (FNII, fnii, XnXX ) \
++ NIOS2_DO_BUILTIN (FNIF, fnif, XnXX ) \
++ NIOS2_DO_BUILTIN (FNIP, fnip, XnXX ) \
++ NIOS2_DO_BUILTIN (FNFI, fnfi, XnXX ) \
++ NIOS2_DO_BUILTIN (FNFF, fnff, XnXX ) \
++ NIOS2_DO_BUILTIN (FNFP, fnfp, XnXX ) \
++ NIOS2_DO_BUILTIN (FNPI, fnpi, XnXX ) \
++ NIOS2_DO_BUILTIN (FNPF, fnpf, XnXX ) \
++ NIOS2_DO_BUILTIN (FNPP, fnpp, XnXX ) \
++ NIOS2_DO_BUILTIN (PN, pn, Xn ) \
++ NIOS2_DO_BUILTIN (PNI, pni, XnX ) \
++ NIOS2_DO_BUILTIN (PNF, pnf, XnX ) \
++ NIOS2_DO_BUILTIN (PNP, pnp, XnX ) \
++ NIOS2_DO_BUILTIN (PNII, pnii, XnXX ) \
++ NIOS2_DO_BUILTIN (PNIF, pnif, XnXX ) \
++ NIOS2_DO_BUILTIN (PNIP, pnip, XnXX ) \
++ NIOS2_DO_BUILTIN (PNFI, pnfi, XnXX ) \
++ NIOS2_DO_BUILTIN (PNFF, pnff, XnXX ) \
++ NIOS2_DO_BUILTIN (PNFP, pnfp, XnXX ) \
++ NIOS2_DO_BUILTIN (PNPI, pnpi, XnXX ) \
++ NIOS2_DO_BUILTIN (PNPF, pnpf, XnXX ) \
++ NIOS2_DO_BUILTIN (PNPP, pnpp, XnXX )
++
++const char *nios2_sys_nosys_string; /* for -msys=nosys */
++const char *nios2_sys_lib_string; /* for -msys-lib= */
++const char *nios2_sys_crt0_string; /* for -msys-crt0= */
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++static const char *NIOS2_CONCAT (nios2_output_fpu_insn_, insn) (rtx); \
++static void NIOS2_CONCAT (nios2_pragma_, insn) (struct cpp_reader *); \
++static void NIOS2_CONCAT (nios2_pragma_no_, insn) (struct cpp_reader *);
++NIOS2_FOR_ALL_FPU_INSNS
++
++nios2_fpu_info nios2_fpu_insns[nios2_fpu_max_insn] = {
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ { NIOS2_STRINGIFY (opt), \
++ NIOS2_STRINGIFY (insn), \
++ NIOS2_STRINGIFY (args), \
++ 0, \
++ -1, \
++ NIOS2_CONCAT (nios2_output_fpu_insn_, insn), \
++ "custom_" NIOS2_STRINGIFY (opt), \
++ NIOS2_CONCAT (nios2_pragma_, insn), \
++ "no_custom_" NIOS2_STRINGIFY (opt), \
++ NIOS2_CONCAT (nios2_pragma_no_, insn), \
++ 0, \
++ 0, \
++ 0, \
++ 0, \
++ 0 },
++ NIOS2_FOR_ALL_FPU_INSNS
++};
++
++const char *nios2_custom_fpu_cfg_string;
++
++static const char *builtin_custom_seen[256];
++
++static void
++nios2_custom_switch (const char *parameter, int *value, const char *opt)
++{
++ /*
++ * We only document values from 0-255, but we secretly allow -1 so
++ * that the -mno-custom-<opt> switches work.
++ */
++ if (parameter && *parameter)
++ {
++ char *endptr;
++ long v = strtol (parameter, &endptr, 0);
++ if (*endptr)
++ {
++ error ("switch `-mcustom-%s' value `%s' must be a number between 0 and 255",
++ opt, parameter);
++ }
++ if (v < -1 || v > 255)
++ {
++ error ("switch `-mcustom-%s' value %ld must be between 0 and 255",
++ opt, v);
++ }
++ *value = (int)v;
++ }
++}
++
++static void
++nios2_custom_check_insns (int is_pragma)
++{
++ int i;
++ int has_double = 0;
++ int errors = 0;
++ const char *ns[256];
++ int ps[256];
++
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ if (nios2_fpu_insns[i].is_double && nios2_fpu_insns[i].N >= 0)
++ {
++ has_double = 1;
++ }
++ }
++
++ if (has_double)
++ {
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ if (nios2_fpu_insns[i].needed_by_double
++ && nios2_fpu_insns[i].N < 0)
++ {
++ if (is_pragma)
++ {
++ error ("either switch `-mcustom-%s' or `#pragma custom_%s' is required for double precision floating point",
++ nios2_fpu_insns[i].option,
++ nios2_fpu_insns[i].option);
++ }
++ else
++ {
++ error ("switch `-mcustom-%s' is required for double precision floating point",
++ nios2_fpu_insns[i].option);
++ }
++ errors = 1;
++ }
++ }
++ }
++
++ /*
++ * Warn if the user has certain exotic operations that won't get used
++ * without -funsafe-math-optimizations, See expand_builtin () in
++ * bulitins.c.
++ */
++ if (!flag_unsafe_math_optimizations)
++ {
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ if (nios2_fpu_insns[i].needs_unsafe && nios2_fpu_insns[i].N >= 0)
++ {
++ warning ("%s%s' has no effect unless -funsafe-math-optimizations is specified",
++ is_pragma ? "`#pragma custom_" : "switch `-mcustom-",
++ nios2_fpu_insns[i].option);
++ /* Just one warning per function per compilation unit, please. */
++ nios2_fpu_insns[i].needs_unsafe = 0;
++ }
++ }
++ }
++
++ /*
++ * Warn if the user is trying to use -mcustom-fmins et. al, that won't
++ * get used without -ffinite-math-only. See fold in fold () in
++ * fold-const.c
++ */
++ if (!flag_finite_math_only)
++ {
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ if (nios2_fpu_insns[i].needs_finite && nios2_fpu_insns[i].N >= 0)
++ {
++ warning ("%s%s' has no effect unless -ffinite-math-only is specified",
++ is_pragma ? "`#pragma custom_" : "switch `-mcustom-",
++ nios2_fpu_insns[i].option);
++ /* Just one warning per function per compilation unit, please. */
++ nios2_fpu_insns[i].needs_finite = 0;
++ }
++ }
++ }
++
++ /*
++ * Warn the user about double precision divide braindamage until we
++ * can fix it properly. See the RDIV_EXPR case of expand_expr_real in
++ * expr.c.
++ */
++ {
++ static int warned = 0;
++ if (flag_unsafe_math_optimizations
++ && !optimize_size
++ && nios2_fpu_insns[nios2_fpu_divdf3].N >= 0
++ && !warned)
++ {
++ warning ("%s%s' behaves poorly without -Os",
++ is_pragma ? "`#pragma custom_" : "switch `-mcustom-",
++ nios2_fpu_insns[nios2_fpu_divdf3].option);
++ warned = 1;
++ }
++ }
++
++ /*
++ * The following bit of voodoo is lifted from the generated file
++ * insn-opinit.c: to allow #pragmas to work properly, we have to tweak
++ * the optab_table manually -- it only gets initialized once after the
++ * switches are handled and before any #pragmas are seen.
++ */
++ if (is_pragma)
++ {
++ /* Only do this if the optabs have already been defined, not
++ when we're handling command line switches. */
++ addv_optab->handlers[SFmode].insn_code =
++ add_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ addv_optab->handlers[DFmode].insn_code =
++ add_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ subv_optab->handlers[SFmode].insn_code =
++ sub_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ subv_optab->handlers[DFmode].insn_code =
++ sub_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ smulv_optab->handlers[SFmode].insn_code =
++ smul_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ smulv_optab->handlers[DFmode].insn_code =
++ smul_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ sdiv_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ sdiv_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ negv_optab->handlers[SFmode].insn_code =
++ neg_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ negv_optab->handlers[DFmode].insn_code =
++ neg_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ smin_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ smin_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ smax_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ smax_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ absv_optab->handlers[SFmode].insn_code =
++ abs_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ absv_optab->handlers[DFmode].insn_code =
++ abs_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ sqrt_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ sqrt_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ cos_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ cos_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ sin_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ sin_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ tan_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ tan_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ atan_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ atan_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ exp_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ exp_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ log_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ log_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++ sfloat_optab->handlers[SFmode][SImode].insn_code = CODE_FOR_nothing;
++ sfloat_optab->handlers[DFmode][SImode].insn_code = CODE_FOR_nothing;
++ ufloat_optab->handlers[SFmode][SImode].insn_code = CODE_FOR_nothing;
++ ufloat_optab->handlers[DFmode][SImode].insn_code = CODE_FOR_nothing;
++ sfix_optab->handlers[SImode][SFmode].insn_code = CODE_FOR_nothing;
++ sfix_optab->handlers[SImode][DFmode].insn_code = CODE_FOR_nothing;
++ ufix_optab->handlers[SImode][SFmode].insn_code = CODE_FOR_nothing;
++ ufix_optab->handlers[SImode][DFmode].insn_code = CODE_FOR_nothing;
++ sext_optab->handlers[DFmode][SFmode].insn_code = CODE_FOR_nothing;
++ trunc_optab->handlers[SFmode][DFmode].insn_code = CODE_FOR_nothing;
++ cmp_optab->handlers[SFmode].insn_code = CODE_FOR_nothing;
++ cmp_optab->handlers[DFmode].insn_code = CODE_FOR_nothing;
++
++ if (HAVE_addsf3)
++ addv_optab->handlers[SFmode].insn_code =
++ add_optab->handlers[SFmode].insn_code = CODE_FOR_addsf3;
++ if (HAVE_adddf3)
++ addv_optab->handlers[DFmode].insn_code =
++ add_optab->handlers[DFmode].insn_code = CODE_FOR_adddf3;
++ if (HAVE_subsf3)
++ subv_optab->handlers[SFmode].insn_code =
++ sub_optab->handlers[SFmode].insn_code = CODE_FOR_subsf3;
++ if (HAVE_subdf3)
++ subv_optab->handlers[DFmode].insn_code =
++ sub_optab->handlers[DFmode].insn_code = CODE_FOR_subdf3;
++ if (HAVE_mulsf3)
++ smulv_optab->handlers[SFmode].insn_code =
++ smul_optab->handlers[SFmode].insn_code = CODE_FOR_mulsf3;
++ if (HAVE_muldf3)
++ smulv_optab->handlers[DFmode].insn_code =
++ smul_optab->handlers[DFmode].insn_code = CODE_FOR_muldf3;
++ if (HAVE_divsf3)
++ sdiv_optab->handlers[SFmode].insn_code = CODE_FOR_divsf3;
++ if (HAVE_divdf3)
++ sdiv_optab->handlers[DFmode].insn_code = CODE_FOR_divdf3;
++ if (HAVE_negsf2)
++ negv_optab->handlers[SFmode].insn_code =
++ neg_optab->handlers[SFmode].insn_code = CODE_FOR_negsf2;
++ if (HAVE_negdf2)
++ negv_optab->handlers[DFmode].insn_code =
++ neg_optab->handlers[DFmode].insn_code = CODE_FOR_negdf2;
++ if (HAVE_minsf3)
++ smin_optab->handlers[SFmode].insn_code = CODE_FOR_minsf3;
++ if (HAVE_mindf3)
++ smin_optab->handlers[DFmode].insn_code = CODE_FOR_mindf3;
++ if (HAVE_maxsf3)
++ smax_optab->handlers[SFmode].insn_code = CODE_FOR_maxsf3;
++ if (HAVE_maxdf3)
++ smax_optab->handlers[DFmode].insn_code = CODE_FOR_maxdf3;
++ if (HAVE_abssf2)
++ absv_optab->handlers[SFmode].insn_code =
++ abs_optab->handlers[SFmode].insn_code = CODE_FOR_abssf2;
++ if (HAVE_absdf2)
++ absv_optab->handlers[DFmode].insn_code =
++ abs_optab->handlers[DFmode].insn_code = CODE_FOR_absdf2;
++ if (HAVE_sqrtsf2)
++ sqrt_optab->handlers[SFmode].insn_code = CODE_FOR_sqrtsf2;
++ if (HAVE_sqrtdf2)
++ sqrt_optab->handlers[DFmode].insn_code = CODE_FOR_sqrtdf2;
++ if (HAVE_cossf2)
++ cos_optab->handlers[SFmode].insn_code = CODE_FOR_cossf2;
++ if (HAVE_cosdf2)
++ cos_optab->handlers[DFmode].insn_code = CODE_FOR_cosdf2;
++ if (HAVE_sinsf2)
++ sin_optab->handlers[SFmode].insn_code = CODE_FOR_sinsf2;
++ if (HAVE_sindf2)
++ sin_optab->handlers[DFmode].insn_code = CODE_FOR_sindf2;
++ if (HAVE_tansf2)
++ tan_optab->handlers[SFmode].insn_code = CODE_FOR_tansf2;
++ if (HAVE_tandf2)
++ tan_optab->handlers[DFmode].insn_code = CODE_FOR_tandf2;
++ if (HAVE_atansf2)
++ atan_optab->handlers[SFmode].insn_code = CODE_FOR_atansf2;
++ if (HAVE_atandf2)
++ atan_optab->handlers[DFmode].insn_code = CODE_FOR_atandf2;
++ if (HAVE_expsf2)
++ exp_optab->handlers[SFmode].insn_code = CODE_FOR_expsf2;
++ if (HAVE_expdf2)
++ exp_optab->handlers[DFmode].insn_code = CODE_FOR_expdf2;
++ if (HAVE_logsf2)
++ log_optab->handlers[SFmode].insn_code = CODE_FOR_logsf2;
++ if (HAVE_logdf2)
++ log_optab->handlers[DFmode].insn_code = CODE_FOR_logdf2;
++ if (HAVE_floatsisf2)
++ sfloat_optab->handlers[SFmode][SImode].insn_code = CODE_FOR_floatsisf2;
++ if (HAVE_floatsidf2)
++ sfloat_optab->handlers[DFmode][SImode].insn_code = CODE_FOR_floatsidf2;
++ if (HAVE_floatunssisf2)
++ ufloat_optab->handlers[SFmode][SImode].insn_code = CODE_FOR_floatunssisf2;
++ if (HAVE_floatunssidf2)
++ ufloat_optab->handlers[DFmode][SImode].insn_code = CODE_FOR_floatunssidf2;
++ if (HAVE_fixsfsi2)
++ sfix_optab->handlers[SImode][SFmode].insn_code = CODE_FOR_fixsfsi2;
++ if (HAVE_fixdfsi2)
++ sfix_optab->handlers[SImode][DFmode].insn_code = CODE_FOR_fixdfsi2;
++ if (HAVE_fixunssfsi2)
++ ufix_optab->handlers[SImode][SFmode].insn_code = CODE_FOR_fixunssfsi2;
++ if (HAVE_fixunsdfsi2)
++ ufix_optab->handlers[SImode][DFmode].insn_code = CODE_FOR_fixunsdfsi2;
++ if (HAVE_extendsfdf2)
++ sext_optab->handlers[DFmode][SFmode].insn_code = CODE_FOR_extendsfdf2;
++ if (HAVE_truncdfsf2)
++ trunc_optab->handlers[SFmode][DFmode].insn_code = CODE_FOR_truncdfsf2;
++ if (HAVE_cmpsf)
++ cmp_optab->handlers[SFmode].insn_code = CODE_FOR_cmpsf;
++ if (HAVE_cmpdf)
++ cmp_optab->handlers[DFmode].insn_code = CODE_FOR_cmpdf;
++ }
++
++ /* Check for duplicate values of N */
++ for (i = 0; i < 256; i++)
++ {
++ ns[i] = 0;
++ ps[i] = 0;
++ }
++
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ int N = nios2_fpu_insns[i].N;
++ if (N >= 0)
++ {
++ if (ns[N])
++ {
++ error ("%s%s' conflicts with %s%s'",
++ is_pragma ? "`#pragma custom_" : "switch `-mcustom-",
++ nios2_fpu_insns[i].option,
++ ps[N] ? "`#pragma custom_" : "switch `-mcustom-",
++ ns[N]);
++ errors = 1;
++ }
++ else if (builtin_custom_seen[N])
++ {
++ error ("call to `%s' conflicts with %s%s'",
++ builtin_custom_seen[N],
++ (nios2_fpu_insns[i].pragma_seen
++ ? "`#pragma custom_" : "switch `-mcustom-"),
++ nios2_fpu_insns[i].option);
++ errors = 1;
++ }
++ else
++ {
++ ns[N] = nios2_fpu_insns[i].option;
++ ps[N] = nios2_fpu_insns[i].pragma_seen;
++ }
++ }
++ }
++
++ if (errors)
++ {
++ fatal_error ("conflicting use of -mcustom switches, #pragmas, and/or __builtin_custom_ functions");
++ }
++}
++
++static void
++nios2_handle_custom_fpu_cfg (const char *cfg, int is_pragma)
++{
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ int opt = nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].N;
++NIOS2_FOR_ALL_FPU_INSNS
++
++ /*
++ * ??? These are just some sample possibilities. We'll change these
++ * at the last minute to match the capabilities of the actual fpu.
++ */
++ if (!strcasecmp (cfg, "60-1"))
++ {
++ fmuls = 252;
++ fadds = 253;
++ fsubs = 254;
++ flag_single_precision_constant = 1;
++ }
++ else if (!strcasecmp (cfg, "60-2"))
++ {
++ fmuls = 252;
++ fadds = 253;
++ fsubs = 254;
++ fdivs = 255;
++ flag_single_precision_constant = 1;
++ }
++ else if (!strcasecmp (cfg, "72-3"))
++ {
++ floatus = 243;
++ fixsi = 244;
++ floatis = 245;
++ fcmpgts = 246;
++ fcmples = 249;
++ fcmpeqs = 250;
++ fcmpnes = 251;
++ fmuls = 252;
++ fadds = 253;
++ fsubs = 254;
++ fdivs = 255;
++ flag_single_precision_constant = 1;
++ }
++ else
++ {
++ warning ("ignoring unrecognized %sfpu-cfg' value `%s'",
++ is_pragma ? "`#pragma custom_" : "switch -mcustom-", cfg);
++ }
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].N = opt;
++NIOS2_FOR_ALL_FPU_INSNS
++
++ /* Guard against errors in the standard configurations. */
++ nios2_custom_check_insns (is_pragma);
++}
++
++void
++override_options ()
++{
++ int i;
++
++ /* Function to allocate machine-dependent function status. */
++ init_machine_status = &nios2_init_machine_status;
++
++ nios2_section_threshold
++ = g_switch_set ? g_switch_value : NIOS2_DEFAULT_GVALUE;
++
++ if (nios2_sys_nosys_string && *nios2_sys_nosys_string)
++ {
++ error ("invalid option '-msys=nosys%s'", nios2_sys_nosys_string);
++ }
++
++ /* If we don't have mul, we don't have mulx either! */
++ if (!TARGET_HAS_MUL && TARGET_HAS_MULX)
++ {
++ target_flags &= ~HAS_MULX_FLAG;
++ }
++
++ /* Set up for stack limit checking */
++ if (TARGET_STACK_CHECK)
++ {
++ stack_limit_rtx = gen_rtx_REG(SImode, ET_REGNO);
++ }
++
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ nios2_fpu_insns[i].is_double = (nios2_fpu_insns[i].args[0] == 'd'
++ || nios2_fpu_insns[i].args[0] == 'd'
++ || nios2_fpu_insns[i].args[0] == 'd');
++ nios2_fpu_insns[i].needed_by_double = (i == nios2_fpu_nios2_fwrx
++ || i == nios2_fpu_nios2_fwry
++ || i == nios2_fpu_nios2_frdxlo
++ || i == nios2_fpu_nios2_frdxhi
++ || i == nios2_fpu_nios2_frdy);
++ nios2_fpu_insns[i].needs_unsafe = (i == nios2_fpu_cossf2
++ || i == nios2_fpu_cosdf2
++ || i == nios2_fpu_sinsf2
++ || i == nios2_fpu_sindf2
++ || i == nios2_fpu_tansf2
++ || i == nios2_fpu_tandf2
++ || i == nios2_fpu_atansf2
++ || i == nios2_fpu_atandf2
++ || i == nios2_fpu_expsf2
++ || i == nios2_fpu_expdf2
++ || i == nios2_fpu_logsf2
++ || i == nios2_fpu_logdf2);
++ nios2_fpu_insns[i].needs_finite = (i == nios2_fpu_minsf3
++ || i == nios2_fpu_maxsf3
++ || i == nios2_fpu_mindf3
++ || i == nios2_fpu_maxdf3);
++ }
++
++ /*
++ * We haven't seen any __builtin_custom functions yet.
++ */
++ for (i = 0; i < 256; i++)
++ {
++ builtin_custom_seen[i] = 0;
++ }
++
++ /*
++ * Set up default handling for floating point custom instructions.
++ *
++ * Putting things in this order means that the -mcustom-fpu-cfg=
++ * switch will always be overridden by individual -mcustom-fadds=
++ * switches, regardless of the order in which they were specified
++ * on the command line. ??? Remember to document this.
++ */
++ if (nios2_custom_fpu_cfg_string && *nios2_custom_fpu_cfg_string)
++ {
++ nios2_handle_custom_fpu_cfg (nios2_custom_fpu_cfg_string, 0);
++ }
++
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ nios2_custom_switch (nios2_fpu_insns[i].value,
++ &nios2_fpu_insns[i].N,
++ nios2_fpu_insns[i].option);
++ }
++
++ nios2_custom_check_insns (0);
++}
++
++void
++optimization_options (int level, int size)
++{
++ if (level || size)
++ {
++ target_flags |= INLINE_MEMCPY_FLAG;
++ }
++
++ if (level >= 3 && !size)
++ {
++ target_flags |= FAST_SW_DIV_FLAG;
++ }
++}
++
++/* Allocate a chunk of memory for per-function machine-dependent data. */
++static struct machine_function *
++nios2_init_machine_status ()
++{
++ return ((struct machine_function *)
++ ggc_alloc_cleared (sizeof (struct machine_function)));
++}
++
++
++
++/*****************
++ * Describing Relative Costs of Operations
++ *****************/
++
++/* Compute a (partial) cost for rtx X. Return true if the complete
++ cost has been computed, and false if subexpressions should be
++ scanned. In either case, *TOTAL contains the cost result. */
++
++
++
++static bool
++nios2_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
++{
++ switch (code)
++ {
++ case CONST_INT:
++ if (INTVAL (x) == 0)
++ {
++ *total = COSTS_N_INSNS (0);
++ return true;
++ }
++ else if (SMALL_INT (INTVAL (x))
++ || SMALL_INT_UNSIGNED (INTVAL (x))
++ || UPPER16_INT (INTVAL (x)))
++ {
++ *total = COSTS_N_INSNS (2);
++ return true;
++ }
++ else
++ {
++ *total = COSTS_N_INSNS (4);
++ return true;
++ }
++
++ case LABEL_REF:
++ case SYMBOL_REF:
++ /* ??? gp relative stuff will fit in here */
++ /* fall through */
++ case CONST:
++ case CONST_DOUBLE:
++ {
++ *total = COSTS_N_INSNS (4);
++ return true;
++ }
++
++ case MULT:
++ {
++ *total = COSTS_N_INSNS (1);
++ return false;
++ }
++ case SIGN_EXTEND:
++ {
++ *total = COSTS_N_INSNS (3);
++ return false;
++ }
++ case ZERO_EXTEND:
++ {
++ *total = COSTS_N_INSNS (1);
++ return false;
++ }
++
++ default:
++ return false;
++ }
++}
++
++
++/***************************************
++ * INSTRUCTION SUPPORT
++ *
++ * These functions are used within the Machine Description to
++ * handle common or complicated output and expansions from
++ * instructions.
++ ***************************************/
++
++int
++nios2_emit_move_sequence (rtx *operands, enum machine_mode mode)
++{
++ rtx to = operands[0];
++ rtx from = operands[1];
++
++ if (!register_operand (to, mode) && !reg_or_0_operand (from, mode))
++ {
++ if (no_new_pseudos)
++ internal_error ("Trying to force_reg no_new_pseudos == 1");
++ from = copy_to_mode_reg (mode, from);
++ }
++
++ operands[0] = to;
++ operands[1] = from;
++ return 0;
++}
++
++/* Divide Support */
++
++/*
++ If -O3 is used, we want to output a table lookup for
++ divides between small numbers (both num and den >= 0
++ and < 0x10). The overhead of this method in the worse
++ case is 40 bytes in the text section (10 insns) and
++ 256 bytes in the data section. Additional divides do
++ not incur additional penalties in the data section.
++
++ Code speed is improved for small divides by about 5x
++ when using this method in the worse case (~9 cycles
++ vs ~45). And in the worse case divides not within the
++ table are penalized by about 10% (~5 cycles vs ~45).
++ However in the typical case the penalty is not as bad
++ because doing the long divide in only 45 cycles is
++ quite optimistic.
++
++ ??? It would be nice to have some benchmarks other
++ than Dhrystone to back this up.
++
++ This bit of expansion is to create this instruction
++ sequence as rtl.
++ or $8, $4, $5
++ slli $9, $4, 4
++ cmpgeui $3, $8, 16
++ beq $3, $0, .L3
++ or $10, $9, $5
++ add $12, $11, divide_table
++ ldbu $2, 0($12)
++ br .L1
++.L3:
++ call slow_div
++.L1:
++# continue here with result in $2
++
++ ??? Ideally I would like the emit libcall block to contain
++ all of this code, but I don't know how to do that. What it
++ means is that if the divide can be eliminated, it may not
++ completely disappear.
++
++ ??? The __divsi3_table label should ideally be moved out
++ of this block and into a global. If it is placed into the
++ sdata section we can save even more cycles by doing things
++ gp relative.
++*/
++int
++nios2_emit_expensive_div (rtx *operands, enum machine_mode mode)
++{
++ rtx or_result, shift_left_result;
++ rtx lookup_value;
++ rtx lab1, lab3;
++ rtx insns;
++ rtx libfunc;
++ rtx final_result;
++ rtx tmp;
++
++ /* it may look a little generic, but only SImode
++ is supported for now */
++ if (mode != SImode)
++ abort ();
++
++ libfunc = sdiv_optab->handlers[(int) SImode].libfunc;
++
++
++
++ lab1 = gen_label_rtx ();
++ lab3 = gen_label_rtx ();
++
++ or_result = expand_simple_binop (SImode, IOR,
++ operands[1], operands[2],
++ 0, 0, OPTAB_LIB_WIDEN);
++
++ emit_cmp_and_jump_insns (or_result, GEN_INT (15), GTU, 0,
++ GET_MODE (or_result), 0, lab3);
++ JUMP_LABEL (get_last_insn ()) = lab3;
++
++ shift_left_result = expand_simple_binop (SImode, ASHIFT,
++ operands[1], GEN_INT (4),
++ 0, 0, OPTAB_LIB_WIDEN);
++
++ lookup_value = expand_simple_binop (SImode, IOR,
++ shift_left_result, operands[2],
++ 0, 0, OPTAB_LIB_WIDEN);
++
++ convert_move (operands[0],
++ gen_rtx (MEM, QImode,
++ gen_rtx (PLUS, SImode,
++ lookup_value,
++ gen_rtx_SYMBOL_REF (SImode, "__divsi3_table"))),
++ 1);
++
++
++ tmp = emit_jump_insn (gen_jump (lab1));
++ JUMP_LABEL (tmp) = lab1;
++ emit_barrier ();
++
++ emit_label (lab3);
++ LABEL_NUSES (lab3) = 1;
++
++ start_sequence ();
++ final_result = emit_library_call_value (libfunc, NULL_RTX,
++ LCT_CONST, SImode, 2,
++ operands[1], SImode,
++ operands[2], SImode);
++
++
++ insns = get_insns ();
++ end_sequence ();
++ emit_libcall_block (insns, operands[0], final_result,
++ gen_rtx (DIV, SImode, operands[1], operands[2]));
++
++ emit_label (lab1);
++ LABEL_NUSES (lab1) = 1;
++ return 1;
++}
++
++/* Branches/Compares */
++
++/* the way of handling branches/compares
++ in gcc is heavily borrowed from MIPS */
++
++enum internal_test
++{
++ ITEST_EQ,
++ ITEST_NE,
++ ITEST_GT,
++ ITEST_GE,
++ ITEST_LT,
++ ITEST_LE,
++ ITEST_GTU,
++ ITEST_GEU,
++ ITEST_LTU,
++ ITEST_LEU,
++ ITEST_MAX
++};
++
++static enum internal_test map_test_to_internal_test (enum rtx_code);
++
++/* Cached operands, and operator to compare for use in set/branch/trap
++ on condition codes. */
++rtx branch_cmp[2];
++enum cmp_type branch_type;
++
++/* Make normal rtx_code into something we can index from an array */
++
++static enum internal_test
++map_test_to_internal_test (enum rtx_code test_code)
++{
++ enum internal_test test = ITEST_MAX;
++
++ switch (test_code)
++ {
++ case EQ:
++ test = ITEST_EQ;
++ break;
++ case NE:
++ test = ITEST_NE;
++ break;
++ case GT:
++ test = ITEST_GT;
++ break;
++ case GE:
++ test = ITEST_GE;
++ break;
++ case LT:
++ test = ITEST_LT;
++ break;
++ case LE:
++ test = ITEST_LE;
++ break;
++ case GTU:
++ test = ITEST_GTU;
++ break;
++ case GEU:
++ test = ITEST_GEU;
++ break;
++ case LTU:
++ test = ITEST_LTU;
++ break;
++ case LEU:
++ test = ITEST_LEU;
++ break;
++ default:
++ break;
++ }
++
++ return test;
++}
++
++bool have_nios2_fpu_cmp_insn( enum rtx_code cond_t, enum cmp_type cmp_t );
++enum rtx_code get_reverse_cond(enum rtx_code cond_t);
++
++bool
++have_nios2_fpu_cmp_insn( enum rtx_code cond_t, enum cmp_type cmp_t )
++{
++ if (cmp_t == CMP_SF)
++ {
++ switch (cond_t) {
++ case EQ:
++ return (nios2_fpu_insns[nios2_fpu_nios2_seqsf].N >= 0);
++ case NE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_snesf].N >= 0);
++ case GT:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sgtsf].N >= 0);
++ case GE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sgesf].N >= 0);
++ case LT:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sltsf].N >= 0);
++ case LE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_slesf].N >= 0);
++ default:
++ break;
++ }
++ }
++ else if (cmp_t == CMP_DF)
++ {
++ switch (cond_t) {
++ case EQ:
++ return (nios2_fpu_insns[nios2_fpu_nios2_seqdf].N >= 0);
++ case NE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_snedf].N >= 0);
++ case GT:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sgtdf].N >= 0);
++ case GE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sgedf].N >= 0);
++ case LT:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sltdf].N >= 0);
++ case LE:
++ return (nios2_fpu_insns[nios2_fpu_nios2_sledf].N >= 0);
++ default:
++ break;
++ }
++ }
++
++ return false;
++}
++
++/* Note that get_reverse_cond() is not the same as get_inverse_cond()
++ get_reverse_cond() means that if the operand order is reversed,
++ what is the operand that is needed to generate the same condition?
++*/
++enum rtx_code
++get_reverse_cond(enum rtx_code cond_t)
++{
++ switch (cond_t)
++ {
++ case GT: return LT;
++ case GE: return LE;
++ case LT: return GT;
++ case LE: return GE;
++ case GTU: return LTU;
++ case GEU: return LEU;
++ case LTU: return GTU;
++ case LEU: return GEU;
++ default: break;
++ }
++
++ return cond_t;
++}
++
++
++/* Generate the code to compare (and possibly branch) two integer values
++ TEST_CODE is the comparison code we are trying to emulate
++ (or implement directly)
++ RESULT is where to store the result of the comparison,
++ or null to emit a branch
++ CMP0 CMP1 are the two comparison operands
++ DESTINATION is the destination of the branch, or null to only compare
++ */
++
++void
++gen_int_relational (enum rtx_code test_code, /* relational test (EQ, etc) */
++ rtx result, /* result to store comp. or 0 if branch */
++ rtx cmp0, /* first operand to compare */
++ rtx cmp1, /* second operand to compare */
++ rtx destination) /* destination of the branch, or 0 if compare */
++{
++ struct cmp_info
++ {
++ /* for register (or 0) compares */
++ enum rtx_code test_code_reg; /* code to use in instruction (LT vs. LTU) */
++ int reverse_regs; /* reverse registers in test */
++
++ /* for immediate compares */
++ enum rtx_code test_code_const;
++ /* code to use in instruction (LT vs. LTU) */
++ int const_low; /* low bound of constant we can accept */
++ int const_high; /* high bound of constant we can accept */
++ int const_add; /* constant to add */
++
++ /* generic info */
++ int unsignedp; /* != 0 for unsigned comparisons. */
++ };
++
++ static const struct cmp_info info[(int) ITEST_MAX] = {
++
++ {EQ, 0, EQ, -32768, 32767, 0, 0}, /* EQ */
++ {NE, 0, NE, -32768, 32767, 0, 0}, /* NE */
++
++ {LT, 1, GE, -32769, 32766, 1, 0}, /* GT */
++ {GE, 0, GE, -32768, 32767, 0, 0}, /* GE */
++ {LT, 0, LT, -32768, 32767, 0, 0}, /* LT */
++ {GE, 1, LT, -32769, 32766, 1, 0}, /* LE */
++
++ {LTU, 1, GEU, 0, 65534, 1, 0}, /* GTU */
++ {GEU, 0, GEU, 0, 65535, 0, 0}, /* GEU */
++ {LTU, 0, LTU, 0, 65535, 0, 0}, /* LTU */
++ {GEU, 1, LTU, 0, 65534, 1, 0}, /* LEU */
++ };
++
++ enum internal_test test;
++ enum machine_mode mode;
++ const struct cmp_info *p_info;
++ int branch_p;
++
++
++ test = map_test_to_internal_test (test_code);
++ if (test == ITEST_MAX)
++ abort ();
++
++ p_info = &info[(int) test];
++
++ mode = GET_MODE (cmp0);
++ if (mode == VOIDmode)
++ mode = GET_MODE (cmp1);
++
++ branch_p = (destination != 0);
++
++ /* Handle floating point comparison directly. */
++ if (branch_type == CMP_SF || branch_type == CMP_DF)
++ {
++
++ bool reverse_operands = false;
++
++ enum machine_mode float_mode = (branch_type == CMP_SF) ? SFmode : DFmode;
++
++ if (!register_operand (cmp0, float_mode)
++ || !register_operand (cmp1, float_mode))
++ {
++ abort ();
++ }
++
++ if (branch_p)
++ {
++ test_code = p_info->test_code_reg;
++ reverse_operands = (p_info->reverse_regs);
++ }
++
++ if ( !have_nios2_fpu_cmp_insn(test_code, branch_type) &&
++ have_nios2_fpu_cmp_insn(get_reverse_cond(test_code), branch_type) )
++ {
++ test_code = get_reverse_cond(test_code);
++ reverse_operands = !reverse_operands;
++ }
++
++ if (reverse_operands)
++ {
++ rtx temp = cmp0;
++ cmp0 = cmp1;
++ cmp1 = temp;
++ }
++
++ if (branch_p)
++ {
++ rtx cond = gen_rtx (test_code, SImode, cmp0, cmp1);
++ rtx label = gen_rtx_LABEL_REF (VOIDmode, destination);
++ rtx insn = gen_rtx_SET (VOIDmode, pc_rtx,
++ gen_rtx_IF_THEN_ELSE (VOIDmode,
++ cond, label, pc_rtx));
++ emit_jump_insn (insn);
++ }
++ else
++ {
++ emit_move_insn (result, gen_rtx (test_code, SImode, cmp0, cmp1));
++ }
++ return;
++ }
++
++ /* We can't, under any circumstances, have const_ints in cmp0
++ ??? Actually we could have const0 */
++ if (GET_CODE (cmp0) == CONST_INT)
++ cmp0 = force_reg (mode, cmp0);
++
++ /* if the comparison is against an int not in legal range
++ move it into a register */
++ if (GET_CODE (cmp1) == CONST_INT)
++ {
++ HOST_WIDE_INT value = INTVAL (cmp1);
++
++ if (value < p_info->const_low || value > p_info->const_high)
++ cmp1 = force_reg (mode, cmp1);
++ }
++
++ /* Comparison to constants, may involve adding 1 to change a GT into GE.
++ Comparison between two registers, may involve switching operands. */
++ if (GET_CODE (cmp1) == CONST_INT)
++ {
++ if (p_info->const_add != 0)
++ {
++ HOST_WIDE_INT new = INTVAL (cmp1) + p_info->const_add;
++
++ /* If modification of cmp1 caused overflow,
++ we would get the wrong answer if we follow the usual path;
++ thus, x > 0xffffffffU would turn into x > 0U. */
++ if ((p_info->unsignedp
++ ? (unsigned HOST_WIDE_INT) new >
++ (unsigned HOST_WIDE_INT) INTVAL (cmp1)
++ : new > INTVAL (cmp1)) != (p_info->const_add > 0))
++ {
++ /* ??? This case can never happen with the current numbers,
++ but I am paranoid and would rather an abort than
++ a bug I will never find */
++ abort ();
++ }
++ else
++ cmp1 = GEN_INT (new);
++ }
++ }
++
++ else if (p_info->reverse_regs)
++ {
++ rtx temp = cmp0;
++ cmp0 = cmp1;
++ cmp1 = temp;
++ }
++
++
++
++ if (branch_p)
++ {
++ if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
++ {
++ rtx insn;
++ rtx cond = gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1);
++ rtx label = gen_rtx_LABEL_REF (VOIDmode, destination);
++
++ insn = gen_rtx_SET (VOIDmode, pc_rtx,
++ gen_rtx_IF_THEN_ELSE (VOIDmode,
++ cond, label, pc_rtx));
++ emit_jump_insn (insn);
++ }
++ else
++ {
++ rtx cond, label;
++
++ result = gen_reg_rtx (mode);
++
++ emit_move_insn (result,
++ gen_rtx (p_info->test_code_const, mode, cmp0,
++ cmp1));
++
++ cond = gen_rtx (NE, mode, result, const0_rtx);
++ label = gen_rtx_LABEL_REF (VOIDmode, destination);
++
++ emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
++ gen_rtx_IF_THEN_ELSE (VOIDmode,
++ cond,
++ label, pc_rtx)));
++ }
++ }
++ else
++ {
++ if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
++ {
++ emit_move_insn (result,
++ gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1));
++ }
++ else
++ {
++ emit_move_insn (result,
++ gen_rtx (p_info->test_code_const, mode, cmp0,
++ cmp1));
++ }
++ }
++
++}
++
++
++/* ??? For now conditional moves are only supported
++ when the mode of the operands being compared are
++ the same as the ones being moved */
++
++void
++gen_conditional_move (rtx *operands, enum machine_mode mode)
++{
++ rtx insn, cond;
++ rtx cmp_reg = gen_reg_rtx (mode);
++ enum rtx_code cmp_code = GET_CODE (operands[1]);
++ enum rtx_code move_code = EQ;
++
++ /* emit a comparison if it is not "simple".
++ Simple comparisons are X eq 0 and X ne 0 */
++ if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[1] == const0_rtx)
++ {
++ cmp_reg = branch_cmp[0];
++ move_code = cmp_code;
++ }
++ else if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[0] == const0_rtx)
++ {
++ cmp_reg = branch_cmp[1];
++ move_code = cmp_code == EQ ? NE : EQ;
++ }
++ else
++ gen_int_relational (cmp_code, cmp_reg, branch_cmp[0], branch_cmp[1],
++ NULL_RTX);
++
++ cond = gen_rtx (move_code, VOIDmode, cmp_reg, CONST0_RTX (mode));
++ insn = gen_rtx_SET (mode, operands[0],
++ gen_rtx_IF_THEN_ELSE (mode,
++ cond, operands[2], operands[3]));
++ emit_insn (insn);
++}
++
++/*******************
++ * Addressing Modes
++ *******************/
++
++int
++nios2_legitimate_address (rtx operand, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int strict)
++{
++ int ret_val = 0;
++
++ switch (GET_CODE (operand))
++ {
++ /* direct. */
++ case SYMBOL_REF:
++ if (SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (operand))
++ {
++ ret_val = 1;
++ break;
++ }
++ /* else, fall through */
++ case LABEL_REF:
++ case CONST_INT:
++ case CONST:
++ case CONST_DOUBLE:
++ /* ??? In here I need to add gp addressing */
++ ret_val = 0;
++
++ break;
++
++ /* Register indirect. */
++ case REG:
++ ret_val = REG_OK_FOR_BASE_P2 (operand, strict);
++ break;
++
++ /* Register indirect with displacement */
++ case PLUS:
++ {
++ rtx op0 = XEXP (operand, 0);
++ rtx op1 = XEXP (operand, 1);
++
++ if (REG_P (op0) && REG_P (op1))
++ ret_val = 0;
++ else if (REG_P (op0) && GET_CODE (op1) == CONST_INT)
++ ret_val = REG_OK_FOR_BASE_P2 (op0, strict)
++ && SMALL_INT (INTVAL (op1));
++ else if (REG_P (op1) && GET_CODE (op0) == CONST_INT)
++ ret_val = REG_OK_FOR_BASE_P2 (op1, strict)
++ && SMALL_INT (INTVAL (op0));
++ else
++ ret_val = 0;
++ }
++ break;
++
++ default:
++ ret_val = 0;
++ break;
++ }
++
++ return ret_val;
++}
++
++/* Return true if EXP should be placed in the small data section. */
++
++static bool
++nios2_in_small_data_p (tree exp)
++{
++ /* We want to merge strings, so we never consider them small data. */
++ if (TREE_CODE (exp) == STRING_CST)
++ return false;
++
++ if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
++ {
++ const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
++ /* ??? these string names need moving into
++ an array in some header file */
++ if (nios2_section_threshold > 0
++ && (strcmp (section, ".sbss") == 0
++ || strncmp (section, ".sbss.", 6) == 0
++ || strcmp (section, ".sdata") == 0
++ || strncmp (section, ".sdata.", 7) == 0))
++ return true;
++ }
++ else if (TREE_CODE (exp) == VAR_DECL)
++ {
++ HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
++
++ /* If this is an incomplete type with size 0, then we can't put it
++ in sdata because it might be too big when completed. */
++ if (size > 0 && (unsigned HOST_WIDE_INT)size <= nios2_section_threshold)
++ return true;
++ }
++
++ return false;
++}
++
++static void
++nios2_encode_section_info (tree decl, rtx rtl, int first)
++{
++
++ rtx symbol;
++ int flags;
++
++ default_encode_section_info (decl, rtl, first);
++
++ /* Careful not to prod global register variables. */
++ if (GET_CODE (rtl) != MEM)
++ return;
++ symbol = XEXP (rtl, 0);
++ if (GET_CODE (symbol) != SYMBOL_REF)
++ return;
++
++ flags = SYMBOL_REF_FLAGS (symbol);
++
++ /* We don't want weak variables to be addressed with gp in case they end up with
++ value 0 which is not within 2^15 of $gp */
++ if (DECL_P (decl) && DECL_WEAK (decl))
++ flags |= SYMBOL_FLAG_WEAK_DECL;
++
++ SYMBOL_REF_FLAGS (symbol) = flags;
++}
++
++
++static unsigned int
++nios2_section_type_flags (tree decl, const char *name, int reloc)
++{
++ unsigned int flags;
++
++ flags = default_section_type_flags (decl, name, reloc);
++
++ /* ??? these string names need moving into an array in some header file */
++ if (strcmp (name, ".sbss") == 0
++ || strncmp (name, ".sbss.", 6) == 0
++ || strcmp (name, ".sdata") == 0
++ || strncmp (name, ".sdata.", 7) == 0)
++ flags |= SECTION_SMALL;
++
++ return flags;
++}
++
++/* Handle a #pragma reverse_bitfields */
++static void
++nios2_pragma_reverse_bitfields (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
++{
++ nios2_pragma_reverse_bitfields_flag = 1; /* Reverse */
++}
++
++/* Handle a #pragma no_reverse_bitfields */
++static void
++nios2_pragma_no_reverse_bitfields (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
++{
++ nios2_pragma_reverse_bitfields_flag = -1; /* Forward */
++}
++
++/* Handle the various #pragma custom_<switch>s */
++static void
++nios2_pragma_fpu (int *value, const char *opt, int *seen)
++{
++ tree t;
++ if (c_lex (&t) != CPP_NUMBER)
++ {
++ error ("`#pragma custom_%s' value must be a number between 0 and 255",
++ opt);
++ return;
++ }
++
++ if (TREE_INT_CST_HIGH (t) == 0
++ && TREE_INT_CST_LOW (t) <= 255)
++ {
++ *value = (int)TREE_INT_CST_LOW (t);
++ *seen = 1;
++ }
++ else
++ {
++ error ("`#pragma custom_%s' value must be between 0 and 255", opt);
++ }
++ nios2_custom_check_insns (1);
++}
++
++/* Handle the various #pragma no_custom_<switch>s */
++static void
++nios2_pragma_no_fpu (int *value, const char *opt ATTRIBUTE_UNUSED)
++{
++ *value = -1;
++ nios2_custom_check_insns (1);
++}
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++static void \
++NIOS2_CONCAT (nios2_pragma_, insn) \
++ (struct cpp_reader *pfile ATTRIBUTE_UNUSED) \
++{ \
++ nios2_fpu_info *inf = &(nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)]); \
++ nios2_pragma_fpu (&(inf->N), inf->option, &(inf->pragma_seen)); \
++} \
++static void \
++NIOS2_CONCAT (nios2_pragma_no_, insn) \
++ (struct cpp_reader *pfile ATTRIBUTE_UNUSED) \
++{ \
++ nios2_fpu_info *inf = &(nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)]); \
++ nios2_pragma_no_fpu (&(inf->N), inf->option); \
++}
++NIOS2_FOR_ALL_FPU_INSNS
++
++static void
++nios2_pragma_handle_custom_fpu_cfg (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
++{
++ tree t;
++ if (c_lex (&t) != CPP_STRING)
++ {
++ error ("`#pragma custom_fpu_cfg' value must be a string");
++ return;
++ }
++
++ if (TREE_STRING_LENGTH (t) > 0)
++ {
++ nios2_handle_custom_fpu_cfg (TREE_STRING_POINTER (t), 1);
++ }
++}
++
++void
++nios2_register_target_pragmas ()
++{
++ int i;
++
++ c_register_pragma (0, "reverse_bitfields",
++ nios2_pragma_reverse_bitfields);
++ c_register_pragma (0, "no_reverse_bitfields",
++ nios2_pragma_no_reverse_bitfields);
++
++ for (i = 0; i < nios2_fpu_max_insn; i++)
++ {
++ nios2_fpu_info *inf = &(nios2_fpu_insns[i]);
++ c_register_pragma (0, inf->pname, inf->pragma);
++ c_register_pragma (0, inf->nopname, inf->nopragma);
++ }
++
++ c_register_pragma (0, "custom_fpu_cfg",
++ nios2_pragma_handle_custom_fpu_cfg);
++}
++
++/* Handle a "reverse_bitfields" or "no_reverse_bitfields" attribute.
++ ??? What do these attributes mean on a union? */
++static tree
++nios2_handle_struct_attribute (tree *node, tree name,
++ tree args ATTRIBUTE_UNUSED,
++ int flags ATTRIBUTE_UNUSED,
++ bool *no_add_attrs)
++{
++ tree *type = NULL;
++ if (DECL_P (*node))
++ {
++ if (TREE_CODE (*node) == TYPE_DECL)
++ {
++ type = &TREE_TYPE (*node);
++ }
++ }
++ else
++ {
++ type = node;
++ }
++
++ if (!(type && (TREE_CODE (*type) == RECORD_TYPE
++ || TREE_CODE (*type) == UNION_TYPE)))
++ {
++ warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
++ *no_add_attrs = true;
++ }
++
++ else if ((is_attribute_p ("reverse_bitfields", name)
++ && lookup_attribute ("no_reverse_bitfields",
++ TYPE_ATTRIBUTES (*type)))
++ || ((is_attribute_p ("no_reverse_bitfields", name)
++ && lookup_attribute ("reverse_bitfields",
++ TYPE_ATTRIBUTES (*type)))))
++ {
++ warning ("`%s' incompatible attribute ignored",
++ IDENTIFIER_POINTER (name));
++ *no_add_attrs = true;
++ }
++
++ return NULL_TREE;
++}
++
++/*
++ Add __attribute__ ((pragma_reverse_bitfields)) when in the scope of a
++ #pragma reverse_bitfields, or __attribute__
++ ((pragma_no_reverse_bitfields)) when in the scope of a #pragma
++ no_reverse_bitfields. This gets called before
++ nios2_handle_struct_attribute above, so we can't just reuse the same
++ attributes.
++*/
++static void
++nios2_insert_attributes (tree node, tree *attr_ptr)
++{
++ tree type = NULL;
++ if (DECL_P (node))
++ {
++ if (TREE_CODE (node) == TYPE_DECL)
++ {
++ type = TREE_TYPE (node);
++ }
++ }
++ else
++ {
++ type = node;
++ }
++
++ if (!type
++ || (TREE_CODE (type) != RECORD_TYPE
++ && TREE_CODE (type) != UNION_TYPE))
++ {
++ /* We can ignore things other than structs & unions */
++ return;
++ }
++
++ if (lookup_attribute ("reverse_bitfields", TYPE_ATTRIBUTES (type))
++ || lookup_attribute ("no_reverse_bitfields", TYPE_ATTRIBUTES (type)))
++ {
++ /* If an attribute is already set, it silently overrides the
++ current #pragma, if any */
++ return;
++ }
++
++ if (nios2_pragma_reverse_bitfields_flag)
++ {
++ const char *id = (nios2_pragma_reverse_bitfields_flag == 1 ?
++ "pragma_reverse_bitfields" :
++ "pragma_no_reverse_bitfields");
++ /* No attribute set, and we are in the scope of a #pragma */
++ *attr_ptr = tree_cons (get_identifier (id), NULL, *attr_ptr);
++ }
++}
++
++
++/*
++ * The attributes take precedence over the pragmas, which in turn take
++ * precedence over the compile-time switches.
++ */
++static bool
++nios2_reverse_bitfield_layout_p (tree record_type)
++{
++ return ((TARGET_REVERSE_BITFIELDS
++ && !lookup_attribute ("pragma_no_reverse_bitfields",
++ TYPE_ATTRIBUTES (record_type))
++ && !lookup_attribute ("no_reverse_bitfields",
++ TYPE_ATTRIBUTES (record_type)))
++ || (lookup_attribute ("pragma_reverse_bitfields",
++ TYPE_ATTRIBUTES (record_type))
++ && !lookup_attribute ("no_reverse_bitfields",
++ TYPE_ATTRIBUTES (record_type)))
++ || lookup_attribute ("reverse_bitfields",
++ TYPE_ATTRIBUTES (record_type)));
++}
++
++
++/*****************************************
++ * Defining the Output Assembler Language
++ *****************************************/
++
++/* -------------- *
++ * Output of Data
++ * -------------- */
++
++
++/* -------------------------------- *
++ * Output of Assembler Instructions
++ * -------------------------------- */
++
++
++/* print the operand OP to file stream
++ FILE modified by LETTER. LETTER
++ can be one of:
++ i: print "i" if OP is an immediate, except 0
++ o: print "io" if OP is volatile
++
++ z: for const0_rtx print $0 instead of 0
++ H: for %hiadj
++ L: for %lo
++ U: for upper half of 32 bit value
++ D: for the upper 32-bits of a 64-bit double value
++ */
++
++void
++nios2_print_operand (FILE *file, rtx op, int letter)
++{
++
++ switch (letter)
++ {
++ case 'i':
++ if (CONSTANT_P (op) && (op != const0_rtx))
++ fprintf (file, "i");
++ return;
++
++ case 'o':
++ if (GET_CODE (op) == MEM
++ && ((MEM_VOLATILE_P (op) && !TARGET_CACHE_VOLATILE)
++ || TARGET_BYPASS_CACHE))
++ fprintf (file, "io");
++ return;
++
++ default:
++ break;
++ }
++
++ if (comparison_operator (op, VOIDmode))
++ {
++ if (letter == 0)
++ {
++ fprintf (file, "%s", GET_RTX_NAME (GET_CODE (op)));
++ return;
++ }
++ }
++
++
++ switch (GET_CODE (op))
++ {
++ case REG:
++ if (letter == 0 || letter == 'z')
++ {
++ fprintf (file, "%s", reg_names[REGNO (op)]);
++ return;
++ }
++ else if (letter == 'D')
++ {
++ fprintf (file, "%s", reg_names[REGNO (op)+1]);
++ return;
++ }
++ break;
++
++ case CONST_INT:
++ if (INTVAL (op) == 0 && letter == 'z')
++ {
++ fprintf (file, "zero");
++ return;
++ }
++ else if (letter == 'U')
++ {
++ HOST_WIDE_INT val = INTVAL (op);
++ rtx new_op;
++ val = (val / 65536) & 0xFFFF;
++ new_op = GEN_INT (val);
++ output_addr_const (file, new_op);
++ return;
++ }
++
++ /* else, fall through */
++ case CONST:
++ case LABEL_REF:
++ case SYMBOL_REF:
++ case CONST_DOUBLE:
++ if (letter == 0 || letter == 'z')
++ {
++ output_addr_const (file, op);
++ return;
++ }
++ else if (letter == 'H')
++ {
++ fprintf (file, "%%hiadj(");
++ output_addr_const (file, op);
++ fprintf (file, ")");
++ return;
++ }
++ else if (letter == 'L')
++ {
++ fprintf (file, "%%lo(");
++ output_addr_const (file, op);
++ fprintf (file, ")");
++ return;
++ }
++ break;
++
++
++ case SUBREG:
++ case MEM:
++ if (letter == 0)
++ {
++ output_address (op);
++ return;
++ }
++ break;
++
++ case CODE_LABEL:
++ if (letter == 0)
++ {
++ output_addr_const (file, op);
++ return;
++ }
++ break;
++
++ default:
++ break;
++ }
++
++ fprintf (stderr, "Missing way to print (%c) ", letter);
++ debug_rtx (op);
++ abort ();
++}
++
++static int gprel_constant (rtx);
++
++static int
++gprel_constant (rtx op)
++{
++ if (GET_CODE (op) == SYMBOL_REF
++ && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (op))
++ {
++ return 1;
++ }
++ else if (GET_CODE (op) == CONST
++ && GET_CODE (XEXP (op, 0)) == PLUS)
++ {
++ return gprel_constant (XEXP (XEXP (op, 0), 0));
++ }
++ else
++ {
++ return 0;
++ }
++}
++
++void
++nios2_print_operand_address (FILE *file, rtx op)
++{
++ switch (GET_CODE (op))
++ {
++ case CONST:
++ case CONST_INT:
++ case LABEL_REF:
++ case CONST_DOUBLE:
++ case SYMBOL_REF:
++ if (gprel_constant (op))
++ {
++ fprintf (file, "%%gprel(");
++ output_addr_const (file, op);
++ fprintf (file, ")(%s)", reg_names[GP_REGNO]);
++ return;
++ }
++
++ break;
++
++ case PLUS:
++ {
++ rtx op0 = XEXP (op, 0);
++ rtx op1 = XEXP (op, 1);
++
++ if (REG_P (op0) && CONSTANT_P (op1))
++ {
++ output_addr_const (file, op1);
++ fprintf (file, "(%s)", reg_names[REGNO (op0)]);
++ return;
++ }
++ else if (REG_P (op1) && CONSTANT_P (op0))
++ {
++ output_addr_const (file, op0);
++ fprintf (file, "(%s)", reg_names[REGNO (op1)]);
++ return;
++ }
++ }
++ break;
++
++ case REG:
++ fprintf (file, "0(%s)", reg_names[REGNO (op)]);
++ return;
++
++ case MEM:
++ {
++ rtx base = XEXP (op, 0);
++ PRINT_OPERAND_ADDRESS (file, base);
++ return;
++ }
++ default:
++ break;
++ }
++
++ fprintf (stderr, "Missing way to print address\n");
++ debug_rtx (op);
++ abort ();
++}
++
++
++
++
++
++/****************************
++ * Predicates
++ ****************************/
++
++int
++arith_operand (rtx op, enum machine_mode mode)
++{
++ if (GET_CODE (op) == CONST_INT && SMALL_INT (INTVAL (op)))
++ return 1;
++
++ return register_operand (op, mode);
++}
++
++int
++uns_arith_operand (rtx op, enum machine_mode mode)
++{
++ if (GET_CODE (op) == CONST_INT && SMALL_INT_UNSIGNED (INTVAL (op)))
++ return 1;
++
++ return register_operand (op, mode);
++}
++
++int
++logical_operand (rtx op, enum machine_mode mode)
++{
++ if (GET_CODE (op) == CONST_INT
++ && (SMALL_INT_UNSIGNED (INTVAL (op)) || UPPER16_INT (INTVAL (op))))
++ return 1;
++
++ return register_operand (op, mode);
++}
++
++int
++shift_operand (rtx op, enum machine_mode mode)
++{
++ if (GET_CODE (op) == CONST_INT && SHIFT_INT (INTVAL (op)))
++ return 1;
++
++ return register_operand (op, mode);
++}
++
++int
++rdwrctl_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
++{
++ return GET_CODE (op) == CONST_INT && RDWRCTL_INT (INTVAL (op));
++}
++
++/* Return truth value of whether OP is a register or the constant 0. */
++
++int
++reg_or_0_operand (rtx op, enum machine_mode mode)
++{
++ switch (GET_CODE (op))
++ {
++ case CONST_INT:
++ return INTVAL (op) == 0;
++
++ case CONST_DOUBLE:
++ return op == CONST0_RTX (mode);
++
++ default:
++ break;
++ }
++
++ return register_operand (op, mode);
++}
++
++
++int
++equality_op (rtx op, enum machine_mode mode)
++{
++ if (mode != GET_MODE (op))
++ return 0;
++
++ return GET_CODE (op) == EQ || GET_CODE (op) == NE;
++}
++
++int
++custom_insn_opcode (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
++{
++ return GET_CODE (op) == CONST_INT && CUSTOM_INSN_OPCODE (INTVAL (op));
++}
++
++
++
++
++/*****************************************************************************
++**
++** custom fpu instruction output
++**
++*****************************************************************************/
++
++static const char *nios2_custom_fpu_insn_zdz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_zsz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_szz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_sss (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_ssz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_iss (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_ddd (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_ddz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_idd (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_siz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_suz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_diz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_duz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_isz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_usz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_idz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_udz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_dsz (rtx, int, const char *);
++static const char *nios2_custom_fpu_insn_sdz (rtx, int, const char *);
++
++static const char *
++nios2_custom_fpu_insn_zdz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, zero, %%0, %%D0 # %s %%0",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_zsz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, zero, %%0, zero # %s %%0",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_szz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%0, zero, zero # %s %%0",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_sss (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%0, %%1, %%2 # %s %%0, %%1, %%2",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_ssz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%0, %%1, zero # %s %%0, %%1",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_iss (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_sss (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_ddd (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0
++ || nios2_fpu_insns[nios2_fpu_nios2_frdy].N < 0
++ || nios2_fpu_insns[nios2_fpu_nios2_fwrx].N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, zero, %%1, %%D1 # fwrx %%1\n\t"
++ "custom\t%d, %%D0, %%2, %%D2 # %s %%0, %%1, %%2\n\t"
++ "custom\t%d, %%0, zero, zero # frdy %%0",
++ nios2_fpu_insns[nios2_fpu_nios2_fwrx].N,
++ N, opt,
++ nios2_fpu_insns[nios2_fpu_nios2_frdy].N) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_ddz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0 || nios2_fpu_insns[nios2_fpu_nios2_frdy].N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%D0, %%1, %%D1 # %s %%0, %%1\n\t"
++ "custom\t%d, %%0, zero, zero # frdy %%0",
++ N, opt,
++ nios2_fpu_insns[nios2_fpu_nios2_frdy].N) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_idd (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0 || nios2_fpu_insns[nios2_fpu_nios2_fwrx].N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, zero, %%1, %%D1 # fwrx %%1\n\t"
++ "custom\t%d, %%0, %%2, %%D2 # %s %%0, %%1, %%2",
++ nios2_fpu_insns[nios2_fpu_nios2_fwrx].N,
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_siz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_ssz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_suz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_ssz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_diz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_dsz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_duz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_dsz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_isz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_ssz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_usz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_ssz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_idz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_sdz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_udz (rtx insn, int N, const char *opt)
++{
++ return nios2_custom_fpu_insn_sdz (insn, N, opt);
++}
++
++static const char *
++nios2_custom_fpu_insn_dsz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0 || nios2_fpu_insns[nios2_fpu_nios2_frdy].N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%D0, %%1, zero # %s %%0, %%1\n\t"
++ "custom\t%d, %%0, zero, zero # frdy %%0",
++ N, opt,
++ nios2_fpu_insns[nios2_fpu_nios2_frdy].N) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++static const char *
++nios2_custom_fpu_insn_sdz (rtx insn, int N, const char *opt)
++{
++ static char buf[1024];
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ "custom\t%d, %%0, %%1, %%D1 # %s %%0, %%1",
++ N, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++static const char * \
++NIOS2_CONCAT (nios2_output_fpu_insn_, insn) (rtx i) \
++{ \
++ return NIOS2_CONCAT (nios2_custom_fpu_insn_, args) \
++ (i, \
++ nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].N, \
++ nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].option); \
++}
++NIOS2_FOR_ALL_FPU_INSNS
++
++
++
++const char *
++nios2_output_fpu_insn_cmps (rtx insn, enum rtx_code cond)
++{
++ static char buf[1024];
++ int N;
++ const char *opt;
++
++ int operandL = 2;
++ int operandR = 3;
++
++ if ( !have_nios2_fpu_cmp_insn(cond, CMP_SF) &&
++ have_nios2_fpu_cmp_insn(get_reverse_cond(cond), CMP_SF) ) {
++
++ int temp = operandL;
++ operandL = operandR;
++ operandR = temp;
++
++ cond = get_reverse_cond(cond);
++ }
++
++ switch (cond)
++ {
++ case EQ:
++ N = nios2_fpu_insns[nios2_fpu_nios2_seqsf].N;
++ opt = "fcmpeqs";
++ break;
++ case NE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_snesf].N;
++ opt = "fcmpnes";
++ break;
++ case GT:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sgtsf].N;
++ opt = "fcmpgts";
++ break;
++ case GE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sgesf].N;
++ opt = "fcmpges";
++ break;
++ case LT:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sltsf].N;
++ opt = "fcmplts";
++ break;
++ case LE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_slesf].N;
++ opt = "fcmples"; break;
++ default:
++ fatal_insn ("bad single compare", insn);
++ }
++
++ if (N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++
++ /*
++ * ??? This raises the whole vexing issue of how to handle
++ * out-of-range branches. Punt for now, seeing as how nios2-elf-as
++ * doesn't even _try_ to handle out-of-range branches yet!
++ */
++ if (snprintf (buf, sizeof (buf),
++ ".set\tnoat\n\t"
++ "custom\t%d, at, %%%d, %%%d # %s at, %%%d, %%%d\n\t"
++ "bne\tat, zero, %%l1\n\t"
++ ".set\tat",
++ N, operandL, operandR, opt, operandL, operandR) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++const char *
++nios2_output_fpu_insn_cmpd (rtx insn, enum rtx_code cond)
++{
++ static char buf[1024];
++ int N;
++ const char *opt;
++
++ int operandL = 2;
++ int operandR = 3;
++
++ if ( !have_nios2_fpu_cmp_insn(cond, CMP_DF) &&
++ have_nios2_fpu_cmp_insn(get_reverse_cond(cond), CMP_DF) ) {
++
++ int temp = operandL;
++ operandL = operandR;
++ operandR = temp;
++
++ cond = get_reverse_cond(cond);
++ }
++
++ switch (cond)
++ {
++ case EQ:
++ N = nios2_fpu_insns[nios2_fpu_nios2_seqdf].N;
++ opt = "fcmpeqd";
++ break;
++ case NE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_snedf].N;
++ opt = "fcmpned";
++ break;
++ case GT:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sgtdf].N;
++ opt = "fcmpgtd";
++ break;
++ case GE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sgedf].N;
++ opt = "fcmpged";
++ break;
++ case LT:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sltdf].N;
++ opt = "fcmpltd";
++ break;
++ case LE:
++ N = nios2_fpu_insns[nios2_fpu_nios2_sledf].N;
++ opt = "fcmpled";
++ break;
++ default:
++ fatal_insn ("bad double compare", insn);
++ }
++
++ if (N < 0 || nios2_fpu_insns[nios2_fpu_nios2_fwrx].N < 0)
++ {
++ fatal_insn ("attempt to use disabled fpu instruction", insn);
++ }
++ if (snprintf (buf, sizeof (buf),
++ ".set\tnoat\n\t"
++ "custom\t%d, zero, %%%d, %%D%d # fwrx %%%d\n\t"
++ "custom\t%d, at, %%%d, %%D%d # %s at, %%%d, %%%d\n\t"
++ "bne\tat, zero, %%l1\n\t"
++ ".set\tat",
++ nios2_fpu_insns[nios2_fpu_nios2_fwrx].N, operandL, operandL, operandL,
++ N, operandR, operandR, operandL, operandR, opt) >= (int)sizeof (buf))
++ {
++ fatal_insn ("buffer overflow", insn);
++ }
++ return buf;
++}
++
++
++
++
++/*****************************************************************************
++**
++** instruction scheduler
++**
++*****************************************************************************/
++static int
++nios2_use_dfa_pipeline_interface ()
++{
++ return 1;
++}
++
++
++static int
++nios2_issue_rate ()
++{
++#ifdef MAX_DFA_ISSUE_RATE
++ return MAX_DFA_ISSUE_RATE;
++#else
++ return 1;
++#endif
++}
++
++
++const char *
++asm_output_opcode (FILE *file ATTRIBUTE_UNUSED,
++ const char *ptr ATTRIBUTE_UNUSED)
++{
++ const char *p;
++
++ p = ptr;
++ return ptr;
++}
++
++
++
++/*****************************************************************************
++**
++** function arguments
++**
++*****************************************************************************/
++
++void
++init_cumulative_args (CUMULATIVE_ARGS *cum,
++ tree fntype ATTRIBUTE_UNUSED,
++ rtx libname ATTRIBUTE_UNUSED,
++ tree fndecl ATTRIBUTE_UNUSED,
++ int n_named_args ATTRIBUTE_UNUSED)
++{
++ cum->regs_used = 0;
++}
++
++
++/* Define where to put the arguments to a function. Value is zero to
++ push the argument on the stack, or a hard register in which to
++ store the argument.
++
++ MODE is the argument's machine mode.
++ TYPE is the data type of the argument (as a tree).
++ This is null for libcalls where that information may
++ not be available.
++ CUM is a variable of type CUMULATIVE_ARGS which gives info about
++ the preceding args and about the function being called.
++ NAMED is nonzero if this argument is a named parameter
++ (otherwise it is an extra parameter matching an ellipsis). */
++rtx
++function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
++ tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
++{
++ rtx return_rtx = NULL_RTX;
++
++ if (cum->regs_used < NUM_ARG_REGS)
++ {
++ return_rtx = gen_rtx_REG (mode, FIRST_ARG_REGNO + cum->regs_used);
++ }
++
++ return return_rtx;
++}
++
++/*
++ * This is just default_must_pass_in_stack from calls.c sans the final
++ * test for padding which isn't needed: we define BLOCK_REG_PADDING
++ * instead.
++ */
++int
++nios2_must_pass_in_stack (enum machine_mode mode, tree type)
++{
++ if (!type)
++ return false;
++
++ /* If the type has variable size... */
++ if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
++ return true;
++
++ /* If the type is marked as addressable (it is required
++ to be constructed into the stack)... */
++ if (TREE_ADDRESSABLE (type))
++ return true;
++
++ return false;
++}
++
++int
++function_arg_partial_nregs (const CUMULATIVE_ARGS *cum,
++ enum machine_mode mode, tree type,
++ int named ATTRIBUTE_UNUSED)
++{
++ HOST_WIDE_INT param_size;
++
++ if (mode == BLKmode)
++ {
++ param_size = int_size_in_bytes (type);
++ if (param_size < 0)
++ internal_error
++ ("Do not know how to handle large structs or variable length types");
++ }
++ else
++ {
++ param_size = GET_MODE_SIZE (mode);
++ }
++
++ /* convert to words (round up) */
++ param_size = (3 + param_size) / 4;
++
++ if (cum->regs_used < NUM_ARG_REGS
++ && cum->regs_used + param_size > NUM_ARG_REGS)
++ {
++ return NUM_ARG_REGS - cum->regs_used;
++ }
++ else
++ {
++ return 0;
++ }
++}
++
++
++/* Update the data in CUM to advance over an argument
++ of mode MODE and data type TYPE.
++ (TYPE is null for libcalls where that information may not be available.) */
++
++void
++function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
++ tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
++{
++ HOST_WIDE_INT param_size;
++
++ if (mode == BLKmode)
++ {
++ param_size = int_size_in_bytes (type);
++ if (param_size < 0)
++ internal_error
++ ("Do not know how to handle large structs or variable length types");
++ }
++ else
++ {
++ param_size = GET_MODE_SIZE (mode);
++ }
++
++ /* convert to words (round up) */
++ param_size = (3 + param_size) / 4;
++
++ if (cum->regs_used + param_size > NUM_ARG_REGS)
++ {
++ cum->regs_used = NUM_ARG_REGS;
++ }
++ else
++ {
++ cum->regs_used += param_size;
++ }
++
++ return;
++}
++
++int
++nios2_function_arg_padding_upward (enum machine_mode mode, tree type)
++{
++ /* On little-endian targets, the first byte of every stack argument
++ is passed in the first byte of the stack slot. */
++ if (!BYTES_BIG_ENDIAN)
++ return 1;
++
++ /* Otherwise, integral types are padded downward: the last byte of a
++ stack argument is passed in the last byte of the stack slot. */
++ if (type != 0
++ ? INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)
++ : GET_MODE_CLASS (mode) == MODE_INT)
++ return 0;
++
++ /* Arguments smaller than a stack slot are padded downward. */
++ if (mode != BLKmode)
++ return (GET_MODE_BITSIZE (mode) >= PARM_BOUNDARY) ? 1 : 0;
++ else
++ return ((int_size_in_bytes (type) >= (PARM_BOUNDARY / BITS_PER_UNIT))
++ ? 1 : 0);
++}
++
++int
++nios2_block_reg_padding_upward (enum machine_mode mode, tree type,
++ int first ATTRIBUTE_UNUSED)
++{
++ /* ??? Do we need to treat floating point specially, ala MIPS? */
++ return nios2_function_arg_padding_upward (mode, type);
++}
++
++int
++nios2_return_in_memory (tree type)
++{
++ int res = ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
++ || (int_size_in_bytes (type) == -1));
++
++ return res;
++}
++
++/* ??? It may be possible to eliminate the copyback and implement
++ my own va_arg type, but that is more work for now. */
++int
++nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *cum,
++ enum machine_mode mode, tree type,
++ int no_rtl)
++{
++ CUMULATIVE_ARGS local_cum;
++ int regs_to_push;
++
++ local_cum = *cum;
++ FUNCTION_ARG_ADVANCE (local_cum, mode, type, 1);
++
++ regs_to_push = NUM_ARG_REGS - local_cum.regs_used;
++
++ if (!no_rtl)
++ {
++ if (regs_to_push > 0)
++ {
++ rtx ptr, mem;
++
++ ptr = virtual_incoming_args_rtx;
++ mem = gen_rtx_MEM (BLKmode, ptr);
++
++ /* va_arg is an array access in this case, which causes
++ it to get MEM_IN_STRUCT_P set. We must set it here
++ so that the insn scheduler won't assume that these
++ stores can't possibly overlap with the va_arg loads. */
++ MEM_SET_IN_STRUCT_P (mem, 1);
++
++ emit_insn (gen_blockage ());
++ move_block_from_reg (local_cum.regs_used + FIRST_ARG_REGNO, mem,
++ regs_to_push);
++ emit_insn (gen_blockage ());
++ }
++ }
++
++ return regs_to_push * UNITS_PER_WORD;
++
++}
++
++
++
++/*****************************************************************************
++**
++** builtins
++**
++** This method for handling builtins is from CSP where _many_ more types of
++** expanders have already been written. Check there first before writing
++** new ones.
++**
++*****************************************************************************/
++
++enum nios2_builtins
++{
++ NIOS2_BUILTIN_LDBIO,
++ NIOS2_BUILTIN_LDBUIO,
++ NIOS2_BUILTIN_LDHIO,
++ NIOS2_BUILTIN_LDHUIO,
++ NIOS2_BUILTIN_LDWIO,
++ NIOS2_BUILTIN_STBIO,
++ NIOS2_BUILTIN_STHIO,
++ NIOS2_BUILTIN_STWIO,
++ NIOS2_BUILTIN_SYNC,
++ NIOS2_BUILTIN_RDCTL,
++ NIOS2_BUILTIN_WRCTL,
++
++#undef NIOS2_DO_BUILTIN
++#define NIOS2_DO_BUILTIN(upper, lower, handler) \
++ NIOS2_CONCAT (NIOS2_BUILTIN_CUSTOM_, upper),
++NIOS2_FOR_ALL_CUSTOM_BUILTINS
++
++ NIOS2_FIRST_FPU_INSN,
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ NIOS2_CONCAT (NIOS2_BUILTIN_FPU_, opt),
++NIOS2_FOR_ALL_FPU_INSNS
++
++ NIOS2_LAST_FPU_INSN,
++
++ LIM_NIOS2_BUILTINS
++};
++
++struct builtin_description
++{
++ const enum insn_code icode;
++ const char *const name;
++ const enum nios2_builtins code;
++ const tree *type;
++ rtx (* expander) (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++};
++
++static rtx nios2_expand_STXIO (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_LDXIO (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_sync (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_rdctl (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_wrctl (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++
++static rtx nios2_expand_custom_n (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_Xn (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_nX (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_XnX (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_nXX (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_XnXX (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++
++static rtx nios2_expand_custom_zdz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_zsz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_szz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_sss (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_ssz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_iss (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_ddd (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_ddz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_idd (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_siz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_suz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_diz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_duz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_isz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_usz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_idz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_udz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_dsz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++static rtx nios2_expand_custom_sdz (const struct builtin_description *,
++ tree, rtx, rtx, enum machine_mode, int);
++
++static tree endlink;
++
++/* int fn (volatile const void *)
++ */
++static tree int_ftype_volatile_const_void_p;
++
++/* int fn (int)
++ */
++static tree int_ftype_int;
++
++/* void fn (int, int)
++ */
++static tree void_ftype_int_int;
++
++/* void fn (volatile void *, int)
++ */
++static tree void_ftype_volatile_void_p_int;
++
++/* void fn (void)
++ */
++static tree void_ftype_void;
++
++#undef NIOS2_DO_BUILTIN
++#define NIOS2_DO_BUILTIN(upper, lower, handler) \
++ static tree NIOS2_CONCAT (custom_, lower);
++NIOS2_FOR_ALL_CUSTOM_BUILTINS
++
++static tree custom_zdz;
++static tree custom_zsz;
++static tree custom_szz;
++static tree custom_sss;
++static tree custom_ssz;
++static tree custom_iss;
++static tree custom_ddd;
++static tree custom_ddz;
++static tree custom_idd;
++static tree custom_siz;
++static tree custom_suz;
++static tree custom_diz;
++static tree custom_duz;
++static tree custom_isz;
++static tree custom_usz;
++static tree custom_idz;
++static tree custom_udz;
++static tree custom_dsz;
++static tree custom_sdz;
++
++static const struct builtin_description bdesc[] = {
++ {CODE_FOR_ldbio, "__builtin_ldbio", NIOS2_BUILTIN_LDBIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
++ {CODE_FOR_ldbuio, "__builtin_ldbuio", NIOS2_BUILTIN_LDBUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
++ {CODE_FOR_ldhio, "__builtin_ldhio", NIOS2_BUILTIN_LDHIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
++ {CODE_FOR_ldhuio, "__builtin_ldhuio", NIOS2_BUILTIN_LDHUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
++ {CODE_FOR_ldwio, "__builtin_ldwio", NIOS2_BUILTIN_LDWIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
++
++ {CODE_FOR_stbio, "__builtin_stbio", NIOS2_BUILTIN_STBIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
++ {CODE_FOR_sthio, "__builtin_sthio", NIOS2_BUILTIN_STHIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
++ {CODE_FOR_stwio, "__builtin_stwio", NIOS2_BUILTIN_STWIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
++
++ {CODE_FOR_sync, "__builtin_sync", NIOS2_BUILTIN_SYNC, &void_ftype_void, nios2_expand_sync},
++ {CODE_FOR_rdctl, "__builtin_rdctl", NIOS2_BUILTIN_RDCTL, &int_ftype_int, nios2_expand_rdctl},
++ {CODE_FOR_wrctl, "__builtin_wrctl", NIOS2_BUILTIN_WRCTL, &void_ftype_int_int, nios2_expand_wrctl},
++
++#undef NIOS2_DO_BUILTIN
++#define NIOS2_DO_BUILTIN(upper, lower, handler) \
++ {NIOS2_CONCAT (CODE_FOR_custom_, lower), \
++ "__builtin_custom_" NIOS2_STRINGIFY (lower), \
++ NIOS2_CONCAT (NIOS2_BUILTIN_CUSTOM_, upper), \
++ &NIOS2_CONCAT (custom_, lower), \
++ NIOS2_CONCAT (nios2_expand_custom_, handler)},
++NIOS2_FOR_ALL_CUSTOM_BUILTINS
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ {NIOS2_CONCAT (CODE_FOR_, insn), \
++ "__builtin_custom_" NIOS2_STRINGIFY (opt), \
++ NIOS2_CONCAT (NIOS2_BUILTIN_FPU_, opt), \
++ &NIOS2_CONCAT (custom_, args), \
++ NIOS2_CONCAT (nios2_expand_custom_, args)},
++NIOS2_FOR_ALL_FPU_INSNS
++
++ {0, 0, 0, 0, 0},
++};
++
++/* This does not have a closing bracket on purpose (see use) */
++#define def_param(TYPE) \
++ tree_cons (NULL_TREE, TYPE,
++
++static void
++nios2_init_builtins ()
++{
++ const struct builtin_description *d;
++
++
++ endlink = void_list_node;
++
++ /* Special indenting here because one of the brackets is in def_param */
++ /* *INDENT-OFF* */
++
++ /* int fn (volatile const void *)
++ */
++ int_ftype_volatile_const_void_p
++ = build_function_type (integer_type_node,
++ def_param (build_qualified_type (ptr_type_node,
++ TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
++ endlink));
++
++
++ /* void fn (volatile void *, int)
++ */
++ void_ftype_volatile_void_p_int
++ = build_function_type (void_type_node,
++ def_param (build_qualified_type (ptr_type_node,
++ TYPE_QUAL_VOLATILE))
++ def_param (integer_type_node)
++ endlink)));
++
++ /* void fn (void)
++ */
++ void_ftype_void
++ = build_function_type (void_type_node,
++ endlink);
++
++ /* int fn (int)
++ */
++ int_ftype_int
++ = build_function_type (integer_type_node,
++ def_param (integer_type_node)
++ endlink));
++
++ /* void fn (int, int)
++ */
++ void_ftype_int_int
++ = build_function_type (void_type_node,
++ def_param (integer_type_node)
++ def_param (integer_type_node)
++ endlink)));
++
++
++#define CUSTOM_NUM def_param (integer_type_node)
++
++ custom_n
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ endlink));
++ custom_ni
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ endlink)));
++ custom_nf
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ endlink)));
++ custom_np
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ endlink)));
++ custom_nii
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_nif
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_nip
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_nfi
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_nff
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_nfp
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_npi
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_npf
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_npp
++ = build_function_type (void_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++
++ custom_in
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ endlink));
++ custom_ini
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ endlink)));
++ custom_inf
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ endlink)));
++ custom_inp
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ endlink)));
++ custom_inii
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_inif
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_inip
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_infi
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_inff
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_infp
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_inpi
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_inpf
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_inpp
++ = build_function_type (integer_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++
++ custom_fn
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ endlink));
++ custom_fni
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ endlink)));
++ custom_fnf
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ endlink)));
++ custom_fnp
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ endlink)));
++ custom_fnii
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_fnif
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_fnip
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_fnfi
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_fnff
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_fnfp
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_fnpi
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_fnpf
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_fnpp
++ = build_function_type (float_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++
++
++ custom_pn
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ endlink));
++ custom_pni
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ endlink)));
++ custom_pnf
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ endlink)));
++ custom_pnp
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ endlink)));
++ custom_pnii
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_pnif
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_pnip
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (integer_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_pnfi
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_pnff
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_pnfp
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (float_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++ custom_pnpi
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (integer_type_node)
++ endlink))));
++ custom_pnpf
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (float_type_node)
++ endlink))));
++ custom_pnpp
++ = build_function_type (ptr_type_node,
++ CUSTOM_NUM
++ def_param (ptr_type_node)
++ def_param (ptr_type_node)
++ endlink))));
++
++ custom_zdz
++ = build_function_type (void_type_node,
++ def_param (double_type_node)
++ endlink));
++
++ custom_zsz
++ = build_function_type (void_type_node,
++ def_param (float_type_node)
++ endlink));
++
++ custom_szz
++ = build_function_type (float_type_node,
++ def_param (void_type_node)
++ endlink));
++
++ custom_sss
++ = build_function_type (float_type_node,
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink)));
++
++ custom_ssz
++ = build_function_type (float_type_node,
++ def_param (float_type_node)
++ endlink));
++
++ custom_iss
++ = build_function_type (integer_type_node,
++ def_param (float_type_node)
++ def_param (float_type_node)
++ endlink)));
++
++ custom_ddd
++ = build_function_type (double_type_node,
++ def_param (double_type_node)
++ def_param (double_type_node)
++ endlink)));
++
++ custom_ddz
++ = build_function_type (double_type_node,
++ def_param (double_type_node)
++ endlink));
++
++ custom_idd
++ = build_function_type (integer_type_node,
++ def_param (double_type_node)
++ def_param (double_type_node)
++ endlink)));
++
++ custom_siz
++ = build_function_type (float_type_node,
++ def_param (integer_type_node)
++ endlink));
++
++ custom_suz
++ = build_function_type (float_type_node,
++ def_param (unsigned_type_node)
++ endlink));
++
++ custom_diz
++ = build_function_type (double_type_node,
++ def_param (integer_type_node)
++ endlink));
++
++ custom_duz
++ = build_function_type (double_type_node,
++ def_param (unsigned_type_node)
++ endlink));
++
++ custom_isz
++ = build_function_type (integer_type_node,
++ def_param (float_type_node)
++ endlink));
++
++ custom_usz
++ = build_function_type (unsigned_type_node,
++ def_param (float_type_node)
++ endlink));
++
++ custom_idz
++ = build_function_type (integer_type_node,
++ def_param (double_type_node)
++ endlink));
++
++ custom_udz
++ = build_function_type (unsigned_type_node,
++ def_param (double_type_node)
++ endlink));
++
++ custom_dsz
++ = build_function_type (double_type_node,
++ def_param (float_type_node)
++ endlink));
++
++ custom_sdz
++ = build_function_type (float_type_node,
++ def_param (double_type_node)
++ endlink));
++
++ /* *INDENT-ON* */
++
++
++ for (d = bdesc; d->name; d++)
++ {
++ builtin_function (d->name, *d->type, d->code,
++ BUILT_IN_MD, NULL, NULL);
++ }
++}
++
++/* Expand an expression EXP that calls a built-in function,
++ with result going to TARGET if that's convenient
++ (and in mode MODE if that's convenient).
++ SUBTARGET may be used as the target for computing one of EXP's operands.
++ IGNORE is nonzero if the value is to be ignored. */
++
++static rtx
++nios2_expand_builtin (tree exp, rtx target, rtx subtarget,
++ enum machine_mode mode, int ignore)
++{
++ const struct builtin_description *d;
++ tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
++ unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
++
++ for (d = bdesc; d->name; d++)
++ if (d->code == fcode)
++ {
++ if (d->code > NIOS2_FIRST_FPU_INSN && d->code < NIOS2_LAST_FPU_INSN)
++ {
++ nios2_fpu_info *inf = &nios2_fpu_insns[d->code - (NIOS2_FIRST_FPU_INSN + 1)];
++ const struct insn_data *idata = &insn_data[d->icode];
++ if (inf->N < 0)
++ {
++ fatal_error ("Cannot call `%s' without specifying switch `-mcustom-%s'",
++ d->name,
++ inf->option);
++ }
++ if (inf->args[0] != 'z'
++ && (!target
++ || !(idata->operand[0].predicate) (target,
++ idata->operand[0].mode)))
++ target = gen_reg_rtx (idata->operand[0].mode);
++ }
++ return (d->expander) (d, exp, target, subtarget, mode, ignore);
++ }
++
++ /* we should have seen one of the functins we registered */
++ abort ();
++}
++
++static rtx nios2_create_target (const struct builtin_description *, rtx);
++
++
++static rtx
++nios2_create_target (const struct builtin_description *d, rtx target)
++{
++ if (!target
++ || !(*insn_data[d->icode].operand[0].predicate) (target,
++ insn_data[d->icode].operand[0].mode))
++ {
++ target = gen_reg_rtx (insn_data[d->icode].operand[0].mode);
++ }
++
++ return target;
++}
++
++
++static rtx nios2_extract_opcode (const struct builtin_description *, int, tree);
++static rtx nios2_extract_operand (const struct builtin_description *, int, int, tree);
++
++static rtx
++nios2_extract_opcode (const struct builtin_description *d, int op, tree arglist)
++{
++ enum machine_mode mode = insn_data[d->icode].operand[op].mode;
++ tree arg = TREE_VALUE (arglist);
++ rtx opcode = expand_expr (arg, NULL_RTX, mode, 0);
++ opcode = protect_from_queue (opcode, 0);
++
++ if (!(*insn_data[d->icode].operand[op].predicate) (opcode, mode))
++ error ("Custom instruction opcode must be compile time constant in the range 0-255 for %s", d->name);
++
++ builtin_custom_seen[INTVAL (opcode)] = d->name;
++ nios2_custom_check_insns (0);
++ return opcode;
++}
++
++static rtx
++nios2_extract_operand (const struct builtin_description *d, int op, int argnum, tree arglist)
++{
++ enum machine_mode mode = insn_data[d->icode].operand[op].mode;
++ tree arg = TREE_VALUE (arglist);
++ rtx operand = expand_expr (arg, NULL_RTX, mode, 0);
++ operand = protect_from_queue (operand, 0);
++
++ if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
++ operand = copy_to_mode_reg (mode, operand);
++
++ /* ??? Better errors would be nice */
++ if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
++ error ("Invalid argument %d to %s", argnum, d->name);
++
++ return operand;
++}
++
++
++static rtx
++nios2_expand_custom_n (const struct builtin_description *d, tree exp,
++ rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++
++ /* custom_n should have exactly one operand */
++ if (insn_data[d->icode].n_operands != 1)
++ abort ();
++
++ opcode = nios2_extract_opcode (d, 0, arglist);
++
++ pat = GEN_FCN (d->icode) (opcode);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_expand_custom_Xn (const struct builtin_description *d, tree exp,
++ rtx target, rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++
++ /* custom_Xn should have exactly two operands */
++ if (insn_data[d->icode].n_operands != 2)
++ abort ();
++
++ target = nios2_create_target (d, target);
++ opcode = nios2_extract_opcode (d, 1, arglist);
++
++ pat = GEN_FCN (d->icode) (target, opcode);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_nX (const struct builtin_description *d, tree exp,
++ rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++ rtx operands[1];
++ int i;
++
++
++ /* custom_nX should have exactly two operands */
++ if (insn_data[d->icode].n_operands != 2)
++ abort ();
++
++ opcode = nios2_extract_opcode (d, 0, arglist);
++ for (i = 0; i < 1; i++)
++ {
++ arglist = TREE_CHAIN (arglist);
++ operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
++ }
++
++ pat = GEN_FCN (d->icode) (opcode, operands[0]);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_expand_custom_XnX (const struct builtin_description *d, tree exp, rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++ rtx operands[1];
++ int i;
++
++ /* custom_Xn should have exactly three operands */
++ if (insn_data[d->icode].n_operands != 3)
++ abort ();
++
++ target = nios2_create_target (d, target);
++ opcode = nios2_extract_opcode (d, 1, arglist);
++
++ for (i = 0; i < 1; i++)
++ {
++ arglist = TREE_CHAIN (arglist);
++ operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
++ }
++
++ pat = GEN_FCN (d->icode) (target, opcode, operands[0]);
++
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_nXX (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++ rtx operands[2];
++ int i;
++
++
++ /* custom_nX should have exactly three operands */
++ if (insn_data[d->icode].n_operands != 3)
++ abort ();
++
++ opcode = nios2_extract_opcode (d, 0, arglist);
++ for (i = 0; i < 2; i++)
++ {
++ arglist = TREE_CHAIN (arglist);
++ operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
++ }
++
++ pat = GEN_FCN (d->icode) (opcode, operands[0], operands[1]);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_expand_custom_XnXX (const struct builtin_description *d, tree exp, rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx opcode;
++ rtx operands[2];
++ int i;
++
++
++ /* custom_XnX should have exactly four operands */
++ if (insn_data[d->icode].n_operands != 4)
++ abort ();
++
++ target = nios2_create_target (d, target);
++ opcode = nios2_extract_opcode (d, 1, arglist);
++ for (i = 0; i < 2; i++)
++ {
++ arglist = TREE_CHAIN (arglist);
++ operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
++ }
++
++ pat = GEN_FCN (d->icode) (target, opcode, operands[0], operands[1]);
++
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return target;
++}
++
++
++
++static rtx
++nios2_expand_STXIO (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx store_dest, store_val;
++ enum insn_code icode = d->icode;
++
++ /* stores should have exactly two operands */
++ if (insn_data[icode].n_operands != 2)
++ abort ();
++
++ /* process the destination of the store */
++ {
++ enum machine_mode mode = insn_data[icode].operand[0].mode;
++ tree arg = TREE_VALUE (arglist);
++ store_dest = expand_expr (arg, NULL_RTX, VOIDmode, 0);
++ store_dest = protect_from_queue (store_dest, 0);
++
++ store_dest = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, store_dest));
++
++ /* ??? Better errors would be nice */
++ if (!(*insn_data[icode].operand[0].predicate) (store_dest, mode))
++ error ("Invalid argument 1 to %s", d->name);
++ }
++
++
++ /* process the value to store */
++ {
++ enum machine_mode mode = insn_data[icode].operand[1].mode;
++ tree arg = TREE_VALUE (TREE_CHAIN (arglist));
++ store_val = expand_expr (arg, NULL_RTX, mode, 0);
++ store_val = protect_from_queue (store_val, 0);
++
++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
++ store_val = copy_to_mode_reg (mode, store_val);
++
++ /* ??? Better errors would be nice */
++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
++ error ("Invalid argument 2 to %s", d->name);
++ }
++
++ pat = GEN_FCN (d->icode) (store_dest, store_val);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return 0;
++}
++
++
++static rtx
++nios2_expand_LDXIO (const struct builtin_description * d, tree exp, rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx ld_src;
++ enum insn_code icode = d->icode;
++
++ /* loads should have exactly two operands */
++ if (insn_data[icode].n_operands != 2)
++ abort ();
++
++ target = nios2_create_target (d, target);
++
++ {
++ enum machine_mode mode = insn_data[icode].operand[1].mode;
++ tree arg = TREE_VALUE (arglist);
++ ld_src = expand_expr (arg, NULL_RTX, VOIDmode, 0);
++ ld_src = protect_from_queue (ld_src, 0);
++
++ ld_src = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, ld_src));
++
++ /* ??? Better errors would be nice */
++ if (!(*insn_data[icode].operand[1].predicate) (ld_src, mode))
++ {
++ error ("Invalid argument 1 to %s", d->name);
++ }
++ }
++
++ pat = GEN_FCN (d->icode) (target, ld_src);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return target;
++}
++
++
++static rtx
++nios2_expand_sync (const struct builtin_description * d ATTRIBUTE_UNUSED,
++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ emit_insn (gen_sync ());
++ return 0;
++}
++
++static rtx
++nios2_expand_rdctl (const struct builtin_description * d ATTRIBUTE_UNUSED,
++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx rdctl_reg;
++ enum insn_code icode = d->icode;
++
++ /* rdctl should have exactly two operands */
++ if (insn_data[icode].n_operands != 2)
++ abort ();
++
++ target = nios2_create_target (d, target);
++
++ {
++ enum machine_mode mode = insn_data[icode].operand[1].mode;
++ tree arg = TREE_VALUE (arglist);
++ rdctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
++ rdctl_reg = protect_from_queue (rdctl_reg, 0);
++
++ if (!(*insn_data[icode].operand[1].predicate) (rdctl_reg, mode))
++ {
++ error ("Control register number must be in range 0-31 for %s", d->name);
++ }
++ }
++
++ pat = GEN_FCN (d->icode) (target, rdctl_reg);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_wrctl (const struct builtin_description * d ATTRIBUTE_UNUSED,
++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat;
++ rtx wrctl_reg, store_val;
++ enum insn_code icode = d->icode;
++
++ /* stores should have exactly two operands */
++ if (insn_data[icode].n_operands != 2)
++ abort ();
++
++ /* process the destination of the store */
++ {
++ enum machine_mode mode = insn_data[icode].operand[0].mode;
++ tree arg = TREE_VALUE (arglist);
++ wrctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
++ wrctl_reg = protect_from_queue (wrctl_reg, 0);
++
++ if (!(*insn_data[icode].operand[0].predicate) (wrctl_reg, mode))
++ error ("Control register number must be in range 0-31 for %s", d->name);
++ }
++
++
++ /* process the value to store */
++ {
++ enum machine_mode mode = insn_data[icode].operand[1].mode;
++ tree arg = TREE_VALUE (TREE_CHAIN (arglist));
++ store_val = expand_expr (arg, NULL_RTX, mode, 0);
++ store_val = protect_from_queue (store_val, 0);
++
++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
++ store_val = copy_to_mode_reg (mode, store_val);
++
++ /* ??? Better errors would be nice */
++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
++ error ("Invalid argument 2 to %s", d->name);
++ }
++
++ pat = GEN_FCN (d->icode) (wrctl_reg, store_val);
++ if (!pat)
++ return 0;
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_extract_double (const struct insn_data *idata, tree arglist, int index)
++{
++ rtx arg;
++
++ while (index--)
++ {
++ arglist = TREE_CHAIN (arglist);
++ }
++ arg = expand_expr (TREE_VALUE (arglist), NULL_RTX, DFmode, 0);
++ arg = protect_from_queue (arg, 0);
++ if (!(*(idata->operand[index+1].predicate)) (arg, DFmode))
++ {
++ arg = copy_to_mode_reg (DFmode, arg);
++ }
++ return arg;
++}
++
++static rtx
++nios2_extract_float (const struct insn_data *idata, tree arglist, int index)
++{
++ rtx arg;
++
++ while (index--)
++ {
++ arglist = TREE_CHAIN (arglist);
++ }
++ arg = expand_expr (TREE_VALUE (arglist), NULL_RTX, SFmode, 0);
++ arg = protect_from_queue (arg, 0);
++ if (!(*(idata->operand[index+1].predicate)) (arg, SFmode))
++ {
++ arg = copy_to_mode_reg (SFmode, arg);
++ }
++ return arg;
++}
++
++static rtx
++nios2_extract_integer (const struct insn_data *idata, tree arglist, int index)
++{
++ rtx arg;
++
++ while (index--)
++ {
++ arglist = TREE_CHAIN (arglist);
++ }
++ arg = expand_expr (TREE_VALUE (arglist), NULL_RTX, SImode, 0);
++ arg = protect_from_queue (arg, 0);
++ if (!(*(idata->operand[index+1].predicate)) (arg, SImode))
++ {
++ arg = copy_to_mode_reg (SImode, arg);
++ }
++ return protect_from_queue (arg, 0);
++}
++
++static rtx
++nios2_expand_custom_zdz (const struct builtin_description *d,
++ tree exp,
++ rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (nios2_extract_double (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_expand_custom_zsz (const struct builtin_description *d,
++ tree exp,
++ rtx target ATTRIBUTE_UNUSED,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (nios2_extract_float (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return 0;
++}
++
++static rtx
++nios2_expand_custom_szz (const struct builtin_description *d,
++ tree exp ATTRIBUTE_UNUSED,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ rtx pat = GEN_FCN (d->icode) (target);
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_sss (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0),
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 1));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_ssz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_iss (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0),
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 1));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_ddd (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0),
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 1));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_ddz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_idd (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0),
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 1));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_siz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_integer (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_suz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_integer (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_diz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_integer (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_duz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_integer (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_isz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_usz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_idz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_udz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_dsz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_float (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++static rtx
++nios2_expand_custom_sdz (const struct builtin_description *d,
++ tree exp,
++ rtx target,
++ rtx subtarget ATTRIBUTE_UNUSED,
++ enum machine_mode mode ATTRIBUTE_UNUSED,
++ int ignore ATTRIBUTE_UNUSED)
++{
++ tree arglist = TREE_OPERAND (exp, 1);
++ rtx pat = GEN_FCN (d->icode) (target,
++ nios2_extract_double (&insn_data[d->icode],
++ arglist, 0));
++ if (pat)
++ emit_insn (pat);
++ return target;
++}
++
++#include "gt-nios2.h"
++
+diff --git a/gcc/config/nios2/nios2.h b/gcc/config/nios2/nios2.h
+new file mode 100644
+index 0000000..500ccf0
+--- /dev/null
++++ b/gcc/config/nios2/nios2.h
+@@ -0,0 +1,1130 @@
++/* Definitions of target machine for Altera NIOS 2G NIOS2 version.
++ Copyright (C) 2005 Altera
++ Contributed by Jonah Graham (jgraham@altera.com) and Will Reece (wreece@altera.com).
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++
++
++#define TARGET_CPU_CPP_BUILTINS() \
++ do \
++ { \
++ builtin_define_std ("NIOS2"); \
++ builtin_define_std ("nios2"); \
++ if (TARGET_BIG_ENDIAN) \
++ builtin_define_std ("nios2_big_endian"); \
++ else \
++ builtin_define_std ("nios2_little_endian"); \
++ } \
++ while (0)
++#define TARGET_VERSION fprintf (stderr, " (Altera Nios II)")
++
++
++
++
++
++/*********************************
++ * Run-time Target Specification
++ *********************************/
++
++#define HAS_DIV_FLAG 0x0001
++#define HAS_MUL_FLAG 0x0002
++#define HAS_MULX_FLAG 0x0004
++#define FAST_SW_DIV_FLAG 0x0008
++#define INLINE_MEMCPY_FLAG 0x00010
++#define CACHE_VOLATILE_FLAG 0x0020
++#define BYPASS_CACHE_FLAG 0x0040
++#define STACK_CHECK_FLAG 0x0080
++#define REVERSE_BITFIELDS_FLAG 0x0100
++/* Reserve 0x0200 for REVERSE_ENDIAN_FLAG */
++#define BIG_ENDIAN_FLAG 0x0400
++
++extern int target_flags;
++#define TARGET_HAS_DIV (target_flags & HAS_DIV_FLAG)
++#define TARGET_HAS_MUL (target_flags & HAS_MUL_FLAG)
++#define TARGET_HAS_MULX (target_flags & HAS_MULX_FLAG)
++#define TARGET_FAST_SW_DIV (target_flags & FAST_SW_DIV_FLAG)
++#define TARGET_INLINE_MEMCPY (target_flags & INLINE_MEMCPY_FLAG)
++#define TARGET_CACHE_VOLATILE (target_flags & CACHE_VOLATILE_FLAG)
++#define TARGET_BYPASS_CACHE (target_flags & BYPASS_CACHE_FLAG)
++#define TARGET_STACK_CHECK (target_flags & STACK_CHECK_FLAG)
++#define TARGET_REVERSE_BITFIELDS (target_flags & REVERSE_BITFIELDS_FLAG)
++#define TARGET_BIG_ENDIAN (target_flags & BIG_ENDIAN_FLAG)
++
++#define TARGET_SWITCHES \
++{ \
++ { "hw-div", HAS_DIV_FLAG, \
++ N_("Enable DIV, DIVU") }, \
++ { "no-hw-div", -HAS_DIV_FLAG, \
++ N_("Disable DIV, DIVU (default)") }, \
++ { "hw-mul", HAS_MUL_FLAG, \
++ N_("Enable MUL instructions (default)") }, \
++ { "hw-mulx", HAS_MULX_FLAG, \
++ N_("Enable MULX instructions, assume fast shifter") }, \
++ { "no-hw-mul", -HAS_MUL_FLAG, \
++ N_("Disable MUL instructions") }, \
++ { "no-hw-mulx", -HAS_MULX_FLAG, \
++ N_("Disable MULX instructions, assume slow shifter (default and implied by -mno-hw-mul)") }, \
++ { "fast-sw-div", FAST_SW_DIV_FLAG, \
++ N_("Use table based fast divide (default at -O3)") }, \
++ { "no-fast-sw-div", -FAST_SW_DIV_FLAG, \
++ N_("Don't use table based fast divide ever") }, \
++ { "inline-memcpy", INLINE_MEMCPY_FLAG, \
++ N_("Inline small memcpy (default when optimizing)") }, \
++ { "no-inline-memcpy", -INLINE_MEMCPY_FLAG, \
++ N_("Don't Inline small memcpy") }, \
++ { "cache-volatile", CACHE_VOLATILE_FLAG, \
++ N_("Volatile accesses use non-io variants of instructions (default)") }, \
++ { "no-cache-volatile", -CACHE_VOLATILE_FLAG, \
++ N_("Volatile accesses use io variants of instructions") }, \
++ { "bypass-cache", BYPASS_CACHE_FLAG, \
++ N_("All ld/st instructins use io variants") }, \
++ { "no-bypass-cache", -BYPASS_CACHE_FLAG, \
++ N_("All ld/st instructins do not use io variants (default)") }, \
++ { "smallc", 0, \
++ N_("Link with a limited version of the C library") }, \
++ { "ctors-in-init", 0, \
++ "" /* undocumented: N_("Link with static constructors and destructors in init") */ }, \
++ { "stack-check", STACK_CHECK_FLAG, \
++ N_("Enable stack limit checking.") }, \
++ { "no-stack-check", -STACK_CHECK_FLAG, \
++ N_("Disable stack limit checking (default).") }, \
++ { "reverse-bitfields", REVERSE_BITFIELDS_FLAG, \
++ N_("Reverse the order of bitfields in a struct.") }, \
++ { "no-reverse-bitfields", -REVERSE_BITFIELDS_FLAG, \
++ N_("Use the normal order of bitfields in a struct (default).") }, \
++ { "eb", BIG_ENDIAN_FLAG, \
++ N_("Use big-endian byte order") }, \
++ { "el", -BIG_ENDIAN_FLAG, \
++ N_("Use little-endian byte order") }, \
++ { "", TARGET_DEFAULT, 0 } \
++}
++
++extern const char *nios2_sys_nosys_string; /* for -msys=nosys */
++extern const char *nios2_sys_lib_string; /* for -msys-lib= */
++extern const char *nios2_sys_crt0_string; /* for -msys-crt0= */
++
++/*
++ * There's a lot of error-prone tedium with all the different
++ * custom floating point instructions. Try to automate it a bit
++ * to make it easier to deal with.
++ */
++#define NIOS2_STRINGIFY_INNER(x) #x
++#define NIOS2_STRINGIFY(x) NIOS2_STRINGIFY_INNER(x)
++#define NIOS2_CONCAT_INNER(x, y) x ## y
++#define NIOS2_CONCAT(x, y) NIOS2_CONCAT_INNER (x, y)
++
++#define NIOS2_FOR_ALL_FPU_INSNS \
++ NIOS2_FPU_INSN (fwrx, nios2_fwrx, zdz) \
++ NIOS2_FPU_INSN (fwry, nios2_fwry, zsz) \
++ NIOS2_FPU_INSN (frdxlo, nios2_frdxlo, szz) \
++ NIOS2_FPU_INSN (frdxhi, nios2_frdxhi, szz) \
++ NIOS2_FPU_INSN (frdy, nios2_frdy, szz) \
++\
++ NIOS2_FPU_INSN (fadds, addsf3, sss) \
++ NIOS2_FPU_INSN (fsubs, subsf3, sss) \
++ NIOS2_FPU_INSN (fmuls, mulsf3, sss) \
++ NIOS2_FPU_INSN (fdivs, divsf3, sss) \
++ NIOS2_FPU_INSN (fmins, minsf3, sss) \
++ NIOS2_FPU_INSN (fmaxs, maxsf3, sss) \
++ NIOS2_FPU_INSN (fnegs, negsf2, ssz) \
++ NIOS2_FPU_INSN (fabss, abssf2, ssz) \
++ NIOS2_FPU_INSN (fsqrts, sqrtsf2, ssz) \
++ NIOS2_FPU_INSN (fcoss, cossf2, ssz) \
++ NIOS2_FPU_INSN (fsins, sinsf2, ssz) \
++ NIOS2_FPU_INSN (ftans, tansf2, ssz) \
++ NIOS2_FPU_INSN (fatans, atansf2, ssz) \
++ NIOS2_FPU_INSN (fexps, expsf2, ssz) \
++ NIOS2_FPU_INSN (flogs, logsf2, ssz) \
++ NIOS2_FPU_INSN (fcmplts, nios2_sltsf, iss) \
++ NIOS2_FPU_INSN (fcmples, nios2_slesf, iss) \
++ NIOS2_FPU_INSN (fcmpgts, nios2_sgtsf, iss) \
++ NIOS2_FPU_INSN (fcmpges, nios2_sgesf, iss) \
++ NIOS2_FPU_INSN (fcmpeqs, nios2_seqsf, iss) \
++ NIOS2_FPU_INSN (fcmpnes, nios2_snesf, iss) \
++\
++ NIOS2_FPU_INSN (faddd, adddf3, ddd) \
++ NIOS2_FPU_INSN (fsubd, subdf3, ddd) \
++ NIOS2_FPU_INSN (fmuld, muldf3, ddd) \
++ NIOS2_FPU_INSN (fdivd, divdf3, ddd) \
++ NIOS2_FPU_INSN (fmind, mindf3, ddd) \
++ NIOS2_FPU_INSN (fmaxd, maxdf3, ddd) \
++ NIOS2_FPU_INSN (fnegd, negdf2, ddz) \
++ NIOS2_FPU_INSN (fabsd, absdf2, ddz) \
++ NIOS2_FPU_INSN (fsqrtd, sqrtdf2, ddz) \
++ NIOS2_FPU_INSN (fcosd, cosdf2, ddz) \
++ NIOS2_FPU_INSN (fsind, sindf2, ddz) \
++ NIOS2_FPU_INSN (ftand, tandf2, ddz) \
++ NIOS2_FPU_INSN (fatand, atandf2, ddz) \
++ NIOS2_FPU_INSN (fexpd, expdf2, ddz) \
++ NIOS2_FPU_INSN (flogd, logdf2, ddz) \
++ NIOS2_FPU_INSN (fcmpltd, nios2_sltdf, idd) \
++ NIOS2_FPU_INSN (fcmpled, nios2_sledf, idd) \
++ NIOS2_FPU_INSN (fcmpgtd, nios2_sgtdf, idd) \
++ NIOS2_FPU_INSN (fcmpged, nios2_sgedf, idd) \
++ NIOS2_FPU_INSN (fcmpeqd, nios2_seqdf, idd) \
++ NIOS2_FPU_INSN (fcmpned, nios2_snedf, idd) \
++\
++ NIOS2_FPU_INSN (floatis, floatsisf2, siz) \
++ NIOS2_FPU_INSN (floatus, floatunssisf2, suz) \
++ NIOS2_FPU_INSN (floatid, floatsidf2, diz) \
++ NIOS2_FPU_INSN (floatud, floatunssidf2, duz) \
++ NIOS2_FPU_INSN (fixsi, fixsfsi2, isz) \
++ NIOS2_FPU_INSN (fixsu, fixunssfsi2, usz) \
++ NIOS2_FPU_INSN (fixdi, fixdfsi2, idz) \
++ NIOS2_FPU_INSN (fixdu, fixunsdfsi2, udz) \
++ NIOS2_FPU_INSN (fextsd, extendsfdf2, dsz) \
++ NIOS2_FPU_INSN (ftruncds, truncdfsf2, sdz)
++
++enum
++{
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ NIOS2_CONCAT (nios2_fpu_, insn),
++NIOS2_FOR_ALL_FPU_INSNS
++ nios2_fpu_max_insn
++};
++
++struct cpp_reader;
++typedef const char * (*nios2_outputfn) (rtx);
++typedef void (*nios2_pragmafn) (struct cpp_reader *);
++
++typedef struct
++{
++ const char *option; /* name of switch, e.g. fadds */
++ const char *insnnm; /* name of gcc insn, e.g. addsf3 */
++ const char *args; /* args to gcc insn, e.g. sss */
++ const char *value; /* value of switch as a string */
++ int N; /* value of switch as an integer, -1 = not used */
++ nios2_outputfn output; /* output function for use in .md file */
++ const char *pname; /* name of corresponding #pragma custom- */
++ nios2_pragmafn pragma; /* pragma function for register_target_pragmas */
++ const char *nopname; /* name of corresponding #pragma no-custom- */
++ nios2_pragmafn nopragma; /* pragma function for register_target_pragmas */
++ int is_double; /* does this insn have any double operands */
++ int needed_by_double; /* is this insn needed if doubles are used? */
++ int needs_unsafe; /* does this insn require
++ -funsafe-math-optimizations to work? */
++ int needs_finite; /* does this insn require
++ -ffinite-math-only to work? */
++ int pragma_seen; /* have we seen the corresponding #pragma? */
++} nios2_fpu_info;
++
++extern nios2_fpu_info nios2_fpu_insns[nios2_fpu_max_insn];
++extern const char *nios2_custom_fpu_cfg_string;
++
++#undef NIOS2_FPU_INSN
++#define NIOS2_FPU_INSN(opt, insn, args) \
++ { \
++ "custom-" NIOS2_STRINGIFY (opt) "=", \
++ &(nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].value), \
++ N_("Integer id (N) of " NIOS2_STRINGIFY (opt) " custom instruction"), \
++ 0 \
++ }, \
++ { \
++ "no-custom-" NIOS2_STRINGIFY (opt), \
++ &(nios2_fpu_insns[NIOS2_CONCAT (nios2_fpu_, insn)].value), \
++ N_("Do not use the " NIOS2_STRINGIFY (opt) " custom instruction"), \
++ "-1" \
++ },
++
++#define TARGET_OPTIONS \
++{ \
++ { "sys=nosys", &nios2_sys_nosys_string, \
++ N_("Use stub versions of OS library calls (default)"), 0}, \
++ { "sys-lib=", &nios2_sys_lib_string, \
++ N_("Name of System Library to link against. (Converted to a -l option)"), 0}, \
++ { "sys-crt0=", &nios2_sys_crt0_string, \
++ N_("Name of the startfile. (default is a crt0 for the ISS only)"), 0}, \
++ NIOS2_FOR_ALL_FPU_INSNS \
++ { "custom-fpu-cfg=", &nios2_custom_fpu_cfg_string, \
++ N_("Floating point custom instruction configuration name"), 0 }, \
++}
++
++/* We're little endian, unless otherwise specified by including big.h */
++#ifndef TARGET_ENDIAN_DEFAULT
++# define TARGET_ENDIAN_DEFAULT 0
++#endif
++
++/* Default target_flags if no switches specified. */
++#ifndef TARGET_DEFAULT
++# define TARGET_DEFAULT (HAS_MUL_FLAG | CACHE_VOLATILE_FLAG | TARGET_ENDIAN_DEFAULT)
++#endif
++
++/* Switch Recognition by gcc.c. Add -G xx support */
++#undef SWITCH_TAKES_ARG
++#define SWITCH_TAKES_ARG(CHAR) \
++ (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
++
++#define OVERRIDE_OPTIONS override_options ()
++#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) optimization_options (LEVEL, SIZE)
++#define CAN_DEBUG_WITHOUT_FP
++
++#define CC1_SPEC "\
++%{G*} %{EB:-meb} %{EL:-mel} %{EB:%{EL:%emay not use both -EB and -EL}}"
++
++#if TARGET_ENDIAN_DEFAULT == 0
++# define ASM_SPEC "\
++%{!EB:%{!meb:-EL}} %{EB|meb:-EB}"
++# define LINK_SPEC "\
++%{!EB:%{!meb:-EL}} %{EB|meb:-EB}"
++# define MULTILIB_DEFAULTS { "EL" }
++#else
++# define ASM_SPEC "\
++%{!EL:%{!mel:-EB}} %{EL|mel:-EL}"
++# define LINK_SPEC "\
++%{!EL:%{!mel:-EB}} %{EL|mel:-EL}"
++# define MULTILIB_DEFAULTS { "EB" }
++#endif
++
++#undef LIB_SPEC
++#define LIB_SPEC \
++"--start-group %{msmallc: -lsmallc} %{!msmallc: -lc} -lgcc \
++ %{msys-lib=*: -l%*} \
++ %{!msys-lib=*: -lnosys -lstack} \
++ --end-group \
++ %{msys-lib=: %eYou need a library name for -msys-lib=} \
++"
++
++
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC \
++"%{msys-crt0=*: %*} %{!msys-crt0=*: crt0%O%s} \
++ %{msys-crt0=: %eYou need a C startup file for -msys-crt0=} \
++ %{mctors-in-init: crti%O%s crtbegin%O%s} \
++"
++
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC \
++ "%{mctors-in-init: crtend%O%s crtn%O%s}"
++
++
++/***********************
++ * Storage Layout
++ ***********************/
++
++#define DEFAULT_SIGNED_CHAR 1
++#define BITS_BIG_ENDIAN 0
++#define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
++#define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
++#if defined(__nios2_big_endian__)
++#define LIBGCC2_WORDS_BIG_ENDIAN 1
++#else
++#define LIBGCC2_WORDS_BIG_ENDIAN 0
++#endif
++#define BITS_PER_UNIT 8
++#define BITS_PER_WORD 32
++#define UNITS_PER_WORD 4
++#define POINTER_SIZE 32
++#define BIGGEST_ALIGNMENT 32
++#define STRICT_ALIGNMENT 1
++#define FUNCTION_BOUNDARY 32
++#define PARM_BOUNDARY 32
++#define STACK_BOUNDARY 32
++#define PREFERRED_STACK_BOUNDARY 32
++#define MAX_FIXED_MODE_SIZE 64
++
++#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
++ ((TREE_CODE (EXP) == STRING_CST) \
++ && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
++
++
++/**********************
++ * Layout of Source Language Data Types
++ **********************/
++
++#define INT_TYPE_SIZE 32
++#define SHORT_TYPE_SIZE 16
++#define LONG_TYPE_SIZE 32
++#define LONG_LONG_TYPE_SIZE 64
++#define FLOAT_TYPE_SIZE 32
++#define DOUBLE_TYPE_SIZE 64
++#define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
++
++
++/*************************
++ * Condition Code Status
++ ************************/
++
++/* comparison type */
++/* ??? Currently CMP_DI is unused. CMP_SF and CMP_DF are only used if
++ the corresponding -mcustom-<opcode> switches are present. */
++enum cmp_type {
++ CMP_SI, /* compare four byte integers */
++ CMP_DI, /* compare eight byte integers */
++ CMP_SF, /* compare single precision floats */
++ CMP_DF, /* compare double precision floats */
++ CMP_MAX /* max comparison type */
++};
++
++extern GTY(()) rtx branch_cmp[2]; /* operands for compare */
++extern enum cmp_type branch_type; /* what type of branch to use */
++
++/**********************
++ * Register Usage
++ **********************/
++
++/* ---------------------------------- *
++ * Basic Characteristics of Registers
++ * ---------------------------------- */
++
++/*
++Register Number
++ Register Name
++ Alternate Name
++ Purpose
++0 r0 zero always zero
++1 r1 at Assembler Temporary
++2-3 r2-r3 Return Location
++4-7 r4-r7 Register Arguments
++8-15 r8-r15 Caller Saved Registers
++16-22 r16-r22 Callee Saved Registers
++23 r23 sc Static Chain (Callee Saved)
++ ??? Does $sc want to be caller or callee
++ saved. If caller, 15, else 23.
++24 r24 et Exception Temporary
++25 r25 bt Breakpoint Temporary
++26 r26 gp Global Pointer
++27 r27 sp Stack Pointer
++28 r28 fp Frame Pointer
++29 r29 ea Exception Return Address
++30 r30 ba Breakpoint Return Address
++31 r31 ra Return Address
++
++32 ctl0 status
++33 ctl1 estatus STATUS saved by exception ?
++34 ctl2 bstatus STATUS saved by break ?
++35 ctl3 ipri Interrupt Priority Mask ?
++36 ctl4 ecause Exception Cause ?
++
++37 pc Not an actual register
++
++38 rap Return address pointer, this does not
++ actually exist and will be eliminated
++
++39 fake_fp Fake Frame Pointer which will always be eliminated.
++40 fake_ap Fake Argument Pointer which will always be eliminated.
++
++41 First Pseudo Register
++
++
++The definitions for all the hard register numbers
++are located in nios2.md.
++*/
++
++#define FIRST_PSEUDO_REGISTER 41
++#define NUM_ARG_REGS (LAST_ARG_REGNO - FIRST_ARG_REGNO + 1)
++
++
++
++/* also see CONDITIONAL_REGISTER_USAGE */
++#define FIXED_REGISTERS \
++ { \
++/* +0 1 2 3 4 5 6 7 8 9 */ \
++/* 0 */ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, \
++/* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
++/* 20 */ 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, \
++/* 30 */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \
++/* 40 */ 1 \
++ }
++
++/* call used is the same as caller saved
++ + fixed regs + args + ret vals */
++#define CALL_USED_REGISTERS \
++ { \
++/* +0 1 2 3 4 5 6 7 8 9 */ \
++/* 0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
++/* 10 */ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, \
++/* 20 */ 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, \
++/* 30 */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \
++/* 40 */ 1 \
++ }
++
++#define HARD_REGNO_NREGS(REGNO, MODE) \
++ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
++ / UNITS_PER_WORD)
++
++/* --------------------------- *
++ * How Values Fit in Registers
++ * --------------------------- */
++
++#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
++
++#define MODES_TIEABLE_P(MODE1, MODE2) 1
++
++
++/*************************
++ * Register Classes
++ *************************/
++
++enum reg_class
++{
++ NO_REGS,
++ D00_REG,
++ D01_REG,
++ D02_REG,
++ D03_REG,
++ D04_REG,
++ D05_REG,
++ D06_REG,
++ D07_REG,
++ D08_REG,
++ D09_REG,
++ D10_REG,
++ D11_REG,
++ D12_REG,
++ D13_REG,
++ D14_REG,
++ D15_REG,
++ D16_REG,
++ D17_REG,
++ D18_REG,
++ D19_REG,
++ D20_REG,
++ D21_REG,
++ D22_REG,
++ D23_REG,
++ D24_REG,
++ D25_REG,
++ D26_REG,
++ D27_REG,
++ D28_REG,
++ D29_REG,
++ D30_REG,
++ D31_REG,
++ GP_REGS,
++ ALL_REGS,
++ LIM_REG_CLASSES
++};
++
++#define N_REG_CLASSES (int) LIM_REG_CLASSES
++
++#define REG_CLASS_NAMES \
++ {"NO_REGS", \
++ "D00_REG", \
++ "D01_REG", \
++ "D02_REG", \
++ "D03_REG", \
++ "D04_REG", \
++ "D05_REG", \
++ "D06_REG", \
++ "D07_REG", \
++ "D08_REG", \
++ "D09_REG", \
++ "D10_REG", \
++ "D11_REG", \
++ "D12_REG", \
++ "D13_REG", \
++ "D14_REG", \
++ "D15_REG", \
++ "D16_REG", \
++ "D17_REG", \
++ "D18_REG", \
++ "D19_REG", \
++ "D20_REG", \
++ "D21_REG", \
++ "D22_REG", \
++ "D23_REG", \
++ "D24_REG", \
++ "D25_REG", \
++ "D26_REG", \
++ "D27_REG", \
++ "D28_REG", \
++ "D29_REG", \
++ "D30_REG", \
++ "D31_REG", \
++ "GP_REGS", \
++ "ALL_REGS"}
++
++#define GENERAL_REGS ALL_REGS
++
++#define REG_CLASS_CONTENTS \
++/* NO_REGS */ {{ 0, 0}, \
++/* D00_REG */ { 1 << 0, 0}, \
++/* D01_REG */ { 1 << 1, 0}, \
++/* D02_REG */ { 1 << 2, 0}, \
++/* D03_REG */ { 1 << 3, 0}, \
++/* D04_REG */ { 1 << 4, 0}, \
++/* D05_REG */ { 1 << 5, 0}, \
++/* D06_REG */ { 1 << 6, 0}, \
++/* D07_REG */ { 1 << 7, 0}, \
++/* D08_REG */ { 1 << 8, 0}, \
++/* D09_REG */ { 1 << 9, 0}, \
++/* D10_REG */ { 1 << 10, 0}, \
++/* D11_REG */ { 1 << 11, 0}, \
++/* D12_REG */ { 1 << 12, 0}, \
++/* D13_REG */ { 1 << 13, 0}, \
++/* D14_REG */ { 1 << 14, 0}, \
++/* D15_REG */ { 1 << 15, 0}, \
++/* D16_REG */ { 1 << 16, 0}, \
++/* D17_REG */ { 1 << 17, 0}, \
++/* D18_REG */ { 1 << 18, 0}, \
++/* D19_REG */ { 1 << 19, 0}, \
++/* D20_REG */ { 1 << 20, 0}, \
++/* D21_REG */ { 1 << 21, 0}, \
++/* D22_REG */ { 1 << 22, 0}, \
++/* D23_REG */ { 1 << 23, 0}, \
++/* D24_REG */ { 1 << 24, 0}, \
++/* D25_REG */ { 1 << 25, 0}, \
++/* D26_REG */ { 1 << 26, 0}, \
++/* D27_REG */ { 1 << 27, 0}, \
++/* D28_REG */ { 1 << 28, 0}, \
++/* D29_REG */ { 1 << 29, 0}, \
++/* D30_REG */ { 1 << 30, 0}, \
++/* D31_REG */ { 1 << 31, 0}, \
++/* GP_REGS */ {~0, 0}, \
++/* ALL_REGS */ {~0,~0}} \
++
++#define REGNO_REG_CLASS(REGNO) ((REGNO) <= 31 ? GP_REGS : ALL_REGS)
++
++#define BASE_REG_CLASS ALL_REGS
++#define INDEX_REG_CLASS ALL_REGS
++
++/* 'r', is handled automatically */
++#define REG_CLASS_FROM_CONSTRAINT(CHAR, STR) \
++ reg_class_from_constraint ((CHAR), (STR))
++
++
++#define REGNO_OK_FOR_BASE_P2(REGNO, STRICT) \
++ ((STRICT) \
++ ? (REGNO) < FIRST_PSEUDO_REGISTER \
++ : (REGNO) < FIRST_PSEUDO_REGISTER || (reg_renumber && reg_renumber[REGNO] < FIRST_PSEUDO_REGISTER))
++
++#define REGNO_OK_FOR_INDEX_P2(REGNO, STRICT) \
++ (REGNO_OK_FOR_BASE_P2 (REGNO, STRICT))
++
++#define REGNO_OK_FOR_BASE_P(REGNO) \
++ (REGNO_OK_FOR_BASE_P2 (REGNO, 1))
++
++#define REGNO_OK_FOR_INDEX_P(REGNO) \
++ (REGNO_OK_FOR_INDEX_P2 (REGNO, 1))
++
++#define REG_OK_FOR_BASE_P2(X, STRICT) \
++ (STRICT \
++ ? REGNO_OK_FOR_BASE_P2 (REGNO (X), 1) \
++ : REGNO_OK_FOR_BASE_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
++
++#define REG_OK_FOR_INDEX_P2(X, STRICT) \
++ (STRICT \
++ ? REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1) \
++ : REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
++
++#define CLASS_MAX_NREGS(CLASS, MODE) \
++ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
++ / UNITS_PER_WORD)
++
++
++#define SMALL_INT(X) ((unsigned HOST_WIDE_INT) ((X) + 0x8000) < 0x10000)
++#define SMALL_INT_UNSIGNED(X) ((unsigned HOST_WIDE_INT) (X) < 0x10000)
++#define UPPER16_INT(X) (((X) & 0xffff) == 0)
++#define SHIFT_INT(X) ((X) >= 0 && (X) <= 31)
++#define RDWRCTL_INT(X) ((X) >= 0 && (X) <= 31)
++#define CUSTOM_INSN_OPCODE(X) ((X) >= 0 && (X) <= 255)
++
++#define CONST_OK_FOR_LETTER_P(VALUE, C) \
++ ( \
++ (C) == 'I' ? SMALL_INT (VALUE) : \
++ (C) == 'J' ? SMALL_INT_UNSIGNED (VALUE) : \
++ (C) == 'K' ? UPPER16_INT (VALUE) : \
++ (C) == 'L' ? SHIFT_INT (VALUE) : \
++ (C) == 'M' ? (VALUE) == 0 : \
++ (C) == 'N' ? CUSTOM_INSN_OPCODE (VALUE) : \
++ (C) == 'O' ? RDWRCTL_INT (VALUE) : \
++ 0)
++
++#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
++
++#define PREFERRED_RELOAD_CLASS(X, CLASS) \
++ ((CLASS) == NO_REGS ? GENERAL_REGS : (CLASS))
++
++#define CONSTRAINT_LEN(C, STR) \
++ ((C) == 'D' ? 3 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
++
++/* 'S' matches immediates which are in small data
++ and therefore can be added to gp to create a
++ 32-bit value. */
++#define EXTRA_CONSTRAINT(VALUE, C) \
++ ((C) == 'S' \
++ && (GET_CODE (VALUE) == SYMBOL_REF) \
++ && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (VALUE))
++
++
++
++
++/* Say that the epilogue uses the return address register. Note that
++ in the case of sibcalls, the values "used by the epilogue" are
++ considered live at the start of the called function. */
++#define EPILOGUE_USES(REGNO) ((REGNO) == RA_REGNO)
++
++
++#define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
++
++/**********************************
++ * Trampolines for Nested Functions
++ ***********************************/
++
++#define TRAMPOLINE_TEMPLATE(FILE) \
++ error ("trampolines not yet implemented")
++#define TRAMPOLINE_SIZE 20
++#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
++ error ("trampolines not yet implemented")
++
++/***************************
++ * Stack Layout and Calling Conventions
++ ***************************/
++
++/* ------------------ *
++ * Basic Stack Layout
++ * ------------------ */
++
++/* The downward variants are used by the compiler,
++ the upward ones serve as documentation */
++#define STACK_GROWS_DOWNWARD
++#define FRAME_GROWS_UPWARD
++#define ARGS_GROW_UPWARD
++
++#define STARTING_FRAME_OFFSET current_function_outgoing_args_size
++#define FIRST_PARM_OFFSET(FUNDECL) 0
++
++/* Before the prologue, RA lives in r31. */
++#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (VOIDmode, RA_REGNO)
++
++/* -------------------------------------- *
++ * Registers That Address the Stack Frame
++ * -------------------------------------- */
++
++#define STACK_POINTER_REGNUM SP_REGNO
++#define STATIC_CHAIN_REGNUM SC_REGNO
++#define PC_REGNUM PC_REGNO
++#define DWARF_FRAME_RETURN_COLUMN RA_REGNO
++
++/* Base register for access to local variables of the function. We
++ pretend that the frame pointer is a non-existent hard register, and
++ then eliminate it to HARD_FRAME_POINTER_REGNUM. */
++#define FRAME_POINTER_REGNUM FAKE_FP_REGNO
++
++#define HARD_FRAME_POINTER_REGNUM FP_REGNO
++#define RETURN_ADDRESS_POINTER_REGNUM RAP_REGNO
++/* the argumnet pointer needs to always be eliminated
++ so it is set to a fake hard register. */
++#define ARG_POINTER_REGNUM FAKE_AP_REGNO
++
++/* ----------------------------------------- *
++ * Eliminating Frame Pointer and Arg Pointer
++ * ----------------------------------------- */
++
++#define FRAME_POINTER_REQUIRED 0
++
++#define ELIMINABLE_REGS \
++{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
++ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
++ { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
++ { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
++ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
++ { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
++
++#define CAN_ELIMINATE(FROM, TO) 1
++
++#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
++ (OFFSET) = nios2_initial_elimination_offset ((FROM), (TO))
++
++#define MUST_SAVE_REGISTER(regno) \
++ ((regs_ever_live[regno] && !call_used_regs[regno]) \
++ || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) \
++ || (regno == RA_REGNO && regs_ever_live[RA_REGNO]))
++
++/* Treat LOC as a byte offset from the stack pointer and round it up
++ to the next fully-aligned offset. */
++#define STACK_ALIGN(LOC) \
++ (((LOC) + ((PREFERRED_STACK_BOUNDARY / 8) - 1)) & ~((PREFERRED_STACK_BOUNDARY / 8) - 1))
++
++
++/* ------------------------------ *
++ * Passing Arguments in Registers
++ * ------------------------------ */
++
++/* see nios2.c */
++#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
++ (function_arg (&CUM, MODE, TYPE, NAMED))
++
++#define MUST_PASS_IN_STACK(MODE, TYPE) \
++ nios2_must_pass_in_stack ((MODE), (TYPE))
++
++#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
++ (function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED))
++
++#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) 0
++
++#define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 0
++
++typedef struct nios2_args
++{
++ int regs_used;
++} CUMULATIVE_ARGS;
++
++/* This is to initialize the above unused CUM data type */
++#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
++ (init_cumulative_args (&CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS))
++
++#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
++ (function_arg_advance (&CUM, MODE, TYPE, NAMED))
++
++#define FUNCTION_ARG_PADDING(MODE, TYPE) \
++ (nios2_function_arg_padding_upward ((MODE), (TYPE)) ? upward : downward)
++
++#define PAD_VARARGS_DOWN \
++ (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
++
++#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
++ (nios2_block_reg_padding_upward ((MODE), (TYPE), (FIRST)) ? upward : downward)
++
++#define FUNCTION_ARG_REGNO_P(REGNO) \
++ ((REGNO) >= FIRST_ARG_REGNO && (REGNO) <= LAST_ARG_REGNO)
++
++#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
++ { \
++ int pret_size = nios2_setup_incoming_varargs (&(CUM), (MODE), \
++ (TYPE), (NO_RTL)); \
++ if (pret_size) \
++ (PRETEND_SIZE) = pret_size; \
++ }
++
++/* ----------------------------- *
++ * Generating Code for Profiling
++ * ----------------------------- */
++
++
++#define PROFILE_BEFORE_PROLOGUE
++#define NO_PROFILE_COUNTERS 1
++#define FUNCTION_PROFILER(FILE, LABELNO) \
++ function_profiler ((FILE), (LABELNO))
++
++/* --------------------------------------- *
++ * Passing Function Arguments on the Stack
++ * --------------------------------------- */
++
++#define PROMOTE_PROTOTYPES 1
++
++#define PUSH_ARGS 0
++#define ACCUMULATE_OUTGOING_ARGS 1
++
++#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACKSIZE) 0
++
++/* --------------------------------------- *
++ * How Scalar Function Values Are Returned
++ * --------------------------------------- */
++
++#define FUNCTION_VALUE(VALTYPE, FUNC) \
++ gen_rtx(REG, TYPE_MODE(VALTYPE), FIRST_RETVAL_REGNO)
++
++#define LIBCALL_VALUE(MODE) \
++ gen_rtx(REG, MODE, FIRST_RETVAL_REGNO)
++
++#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == FIRST_RETVAL_REGNO)
++
++/* ----------------------------- *
++ * How Large Values Are Returned
++ * ----------------------------- */
++
++
++#define RETURN_IN_MEMORY(TYPE) \
++ nios2_return_in_memory (TYPE)
++
++
++#define STRUCT_VALUE 0
++
++#define DEFAULT_PCC_STRUCT_RETURN 0
++
++/*******************
++ * Addressing Modes
++ *******************/
++
++
++#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
++
++#define CONSTANT_ADDRESS_P(X) (CONSTANT_P (X))
++
++#define MAX_REGS_PER_ADDRESS 1
++
++/* Go to ADDR if X is a valid address. */
++#ifndef REG_OK_STRICT
++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
++ { \
++ if (nios2_legitimate_address ((X), (MODE), 0)) \
++ goto ADDR; \
++ }
++#else
++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
++ { \
++ if (nios2_legitimate_address ((X), (MODE), 1)) \
++ goto ADDR; \
++ }
++#endif
++
++#ifndef REG_OK_STRICT
++#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P2 (REGNO (X), 0)
++#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P2 (REGNO (X), 0)
++#else
++#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P2 (REGNO (X), 1)
++#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1)
++#endif
++
++#define LEGITIMATE_CONSTANT_P(X) 1
++
++/* Nios II has no mode dependent addresses. */
++#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
++
++/* Set if this has a weak declaration */
++#define SYMBOL_FLAG_WEAK_DECL (1 << SYMBOL_FLAG_MACH_DEP_SHIFT)
++#define SYMBOL_REF_WEAK_DECL_P(RTX) \
++ ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_WEAK_DECL) != 0)
++
++
++/* true if a symbol is both small and not weak. In this case, gp
++ relative access can be used */
++#define SYMBOL_REF_IN_NIOS2_SMALL_DATA_P(RTX) \
++ (SYMBOL_REF_SMALL_P(RTX) && !SYMBOL_REF_WEAK_DECL_P(RTX))
++
++/*****************
++ * Describing Relative Costs of Operations
++ *****************/
++
++#define SLOW_BYTE_ACCESS 1
++
++/* It is as good to call a constant function address as to call an address
++ kept in a register.
++ ??? Not true anymore really. Now that call cannot address full range
++ of memory callr may need to be used */
++
++#define NO_FUNCTION_CSE
++#define NO_RECURSIVE_FUNCTION_CSE
++
++
++
++/*****************************************
++ * Defining the Output Assembler Language
++ *****************************************/
++
++/* ------------------------------------------ *
++ * The Overall Framework of an Assembler File
++ * ------------------------------------------ */
++
++#define ASM_APP_ON "#APP\n"
++#define ASM_APP_OFF "#NO_APP\n"
++
++#define ASM_COMMENT_START "# "
++
++/* ------------------------------- *
++ * Output and Generation of Labels
++ * ------------------------------- */
++
++#define GLOBAL_ASM_OP "\t.global\t"
++
++
++/* -------------- *
++ * Output of Data
++ * -------------- */
++
++#define DWARF2_UNWIND_INFO 0
++
++
++/* -------------------------------- *
++ * Assembler Commands for Alignment
++ * -------------------------------- */
++
++#define ASM_OUTPUT_ALIGN(FILE, LOG) \
++ do { \
++ fprintf ((FILE), "%s%d\n", ALIGN_ASM_OP, (LOG)); \
++ } while (0)
++
++
++/* -------------------------------- *
++ * Output of Assembler Instructions
++ * -------------------------------- */
++
++#define REGISTER_NAMES \
++{ \
++ "zero", \
++ "at", \
++ "r2", \
++ "r3", \
++ "r4", \
++ "r5", \
++ "r6", \
++ "r7", \
++ "r8", \
++ "r9", \
++ "r10", \
++ "r11", \
++ "r12", \
++ "r13", \
++ "r14", \
++ "r15", \
++ "r16", \
++ "r17", \
++ "r18", \
++ "r19", \
++ "r20", \
++ "r21", \
++ "r22", \
++ "r23", \
++ "et", \
++ "bt", \
++ "gp", \
++ "sp", \
++ "fp", \
++ "ta", \
++ "ba", \
++ "ra", \
++ "status", \
++ "estatus", \
++ "bstatus", \
++ "ipri", \
++ "ecause", \
++ "pc", \
++ "rap", \
++ "fake_fp", \
++ "fake_ap", \
++}
++
++#define ADDITIONAL_REGISTER_NAMES \
++{ \
++ {"r0", 0}, \
++ {"r1", 1}, \
++ {"r24", 24}, \
++ {"r25", 25}, \
++ {"r26", 26}, \
++ {"r27", 27}, \
++ {"r28", 28}, \
++ {"r29", 29}, \
++ {"r30", 30}, \
++ {"r31", 31} \
++}
++
++
++#define ASM_OUTPUT_OPCODE(STREAM, PTR)\
++ (PTR) = asm_output_opcode (STREAM, PTR)
++
++#define PRINT_OPERAND(STREAM, X, CODE) \
++ nios2_print_operand (STREAM, X, CODE)
++
++#define PRINT_OPERAND_ADDRESS(STREAM, X) \
++ nios2_print_operand_address (STREAM, X)
++
++#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
++do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \
++ fprintf (FILE, ".L%u\n", (unsigned) (VALUE)); \
++ } while (0)
++
++
++/* ------------ *
++ * Label Output
++ * ------------ */
++
++
++/* ---------------------------------------------------- *
++ * Dividing the Output into Sections (Texts, Data, ...)
++ * ---------------------------------------------------- */
++
++/* Output before read-only data. */
++#define TEXT_SECTION_ASM_OP ("\t.section\t.text")
++
++/* Output before writable data. */
++#define DATA_SECTION_ASM_OP ("\t.section\t.data")
++
++
++/* Default the definition of "small data" to 8 bytes. */
++/* ??? How come I can't use HOST_WIDE_INT here? */
++extern unsigned long nios2_section_threshold;
++#define NIOS2_DEFAULT_GVALUE 8
++
++
++
++/* This says how to output assembler code to declare an
++ uninitialized external linkage data object. Under SVR4,
++ the linker seems to want the alignment of data objects
++ to depend on their types. We do exactly that here. */
++
++#undef COMMON_ASM_OP
++#define COMMON_ASM_OP "\t.comm\t"
++
++#undef ASM_OUTPUT_ALIGNED_COMMON
++#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
++do \
++{ \
++ if ((SIZE) <= nios2_section_threshold) \
++ { \
++ named_section (0, ".sbss", 0); \
++ (*targetm.asm_out.globalize_label) (FILE, NAME); \
++ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
++ if (!flag_inhibit_size_directive) \
++ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
++ ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
++ ASM_OUTPUT_LABEL(FILE, NAME); \
++ ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
++ } \
++ else \
++ { \
++ fprintf ((FILE), "%s", COMMON_ASM_OP); \
++ assemble_name ((FILE), (NAME)); \
++ fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
++ } \
++} \
++while (0)
++
++
++/* This says how to output assembler code to declare an
++ uninitialized internal linkage data object. Under SVR4,
++ the linker seems to want the alignment of data objects
++ to depend on their types. We do exactly that here. */
++
++#undef ASM_OUTPUT_ALIGNED_LOCAL
++#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
++do { \
++ if ((SIZE) <= nios2_section_threshold) \
++ named_section (0, ".sbss", 0); \
++ else \
++ named_section (0, ".bss", 0); \
++ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
++ if (!flag_inhibit_size_directive) \
++ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
++ ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
++ ASM_OUTPUT_LABEL(FILE, NAME); \
++ ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
++} while (0)
++
++
++
++/***************************
++ * Miscellaneous Parameters
++ ***************************/
++
++#define MOVE_MAX 4
++
++#define STORE_FLAG_VALUE 1
++#define Pmode SImode
++#define FUNCTION_MODE QImode
++
++#define REGISTER_TARGET_PRAGMAS() nios2_register_target_pragmas ();
++
++#define CASE_VECTOR_MODE Pmode
++
++#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
++
++#define LOAD_EXTEND_OP(MODE) (ZERO_EXTEND)
++
++#define WORD_REGISTER_OPERATIONS
+diff --git a/gcc/config/nios2/nios2.md b/gcc/config/nios2/nios2.md
+new file mode 100644
+index 0000000..6183247
+--- /dev/null
++++ b/gcc/config/nios2/nios2.md
+@@ -0,0 +1,2867 @@
++;; Machine Description for Altera NIOS 2G NIOS2 version.
++;; Copyright (C) 2005 Altera
++;; Contributed by Jonah Graham (jgraham@altera.com) and Will Reece (wreece@altera.com).
++;;
++;; This file is part of GNU CC.
++;;
++;; GNU CC is free software; you can redistribute it and/or modify
++;; it under the terms of the GNU General Public License as published by
++;; the Free Software Foundation; either version 2, or (at your option)
++;; any later version.
++;;
++;; GNU CC is distributed in the hope that it will be useful,
++;; but WITHOUT ANY WARRANTY; without even the implied warranty of
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++;; GNU General Public License for more details.
++;;
++;; You should have received a copy of the GNU General Public License
++;; along with GNU CC; see the file COPYING. If not, write to
++;; the Free Software Foundation, 59 Temple Place - Suite 330,
++;; Boston, MA 02111-1307, USA. */
++
++
++
++
++;*****************************************************************************
++;*
++;* constraint strings
++;*
++;*****************************************************************************
++;
++; We use the following constraint letters for constants
++;
++; I: -32768 to -32767
++; J: 0 to 65535
++; K: $nnnn0000 for some nnnn
++; L: 0 to 31 (for shift counts)
++; M: 0
++; N: 0 to 255 (for custom instruction numbers)
++; O: 0 to 31 (for control register numbers)
++;
++; We use the following built-in register classes:
++;
++; r: general purpose register (r0..r31)
++; m: memory operand
++;
++; Plus, we define the following constraint strings:
++;
++; S: symbol that is in the "small data" area
++; Dnn: Dnn_REG (just rnn)
++;
++
++
++
++;*****************************************************************************
++;*
++;* constants
++;*
++;*****************************************************************************
++(define_constants [
++ (ET_REGNO 24)
++ (GP_REGNO 26)
++ (SP_REGNO 27)
++ (FP_REGNO 28)
++ (RA_REGNO 31)
++ (RAP_REGNO 38)
++ (FIRST_RETVAL_REGNO 2)
++ (LAST_RETVAL_REGNO 3)
++ (FIRST_ARG_REGNO 4)
++ (LAST_ARG_REGNO 7)
++ (SC_REGNO 23)
++ (PC_REGNO 37)
++ (FAKE_FP_REGNO 39)
++ (FAKE_AP_REGNO 40)
++
++
++ (UNSPEC_BLOCKAGE 0)
++ (UNSPEC_LDBIO 1)
++ (UNSPEC_LDBUIO 2)
++ (UNSPEC_LDHIO 3)
++ (UNSPEC_LDHUIO 4)
++ (UNSPEC_LDWIO 5)
++ (UNSPEC_STBIO 6)
++ (UNSPEC_STHIO 7)
++ (UNSPEC_STWIO 8)
++ (UNSPEC_SYNC 9)
++ (UNSPEC_WRCTL 10)
++ (UNSPEC_RDCTL 11)
++ (UNSPEC_TRAP 12)
++ (UNSPEC_STACK_OVERFLOW_DETECT_AND_TRAP 13)
++ (UNSPEC_FCOSS 14)
++ (UNSPEC_FCOSD 15)
++ (UNSPEC_FSINS 16)
++ (UNSPEC_FSIND 17)
++ (UNSPEC_FTANS 18)
++ (UNSPEC_FTAND 19)
++ (UNSPEC_FATANS 20)
++ (UNSPEC_FATAND 21)
++ (UNSPEC_FEXPS 22)
++ (UNSPEC_FEXPD 23)
++ (UNSPEC_FLOGS 24)
++ (UNSPEC_FLOGD 25)
++ (UNSPEC_FWRX 26)
++ (UNSPEC_FWRY 27)
++ (UNSPEC_FRDXLO 28)
++ (UNSPEC_FRDXHI 29)
++ (UNSPEC_FRDY 30)
++ ;; Note that values 100..151 are used by custom instructions, see below.
++])
++
++
++
++;*****************************************************************************
++;*
++;* instruction scheduler
++;*
++;*****************************************************************************
++
++; No schedule info is currently available, using an assumption that no
++; instruction can use the results of the previous instruction without
++; incuring a stall.
++
++; length of an instruction (in bytes)
++(define_attr "length" "" (const_int 4))
++(define_attr "type" "unknown,complex,control,alu,cond_alu,st,ld,shift,mul,div,custom" (const_string "complex"))
++
++(define_asm_attributes
++ [(set_attr "length" "4")
++ (set_attr "type" "complex")])
++
++(define_automaton "nios2")
++(automata_option "v")
++;(automata_option "no-minimization")
++(automata_option "ndfa")
++
++; The nios2 pipeline is fairly straightforward for the fast model.
++; Every alu operation is pipelined so that an instruction can
++; be issued every cycle. However, there are still potential
++; stalls which this description tries to deal with.
++
++(define_cpu_unit "cpu" "nios2")
++
++(define_insn_reservation "complex" 1
++ (eq_attr "type" "complex")
++ "cpu")
++
++(define_insn_reservation "control" 1
++ (eq_attr "type" "control")
++ "cpu")
++
++(define_insn_reservation "alu" 1
++ (eq_attr "type" "alu")
++ "cpu")
++
++(define_insn_reservation "cond_alu" 1
++ (eq_attr "type" "cond_alu")
++ "cpu")
++
++(define_insn_reservation "st" 1
++ (eq_attr "type" "st")
++ "cpu")
++
++(define_insn_reservation "custom" 1
++ (eq_attr "type" "custom")
++ "cpu")
++
++; shifts, muls and lds have three cycle latency
++(define_insn_reservation "ld" 3
++ (eq_attr "type" "ld")
++ "cpu")
++
++(define_insn_reservation "shift" 3
++ (eq_attr "type" "shift")
++ "cpu")
++
++(define_insn_reservation "mul" 3
++ (eq_attr "type" "mul")
++ "cpu")
++
++(define_insn_reservation "div" 1
++ (eq_attr "type" "div")
++ "cpu")
++
++
++;*****************************************************************************
++;*
++;* MOV Instructions
++;*
++;*****************************************************************************
++
++(define_expand "movqi"
++ [(set (match_operand:QI 0 "nonimmediate_operand" "")
++ (match_operand:QI 1 "general_operand" ""))]
++ ""
++{
++ if (nios2_emit_move_sequence (operands, QImode))
++ DONE;
++})
++
++(define_insn "movqi_internal"
++ [(set (match_operand:QI 0 "nonimmediate_operand" "=m, r,r, r")
++ (match_operand:QI 1 "general_operand" "rM,m,rM,I"))]
++ "(register_operand (operands[0], QImode)
++ || reg_or_0_operand (operands[1], QImode))"
++ "@
++ stb%o0\\t%z1, %0
++ ldbu%o1\\t%0, %1
++ mov\\t%0, %z1
++ movi\\t%0, %1"
++ [(set_attr "type" "st,ld,alu,alu")])
++
++(define_insn "ldbio"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDBIO))
++ (use (match_operand:SI 1 "memory_operand" "m"))]
++ ""
++ "ldbio\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++(define_insn "ldbuio"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDBUIO))
++ (use (match_operand:SI 1 "memory_operand" "m"))]
++ ""
++ "ldbuio\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++(define_insn "stbio"
++ [(set (match_operand:SI 0 "memory_operand" "=m")
++ (match_operand:SI 1 "reg_or_0_operand" "rM"))
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STBIO)]
++ ""
++ "stbio\\t%z1, %0"
++ [(set_attr "type" "st")])
++
++
++(define_expand "movhi"
++ [(set (match_operand:HI 0 "nonimmediate_operand" "")
++ (match_operand:HI 1 "general_operand" ""))]
++ ""
++{
++ if (nios2_emit_move_sequence (operands, HImode))
++ DONE;
++})
++
++(define_insn "movhi_internal"
++ [(set (match_operand:HI 0 "nonimmediate_operand" "=m, r,r, r,r")
++ (match_operand:HI 1 "general_operand" "rM,m,rM,I,J"))]
++ "(register_operand (operands[0], HImode)
++ || reg_or_0_operand (operands[1], HImode))"
++ "@
++ sth%o0\\t%z1, %0
++ ldhu%o1\\t%0, %1
++ mov\\t%0, %z1
++ movi\\t%0, %1
++ movui\\t%0, %1"
++ [(set_attr "type" "st,ld,alu,alu,alu")])
++
++(define_insn "ldhio"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDHIO))
++ (use (match_operand:SI 1 "memory_operand" "m"))]
++ ""
++ "ldhio\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++(define_insn "ldhuio"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDHUIO))
++ (use (match_operand:SI 1 "memory_operand" "m"))]
++ ""
++ "ldhuio\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++(define_insn "sthio"
++ [(set (match_operand:SI 0 "memory_operand" "=m")
++ (match_operand:SI 1 "reg_or_0_operand" "rM"))
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STHIO)]
++ ""
++ "sthio\\t%z1, %0"
++ [(set_attr "type" "st")])
++
++(define_expand "movsi"
++ [(set (match_operand:SI 0 "nonimmediate_operand" "")
++ (match_operand:SI 1 "general_operand" ""))]
++ ""
++{
++ if (nios2_emit_move_sequence (operands, SImode))
++ DONE;
++})
++
++(define_insn "movsi_internal"
++ [(set (match_operand:SI 0 "nonimmediate_operand" "=m, r,r, r,r,r,r")
++ (match_operand:SI 1 "general_operand" "rM,m,rM,I,J,S,i"))]
++ "(register_operand (operands[0], SImode)
++ || reg_or_0_operand (operands[1], SImode))"
++ "@
++ stw%o0\\t%z1, %0
++ ldw%o1\\t%0, %1
++ mov\\t%0, %z1
++ movi\\t%0, %1
++ movui\\t%0, %1
++ addi\\t%0, gp, %%gprel(%1)
++ movhi\\t%0, %H1\;addi\\t%0, %0, %L1"
++ [(set_attr "type" "st,ld,alu,alu,alu,alu,alu")])
++
++(define_insn "ldwio"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDWIO))
++ (use (match_operand:SI 1 "memory_operand" "m"))]
++ ""
++ "ldwio\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++(define_insn "stwio"
++ [(set (match_operand:SI 0 "memory_operand" "=m")
++ (match_operand:SI 1 "reg_or_0_operand" "rM"))
++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STWIO)]
++ ""
++ "stwio\\t%z1, %0"
++ [(set_attr "type" "st")])
++
++
++
++;*****************************************************************************
++;*
++;* zero extension
++;*
++;*****************************************************************************
++
++
++(define_insn "zero_extendhisi2"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
++ ""
++ "@
++ andi\\t%0, %1, 0xffff
++ ldhu%o1\\t%0, %1"
++ [(set_attr "type" "alu,ld")])
++
++(define_insn "zero_extendqihi2"
++ [(set (match_operand:HI 0 "register_operand" "=r,r")
++ (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
++ ""
++ "@
++ andi\\t%0, %1, 0xff
++ ldbu%o1\\t%0, %1"
++ [(set_attr "type" "alu,ld")])
++
++(define_insn "zero_extendqisi2"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
++ ""
++ "@
++ andi\\t%0, %1, 0xff
++ ldbu%o1\\t%0, %1"
++ [(set_attr "type" "alu,ld")])
++
++
++
++;*****************************************************************************
++;*
++;* sign extension
++;*
++;*****************************************************************************
++(define_expand "extendhisi2"
++ [(set (match_operand:SI 0 "register_operand" "")
++ (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
++ ""
++{
++})
++
++(define_insn "*extendhisi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
++ ""
++ "#")
++
++(define_split
++ [(set (match_operand:SI 0 "register_operand" "")
++ (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
++ "reload_completed"
++ [(set (match_dup 0)
++ (and:SI (match_dup 1) (const_int 65535)))
++ (set (match_dup 0)
++ (xor:SI (match_dup 0) (const_int 32768)))
++ (set (match_dup 0)
++ (plus:SI (match_dup 0) (const_int -32768)))]
++ "operands[1] = gen_lowpart (SImode, operands[1]);")
++
++(define_insn "extendhisi2_internal"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
++ ""
++ "ldh%o1\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++
++(define_expand "extendqihi2"
++ [(set (match_operand:HI 0 "register_operand" "")
++ (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
++ ""
++{
++})
++
++(define_insn "*extendqihi2"
++ [(set (match_operand:HI 0 "register_operand" "=r")
++ (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
++ ""
++ "#")
++
++(define_split
++ [(set (match_operand:HI 0 "register_operand" "")
++ (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
++ "reload_completed"
++ [(set (match_dup 0)
++ (and:SI (match_dup 1) (const_int 255)))
++ (set (match_dup 0)
++ (xor:SI (match_dup 0) (const_int 128)))
++ (set (match_dup 0)
++ (plus:SI (match_dup 0) (const_int -128)))]
++ "operands[0] = gen_lowpart (SImode, operands[0]);
++ operands[1] = gen_lowpart (SImode, operands[1]);")
++
++
++
++(define_insn "extendqihi2_internal"
++ [(set (match_operand:HI 0 "register_operand" "=r")
++ (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
++ ""
++ "ldb%o1\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++
++(define_expand "extendqisi2"
++ [(set (match_operand:SI 0 "register_operand" "")
++ (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
++ ""
++{
++})
++
++(define_insn "*extendqisi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
++ ""
++ "#")
++
++(define_split
++ [(set (match_operand:SI 0 "register_operand" "")
++ (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
++ "reload_completed"
++ [(set (match_dup 0)
++ (and:SI (match_dup 1) (const_int 255)))
++ (set (match_dup 0)
++ (xor:SI (match_dup 0) (const_int 128)))
++ (set (match_dup 0)
++ (plus:SI (match_dup 0) (const_int -128)))]
++ "operands[1] = gen_lowpart (SImode, operands[1]);")
++
++(define_insn "extendqisi2_insn"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
++ ""
++ "ldb%o1\\t%0, %1"
++ [(set_attr "type" "ld")])
++
++
++
++
++;*****************************************************************************
++;*
++;* Arithmetic Operations
++;*
++;*****************************************************************************
++
++(define_insn "addsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
++ (match_operand:SI 2 "arith_operand" "r,I")))]
++ ""
++ "add%i2\\t%0, %1, %z2"
++ [(set_attr "type" "alu")])
++
++(define_insn "addsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (plus:SF (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_addsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_addsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "adddf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (plus:DF (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_adddf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_adddf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "subsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "register_operand" "r")))]
++ ""
++ "sub\\t%0, %z1, %2"
++ [(set_attr "type" "alu")])
++
++(define_insn "subsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (minus:SF (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_subsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_subsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "subdf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (minus:DF (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_subdf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_subdf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "mulsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (mult:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "arith_operand" "r,I")))]
++ "TARGET_HAS_MUL"
++ "mul%i2\\t%0, %1, %z2"
++ [(set_attr "type" "mul")])
++
++(define_insn "mulsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (mult:SF (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_mulsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_mulsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "muldf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (mult:DF (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_muldf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_muldf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_expand "divsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (div:SI (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")))]
++ ""
++{
++ if (!TARGET_HAS_DIV)
++ {
++ if (!TARGET_FAST_SW_DIV)
++ FAIL;
++ else
++ {
++ if (nios2_emit_expensive_div (operands, SImode))
++ DONE;
++ }
++ }
++})
++
++(define_insn "divsi3_insn"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (div:SI (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")))]
++ "TARGET_HAS_DIV"
++ "div\\t%0, %1, %2"
++ [(set_attr "type" "div")])
++
++(define_insn "divsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (div:SF (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_divsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_divsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "divdf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (div:DF (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_divdf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_divdf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "udivsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (udiv:SI (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")))]
++ "TARGET_HAS_DIV"
++ "divu\\t%0, %1, %2"
++ [(set_attr "type" "div")])
++
++(define_insn "smulsi3_highpart"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (truncate:SI
++ (lshiftrt:DI
++ (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
++ (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
++ (const_int 32))))]
++ "TARGET_HAS_MULX"
++ "mulxss\\t%0, %1, %2"
++ [(set_attr "type" "mul")])
++
++(define_insn "umulsi3_highpart"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (truncate:SI
++ (lshiftrt:DI
++ (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
++ (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
++ (const_int 32))))]
++ "TARGET_HAS_MULX"
++ "mulxuu\\t%0, %1, %2"
++ [(set_attr "type" "mul")])
++
++
++(define_expand "mulsidi3_little_endian"
++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
++ (mult:SI (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")))
++ (set (subreg:SI (match_dup 0) 4)
++ (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
++ (sign_extend:DI (match_dup 2)))
++ (const_int 32))))]
++ "TARGET_HAS_MULX && !WORDS_BIG_ENDIAN"
++ "")
++
++(define_expand "mulsidi3_big_endian"
++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
++ (mult:SI (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")))
++ (set (subreg:SI (match_dup 0) 0)
++ (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
++ (sign_extend:DI (match_dup 2)))
++ (const_int 32))))]
++ "TARGET_HAS_MULX && WORDS_BIG_ENDIAN"
++ "")
++
++(define_expand "mulsidi3"
++ [(match_operand:DI 0 "register_operand" "")
++ (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")]
++ "TARGET_HAS_MULX"
++ {
++ if (WORDS_BIG_ENDIAN)
++ {
++ emit_insn (gen_mulsidi3_big_endian (operands[0],
++ operands[1],
++ operands[2]));
++ }
++ else
++ {
++ emit_insn (gen_mulsidi3_little_endian (operands[0],
++ operands[1],
++ operands[2]));
++ }
++ DONE;
++ })
++
++(define_expand "umulsidi3_little_endian"
++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
++ (mult:SI (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")))
++ (set (subreg:SI (match_dup 0) 4)
++ (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
++ (zero_extend:DI (match_dup 2)))
++ (const_int 32))))]
++ "TARGET_HAS_MULX && !WORDS_BIG_ENDIAN"
++ "")
++
++(define_expand "umulsidi3_big_endian"
++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
++ (mult:SI (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")))
++ (set (subreg:SI (match_dup 0) 0)
++ (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
++ (zero_extend:DI (match_dup 2)))
++ (const_int 32))))]
++ "TARGET_HAS_MULX && WORDS_BIG_ENDIAN"
++ "")
++
++(define_expand "umulsidi3"
++ [(match_operand:DI 0 "register_operand" "")
++ (match_operand:SI 1 "register_operand" "")
++ (match_operand:SI 2 "register_operand" "")]
++ "TARGET_HAS_MULX"
++ {
++ if (WORDS_BIG_ENDIAN)
++ {
++ emit_insn (gen_umulsidi3_big_endian (operands[0],
++ operands[1],
++ operands[2]));
++ }
++ else
++ {
++ emit_insn (gen_umulsidi3_little_endian (operands[0],
++ operands[1],
++ operands[2]));
++ }
++ DONE;
++ })
++
++
++;*****************************************************************************
++;*
++;* Negate and ones complement
++;*
++;*****************************************************************************
++
++(define_insn "negsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (neg:SI (match_operand:SI 1 "register_operand" "r")))]
++ ""
++{
++ operands[2] = const0_rtx;
++ return "sub\\t%0, %z2, %1";
++}
++ [(set_attr "type" "alu")])
++
++(define_insn "negsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (neg:SF (match_operand:SF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_negsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_negsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "negdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (neg:DF (match_operand:DF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_negdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_negdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "one_cmplsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (not:SI (match_operand:SI 1 "register_operand" "r")))]
++ ""
++{
++ operands[2] = const0_rtx;
++ return "nor\\t%0, %z2, %1";
++}
++ [(set_attr "type" "alu")])
++
++
++;*****************************************************************************
++;*
++;* Miscellaneous floating point
++;*
++;*****************************************************************************
++(define_insn "nios2_fwrx"
++ [(unspec_volatile [(match_operand:DF 0 "register_operand" "r")] UNSPEC_FWRX)]
++ "nios2_fpu_insns[nios2_fpu_nios2_fwrx].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_fwrx].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "nios2_fwry"
++ [(unspec_volatile [(match_operand:SF 0 "register_operand" "r")] UNSPEC_FWRY)]
++ "nios2_fpu_insns[nios2_fpu_nios2_fwry].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_fwry].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "nios2_frdxlo"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(const_int 0)] UNSPEC_FRDXLO))]
++ "nios2_fpu_insns[nios2_fpu_nios2_frdxlo].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_frdxlo].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "nios2_frdxhi"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(const_int 0)] UNSPEC_FRDXHI))]
++ "nios2_fpu_insns[nios2_fpu_nios2_frdxhi].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_frdxhi].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "nios2_frdy"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(const_int 0)] UNSPEC_FRDY))]
++ "nios2_fpu_insns[nios2_fpu_nios2_frdy].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_frdy].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "minsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (if_then_else:SF (lt:SF (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r"))
++ (match_dup 1)
++ (match_dup 2)))]
++ "nios2_fpu_insns[nios2_fpu_minsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_minsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "mindf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (if_then_else:DF (lt:DF (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r"))
++ (match_dup 1)
++ (match_dup 2)))]
++ "nios2_fpu_insns[nios2_fpu_mindf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_mindf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "maxsf3"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (if_then_else:SF (lt:SF (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r"))
++ (match_dup 2)
++ (match_dup 1)))]
++ "nios2_fpu_insns[nios2_fpu_maxsf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_maxsf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "maxdf3"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (if_then_else:DF (lt:DF (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r"))
++ (match_dup 2)
++ (match_dup 1)))]
++ "nios2_fpu_insns[nios2_fpu_maxdf3].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_maxdf3].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "abssf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (abs:SF (match_operand:SF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_abssf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_abssf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "absdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (abs:DF (match_operand:DF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_absdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_absdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "sqrtsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (sqrt:SF (match_operand:SF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_sqrtsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_sqrtsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "sqrtdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (sqrt:DF (match_operand:DF 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_sqrtdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_sqrtdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "cossf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FCOSS))]
++ "nios2_fpu_insns[nios2_fpu_cossf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_cossf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "cosdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FCOSD))]
++ "nios2_fpu_insns[nios2_fpu_cosdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_cosdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "sinsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FSINS))]
++ "nios2_fpu_insns[nios2_fpu_sinsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_sinsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "sindf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FSIND))]
++ "nios2_fpu_insns[nios2_fpu_sindf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_sindf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "tansf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FTANS))]
++ "nios2_fpu_insns[nios2_fpu_tansf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_tansf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "tandf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FTAND))]
++ "nios2_fpu_insns[nios2_fpu_tandf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_tandf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "atansf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FATANS))]
++ "nios2_fpu_insns[nios2_fpu_atansf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_atansf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "atandf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FATAND))]
++ "nios2_fpu_insns[nios2_fpu_atandf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_atandf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "expsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FEXPS))]
++ "nios2_fpu_insns[nios2_fpu_expsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_expsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "expdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FEXPD))]
++ "nios2_fpu_insns[nios2_fpu_expdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_expdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "logsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FLOGS))]
++ "nios2_fpu_insns[nios2_fpu_logsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_logsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "logdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unspec:DF [(match_operand:DF 1 "register_operand" "r")] UNSPEC_FLOGD))]
++ "nios2_fpu_insns[nios2_fpu_logdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_logdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++;*****************************************************************************
++;*
++;* Logical Operantions
++;*
++;*****************************************************************************
++
++(define_insn "andsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
++ (and:SI (match_operand:SI 1 "register_operand" "%r, r,r")
++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
++ ""
++ "@
++ and\\t%0, %1, %z2
++ and%i2\\t%0, %1, %2
++ andh%i2\\t%0, %1, %U2"
++ [(set_attr "type" "alu")])
++
++(define_insn "iorsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
++ (ior:SI (match_operand:SI 1 "register_operand" "%r, r,r")
++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
++ ""
++ "@
++ or\\t%0, %1, %z2
++ or%i2\\t%0, %1, %2
++ orh%i2\\t%0, %1, %U2"
++ [(set_attr "type" "alu")])
++
++(define_insn "*norsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (and:SI (not:SI (match_operand:SI 1 "register_operand" "%r"))
++ (not:SI (match_operand:SI 2 "reg_or_0_operand" "rM"))))]
++ ""
++ "nor\\t%0, %1, %z2"
++ [(set_attr "type" "alu")])
++
++(define_insn "xorsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
++ (xor:SI (match_operand:SI 1 "register_operand" "%r, r,r")
++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
++ ""
++ "@
++ xor\\t%0, %1, %z2
++ xor%i2\\t%0, %1, %2
++ xorh%i2\\t%0, %1, %U2"
++ [(set_attr "type" "alu")])
++
++
++
++;*****************************************************************************
++;*
++;* Shifts
++;*
++;*****************************************************************************
++
++(define_insn "ashlsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "shift_operand" "r,L")))]
++ ""
++
++{
++ if( GET_CODE ( operands[2] ) == CONST_INT && INTVAL( operands[2] ) == 1 )
++ return "add\t%0,%1,%1";
++ return "sll%i2\t%0,%1,%z2";
++}
++ [(set_attr "type" "shift")])
++
++(define_insn "ashrsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "shift_operand" "r,L")))]
++ ""
++ "sra%i2\\t%0, %1, %z2"
++ [(set_attr "type" "shift")])
++
++(define_insn "lshrsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "shift_operand" "r,L")))]
++ ""
++ "srl%i2\\t%0, %1, %z2"
++ [(set_attr "type" "shift")])
++
++(define_insn "rotlsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (rotate:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "shift_operand" "r,L")))]
++ ""
++ "rol%i2\\t%0, %1, %z2"
++ [(set_attr "type" "shift")])
++
++(define_insn "rotrsi3"
++ [(set (match_operand:SI 0 "register_operand" "=r,r")
++ (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
++ (match_operand:SI 2 "register_operand" "r,r")))]
++ ""
++ "ror\\t%0, %1, %2"
++ [(set_attr "type" "shift")])
++
++(define_insn "*shift_mul_constants"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ashift:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "const_int_operand" "I"))
++ (match_operand:SI 3 "const_int_operand" "I")))]
++ "TARGET_HAS_MUL && SMALL_INT (INTVAL (operands[2]) << INTVAL (operands[3]))"
++{
++ HOST_WIDE_INT mul = INTVAL (operands[2]) << INTVAL (operands[3]);
++ rtx ops[3];
++
++ ops[0] = operands[0];
++ ops[1] = operands[1];
++ ops[2] = GEN_INT (mul);
++
++ output_asm_insn ("muli\t%0, %1, %2", ops);
++ return "";
++}
++ [(set_attr "type" "mul")])
++
++
++
++
++;*****************************************************************************
++;*
++;* Converting between floating point and fixed point
++;*
++;*****************************************************************************
++(define_insn "floatsisf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (float:SF (match_operand:SI 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_floatsisf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_floatsisf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "floatsidf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (float:DF (match_operand:SI 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_floatsidf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_floatsidf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "floatunssisf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unsigned_float:SF (match_operand:SI 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_floatunssisf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_floatunssisf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "floatunssidf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (unsigned_float:DF (match_operand:SI 1 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_floatunssidf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_floatunssidf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "fixsfsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (fix:SI (match_operand:SF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_fixsfsi2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_fixsfsi2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "fixdfsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (fix:SI (match_operand:DF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_fixdfsi2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_fixdfsi2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "fixunssfsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unsigned_fix:SI (match_operand:SF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_fixunssfsi2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_fixunssfsi2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "fixunsdfsi2"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unsigned_fix:SI (match_operand:DF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_fixunsdfsi2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_fixunsdfsi2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "extendsfdf2"
++ [(set (match_operand:DF 0 "register_operand" "=r")
++ (float_extend:DF (match_operand:SF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_extendsfdf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_extendsfdf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++(define_insn "truncdfsf2"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (float_truncate:SF (match_operand:DF 1 "general_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_truncdfsf2].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_truncdfsf2].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++
++
++
++
++
++
++;*****************************************************************************
++;*
++;* Prologue, Epilogue and Return
++;*
++;*****************************************************************************
++
++(define_expand "prologue"
++ [(const_int 1)]
++ ""
++{
++ expand_prologue ();
++ DONE;
++})
++
++(define_expand "epilogue"
++ [(return)]
++ ""
++{
++ expand_epilogue (false);
++ DONE;
++})
++
++(define_expand "sibcall_epilogue"
++ [(return)]
++ ""
++{
++ expand_epilogue (true);
++ DONE;
++})
++
++(define_insn "return"
++ [(return)]
++ "reload_completed && nios2_can_use_return_insn ()"
++ "ret\\t"
++)
++
++(define_insn "return_from_epilogue"
++ [(use (match_operand 0 "pmode_register_operand" ""))
++ (return)]
++ "reload_completed"
++ "ret\\t"
++)
++
++;; Block any insns from being moved before this point, since the
++;; profiling call to mcount can use various registers that aren't
++;; saved or used to pass arguments.
++
++(define_insn "blockage"
++ [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
++ ""
++ ""
++ [(set_attr "type" "unknown")
++ (set_attr "length" "0")])
++
++
++
++;*****************************************************************************
++;*
++;* Jumps and Calls
++;*
++;*****************************************************************************
++
++(define_insn "indirect_jump"
++ [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
++ ""
++ "jmp\\t%0"
++ [(set_attr "type" "control")])
++
++(define_insn "jump"
++ [(set (pc)
++ (label_ref (match_operand 0 "" "")))]
++ ""
++ "br\\t%0"
++ [(set_attr "type" "control")])
++
++
++(define_insn "indirect_call"
++ [(call (mem:QI (match_operand:SI 0 "register_operand" "r"))
++ (match_operand 1 "" ""))
++ (clobber (reg:SI RA_REGNO))]
++ ""
++ "callr\\t%0"
++ [(set_attr "type" "control")])
++
++(define_insn "indirect_call_value"
++ [(set (match_operand 0 "" "")
++ (call (mem:QI (match_operand:SI 1 "register_operand" "r"))
++ (match_operand 2 "" "")))
++ (clobber (reg:SI RA_REGNO))]
++ ""
++ "callr\\t%1"
++)
++
++(define_expand "call"
++ [(parallel [(call (match_operand 0 "" "")
++ (match_operand 1 "" ""))
++ (clobber (reg:SI RA_REGNO))])]
++ ""
++ "")
++
++(define_expand "call_value"
++ [(parallel [(set (match_operand 0 "" "")
++ (call (match_operand 1 "" "")
++ (match_operand 2 "" "")))
++ (clobber (reg:SI RA_REGNO))])]
++ ""
++ "")
++
++(define_insn "*call"
++ [(call (mem:QI (match_operand:SI 0 "immediate_operand" "i"))
++ (match_operand 1 "" ""))
++ (clobber (match_operand:SI 2 "register_operand" "=r"))]
++ ""
++ "call\\t%0"
++ [(set_attr "type" "control")])
++
++(define_insn "*call_value"
++ [(set (match_operand 0 "" "")
++ (call (mem:QI (match_operand:SI 1 "immediate_operand" "i"))
++ (match_operand 2 "" "")))
++ (clobber (match_operand:SI 3 "register_operand" "=r"))]
++ ""
++ "call\\t%1"
++ [(set_attr "type" "control")])
++
++(define_expand "sibcall"
++ [(parallel [(call (match_operand 0 "" "")
++ (match_operand 1 "" ""))
++ (return)
++ (use (match_operand 2 "" ""))])]
++ ""
++ {
++ XEXP (operands[0], 0) = copy_to_mode_reg (SImode, XEXP (operands[0], 0));
++
++ if (operands[2] == NULL_RTX)
++ operands[2] = const0_rtx;
++ }
++)
++
++(define_expand "sibcall_value"
++ [(parallel [(set (match_operand 0 "" "")
++ (call (match_operand 1 "" "")
++ (match_operand 2 "" "")))
++ (return)
++ (use (match_operand 3 "" ""))])]
++ ""
++ {
++ XEXP (operands[1], 0) = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
++
++ if (operands[3] == NULL_RTX)
++ operands[3] = const0_rtx;
++ }
++)
++
++(define_insn "sibcall_insn"
++ [(call (mem:QI (match_operand:SI 0 "register_operand" "D08"))
++ (match_operand 1 "" ""))
++ (return)
++ (use (match_operand 2 "" ""))]
++ ""
++ "jmp\\t%0"
++)
++
++(define_insn "sibcall_value_insn"
++ [(set (match_operand 0 "register_operand" "")
++ (call (mem:QI (match_operand:SI 1 "register_operand" "D08"))
++ (match_operand 2 "" "")))
++ (return)
++ (use (match_operand 3 "" ""))]
++ ""
++ "jmp\\t%1"
++)
++
++
++
++
++(define_expand "tablejump"
++ [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
++ (use (label_ref (match_operand 1 "" "")))])]
++ ""
++ ""
++)
++
++(define_insn "*tablejump"
++ [(set (pc)
++ (match_operand:SI 0 "register_operand" "r"))
++ (use (label_ref (match_operand 1 "" "")))]
++ ""
++ "jmp\\t%0"
++ [(set_attr "type" "control")])
++
++
++
++;*****************************************************************************
++;*
++;* Comparisons
++;*
++;*****************************************************************************
++;; Flow here is rather complex (based on MIPS):
++;;
++;; 1) The cmp{si,di,sf,df} routine is called. It deposits the
++;; arguments into the branch_cmp array, and the type into
++;; branch_type. No RTL is generated.
++;;
++;; 2) The appropriate branch define_expand is called, which then
++;; creates the appropriate RTL for the comparison and branch.
++;; Different CC modes are used, based on what type of branch is
++;; done, so that we can constrain things appropriately. There
++;; are assumptions in the rest of GCC that break if we fold the
++;; operands into the branchs for integer operations, and use cc0
++;; for floating point, so we use the fp status register instead.
++;; If needed, an appropriate temporary is created to hold the
++;; of the integer compare.
++
++(define_expand "cmpsi"
++ [(set (cc0)
++ (compare:CC (match_operand:SI 0 "register_operand" "")
++ (match_operand:SI 1 "arith_operand" "")))]
++ ""
++{
++ branch_cmp[0] = operands[0];
++ branch_cmp[1] = operands[1];
++ branch_type = CMP_SI;
++ DONE;
++})
++
++(define_expand "tstsi"
++ [(set (cc0)
++ (match_operand:SI 0 "register_operand" ""))]
++ ""
++{
++ branch_cmp[0] = operands[0];
++ branch_cmp[1] = const0_rtx;
++ branch_type = CMP_SI;
++ DONE;
++})
++
++(define_expand "cmpsf"
++ [(set (cc0)
++ (compare:CC (match_operand:SF 0 "register_operand" "")
++ (match_operand:SF 1 "register_operand" "")))]
++ "(nios2_fpu_insns[nios2_fpu_nios2_sltsf].N >= 0
++ || nios2_fpu_insns[nios2_fpu_nios2_sgtsf].N >= 0)
++ && (nios2_fpu_insns[nios2_fpu_nios2_sgesf].N >= 0
++ || nios2_fpu_insns[nios2_fpu_nios2_slesf].N >= 0)
++ && nios2_fpu_insns[nios2_fpu_nios2_seqsf].N >= 0
++ && nios2_fpu_insns[nios2_fpu_nios2_snesf].N >= 0"
++{
++ branch_cmp[0] = operands[0];
++ branch_cmp[1] = operands[1];
++ branch_type = CMP_SF;
++ DONE;
++})
++
++(define_expand "cmpdf"
++ [(set (cc0)
++ (compare:CC (match_operand:DF 0 "register_operand" "")
++ (match_operand:DF 1 "register_operand" "")))]
++ "(nios2_fpu_insns[nios2_fpu_nios2_sltdf].N >= 0
++ || nios2_fpu_insns[nios2_fpu_nios2_sgtdf].N >= 0)
++ && (nios2_fpu_insns[nios2_fpu_nios2_sgedf].N >= 0
++ || nios2_fpu_insns[nios2_fpu_nios2_sledf].N >= 0)
++ && nios2_fpu_insns[nios2_fpu_nios2_seqdf].N >= 0
++ && nios2_fpu_insns[nios2_fpu_nios2_snedf].N >= 0"
++{
++ branch_cmp[0] = operands[0];
++ branch_cmp[1] = operands[1];
++ branch_type = CMP_DF;
++ DONE;
++})
++
++
++;*****************************************************************************
++;*
++;* setting a register from a comparison
++;*
++;*****************************************************************************
++
++(define_expand "seq"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (eq:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (EQ, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*seq"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (eq:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
++ (match_operand:SI 2 "arith_operand" "rI")))]
++ ""
++ "cmpeq%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_seqsf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (eq:SI (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_seqsf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_seqsf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_seqdf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (eq:SI (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_seqdf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_seqdf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "sne"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ne:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (NE, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sne"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ne:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
++ (match_operand:SI 2 "arith_operand" "rI")))]
++ ""
++ "cmpne%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_snesf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ne:SI (match_operand:SF 1 "register_operand" "%r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_snesf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_snesf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_snedf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ne:SI (match_operand:DF 1 "register_operand" "%r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_snedf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_snedf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "sgt"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gt:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (GT, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sgt"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gt:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
++ ""
++ "cmplt\\t%0, %z2, %z1"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_sgtsf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gt:SI (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sgtsf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sgtsf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_sgtdf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gt:SI (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sgtdf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sgtdf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "sge"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ge:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (GE, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sge"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ge:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "arith_operand" "rI")))]
++ ""
++ "cmpge%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_sgesf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ge:SI (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sgesf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sgesf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_sgedf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ge:SI (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sgedf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sgedf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "sle"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (le:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (LE, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sle"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (le:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
++ ""
++ "cmpge\\t%0, %z2, %z1"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_slesf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (le:SI (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_slesf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_slesf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_sledf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (le:SI (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sledf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sledf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "slt"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (lt:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI && branch_type != CMP_SF && branch_type != CMP_DF)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (LT, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*slt"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (lt:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "arith_operand" "rI")))]
++ ""
++ "cmplt%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++
++(define_insn "nios2_sltsf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (lt:SI (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sltsf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sltsf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_sltdf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (lt:SI (match_operand:DF 1 "register_operand" "r")
++ (match_operand:DF 2 "register_operand" "r")))]
++ "nios2_fpu_insns[nios2_fpu_nios2_sltdf].N >= 0"
++ {
++ return (*nios2_fpu_insns[nios2_fpu_nios2_sltdf].output) (insn);
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "sgtu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gtu:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (GTU, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sgtu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (gtu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
++ ""
++ "cmpltu\\t%0, %z2, %z1"
++ [(set_attr "type" "alu")])
++
++
++(define_expand "sgeu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (geu:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (GEU, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sgeu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (geu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "uns_arith_operand" "rJ")))]
++ ""
++ "cmpgeu%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++(define_expand "sleu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (leu:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (LEU, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sleu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (leu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
++ ""
++ "cmpgeu\\t%0, %z2, %z1"
++ [(set_attr "type" "alu")])
++
++
++(define_expand "sltu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ltu:SI (match_dup 1)
++ (match_dup 2)))]
++ ""
++{
++ if (branch_type != CMP_SI)
++ FAIL;
++
++ /* set up operands from compare. */
++ operands[1] = branch_cmp[0];
++ operands[2] = branch_cmp[1];
++
++ gen_int_relational (LTU, operands[0], operands[1], operands[2], NULL_RTX);
++ DONE;
++})
++
++
++(define_insn "*sltu"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (ltu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
++ (match_operand:SI 2 "uns_arith_operand" "rJ")))]
++ ""
++ "cmpltu%i2\\t%0, %z1, %z2"
++ [(set_attr "type" "alu")])
++
++
++
++
++;*****************************************************************************
++;*
++;* branches
++;*
++;*****************************************************************************
++
++(define_insn "*cbranch"
++ [(set (pc)
++ (if_then_else
++ (match_operator:SI 0 "comparison_operator"
++ [(match_operand:SI 2 "reg_or_0_operand" "rM")
++ (match_operand:SI 3 "reg_or_0_operand" "rM")])
++ (label_ref (match_operand 1 "" ""))
++ (pc)))]
++ ""
++ "b%0\\t%z2, %z3, %l1"
++ [(set_attr "type" "control")])
++
++
++(define_insn "nios2_cbranch_sf"
++ [(set (pc)
++ (if_then_else
++ (match_operator:SI 0 "comparison_operator"
++ [(match_operand:SF 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")])
++ (label_ref (match_operand 1 "" ""))
++ (pc)))]
++ ""
++ {
++ return nios2_output_fpu_insn_cmps (insn, GET_CODE (operands[0]));
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_insn "nios2_cbranch_df"
++ [(set (pc)
++ (if_then_else
++ (match_operator:SI 0 "comparison_operator"
++ [(match_operand:DF 2 "register_operand" "r")
++ (match_operand:DF 3 "register_operand" "r")])
++ (label_ref (match_operand 1 "" ""))
++ (pc)))]
++ ""
++ {
++ return nios2_output_fpu_insn_cmpd (insn, GET_CODE (operands[0]));
++ }
++ [(set_attr "type" "custom")])
++
++
++(define_expand "beq"
++ [(set (pc)
++ (if_then_else (eq:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (EQ, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++
++(define_expand "bne"
++ [(set (pc)
++ (if_then_else (ne:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (NE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++
++(define_expand "bgt"
++ [(set (pc)
++ (if_then_else (gt:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (GT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "bge"
++ [(set (pc)
++ (if_then_else (ge:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (GE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "ble"
++ [(set (pc)
++ (if_then_else (le:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (LE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "blt"
++ [(set (pc)
++ (if_then_else (lt:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (LT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++
++(define_expand "bgtu"
++ [(set (pc)
++ (if_then_else (gtu:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (GTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "bgeu"
++ [(set (pc)
++ (if_then_else (geu:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (GEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "bleu"
++ [(set (pc)
++ (if_then_else (leu:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (LEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++(define_expand "bltu"
++ [(set (pc)
++ (if_then_else (ltu:CC (cc0)
++ (const_int 0))
++ (label_ref (match_operand 0 "" ""))
++ (pc)))]
++ ""
++{
++ gen_int_relational (LTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
++ DONE;
++})
++
++
++;*****************************************************************************
++;*
++;* String and Block Operations
++;*
++;*****************************************************************************
++
++; ??? This is all really a hack to get Dhrystone to work as fast as possible
++; things to be fixed:
++; * let the compiler core handle all of this, for that to work the extra
++; aliasing needs to be addressed.
++; * we use three temporary registers for loading and storing to ensure no
++; ld use stalls, this is excessive, because after the first ld/st only
++; two are needed. Only two would be needed all the way through if
++; we could schedule with other code. Consider:
++; 1 ld $1, 0($src)
++; 2 ld $2, 4($src)
++; 3 ld $3, 8($src)
++; 4 st $1, 0($dest)
++; 5 ld $1, 12($src)
++; 6 st $2, 4($src)
++; 7 etc.
++; The first store has to wait until 4. If it does not there will be one
++; cycle of stalling. However, if any other instruction could be placed
++; between 1 and 4, $3 would not be needed.
++; * In small we probably don't want to ever do this ourself because there
++; is no ld use stall.
++
++(define_expand "movstrsi"
++ [(parallel [(set (match_operand:BLK 0 "general_operand" "")
++ (match_operand:BLK 1 "general_operand" ""))
++ (use (match_operand:SI 2 "const_int_operand" ""))
++ (use (match_operand:SI 3 "const_int_operand" ""))
++ (clobber (match_scratch:SI 4 "=&r"))
++ (clobber (match_scratch:SI 5 "=&r"))
++ (clobber (match_scratch:SI 6 "=&r"))])]
++ "TARGET_INLINE_MEMCPY"
++{
++ rtx ld_addr_reg, st_addr_reg;
++
++ /* If the predicate for op2 fails in expr.c:emit_block_move_via_movstr
++ it trys to copy to a register, but does not re-try the predicate.
++ ??? Intead of fixing expr.c, I fix it here. */
++ if (!const_int_operand (operands[2], SImode))
++ FAIL;
++
++ /* ??? there are some magic numbers which need to be sorted out here.
++ the basis for them is not increasing code size hugely or going
++ out of range of offset addressing */
++ if (INTVAL (operands[3]) < 4)
++ FAIL;
++ if (!optimize
++ || (optimize_size && INTVAL (operands[2]) > 12)
++ || (optimize < 3 && INTVAL (operands[2]) > 100)
++ || INTVAL (operands[2]) > 200)
++ FAIL;
++
++ st_addr_reg
++ = replace_equiv_address (operands[0],
++ copy_to_mode_reg (Pmode, XEXP (operands[0], 0)));
++ ld_addr_reg
++ = replace_equiv_address (operands[1],
++ copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
++ emit_insn (gen_movstrsi_internal (st_addr_reg, ld_addr_reg,
++ operands[2], operands[3]));
++
++ DONE;
++})
++
++
++(define_insn "movstrsi_internal"
++ [(set (match_operand:BLK 0 "memory_operand" "=o")
++ (match_operand:BLK 1 "memory_operand" "o"))
++ (use (match_operand:SI 2 "const_int_operand" "i"))
++ (use (match_operand:SI 3 "const_int_operand" "i"))
++ (clobber (match_scratch:SI 4 "=&r"))
++ (clobber (match_scratch:SI 5 "=&r"))
++ (clobber (match_scratch:SI 6 "=&r"))]
++ "TARGET_INLINE_MEMCPY"
++{
++ int ld_offset = INTVAL (operands[2]);
++ int ld_len = INTVAL (operands[2]);
++ int ld_reg = 0;
++ rtx ld_addr_reg = XEXP (operands[1], 0);
++ int st_offset = INTVAL (operands[2]);
++ int st_len = INTVAL (operands[2]);
++ int st_reg = 0;
++ rtx st_addr_reg = XEXP (operands[0], 0);
++ int delay_count = 0;
++
++ /* ops[0] is the address used by the insn
++ ops[1] is the register being loaded or stored */
++ rtx ops[2];
++
++ if (INTVAL (operands[3]) < 4)
++ abort ();
++
++ while (ld_offset >= 4)
++ {
++ /* if the load use delay has been met, I can start
++ storing */
++ if (delay_count >= 3)
++ {
++ ops[0] = gen_rtx (MEM, SImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("stw\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 4;
++ }
++
++ ops[0] = gen_rtx (MEM, SImode,
++ plus_constant (ld_addr_reg, ld_len - ld_offset));
++ ops[1] = operands[ld_reg + 4];
++ output_asm_insn ("ldw\t%1, %0", ops);
++
++ ld_reg = (ld_reg + 1) % 3;
++ ld_offset -= 4;
++ delay_count++;
++ }
++
++ if (ld_offset >= 2)
++ {
++ /* if the load use delay has been met, I can start
++ storing */
++ if (delay_count >= 3)
++ {
++ ops[0] = gen_rtx (MEM, SImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("stw\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 4;
++ }
++
++ ops[0] = gen_rtx (MEM, HImode,
++ plus_constant (ld_addr_reg, ld_len - ld_offset));
++ ops[1] = operands[ld_reg + 4];
++ output_asm_insn ("ldh\t%1, %0", ops);
++
++ ld_reg = (ld_reg + 1) % 3;
++ ld_offset -= 2;
++ delay_count++;
++ }
++
++ if (ld_offset >= 1)
++ {
++ /* if the load use delay has been met, I can start
++ storing */
++ if (delay_count >= 3)
++ {
++ ops[0] = gen_rtx (MEM, SImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("stw\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 4;
++ }
++
++ ops[0] = gen_rtx (MEM, QImode,
++ plus_constant (ld_addr_reg, ld_len - ld_offset));
++ ops[1] = operands[ld_reg + 4];
++ output_asm_insn ("ldb\t%1, %0", ops);
++
++ ld_reg = (ld_reg + 1) % 3;
++ ld_offset -= 1;
++ delay_count++;
++ }
++
++ while (st_offset >= 4)
++ {
++ ops[0] = gen_rtx (MEM, SImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("stw\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 4;
++ }
++
++ while (st_offset >= 2)
++ {
++ ops[0] = gen_rtx (MEM, HImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("sth\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 2;
++ }
++
++ while (st_offset >= 1)
++ {
++ ops[0] = gen_rtx (MEM, QImode,
++ plus_constant (st_addr_reg, st_len - st_offset));
++ ops[1] = operands[st_reg + 4];
++ output_asm_insn ("stb\t%1, %0", ops);
++
++ st_reg = (st_reg + 1) % 3;
++ st_offset -= 1;
++ }
++
++ return "";
++}
++; ??? lengths are not being used yet, but I will probably forget
++; to update this once I am using lengths, so set it to something
++; definetely big enough to cover it. 400 allows for 200 bytes
++; of motion.
++ [(set_attr "length" "400")])
++
++
++
++;*****************************************************************************
++;*
++;* Custom instructions
++;*
++;*****************************************************************************
++
++(define_constants [
++ (CUSTOM_N 100)
++ (CUSTOM_NI 101)
++ (CUSTOM_NF 102)
++ (CUSTOM_NP 103)
++ (CUSTOM_NII 104)
++ (CUSTOM_NIF 105)
++ (CUSTOM_NIP 106)
++ (CUSTOM_NFI 107)
++ (CUSTOM_NFF 108)
++ (CUSTOM_NFP 109)
++ (CUSTOM_NPI 110)
++ (CUSTOM_NPF 111)
++ (CUSTOM_NPP 112)
++ (CUSTOM_IN 113)
++ (CUSTOM_INI 114)
++ (CUSTOM_INF 115)
++ (CUSTOM_INP 116)
++ (CUSTOM_INII 117)
++ (CUSTOM_INIF 118)
++ (CUSTOM_INIP 119)
++ (CUSTOM_INFI 120)
++ (CUSTOM_INFF 121)
++ (CUSTOM_INFP 122)
++ (CUSTOM_INPI 123)
++ (CUSTOM_INPF 124)
++ (CUSTOM_INPP 125)
++ (CUSTOM_FN 126)
++ (CUSTOM_FNI 127)
++ (CUSTOM_FNF 128)
++ (CUSTOM_FNP 129)
++ (CUSTOM_FNII 130)
++ (CUSTOM_FNIF 131)
++ (CUSTOM_FNIP 132)
++ (CUSTOM_FNFI 133)
++ (CUSTOM_FNFF 134)
++ (CUSTOM_FNFP 135)
++ (CUSTOM_FNPI 136)
++ (CUSTOM_FNPF 137)
++ (CUSTOM_FNPP 138)
++ (CUSTOM_PN 139)
++ (CUSTOM_PNI 140)
++ (CUSTOM_PNF 141)
++ (CUSTOM_PNP 142)
++ (CUSTOM_PNII 143)
++ (CUSTOM_PNIF 144)
++ (CUSTOM_PNIP 145)
++ (CUSTOM_PNFI 146)
++ (CUSTOM_PNFF 147)
++ (CUSTOM_PNFP 148)
++ (CUSTOM_PNPI 149)
++ (CUSTOM_PNPF 150)
++ (CUSTOM_PNPP 151)
++])
++
++
++(define_insn "custom_n"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")] CUSTOM_N)]
++ ""
++ "custom\\t%0, zero, zero, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_ni"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")] CUSTOM_NI)]
++ ""
++ "custom\\t%0, zero, %1, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nf"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SF 1 "register_operand" "r")] CUSTOM_NF)]
++ ""
++ "custom\\t%0, zero, %1, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_np"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")] CUSTOM_NP)]
++ ""
++ "custom\\t%0, zero, %1, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nii"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NII)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nif"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NIF)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nip"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NIP)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nfi"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NFI)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nff"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NFF)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_nfp"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SF 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NFP)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_npi"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NPI)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_npf"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NPF)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_npp"
++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
++ (match_operand:SI 1 "register_operand" "r")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NPP)]
++ ""
++ "custom\\t%0, zero, %1, %2"
++ [(set_attr "type" "custom")])
++
++
++
++(define_insn "custom_in"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_IN))]
++ ""
++ "custom\\t%1, %0, zero, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_ini"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_INI))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_INF))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_INP))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inii"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INII))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inif"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INIF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inip"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INIP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_infi"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INFI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inff"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INFF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_infp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INFP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inpi"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INPI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inpf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INPF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_inpp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INPP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++
++
++
++
++(define_insn "custom_fn"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_FN))]
++ ""
++ "custom\\t%1, %0, zero, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fni"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_FNI))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnf"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_FNF))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnp"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_FNP))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnii"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNII))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnif"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNIF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnip"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNIP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnfi"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNFI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnff"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNFF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnfp"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNFP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnpi"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNPI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnpf"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNPF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_fnpp"
++ [(set (match_operand:SF 0 "register_operand" "=r")
++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNPP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++
++
++(define_insn "custom_pn"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_PN))]
++ ""
++ "custom\\t%1, %0, zero, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pni"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_PNI))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_PNF))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_PNP))]
++ ""
++ "custom\\t%1, %0, %2, zero"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnii"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNII))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnif"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNIF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnip"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNIP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnfi"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNFI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnff"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNFF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnfp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SF 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNFP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnpi"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNPI))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnpf"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNPF))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++(define_insn "custom_pnpp"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNPP))]
++ ""
++ "custom\\t%1, %0, %2, %3"
++ [(set_attr "type" "custom")])
++
++
++
++
++
++
++;*****************************************************************************
++;*
++;* Misc
++;*
++;*****************************************************************************
++
++(define_insn "nop"
++ [(const_int 0)]
++ ""
++ "nop\\t"
++ [(set_attr "type" "alu")])
++
++(define_insn "sync"
++ [(unspec_volatile [(const_int 0)] UNSPEC_SYNC)]
++ ""
++ "sync\\t"
++ [(set_attr "type" "control")])
++
++
++(define_insn "rdctl"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI [(match_operand:SI 1 "rdwrctl_operand" "O")] UNSPEC_RDCTL))]
++ ""
++ "rdctl\\t%0, ctl%1"
++ [(set_attr "type" "control")])
++
++(define_insn "wrctl"
++ [(unspec_volatile:SI [(match_operand:SI 0 "rdwrctl_operand" "O")
++ (match_operand:SI 1 "reg_or_0_operand" "rM")] UNSPEC_WRCTL)]
++ ""
++ "wrctl\\tctl%0, %z1"
++ [(set_attr "type" "control")])
++
++;Used to signal a stack overflow
++(define_insn "trap"
++ [(unspec_volatile [(const_int 0)] UNSPEC_TRAP)]
++ ""
++ "break\\t3"
++ [(set_attr "type" "control")])
++
++(define_insn "stack_overflow_detect_and_trap"
++ [(unspec_volatile [(const_int 0)] UNSPEC_STACK_OVERFLOW_DETECT_AND_TRAP)]
++ ""
++ "bgeu\\tsp, et, 1f\;break\\t3\;1:"
++ [(set_attr "type" "control")])
++
++
++;*****************************************************************************
++;*
++;* Peepholes
++;*
++;*****************************************************************************
++
++
++;; Local Variables:
++;; mode: lisp
++;; End:
+diff --git a/gcc/config/nios2/t-nios2 b/gcc/config/nios2/t-nios2
+new file mode 100644
+index 0000000..b92f80a
+--- /dev/null
++++ b/gcc/config/nios2/t-nios2
+@@ -0,0 +1,175 @@
++##
++## Compiler flags to use when compiling libgcc2.c.
++##
++## LIB2FUNCS_EXTRA
++## A list of source file names to be compiled or assembled and inserted into libgcc.a.
++
++LIB2FUNCS_EXTRA=$(srcdir)/config/nios2/lib2-divmod.c \
++ $(srcdir)/config/nios2/lib2-divmod-hi.c \
++ $(srcdir)/config/nios2/lib2-divtable.c \
++ $(srcdir)/config/nios2/lib2-mul.c
++
++##
++## Floating Point Emulation
++## To have GCC include software floating point libraries in libgcc.a define FPBIT
++## and DPBIT along with a few rules as follows:
++##
++## # We want fine grained libraries, so use the new code
++## # to build the floating point emulation libraries.
++FPBIT=$(srcdir)/config/nios2/nios2-fp-bit.c
++DPBIT=$(srcdir)/config/nios2/nios2-dp-bit.c
++
++TARGET_LIBGCC2_CFLAGS = -O2
++
++# FLOAT_ONLY - no doubles
++# SMALL_MACHINE - QI/HI is faster than SI
++# Actually SMALL_MACHINE uses chars and shorts instead of ints
++# since ints (16-bit ones as they are today) are at least as fast
++# as chars and shorts, don't define SMALL_MACHINE
++# CMPtype - type returned by FP compare, i.e. INT (hard coded in fp-bit - see code )
++
++$(FPBIT): $(srcdir)/config/fp-bit.c Makefile
++ echo '#define FLOAT' > ${FPBIT}
++ echo '#ifndef __nios2_big_endian__' >> ${FPBIT}
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> ${FPBIT}
++ echo '#endif' >> ${FPBIT}
++ cat $(srcdir)/config/fp-bit.c >> ${FPBIT}
++
++$(DPBIT): $(srcdir)/config/fp-bit.c Makefile
++ echo '' > ${DPBIT}
++ echo '#ifndef __nios2_big_endian__' >> ${DPBIT}
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> ${DPBIT}
++ echo '#endif' >> ${DPBIT}
++ cat $(srcdir)/config/fp-bit.c >> ${DPBIT}
++
++EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o
++
++# Assemble startup files.
++$(T)crti.o: $(srcdir)/config/nios2/crti.asm $(GCC_PASSES)
++ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
++ -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/nios2/crti.asm
++
++$(T)crtn.o: $(srcdir)/config/nios2/crtn.asm $(GCC_PASSES)
++ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
++ -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/nios2/crtn.asm
++
++
++## You may need to provide additional #defines at the beginning of
++## fp-bit.c and dp-bit.c to control target endianness and other options
++##
++## CRTSTUFF_T_CFLAGS
++## Special flags used when compiling crtstuff.c. See Initialization.
++##
++## CRTSTUFF_T_CFLAGS_S
++## Special flags used when compiling crtstuff.c for shared linking. Used
++## if you use crtbeginS.o and crtendS.o in EXTRA-PARTS. See Initialization.
++##
++## MULTILIB_OPTIONS
++## For some targets, invoking GCC in different ways produces objects that
++## can not be linked together. For example, for some targets GCC produces
++## both big and little endian code. For these targets, you must arrange
++## for multiple versions of libgcc.a to be compiled, one for each set of
++## incompatible options. When GCC invokes the linker, it arranges to link
++## in the right version of libgcc.a, based on the command line options
++## used.
++## The MULTILIB_OPTIONS macro lists the set of options for which special
++## versions of libgcc.a must be built. Write options that are mutually
++## incompatible side by side, separated by a slash. Write options that may
++## be used together separated by a space. The build procedure will build
++## all combinations of compatible options.
++##
++## For example, if you set MULTILIB_OPTIONS to m68000/m68020 msoft-float,
++## Makefile will build special versions of libgcc.a using the following
++## sets of options: -m68000, -m68020, -msoft-float, -m68000 -msoft-float,
++## and -m68020 -msoft-float.
++
++
++## The BUILD_BE_MULTILIB and BUILD_PG_MULTILIB variables allow the
++## makefile user to enable/disable the generation of the precompiled
++## big endian and profiling libraries. By default, the big endian
++## libraries are not created on a windows build and the profiling
++## libraries are not created on a Solaris build. All other library
++## combinations are created by default.
++
++# Uncomment to temporarily avoid building big endian and profiling libraries during a Windows build.
++#ifeq ($(DEV_HOST_OS), win32)
++#BUILD_BE_MULTILIB ?= 0
++#BUILD_PG_MULTILIB ?= 0
++#endif
++
++#By default, avoid building the profiling libraries during a Solaris build.
++ifeq ($(DEV_HOST_OS), solaris)
++BUILD_PG_MULTILIB ?= 0
++endif
++
++BUILD_BE_MULTILIB ?= 1
++BUILD_PG_MULTILIB ?= 1
++BUILD_MULTILIB ?= 1
++
++ifeq ($(BUILD_MULTILIB), 1)
++
++MULTILIB_OPTIONS = mno-hw-mul mhw-mulx mstack-check mcustom-fpu-cfg=60-1 mcustom-fpu-cfg=60-2
++
++#Add the profiling flag to the multilib variable if required
++ifeq ($(BUILD_PG_MULTILIB), 1)
++MULTILIB_OPTIONS += pg
++endif
++
++#Add the big endian flag to the multilib variable if required
++ifeq ($(BUILD_BE_MULTILIB), 1)
++MULTILIB_OPTIONS += EB/EL
++endif
++
++endif
++
++## MULTILIB_DIRNAMES
++## If MULTILIB_OPTIONS is used, this variable specifies the directory names
++## that should be used to hold the various libraries. Write one element in
++## MULTILIB_DIRNAMES for each element in MULTILIB_OPTIONS. If
++## MULTILIB_DIRNAMES is not used, the default value will be
++## MULTILIB_OPTIONS, with all slashes treated as spaces.
++## For example, if MULTILIB_OPTIONS is set to m68000/m68020 msoft-float,
++## then the default value of MULTILIB_DIRNAMES is m68000 m68020
++## msoft-float. You may specify a different value if you desire a
++## different set of directory names.
++
++# MULTILIB_DIRNAMES =
++
++## MULTILIB_MATCHES
++## Sometimes the same option may be written in two different ways. If an
++## option is listed in MULTILIB_OPTIONS, GCC needs to know about any
++## synonyms. In that case, set MULTILIB_MATCHES to a list of items of the
++## form option=option to describe all relevant synonyms. For example,
++## m68000=mc68000 m68020=mc68020.
++
++ifeq ($(BUILD_MULTILIB), 1)
++ifeq ($(BUILD_BE_MULTILIB), 1)
++MULTILIB_MATCHES = EL=mel EB=meb
++endif
++endif
++
++##
++## MULTILIB_EXCEPTIONS
++## Sometimes when there are multiple sets of MULTILIB_OPTIONS being
++## specified, there are combinations that should not be built. In that
++## case, set MULTILIB_EXCEPTIONS to be all of the switch exceptions in
++## shell case syntax that should not be built.
++## For example, in the PowerPC embedded ABI support, it is not desirable to
++## build libraries compiled with the -mcall-aix option and either of the
++## -fleading-underscore or -mlittle options at the same time. Therefore
++## MULTILIB_EXCEPTIONS is set to
++##
++## *mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*
++##
++
++ifeq ($(BUILD_MULTILIB), 1)
++MULTILIB_EXCEPTIONS = *mno-hw-mul/*mhw-mulx* *mcustom-fpu-cfg=60-1/*mcustom-fpu-cfg=60-2*
++endif
++
++##
++## MULTILIB_EXTRA_OPTS Sometimes it is desirable that when building
++## multiple versions of libgcc.a certain options should always be passed on
++## to the compiler. In that case, set MULTILIB_EXTRA_OPTS to be the list
++## of options to be used for all builds.
++##
++
+diff --git a/gcc/config/nios2/t-nios2-uclibc b/gcc/config/nios2/t-nios2-uclibc
+new file mode 100644
+index 0000000..9a303db
+--- /dev/null
++++ b/gcc/config/nios2/t-nios2-uclibc
+@@ -0,0 +1,152 @@
++##
++## Compiler flags to use when compiling libgcc2.c.
++##
++## LIB2FUNCS_EXTRA
++## A list of source file names to be compiled or assembled and inserted into libgcc.a.
++
++LIB2FUNCS_EXTRA=$(srcdir)/config/nios2/lib2-divmod.c \
++ $(srcdir)/config/nios2/lib2-divmod-hi.c \
++ $(srcdir)/config/nios2/lib2-divtable.c \
++ $(srcdir)/config/nios2/lib2-mul.c
++
++##
++## Floating Point Emulation
++## To have GCC include software floating point libraries in libgcc.a define FPBIT
++## and DPBIT along with a few rules as follows:
++##
++## # We want fine grained libraries, so use the new code
++## # to build the floating point emulation libraries.
++FPBIT=$(srcdir)/config/nios2/nios2-fp-bit.c
++DPBIT=$(srcdir)/config/nios2/nios2-dp-bit.c
++
++TARGET_LIBGCC2_CFLAGS = -O2
++
++# FLOAT_ONLY - no doubles
++# SMALL_MACHINE - QI/HI is faster than SI
++# Actually SMALL_MACHINE uses chars and shorts instead of ints
++# since ints (16-bit ones as they are today) are at least as fast
++# as chars and shorts, don't define SMALL_MACHINE
++# CMPtype - type returned by FP compare, i.e. INT (hard coded in fp-bit - see code )
++
++$(FPBIT): $(srcdir)/config/fp-bit.c Makefile
++ echo '#define FLOAT' > ${FPBIT}
++ echo '#ifndef __nios2_big_endian__' >> ${FPBIT}
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> ${FPBIT}
++ echo '#endif' >> ${FPBIT}
++ cat $(srcdir)/config/fp-bit.c >> ${FPBIT}
++
++$(DPBIT): $(srcdir)/config/fp-bit.c Makefile
++ echo '' > ${DPBIT}
++ echo '#ifndef __nios2_big_endian__' >> ${DPBIT}
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> ${DPBIT}
++ echo '#endif' >> ${DPBIT}
++ cat $(srcdir)/config/fp-bit.c >> ${DPBIT}
++
++EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
++
++## You may need to provide additional #defines at the beginning of
++## fp-bit.c and dp-bit.c to control target endianness and other options
++##
++## CRTSTUFF_T_CFLAGS
++## Special flags used when compiling crtstuff.c. See Initialization.
++##
++## CRTSTUFF_T_CFLAGS_S
++## Special flags used when compiling crtstuff.c for shared linking. Used
++## if you use crtbeginS.o and crtendS.o in EXTRA-PARTS. See Initialization.
++##
++## MULTILIB_OPTIONS
++## For some targets, invoking GCC in different ways produces objects that
++## can not be linked together. For example, for some targets GCC produces
++## both big and little endian code. For these targets, you must arrange
++## for multiple versions of libgcc.a to be compiled, one for each set of
++## incompatible options. When GCC invokes the linker, it arranges to link
++## in the right version of libgcc.a, based on the command line options
++## used.
++## The MULTILIB_OPTIONS macro lists the set of options for which special
++## versions of libgcc.a must be built. Write options that are mutually
++## incompatible side by side, separated by a slash. Write options that may
++## be used together separated by a space. The build procedure will build
++## all combinations of compatible options.
++##
++## For example, if you set MULTILIB_OPTIONS to m68000/m68020 msoft-float,
++## Makefile will build special versions of libgcc.a using the following
++## sets of options: -m68000, -m68020, -msoft-float, -m68000 -msoft-float,
++## and -m68020 -msoft-float.
++
++
++## The BUILD_BE_MULTILIB and BUILD_PG_MULTILIB variables allow the
++## makefile user to enable/disable the generation of the precompiled
++## big endian and profiling libraries.
++
++# By default, avoid building big endian and profiling libraries
++BUILD_BE_MULTILIB ?= 0
++BUILD_PG_MULTILIB ?= 0
++BUILD_MULTILIB ?= 1
++
++ifeq ($(BUILD_MULTILIB), 1)
++
++MULTILIB_OPTIONS = mno-hw-mul mhw-mulx mstack-check mcustom-fpu-cfg=60-1 mcustom-fpu-cfg=60-2
++
++#Add the profiling flag to the multilib variable if required
++ifeq ($(BUILD_PG_MULTILIB), 1)
++MULTILIB_OPTIONS += pg
++endif
++
++#Add the big endian flag to the multilib variable if required
++ifeq ($(BUILD_BE_MULTILIB), 1)
++MULTILIB_OPTIONS += EB/EL
++endif
++
++endif
++
++## MULTILIB_DIRNAMES
++## If MULTILIB_OPTIONS is used, this variable specifies the directory names
++## that should be used to hold the various libraries. Write one element in
++## MULTILIB_DIRNAMES for each element in MULTILIB_OPTIONS. If
++## MULTILIB_DIRNAMES is not used, the default value will be
++## MULTILIB_OPTIONS, with all slashes treated as spaces.
++## For example, if MULTILIB_OPTIONS is set to m68000/m68020 msoft-float,
++## then the default value of MULTILIB_DIRNAMES is m68000 m68020
++## msoft-float. You may specify a different value if you desire a
++## different set of directory names.
++
++# MULTILIB_DIRNAMES =
++
++## MULTILIB_MATCHES
++## Sometimes the same option may be written in two different ways. If an
++## option is listed in MULTILIB_OPTIONS, GCC needs to know about any
++## synonyms. In that case, set MULTILIB_MATCHES to a list of items of the
++## form option=option to describe all relevant synonyms. For example,
++## m68000=mc68000 m68020=mc68020.
++
++ifeq ($(BUILD_MULTILIB), 1)
++ifeq ($(BUILD_BE_MULTILIB), 1)
++MULTILIB_MATCHES = EL=mel EB=meb
++endif
++endif
++
++##
++## MULTILIB_EXCEPTIONS
++## Sometimes when there are multiple sets of MULTILIB_OPTIONS being
++## specified, there are combinations that should not be built. In that
++## case, set MULTILIB_EXCEPTIONS to be all of the switch exceptions in
++## shell case syntax that should not be built.
++## For example, in the PowerPC embedded ABI support, it is not desirable to
++## build libraries compiled with the -mcall-aix option and either of the
++## -fleading-underscore or -mlittle options at the same time. Therefore
++## MULTILIB_EXCEPTIONS is set to
++##
++## *mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*
++##
++
++ifeq ($(BUILD_MULTILIB), 1)
++MULTILIB_EXCEPTIONS = *mno-hw-mul/*mhw-mulx* *mcustom-fpu-cfg=60-1/*mcustom-fpu-cfg=60-2*
++endif
++
++##
++## MULTILIB_EXTRA_OPTS Sometimes it is desirable that when building
++## multiple versions of libgcc.a certain options should always be passed on
++## to the compiler. In that case, set MULTILIB_EXTRA_OPTS to be the list
++## of options to be used for all builds.
++##
++
+diff --git a/gcc/cse.c b/gcc/cse.c
+index 72af39a..b36310c 100644
+--- a/gcc/cse.c
++++ b/gcc/cse.c
+@@ -3134,6 +3134,10 @@ find_comparison_args (enum rtx_code code, rtx *parg1, rtx *parg2,
+ #ifdef FLOAT_STORE_FLAG_VALUE
+ REAL_VALUE_TYPE fsfv;
+ #endif
++#ifdef __nios2__
++ if (p->is_const)
++ break;
++#endif
+
+ /* If the entry isn't valid, skip it. */
+ if (! exp_equiv_p (p->exp, p->exp, 1, 0))
+diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
+index 4638645..cdb248d 100644
+--- a/gcc/doc/extend.texi
++++ b/gcc/doc/extend.texi
+@@ -2488,6 +2488,33 @@ contents of that register. The @code{short_call} attribute always places
+ the offset to the function from the call site into the @samp{BL}
+ instruction directly.
+
++@item reverse_bitfields/no_reverse_bitfields
++@cindex reverse_bitfields on Altera Nios II
++This attribute specifies the order of bitfield allocation within a
++particular struct on Altera's Nios II processor. This overrides both
++the @option{-mno-reverse-bitfields} and @option{-mreverse-bitfields}
++switches, as well as any @code{#pragma} that might be present. It is
++ignored except when present on a struct.
++
++@smallexample
++struct inner
++@{
++ unsigned int a:1;
++ unsigned int b:31;
++@} __attribute__ ((reverse_bitfields));
++
++union outer
++@{
++ struct inner inner;
++ unsigned int val;
++@};
++
++@end smallexample
++
++will cause a to be allocated overlapping the most significant bit of
++val, regardless of any @code{#pragma} or compiler switch. See the
++@option{-mreverse-bitfields} switch for more examples.
++
+ @item function_vector
+ @cindex calling functions through the function vector on the H8/300 processors
+ Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
+@@ -5638,12 +5665,118 @@ to those machines. Generally these generate calls to specific machine
+ instructions, but allow the compiler to schedule those calls.
+
+ @menu
++* Altera Nios II Built-in Functions::
+ * Alpha Built-in Functions::
+ * ARM Built-in Functions::
+ * X86 Built-in Functions::
+ * PowerPC AltiVec Built-in Functions::
+ @end menu
+
++@node Altera Nios II Built-in Functions
++@subsection Altera Nios II Built-in Functions
++
++These built-in functions are available for the Altera Nios II
++family of processors.
++
++The following built-in functions are always available. They
++all generate the machine instruction that is part of the name.
++
++@example
++int __builtin_ldbio (volatile const void *)
++int __builtin_ldbuio (volatile const void *)
++int __builtin_ldhio (volatile const void *)
++int __builtin_ldhuio (volatile const void *)
++int __builtin_ldwio (volatile const void *)
++void __builtin_stbio (volatile void *, int)
++void __builtin_sthio (volatile void *, int)
++void __builtin_stwio (volatile void *, int)
++void __builtin_sync (void)
++int __builtin_rdctl (int)
++void __builtin_wrctl (int, int)
++@end example
++
++The following built-in functions are always available. They
++all generate a Nios II Custom Instruction. The name of the
++function represents the types that the function takes and
++returns. The letter before the @code{n} is the return type
++or void if absent. The @code{n} represnts the first parameter
++to all the custom instructions, the custom instruction number.
++The two letters after the @code{n} represent the up to two
++parameters to the function.
++
++The letters reprsent the following data types:
++@table @code
++@item <no letter>
++@code{void} for return type and no parameter for parameter types.
++
++@item i
++@code{int} for return type and parameter type
++
++@item f
++@code{float} for return type and parameter type
++
++@item p
++@code{void *} for return type and parameter type
++
++@end table
++
++And the function names are:
++@example
++void __builtin_custom_n (void)
++void __builtin_custom_ni (int)
++void __builtin_custom_nf (float)
++void __builtin_custom_np (void *)
++void __builtin_custom_nii (int, int)
++void __builtin_custom_nif (int, float)
++void __builtin_custom_nip (int, void *)
++void __builtin_custom_nfi (float, int)
++void __builtin_custom_nff (float, float)
++void __builtin_custom_nfp (float, void *)
++void __builtin_custom_npi (void *, int)
++void __builtin_custom_npf (void *, float)
++void __builtin_custom_npp (void *, void *)
++int __builtin_custom_in (void)
++int __builtin_custom_ini (int)
++int __builtin_custom_inf (float)
++int __builtin_custom_inp (void *)
++int __builtin_custom_inii (int, int)
++int __builtin_custom_inif (int, float)
++int __builtin_custom_inip (int, void *)
++int __builtin_custom_infi (float, int)
++int __builtin_custom_inff (float, float)
++int __builtin_custom_infp (float, void *)
++int __builtin_custom_inpi (void *, int)
++int __builtin_custom_inpf (void *, float)
++int __builtin_custom_inpp (void *, void *)
++float __builtin_custom_fn (void)
++float __builtin_custom_fni (int)
++float __builtin_custom_fnf (float)
++float __builtin_custom_fnp (void *)
++float __builtin_custom_fnii (int, int)
++float __builtin_custom_fnif (int, float)
++float __builtin_custom_fnip (int, void *)
++float __builtin_custom_fnfi (float, int)
++float __builtin_custom_fnff (float, float)
++float __builtin_custom_fnfp (float, void *)
++float __builtin_custom_fnpi (void *, int)
++float __builtin_custom_fnpf (void *, float)
++float __builtin_custom_fnpp (void *, void *)
++void * __builtin_custom_pn (void)
++void * __builtin_custom_pni (int)
++void * __builtin_custom_pnf (float)
++void * __builtin_custom_pnp (void *)
++void * __builtin_custom_pnii (int, int)
++void * __builtin_custom_pnif (int, float)
++void * __builtin_custom_pnip (int, void *)
++void * __builtin_custom_pnfi (float, int)
++void * __builtin_custom_pnff (float, float)
++void * __builtin_custom_pnfp (float, void *)
++void * __builtin_custom_pnpi (void *, int)
++void * __builtin_custom_pnpf (void *, float)
++void * __builtin_custom_pnpp (void *, void *)
++@end example
++
++
+ @node Alpha Built-in Functions
+ @subsection Alpha Built-in Functions
+
+@@ -8022,6 +8155,7 @@ we do not recommend the use of pragmas; @xref{Function Attributes},
+ for further explanation.
+
+ @menu
++* Altera Nios II Pragmas::
+ * ARM Pragmas::
+ * RS/6000 and PowerPC Pragmas::
+ * Darwin Pragmas::
+@@ -8029,6 +8163,29 @@ for further explanation.
+ * Tru64 Pragmas::
+ @end menu
+
++@node Altera Nios II Pragmas
++@subsection Altera Nios II Pragmas
++
++The Altera Nios II target defines two pragmas to control the placement
++of bitfields within a struct.
++
++@table @code
++@item reverse_bitfields
++@cindex pragma, reverse_bitfields
++Cause all subsequent structs to behave as though the -mreverse-bitfields
++compiler switch had been given. Can be overridden by the
++@code{no_reverse_bitfields} attribute or a subsequent
++@code{#pragma no_reverse_bitfields}.
++
++@item no_reverse_bitfields
++@cindex pragma, no_reverse_bitfields
++Cause all subsequent structs to behave as though the -mno-reverse-bitfields
++compiler switch had been given. Can be overridden by the
++@code{reverse_bitfields} attribute or a subsequent
++@code{#pragma reverse_bitfields}.
++
++@end table
++
+ @node ARM Pragmas
+ @subsection ARM Pragmas
+
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index e683d0c..b34200f 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -337,6 +337,16 @@ in the following sections.
+ @item Machine Dependent Options
+ @xref{Submodel Options,,Hardware Models and Configurations}.
+
++@emph{Altera Nios II Options}
++@gccoptlist{-msmallc -mno-bypass-cache -mbypass-cache @gol
++-mno-cache-volatile -mcache-volatile -mno-inline-memcpy @gol
++-minline-memcpy -mno-fast-sw-div -mfast-sw-div @gol
++-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx @gol
++-mno-hw-div -mhw-div @gol
++-mno-stack-check -mstack-check @gol
++-msys-crt0= -msys-lib= -msys=nosys @gol
++-mreverse-bitfields -mno-reverse-bitfields}
++
+ @emph{M680x0 Options}
+ @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
+ -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol
+@@ -5839,6 +5849,7 @@ machine description. The default for the options is also defined by
+ that macro, which enables you to change the defaults.
+
+ @menu
++* Altera Nios II Options::
+ * M680x0 Options::
+ * M68hc1x Options::
+ * VAX Options::
+@@ -5874,6 +5885,290 @@ that macro, which enables you to change the defaults.
+ * FRV Options::
+ @end menu
+
++
++@node Altera Nios II Options
++@subsection Altera Nios II Options
++@cindex Altera Nios II options
++
++These are the @samp{-m} options defined for the Altera Nios II
++processor.
++
++@table @gcctabopt
++
++@item -msmallc
++@opindex msmallc
++Link with a limited version of the C library, -lsmallc. For more
++information see the C Library Documentation.
++
++
++@item -mbypass-cache
++@itemx -mno-bypass-cache
++@opindex mno-bypass-cache
++@opindex mbypass-cache
++Force all load and store instructions to always bypass cache by
++using io variants of the instructions. The default is to not
++bypass the cache.
++
++@item -mno-cache-volatile
++@itemx -mcache-volatile
++@opindex mcache-volatile
++@opindex mno-cache-volatile
++Volatile memory access bypass the cache using the io variants of
++the ld and st instructions. The default is to cache volatile
++accesses.
++
++-mno-cache-volatile is deprecated and will be deleted in a
++future GCC release.
++
++
++@item -mno-inline-memcpy
++@itemx -minline-memcpy
++@opindex mno-inline-memcpy
++@opindex minline-memcpy
++Do not inline memcpy. The default is to inline when -O is on.
++
++
++@item -mno-fast-sw-div
++@itemx -mfast-sw-div
++@opindex mno-fast-sw-div
++@opindex mfast-sw-div
++Do no use table based fast divide for small numbers. The default
++is to use the fast divide at -O3 and above.
++
++
++@item -mno-hw-mul
++@itemx -mhw-mul
++@itemx -mno-hw-mulx
++@itemx -mhw-mulx
++@itemx -mno-hw-div
++@itemx -mhw-div
++@opindex mno-hw-mul
++@opindex mhw-mul
++@opindex mno-hw-mulx
++@opindex mhw-mulx
++@opindex mno-hw-div
++@opindex mhw-div
++Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
++instructions by the compiler. The default is to emit @code{mul}
++and not emit @code{div} and @code{mulx}.
++
++The different combinations of @code{mul} and @code{mulx} instructions
++generate a different multilib options.
++
++@item -mno-stack-check
++@itemx -mstack-check
++@opindex no-stack-check
++@opindex stack-check
++Enables or disables the checking for sufficient memory when
++items are pushed onto the stack. A checked and non-checked
++version of each of the multilibs is provided.
++
++@item -msys-crt0=@var{startfile}
++@opindex msys-crt0
++@var{startfile} is the file name of the startfile (crt0) to use
++when linking. The default is crt0.o that comes with libgloss
++and is only suitable for use with the instruction set
++simulator.
++
++@item -msys-lib=@var{systemlib}
++@itemx -msys-lib=nosys
++@opindex msys-lib
++@var{systemlib} is the library name of the library which provides
++the system calls required by the C library, e.g. @code{read}, @code{write}
++etc. The default is to use nosys, this library provides
++stub implementations of the calls and is part of libgloss.
++
++@item -mno-reverse-bitfields
++@itemx -mreverse-bitfields
++@opindex mno-reverse-bitfields
++@opindex mreverse-bitfields
++When enabled, bitfields within a struct are allocated in reverse order.
++This is useful with legacy code that depends on the (inherently
++non-portable) ordering of bitfields via a union. Given:
++
++@smallexample
++struct inner
++@{
++ unsigned int a:1;
++ unsigned int b:31;
++@};
++
++union outer
++@{
++ struct inner inner;
++ unsigned int val;
++@};
++
++unsigned int f()
++@{
++ union outer o;
++ o.inner.a = 1;
++ o.inner.b = 0;
++ return o.val;
++@}
++@end smallexample
++
++a call to @code{f} will return 1 when compiled with
++@option{-mno-reverse-bitfields} (the default), or 2147483648 when
++compiled with @option{-mreverse-bitfields}.
++
++For structures that are a multiple of 32 bits wide, the reversal is
++done 32 bits at a time. For structures that are an odd multiple of 16
++bits wide, the reversal is done 16 bits at a time. For structures
++that are an odd multiple of 8 bits wide, the reversal is done 8 bits
++at a time. The size of a structure (as measured by the @code{sizeof}
++operator) never changes between @option{-mno-reverse-bitfields} and
++@option{-mreverse-bitfields}. Nonetheless, there can be some
++confusing corner cases with structs where the compiler has to add
++additional padding to meet alignment restrictions. Consider:
++
++@smallexample
++struct inner
++@{
++ unsigned int a:1;
++ unsigned int b:15;
++@};
++
++union outer
++@{
++ struct inner inner;
++ unsigned int val;
++@};
++
++unsigned int f()
++@{
++ union outer o;
++ o.val = 0;
++ o.inner.b = 1;
++ return o.val;
++@}
++@end smallexample
++
++a call to @code{f} will return 2 when compiled with
++@option{-mno-reverse-bitfields} (the default), or 65536 when compiled
++with @option{-mreverse-bitfields}. This is because @code{sizeof
++(inner)} is 4 in both cases. In the @option{-mno-reverse-bitfields}
++case, the compiler pads the struct at the end to be 4 bytes long,
++effectively doing:
++
++@smallexample
++struct inner
++@{
++ unsigned int a:1;
++ unsigned int b:15;
++ unsigned int padding:16;
++@};
++@end smallexample
++
++In the @option{-mreverse-bitfields} case, the hidden padding is
++reversed along with everything else, yielding the equivalent of:
++
++@smallexample
++struct inner
++@{
++ unsigned int padding:16;
++ unsigned int b:15;
++ unsigned int a:1;
++@};
++@end smallexample
++
++Of course, if we would rather that @code{sizeof (inner)} was 2, we could
++write the struct as:
++
++@smallexample
++struct inner
++@{
++ unsigned short a:1;
++ unsigned short b:15;
++@};
++@end smallexample
++
++and the padding would go away.
++
++In some cases, especially when using the @code{__packed__} attribute,
++there is no well-defined bit reversal that is possible: the compiler
++will issue an error message in this case. Consider:
++
++@smallexample
++struct invalid
++@{
++ unsigned int f1:1;
++ unsigned int f2:15;
++ unsigned int f3:4;
++ unsigned int f4:4;
++@} __attribute__ ((__packed__));
++@end smallexample
++
++Since @code{sizeof (invalid)} is 3, we are forced to try reversing
++individual bytes in the struct. But f2 is more than a byte wide, so
++we can't reverse it and still have it be contiguous. Similar cases
++occur when dealing with arrays or other large contiguous objects:
++
++@smallexample
++struct invalid2
++@{
++ unsigned char f1[5];
++ unsigned char f2[3];
++@};
++@end smallexample
++
++You'll have to rewrite the affected structs to say exactly what you
++mean in odd cases like that.
++
++Finally, note that individual fields are sized as a whole. The structs
++
++@smallexample
++struct array1
++@{
++ unsigned char f1[3];
++ unsigned char f2;
++@}
++@end smallexample
++
++and:
++
++@smallexample
++struct array2
++@{
++ unsigned char f1a;
++ unsigned char f1b;
++ unsigned char f1c;
++ unsigned char f2;
++@}
++@end smallexample
++
++are not equivalent. When compiled with @option{-mreverse-bitfields},
++they behave the same as:
++
++@smallexample
++struct array1r
++@{
++ unsigned char f2;
++ unsigned char f1[3];
++@}
++@end smallexample
++
++and:
++
++@smallexample
++struct array2r
++@{
++ unsigned char f2;
++ unsigned char f1c;
++ unsigned char f1b;
++ unsigned char f1a;
++@}
++@end smallexample
++
++would, respectively, when compiled with
++@option{-mno-reverse-bitfields}. In particular, f1 is treated as a
++single contiguous 24-bit object for purposes of reversal, while f1a,
++f1b, and f1c are treated as individual 8-bit objects that need not
++(and do not) remain contiguous. Use caution.
++
++@end table
++
++
+ @node M680x0 Options
+ @subsection M680x0 Options
+ @cindex M680x0 options
+diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
+index b73f325..4a134b2 100644
+--- a/gcc/doc/md.texi
++++ b/gcc/doc/md.texi
+@@ -1337,6 +1337,58 @@ However, here is a summary of the machine-dependent constraints
+ available on some particular machines.
+
+ @table @emph
++
++@item Altera Nios II family---@file{nios2.h}
++@table @code
++
++@item I
++Integer that is valid as an immediate operand in an
++instruction taking a signed 16-bit number. Range
++@minus{}32768 to 32767.
++
++@item J
++Integer that is valid as an immediate operand in an
++instruction taking an unsigned 16-bit number. Range
++0 to 65535.
++
++@item K
++Integer that is valid as an immediate operand in an
++instruction taking only the upper 16-bits of a
++32-bit number. Range 32-bit numbers with the lower
++16-bits being 0.
++
++@item L
++Integer that is valid as an immediate operand for a
++shift instruction. Range 0 to 31.
++
++
++@item M
++Integer that is valid as an immediate operand for
++only the value 0. Can be used in conjunction with
++the format modifier @code{z} to use @code{r0}
++instead of @code{0} in the assembly output.
++
++@item N
++Integer that is valid as an immediate operand for
++a custom instruction opcode. Range 0 to 255.
++
++@item S
++Matches immediates which are addresses in the small
++data section and therefore can be added to @code{gp}
++as a 16-bit immediate to re-create their 32-bit value.
++
++@item D@var{nn}
++For a given two digit @var{nn} constrains the operand
++to the corresponding register. Example: D02 forces the
++operand into register r2. The side effect of using this
++operand constraint is that reload may not be able to
++meet the constraint. If reload fails, an error message
++about failing to find any register to spill in the
++D@var{nn}_REG register class will be emitted.
++
++@end table
++
++
+ @item ARM family---@file{arm.h}
+ @table @code
+ @item f
+diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
+index 4527fe4..e7cc581 100644
+--- a/gcc/stor-layout.c
++++ b/gcc/stor-layout.c
+@@ -1435,6 +1435,355 @@ finalize_type_size (tree type)
+ }
+ }
+
++static void
++reverse_bitfield_layout (record_layout_info rli)
++{
++ tree field;
++ tree rev_size;
++ unsigned int rev_size_int;
++
++ /*
++ * The size of the words we'll be reversing. Normally, we reverse
++ * entire SImode words. However, if the entire struct's size isn't an
++ * exact multiple of the size of SImode, we can reverse HImode or even
++ * QImode pieces. In the examples below, assume SImode/int is 32
++ * bits, HImode/short is 16 bits, and QImode/char is 8 bits.
++ * Consider:
++ *
++ * struct s1
++ * {
++ * int f1:1;
++ * int f2:31;
++ * };
++ *
++ * struct s2
++ * {
++ * int f1:1;
++ * int f2:15;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s3
++ * {
++ * short f1:1;
++ * short f2:15;
++ * };
++ *
++ * struct s4
++ * {
++ * int f1:1;
++ * int f2:15;
++ * };
++ *
++ * struct s5
++ * {
++ * int f1:8;
++ * int f2:8;
++ * int f3:4;
++ * int f4:4;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s6
++ * {
++ * int f1:1;
++ * int f2:15;
++ * int f3:4;
++ * int f4:4;
++ * int f5:8;
++ * };
++ *
++ * struct s7
++ * {
++ * int f1:1;
++ * int f2:15;
++ * int f3:4;
++ * int f4:4;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s8
++ * {
++ * char f1;
++ * short f2;
++ * char f3;
++ * };
++ *
++ * struct s9
++ * {
++ * char f1;
++ * short f2;
++ * char f3;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s10
++ * {
++ * char f1;
++ * short f2;
++ * char f3;
++ * short f4;
++ * };
++ *
++ * struct s11
++ * {
++ * char f1[5];
++ * int f2;
++ * };
++ *
++ * struct s12
++ * {
++ * char f1[5];
++ * char f2[3];
++ * int f3;
++ * };
++ *
++ * struct s13
++ * {
++ * char f1[3];
++ * int f2;
++ * };
++ *
++ * struct s14
++ * {
++ * char f1a;
++ * char f1b;
++ * char f1c;
++ * int f2;
++ * };
++ *
++ * Then we have:
++ *
++ * sizeof (struct s1) == 4
++ * sizeof (struct s2) == 2
++ * sizeof (struct s3) == 2
++ * sizeof (struct s4) == 4
++ * sizeof (struct s5) == 3
++ * sizeof (struct s6) == 4
++ * sizeof (struct s7) == 3
++ * sizeof (struct s8) == 6
++ * sizeof (struct s9) == 4
++ * sizeof (struct s10) == 8
++ * sizeof (struct s11) == 12
++ * sizeof (struct s12) == 12
++ *
++ * We want the equivalent reversed bitfield structs to be:
++ *
++ * struct s1r
++ * {
++ * int f2:31;
++ * int f1:1;
++ * };
++ *
++ * struct s2r
++ * {
++ * int f2:15;
++ * int f1:1;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s3r
++ * {
++ * short f2:15;
++ * short f1:1;
++ * };
++ *
++ * struct s4r
++ * {
++ * int unnamed:16;
++ * int f2:15;
++ * int f1:1;
++ * };
++ *
++ * struct s5r
++ * {
++ * int f1:8;
++ * int f2:8;
++ * int f4:4;
++ * int f3:4;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s6r
++ * {
++ * int f5:8;
++ * int f4:4;
++ * int f3:4;
++ * int f2:15;
++ * int f1:1;
++ * };
++ *
++ * struct s7r
++ * {
++ * #error cannot reverse bitfield
++ * } __attribute__ ((__packed__));
++ *
++ * struct s8r
++ * {
++ * char unnamed1;
++ * char f1;
++ * short f2;
++ * char unnamed2;
++ * char f3;
++ * };
++ *
++ * struct s9r
++ * {
++ * char f3;
++ * short f2;
++ * char f1;
++ * } __attribute__ ((__packed__));
++ *
++ * struct s10r
++ * {
++ * short f2;
++ * char unnamed1;
++ * char f1;
++ * short f4;
++ * char unnamed2;
++ * char f3;
++ * };
++ *
++ * struct s11r
++ * {
++ * char f1[5];
++ * int f2;
++ * };
++ *
++ * struct s12r
++ * {
++ * #error cannot reverse bitfield
++ * };
++ *
++ * struct s13r
++ * {
++ * char unnamed;
++ * char f1[3];
++ * int f2;
++ * };
++ *
++ * struct s14r
++ * {
++ * char unnamed;
++ * char f1c;
++ * char f1b;
++ * char f1a;
++ * int f2;
++ * };
++ *
++ * Note that the s4, s8, s10, s13, and s14 cases produce somewhat
++ * suprising results: the normally hidden padding bytes the compiler
++ * adds are also reversed. Further note that s13 and s14 are not
++ * equivalent: the f1 field in s13 is 24-bits wide, and is reversed
++ * accordingly, while the three fields f1a, f1b, and f1c in s14 are
++ * reversed as individual bytes.
++ *
++ * The s7 and s12 cases produce an error: we can't reverse a bitfield
++ * that is larger than word size we're reversing. The error is
++ * suppressed in the s11 case since the field in question and the
++ * field that follows are both word aligned.
++ */
++
++ /*
++ * First, figure out what size words to reverse. We look at the total
++ * number of bits currently in use by the struct, rounded up to the
++ * next multiple of rli->record_align, to decide.
++ */
++ {
++ int bits_in_use = TREE_INT_CST_LOW (round_up (rli_size_so_far (rli),
++ rli->record_align));
++ unsigned int size;
++ for (size = GET_MODE_BITSIZE (SImode);
++ size >= GET_MODE_BITSIZE (QImode);
++ size /= 2)
++ {
++ if (bits_in_use % size == 0)
++ {
++ break;
++ }
++ }
++ if (size < GET_MODE_BITSIZE (QImode))
++ {
++ /*
++ * rli->record_align should never be less than QImode, even
++ * for packed structs.
++ */
++ abort ();
++ }
++ rev_size = size_int_type (size, bitsizetype);
++ rev_size_int = size;
++ }
++
++ /*
++ * Then, iterate over the fields, reversing them as we go.
++ */
++ for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field))
++ {
++ tree type = TREE_TYPE (field);
++ if (TREE_CODE (field) != FIELD_DECL)
++ {
++ continue;
++ }
++ if (TREE_CODE (field) == ERROR_MARK || TREE_CODE (type) == ERROR_MARK)
++ {
++ return;
++ }
++ {
++ tree offset = DECL_FIELD_OFFSET (field);
++ tree offset_type = TREE_TYPE (offset);
++ tree bit_offset = DECL_FIELD_BIT_OFFSET (field);
++ tree bit_offset_type = TREE_TYPE (bit_offset);
++ tree bit = bit_from_pos (offset, bit_offset);
++ tree true_size = DECL_SIZE (field);
++ pos_from_bit (&offset, &bit_offset, rev_size_int, bit);
++ bit_offset = size_binop (MINUS_EXPR,
++ size_binop (MINUS_EXPR, rev_size, true_size),
++ bit_offset);
++ if (TREE_INT_CST_HIGH (bit_offset) != 0)
++ {
++ /*
++ * This happens when a field spans a rev_size boundary (see
++ * example s7 above): rather than try to come up with some
++ * well-defined, but non-intuitive definition for this case,
++ * just issue an error. It can also happen for large fields,
++ * e.g. arrays or other structs: if these large fields were
++ * already aligned, leave them be; otherwise issue the error
++ * in this case as well.
++ */
++ if ((TREE_INT_CST_HIGH (true_size) != 0
++ || TREE_INT_CST_LOW (true_size) > rev_size_int)
++ && TREE_INT_CST_HIGH (DECL_FIELD_BIT_OFFSET (field)) == 0
++ && TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)) == 0)
++ {
++ tree next_field = TREE_CHAIN (field);
++ if (!next_field)
++ {
++ /* No following field, so we're ok. */
++ continue;
++ }
++ else
++ {
++ tree next_offset = DECL_FIELD_OFFSET (next_field);
++ tree next_bit_offset = DECL_FIELD_BIT_OFFSET (next_field);
++ tree next_bit = bit_from_pos (next_offset, next_bit_offset);
++ pos_from_bit (&next_offset, &next_bit_offset, rev_size_int,
++ next_bit);
++ if (TREE_INT_CST_HIGH (next_bit_offset) == 0
++ && TREE_INT_CST_LOW (next_bit_offset) == 0)
++ {
++ /* Following field is aligned wrt rev_size_int boundary,
++ so we're ok. */
++ continue;
++ }
++ }
++ }
++ error ("unable to reverse bitfields in structure");
++ return;
++ }
++ bit = bit_from_pos (offset, bit_offset);
++ pos_from_bit (&offset, &bit_offset, rli->offset_align, bit);
++ TREE_TYPE (offset) = offset_type;
++ DECL_FIELD_OFFSET (field) = offset;
++ TREE_TYPE (bit_offset) = bit_offset_type;
++ DECL_FIELD_BIT_OFFSET (field) = bit_offset;
++ }
++ }
++}
++
+ /* Do all of the work required to layout the type indicated by RLI,
+ once the fields have been laid out. This function will call `free'
+ for RLI, unless FREE_P is false. Passing a value other than false
+@@ -1444,6 +1793,12 @@ finalize_type_size (tree type)
+ void
+ finish_record_layout (record_layout_info rli, int free_p)
+ {
++ /* Optionally reverse the placement of bitfields within the record */
++ if ((* targetm.reverse_bitfield_layout_p) (rli->t))
++ {
++ reverse_bitfield_layout (rli);
++ }
++
+ /* Compute the final size. */
+ finalize_record_size (rli);
+
+diff --git a/gcc/target-def.h b/gcc/target-def.h
+index 32d00ae..bdea4d4 100644
+--- a/gcc/target-def.h
++++ b/gcc/target-def.h
+@@ -300,6 +300,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #define TARGET_INSERT_ATTRIBUTES hook_void_tree_treeptr
+ #define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P hook_bool_tree_false
+ #define TARGET_MS_BITFIELD_LAYOUT_P hook_bool_tree_false
++#define TARGET_REVERSE_BITFIELD_LAYOUT_P hook_bool_tree_false
+ #define TARGET_RTX_COSTS hook_bool_rtx_int_int_intp_false
+ #define TARGET_MANGLE_FUNDAMENTAL_TYPE hook_constcharptr_tree_null
+
+@@ -368,6 +369,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ TARGET_INSERT_ATTRIBUTES, \
+ TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P, \
+ TARGET_MS_BITFIELD_LAYOUT_P, \
++ TARGET_REVERSE_BITFIELD_LAYOUT_P, \
+ TARGET_INIT_BUILTINS, \
+ TARGET_EXPAND_BUILTIN, \
+ TARGET_MANGLE_FUNDAMENTAL_TYPE, \
+diff --git a/gcc/target.h b/gcc/target.h
+index 59788f9..97bde5f 100644
+--- a/gcc/target.h
++++ b/gcc/target.h
+@@ -295,6 +295,10 @@ struct gcc_target
+ Microsoft Visual C++ bitfield layout rules. */
+ bool (* ms_bitfield_layout_p) (tree record_type);
+
++ /* Return true if bitfields in RECORD_TYPE should be allocated
++ within their base type's bytes starting at the opposite end. */
++ bool (* reverse_bitfield_layout_p) (tree record_type);
++
+ /* Set up target-specific built-in functions. */
+ void (* init_builtins) (void);
+
+diff --git a/gcc/varasm.c b/gcc/varasm.c
+index 33307e5..d4ed0fc 100644
+--- a/gcc/varasm.c
++++ b/gcc/varasm.c
+@@ -3912,6 +3912,107 @@ array_size_for_constructor (tree val)
+ return tree_low_cst (i, 1);
+ }
+
++struct reorder_bitfields_key
++{
++ tree field;
++ tree value;
++};
++
++static int
++reorder_bitfields_compare (const void *x1, const void *x2)
++{
++ const struct reorder_bitfields_key *key1 = x1;
++ const struct reorder_bitfields_key *key2 = x2;
++ int pos1 = int_bit_position (key1->field);
++ int pos2 = int_bit_position (key2->field);
++
++ if (pos1 < pos2)
++ {
++ return -1;
++ }
++ else if (pos1 > pos2)
++ {
++ return 1;
++ }
++ else
++ {
++ /*
++ * No two fields should ever have the same bit_position, so
++ * something is horribly wrong.
++ */
++ abort ();
++ }
++}
++
++static void
++reorder_bitfields (tree *first_field, tree *first_value)
++{
++ struct reorder_bitfields_key *keys;
++ size_t field_count;
++ tree field;
++ tree value;
++ size_t i;
++
++ /*
++ * Find out how many fields are in this record, and allocate an array
++ * of keys to hold them all.
++ */
++ field_count = 0;
++ for (field = *first_field; field; field = TREE_CHAIN (field))
++ {
++ field_count++;
++ }
++ if (field_count < 2)
++ {
++ return;
++ }
++ keys = xmalloc (sizeof (struct reorder_bitfields_key) * field_count);
++
++ /*
++ * Make copies of the existing fields and values (using signed integer
++ * zeros for missing values) in the array of keys.
++ */
++ field = *first_field;
++ value = *first_value;
++ for (i = 0; i < field_count; i++)
++ {
++ keys[i].field = copy_node (field);
++ field = TREE_CHAIN (field);
++ if (value)
++ {
++ keys[i].value = copy_node (value);
++ TREE_PURPOSE (keys[i].value) = keys[i].field;
++ value = TREE_CHAIN (value);
++ }
++ else
++ {
++ keys[i].value = tree_cons (keys[i].field, ssize_int (0), 0);
++ }
++ }
++
++ /*
++ * Sort the array based on position of the fields in the record.
++ */
++ qsort (keys, field_count, sizeof (struct reorder_bitfields_key),
++ reorder_bitfields_compare);
++
++ /*
++ * Build new lists out of the sorted array.
++ */
++ for (i = 0; i < field_count - 1; i++)
++ {
++ TREE_CHAIN (keys[i].field) = keys[i+1].field;
++ TREE_CHAIN (keys[i].value) = keys[i+1].value;
++ }
++ *first_field = keys[0].field;
++ *first_value = keys[0].value;
++
++ /*
++ * Get rid of our array of keys and we're done.
++ */
++ free (keys);
++}
++
+ /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants).
+ Generate at least SIZE bytes, padding if necessary. */
+
+@@ -3928,12 +4029,29 @@ output_constructor (tree exp, unsigned HOST_WIDE_INT size,
+ /* Nonzero means BYTE contains part of a byte, to be output. */
+ int byte_buffer_in_use = 0;
+ int byte = 0;
++ tree first_link = CONSTRUCTOR_ELTS (exp);
+
+ if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
+ abort ();
+
+ if (TREE_CODE (type) == RECORD_TYPE)
++ {
++ if ((*targetm.reverse_bitfield_layout_p) (type))
++ {
++ /*
++ * If we're reversing bitfields, we have to reverse the order in
++ * which constructors containing bitfields are output. The
++ * easiest way to do that is to reorder the constructor elements
++ * and fields to be in memory-order.
++ */
+ field = TYPE_FIELDS (type);
++ reorder_bitfields (&field, &first_link);
++ }
++ else
++ {
++ field = TYPE_FIELDS (type);
++ }
++ }
+
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) != 0)
+@@ -3948,7 +4066,7 @@ output_constructor (tree exp, unsigned HOST_WIDE_INT size,
+ There is always a maximum of one element in the chain LINK for unions
+ (even if the initializer in a source program incorrectly contains
+ more one). */
+- for (link = CONSTRUCTOR_ELTS (exp);
++ for (link = first_link;
+ link;
+ link = TREE_CHAIN (link),
+ field = field ? TREE_CHAIN (field) : 0)
diff --git a/cleopatre/buildroot/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional b/cleopatre/buildroot/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional
new file mode 100644
index 0000000000..19d1b90dac
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional
@@ -0,0 +1,270 @@
+Note... modified my mjn3 to not conflict with the big endian arm patch.
+Warning!!! Only the linux target is aware of TARGET_ENDIAN_DEFAULT.
+Also changed
+ #define SUBTARGET_EXTRA_ASM_SPEC "\
+ %{!mcpu=*:-mcpu=xscale} \
+ %{mhard-float:-mfpu=fpa} \
+ %{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
+to
+ #define SUBTARGET_EXTRA_ASM_SPEC "\
+ %{mhard-float:-mfpu=fpa} \
+ %{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
+in gcc/config/arm/linux-elf.h.
+#
+# Submitted:
+#
+# Dimitry Andric <dimitry@andric.com>, 2004-05-01
+#
+# Description:
+#
+# Nicholas Pitre released this patch for gcc soft-float support here:
+# http://lists.arm.linux.org.uk/pipermail/linux-arm/2003-October/006436.html
+#
+# This version has been adapted to work with gcc 3.4.0.
+#
+# The original patch doesn't distinguish between softfpa and softvfp modes
+# in the way Nicholas Pitre probably meant. His description is:
+#
+# "Default is to use APCS-32 mode with soft-vfp. The old Linux default for
+# floats can be achieved with -mhard-float or with the configure
+# --with-float=hard option. If -msoft-float or --with-float=soft is used then
+# software float support will be used just like the default but with the legacy
+# big endian word ordering for double float representation instead."
+#
+# Which means the following:
+#
+# * If you compile without -mhard-float or -msoft-float, you should get
+# software floating point, using the VFP format. The produced object file
+# should have these flags in its header:
+#
+# private flags = 600: [APCS-32] [VFP float format] [software FP]
+#
+# * If you compile with -mhard-float, you should get hardware floating point,
+# which always uses the FPA format. Object file header flags should be:
+#
+# private flags = 0: [APCS-32] [FPA float format]
+#
+# * If you compile with -msoft-float, you should get software floating point,
+# using the FPA format. This is done for compatibility reasons with many
+# existing distributions. Object file header flags should be:
+#
+# private flags = 200: [APCS-32] [FPA float format] [software FP]
+#
+# The original patch from Nicholas Pitre contained the following constructs:
+#
+# #define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
+# %{mhard-float:-mfpu=fpa} \
+# %{!mhard-float: %{msoft-float:-mfpu=softfpa;:-mfpu=softvfp}}"
+#
+# However, gcc doesn't accept this ";:" notation, used in the 3rd line. This
+# is probably the reason Robert Schwebel modified it to:
+#
+# #define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
+# %{mhard-float:-mfpu=fpa} \
+# %{!mhard-float: %{msoft-float:-mfpu=softfpa -mfpu=softvfp}}"
+#
+# But this causes the following behaviour:
+#
+# * If you compile without -mhard-float or -msoft-float, the compiler generates
+# software floating point instructions, but *nothing* is passed to the
+# assembler, which results in an object file which has flags:
+#
+# private flags = 0: [APCS-32] [FPA float format]
+#
+# This is not correct!
+#
+# * If you compile with -mhard-float, the compiler generates hardware floating
+# point instructions, and passes "-mfpu=fpa" to the assembler, which results
+# in an object file which has the same flags as in the previous item, but now
+# those *are* correct.
+#
+# * If you compile with -msoft-float, the compiler generates software floating
+# point instructions, and passes "-mfpu=softfpa -mfpu=softvfp" (in that
+# order) to the assembler, which results in an object file with flags:
+#
+# private flags = 600: [APCS-32] [VFP float format] [software FP]
+#
+# This is not correct, because the last "-mfpu=" option on the assembler
+# command line determines the actual FPU convention used (which should be FPA
+# in this case).
+#
+# Therefore, I modified this patch to get the desired behaviour. Every
+# instance of the notation:
+#
+# %{msoft-float:-mfpu=softfpa -mfpu=softvfp}
+#
+# was changed to:
+#
+# %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}
+#
+# I also did the following:
+#
+# * Modified all TARGET_DEFAULT macros I could find to include ARM_FLAG_VFP, to
+# be consistent with Nicholas' original patch.
+# * Removed any "msoft-float" or "mhard-float" from all MULTILIB_DEFAULTS
+# macros I could find. I think that if you compile without any options, you
+# would like to get the defaults. :)
+# * Removed the extra -lfloat option from LIBGCC_SPEC, since it isn't needed
+# anymore. (The required functions are now in libgcc.)
+
+diff -urN gcc-3.4.1-old/gcc/config/arm/coff.h gcc-3.4.1/gcc/config/arm/coff.h
+--- gcc-3.4.1-old/gcc/config/arm/coff.h 2004-02-24 08:25:22.000000000 -0600
++++ gcc-3.4.1/gcc/config/arm/coff.h 2004-09-02 21:51:15.000000000 -0500
+@@ -31,11 +31,16 @@
+ #define TARGET_VERSION fputs (" (ARM/coff)", stderr)
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
++#define TARGET_DEFAULT \
++ ( ARM_FLAG_SOFT_FLOAT \
++ | ARM_FLAG_VFP \
++ | ARM_FLAG_APCS_32 \
++ | ARM_FLAG_APCS_FRAME \
++ | ARM_FLAG_MMU_TRAPS )
+
+ #ifndef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
++ { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork" }
+ #endif
+
+ /* This is COFF, but prefer stabs. */
+diff -urN gcc-3.4.1-old/gcc/config/arm/elf.h gcc-3.4.1/gcc/config/arm/elf.h
+--- gcc-3.4.1-old/gcc/config/arm/elf.h 2004-02-24 08:25:22.000000000 -0600
++++ gcc-3.4.1/gcc/config/arm/elf.h 2004-09-02 21:51:15.000000000 -0500
+@@ -46,7 +46,9 @@
+
+ #ifndef SUBTARGET_ASM_FLOAT_SPEC
+ #define SUBTARGET_ASM_FLOAT_SPEC "\
+-%{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
++%{mapcs-float:-mfloat} \
++%{mhard-float:-mfpu=fpa} \
++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
+ #endif
+
+ #ifndef ASM_SPEC
+@@ -106,12 +108,17 @@
+ #endif
+
+ #ifndef TARGET_DEFAULT
+-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
++#define TARGET_DEFAULT \
++ ( ARM_FLAG_SOFT_FLOAT \
++ | ARM_FLAG_VFP \
++ | ARM_FLAG_APCS_32 \
++ | ARM_FLAG_APCS_FRAME \
++ | ARM_FLAG_MMU_TRAPS )
+ #endif
+
+ #ifndef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
++ { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
+ #endif
+
+ #define TARGET_ASM_FILE_START_APP_OFF true
+diff -urN gcc-3.4.1-old/gcc/config/arm/linux-elf.h gcc-3.4.1/gcc/config/arm/linux-elf.h
+--- gcc-3.4.1-old/gcc/config/arm/linux-elf.h 2004-09-02 21:50:52.000000000 -0500
++++ gcc-3.4.1/gcc/config/arm/linux-elf.h 2004-09-02 22:00:49.000000000 -0500
+@@ -44,12 +44,26 @@
+ #define TARGET_LINKER_EMULATION "armelf_linux"
+ #endif
+
+-/* Default is to use APCS-32 mode. */
++/*
++ * Default is to use APCS-32 mode with soft-vfp.
++ * The old Linux default for floats can be achieved with -mhard-float
++ * or with the configure --with-float=hard option.
++ * If -msoft-float or --with-float=soft is used then software float
++ * support will be used just like the default but with the legacy
++ * big endian word ordering for double float representation instead.
++ */
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT \
+- ( ARM_FLAG_APCS_32 | \
+- ARM_FLAG_MMU_TRAPS | \
+- TARGET_ENDIAN_DEFAULT )
++#define TARGET_DEFAULT \
++ ( ARM_FLAG_APCS_32 \
++ | ARM_FLAG_SOFT_FLOAT \
++ | TARGET_ENDIAN_DEFAULT \
++ | ARM_FLAG_VFP \
++ | ARM_FLAG_MMU_TRAPS )
++
++#undef SUBTARGET_EXTRA_ASM_SPEC
++#define SUBTARGET_EXTRA_ASM_SPEC "\
++%{mhard-float:-mfpu=fpa} \
++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+@@ -57,7 +71,7 @@
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mapcs-32", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mapcs-32", "mno-thumb-interwork" }
+
+ #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
+
+@@ -72,7 +86,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
+ the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
+diff -urN gcc-3.4.1-old/gcc/config/arm/t-linux gcc-3.4.1/gcc/config/arm/t-linux
+--- gcc-3.4.1-old/gcc/config/arm/t-linux 2003-09-20 16:09:07.000000000 -0500
++++ gcc-3.4.1/gcc/config/arm/t-linux 2004-09-02 21:51:15.000000000 -0500
+@@ -4,7 +4,10 @@
+ LIBGCC2_DEBUG_CFLAGS = -g0
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+diff -urN gcc-3.4.1-old/gcc/config/arm/unknown-elf.h gcc-3.4.1/gcc/config/arm/unknown-elf.h
+--- gcc-3.4.1-old/gcc/config/arm/unknown-elf.h 2004-02-24 08:25:22.000000000 -0600
++++ gcc-3.4.1/gcc/config/arm/unknown-elf.h 2004-09-02 21:51:15.000000000 -0500
+@@ -30,7 +30,12 @@
+
+ /* Default to using APCS-32 and software floating point. */
+ #ifndef TARGET_DEFAULT
+-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
++#define TARGET_DEFAULT \
++ ( ARM_FLAG_SOFT_FLOAT \
++ | ARM_FLAG_VFP \
++ | ARM_FLAG_APCS_32 \
++ | ARM_FLAG_APCS_FRAME \
++ | ARM_FLAG_MMU_TRAPS )
+ #endif
+
+ /* Now we define the strings used to build the spec file. */
+diff -urN gcc-3.4.1-old/gcc/config/arm/xscale-elf.h gcc-3.4.1/gcc/config/arm/xscale-elf.h
+--- gcc-3.4.1-old/gcc/config/arm/xscale-elf.h 2003-07-01 18:26:43.000000000 -0500
++++ gcc-3.4.1/gcc/config/arm/xscale-elf.h 2004-09-02 21:51:15.000000000 -0500
+@@ -49,11 +49,12 @@
+ endian, regardless of the endian-ness of the memory
+ system. */
+
+-#define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
+- %{mhard-float:-mfpu=fpa} \
+- %{!mhard-float: %{msoft-float:-mfpu=softfpa;:-mfpu=softvfp}}"
++#define SUBTARGET_EXTRA_ASM_SPEC "\
++%{!mcpu=*:-mcpu=xscale} \
++%{mhard-float:-mfpu=fpa} \
++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
+
+ #ifndef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "mlittle-endian", "mno-thumb-interwork", "marm", "msoft-float" }
++ { "mlittle-endian", "mno-thumb-interwork", "marm" }
+ #endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/100-uclibc-conf.patch
new file mode 100644
index 0000000000..3be7d0975d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/100-uclibc-conf.patch
@@ -0,0 +1,553 @@
+--- gcc-4.0.2/gcc/config/t-linux-uclibc
++++ gcc-4.0.2/gcc/config/t-linux-uclibc
+@@ -0,0 +1,5 @@
++# Remove glibc specific files added in t-linux
++SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES))
++
++# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc
++LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH))
+--- gcc-4.0.2/gcc/config.gcc
++++ gcc-4.0.2/gcc/config.gcc
+@@ -1778,7 +1778,7 @@
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
+@@ -2234,10 +2234,16 @@
+ *)
+ echo "*** Configuration ${target} not supported" 1>&2
+ exit 1
+ ;;
+ esac
++
++# Rather than hook into each target, just do it after all the linux
++# targets have been processed
++case ${target} in
++*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc"
++esac
+
+ case ${target} in
+ i[34567]86-*-linux*aout* | i[34567]86-*-linux*libc1)
+ tmake_file="${tmake_file} i386/t-gmm_malloc"
+ ;;
+--- gcc-4.0.2/gcc/config/alpha/linux-elf.h
++++ gcc-4.0.2/gcc/config/alpha/linux-elf.h
+@@ -27,7 +27,11 @@
+ #define SUBTARGET_EXTRA_SPECS \
+ { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
+ #define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+
+ #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+--- gcc-4.0.2/gcc/config/arm/linux-elf.h
++++ gcc-4.0.2/gcc/config/arm/linux-elf.h
+@@ -81,14 +81,19 @@
+ #define ENDFILE_SPEC \
+ "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "%{h*} %{version:-v} \
+ %{b} %{Wl,*:%*} \
+ %{static:-Bstatic} \
+ %{shared:-shared} \
+ %{symbolic:-Bsymbolic} \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "} \
+ -X \
+ %{mbig-endian:-EB}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+--- gcc-4.0.2/gcc/config/cris/linux.h
++++ gcc-4.0.2/gcc/config/cris/linux.h
+@@ -79,6 +79,25 @@
+ #undef CRIS_DEFAULT_CPU_VERSION
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
++#ifdef USE_UCLIBC
++
++#undef CRIS_SUBTARGET_VERSION
++#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++
++#undef CRIS_LINK_SUBTARGET_SPEC
++#define CRIS_LINK_SUBTARGET_SPEC \
++ "-mcrislinux\
++ -rpath-link include/asm/../..%s\
++ %{shared} %{static}\
++ %{symbolic:-Bdynamic} %{shlib:-Bdynamic} %{static:-Bstatic}\
++ %{!shared: \
++ %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}} \
++ %{!r:%{O2|O3: --gc-sections}}"
++
++#else /* USE_UCLIBC */
++
+ #undef CRIS_SUBTARGET_VERSION
+ #define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
+
+@@ -93,6 +112,8 @@
+ %{!shared:%{!static:%{rdynamic:-export-dynamic}}}\
+ %{!r:%{O2|O3: --gc-sections}}"
+
++#endif /* USE_UCLIBC */
++
+
+ /* Node: Run-time Target */
+
+--- gcc-4.0.2/gcc/config/i386/linux.h
++++ gcc-4.0.2/gcc/config/i386/linux.h
+@@ -107,6 +107,11 @@
+ #define LINK_EMULATION "elf_i386"
+ #define DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
++#ifdef USE_UCLIBC
++#undef DYNAMIC_LINKER
++#define DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#endif
++
+ #undef SUBTARGET_EXTRA_SPECS
+ #define SUBTARGET_EXTRA_SPECS \
+ { "link_emulation", LINK_EMULATION },\
+--- gcc-4.0.2/gcc/config/i386/linux64.h
++++ gcc-4.0.2/gcc/config/i386/linux64.h
+@@ -54,14 +54,21 @@
+ When the -shared link option is used a final link is not being
+ done. */
+
++#ifdef USE_UCLIBC
++#define ELF32_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF32_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define ELF64_DYNAMIC_LINKER "/lib64/ld-linux-x86-64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
+- %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
++ %{m32:%{!dynamic-linker:-dynamic-linker " ELF32_DYNAMIC_LINKER "}} \
++ %{!m32:%{!dynamic-linker:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}} \
+ %{static:-static}}"
+
+ #define MULTILIB_DEFAULTS { "m64" }
+--- gcc-4.0.2/gcc/config/ia64/linux.h
++++ gcc-4.0.2/gcc/config/ia64/linux.h
+@@ -37,13 +37,18 @@
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+
+--- gcc-4.0.2/gcc/config/m68k/linux.h
++++ gcc-4.0.2/gcc/config/m68k/linux.h
+@@ -127,12 +127,17 @@
+
+ /* If ELF is the default format, we should not use /lib/elf. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m m68kelf %{shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker*:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static}}"
+
+ /* For compatibility with linux/a.out */
+--- gcc-4.0.2/gcc/config/mips/linux.h
++++ gcc-4.0.2/gcc/config/mips/linux.h
+@@ -108,14 +108,19 @@
+
+ /* Borrowed from sparc/linux.h */
+ #undef LINK_SPEC
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #define LINK_SPEC \
+ "%(endian_spec) \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+
+ #undef SUBTARGET_ASM_SPEC
+--- gcc-4.0.2/gcc/config/pa/pa-linux.h
++++ gcc-4.0.2/gcc/config/pa/pa-linux.h
+@@ -82,13 +82,18 @@
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+ /* glibc's profiling functions don't need gcc to allocate counters. */
+--- gcc-4.0.2/gcc/config/rs6000/linux.h
++++ gcc-4.0.2/gcc/config/rs6000/linux.h
+@@ -69,7 +69,11 @@
+ #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
+
+ #undef LINK_OS_DEFAULT_SPEC
++#ifdef USE_UCLIBC
++#define LINK_OS_DEFAULT_SPEC "%(link_os_linux_uclibc)"
++#else
+ #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
++#endif
+
+ #define LINK_GCC_C_SEQUENCE_SPEC \
+ "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
+--- gcc-4.0.2/gcc/config/rs6000/sysv4.h
++++ gcc-4.0.2/gcc/config/rs6000/sysv4.h
+@@ -949,6 +949,7 @@
+ mcall-linux : %(link_os_linux) ; \
+ mcall-gnu : %(link_os_gnu) ; \
+ mcall-netbsd : %(link_os_netbsd) ; \
++ mcall-linux-uclibc : %(link_os_linux_uclibc); \
+ mcall-openbsd: %(link_os_openbsd) ; \
+ : %(link_os_default) }"
+
+@@ -1127,6 +1128,10 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
+
++#define LINK_OS_LINUX_UCLIBC_SPEC "-m elf32ppclinux %{!shared: %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}}"
++
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+ # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+ #endif
+@@ -1293,6 +1298,7 @@
+ { "link_os_sim", LINK_OS_SIM_SPEC }, \
+ { "link_os_freebsd", LINK_OS_FREEBSD_SPEC }, \
+ { "link_os_linux", LINK_OS_LINUX_SPEC }, \
++ { "link_os_linux_uclibc", LINK_OS_LINUX_UCLIBC_SPEC }, \
+ { "link_os_gnu", LINK_OS_GNU_SPEC }, \
+ { "link_os_netbsd", LINK_OS_NETBSD_SPEC }, \
+ { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
+--- gcc-4.0.2/gcc/config/s390/linux.h
++++ gcc-4.0.2/gcc/config/s390/linux.h
+@@ -77,6 +77,13 @@
+ #define MULTILIB_DEFAULTS { "m31" }
+ #endif
+
++#ifdef USE_UCLIBC
++#define ELF31_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF31_DYNAMIC_LINKER "/lib/ld.so.1"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+ "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
+@@ -86,8 +93,8 @@
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker: \
+- %{m31:-dynamic-linker /lib/ld.so.1} \
+- %{m64:-dynamic-linker /lib/ld64.so.1}}}}"
++ %{m31:-dynamic-linker " ELF31_DYNAMIC_LINKER "} \
++ %{m64:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}}}"
+
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+--- gcc-4.0.2/gcc/config/sh/linux.h
++++ gcc-4.0.2/gcc/config/sh/linux.h
+@@ -67,11 +67,16 @@
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
+ #undef SUBTARGET_LINK_SPEC
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define SUBTARGET_LINK_SPEC \
+ "%{shared:-shared} \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}"
+
+ #undef LIB_SPEC
+--- gcc-4.0.2/gcc/config/sparc/linux.h
++++ gcc-4.0.2/gcc/config/sparc/linux.h
+@@ -130,14 +130,19 @@
+
+ /* If ELF is the default format, we should not use /lib/elf. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!mno-relax:%{!r:-relax}} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+
+ /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
+--- gcc-4.0.2/gcc/config/sparc/linux64.h
++++ gcc-4.0.2/gcc/config/sparc/linux64.h
+@@ -167,12 +166,17 @@
+ { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
+ { "link_arch", LINK_ARCH_SPEC },
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}} \
+ "
+
+--- gcc-4.0.2/libtool.m4
++++ gcc-4.0.2/libtool.m4
+@@ -682,6 +682,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+--- gcc-4.0.2/ltconfig
++++ gcc-4.0.2/ltconfig
+@@ -603,6 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1274,6 +1275,23 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- gcc-4.0.2/libffi/configure
++++ gcc-4.0.2/libffi/configure
+@@ -3457,6 +3457,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/libgfortran/configure
++++ gcc-4.0.2/libgfortran/configure
+@@ -3681,6 +3681,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/libjava/configure
++++ gcc-4.0.2/libjava/configure
+@@ -4351,6 +4351,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/libmudflap/configure
++++ gcc-4.0.2/libmudflap/configure
+@@ -5380,6 +5380,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/libobjc/configure
++++ gcc-4.0.2/libobjc/configure
+@@ -3283,6 +3283,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/boehm-gc/configure
++++ gcc-4.0.2/boehm-gc/configure
+@@ -4320,6 +4320,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.0.2/configure
++++ gcc-4.0.2/configure
+@@ -1141,7 +1141,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+--- gcc-4.0.2/configure.in
++++ gcc-4.0.2/configure.in
+@@ -350,7 +350,7 @@
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+--- gcc-4.0.2/contrib/regression/objs-gcc.sh
++++ gcc-4.0.2/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc-4.0.2/zlib/configure
++++ gcc-4.0.2/zlib/configure
+@@ -3426,6 +3426,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/200-uclibc-locale.patch
new file mode 100644
index 0000000000..ac4cf97209
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/200-uclibc-locale.patch
@@ -0,0 +1,3237 @@
+diff -urN gcc-4.0.0-100/libstdc++-v3/acinclude.m4 gcc-4.0.0/libstdc++-v3/acinclude.m4
+--- gcc-4.0.0-100/libstdc++-v3/acinclude.m4 2005-04-30 13:06:53.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/acinclude.m4 2005-04-28 20:19:01.000000000 -0500
+@@ -1104,7 +1104,7 @@
+ AC_MSG_CHECKING([for C locale to use])
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # If they didn't use this option switch, or if they specified --enable
+ # with no specific model, we'll have to look for one. If they
+@@ -1120,6 +1120,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1263,6 +1266,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c++locale_internal.h gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,59 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#endif // GLIBC 2.3 and later
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c_locale.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c_locale.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c_locale.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c_locale.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c_locale.h gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c_locale.h
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/c_locale.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/c_locale.h 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,115 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out, const int __size, const char* __fmt,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/codecvt_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/codecvt_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/codecvt_members.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/collate_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/collate_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/collate_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/collate_members.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/ctype_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/ctype_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/messages_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/messages_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/messages_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/messages_members.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.0.0/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/messages_members.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/messages_members.h 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/monetary_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/monetary_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2005-04-28 01:23:02.000000000 -0500
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ __ret = pattern();
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/numeric_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/numeric_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2005-04-28 01:20:20.000000000 -0500
+@@ -0,0 +1,173 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/time_members.cc gcc-4.0.0/libstdc++-v3/config/locale/uclibc/time_members.cc
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/time_members.cc 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/time_members.cc 2005-04-28 01:13:15.000000000 -0500
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.0.0/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-4.0.0-100/libstdc++-v3/config/locale/uclibc/time_members.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/locale/uclibc/time_members.h 2004-05-22 18:46:31.000000000 -0500
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_base.h gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_base.h
+--- gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_base.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_base.h 2005-04-28 01:10:27.000000000 -0500
+@@ -0,0 +1,64 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++/** @file ctype_base.h
++ * This is an internal header file, included by other library headers.
++ * You should not attempt to use it directly.
++ */
++
++// Information as gleaned from /usr/include/ctype.h
++
++ /// @brief Base class for ctype.
++ struct ctype_base
++ {
++ // Note: In uClibc, the following two types depend on configuration.
++
++ // Non-standard typedefs.
++ typedef const __ctype_touplow_t* __to_type;
++
++ // NB: Offsets into ctype<char>::_M_table force a particular size
++ // on the mask type. Because of this, we don't use an enum.
++ typedef __ctype_mask_t mask;
++ static const mask upper = _ISupper;
++ static const mask lower = _ISlower;
++ static const mask alpha = _ISalpha;
++ static const mask digit = _ISdigit;
++ static const mask xdigit = _ISxdigit;
++ static const mask space = _ISspace;
++ static const mask print = _ISprint;
++ static const mask graph = _ISalpha | _ISdigit | _ISpunct;
++ static const mask cntrl = _IScntrl;
++ static const mask punct = _ISpunct;
++ static const mask alnum = _ISalpha | _ISdigit;
++ };
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_inline.h gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_inline.h
+--- gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_inline.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_inline.h 2002-06-24 00:49:19.000000000 -0500
+@@ -0,0 +1,69 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
++// functions go in ctype.cc
++
++ bool
++ ctype<char>::
++ is(mask __m, char __c) const
++ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
++
++ const char*
++ ctype<char>::
++ is(const char* __low, const char* __high, mask* __vec) const
++ {
++ while (__low < __high)
++ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
++ return __high;
++ }
++
++ const char*
++ ctype<char>::
++ scan_is(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++ ++__low;
++ return __low;
++ }
++
++ const char*
++ ctype<char>::
++ scan_not(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++ ++__low;
++ return __low;
++ }
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_noninline.h gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_noninline.h
+--- gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/ctype_noninline.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/os/uclibc/ctype_noninline.h 2005-04-28 01:10:27.000000000 -0500
+@@ -0,0 +1,92 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// Information as gleaned from /usr/include/ctype.h
++
++ const ctype_base::mask*
++ ctype<char>::classic_table() throw()
++ { return __C_ctype_b; }
++
++ ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ char
++ ctype<char>::do_toupper(char __c) const
++ { return _M_toupper[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_toupper(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
++
++ char
++ ctype<char>::do_tolower(char __c) const
++ { return _M_tolower[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_tolower(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
+diff -urN gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/os_defines.h gcc-4.0.0/libstdc++-v3/config/os/uclibc/os_defines.h
+--- gcc-4.0.0-100/libstdc++-v3/config/os/uclibc/os_defines.h 1969-12-31 18:00:00.000000000 -0600
++++ gcc-4.0.0/libstdc++-v3/config/os/uclibc/os_defines.h 2005-04-28 01:10:27.000000000 -0500
+@@ -0,0 +1,44 @@
++// Specific definitions for GNU/Linux -*- C++ -*-
++
++// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++#ifndef _GLIBCXX_OS_DEFINES
++#define _GLIBCXX_OS_DEFINES 1
++
++// System-specific #define, typedefs, corrections, etc, go here. This
++// file will come before all others.
++
++// This keeps isanum, et al from being propagated as macros.
++#define __NO_CTYPE 1
++
++#include <features.h>
++
++// We must not see the optimized string functions GNU libc defines.
++#define __NO_STRING_INLINES
++
++#endif
+diff -urN gcc-4.0.0-100/libstdc++-v3/configure gcc-4.0.0/libstdc++-v3/configure
+--- gcc-4.0.0-100/libstdc++-v3/configure 2005-04-30 13:06:53.683055232 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 12:24:24.000000000 -0500
+@@ -3998,6 +3998,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5672,7 +5677,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5697,6 +5702,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -5927,6 +5935,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+diff -urN gcc-4.0.0-100/libstdc++-v3/configure.host gcc-4.0.0/libstdc++-v3/configure.host
+--- gcc-4.0.0-100/libstdc++-v3/configure.host 2005-04-30 13:06:53.688054472 -0500
++++ gcc-4.0.0/libstdc++-v3/configure.host 2005-04-28 20:20:32.000000000 -0500
+@@ -249,6 +249,12 @@
+ ;;
+ esac
+
++# Override for uClibc since linux-uclibc gets mishandled above.
++case "${host_os}" in
++ *-uclibc*)
++ os_include_dir="os/uclibc"
++ ;;
++esac
+
+ # Set any OS-dependent and CPU-dependent bits.
+ # THIS TABLE IS SORTED. KEEP IT THAT WAY.
+diff -urN gcc-4.0.0-100/libstdc++-v3/crossconfig.m4 gcc-4.0.0/libstdc++-v3/crossconfig.m4
+--- gcc-4.0.0-100/libstdc++-v3/crossconfig.m4 2005-04-30 13:06:53.689054320 -0500
++++ gcc-4.0.0/libstdc++-v3/crossconfig.m4 2005-04-28 20:27:15.000000000 -0500
+@@ -142,6 +142,98 @@
+ ;;
+ esac
+ ;;
++ *-uclibc*)
++# Temporary hack until we implement the float versions of the libm funcs
++ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
++ machine/endian.h machine/param.h sys/machine.h sys/types.h \
++ fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
++ SECTION_FLAGS='-ffunction-sections -fdata-sections'
++ AC_SUBST(SECTION_FLAGS)
++ GLIBCXX_CHECK_LINKER_FEATURES
++ GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
++ GLIBCXX_CHECK_WCHAR_T_SUPPORT
++
++ # For LFS.
++ AC_DEFINE(HAVE_INT64_T)
++ case "$target" in
++ *-uclinux*)
++ # Don't enable LFS with uClinux
++ ;;
++ *)
++ AC_DEFINE(_GLIBCXX_USE_LFS)
++ esac
++
++ # For showmanyc_helper().
++ AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
++ GLIBCXX_CHECK_POLL
++ GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
++
++ # For xsputn_2().
++ AC_CHECK_HEADERS(sys/uio.h)
++ GLIBCXX_CHECK_WRITEV
++
++# AC_DEFINE(HAVE_ACOSF)
++# AC_DEFINE(HAVE_ASINF)
++# AC_DEFINE(HAVE_ATANF)
++# AC_DEFINE(HAVE_ATAN2F)
++ AC_DEFINE(HAVE_CEILF)
++ AC_DEFINE(HAVE_COPYSIGN)
++# AC_DEFINE(HAVE_COPYSIGNF)
++# AC_DEFINE(HAVE_COSF)
++# AC_DEFINE(HAVE_COSHF)
++# AC_DEFINE(HAVE_EXPF)
++# AC_DEFINE(HAVE_FABSF)
++ AC_DEFINE(HAVE_FINITE)
++ AC_DEFINE(HAVE_FINITEF)
++ AC_DEFINE(HAVE_FLOORF)
++# AC_DEFINE(HAVE_FMODF)
++# AC_DEFINE(HAVE_FREXPF)
++ AC_DEFINE(HAVE_HYPOT)
++# AC_DEFINE(HAVE_HYPOTF)
++ AC_DEFINE(HAVE_ISINF)
++ AC_DEFINE(HAVE_ISINFF)
++ AC_DEFINE(HAVE_ISNAN)
++ AC_DEFINE(HAVE_ISNANF)
++# AC_DEFINE(HAVE_LOGF)
++# AC_DEFINE(HAVE_LOG10F)
++# AC_DEFINE(HAVE_MODFF)
++# AC_DEFINE(HAVE_SINF)
++# AC_DEFINE(HAVE_SINHF)
++# AC_DEFINE(HAVE_SINCOS)
++# AC_DEFINE(HAVE_SINCOSF)
++ AC_DEFINE(HAVE_SQRTF)
++# AC_DEFINE(HAVE_TANF)
++# AC_DEFINE(HAVE_TANHF)
++ if test x"long_double_math_on_this_cpu" = x"yes"; then
++# AC_DEFINE(HAVE_ACOSL)
++# AC_DEFINE(HAVE_ASINL)
++# AC_DEFINE(HAVE_ATANL)
++# AC_DEFINE(HAVE_ATAN2L)
++# AC_DEFINE(HAVE_CEILL)
++# AC_DEFINE(HAVE_COPYSIGNL)
++# AC_DEFINE(HAVE_COSL)
++# AC_DEFINE(HAVE_COSHL)
++# AC_DEFINE(HAVE_EXPL)
++# AC_DEFINE(HAVE_FABSL)
++# AC_DEFINE(HAVE_FINITEL)
++# AC_DEFINE(HAVE_FLOORL)
++# AC_DEFINE(HAVE_FMODL)
++# AC_DEFINE(HAVE_FREXPL)
++# AC_DEFINE(HAVE_HYPOTL)
++# AC_DEFINE(HAVE_ISINFL)
++# AC_DEFINE(HAVE_ISNANL)
++# AC_DEFINE(HAVE_LOGL)
++# AC_DEFINE(HAVE_LOG10L)
++# AC_DEFINE(HAVE_MODFL)
++# AC_DEFINE(HAVE_POWL)
++# AC_DEFINE(HAVE_SINL)
++# AC_DEFINE(HAVE_SINHL)
++# AC_DEFINE(HAVE_SINCOSL)
++# AC_DEFINE(HAVE_SQRTL)
++# AC_DEFINE(HAVE_TANL)
++# AC_DEFINE(HAVE_TANHL)
++ fi
++ ;;
+ *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu)
+ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
+ machine/endian.h machine/param.h sys/machine.h sys/types.h \
+@@ -156,7 +248,7 @@
+ AC_DEFINE(HAVE_INT64_T)
+ case "$target" in
+ *-uclinux*)
+- # Don't enable LFS with uClibc
++ # Don't enable LFS with uClinux
+ ;;
+ *)
+ AC_DEFINE(_GLIBCXX_USE_LFS)
+diff -urN gcc-4.0.0-100/libstdc++-v3/include/c_compatibility/wchar.h gcc-4.0.0/libstdc++-v3/include/c_compatibility/wchar.h
+--- gcc-4.0.0-100/libstdc++-v3/include/c_compatibility/wchar.h 2005-04-30 13:06:53.690054168 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_compatibility/wchar.h 2005-04-28 20:15:56.000000000 -0500
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+diff -urN gcc-4.0.0-100/libstdc++-v3/include/c_std/std_cwchar.h gcc-4.0.0/libstdc++-v3/include/c_std/std_cwchar.h
+--- gcc-4.0.0-100/libstdc++-v3/include/c_std/std_cwchar.h 2005-04-30 13:06:53.691054016 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cwchar.h 2005-04-28 20:15:56.000000000 -0500
+@@ -179,7 +179,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..a9d6e7185f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/300-libstdc++-pic.patch
@@ -0,0 +1,45 @@
+--- gcc-4.0.0/libstdc++-v3/src/Makefile.am
++++ gcc-4.0.0/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,10 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc-4.0.0/libstdc++-v3/src/Makefile.in
++++ gcc-4.0.0/libstdc++-v3/src/Makefile.in
+@@ -625,7 +625,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -664,7 +664,7 @@
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-info-am \
+- uninstall-toolexeclibLTLIBRARIES
++ uninstall-toolexeclibLTLIBRARIES install-exec-local
+
+ @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@libstdc++-symbol.ver: ${glibcxx_srcdir}/$(SYMVER_MAP)
+ @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@ cp ${glibcxx_srcdir}/$(SYMVER_MAP) ./libstdc++-symbol.ver
+@@ -743,6 +743,11 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/304-index_macro.patch
new file mode 100644
index 0000000000..1fac112fa9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ namespace __gnu_cxx
+ {
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..89196d9fa5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.4.orig/gcc/Makefile.in 2007-02-12 11:35:43.000000000 +0100
++++ gcc-4.0.4/gcc/Makefile.in 2007-02-12 11:38:04.000000000 +0100
+@@ -2202,7 +2202,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H)
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h
++ insn-attr.h gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/602-sdk-libstdc++-includes.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/602-sdk-libstdc++-includes.patch
new file mode 100644
index 0000000000..c7676ae6a2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/602-sdk-libstdc++-includes.patch
@@ -0,0 +1,22 @@
+diff -urN gcc-4.0.0-100/libstdc++-v3/fragment.am gcc-4.0.0/libstdc++-v3/fragment.am
+--- gcc-4.0.0-100/libstdc++-v3/fragment.am 2004-10-25 15:32:40.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/fragment.am 2005-04-28 21:48:43.000000000 -0500
+@@ -18,5 +18,5 @@
+ $(WARN_FLAGS) $(WERROR) -fdiagnostics-show-location=once
+
+ # -I/-D flags to pass when compiling.
+-AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
++AM_CPPFLAGS = $(GLIBCXX_INCLUDES) -I$(toplevel_srcdir)/include
+
+diff -urN gcc-4.0.0-100/libstdc++-v3/libmath/Makefile.am gcc-4.0.0/libstdc++-v3/libmath/Makefile.am
+--- gcc-4.0.0-100/libstdc++-v3/libmath/Makefile.am 2003-08-27 16:29:42.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/libmath/Makefile.am 2005-04-28 21:48:43.000000000 -0500
+@@ -32,7 +32,7 @@
+
+ libmath_la_SOURCES = stubs.c
+
+-AM_CPPFLAGS = $(CANADIAN_INCLUDES)
++AM_CPPFLAGS = $(CANADIAN_INCLUDES) -I$(toplevel_srcdir)/include
+
+ # Only compiling "C" sources in this directory.
+ LIBTOOL = @LIBTOOL@ --tag CC
diff --git a/cleopatre/buildroot/toolchain/gcc/4.0.4/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.0.4/800-arm-bigendian.patch
new file mode 100644
index 0000000000..307aea3ea3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.0.4/800-arm-bigendian.patch
@@ -0,0 +1,67 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-4.0.3/gcc/config/arm/linux-elf.h
++++ gcc-4.0.3/gcc/config/arm/linux-elf.h
+@@ -31,19 +31,33 @@
+ /* Do not assume anything about header files. */
+ #define NO_IMPLICIT_EXTERN_C
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT ARM_FLAG_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* The GNU C++ standard library requires that these macros be defined. */
+ #undef CPLUSPLUS_CPP_SPEC
+@@ -90,7 +104,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #define TARGET_OS_CPP_BUILTINS() \
+--- gcc-4.0.3/gcc/config.gcc
++++ gcc-4.0.3/gcc/config.gcc
+@@ -672,6 +672,11 @@
+ ;;
+ arm*-*-linux*) # ARM GNU/Linux with ELF
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h arm/aout.h arm/arm.h"
++ case $target in
++ arm*b-*)
++ tm_defines="TARGET_BIG_ENDIAN_DEFAULT=1 $tm_defines"
++ ;;
++ esac
+ tmake_file="${tmake_file} arm/t-arm arm/t-linux"
+ extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+ gnu_ld=yes
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/100-uclibc-conf.patch
new file mode 100644
index 0000000000..49d576c7dd
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/100-uclibc-conf.patch
@@ -0,0 +1,544 @@
+--- gcc-4.1.0/gcc/config/t-linux-uclibc
++++ gcc-4.1.0/gcc/config/t-linux-uclibc
+@@ -0,0 +1,5 @@
++# Remove glibc specific files added in t-linux
++SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES))
++
++# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc
++LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH))
+--- gcc-4.1.0/gcc/config.gcc
++++ gcc-4.1.0/gcc/config.gcc
+@@ -1887,7 +1887,7 @@ s390x-ibm-tpf*)
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
+@@ -2341,6 +2341,12 @@ m32c-*-elf*)
+ ;;
+ esac
+
++# Rather than hook into each target, just do it after all the linux
++# targets have been processed
++case ${target} in
++*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc"
++esac
++
+ case ${target} in
+ i[34567]86-*-linux*aout* | i[34567]86-*-linux*libc1)
+ tmake_file="${tmake_file} i386/t-gmm_malloc"
+--- gcc-4.1.0/boehm-gc/configure
++++ gcc-4.1.0/boehm-gc/configure
+@@ -4320,6 +4320,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/configure
++++ gcc-4.1.0/configure
+@@ -1133,7 +1133,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+--- gcc-4.1.0/configure.in
++++ gcc-4.1.0/configure.in
+@@ -341,7 +341,7 @@ no)
+ ;;
+ "")
+ case "${target}" in
+- *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
++ *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
+ # Enable libmudflap by default in GNU and friends.
+ ;;
+ *-*-freebsd*)
+--- gcc-4.1.0/contrib/regression/objs-gcc.sh
++++ gcc-4.1.0/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc-4.1.0/gcc/config/alpha/linux-elf.h
++++ gcc-4.1.0/gcc/config/alpha/linux-elf.h
+@@ -27,7 +27,11 @@ Boston, MA 02110-1301, USA. */
+ #define SUBTARGET_EXTRA_SPECS \
+ { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
+
++#if defined USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
+ #define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+
+ #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+--- gcc-4.1.0/gcc/config/arm/linux-elf.h
++++ gcc-4.1.0/gcc/config/arm/linux-elf.h
+@@ -51,7 +51,11 @@
+
+ #define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
+
++#ifdef USE_UCLIBC
++#define LINUX_TARGET_INTERPRETER "/lib/ld-uClibc.so.0"
++#else
+ #define LINUX_TARGET_INTERPRETER "/lib/ld-linux.so.2"
++#endif
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
+ %{b} \
+--- gcc-4.1.0/gcc/config/cris/linux.h
++++ gcc-4.1.0/gcc/config/cris/linux.h
+@@ -73,6 +73,25 @@ Boston, MA 02110-1301, USA. */
+ #undef CRIS_DEFAULT_CPU_VERSION
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
++#ifdef USE_UCLIBC
++
++#undef CRIS_SUBTARGET_VERSION
++#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++
++#undef CRIS_LINK_SUBTARGET_SPEC
++#define CRIS_LINK_SUBTARGET_SPEC \
++ "-mcrislinux\
++ -rpath-link include/asm/../..%s\
++ %{shared} %{static}\
++ %{symbolic:-Bdynamic} %{shlib:-Bdynamic} %{static:-Bstatic}\
++ %{!shared: \
++ %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}} \
++ %{!r:%{O2|O3: --gc-sections}}"
++
++#else /* USE_UCLIBC */
++
+ #undef CRIS_SUBTARGET_VERSION
+ #define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
+
+@@ -87,6 +106,8 @@ Boston, MA 02110-1301, USA. */
+ %{!shared:%{!static:%{rdynamic:-export-dynamic}}}\
+ %{!r:%{O2|O3: --gc-sections}}"
+
++#endif /* USE_UCLIBC */
++
+
+ /* Node: Run-time Target */
+
+--- gcc-4.1.0/gcc/config/i386/linux.h
++++ gcc-4.1.0/gcc/config/i386/linux.h
+@@ -107,6 +107,11 @@ Boston, MA 02110-1301, USA. */
+ #define LINK_EMULATION "elf_i386"
+ #define DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
++#if defined USE_UCLIBC
++#undef DYNAMIC_LINKER
++#define DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#endif
++
+ #undef SUBTARGET_EXTRA_SPECS
+ #define SUBTARGET_EXTRA_SPECS \
+ { "link_emulation", LINK_EMULATION },\
+--- gcc-4.1.0/gcc/config/i386/linux64.h
++++ gcc-4.1.0/gcc/config/i386/linux64.h
+@@ -54,14 +54,21 @@ Boston, MA 02110-1301, USA. */
+ When the -shared link option is used a final link is not being
+ done. */
+
++#ifdef USE_UCLIBC
++#define ELF32_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF32_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define ELF64_DYNAMIC_LINKER "/lib64/ld-linux-x86-64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
+- %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
++ %{m32:%{!dynamic-linker:-dynamic-linker " ELF32_DYNAMIC_LINKER "}} \
++ %{!m32:%{!dynamic-linker:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}} \
+ %{static:-static}}"
+
+ /* Similar to standard Linux, but adding -ffast-math support. */
+--- gcc-4.1.0/gcc/config/ia64/linux.h
++++ gcc-4.1.0/gcc/config/ia64/linux.h
+@@ -37,13 +37,18 @@ do { \
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+
+--- gcc-4.1.0/gcc/config/m68k/linux.h
++++ gcc-4.1.0/gcc/config/m68k/linux.h
+@@ -123,12 +123,17 @@ Boston, MA 02110-1301, USA. */
+
+ /* If ELF is the default format, we should not use /lib/elf. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m m68kelf %{shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker*:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static}}"
+
+ /* For compatibility with linux/a.out */
+--- gcc-4.1.0/gcc/config/mips/linux.h
++++ gcc-4.1.0/gcc/config/mips/linux.h
+@@ -105,6 +105,11 @@ Boston, MA 02110-1301, USA. */
+
+ /* Borrowed from sparc/linux.h */
+ #undef LINK_SPEC
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #define LINK_SPEC \
+ "%(endian_spec) \
+ %{shared:-shared} \
+@@ -112,7 +117,7 @@ Boston, MA 02110-1301, USA. */
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+
+ #undef SUBTARGET_ASM_SPEC
+--- gcc-4.1.0/gcc/config/pa/pa-linux.h
++++ gcc-4.1.0/gcc/config/pa/pa-linux.h
+@@ -49,13 +49,18 @@ Boston, MA 02110-1301, USA. */
+ /* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}"
+
+ /* glibc's profiling functions don't need gcc to allocate counters. */
+--- gcc-4.1.0/gcc/config/rs6000/linux.h
++++ gcc-4.1.0/gcc/config/rs6000/linux.h
+@@ -72,7 +72,11 @@
+ #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
+
+ #undef LINK_OS_DEFAULT_SPEC
++#ifdef USE_UCLIBC
++#define LINK_OS_DEFAULT_SPEC "%(link_os_linux_uclibc)"
++#else
+ #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
++#endif
+
+ #define LINK_GCC_C_SEQUENCE_SPEC \
+ "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
+--- gcc-4.1.0/gcc/config/rs6000/sysv4.h
++++ gcc-4.1.0/gcc/config/rs6000/sysv4.h
+@@ -866,6 +866,7 @@ extern int fixuplabelno;
+ mcall-linux : %(link_os_linux) ; \
+ mcall-gnu : %(link_os_gnu) ; \
+ mcall-netbsd : %(link_os_netbsd) ; \
++ mcall-linux-uclibc : %(link_os_linux_uclibc); \
+ mcall-openbsd: %(link_os_openbsd) ; \
+ : %(link_os_default) }"
+
+@@ -1043,6 +1044,10 @@ extern int fixuplabelno;
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
+
++#define LINK_OS_LINUX_UCLIBC_SPEC "-m elf32ppclinux %{!shared: %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}}"
++
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+ # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+ #endif
+@@ -1209,6 +1214,7 @@ ncrtn.o%s"
+ { "link_os_sim", LINK_OS_SIM_SPEC }, \
+ { "link_os_freebsd", LINK_OS_FREEBSD_SPEC }, \
+ { "link_os_linux", LINK_OS_LINUX_SPEC }, \
++ { "link_os_linux_uclibc", LINK_OS_LINUX_UCLIBC_SPEC }, \
+ { "link_os_gnu", LINK_OS_GNU_SPEC }, \
+ { "link_os_netbsd", LINK_OS_NETBSD_SPEC }, \
+ { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
+--- gcc-4.1.0/gcc/config/s390/linux.h
++++ gcc-4.1.0/gcc/config/s390/linux.h
+@@ -77,6 +77,13 @@ Software Foundation, 51 Franklin Street,
+ #define MULTILIB_DEFAULTS { "m31" }
+ #endif
+
++#ifdef USE_UCLIBC
++#define ELF31_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
++#else
++#define ELF31_DYNAMIC_LINKER "/lib/ld.so.1"
++#define ELF64_DYNAMIC_LINKER "/lib/ld64.so.1"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+ "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
+@@ -86,8 +93,8 @@ Software Foundation, 51 Franklin Street,
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker: \
+- %{m31:-dynamic-linker /lib/ld.so.1} \
+- %{m64:-dynamic-linker /lib/ld64.so.1}}}}"
++ %{m31:-dynamic-linker " ELF31_DYNAMIC_LINKER "} \
++ %{m64:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}}}"
+
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+--- gcc-4.1.0/gcc/config/sh/linux.h
++++ gcc-4.1.0/gcc/config/sh/linux.h
+@@ -56,12 +56,21 @@ Boston, MA 02110-1301, USA. */
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
+ #undef SUBTARGET_LINK_SPEC
++#ifdef USE_UCLIBC
++#define SUBTARGET_LINK_SPEC \
++ "%{shared:-shared} \
++ %{!static: \
++ %{rdynamic:-export-dynamic} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}} \
++ %{static:-static}"
++#else
+ #define SUBTARGET_LINK_SPEC \
+ "%{shared:-shared} \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
+ %{static:-static}"
++#endif
+
+ /* Output assembler code to STREAM to call the profiler. */
+
+--- gcc-4.1.0/gcc/config/sparc/linux.h
++++ gcc-4.1.0/gcc/config/sparc/linux.h
+@@ -125,6 +125,11 @@ Boston, MA 02110-1301, USA. */
+
+ /* If ELF is the default format, we should not use /lib/elf. */
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!mno-relax:%{!r:-relax}} \
+@@ -132,7 +137,7 @@ Boston, MA 02110-1301, USA. */
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}}"
+
+ /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
+--- gcc-4.1.0/gcc/config/sparc/linux64.h
++++ gcc-4.1.0/gcc/config/sparc/linux64.h
+@@ -162,12 +162,17 @@ Boston, MA 02110-1301, USA. */
+ { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
+ { "link_arch", LINK_ARCH_SPEC },
+
++#ifdef USE_UCLIBC
++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#else
++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#endif
+ #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+ %{!shared: \
+ %{!ibcs: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
++ %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
+ %{static:-static}}} \
+ "
+
+--- gcc-4.1.0/libffi/configure
++++ gcc-4.1.0/libffi/configure
+@@ -3457,6 +3457,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/libgfortran/configure
++++ gcc-4.1.0/libgfortran/configure
+@@ -3699,6 +3699,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/libjava/configure
++++ gcc-4.1.0/libjava/configure
+@@ -5137,6 +5137,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/libmudflap/configure
++++ gcc-4.1.0/libmudflap/configure
+@@ -5382,6 +5382,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/libobjc/configure
++++ gcc-4.1.0/libobjc/configure
+@@ -3312,6 +3312,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gcc-4.1.0/libtool.m4
++++ gcc-4.1.0/libtool.m4
+@@ -743,6 +743,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+--- gcc-4.1.0/ltconfig
++++ gcc-4.1.0/ltconfig
+@@ -603,6 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
++linux-uclibc*) ;;
+ linux-gnu*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+@@ -1274,6 +1275,23 @@ linux-gnu*)
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- gcc-4.1.0/zlib/configure
++++ gcc-4.1.0/zlib/configure
+@@ -3426,6 +3426,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/110-arm-eabi.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/110-arm-eabi.patch
new file mode 100644
index 0000000000..acebe5308f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/110-arm-eabi.patch
@@ -0,0 +1,27 @@
+--- gcc-2005q3-1.orig/gcc/config.gcc 2005-10-31 19:02:54.000000000 +0300
++++ gcc-2005q3-1/gcc/config.gcc 2006-01-27 01:09:09.000000000 +0300
+@@ -674,7 +674,7 @@
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+ tmake_file="t-slibgcc-elf-ver t-linux arm/t-arm"
+ case ${target} in
+- arm*-*-linux-gnueabi)
++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
+ # The BPABI long long divmod functions return a 128-bit value in
+
+diff -urN gcc-2005q3-2/gcc/config/arm/linux-eabi.h gcc-2005q3-2.new/gcc/config/arm/linux-eabi.h
+--- gcc-2005q3-2/gcc/config/arm/linux-eabi.h 2005-12-07 23:14:16.000000000 +0300
++++ gcc-2005q3-2.new/gcc/config/arm/linux-eabi.h 2006-03-29 19:02:34.000000000 +0400
+@@ -53,7 +53,11 @@
+ /* Use ld-linux.so.3 so that it will be possible to run "classic"
+ GNU/Linux binaries on an EABI system. */
+ #undef LINUX_TARGET_INTERPRETER
++#ifdef USE_UCLIBC
++#define LINUX_TARGET_INTERPRETER "/lib/ld-uClibc.so.0"
++#else
+ #define LINUX_TARGET_INTERPRETER "/lib/ld-linux.so.3"
++#endif
+
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/200-uclibc-locale.patch
new file mode 100644
index 0000000000..e5d712e723
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/200-uclibc-locale.patch
@@ -0,0 +1,3239 @@
+--- gcc-4.1.0-dist/libstdc++-v3/acinclude.m4
++++ gcc-4.1.0/libstdc++-v3/acinclude.m4
+@@ -1071,7 +1071,7 @@
+ AC_MSG_CHECKING([for C locale to use])
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # If they didn't use this option switch, or if they specified --enable
+ # with no specific model, we'll have to look for one. If they
+@@ -1087,6 +1087,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1230,6 +1233,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+@@ -0,0 +1,63 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <bits/c++config.h>
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++#endif
++
++#endif // GLIBC 2.3 and later
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/c_locale.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/c_locale.cc
+@@ -0,0 +1,152 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (__cloc && _S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/c_locale.h
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/c_locale.h
+@@ -0,0 +1,117 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out,
++ const int __size __attribute__ ((__unused__)),
++ const char* __fmt,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/collate_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/collate_members.cc
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/ctype_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+@@ -0,0 +1,314 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // The case of __m == ctype_base::space is particularly important,
++ // due to its use in many istream functions. Therefore we deal with
++ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
++ // is the mask corresponding to ctype_base::space. NB: an encoding
++ // change would not affect correctness!
++ bool __ret = false;
++ if (__m == _M_bit[5])
++ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
++ else
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur])
++ {
++ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ else if (__m == _M_bit[__bitcur])
++ break;
++ }
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/messages_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/messages_members.cc
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/messages_members.h
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/messages_members.h
+@@ -0,0 +1,121 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
++ {
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
++ _M_name_messages = __tmp;
++
++ // Last to avoid leaking memory if new throws.
++ _M_c_locale_messages = _S_clone_c_locale(__cloc);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/monetary_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ __ret = pattern();
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/numeric_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+@@ -0,0 +1,173 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/time_members.cc
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/time_members.cc
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+--- gcc-4.1.0-dist/libstdc++-v3/config/locale/uclibc/time_members.h
++++ gcc-4.1.0/libstdc++-v3/config/locale/uclibc/time_members.h
+@@ -0,0 +1,76 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(NULL)
++ {
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
++ _M_name_timepunct = __tmp;
++
++ try
++ { _M_initialize_timepunct(__cloc); }
++ catch(...)
++ {
++ delete [] _M_name_timepunct;
++ __throw_exception_again;
++ }
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+--- gcc-4.1.0-dist/libstdc++-v3/config/os/uclibc/ctype_base.h
++++ gcc-4.1.0/libstdc++-v3/config/os/uclibc/ctype_base.h
+@@ -0,0 +1,64 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++/** @file ctype_base.h
++ * This is an internal header file, included by other library headers.
++ * You should not attempt to use it directly.
++ */
++
++// Information as gleaned from /usr/include/ctype.h
++
++ /// @brief Base class for ctype.
++ struct ctype_base
++ {
++ // Note: In uClibc, the following two types depend on configuration.
++
++ // Non-standard typedefs.
++ typedef const __ctype_touplow_t* __to_type;
++
++ // NB: Offsets into ctype<char>::_M_table force a particular size
++ // on the mask type. Because of this, we don't use an enum.
++ typedef __ctype_mask_t mask;
++ static const mask upper = _ISupper;
++ static const mask lower = _ISlower;
++ static const mask alpha = _ISalpha;
++ static const mask digit = _ISdigit;
++ static const mask xdigit = _ISxdigit;
++ static const mask space = _ISspace;
++ static const mask print = _ISprint;
++ static const mask graph = _ISalpha | _ISdigit | _ISpunct;
++ static const mask cntrl = _IScntrl;
++ static const mask punct = _ISpunct;
++ static const mask alnum = _ISalpha | _ISdigit;
++ };
+--- gcc-4.1.0-dist/libstdc++-v3/config/os/uclibc/ctype_inline.h
++++ gcc-4.1.0/libstdc++-v3/config/os/uclibc/ctype_inline.h
+@@ -0,0 +1,69 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
++// functions go in ctype.cc
++
++ bool
++ ctype<char>::
++ is(mask __m, char __c) const
++ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
++
++ const char*
++ ctype<char>::
++ is(const char* __low, const char* __high, mask* __vec) const
++ {
++ while (__low < __high)
++ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
++ return __high;
++ }
++
++ const char*
++ ctype<char>::
++ scan_is(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++ ++__low;
++ return __low;
++ }
++
++ const char*
++ ctype<char>::
++ scan_not(mask __m, const char* __low, const char* __high) const
++ {
++ while (__low < __high
++ && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++ ++__low;
++ return __low;
++ }
+--- gcc-4.1.0-dist/libstdc++-v3/config/os/uclibc/ctype_noninline.h
++++ gcc-4.1.0/libstdc++-v3/config/os/uclibc/ctype_noninline.h
+@@ -0,0 +1,92 @@
++// Locale support -*- C++ -*-
++
++// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
++// Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.1 Locales
++//
++
++// Information as gleaned from /usr/include/ctype.h
++
++ const ctype_base::mask*
++ ctype<char>::classic_table() throw()
++ { return __C_ctype_b; }
++
++ ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
++ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
++ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
++ {
++ _M_toupper = __C_ctype_toupper;
++ _M_tolower = __C_ctype_tolower;
++ _M_table = __table ? __table : __C_ctype_b;
++ memset(_M_widen, 0, sizeof(_M_widen));
++ memset(_M_narrow, 0, sizeof(_M_narrow));
++ }
++
++ char
++ ctype<char>::do_toupper(char __c) const
++ { return _M_toupper[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_toupper(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
++
++ char
++ ctype<char>::do_tolower(char __c) const
++ { return _M_tolower[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<char>::do_tolower(char* __low, const char* __high) const
++ {
++ while (__low < __high)
++ {
++ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++ ++__low;
++ }
++ return __high;
++ }
+--- gcc-4.1.0-dist/libstdc++-v3/config/os/uclibc/os_defines.h
++++ gcc-4.1.0/libstdc++-v3/config/os/uclibc/os_defines.h
+@@ -0,0 +1,44 @@
++// Specific definitions for GNU/Linux -*- C++ -*-
++
++// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++#ifndef _GLIBCXX_OS_DEFINES
++#define _GLIBCXX_OS_DEFINES 1
++
++// System-specific #define, typedefs, corrections, etc, go here. This
++// file will come before all others.
++
++// This keeps isanum, et al from being propagated as macros.
++#define __NO_CTYPE 1
++
++#include <features.h>
++
++// We must not see the optimized string functions GNU libc defines.
++#define __NO_STRING_INLINES
++
++#endif
+--- gcc-4.1.0-dist/libstdc++-v3/configure
++++ gcc-4.1.0/libstdc++-v3/configure
+@@ -4005,6 +4005,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5740,7 +5745,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5765,6 +5770,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -5995,6 +6003,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc-4.1.0-dist/libstdc++-v3/configure.host
++++ gcc-4.1.0/libstdc++-v3/configure.host
+@@ -261,6 +261,12 @@
+ ;;
+ esac
+
++# Override for uClibc since linux-uclibc gets mishandled above.
++case "${host_os}" in
++ *-uclibc*)
++ os_include_dir="os/uclibc"
++ ;;
++esac
+
+ # Set any OS-dependent and CPU-dependent bits.
+ # THIS TABLE IS SORTED. KEEP IT THAT WAY.
+--- gcc-4.1.0-dist/libstdc++-v3/crossconfig.m4
++++ gcc-4.1.0/libstdc++-v3/crossconfig.m4
+@@ -143,6 +143,99 @@
+ ;;
+ esac
+ ;;
++ *-uclibc*)
++# Temporary hack until we implement the float versions of the libm funcs
++ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
++ machine/endian.h machine/param.h sys/machine.h sys/types.h \
++ fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
++ SECTION_FLAGS='-ffunction-sections -fdata-sections'
++ AC_SUBST(SECTION_FLAGS)
++ GLIBCXX_CHECK_LINKER_FEATURES
++ GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
++ GLIBCXX_CHECK_WCHAR_T_SUPPORT
++
++ # For LFS.
++ AC_DEFINE(HAVE_INT64_T)
++ case "$target" in
++ *-uclinux*)
++ # Don't enable LFS with uClinux
++ ;;
++ *)
++ AC_DEFINE(_GLIBCXX_USE_LFS)
++ esac
++
++ # For showmanyc_helper().
++ AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
++ GLIBCXX_CHECK_POLL
++ GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
++
++ # For xsputn_2().
++ AC_CHECK_HEADERS(sys/uio.h)
++ GLIBCXX_CHECK_WRITEV
++
++# AC_DEFINE(HAVE_ACOSF)
++# AC_DEFINE(HAVE_ASINF)
++# AC_DEFINE(HAVE_ATANF)
++# AC_DEFINE(HAVE_ATAN2F)
++ AC_DEFINE(HAVE_CEILF)
++ AC_DEFINE(HAVE_COPYSIGN)
++# AC_DEFINE(HAVE_COPYSIGNF)
++# AC_DEFINE(HAVE_COSF)
++# AC_DEFINE(HAVE_COSHF)
++# AC_DEFINE(HAVE_EXPF)
++# AC_DEFINE(HAVE_FABSF)
++ AC_DEFINE(HAVE_FINITE)
++ AC_DEFINE(HAVE_FINITEF)
++ AC_DEFINE(HAVE_FLOORF)
++# AC_DEFINE(HAVE_FMODF)
++# AC_DEFINE(HAVE_FREXPF)
++ AC_DEFINE(HAVE_HYPOT)
++# AC_DEFINE(HAVE_HYPOTF)
++ AC_DEFINE(HAVE_ISINF)
++ AC_DEFINE(HAVE_ISINFF)
++ AC_DEFINE(HAVE_ISNAN)
++ AC_DEFINE(HAVE_ISNANF)
++# AC_DEFINE(HAVE_LOGF)
++# AC_DEFINE(HAVE_LOG10F)
++# AC_DEFINE(HAVE_MODFF)
++# AC_DEFINE(HAVE_SINF)
++# AC_DEFINE(HAVE_SINHF)
++# AC_DEFINE(HAVE_SINCOS)
++# AC_DEFINE(HAVE_SINCOSF)
++ AC_DEFINE(HAVE_SQRTF)
++# AC_DEFINE(HAVE_TANF)
++# AC_DEFINE(HAVE_TANHF)
++ if test x"long_double_math_on_this_cpu" = x"yes"; then
++ AC_MSG_ERROR([long_double_math_on_this_cpu is yes!])
++# AC_DEFINE(HAVE_ACOSL)
++# AC_DEFINE(HAVE_ASINL)
++# AC_DEFINE(HAVE_ATANL)
++# AC_DEFINE(HAVE_ATAN2L)
++# AC_DEFINE(HAVE_CEILL)
++# AC_DEFINE(HAVE_COPYSIGNL)
++# AC_DEFINE(HAVE_COSL)
++# AC_DEFINE(HAVE_COSHL)
++# AC_DEFINE(HAVE_EXPL)
++# AC_DEFINE(HAVE_FABSL)
++# AC_DEFINE(HAVE_FINITEL)
++# AC_DEFINE(HAVE_FLOORL)
++# AC_DEFINE(HAVE_FMODL)
++# AC_DEFINE(HAVE_FREXPL)
++# AC_DEFINE(HAVE_HYPOTL)
++# AC_DEFINE(HAVE_ISINFL)
++# AC_DEFINE(HAVE_ISNANL)
++# AC_DEFINE(HAVE_LOGL)
++# AC_DEFINE(HAVE_LOG10L)
++# AC_DEFINE(HAVE_MODFL)
++# AC_DEFINE(HAVE_POWL)
++# AC_DEFINE(HAVE_SINL)
++# AC_DEFINE(HAVE_SINHL)
++# AC_DEFINE(HAVE_SINCOSL)
++# AC_DEFINE(HAVE_SQRTL)
++# AC_DEFINE(HAVE_TANL)
++# AC_DEFINE(HAVE_TANHL)
++ fi
++ ;;
+ *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu)
+ AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
+ machine/endian.h machine/param.h sys/machine.h sys/types.h \
+@@ -157,7 +250,7 @@
+ AC_DEFINE(HAVE_INT64_T)
+ case "$target" in
+ *-uclinux*)
+- # Don't enable LFS with uClibc
++ # Don't enable LFS with uClinux
+ ;;
+ *)
+ AC_DEFINE(_GLIBCXX_USE_LFS)
+--- gcc-4.1.0-dist/libstdc++-v3/include/c_compatibility/wchar.h
++++ gcc-4.1.0/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+--- gcc-4.1.0-dist/libstdc++-v3/include/c_std/std_cwchar.h
++++ gcc-4.1.0/libstdc++-v3/include/c_std/std_cwchar.h
+@@ -180,7 +180,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..560bcb237b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/300-libstdc++-pic.patch
@@ -0,0 +1,50 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,12 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+@@ -627,7 +627,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -660,6 +660,7 @@
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-data-local install-exec \
++ install-exec-local \
+ install-exec-am install-info install-info-am install-man \
+ install-strip install-toolexeclibLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+@@ -743,6 +743,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/304-index_macro.patch
new file mode 100644
index 0000000000..1fac112fa9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ namespace __gnu_cxx
+ {
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..b7d9bb9939
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,12 @@
+# gcc.gnu.org/PR30620
+--- gcc-4.1.2-20070208.orig/gcc/Makefile.in 2006-11-01 15:40:44.000000000 +0100
++++ gcc-4.1.2-20070208/gcc/Makefile.in 2007-02-13 19:23:31.000000000 +0100
+@@ -2522,7 +2522,7 @@
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
++ insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE) gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/740-sh-pr24836.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/740-sh-pr24836.patch
new file mode 100644
index 0000000000..7992282cff
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/740-sh-pr24836.patch
@@ -0,0 +1,25 @@
+http://sourceforge.net/mailarchive/forum.php?thread_id=8959304&forum_id=5348
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24836
+
+--- gcc/gcc/configure.ac (revision 106699)
++++ gcc/gcc/configure.ac (working copy)
+@@ -2446,7 +2446,7 @@
+ tls_first_minor=14
+ tls_as_opt="-m64 -Aesame --fatal-warnings"
+ ;;
+- sh-*-* | sh[34]-*-*)
++ sh-*-* | sh[34]*-*-*)
+ conftest_s='
+ .section ".tdata","awT",@progbits
+ foo: .long 25
+--- gcc/gcc/configure
++++ gcc/gcc/configure
+@@ -14846,7 +14846,7 @@
+ tls_first_minor=14
+ tls_as_opt="-m64 -Aesame --fatal-warnings"
+ ;;
+- sh-*-* | sh[34]-*-*)
++ sh-*-* | sh[34]*-*-*)
+ conftest_s='
+ .section ".tdata","awT",@progbits
+ foo: .long 25
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/800-arm-bigendian.patch
new file mode 100644
index 0000000000..0a9417419e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/800-arm-bigendian.patch
@@ -0,0 +1,127 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+Index: gcc-4.1.1/gcc/config/arm/linux-elf.h
+===================================================================
+--- gcc-4.1.1.orig/gcc/config/arm/linux-elf.h
++++ gcc-4.1.1/gcc/config/arm/linux-elf.h
+@@ -28,19 +28,33 @@
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* Now we define the strings used to build the spec file. */
+ #undef LIB_SPEC
+@@ -61,7 +75,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #undef LINK_SPEC
+Index: gcc-4.1.1/gcc/config.gcc
+===================================================================
+--- gcc-4.1.1.orig/gcc/config.gcc
++++ gcc-4.1.1/gcc/config.gcc
+@@ -672,6 +672,11 @@ arm*-*-netbsd*)
+ ;;
+ arm*-*-linux*) # ARM GNU/Linux with ELF
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
++ case $target in
++ arm*b-*)
++ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
++ ;;
++ esac
+ tmake_file="${tmake_file} t-linux arm/t-arm"
+ case ${target} in
+ arm*-*-linux-gnueabi)
+Index: gcc-4.1.1/gcc/config/arm/linux-eabi.h
+===================================================================
+--- gcc-4.1.1.orig/gcc/config/arm/linux-eabi.h
++++ gcc-4.1.1/gcc/config/arm/linux-eabi.h
+@@ -20,6 +20,17 @@
+ the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#undef TARGET_LINKER_EMULATION
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_LINKER_EMULATION "armelfb_linux_eabi"
++#else
++#define TARGET_LINKER_EMULATION "armelf_linux_eabi"
++#endif
++
+ /* On EABI GNU/Linux, we want both the BPABI builtins and the
+ GNU/Linux builtins. */
+ #undef TARGET_OS_CPP_BUILTINS
+@@ -48,7 +59,7 @@
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
+
+ #undef SUBTARGET_EXTRA_LINK_SPEC
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux_eabi"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION
+
+ /* Use ld-linux.so.3 so that it will be possible to run "classic"
+ GNU/Linux binaries on an EABI system. */
+Index: gcc-4.1.1/gcc/config/arm/bpabi.h
+===================================================================
+--- gcc-4.1.1.orig/gcc/config/arm/bpabi.h
++++ gcc-4.1.1/gcc/config/arm/bpabi.h
+@@ -33,9 +33,19 @@
+ #undef FPUTYPE_DEFAULT
+ #define FPUTYPE_DEFAULT FPUTYPE_VFP
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#endif
++
+ /* EABI targets should enable interworking by default. */
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT MASK_INTERWORK
++#define TARGET_DEFAULT (MASK_INTERWORK | TARGET_ENDIAN_DEFAULT)
+
+ /* The ARM BPABI functions return a boolean; they use no special
+ calling convention. */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/801-arm-bootstrap-libgcc.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/801-arm-bootstrap-libgcc.patch
new file mode 100644
index 0000000000..078da5bb45
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/801-arm-bootstrap-libgcc.patch
@@ -0,0 +1,63 @@
+diff -ur gcc-4.1.2/gcc/config/arm/unwind-arm.c gcc-4.1.2-patched/gcc/config/arm/unwind-arm.c
+--- gcc-4.1.2/gcc/config/arm/unwind-arm.c 2006-09-20 12:31:12.000000000 -0500
++++ gcc-4.1.2-patched/gcc/config/arm/unwind-arm.c 2008-02-27 13:30:45.339282365 -0600
+@@ -29,7 +29,13 @@
+
+ /* We add a prototype for abort here to avoid creating a dependency on
+ target headers. */
++#ifndef BOOTSTRAP_GCC
+ extern void abort (void);
++#else
++void abort (void)
++{
++}
++#endif
+
+ /* Definitions for C++ runtime support routines. We make these weak
+ declarations to avoid pulling in libsupc++ unnecessarily. */
+@@ -542,7 +548,9 @@
+ {
+ UCB_SAVED_CALLSITE_ADDR (ucbp) = saved_vrs.core.r[R_PC];
+
++#ifndef BOOTSTRAP_GCC
+ next_vrs = saved_vrs;
++#endif
+
+ /* Call the pr to decide what to do. */
+ pr_result = ((personality_routine) UCB_PR_ADDR (ucbp))
+@@ -572,7 +580,9 @@
+ if (entry_code != _URC_OK)
+ return entry_code;
+
++#ifndef BOOTSTRAP_GCC
+ saved_vrs = next_vrs;
++#endif
+ }
+ while (pr_result == _URC_CONTINUE_UNWIND);
+
+diff -ur gcc-4.1.2/gcc/mklibgcc.in gcc-4.1.2-patched/gcc/mklibgcc.in
+--- gcc-4.1.2/gcc/mklibgcc.in 2006-09-10 02:13:12.000000000 -0500
++++ gcc-4.1.2-patched/gcc/mklibgcc.in 2008-02-27 13:39:15.697843177 -0600
+@@ -169,7 +169,7 @@
+ # It is too hard to guarantee that vis_hide and gen-hide-list will never
+ # be referenced if SHLIB_LINK is not set, so set them to the values they'd
+ # have if SHLIB_LINK were set and we didn't have visibility support.
+- echo "vis_hide ="
++ echo "vis_hide :=-DBOOTSTRAP_GCC"
+ echo "gen-hide-list = echo > \$@"
+ fi
+
+diff -ur gcc-4.1.2/gcc/unwind-dw2.c gcc-4.1.2-patched/gcc/unwind-dw2.c
+--- gcc-4.1.2/gcc/unwind-dw2.c 2005-11-17 19:19:10.000000000 -0600
++++ gcc-4.1.2-patched/gcc/unwind-dw2.c 2008-02-27 13:29:55.414640030 -0600
+@@ -1311,8 +1311,10 @@
+ void *c = current->reg[i];
+ void *t = target->reg[i];
+
++#ifndef BOOTSTRAP_GCC
+ if (t && c && t != c)
+ memcpy (c, t, dwarf_reg_size_table[i]);
++#endif
+ }
+
+ /* If the current frame doesn't have a saved stack pointer, then we
diff --git a/cleopatre/buildroot/toolchain/gcc/4.1.2/910-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.1.2/910-soft-float.patch
new file mode 100644
index 0000000000..3f886acbf5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.1.2/910-soft-float.patch
@@ -0,0 +1,26 @@
+--- gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
+@@ -4,7 +4,10 @@
+ LIBGCC2_DEBUG_CFLAGS = -g0
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+
+--- gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
+@@ -63,7 +63,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4243ff7b91
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+--- gcc/libgomp/configure
++++ gcc/libgomp/configure
+@@ -3771,7 +3771,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/gcc/config/cris/linux.h
++++ gcc/gcc/config/cris/linux.h
+@@ -74,7 +74,11 @@
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
+ #undef CRIS_SUBTARGET_VERSION
+-#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#if UCLIBC_DEFAULT
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++#else
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#endif
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -4276,7 +4276,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/zlib/configure
++++ gcc/zlib/configure
+@@ -3422,7 +3422,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libobjc/configure
++++ gcc/libobjc/configure
+@@ -3309,7 +3309,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libgfortran/configure
++++ gcc/libgfortran/configure
+@@ -3695,7 +3695,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libmudflap/configure
++++ gcc/libmudflap/configure
+@@ -5378,7 +5378,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/boehm-gc/configure
++++ gcc/boehm-gc/configure
+@@ -4316,7 +4316,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libffi/configure
++++ gcc/libffi/configure
+@@ -3453,7 +3453,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libssp/configure
++++ gcc/libssp/configure
+@@ -4409,7 +4409,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/contrib/regression/objs-gcc.sh
++++ gcc/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc/libjava/classpath/ltconfig
++++ gcc/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- gcc/libjava/classpath/configure
++++ gcc/libjava/classpath/configure
+@@ -4665,7 +4665,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libjava/configure
++++ gcc/libjava/configure
+@@ -5212,7 +5212,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libtool.m4
++++ gcc/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/ltconfig
++++ gcc/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/103-uclibc-conf-noupstream.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/103-uclibc-conf-noupstream.patch
new file mode 100644
index 0000000000..09c9bbecfb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/103-uclibc-conf-noupstream.patch
@@ -0,0 +1,11 @@
+--- gcc/gcc/config.gcc.uclibc100-sh~ 2006-03-06 20:46:56 +0100
++++ gcc/gcc/config.gcc 2006-03-10 15:02:41 +0100
+@@ -1905,7 +1905,7 @@
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/200-uclibc-locale.patch
new file mode 100644
index 0000000000..c933d1c446
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/200-uclibc-locale.patch
@@ -0,0 +1,2790 @@
+--- gcc/libstdc++-v3/acinclude.m4
++++ gcc/libstdc++-v3/acinclude.m4
+@@ -1369,7 +1369,7 @@
+ AC_MSG_CHECKING([for C locale to use])
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # If they didn't use this option switch, or if they specified --enable
+ # with no specific model, we'll have to look for one. If they
+@@ -1385,6 +1385,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1528,6 +1531,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+@@ -0,0 +1,63 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <bits/c++config.h>
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++#endif
++
++#endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
+@@ -0,0 +1,117 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out,
++ const int __size __attribute__ ((__unused__)),
++ const char* __fmt,
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ ;
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+@@ -0,0 +1,160 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -5764,7 +5764,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5789,6 +5789,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -6019,6 +6022,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/include/c_compatibility/wchar.h
++++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+--- gcc/libstdc++-v3/include/c_std/std_cwchar.h
++++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
+@@ -182,7 +182,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/203-uclibc-locale-no__x.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/203-uclibc-locale-no__x.patch
new file mode 100644
index 0000000000..6ba47003b3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/203-uclibc-locale-no__x.patch
@@ -0,0 +1,213 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2006-03-10 15:32:37 +0100
+@@ -60,4 +60,49 @@
+ extern "C" __typeof(wctype_l) __wctype_l;
+ #endif
+
++# define __nl_langinfo_l nl_langinfo_l
++# define __strcoll_l strcoll_l
++# define __strftime_l strftime_l
++# define __strtod_l strtod_l
++# define __strtof_l strtof_l
++# define __strtold_l strtold_l
++# define __strxfrm_l strxfrm_l
++# define __newlocale newlocale
++# define __freelocale freelocale
++# define __duplocale duplocale
++# define __uselocale uselocale
++
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l iswctype_l
++# define __towlower_l towlower_l
++# define __towupper_l towupper_l
++# define __wcscoll_l wcscoll_l
++# define __wcsftime_l wcsftime_l
++# define __wcsxfrm_l wcsxfrm_l
++# define __wctype_l wctype_l
++# endif
++
++#else
++# define __nl_langinfo_l(N, L) nl_langinfo((N))
++# define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++# define __strtod_l(S, E, L) strtod((S), (E))
++# define __strtof_l(S, E, L) strtof((S), (E))
++# define __strtold_l(S, E, L) strtold((S), (E))
++# define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++# warning should dummy __newlocale check for C|POSIX ?
++# define __newlocale(a, b, c) NULL
++# define __freelocale(a) ((void)0)
++# define __duplocale(a) __c_locale()
++//# define __uselocale ?
++//
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l(C, M, L) iswctype((C), (M))
++# define __towlower_l(C, L) towlower((C))
++# define __towupper_l(C, L) towupper((C))
++# define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++//# define __wcsftime_l(S, M, F, T, L) wcsftime((S), (M), (F), (T))
++# define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++# define __wctype_l(S, L) wctype((S))
++# endif
++
+ #endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:32:37 +0100
+@@ -39,20 +39,6 @@
+ #include <langinfo.h>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
+-#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
+-#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
+-#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
+-#define __strtof_l(S, E, L) strtof((S), (E))
+-#define __strtod_l(S, E, L) strtod((S), (E))
+-#define __strtold_l(S, E, L) strtold((S), (E))
+-#warning should dummy __newlocale check for C|POSIX ?
+-#define __newlocale(a, b, c) NULL
+-#define __freelocale(a) ((void)0)
+-#define __duplocale(a) __c_locale()
+-#endif
+-
+ namespace std
+ {
+ template<>
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc 2006-03-10 15:32:37 +0100
+@@ -36,13 +36,6 @@
+ #include <locale>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
+-#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
+-#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
+-#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
+-#endif
+-
+ namespace std
+ {
+ // These are basically extensions to char_traits, and perhaps should
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:32:37 +0100
+@@ -43,10 +43,6 @@
+ #warning tailor for stub locale support
+ #endif
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+-
+ namespace std
+ {
+ // Construct and return valid pattern consisting of some combination of:
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:32:37 +0100
+@@ -41,9 +41,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc 2006-03-10 15:32:37 +0100
+@@ -40,9 +40,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:32:37 +0100
+@@ -38,13 +38,6 @@
+ #undef _LIBC
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __wctype_l(S, L) wctype((S))
+-#define __towupper_l(C, L) towupper((C))
+-#define __towlower_l(C, L) towlower((C))
+-#define __iswctype_l(C, M, L) iswctype((C), (M))
+-#endif
+-
+ namespace std
+ {
+ // NB: The other ctype<char> specializations are in src/locale.cc and
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc 2006-03-10 15:32:37 +0100
+@@ -39,13 +39,10 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix gettext stuff
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__dcgettext(const char *domainname,
+- const char *msgid, int category);
+ #undef gettext
+-#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#define gettext(msgid) dcgettext(NULL, msgid, LC_MESSAGES)
+ #else
+-#undef gettext
+ #define gettext(msgid) (msgid)
+ #endif
+
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:32:37 +0100
+@@ -36,15 +36,11 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__textdomain(const char *domainname);
+-extern "C" char *__bindtextdomain(const char *domainname,
+- const char *dirname);
+-#else
+-#undef __textdomain
+-#undef __bindtextdomain
+-#define __textdomain(D) ((void)0)
+-#define __bindtextdomain(D,P) ((void)0)
++#ifndef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#undef textdomain
++#undef bindtextdomain
++#define textdomain(D) ((void)0)
++#define bindtextdomain(D,P) ((void)0)
+ #endif
+
+ // Non-virtual member functions.
+@@ -70,7 +66,7 @@
+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
+ const char* __dir) const
+ {
+- __bindtextdomain(__s.c_str(), __dir);
++ bindtextdomain(__s.c_str(), __dir);
+ return this->do_open(__s, __loc);
+ }
+
+@@ -90,7 +86,7 @@
+ {
+ // No error checking is done, assume the catalog exists and can
+ // be used.
+- __textdomain(__s.c_str());
++ textdomain(__s.c_str());
+ return 0;
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-03-10 15:32:37 +0100
+@@ -68,6 +68,7 @@
+ {
+ extern "C" __typeof(uselocale) __uselocale;
+ }
++#define __uselocale uselocale
+ #endif
+
+ namespace std
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/204-uclibc-locale-wchar_fix.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/204-uclibc-locale-wchar_fix.patch
new file mode 100644
index 0000000000..160ab35bb3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/204-uclibc-locale-wchar_fix.patch
@@ -0,0 +1,48 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:37:27 +0100
+@@ -401,7 +401,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+@@ -556,7 +556,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:37:27 +0100
+@@ -127,12 +127,25 @@
+ {
+ // Named locale.
+ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be numeric
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
+ union { char *__s; wchar_t __w; } __u;
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_data->_M_decimal_point = __u.__w;
+
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
+ _M_data->_M_thousands_sep = __u.__w;
++#endif
+
+ if (_M_data->_M_thousands_sep == L'\0')
+ _M_data->_M_grouping = "";
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/205-uclibc-locale-update.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/205-uclibc-locale-update.patch
new file mode 100644
index 0000000000..86b2844554
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/205-uclibc-locale-update.patch
@@ -0,0 +1,347 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
+@@ -46,16 +47,13 @@
+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- float __f = __strtof_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __f;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -63,16 +61,13 @@
+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- double __d = __strtod_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __d;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -80,16 +75,13 @@
+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- long double __ld = __strtold_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __ld;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ void
+@@ -110,7 +102,7 @@
+ void
+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
+ {
+- if (_S_get_c_locale() != __cloc)
++ if (__cloc && _S_get_c_locale() != __cloc)
+ __freelocale(__cloc);
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ namespace std
+@@ -138,20 +143,34 @@
+ ctype<wchar_t>::
+ do_is(mask __m, wchar_t __c) const
+ {
+- // Highest bitmask in ctype_base == 10, but extra in "C"
+- // library for blank.
++ // The case of __m == ctype_base::space is particularly important,
++ // due to its use in many istream functions. Therefore we deal with
++ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
++ // is the mask corresponding to ctype_base::space. NB: an encoding
++ // change would not affect correctness!
+ bool __ret = false;
+- const size_t __bitmasksize = 11;
+- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+- if (__m & _M_bit[__bitcur]
+- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
+- {
+- __ret = true;
+- break;
+- }
++ if (__m == _M_bit[5])
++ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
++ else
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur])
++ {
++ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ else if (__m == _M_bit[__bitcur])
++ break;
++ }
++ }
+ return __ret;
+ }
+-
++
+ const wchar_t*
+ ctype<wchar_t>::
+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
+@@ -47,18 +47,21 @@
+ template<typename _CharT>
+ messages<_CharT>::messages(size_t __refs)
+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
+- _M_name_messages(_S_get_c_name())
++ _M_name_messages(_S_get_c_name())
+ { }
+
+ template<typename _CharT>
+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
+ size_t __refs)
+- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
+- _M_name_messages(__s)
++ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_messages = __tmp;
++
++ // Last to avoid leaking memory if new throws.
++ _M_c_locale_messages = _S_clone_c_locale(__cloc);
+ }
+
+ template<typename _CharT>
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+@@ -206,7 +211,7 @@
+ }
+ break;
+ default:
+- ;
++ __ret = pattern();
+ }
+ return __ret;
+ }
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
+@@ -37,25 +37,33 @@
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
+ size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(__s)
++ _M_name_timepunct(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_timepunct = __tmp;
+- _M_initialize_timepunct(__cloc);
++
++ try
++ { _M_initialize_timepunct(__cloc); }
++ catch(...)
++ {
++ delete [] _M_name_timepunct;
++ __throw_exception_again;
++ }
+ }
+
+ template<typename _CharT>
+--- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
+@@ -39,21 +39,23 @@
+ #pragma GCC system_header
+
+ #include <cstring> // get std::strlen
+-#include <cstdio> // get std::snprintf or std::sprintf
++#include <cstdio> // get std::vsnprintf or std::vsprintf
+ #include <clocale>
+ #include <langinfo.h> // For codecvt
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix this
+ #endif
+-#ifdef __UCLIBC_HAS_LOCALE__
++#ifdef _GLIBCXX_USE_ICONV
+ #include <iconv.h> // For codecvt using iconv, iconv_t
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-#include <libintl.h> // For messages
++#ifdef HAVE_LIBINTL_H
++#include <libintl.h> // For messages
+ #endif
++#include <cstdarg>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning what is _GLIBCXX_C_LOCALE_GNU for
++// psm: used in os/gnu-linux/ctype_noninline.h
+ #endif
+ #define _GLIBCXX_C_LOCALE_GNU 1
+
+@@ -62,7 +64,7 @@
+ #endif
+ // #define _GLIBCXX_NUM_CATEGORIES 6
+ #define _GLIBCXX_NUM_CATEGORIES 0
+-
++
+ #ifdef __UCLIBC_HAS_XLOCALE__
+ namespace __gnu_cxx
+ {
+@@ -79,22 +81,24 @@
+ typedef int* __c_locale;
+ #endif
+
+- // Convert numeric value of type _Tv to string and return length of
+- // string. If snprintf is available use it, otherwise fall back to
+- // the unsafe sprintf which, in general, can be dangerous and should
++ // Convert numeric value of type double to string and return length of
++ // string. If vsnprintf is available use it, otherwise fall back to
++ // the unsafe vsprintf which, in general, can be dangerous and should
+ // be avoided.
+- template<typename _Tv>
+- int
+- __convert_from_v(char* __out,
+- const int __size __attribute__ ((__unused__)),
+- const char* __fmt,
+-#ifdef __UCLIBC_HAS_XCLOCALE__
+- _Tv __v, const __c_locale& __cloc, int __prec)
++ inline int
++ __convert_from_v(const __c_locale&
++#ifndef __UCLIBC_HAS_XCLOCALE__
++ __cloc __attribute__ ((__unused__))
++#endif
++ ,
++ char* __out,
++ const int __size,
++ const char* __fmt, ...)
+ {
++ va_list __args;
++#ifdef __UCLIBC_HAS_XCLOCALE__
+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
+ #else
+- _Tv __v, const __c_locale&, int __prec)
+- {
+ # ifdef __UCLIBC_HAS_LOCALE__
+ char* __old = std::setlocale(LC_ALL, NULL);
+ char* __sav = new char[std::strlen(__old) + 1];
+@@ -103,7 +107,9 @@
+ # endif
+ #endif
+
+- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++ va_start(__args, __fmt);
++ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
++ va_end(__args);
+
+ #ifdef __UCLIBC_HAS_XCLOCALE__
+ __gnu_cxx::__uselocale(__old);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..560bcb237b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/300-libstdc++-pic.patch
@@ -0,0 +1,50 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,12 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+@@ -627,7 +627,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -660,6 +660,7 @@
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-data-local install-exec \
++ install-exec-local \
+ install-exec-am install-info install-info-am install-man \
+ install-strip install-toolexeclibLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+@@ -743,6 +743,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/304-index_macro.patch
new file mode 100644
index 0000000000..d8e476555d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/306-libstdc++-namespace.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/306-libstdc++-namespace.patch
new file mode 100644
index 0000000000..69587ca63a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/306-libstdc++-namespace.patch
@@ -0,0 +1,36 @@
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 15:23:41.000000000 +0100
+@@ -32,7 +32,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+@@ -115,3 +116,4 @@
+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
+ }
++}
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 15:20:31.000000000 +0100
+@@ -33,7 +33,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+@@ -74,3 +75,4 @@
+ delete _M_data;
+ _S_destroy_c_locale(_M_c_locale_timepunct);
+ }
++}
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..0bf115c45d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.2/gcc/Makefile.in
+===================================================================
+--- gcc-4.2/gcc/Makefile.in (revision 121758)
++++ gcc-4.2/gcc/Makefile.in (working copy)
+@@ -2658,7 +2658,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H)
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
++ insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE) gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/800-arm-bigendian.patch
new file mode 100644
index 0000000000..07c6093379
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/800-arm-bigendian.patch
@@ -0,0 +1,67 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-4.2.0/gcc/config/arm/linux-elf.h
++++ gcc-4.2.0/gcc/config/arm/linux-elf.h
+@@ -28,19 +28,33 @@
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* Now we define the strings used to build the spec file. */
+ #undef LIB_SPEC
+@@ -61,7 +75,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #undef LINK_SPEC
+--- gcc-4.2.0/gcc/config.gcc.orig 2006-09-22 14:53:41.000000000 +0200
++++ gcc-4.2.0/gcc/config.gcc 2006-09-25 10:45:21.000000000 +0200
+@@ -696,6 +696,11 @@
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+ tmake_file="${tmake_file} t-linux arm/t-arm"
+ case ${target} in
++ arm*b-*)
++ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
++ ;;
++ esac
++ case ${target} in
+ arm*-*-linux-*eabi)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.0/904-flatten-switch-stmt-00.patch b/cleopatre/buildroot/toolchain/gcc/4.2.0/904-flatten-switch-stmt-00.patch
new file mode 100644
index 0000000000..8fac37c4df
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.0/904-flatten-switch-stmt-00.patch
@@ -0,0 +1,153 @@
+Hi,
+
+The attached patch makes sure that we create smaller object code for
+simple switch statements. We just make sure to flatten the switch
+statement into an if-else chain, basically.
+
+This fixes a size-regression as compared to gcc-3.4, as can be seen
+below.
+
+2007-04-15 Bernhard Fischer <..>
+
+ * stmt.c (expand_case): Do not create a complex binary tree when
+ optimizing for size but rather use the simple ordered list.
+ (emit_case_nodes): do not emit jumps to the default_label when
+ optimizing for size.
+
+Not regtested so far.
+Comments?
+
+Attached is the test switch.c mentioned below.
+
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -DCHAIN -Os -o switch-CHAIN-$i.o -c switch.c ;done
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -UCHAIN -Os -o switch-$i.o -c switch.c ;done
+
+$ size switch-*.o
+ text data bss dec hex filename
+ 169 0 0 169 a9 switch-2.95.o
+ 115 0 0 115 73 switch-3.3.o
+ 103 0 0 103 67 switch-3.4.o
+ 124 0 0 124 7c switch-4.0.o
+ 124 0 0 124 7c switch-4.1.o
+ 124 0 0 124 7c switch-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-4.3-HEAD.o
+ 124 0 0 124 7c switch-4.3.orig-HEAD.o
+ 166 0 0 166 a6 switch-CHAIN-2.95.o
+ 111 0 0 111 6f switch-CHAIN-3.3.o
+ 95 0 0 95 5f switch-CHAIN-3.4.o
+ 95 0 0 95 5f switch-CHAIN-4.0.o
+ 95 0 0 95 5f switch-CHAIN-4.1.o
+ 95 0 0 95 5f switch-CHAIN-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3.orig-HEAD.o
+
+
+Content-Type: text/x-diff; charset=us-ascii
+Content-Disposition: attachment; filename="gcc-4.3.gcc-flatten-switch-stmt.00.diff"
+
+Index: gcc-4.2.0/gcc/stmt.c
+===================================================================
+--- gcc-4.2.0.orig/gcc/stmt.c (revision 123843)
++++ gcc-4.2.0/gcc/stmt.c (working copy)
+@@ -2517,7 +2517,11 @@ expand_case (tree exp)
+ use_cost_table
+ = (TREE_CODE (orig_type) != ENUMERAL_TYPE
+ && estimate_case_costs (case_list));
+- balance_case_nodes (&case_list, NULL);
++ /* When optimizing for size, we want a straight list to avoid
++ jumps as much as possible. This basically creates an if-else
++ chain. */
++ if (!optimize_size)
++ balance_case_nodes (&case_list, NULL);
+ emit_case_nodes (index, case_list, default_label, index_type);
+ emit_jump (default_label);
+ }
+@@ -3075,6 +3079,7 @@ emit_case_nodes (rtx index, case_node_pt
+ {
+ if (!node_has_low_bound (node, index_type))
+ {
++ if (!optimize_size) /* don't jl to the .default_label. */
+ emit_cmp_and_jump_insns (index,
+ convert_modes
+ (mode, imode,
+
+
+Content-Type: text/x-csrc; charset=us-ascii
+Content-Disposition: attachment; filename="switch.c"
+
+int
+commutative_tree_code (int code)
+{
+#define CASE(val, ret) case val:/* __asm__("# val="#val ",ret="#ret);*/ return ret;
+#ifndef CHAIN
+ switch (code)
+ {
+# if 1
+ CASE(1,3)
+ CASE(3,2)
+ CASE(5,8)
+ CASE(7,1)
+ CASE(33,4)
+ CASE(44,9)
+ CASE(55,10)
+ CASE(66,-1)
+ CASE(77,99)
+ CASE(666,0)
+# else
+ case 1:
+ return 3;
+ case 3:
+ return 2;
+ case 5:
+ return 8;
+ case 7:
+ return 1;
+ case 33:
+ return 4;
+ case 44:
+ return 9;
+ case 55:
+ return 10;
+ case 66:
+ return -1;
+ case 77:
+ return 99;
+ case 666:
+ return 0;
+# endif
+ default:
+ break;
+ }
+ return 4711;
+
+#else
+ if (code == 1)
+ return 3;
+ else if (code == 3)
+ return 2;
+ else if (code == 5)
+ return 8;
+ else if (code == 7)
+ return 1;
+ else if (code == 33)
+ return 4;
+ else if (code == 44)
+ return 9;
+ else if (code == 55)
+ return 10;
+ else if (code == 66)
+ return -1;
+ else if (code == 77)
+ return 99;
+ else if (code == 666)
+ return 0;
+ else
+ return 4711;
+#endif
+}
+
+
+--AhhlLboLdkugWU4S--
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4243ff7b91
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+--- gcc/libgomp/configure
++++ gcc/libgomp/configure
+@@ -3771,7 +3771,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/gcc/config/cris/linux.h
++++ gcc/gcc/config/cris/linux.h
+@@ -74,7 +74,11 @@
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
+ #undef CRIS_SUBTARGET_VERSION
+-#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#if UCLIBC_DEFAULT
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++#else
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#endif
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -4276,7 +4276,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/zlib/configure
++++ gcc/zlib/configure
+@@ -3422,7 +3422,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libobjc/configure
++++ gcc/libobjc/configure
+@@ -3309,7 +3309,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libgfortran/configure
++++ gcc/libgfortran/configure
+@@ -3695,7 +3695,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libmudflap/configure
++++ gcc/libmudflap/configure
+@@ -5378,7 +5378,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/boehm-gc/configure
++++ gcc/boehm-gc/configure
+@@ -4316,7 +4316,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libffi/configure
++++ gcc/libffi/configure
+@@ -3453,7 +3453,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libssp/configure
++++ gcc/libssp/configure
+@@ -4409,7 +4409,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/contrib/regression/objs-gcc.sh
++++ gcc/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc/libjava/classpath/ltconfig
++++ gcc/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- gcc/libjava/classpath/configure
++++ gcc/libjava/classpath/configure
+@@ -4665,7 +4665,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libjava/configure
++++ gcc/libjava/configure
+@@ -5212,7 +5212,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libtool.m4
++++ gcc/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/ltconfig
++++ gcc/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/103-uclibc-conf-noupstream.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/103-uclibc-conf-noupstream.patch
new file mode 100644
index 0000000000..09c9bbecfb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/103-uclibc-conf-noupstream.patch
@@ -0,0 +1,11 @@
+--- gcc/gcc/config.gcc.uclibc100-sh~ 2006-03-06 20:46:56 +0100
++++ gcc/gcc/config.gcc 2006-03-10 15:02:41 +0100
+@@ -1905,7 +1905,7 @@
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/104-gnuhurd-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/104-gnuhurd-uclibc-conf.patch
new file mode 100644
index 0000000000..c04dd9ff00
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/104-gnuhurd-uclibc-conf.patch
@@ -0,0 +1,13 @@
+diff -rdup gcc-4.2.1.oorig/gcc/config.gcc gcc-4.2.1/gcc/config.gcc
+--- gcc-4.2.1.oorig/gcc/config.gcc 2007-10-01 11:52:52.000000000 +0200
++++ gcc-4.2.1/gcc/config.gcc 2007-10-01 13:22:12.000000000 +0200
+@@ -494,6 +494,9 @@ case ${target} in
+ alpha*)
+ tm_file="${cpu_type}/${cpu_type}.h alpha/elf.h alpha/linux.h alpha/linux-elf.h gnu.h ${tm_file}"
+ ;;
++ i[34567]86-*hurd*-*)
++ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/gnu.h gnu.h ${tm_file}"
++ ;;
+ i[34567]86-*-*)
+ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h gnu.h ${tm_file}"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/200-uclibc-locale.patch
new file mode 100644
index 0000000000..ea21388b75
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/200-uclibc-locale.patch
@@ -0,0 +1,2790 @@
+--- gcc/libstdc++-v3/acinclude.m4
++++ gcc/libstdc++-v3/acinclude.m4
+@@ -1369,7 +1369,7 @@
+ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # Deal with gettext issues. Default to not using it (=no) until we detect
+ # support for it later. Let the user turn it off via --e/d, but let that
+@@ -1385,6 +1385,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1528,6 +1531,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+@@ -0,0 +1,63 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <bits/c++config.h>
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++#endif
++
++#endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
+@@ -0,0 +1,117 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out,
++ const int __size __attribute__ ((__unused__)),
++ const char* __fmt,
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ ;
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+@@ -0,0 +1,160 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -5764,7 +5764,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5789,6 +5789,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -6019,6 +6022,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/include/c_compatibility/wchar.h
++++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+--- gcc/libstdc++-v3/include/c_std/std_cwchar.h
++++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
+@@ -182,7 +182,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/203-uclibc-locale-no__x.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/203-uclibc-locale-no__x.patch
new file mode 100644
index 0000000000..6ba47003b3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/203-uclibc-locale-no__x.patch
@@ -0,0 +1,213 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2006-03-10 15:32:37 +0100
+@@ -60,4 +60,49 @@
+ extern "C" __typeof(wctype_l) __wctype_l;
+ #endif
+
++# define __nl_langinfo_l nl_langinfo_l
++# define __strcoll_l strcoll_l
++# define __strftime_l strftime_l
++# define __strtod_l strtod_l
++# define __strtof_l strtof_l
++# define __strtold_l strtold_l
++# define __strxfrm_l strxfrm_l
++# define __newlocale newlocale
++# define __freelocale freelocale
++# define __duplocale duplocale
++# define __uselocale uselocale
++
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l iswctype_l
++# define __towlower_l towlower_l
++# define __towupper_l towupper_l
++# define __wcscoll_l wcscoll_l
++# define __wcsftime_l wcsftime_l
++# define __wcsxfrm_l wcsxfrm_l
++# define __wctype_l wctype_l
++# endif
++
++#else
++# define __nl_langinfo_l(N, L) nl_langinfo((N))
++# define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++# define __strtod_l(S, E, L) strtod((S), (E))
++# define __strtof_l(S, E, L) strtof((S), (E))
++# define __strtold_l(S, E, L) strtold((S), (E))
++# define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++# warning should dummy __newlocale check for C|POSIX ?
++# define __newlocale(a, b, c) NULL
++# define __freelocale(a) ((void)0)
++# define __duplocale(a) __c_locale()
++//# define __uselocale ?
++//
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l(C, M, L) iswctype((C), (M))
++# define __towlower_l(C, L) towlower((C))
++# define __towupper_l(C, L) towupper((C))
++# define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++//# define __wcsftime_l(S, M, F, T, L) wcsftime((S), (M), (F), (T))
++# define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++# define __wctype_l(S, L) wctype((S))
++# endif
++
+ #endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:32:37 +0100
+@@ -39,20 +39,6 @@
+ #include <langinfo.h>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
+-#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
+-#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
+-#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
+-#define __strtof_l(S, E, L) strtof((S), (E))
+-#define __strtod_l(S, E, L) strtod((S), (E))
+-#define __strtold_l(S, E, L) strtold((S), (E))
+-#warning should dummy __newlocale check for C|POSIX ?
+-#define __newlocale(a, b, c) NULL
+-#define __freelocale(a) ((void)0)
+-#define __duplocale(a) __c_locale()
+-#endif
+-
+ namespace std
+ {
+ template<>
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc 2006-03-10 15:32:37 +0100
+@@ -36,13 +36,6 @@
+ #include <locale>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
+-#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
+-#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
+-#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
+-#endif
+-
+ namespace std
+ {
+ // These are basically extensions to char_traits, and perhaps should
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:32:37 +0100
+@@ -43,10 +43,6 @@
+ #warning tailor for stub locale support
+ #endif
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+-
+ namespace std
+ {
+ // Construct and return valid pattern consisting of some combination of:
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:32:37 +0100
+@@ -41,9 +41,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc 2006-03-10 15:32:37 +0100
+@@ -40,9 +40,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:32:37 +0100
+@@ -38,13 +38,6 @@
+ #undef _LIBC
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __wctype_l(S, L) wctype((S))
+-#define __towupper_l(C, L) towupper((C))
+-#define __towlower_l(C, L) towlower((C))
+-#define __iswctype_l(C, M, L) iswctype((C), (M))
+-#endif
+-
+ namespace std
+ {
+ // NB: The other ctype<char> specializations are in src/locale.cc and
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc 2006-03-10 15:32:37 +0100
+@@ -39,13 +39,10 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix gettext stuff
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__dcgettext(const char *domainname,
+- const char *msgid, int category);
+ #undef gettext
+-#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#define gettext(msgid) dcgettext(NULL, msgid, LC_MESSAGES)
+ #else
+-#undef gettext
+ #define gettext(msgid) (msgid)
+ #endif
+
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:32:37 +0100
+@@ -36,15 +36,11 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__textdomain(const char *domainname);
+-extern "C" char *__bindtextdomain(const char *domainname,
+- const char *dirname);
+-#else
+-#undef __textdomain
+-#undef __bindtextdomain
+-#define __textdomain(D) ((void)0)
+-#define __bindtextdomain(D,P) ((void)0)
++#ifndef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#undef textdomain
++#undef bindtextdomain
++#define textdomain(D) ((void)0)
++#define bindtextdomain(D,P) ((void)0)
+ #endif
+
+ // Non-virtual member functions.
+@@ -70,7 +66,7 @@
+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
+ const char* __dir) const
+ {
+- __bindtextdomain(__s.c_str(), __dir);
++ bindtextdomain(__s.c_str(), __dir);
+ return this->do_open(__s, __loc);
+ }
+
+@@ -90,7 +86,7 @@
+ {
+ // No error checking is done, assume the catalog exists and can
+ // be used.
+- __textdomain(__s.c_str());
++ textdomain(__s.c_str());
+ return 0;
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-03-10 15:32:37 +0100
+@@ -68,6 +68,7 @@
+ {
+ extern "C" __typeof(uselocale) __uselocale;
+ }
++#define __uselocale uselocale
+ #endif
+
+ namespace std
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/204-uclibc-locale-wchar_fix.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/204-uclibc-locale-wchar_fix.patch
new file mode 100644
index 0000000000..160ab35bb3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/204-uclibc-locale-wchar_fix.patch
@@ -0,0 +1,48 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:37:27 +0100
+@@ -401,7 +401,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+@@ -556,7 +556,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:37:27 +0100
+@@ -127,12 +127,25 @@
+ {
+ // Named locale.
+ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be numeric
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
+ union { char *__s; wchar_t __w; } __u;
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_data->_M_decimal_point = __u.__w;
+
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
+ _M_data->_M_thousands_sep = __u.__w;
++#endif
+
+ if (_M_data->_M_thousands_sep == L'\0')
+ _M_data->_M_grouping = "";
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/205-uclibc-locale-update.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/205-uclibc-locale-update.patch
new file mode 100644
index 0000000000..86b2844554
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/205-uclibc-locale-update.patch
@@ -0,0 +1,347 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
+@@ -46,16 +47,13 @@
+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- float __f = __strtof_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __f;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -63,16 +61,13 @@
+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- double __d = __strtod_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __d;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -80,16 +75,13 @@
+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- long double __ld = __strtold_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __ld;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ void
+@@ -110,7 +102,7 @@
+ void
+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
+ {
+- if (_S_get_c_locale() != __cloc)
++ if (__cloc && _S_get_c_locale() != __cloc)
+ __freelocale(__cloc);
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ namespace std
+@@ -138,20 +143,34 @@
+ ctype<wchar_t>::
+ do_is(mask __m, wchar_t __c) const
+ {
+- // Highest bitmask in ctype_base == 10, but extra in "C"
+- // library for blank.
++ // The case of __m == ctype_base::space is particularly important,
++ // due to its use in many istream functions. Therefore we deal with
++ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
++ // is the mask corresponding to ctype_base::space. NB: an encoding
++ // change would not affect correctness!
+ bool __ret = false;
+- const size_t __bitmasksize = 11;
+- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+- if (__m & _M_bit[__bitcur]
+- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
+- {
+- __ret = true;
+- break;
+- }
++ if (__m == _M_bit[5])
++ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
++ else
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur])
++ {
++ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ else if (__m == _M_bit[__bitcur])
++ break;
++ }
++ }
+ return __ret;
+ }
+-
++
+ const wchar_t*
+ ctype<wchar_t>::
+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
+@@ -47,18 +47,21 @@
+ template<typename _CharT>
+ messages<_CharT>::messages(size_t __refs)
+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
+- _M_name_messages(_S_get_c_name())
++ _M_name_messages(_S_get_c_name())
+ { }
+
+ template<typename _CharT>
+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
+ size_t __refs)
+- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
+- _M_name_messages(__s)
++ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_messages = __tmp;
++
++ // Last to avoid leaking memory if new throws.
++ _M_c_locale_messages = _S_clone_c_locale(__cloc);
+ }
+
+ template<typename _CharT>
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+@@ -206,7 +211,7 @@
+ }
+ break;
+ default:
+- ;
++ __ret = pattern();
+ }
+ return __ret;
+ }
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
+@@ -37,25 +37,33 @@
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
+ size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(__s)
++ _M_name_timepunct(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_timepunct = __tmp;
+- _M_initialize_timepunct(__cloc);
++
++ try
++ { _M_initialize_timepunct(__cloc); }
++ catch(...)
++ {
++ delete [] _M_name_timepunct;
++ __throw_exception_again;
++ }
+ }
+
+ template<typename _CharT>
+--- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
+@@ -39,21 +39,23 @@
+ #pragma GCC system_header
+
+ #include <cstring> // get std::strlen
+-#include <cstdio> // get std::snprintf or std::sprintf
++#include <cstdio> // get std::vsnprintf or std::vsprintf
+ #include <clocale>
+ #include <langinfo.h> // For codecvt
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix this
+ #endif
+-#ifdef __UCLIBC_HAS_LOCALE__
++#ifdef _GLIBCXX_USE_ICONV
+ #include <iconv.h> // For codecvt using iconv, iconv_t
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-#include <libintl.h> // For messages
++#ifdef HAVE_LIBINTL_H
++#include <libintl.h> // For messages
+ #endif
++#include <cstdarg>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning what is _GLIBCXX_C_LOCALE_GNU for
++// psm: used in os/gnu-linux/ctype_noninline.h
+ #endif
+ #define _GLIBCXX_C_LOCALE_GNU 1
+
+@@ -62,7 +64,7 @@
+ #endif
+ // #define _GLIBCXX_NUM_CATEGORIES 6
+ #define _GLIBCXX_NUM_CATEGORIES 0
+-
++
+ #ifdef __UCLIBC_HAS_XLOCALE__
+ namespace __gnu_cxx
+ {
+@@ -79,22 +81,24 @@
+ typedef int* __c_locale;
+ #endif
+
+- // Convert numeric value of type _Tv to string and return length of
+- // string. If snprintf is available use it, otherwise fall back to
+- // the unsafe sprintf which, in general, can be dangerous and should
++ // Convert numeric value of type double to string and return length of
++ // string. If vsnprintf is available use it, otherwise fall back to
++ // the unsafe vsprintf which, in general, can be dangerous and should
+ // be avoided.
+- template<typename _Tv>
+- int
+- __convert_from_v(char* __out,
+- const int __size __attribute__ ((__unused__)),
+- const char* __fmt,
+-#ifdef __UCLIBC_HAS_XCLOCALE__
+- _Tv __v, const __c_locale& __cloc, int __prec)
++ inline int
++ __convert_from_v(const __c_locale&
++#ifndef __UCLIBC_HAS_XCLOCALE__
++ __cloc __attribute__ ((__unused__))
++#endif
++ ,
++ char* __out,
++ const int __size,
++ const char* __fmt, ...)
+ {
++ va_list __args;
++#ifdef __UCLIBC_HAS_XCLOCALE__
+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
+ #else
+- _Tv __v, const __c_locale&, int __prec)
+- {
+ # ifdef __UCLIBC_HAS_LOCALE__
+ char* __old = std::setlocale(LC_ALL, NULL);
+ char* __sav = new char[std::strlen(__old) + 1];
+@@ -103,7 +107,9 @@
+ # endif
+ #endif
+
+- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++ va_start(__args, __fmt);
++ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
++ va_end(__args);
+
+ #ifdef __UCLIBC_HAS_XCLOCALE__
+ __gnu_cxx::__uselocale(__old);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..560bcb237b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/300-libstdc++-pic.patch
@@ -0,0 +1,50 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,12 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+@@ -627,7 +627,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -660,6 +660,7 @@
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-data-local install-exec \
++ install-exec-local \
+ install-exec-am install-info install-info-am install-man \
+ install-strip install-toolexeclibLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+@@ -743,6 +743,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/304-index_macro.patch
new file mode 100644
index 0000000000..d8e476555d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/306-libstdc++-namespace.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/306-libstdc++-namespace.patch
new file mode 100644
index 0000000000..69587ca63a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/306-libstdc++-namespace.patch
@@ -0,0 +1,36 @@
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 15:23:41.000000000 +0100
+@@ -32,7 +32,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+@@ -115,3 +116,4 @@
+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
+ }
++}
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 15:20:31.000000000 +0100
+@@ -33,7 +33,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+@@ -74,3 +75,4 @@
+ delete _M_data;
+ _S_destroy_c_locale(_M_c_locale_timepunct);
+ }
++}
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/307-locale_facets.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/307-locale_facets.patch
new file mode 100644
index 0000000000..412f8657dc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/307-locale_facets.patch
@@ -0,0 +1,26 @@
+This patch fixes a bug into ostream::operator<<(double) due to the wrong size
+passed into the __convert_from_v method. The wrong size is then passed to
+std::snprintf function, that, on uClibc, doens't handle sized 0 buffer.
+
+Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+--- gcc-4.2.1/libstdc++-v3/include/bits/locale_facets.tcc 2006-10-17 18:43:47.000000000 +0200
++++ gcc-4.2.1-st/libstdc++-v3/include/bits/locale_facets.tcc 2007-08-22 18:54:23.000000000 +0200
+@@ -1143,7 +1143,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ const int __cs_size = __fixed ? __max_exp + __prec + 4
+ : __max_digits * 2 + __prec;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
++ __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf,
+ __prec, __v);
+ #endif
+
+@@ -1777,7 +1777,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
+ const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
++ int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, "%.*Lf",
+ 0, __units);
+ #endif
+ string_type __digits(__len, char_type());
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..0bf115c45d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.2/gcc/Makefile.in
+===================================================================
+--- gcc-4.2/gcc/Makefile.in (revision 121758)
++++ gcc-4.2/gcc/Makefile.in (working copy)
+@@ -2658,7 +2658,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H)
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
++ insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE) gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/800-arm-bigendian.patch
new file mode 100644
index 0000000000..07c6093379
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/800-arm-bigendian.patch
@@ -0,0 +1,67 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-4.2.0/gcc/config/arm/linux-elf.h
++++ gcc-4.2.0/gcc/config/arm/linux-elf.h
+@@ -28,19 +28,33 @@
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* Now we define the strings used to build the spec file. */
+ #undef LIB_SPEC
+@@ -61,7 +75,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #undef LINK_SPEC
+--- gcc-4.2.0/gcc/config.gcc.orig 2006-09-22 14:53:41.000000000 +0200
++++ gcc-4.2.0/gcc/config.gcc 2006-09-25 10:45:21.000000000 +0200
+@@ -696,6 +696,11 @@
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+ tmake_file="${tmake_file} t-linux arm/t-arm"
+ case ${target} in
++ arm*b-*)
++ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
++ ;;
++ esac
++ case ${target} in
+ arm*-*-linux-*eabi)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/904-flatten-switch-stmt-00.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/904-flatten-switch-stmt-00.patch
new file mode 100644
index 0000000000..8fac37c4df
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/904-flatten-switch-stmt-00.patch
@@ -0,0 +1,153 @@
+Hi,
+
+The attached patch makes sure that we create smaller object code for
+simple switch statements. We just make sure to flatten the switch
+statement into an if-else chain, basically.
+
+This fixes a size-regression as compared to gcc-3.4, as can be seen
+below.
+
+2007-04-15 Bernhard Fischer <..>
+
+ * stmt.c (expand_case): Do not create a complex binary tree when
+ optimizing for size but rather use the simple ordered list.
+ (emit_case_nodes): do not emit jumps to the default_label when
+ optimizing for size.
+
+Not regtested so far.
+Comments?
+
+Attached is the test switch.c mentioned below.
+
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -DCHAIN -Os -o switch-CHAIN-$i.o -c switch.c ;done
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -UCHAIN -Os -o switch-$i.o -c switch.c ;done
+
+$ size switch-*.o
+ text data bss dec hex filename
+ 169 0 0 169 a9 switch-2.95.o
+ 115 0 0 115 73 switch-3.3.o
+ 103 0 0 103 67 switch-3.4.o
+ 124 0 0 124 7c switch-4.0.o
+ 124 0 0 124 7c switch-4.1.o
+ 124 0 0 124 7c switch-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-4.3-HEAD.o
+ 124 0 0 124 7c switch-4.3.orig-HEAD.o
+ 166 0 0 166 a6 switch-CHAIN-2.95.o
+ 111 0 0 111 6f switch-CHAIN-3.3.o
+ 95 0 0 95 5f switch-CHAIN-3.4.o
+ 95 0 0 95 5f switch-CHAIN-4.0.o
+ 95 0 0 95 5f switch-CHAIN-4.1.o
+ 95 0 0 95 5f switch-CHAIN-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3.orig-HEAD.o
+
+
+Content-Type: text/x-diff; charset=us-ascii
+Content-Disposition: attachment; filename="gcc-4.3.gcc-flatten-switch-stmt.00.diff"
+
+Index: gcc-4.2.0/gcc/stmt.c
+===================================================================
+--- gcc-4.2.0.orig/gcc/stmt.c (revision 123843)
++++ gcc-4.2.0/gcc/stmt.c (working copy)
+@@ -2517,7 +2517,11 @@ expand_case (tree exp)
+ use_cost_table
+ = (TREE_CODE (orig_type) != ENUMERAL_TYPE
+ && estimate_case_costs (case_list));
+- balance_case_nodes (&case_list, NULL);
++ /* When optimizing for size, we want a straight list to avoid
++ jumps as much as possible. This basically creates an if-else
++ chain. */
++ if (!optimize_size)
++ balance_case_nodes (&case_list, NULL);
+ emit_case_nodes (index, case_list, default_label, index_type);
+ emit_jump (default_label);
+ }
+@@ -3075,6 +3079,7 @@ emit_case_nodes (rtx index, case_node_pt
+ {
+ if (!node_has_low_bound (node, index_type))
+ {
++ if (!optimize_size) /* don't jl to the .default_label. */
+ emit_cmp_and_jump_insns (index,
+ convert_modes
+ (mode, imode,
+
+
+Content-Type: text/x-csrc; charset=us-ascii
+Content-Disposition: attachment; filename="switch.c"
+
+int
+commutative_tree_code (int code)
+{
+#define CASE(val, ret) case val:/* __asm__("# val="#val ",ret="#ret);*/ return ret;
+#ifndef CHAIN
+ switch (code)
+ {
+# if 1
+ CASE(1,3)
+ CASE(3,2)
+ CASE(5,8)
+ CASE(7,1)
+ CASE(33,4)
+ CASE(44,9)
+ CASE(55,10)
+ CASE(66,-1)
+ CASE(77,99)
+ CASE(666,0)
+# else
+ case 1:
+ return 3;
+ case 3:
+ return 2;
+ case 5:
+ return 8;
+ case 7:
+ return 1;
+ case 33:
+ return 4;
+ case 44:
+ return 9;
+ case 55:
+ return 10;
+ case 66:
+ return -1;
+ case 77:
+ return 99;
+ case 666:
+ return 0;
+# endif
+ default:
+ break;
+ }
+ return 4711;
+
+#else
+ if (code == 1)
+ return 3;
+ else if (code == 3)
+ return 2;
+ else if (code == 5)
+ return 8;
+ else if (code == 7)
+ return 1;
+ else if (code == 33)
+ return 4;
+ else if (code == 44)
+ return 9;
+ else if (code == 55)
+ return 10;
+ else if (code == 66)
+ return -1;
+ else if (code == 77)
+ return 99;
+ else if (code == 666)
+ return 0;
+ else
+ return 4711;
+#endif
+}
+
+
+--AhhlLboLdkugWU4S--
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/910-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/910-soft-float.patch
new file mode 100644
index 0000000000..3f886acbf5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/910-soft-float.patch
@@ -0,0 +1,26 @@
+--- gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
+@@ -4,7 +4,10 @@
+ LIBGCC2_DEBUG_CFLAGS = -g0
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+
+--- gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
+@@ -63,7 +63,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.1/920-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.1/920-soft-float.patch
new file mode 100644
index 0000000000..4287bfae27
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.1/920-soft-float.patch
@@ -0,0 +1,21 @@
+diff -uNpr gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c
+--- gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c 2007-03-05 11:54:00.000000000 -0500
++++ gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c 2008-01-31 17:51:24.000000000 -0500
+@@ -70,6 +70,8 @@ Software Foundation, 51 Franklin Street,
+ but GCC currently generates poor code when a union is used to turn
+ a long double into a pair of doubles. */
+
++#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
++
+ long double __gcc_qadd (double, double, double, double);
+ long double __gcc_qsub (double, double, double, double);
+ long double __gcc_qmul (double, double, double, double);
+@@ -219,8 +221,6 @@ __gcc_qdiv (double a, double b, double c
+ return z.ldval;
+ }
+
+-#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
+-
+ long double __gcc_qneg (double, double);
+ int __gcc_qeq (double, double, double, double);
+ int __gcc_qne (double, double, double, double);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4243ff7b91
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+--- gcc/libgomp/configure
++++ gcc/libgomp/configure
+@@ -3771,7 +3771,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/gcc/config/cris/linux.h
++++ gcc/gcc/config/cris/linux.h
+@@ -74,7 +74,11 @@
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
+ #undef CRIS_SUBTARGET_VERSION
+-#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#if UCLIBC_DEFAULT
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++#else
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#endif
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -4276,7 +4276,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/zlib/configure
++++ gcc/zlib/configure
+@@ -3422,7 +3422,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libobjc/configure
++++ gcc/libobjc/configure
+@@ -3309,7 +3309,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libgfortran/configure
++++ gcc/libgfortran/configure
+@@ -3695,7 +3695,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libmudflap/configure
++++ gcc/libmudflap/configure
+@@ -5378,7 +5378,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/boehm-gc/configure
++++ gcc/boehm-gc/configure
+@@ -4316,7 +4316,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libffi/configure
++++ gcc/libffi/configure
+@@ -3453,7 +3453,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libssp/configure
++++ gcc/libssp/configure
+@@ -4409,7 +4409,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/contrib/regression/objs-gcc.sh
++++ gcc/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc/libjava/classpath/ltconfig
++++ gcc/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- gcc/libjava/classpath/configure
++++ gcc/libjava/classpath/configure
+@@ -4665,7 +4665,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libjava/configure
++++ gcc/libjava/configure
+@@ -5212,7 +5212,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libtool.m4
++++ gcc/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/ltconfig
++++ gcc/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/103-uclibc-conf-noupstream.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/103-uclibc-conf-noupstream.patch
new file mode 100644
index 0000000000..09c9bbecfb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/103-uclibc-conf-noupstream.patch
@@ -0,0 +1,11 @@
+--- gcc/gcc/config.gcc.uclibc100-sh~ 2006-03-06 20:46:56 +0100
++++ gcc/gcc/config.gcc 2006-03-10 15:02:41 +0100
+@@ -1905,7 +1905,7 @@
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/104-gnuhurd-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/104-gnuhurd-uclibc-conf.patch
new file mode 100644
index 0000000000..c04dd9ff00
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/104-gnuhurd-uclibc-conf.patch
@@ -0,0 +1,13 @@
+diff -rdup gcc-4.2.1.oorig/gcc/config.gcc gcc-4.2.1/gcc/config.gcc
+--- gcc-4.2.1.oorig/gcc/config.gcc 2007-10-01 11:52:52.000000000 +0200
++++ gcc-4.2.1/gcc/config.gcc 2007-10-01 13:22:12.000000000 +0200
+@@ -494,6 +494,9 @@ case ${target} in
+ alpha*)
+ tm_file="${cpu_type}/${cpu_type}.h alpha/elf.h alpha/linux.h alpha/linux-elf.h gnu.h ${tm_file}"
+ ;;
++ i[34567]86-*hurd*-*)
++ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/gnu.h gnu.h ${tm_file}"
++ ;;
+ i[34567]86-*-*)
+ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h gnu.h ${tm_file}"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/200-uclibc-locale.patch
new file mode 100644
index 0000000000..ea21388b75
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/200-uclibc-locale.patch
@@ -0,0 +1,2790 @@
+--- gcc/libstdc++-v3/acinclude.m4
++++ gcc/libstdc++-v3/acinclude.m4
+@@ -1369,7 +1369,7 @@
+ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # Deal with gettext issues. Default to not using it (=no) until we detect
+ # support for it later. Let the user turn it off via --e/d, but let that
+@@ -1385,6 +1385,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1528,6 +1531,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+@@ -0,0 +1,63 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <bits/c++config.h>
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++#endif
++
++#endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
+@@ -0,0 +1,117 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out,
++ const int __size __attribute__ ((__unused__)),
++ const char* __fmt,
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ ;
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+@@ -0,0 +1,160 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -5764,7 +5764,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5789,6 +5789,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -6019,6 +6022,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/include/c_compatibility/wchar.h
++++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+--- gcc/libstdc++-v3/include/c_std/std_cwchar.h
++++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
+@@ -182,7 +182,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/203-uclibc-locale-no__x.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/203-uclibc-locale-no__x.patch
new file mode 100644
index 0000000000..6ba47003b3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/203-uclibc-locale-no__x.patch
@@ -0,0 +1,213 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2006-03-10 15:32:37 +0100
+@@ -60,4 +60,49 @@
+ extern "C" __typeof(wctype_l) __wctype_l;
+ #endif
+
++# define __nl_langinfo_l nl_langinfo_l
++# define __strcoll_l strcoll_l
++# define __strftime_l strftime_l
++# define __strtod_l strtod_l
++# define __strtof_l strtof_l
++# define __strtold_l strtold_l
++# define __strxfrm_l strxfrm_l
++# define __newlocale newlocale
++# define __freelocale freelocale
++# define __duplocale duplocale
++# define __uselocale uselocale
++
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l iswctype_l
++# define __towlower_l towlower_l
++# define __towupper_l towupper_l
++# define __wcscoll_l wcscoll_l
++# define __wcsftime_l wcsftime_l
++# define __wcsxfrm_l wcsxfrm_l
++# define __wctype_l wctype_l
++# endif
++
++#else
++# define __nl_langinfo_l(N, L) nl_langinfo((N))
++# define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++# define __strtod_l(S, E, L) strtod((S), (E))
++# define __strtof_l(S, E, L) strtof((S), (E))
++# define __strtold_l(S, E, L) strtold((S), (E))
++# define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++# warning should dummy __newlocale check for C|POSIX ?
++# define __newlocale(a, b, c) NULL
++# define __freelocale(a) ((void)0)
++# define __duplocale(a) __c_locale()
++//# define __uselocale ?
++//
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l(C, M, L) iswctype((C), (M))
++# define __towlower_l(C, L) towlower((C))
++# define __towupper_l(C, L) towupper((C))
++# define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++//# define __wcsftime_l(S, M, F, T, L) wcsftime((S), (M), (F), (T))
++# define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++# define __wctype_l(S, L) wctype((S))
++# endif
++
+ #endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:32:37 +0100
+@@ -39,20 +39,6 @@
+ #include <langinfo.h>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
+-#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
+-#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
+-#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
+-#define __strtof_l(S, E, L) strtof((S), (E))
+-#define __strtod_l(S, E, L) strtod((S), (E))
+-#define __strtold_l(S, E, L) strtold((S), (E))
+-#warning should dummy __newlocale check for C|POSIX ?
+-#define __newlocale(a, b, c) NULL
+-#define __freelocale(a) ((void)0)
+-#define __duplocale(a) __c_locale()
+-#endif
+-
+ namespace std
+ {
+ template<>
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc 2006-03-10 15:32:37 +0100
+@@ -36,13 +36,6 @@
+ #include <locale>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
+-#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
+-#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
+-#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
+-#endif
+-
+ namespace std
+ {
+ // These are basically extensions to char_traits, and perhaps should
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:32:37 +0100
+@@ -43,10 +43,6 @@
+ #warning tailor for stub locale support
+ #endif
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+-
+ namespace std
+ {
+ // Construct and return valid pattern consisting of some combination of:
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:32:37 +0100
+@@ -41,9 +41,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc 2006-03-10 15:32:37 +0100
+@@ -40,9 +40,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:32:37 +0100
+@@ -38,13 +38,6 @@
+ #undef _LIBC
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __wctype_l(S, L) wctype((S))
+-#define __towupper_l(C, L) towupper((C))
+-#define __towlower_l(C, L) towlower((C))
+-#define __iswctype_l(C, M, L) iswctype((C), (M))
+-#endif
+-
+ namespace std
+ {
+ // NB: The other ctype<char> specializations are in src/locale.cc and
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc 2006-03-10 15:32:37 +0100
+@@ -39,13 +39,10 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix gettext stuff
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__dcgettext(const char *domainname,
+- const char *msgid, int category);
+ #undef gettext
+-#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#define gettext(msgid) dcgettext(NULL, msgid, LC_MESSAGES)
+ #else
+-#undef gettext
+ #define gettext(msgid) (msgid)
+ #endif
+
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:32:37 +0100
+@@ -36,15 +36,11 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__textdomain(const char *domainname);
+-extern "C" char *__bindtextdomain(const char *domainname,
+- const char *dirname);
+-#else
+-#undef __textdomain
+-#undef __bindtextdomain
+-#define __textdomain(D) ((void)0)
+-#define __bindtextdomain(D,P) ((void)0)
++#ifndef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#undef textdomain
++#undef bindtextdomain
++#define textdomain(D) ((void)0)
++#define bindtextdomain(D,P) ((void)0)
+ #endif
+
+ // Non-virtual member functions.
+@@ -70,7 +66,7 @@
+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
+ const char* __dir) const
+ {
+- __bindtextdomain(__s.c_str(), __dir);
++ bindtextdomain(__s.c_str(), __dir);
+ return this->do_open(__s, __loc);
+ }
+
+@@ -90,7 +86,7 @@
+ {
+ // No error checking is done, assume the catalog exists and can
+ // be used.
+- __textdomain(__s.c_str());
++ textdomain(__s.c_str());
+ return 0;
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-03-10 15:32:37 +0100
+@@ -68,6 +68,7 @@
+ {
+ extern "C" __typeof(uselocale) __uselocale;
+ }
++#define __uselocale uselocale
+ #endif
+
+ namespace std
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/204-uclibc-locale-wchar_fix.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/204-uclibc-locale-wchar_fix.patch
new file mode 100644
index 0000000000..160ab35bb3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/204-uclibc-locale-wchar_fix.patch
@@ -0,0 +1,48 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:37:27 +0100
+@@ -401,7 +401,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+@@ -556,7 +556,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:37:27 +0100
+@@ -127,12 +127,25 @@
+ {
+ // Named locale.
+ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be numeric
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
+ union { char *__s; wchar_t __w; } __u;
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_data->_M_decimal_point = __u.__w;
+
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
+ _M_data->_M_thousands_sep = __u.__w;
++#endif
+
+ if (_M_data->_M_thousands_sep == L'\0')
+ _M_data->_M_grouping = "";
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/205-uclibc-locale-update.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/205-uclibc-locale-update.patch
new file mode 100644
index 0000000000..86b2844554
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/205-uclibc-locale-update.patch
@@ -0,0 +1,347 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
+@@ -46,16 +47,13 @@
+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- float __f = __strtof_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __f;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -63,16 +61,13 @@
+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- double __d = __strtod_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __d;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -80,16 +75,13 @@
+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- long double __ld = __strtold_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __ld;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ void
+@@ -110,7 +102,7 @@
+ void
+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
+ {
+- if (_S_get_c_locale() != __cloc)
++ if (__cloc && _S_get_c_locale() != __cloc)
+ __freelocale(__cloc);
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ namespace std
+@@ -138,20 +143,34 @@
+ ctype<wchar_t>::
+ do_is(mask __m, wchar_t __c) const
+ {
+- // Highest bitmask in ctype_base == 10, but extra in "C"
+- // library for blank.
++ // The case of __m == ctype_base::space is particularly important,
++ // due to its use in many istream functions. Therefore we deal with
++ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
++ // is the mask corresponding to ctype_base::space. NB: an encoding
++ // change would not affect correctness!
+ bool __ret = false;
+- const size_t __bitmasksize = 11;
+- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+- if (__m & _M_bit[__bitcur]
+- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
+- {
+- __ret = true;
+- break;
+- }
++ if (__m == _M_bit[5])
++ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
++ else
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur])
++ {
++ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ else if (__m == _M_bit[__bitcur])
++ break;
++ }
++ }
+ return __ret;
+ }
+-
++
+ const wchar_t*
+ ctype<wchar_t>::
+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
+@@ -47,18 +47,21 @@
+ template<typename _CharT>
+ messages<_CharT>::messages(size_t __refs)
+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
+- _M_name_messages(_S_get_c_name())
++ _M_name_messages(_S_get_c_name())
+ { }
+
+ template<typename _CharT>
+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
+ size_t __refs)
+- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
+- _M_name_messages(__s)
++ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_messages = __tmp;
++
++ // Last to avoid leaking memory if new throws.
++ _M_c_locale_messages = _S_clone_c_locale(__cloc);
+ }
+
+ template<typename _CharT>
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+@@ -206,7 +211,7 @@
+ }
+ break;
+ default:
+- ;
++ __ret = pattern();
+ }
+ return __ret;
+ }
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
+@@ -37,25 +37,33 @@
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
+ size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(__s)
++ _M_name_timepunct(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_timepunct = __tmp;
+- _M_initialize_timepunct(__cloc);
++
++ try
++ { _M_initialize_timepunct(__cloc); }
++ catch(...)
++ {
++ delete [] _M_name_timepunct;
++ __throw_exception_again;
++ }
+ }
+
+ template<typename _CharT>
+--- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
+@@ -39,21 +39,23 @@
+ #pragma GCC system_header
+
+ #include <cstring> // get std::strlen
+-#include <cstdio> // get std::snprintf or std::sprintf
++#include <cstdio> // get std::vsnprintf or std::vsprintf
+ #include <clocale>
+ #include <langinfo.h> // For codecvt
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix this
+ #endif
+-#ifdef __UCLIBC_HAS_LOCALE__
++#ifdef _GLIBCXX_USE_ICONV
+ #include <iconv.h> // For codecvt using iconv, iconv_t
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-#include <libintl.h> // For messages
++#ifdef HAVE_LIBINTL_H
++#include <libintl.h> // For messages
+ #endif
++#include <cstdarg>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning what is _GLIBCXX_C_LOCALE_GNU for
++// psm: used in os/gnu-linux/ctype_noninline.h
+ #endif
+ #define _GLIBCXX_C_LOCALE_GNU 1
+
+@@ -62,7 +64,7 @@
+ #endif
+ // #define _GLIBCXX_NUM_CATEGORIES 6
+ #define _GLIBCXX_NUM_CATEGORIES 0
+-
++
+ #ifdef __UCLIBC_HAS_XLOCALE__
+ namespace __gnu_cxx
+ {
+@@ -79,22 +81,24 @@
+ typedef int* __c_locale;
+ #endif
+
+- // Convert numeric value of type _Tv to string and return length of
+- // string. If snprintf is available use it, otherwise fall back to
+- // the unsafe sprintf which, in general, can be dangerous and should
++ // Convert numeric value of type double to string and return length of
++ // string. If vsnprintf is available use it, otherwise fall back to
++ // the unsafe vsprintf which, in general, can be dangerous and should
+ // be avoided.
+- template<typename _Tv>
+- int
+- __convert_from_v(char* __out,
+- const int __size __attribute__ ((__unused__)),
+- const char* __fmt,
+-#ifdef __UCLIBC_HAS_XCLOCALE__
+- _Tv __v, const __c_locale& __cloc, int __prec)
++ inline int
++ __convert_from_v(const __c_locale&
++#ifndef __UCLIBC_HAS_XCLOCALE__
++ __cloc __attribute__ ((__unused__))
++#endif
++ ,
++ char* __out,
++ const int __size,
++ const char* __fmt, ...)
+ {
++ va_list __args;
++#ifdef __UCLIBC_HAS_XCLOCALE__
+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
+ #else
+- _Tv __v, const __c_locale&, int __prec)
+- {
+ # ifdef __UCLIBC_HAS_LOCALE__
+ char* __old = std::setlocale(LC_ALL, NULL);
+ char* __sav = new char[std::strlen(__old) + 1];
+@@ -103,7 +107,9 @@
+ # endif
+ #endif
+
+- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++ va_start(__args, __fmt);
++ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
++ va_end(__args);
+
+ #ifdef __UCLIBC_HAS_XCLOCALE__
+ __gnu_cxx::__uselocale(__old);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..560bcb237b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/300-libstdc++-pic.patch
@@ -0,0 +1,50 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,12 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+@@ -627,7 +627,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -660,6 +660,7 @@
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-data-local install-exec \
++ install-exec-local \
+ install-exec-am install-info install-info-am install-man \
+ install-strip install-toolexeclibLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+@@ -743,6 +743,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/304-index_macro.patch
new file mode 100644
index 0000000000..d8e476555d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/306-libstdc++-namespace.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/306-libstdc++-namespace.patch
new file mode 100644
index 0000000000..69587ca63a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/306-libstdc++-namespace.patch
@@ -0,0 +1,36 @@
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 15:23:41.000000000 +0100
+@@ -32,7 +32,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+@@ -115,3 +116,4 @@
+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
+ }
++}
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 15:20:31.000000000 +0100
+@@ -33,7 +33,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+@@ -74,3 +75,4 @@
+ delete _M_data;
+ _S_destroy_c_locale(_M_c_locale_timepunct);
+ }
++}
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/307-locale_facets.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/307-locale_facets.patch
new file mode 100644
index 0000000000..412f8657dc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/307-locale_facets.patch
@@ -0,0 +1,26 @@
+This patch fixes a bug into ostream::operator<<(double) due to the wrong size
+passed into the __convert_from_v method. The wrong size is then passed to
+std::snprintf function, that, on uClibc, doens't handle sized 0 buffer.
+
+Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+--- gcc-4.2.1/libstdc++-v3/include/bits/locale_facets.tcc 2006-10-17 18:43:47.000000000 +0200
++++ gcc-4.2.1-st/libstdc++-v3/include/bits/locale_facets.tcc 2007-08-22 18:54:23.000000000 +0200
+@@ -1143,7 +1143,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ const int __cs_size = __fixed ? __max_exp + __prec + 4
+ : __max_digits * 2 + __prec;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
++ __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf,
+ __prec, __v);
+ #endif
+
+@@ -1777,7 +1777,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
+ const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
++ int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, "%.*Lf",
+ 0, __units);
+ #endif
+ string_type __digits(__len, char_type());
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..0bf115c45d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.2/gcc/Makefile.in
+===================================================================
+--- gcc-4.2/gcc/Makefile.in (revision 121758)
++++ gcc-4.2/gcc/Makefile.in (working copy)
+@@ -2658,7 +2658,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H)
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
++ insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE) gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/800-arm-bigendian.patch
new file mode 100644
index 0000000000..07c6093379
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/800-arm-bigendian.patch
@@ -0,0 +1,67 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-4.2.0/gcc/config/arm/linux-elf.h
++++ gcc-4.2.0/gcc/config/arm/linux-elf.h
+@@ -28,19 +28,33 @@
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* Now we define the strings used to build the spec file. */
+ #undef LIB_SPEC
+@@ -61,7 +75,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #undef LINK_SPEC
+--- gcc-4.2.0/gcc/config.gcc.orig 2006-09-22 14:53:41.000000000 +0200
++++ gcc-4.2.0/gcc/config.gcc 2006-09-25 10:45:21.000000000 +0200
+@@ -696,6 +696,11 @@
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+ tmake_file="${tmake_file} t-linux arm/t-arm"
+ case ${target} in
++ arm*b-*)
++ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
++ ;;
++ esac
++ case ${target} in
+ arm*-*-linux-*eabi)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/904-flatten-switch-stmt-00.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/904-flatten-switch-stmt-00.patch
new file mode 100644
index 0000000000..8fac37c4df
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/904-flatten-switch-stmt-00.patch
@@ -0,0 +1,153 @@
+Hi,
+
+The attached patch makes sure that we create smaller object code for
+simple switch statements. We just make sure to flatten the switch
+statement into an if-else chain, basically.
+
+This fixes a size-regression as compared to gcc-3.4, as can be seen
+below.
+
+2007-04-15 Bernhard Fischer <..>
+
+ * stmt.c (expand_case): Do not create a complex binary tree when
+ optimizing for size but rather use the simple ordered list.
+ (emit_case_nodes): do not emit jumps to the default_label when
+ optimizing for size.
+
+Not regtested so far.
+Comments?
+
+Attached is the test switch.c mentioned below.
+
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -DCHAIN -Os -o switch-CHAIN-$i.o -c switch.c ;done
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -UCHAIN -Os -o switch-$i.o -c switch.c ;done
+
+$ size switch-*.o
+ text data bss dec hex filename
+ 169 0 0 169 a9 switch-2.95.o
+ 115 0 0 115 73 switch-3.3.o
+ 103 0 0 103 67 switch-3.4.o
+ 124 0 0 124 7c switch-4.0.o
+ 124 0 0 124 7c switch-4.1.o
+ 124 0 0 124 7c switch-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-4.3-HEAD.o
+ 124 0 0 124 7c switch-4.3.orig-HEAD.o
+ 166 0 0 166 a6 switch-CHAIN-2.95.o
+ 111 0 0 111 6f switch-CHAIN-3.3.o
+ 95 0 0 95 5f switch-CHAIN-3.4.o
+ 95 0 0 95 5f switch-CHAIN-4.0.o
+ 95 0 0 95 5f switch-CHAIN-4.1.o
+ 95 0 0 95 5f switch-CHAIN-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3.orig-HEAD.o
+
+
+Content-Type: text/x-diff; charset=us-ascii
+Content-Disposition: attachment; filename="gcc-4.3.gcc-flatten-switch-stmt.00.diff"
+
+Index: gcc-4.2.0/gcc/stmt.c
+===================================================================
+--- gcc-4.2.0.orig/gcc/stmt.c (revision 123843)
++++ gcc-4.2.0/gcc/stmt.c (working copy)
+@@ -2517,7 +2517,11 @@ expand_case (tree exp)
+ use_cost_table
+ = (TREE_CODE (orig_type) != ENUMERAL_TYPE
+ && estimate_case_costs (case_list));
+- balance_case_nodes (&case_list, NULL);
++ /* When optimizing for size, we want a straight list to avoid
++ jumps as much as possible. This basically creates an if-else
++ chain. */
++ if (!optimize_size)
++ balance_case_nodes (&case_list, NULL);
+ emit_case_nodes (index, case_list, default_label, index_type);
+ emit_jump (default_label);
+ }
+@@ -3075,6 +3079,7 @@ emit_case_nodes (rtx index, case_node_pt
+ {
+ if (!node_has_low_bound (node, index_type))
+ {
++ if (!optimize_size) /* don't jl to the .default_label. */
+ emit_cmp_and_jump_insns (index,
+ convert_modes
+ (mode, imode,
+
+
+Content-Type: text/x-csrc; charset=us-ascii
+Content-Disposition: attachment; filename="switch.c"
+
+int
+commutative_tree_code (int code)
+{
+#define CASE(val, ret) case val:/* __asm__("# val="#val ",ret="#ret);*/ return ret;
+#ifndef CHAIN
+ switch (code)
+ {
+# if 1
+ CASE(1,3)
+ CASE(3,2)
+ CASE(5,8)
+ CASE(7,1)
+ CASE(33,4)
+ CASE(44,9)
+ CASE(55,10)
+ CASE(66,-1)
+ CASE(77,99)
+ CASE(666,0)
+# else
+ case 1:
+ return 3;
+ case 3:
+ return 2;
+ case 5:
+ return 8;
+ case 7:
+ return 1;
+ case 33:
+ return 4;
+ case 44:
+ return 9;
+ case 55:
+ return 10;
+ case 66:
+ return -1;
+ case 77:
+ return 99;
+ case 666:
+ return 0;
+# endif
+ default:
+ break;
+ }
+ return 4711;
+
+#else
+ if (code == 1)
+ return 3;
+ else if (code == 3)
+ return 2;
+ else if (code == 5)
+ return 8;
+ else if (code == 7)
+ return 1;
+ else if (code == 33)
+ return 4;
+ else if (code == 44)
+ return 9;
+ else if (code == 55)
+ return 10;
+ else if (code == 66)
+ return -1;
+ else if (code == 77)
+ return 99;
+ else if (code == 666)
+ return 0;
+ else
+ return 4711;
+#endif
+}
+
+
+--AhhlLboLdkugWU4S--
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/910-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/910-soft-float.patch
new file mode 100644
index 0000000000..3f886acbf5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/910-soft-float.patch
@@ -0,0 +1,26 @@
+--- gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
+@@ -4,7 +4,10 @@
+ LIBGCC2_DEBUG_CFLAGS = -g0
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+
+--- gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
+@@ -63,7 +63,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.3/920-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.3/920-soft-float.patch
new file mode 100644
index 0000000000..4287bfae27
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.3/920-soft-float.patch
@@ -0,0 +1,21 @@
+diff -uNpr gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c
+--- gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c 2007-03-05 11:54:00.000000000 -0500
++++ gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c 2008-01-31 17:51:24.000000000 -0500
+@@ -70,6 +70,8 @@ Software Foundation, 51 Franklin Street,
+ but GCC currently generates poor code when a union is used to turn
+ a long double into a pair of doubles. */
+
++#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
++
+ long double __gcc_qadd (double, double, double, double);
+ long double __gcc_qsub (double, double, double, double);
+ long double __gcc_qmul (double, double, double, double);
+@@ -219,8 +221,6 @@ __gcc_qdiv (double a, double b, double c
+ return z.ldval;
+ }
+
+-#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
+-
+ long double __gcc_qneg (double, double);
+ int __gcc_qeq (double, double, double, double);
+ int __gcc_qne (double, double, double, double);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/100-uclibc-conf.patch
new file mode 100644
index 0000000000..4243ff7b91
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/100-uclibc-conf.patch
@@ -0,0 +1,200 @@
+--- gcc/libgomp/configure
++++ gcc/libgomp/configure
+@@ -3771,7 +3771,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/gcc/config/cris/linux.h
++++ gcc/gcc/config/cris/linux.h
+@@ -74,7 +74,11 @@
+ #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
+
+ #undef CRIS_SUBTARGET_VERSION
+-#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#if UCLIBC_DEFAULT
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
++#else
++# define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
++#endif
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -4276,7 +4276,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/zlib/configure
++++ gcc/zlib/configure
+@@ -3422,7 +3422,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libobjc/configure
++++ gcc/libobjc/configure
+@@ -3309,7 +3309,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libgfortran/configure
++++ gcc/libgfortran/configure
+@@ -3695,7 +3695,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libmudflap/configure
++++ gcc/libmudflap/configure
+@@ -5378,7 +5378,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/boehm-gc/configure
++++ gcc/boehm-gc/configure
+@@ -4316,7 +4316,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libffi/configure
++++ gcc/libffi/configure
+@@ -3453,7 +3453,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libssp/configure
++++ gcc/libssp/configure
+@@ -4409,7 +4409,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/contrib/regression/objs-gcc.sh
++++ gcc/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc/libjava/classpath/ltconfig
++++ gcc/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+--- gcc/libjava/classpath/configure
++++ gcc/libjava/classpath/configure
+@@ -4665,7 +4665,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libjava/configure
++++ gcc/libjava/configure
+@@ -5212,7 +5212,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/libtool.m4
++++ gcc/libtool.m4
+@@ -739,7 +739,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+--- gcc/ltconfig
++++ gcc/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/103-uclibc-conf-noupstream.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/103-uclibc-conf-noupstream.patch
new file mode 100644
index 0000000000..09c9bbecfb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/103-uclibc-conf-noupstream.patch
@@ -0,0 +1,11 @@
+--- gcc/gcc/config.gcc.uclibc100-sh~ 2006-03-06 20:46:56 +0100
++++ gcc/gcc/config.gcc 2006-03-10 15:02:41 +0100
+@@ -1905,7 +1905,7 @@
+ ;;
+ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
+ sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
+- sh-*-linux* | sh[346lbe]*-*-linux* | \
++ sh*-*-linux* | sh[346lbe]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+ sh64-*-netbsd* | sh64l*-*-netbsd*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/104-gnuhurd-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/104-gnuhurd-uclibc-conf.patch
new file mode 100644
index 0000000000..c04dd9ff00
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/104-gnuhurd-uclibc-conf.patch
@@ -0,0 +1,13 @@
+diff -rdup gcc-4.2.1.oorig/gcc/config.gcc gcc-4.2.1/gcc/config.gcc
+--- gcc-4.2.1.oorig/gcc/config.gcc 2007-10-01 11:52:52.000000000 +0200
++++ gcc-4.2.1/gcc/config.gcc 2007-10-01 13:22:12.000000000 +0200
+@@ -494,6 +494,9 @@ case ${target} in
+ alpha*)
+ tm_file="${cpu_type}/${cpu_type}.h alpha/elf.h alpha/linux.h alpha/linux-elf.h gnu.h ${tm_file}"
+ ;;
++ i[34567]86-*hurd*-*)
++ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/gnu.h gnu.h ${tm_file}"
++ ;;
+ i[34567]86-*-*)
+ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h gnu.h ${tm_file}"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/200-uclibc-locale.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/200-uclibc-locale.patch
new file mode 100644
index 0000000000..ea21388b75
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/200-uclibc-locale.patch
@@ -0,0 +1,2790 @@
+--- gcc/libstdc++-v3/acinclude.m4
++++ gcc/libstdc++-v3/acinclude.m4
+@@ -1369,7 +1369,7 @@
+ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
+ GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
+ [use MODEL for target locale package],
+- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
++ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
+
+ # Deal with gettext issues. Default to not using it (=no) until we detect
+ # support for it later. Let the user turn it off via --e/d, but let that
+@@ -1385,6 +1385,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ *-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ AC_EGREP_CPP([_GLIBCXX_ok], [
+ #include <features.h>
+@@ -1528,6 +1531,40 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ AC_MSG_RESULT(uclibc)
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++ AC_SUBST(glibcxx_MOFILES)
++ AC_SUBST(glibcxx_POFILES)
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
+@@ -0,0 +1,63 @@
++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
++
++// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++// Written by Jakub Jelinek <jakub@redhat.com>
++
++#include <bits/c++config.h>
++#include <clocale>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning clean this up
++#endif
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++
++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
++extern "C" __typeof(strcoll_l) __strcoll_l;
++extern "C" __typeof(strftime_l) __strftime_l;
++extern "C" __typeof(strtod_l) __strtod_l;
++extern "C" __typeof(strtof_l) __strtof_l;
++extern "C" __typeof(strtold_l) __strtold_l;
++extern "C" __typeof(strxfrm_l) __strxfrm_l;
++extern "C" __typeof(newlocale) __newlocale;
++extern "C" __typeof(freelocale) __freelocale;
++extern "C" __typeof(duplocale) __duplocale;
++extern "C" __typeof(uselocale) __uselocale;
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++extern "C" __typeof(iswctype_l) __iswctype_l;
++extern "C" __typeof(towlower_l) __towlower_l;
++extern "C" __typeof(towupper_l) __towupper_l;
++extern "C" __typeof(wcscoll_l) __wcscoll_l;
++extern "C" __typeof(wcsftime_l) __wcsftime_l;
++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
++extern "C" __typeof(wctype_l) __wctype_l;
++#endif
++
++#endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
+@@ -0,0 +1,160 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <cerrno> // For errno
++#include <locale>
++#include <stdexcept>
++#include <langinfo.h>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
++#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
++#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
++#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
++#define __strtof_l(S, E, L) strtof((S), (E))
++#define __strtod_l(S, E, L) strtod((S), (E))
++#define __strtold_l(S, E, L) strtold((S), (E))
++#warning should dummy __newlocale check for C|POSIX ?
++#define __newlocale(a, b, c) NULL
++#define __freelocale(a) ((void)0)
++#define __duplocale(a) __c_locale()
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ template<>
++ void
++ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
++ const __c_locale& __cloc)
++ {
++ if (!(__err & ios_base::failbit))
++ {
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
++ }
++ }
++
++ void
++ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
++ __c_locale __old)
++ {
++ __cloc = __newlocale(1 << LC_ALL, __s, __old);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ if (!__cloc)
++ {
++ // This named locale is not supported by the underlying OS.
++ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
++ "name not valid"));
++ }
++#endif
++ }
++
++ void
++ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
++ {
++ if (_S_get_c_locale() != __cloc)
++ __freelocale(__cloc);
++ }
++
++ __c_locale
++ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
++ { return __duplocale(__cloc); }
++} // namespace std
++
++namespace __gnu_cxx
++{
++ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
++ {
++ "LC_CTYPE",
++ "LC_NUMERIC",
++ "LC_TIME",
++ "LC_COLLATE",
++ "LC_MONETARY",
++ "LC_MESSAGES",
++#if _GLIBCXX_NUM_CATEGORIES != 0
++ "LC_PAPER",
++ "LC_NAME",
++ "LC_ADDRESS",
++ "LC_TELEPHONE",
++ "LC_MEASUREMENT",
++ "LC_IDENTIFICATION"
++#endif
++ };
++}
++
++namespace std
++{
++ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
++} // namespace std
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
+@@ -0,0 +1,117 @@
++// Wrapper for underlying C-language localization -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.8 Standard locale categories.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifndef _C_LOCALE_H
++#define _C_LOCALE_H 1
++
++#pragma GCC system_header
++
++#include <cstring> // get std::strlen
++#include <cstdio> // get std::snprintf or std::sprintf
++#include <clocale>
++#include <langinfo.h> // For codecvt
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this
++#endif
++#ifdef __UCLIBC_HAS_LOCALE__
++#include <iconv.h> // For codecvt using iconv, iconv_t
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#include <libintl.h> // For messages
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning what is _GLIBCXX_C_LOCALE_GNU for
++#endif
++#define _GLIBCXX_C_LOCALE_GNU 1
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix categories
++#endif
++// #define _GLIBCXX_NUM_CATEGORIES 6
++#define _GLIBCXX_NUM_CATEGORIES 0
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++namespace __gnu_cxx
++{
++ extern "C" __typeof(uselocale) __uselocale;
++}
++#endif
++
++namespace std
++{
++#ifdef __UCLIBC_HAS_XLOCALE__
++ typedef __locale_t __c_locale;
++#else
++ typedef int* __c_locale;
++#endif
++
++ // Convert numeric value of type _Tv to string and return length of
++ // string. If snprintf is available use it, otherwise fall back to
++ // the unsafe sprintf which, in general, can be dangerous and should
++ // be avoided.
++ template<typename _Tv>
++ int
++ __convert_from_v(char* __out,
++ const int __size __attribute__ ((__unused__)),
++ const char* __fmt,
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ _Tv __v, const __c_locale& __cloc, int __prec)
++ {
++ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
++#else
++ _Tv __v, const __c_locale&, int __prec)
++ {
++# ifdef __UCLIBC_HAS_LOCALE__
++ char* __old = std::setlocale(LC_ALL, NULL);
++ char* __sav = new char[std::strlen(__old) + 1];
++ std::strcpy(__sav, __old);
++ std::setlocale(LC_ALL, "C");
++# endif
++#endif
++
++ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++
++#ifdef __UCLIBC_HAS_XCLOCALE__
++ __gnu_cxx::__uselocale(__old);
++#elif defined __UCLIBC_HAS_LOCALE__
++ std::setlocale(LC_ALL, __sav);
++ delete [] __sav;
++#endif
++ return __ret;
++ }
++}
++
++#endif
+--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
+@@ -0,0 +1,306 @@
++// std::codecvt implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++namespace std
++{
++ // Specializations.
++#ifdef _GLIBCXX_USE_WCHAR_T
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_out(state_type& __state, const intern_type* __from,
++ const intern_type* __from_end, const intern_type*& __from_next,
++ extern_type* __to, extern_type* __to_end,
++ extern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
++ // in case we fall back to wcrtomb and then continue, in a loop.
++ // NB: wcsnrtombs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
++ __from_end - __from_next);
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // wcrtomb.
++ for (; __from < __from_next; ++__from)
++ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ extern_type __buf[MB_LEN_MAX];
++ __tmp_state = __state;
++ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
++ if (__conv > static_cast<size_t>(__to_end - __to_next))
++ __ret = partial;
++ else
++ {
++ memcpy(__to_next, __buf, __conv);
++ __state = __tmp_state;
++ __to_next += __conv;
++ ++__from_next;
++ }
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ codecvt_base::result
++ codecvt<wchar_t, char, mbstate_t>::
++ do_in(state_type& __state, const extern_type* __from,
++ const extern_type* __from_end, const extern_type*& __from_next,
++ intern_type* __to, intern_type* __to_end,
++ intern_type*& __to_next) const
++ {
++ result __ret = ok;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we store a L'\0' and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++ for (__from_next = __from, __to_next = __to;
++ __from_next < __from_end && __to_next < __to_end
++ && __ret == ok;)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
++ __from_end
++ - __from_next));
++ if (!__from_chunk_end)
++ __from_chunk_end = __from_end;
++
++ __from = __from_next;
++ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
++ __from_chunk_end - __from_next,
++ __to_end - __to_next, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (;; ++__to_next, __from += __conv)
++ {
++ __conv = mbrtowc(__to_next, __from, __from_end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __from_next = __from;
++ __state = __tmp_state;
++ __ret = error;
++ }
++ else if (__from_next && __from_next < __from_chunk_end)
++ {
++ // It is unclear what to return in this case (see DR 382).
++ __to_next += __conv;
++ __ret = partial;
++ }
++ else
++ {
++ __from_next = __from_chunk_end;
++ __to_next += __conv;
++ }
++
++ if (__from_next < __from_end && __ret == ok)
++ {
++ if (__to_next < __to_end)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from_next;
++ *__to_next++ = L'\0';
++ }
++ else
++ __ret = partial;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_encoding() const throw()
++ {
++ // XXX This implementation assumes that the encoding is
++ // stateless and is either single-byte or variable-width.
++ int __ret = 0;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ if (MB_CUR_MAX == 1)
++ __ret = 1;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_max_length() const throw()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++ // XXX Probably wrong for stateful encodings.
++ int __ret = MB_CUR_MAX;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __ret;
++ }
++
++ int
++ codecvt<wchar_t, char, mbstate_t>::
++ do_length(state_type& __state, const extern_type* __from,
++ const extern_type* __end, size_t __max) const
++ {
++ int __ret = 0;
++ state_type __tmp_state(__state);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_codecvt);
++#endif
++
++ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
++ // in case we advance past it and then continue, in a loop.
++ // NB: mbsnrtowcs is a GNU extension
++
++ // A dummy internal buffer is needed in order for mbsnrtocws to consider
++ // its fourth parameter (it wouldn't with NULL as first parameter).
++ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
++ * __max));
++ while (__from < __end && __max)
++ {
++ const extern_type* __from_chunk_end;
++ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
++ __end
++ - __from));
++ if (!__from_chunk_end)
++ __from_chunk_end = __end;
++
++ const extern_type* __tmp_from = __from;
++ size_t __conv = mbsnrtowcs(__to, &__from,
++ __from_chunk_end - __from,
++ __max, &__state);
++ if (__conv == static_cast<size_t>(-1))
++ {
++ // In case of error, in order to stop at the exact place we
++ // have to start again from the beginning with a series of
++ // mbrtowc.
++ for (__from = __tmp_from;; __from += __conv)
++ {
++ __conv = mbrtowc(NULL, __from, __end - __from,
++ &__tmp_state);
++ if (__conv == static_cast<size_t>(-1)
++ || __conv == static_cast<size_t>(-2))
++ break;
++ }
++ __state = __tmp_state;
++ __ret += __from - __tmp_from;
++ break;
++ }
++ if (!__from)
++ __from = __from_chunk_end;
++
++ __ret += __from - __tmp_from;
++ __max -= __conv;
++
++ if (__from < __end && __max)
++ {
++ // XXX Probably wrong for stateful encodings
++ __tmp_state = __state;
++ ++__from;
++ ++__ret;
++ --__max;
++ }
++ }
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++
++ return __ret;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
+@@ -0,0 +1,80 @@
++// std::collate implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++#endif
++
++namespace std
++{
++ // These are basically extensions to char_traits, and perhaps should
++ // be put there instead of here.
++ template<>
++ int
++ collate<char>::_M_compare(const char* __one, const char* __two) const
++ {
++ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<char>::_M_transform(char* __to, const char* __from,
++ size_t __n) const
++ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ int
++ collate<wchar_t>::_M_compare(const wchar_t* __one,
++ const wchar_t* __two) const
++ {
++ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
++ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
++ }
++
++ template<>
++ size_t
++ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
++ size_t __n) const
++ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
+@@ -0,0 +1,300 @@
++// std::ctype implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __wctype_l(S, L) wctype((S))
++#define __towupper_l(C, L) towupper((C))
++#define __towlower_l(C, L) towlower((C))
++#define __iswctype_l(C, M, L) iswctype((C), (M))
++#endif
++
++namespace std
++{
++ // NB: The other ctype<char> specializations are in src/locale.cc and
++ // various /config/os/* files.
++ template<>
++ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
++ : ctype<char>(0, false, __refs)
++ {
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
++ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
++ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
++ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
++#endif
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ ctype<wchar_t>::__wmask_type
++ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
++ {
++ __wmask_type __ret;
++ switch (__m)
++ {
++ case space:
++ __ret = __wctype_l("space", _M_c_locale_ctype);
++ break;
++ case print:
++ __ret = __wctype_l("print", _M_c_locale_ctype);
++ break;
++ case cntrl:
++ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
++ break;
++ case upper:
++ __ret = __wctype_l("upper", _M_c_locale_ctype);
++ break;
++ case lower:
++ __ret = __wctype_l("lower", _M_c_locale_ctype);
++ break;
++ case alpha:
++ __ret = __wctype_l("alpha", _M_c_locale_ctype);
++ break;
++ case digit:
++ __ret = __wctype_l("digit", _M_c_locale_ctype);
++ break;
++ case punct:
++ __ret = __wctype_l("punct", _M_c_locale_ctype);
++ break;
++ case xdigit:
++ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
++ break;
++ case alnum:
++ __ret = __wctype_l("alnum", _M_c_locale_ctype);
++ break;
++ case graph:
++ __ret = __wctype_l("graph", _M_c_locale_ctype);
++ break;
++ default:
++ __ret = __wmask_type();
++ }
++ return __ret;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_toupper(wchar_t __c) const
++ { return __towupper_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ wchar_t
++ ctype<wchar_t>::do_tolower(wchar_t __c) const
++ { return __towlower_l(__c, _M_c_locale_ctype); }
++
++ const wchar_t*
++ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi)
++ {
++ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
++ ++__lo;
++ }
++ return __hi;
++ }
++
++ bool
++ ctype<wchar_t>::
++ do_is(mask __m, wchar_t __c) const
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ bool __ret = false;
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur]
++ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ return __ret;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
++ {
++ for (; __lo < __hi; ++__vec, ++__lo)
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ mask __m = 0;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
++ __m |= _M_bit[__bitcur];
++ *__vec = __m;
++ }
++ return __hi;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
++ {
++ while (__lo < __hi && !this->do_is(__m, *__lo))
++ ++__lo;
++ return __lo;
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
++ {
++ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++ ++__lo;
++ return __lo;
++ }
++
++ wchar_t
++ ctype<wchar_t>::
++ do_widen(char __c) const
++ { return _M_widen[static_cast<unsigned char>(__c)]; }
++
++ const char*
++ ctype<wchar_t>::
++ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
++ {
++ while (__lo < __hi)
++ {
++ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++ ++__lo;
++ ++__dest;
++ }
++ return __hi;
++ }
++
++ char
++ ctype<wchar_t>::
++ do_narrow(wchar_t __wc, char __dfault) const
++ {
++ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
++ return _M_narrow[__wc];
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ const int __c = wctob(__wc);
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++
++ const wchar_t*
++ ctype<wchar_t>::
++ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
++ char* __dest) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ if (_M_narrow_ok)
++ while (__lo < __hi)
++ {
++ if (*__lo >= 0 && *__lo < 128)
++ *__dest = _M_narrow[*__lo];
++ else
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ }
++ ++__lo;
++ ++__dest;
++ }
++ else
++ while (__lo < __hi)
++ {
++ const int __c = wctob(*__lo);
++ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++ ++__lo;
++ ++__dest;
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ return __hi;
++ }
++
++ void
++ ctype<wchar_t>::_M_initialize_ctype()
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_ctype);
++#endif
++ wint_t __i;
++ for (__i = 0; __i < 128; ++__i)
++ {
++ const int __c = wctob(__i);
++ if (__c == EOF)
++ break;
++ else
++ _M_narrow[__i] = static_cast<char>(__c);
++ }
++ if (__i == 128)
++ _M_narrow_ok = true;
++ else
++ _M_narrow_ok = false;
++ for (size_t __j = 0;
++ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
++ _M_widen[__j] = btowc(__j);
++
++ for (size_t __k = 0; __k <= 11; ++__k)
++ {
++ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
++ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
++ }
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#endif
++ }
++#endif // _GLIBCXX_USE_WCHAR_T
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
+@@ -0,0 +1,100 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix gettext stuff
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__dcgettext(const char *domainname,
++ const char *msgid, int category);
++#undef gettext
++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#else
++#undef gettext
++#define gettext(msgid) (msgid)
++#endif
++
++namespace std
++{
++ // Specializations.
++ template<>
++ string
++ messages<char>::do_get(catalog, int, int, const string& __dfault) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
++ __uselocale(__old);
++ return string(__msg);
++#elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ const char* __msg = gettext(__dfault.c_str());
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return string(__msg);
++#else
++ const char* __msg = gettext(__dfault.c_str());
++ return string(__msg);
++#endif
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ wstring
++ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
++ {
++# ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(_M_c_locale_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ __uselocale(__old);
++ return _M_convert_from_char(__msg);
++# elif defined __UCLIBC_HAS_LOCALE__
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_messages);
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ setlocale(LC_ALL, __old);
++ free(__old);
++ return _M_convert_from_char(__msg);
++# else
++ char* __msg = gettext(_M_convert_to_char(__dfault));
++ return _M_convert_from_char(__msg);
++# endif
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
+@@ -0,0 +1,118 @@
++// std::messages implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.7.1.2 messages functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix prototypes for *textdomain funcs
++#endif
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++extern "C" char *__textdomain(const char *domainname);
++extern "C" char *__bindtextdomain(const char *domainname,
++ const char *dirname);
++#else
++#undef __textdomain
++#undef __bindtextdomain
++#define __textdomain(D) ((void)0)
++#define __bindtextdomain(D,P) ((void)0)
++#endif
++
++ // Non-virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::messages(size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
++ _M_name_messages(_S_get_c_name())
++ { }
++
++ template<typename _CharT>
++ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
++ _M_name_messages(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_messages = __tmp;
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
++ const char* __dir) const
++ {
++ __bindtextdomain(__s.c_str(), __dir);
++ return this->do_open(__s, __loc);
++ }
++
++ // Virtual member functions.
++ template<typename _CharT>
++ messages<_CharT>::~messages()
++ {
++ if (_M_name_messages != _S_get_c_name())
++ delete [] _M_name_messages;
++ _S_destroy_c_locale(_M_c_locale_messages);
++ }
++
++ template<typename _CharT>
++ typename messages<_CharT>::catalog
++ messages<_CharT>::do_open(const basic_string<char>& __s,
++ const locale&) const
++ {
++ // No error checking is done, assume the catalog exists and can
++ // be used.
++ __textdomain(__s.c_str());
++ return 0;
++ }
++
++ template<typename _CharT>
++ void
++ messages<_CharT>::do_close(catalog) const
++ { }
++
++ // messages_byname
++ template<typename _CharT>
++ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
++ : messages<_CharT>(__refs)
++ {
++ if (this->_M_name_messages != locale::facet::_S_get_c_name())
++ delete [] this->_M_name_messages;
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ this->_M_name_messages = __tmp;
++
++ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
++ {
++ this->_S_destroy_c_locale(this->_M_c_locale_messages);
++ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
++ }
++ }
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
+@@ -0,0 +1,692 @@
++// std::moneypunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning optimize this for uclibc
++#warning tailor for stub locale support
++#endif
++
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ // Construct and return valid pattern consisting of some combination of:
++ // space none symbol sign value
++ money_base::pattern
++ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
++ {
++ pattern __ret;
++
++ // This insanely complicated routine attempts to construct a valid
++ // pattern for use with monyepunct. A couple of invariants:
++
++ // if (__precedes) symbol -> value
++ // else value -> symbol
++
++ // if (__space) space
++ // else none
++
++ // none == never first
++ // space never first or last
++
++ // Any elegant implementations of this are welcome.
++ switch (__posn)
++ {
++ case 0:
++ case 1:
++ // 1 The sign precedes the value and symbol.
++ __ret.field[0] = sign;
++ if (__space)
++ {
++ // Pattern starts with sign.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[3] = symbol;
++ }
++ __ret.field[2] = space;
++ }
++ else
++ {
++ // Pattern starts with sign and ends with none.
++ if (__precedes)
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[1] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[3] = none;
++ }
++ break;
++ case 2:
++ // 2 The sign follows the value and symbol.
++ if (__space)
++ {
++ // Pattern either ends with sign.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[2] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[2] = symbol;
++ }
++ __ret.field[1] = space;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ // Pattern ends with sign then none.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = value;
++ }
++ else
++ {
++ __ret.field[0] = value;
++ __ret.field[1] = symbol;
++ }
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ break;
++ case 3:
++ // 3 The sign immediately precedes the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = sign;
++ __ret.field[1] = symbol;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = sign;
++ __ret.field[3] = symbol;
++ }
++ else
++ {
++ __ret.field[1] = sign;
++ __ret.field[2] = symbol;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ case 4:
++ // 4 The sign immediately follows the symbol.
++ if (__precedes)
++ {
++ __ret.field[0] = symbol;
++ __ret.field[1] = sign;
++ if (__space)
++ {
++ __ret.field[2] = space;
++ __ret.field[3] = value;
++ }
++ else
++ {
++ __ret.field[2] = value;
++ __ret.field[3] = none;
++ }
++ }
++ else
++ {
++ __ret.field[0] = value;
++ if (__space)
++ {
++ __ret.field[1] = space;
++ __ret.field[2] = symbol;
++ __ret.field[3] = sign;
++ }
++ else
++ {
++ __ret.field[1] = symbol;
++ __ret.field[2] = sign;
++ __ret.field[3] = none;
++ }
++ }
++ break;
++ default:
++ ;
++ }
++ return __ret;
++ }
++
++ template<>
++ void
++ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == true
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ void
++ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
++ const char*)
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<char, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = "";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = "";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = "";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
++ __cloc));
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
++
++ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ if (!__nposn)
++ _M_data->_M_negative_sign = "()";
++ else
++ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
++ __cloc);
++ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
++
++ // _Intl == false
++ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++ }
++ }
++
++ template<>
++ moneypunct<char, true>::~moneypunct()
++ { delete _M_data; }
++
++ template<>
++ moneypunct<char, false>::~moneypunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, true>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
++ __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ void
++ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const char*)
++#else
++ const char* __name)
++#endif
++ {
++ if (!_M_data)
++ _M_data = new __moneypunct_cache<wchar_t, false>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = 0;
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = 0;
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = 0;
++ _M_data->_M_frac_digits = 0;
++ _M_data->_M_pos_format = money_base::_S_default_pattern;
++ _M_data->_M_neg_format = money_base::_S_default_pattern;
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
++ _M_data->_M_atoms[__i] =
++ static_cast<wchar_t>(money_base::_S_atoms[__i]);
++ }
++ else
++ {
++ // Named locale.
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __c_locale __old = __uselocale(__cloc);
++#else
++ // Switch to named locale so that mbsrtowcs will work.
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, __name);
++#endif
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be monetary
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# else
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++#endif
++ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++
++ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
++ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
++ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
++
++ wchar_t* __wcs_ps = 0;
++ wchar_t* __wcs_ns = 0;
++ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
++ try
++ {
++ mbstate_t __state;
++ size_t __len;
++ __len = strlen(__cpossign);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ps = new wchar_t[__len];
++ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
++ _M_data->_M_positive_sign = __wcs_ps;
++ }
++ else
++ _M_data->_M_positive_sign = L"";
++ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
++
++ __len = strlen(__cnegsign);
++ if (!__nposn)
++ _M_data->_M_negative_sign = L"()";
++ else if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ __wcs_ns = new wchar_t[__len];
++ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
++ _M_data->_M_negative_sign = __wcs_ns;
++ }
++ else
++ _M_data->_M_negative_sign = L"";
++ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
++
++ // _Intl == true.
++ __len = strlen(__ccurr);
++ if (__len)
++ {
++ ++__len;
++ memset(&__state, 0, sizeof(mbstate_t));
++ wchar_t* __wcs = new wchar_t[__len];
++ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
++ _M_data->_M_curr_symbol = __wcs;
++ }
++ else
++ _M_data->_M_curr_symbol = L"";
++ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
++ }
++ catch (...)
++ {
++ delete _M_data;
++ _M_data = 0;
++ delete __wcs_ps;
++ delete __wcs_ns;
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ __throw_exception_again;
++ }
++
++ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
++ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
++ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
++ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
++ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
++ __pposn);
++ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
++ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
++ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
++ __nposn);
++
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __uselocale(__old);
++#else
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ }
++ }
++
++ template<>
++ moneypunct<wchar_t, true>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++
++ template<>
++ moneypunct<wchar_t, false>::~moneypunct()
++ {
++ if (_M_data->_M_positive_sign_size)
++ delete [] _M_data->_M_positive_sign;
++ if (_M_data->_M_negative_sign_size
++ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
++ delete [] _M_data->_M_negative_sign;
++ if (_M_data->_M_curr_symbol_size)
++ delete [] _M_data->_M_curr_symbol;
++ delete _M_data;
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
+@@ -0,0 +1,160 @@
++// std::numpunct implementation details, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#define _LIBC
++#include <locale>
++#undef _LIBC
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = '.';
++ _M_data->_M_thousands_sep = ',';
++
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
++ }
++ else
++ {
++ // Named locale.
++ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
++ __cloc));
++ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
++ __cloc));
++
++ // Check for NULL, which implies no grouping.
++ if (_M_data->_M_thousands_sep == '\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = "true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = "false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<char>::~numpunct()
++ { delete _M_data; }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __numpunct_cache<wchar_t>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_data->_M_grouping = "";
++ _M_data->_M_grouping_size = 0;
++ _M_data->_M_use_grouping = false;
++
++ _M_data->_M_decimal_point = L'.';
++ _M_data->_M_thousands_sep = L',';
++
++ // Use ctype::widen code without the facet...
++ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
++ _M_data->_M_atoms_out[__i] =
++ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
++
++ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
++ _M_data->_M_atoms_in[__j] =
++ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
++ }
++ else
++ {
++ // Named locale.
++ // NB: In the GNU model wchar_t is always 32 bit wide.
++ union { char *__s; wchar_t __w; } __u;
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
++ _M_data->_M_decimal_point = __u.__w;
++
++ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
++ _M_data->_M_thousands_sep = __u.__w;
++
++ if (_M_data->_M_thousands_sep == L'\0')
++ _M_data->_M_grouping = "";
++ else
++ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
++ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
++ }
++
++ // NB: There is no way to extact this info from posix locales.
++ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
++ _M_data->_M_truename = L"true";
++ _M_data->_M_truename_size = 4;
++ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
++ _M_data->_M_falsename = L"false";
++ _M_data->_M_falsename_size = 5;
++ }
++
++ template<>
++ numpunct<wchar_t>::~numpunct()
++ { delete _M_data; }
++ #endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
+@@ -0,0 +1,406 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++#include <locale>
++#include <bits/c++locale_internal.h>
++
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning tailor for stub locale support
++#endif
++#ifndef __UCLIBC_HAS_XLOCALE__
++#define __nl_langinfo_l(N, L) nl_langinfo((N))
++#endif
++
++namespace std
++{
++ template<>
++ void
++ __timepunct<char>::
++ _M_put(char* __s, size_t __maxlen, const char* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = strftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = '\0';
++ }
++
++ template<>
++ void
++ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<char>;
++
++ if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = "%m/%d/%y";
++ _M_data->_M_date_era_format = "%m/%d/%y";
++ _M_data->_M_time_format = "%H:%M:%S";
++ _M_data->_M_time_era_format = "%H:%M:%S";
++ _M_data->_M_date_time_format = "";
++ _M_data->_M_date_time_era_format = "";
++ _M_data->_M_am = "AM";
++ _M_data->_M_pm = "PM";
++ _M_data->_M_am_pm_format = "";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = "Sunday";
++ _M_data->_M_day2 = "Monday";
++ _M_data->_M_day3 = "Tuesday";
++ _M_data->_M_day4 = "Wednesday";
++ _M_data->_M_day5 = "Thursday";
++ _M_data->_M_day6 = "Friday";
++ _M_data->_M_day7 = "Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = "Sun";
++ _M_data->_M_aday2 = "Mon";
++ _M_data->_M_aday3 = "Tue";
++ _M_data->_M_aday4 = "Wed";
++ _M_data->_M_aday5 = "Thu";
++ _M_data->_M_aday6 = "Fri";
++ _M_data->_M_aday7 = "Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = "January";
++ _M_data->_M_month02 = "February";
++ _M_data->_M_month03 = "March";
++ _M_data->_M_month04 = "April";
++ _M_data->_M_month05 = "May";
++ _M_data->_M_month06 = "June";
++ _M_data->_M_month07 = "July";
++ _M_data->_M_month08 = "August";
++ _M_data->_M_month09 = "September";
++ _M_data->_M_month10 = "October";
++ _M_data->_M_month11 = "November";
++ _M_data->_M_month12 = "December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = "Jan";
++ _M_data->_M_amonth02 = "Feb";
++ _M_data->_M_amonth03 = "Mar";
++ _M_data->_M_amonth04 = "Apr";
++ _M_data->_M_amonth05 = "May";
++ _M_data->_M_amonth06 = "Jun";
++ _M_data->_M_amonth07 = "Jul";
++ _M_data->_M_amonth08 = "Aug";
++ _M_data->_M_amonth09 = "Sep";
++ _M_data->_M_amonth10 = "Oct";
++ _M_data->_M_amonth11 = "Nov";
++ _M_data->_M_amonth12 = "Dec";
++ }
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
++ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
++ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
++ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
++ __cloc);
++ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
++ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
++ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
++ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
++ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
++ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
++ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
++ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
++ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
++ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
++ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
++ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
++ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
++ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
++ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
++ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
++ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
++ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
++ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
++ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
++ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
++ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
++ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
++ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
++ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
++ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
++ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
++ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
++ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
++ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
++ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
++ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
++ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
++ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
++ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
++ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
++ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
++ }
++ }
++
++#ifdef _GLIBCXX_USE_WCHAR_T
++ template<>
++ void
++ __timepunct<wchar_t>::
++ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
++ const tm* __tm) const
++ {
++#ifdef __UCLIBC_HAS_XLOCALE__
++ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
++ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
++ _M_c_locale_timepunct);
++#else
++ char* __old = strdup(setlocale(LC_ALL, NULL));
++ setlocale(LC_ALL, _M_name_timepunct);
++ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
++ setlocale(LC_ALL, __old);
++ free(__old);
++#endif
++ // Make sure __s is null terminated.
++ if (__len == 0)
++ __s[0] = L'\0';
++ }
++
++ template<>
++ void
++ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
++ {
++ if (!_M_data)
++ _M_data = new __timepunct_cache<wchar_t>;
++
++#warning wide time stuff
++// if (!__cloc)
++ {
++ // "C" locale
++ _M_c_locale_timepunct = _S_get_c_locale();
++
++ _M_data->_M_date_format = L"%m/%d/%y";
++ _M_data->_M_date_era_format = L"%m/%d/%y";
++ _M_data->_M_time_format = L"%H:%M:%S";
++ _M_data->_M_time_era_format = L"%H:%M:%S";
++ _M_data->_M_date_time_format = L"";
++ _M_data->_M_date_time_era_format = L"";
++ _M_data->_M_am = L"AM";
++ _M_data->_M_pm = L"PM";
++ _M_data->_M_am_pm_format = L"";
++
++ // Day names, starting with "C"'s Sunday.
++ _M_data->_M_day1 = L"Sunday";
++ _M_data->_M_day2 = L"Monday";
++ _M_data->_M_day3 = L"Tuesday";
++ _M_data->_M_day4 = L"Wednesday";
++ _M_data->_M_day5 = L"Thursday";
++ _M_data->_M_day6 = L"Friday";
++ _M_data->_M_day7 = L"Saturday";
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ _M_data->_M_aday1 = L"Sun";
++ _M_data->_M_aday2 = L"Mon";
++ _M_data->_M_aday3 = L"Tue";
++ _M_data->_M_aday4 = L"Wed";
++ _M_data->_M_aday5 = L"Thu";
++ _M_data->_M_aday6 = L"Fri";
++ _M_data->_M_aday7 = L"Sat";
++
++ // Month names, starting with "C"'s January.
++ _M_data->_M_month01 = L"January";
++ _M_data->_M_month02 = L"February";
++ _M_data->_M_month03 = L"March";
++ _M_data->_M_month04 = L"April";
++ _M_data->_M_month05 = L"May";
++ _M_data->_M_month06 = L"June";
++ _M_data->_M_month07 = L"July";
++ _M_data->_M_month08 = L"August";
++ _M_data->_M_month09 = L"September";
++ _M_data->_M_month10 = L"October";
++ _M_data->_M_month11 = L"November";
++ _M_data->_M_month12 = L"December";
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ _M_data->_M_amonth01 = L"Jan";
++ _M_data->_M_amonth02 = L"Feb";
++ _M_data->_M_amonth03 = L"Mar";
++ _M_data->_M_amonth04 = L"Apr";
++ _M_data->_M_amonth05 = L"May";
++ _M_data->_M_amonth06 = L"Jun";
++ _M_data->_M_amonth07 = L"Jul";
++ _M_data->_M_amonth08 = L"Aug";
++ _M_data->_M_amonth09 = L"Sep";
++ _M_data->_M_amonth10 = L"Oct";
++ _M_data->_M_amonth11 = L"Nov";
++ _M_data->_M_amonth12 = L"Dec";
++ }
++#if 0
++ else
++ {
++ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
++
++ union { char *__s; wchar_t *__w; } __u;
++
++ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
++ _M_data->_M_date_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
++ _M_data->_M_date_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
++ _M_data->_M_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
++ _M_data->_M_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
++ _M_data->_M_date_time_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
++ _M_data->_M_date_time_era_format = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
++ _M_data->_M_am = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
++ _M_data->_M_pm = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
++ _M_data->_M_am_pm_format = __u.__w;
++
++ // Day names, starting with "C"'s Sunday.
++ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
++ _M_data->_M_day1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
++ _M_data->_M_day2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
++ _M_data->_M_day3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
++ _M_data->_M_day4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
++ _M_data->_M_day5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
++ _M_data->_M_day6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
++ _M_data->_M_day7 = __u.__w;
++
++ // Abbreviated day names, starting with "C"'s Sun.
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
++ _M_data->_M_aday1 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
++ _M_data->_M_aday2 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
++ _M_data->_M_aday3 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
++ _M_data->_M_aday4 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
++ _M_data->_M_aday5 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
++ _M_data->_M_aday6 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
++ _M_data->_M_aday7 = __u.__w;
++
++ // Month names, starting with "C"'s January.
++ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
++ _M_data->_M_month01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
++ _M_data->_M_month02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
++ _M_data->_M_month03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
++ _M_data->_M_month04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
++ _M_data->_M_month05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
++ _M_data->_M_month06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
++ _M_data->_M_month07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
++ _M_data->_M_month08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
++ _M_data->_M_month09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
++ _M_data->_M_month10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
++ _M_data->_M_month11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
++ _M_data->_M_month12 = __u.__w;
++
++ // Abbreviated month names, starting with "C"'s Jan.
++ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
++ _M_data->_M_amonth01 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
++ _M_data->_M_amonth02 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
++ _M_data->_M_amonth03 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
++ _M_data->_M_amonth04 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
++ _M_data->_M_amonth05 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
++ _M_data->_M_amonth06 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
++ _M_data->_M_amonth07 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
++ _M_data->_M_amonth08 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
++ _M_data->_M_amonth09 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
++ _M_data->_M_amonth10 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
++ _M_data->_M_amonth11 = __u.__w;
++ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
++ _M_data->_M_amonth12 = __u.__w;
++ }
++#endif // 0
++ }
++#endif
++}
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
+@@ -0,0 +1,68 @@
++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
++
++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
++//
++// This file is part of the GNU ISO C++ Library. This library is free
++// software; you can redistribute it and/or modify it under the
++// terms of the GNU General Public License as published by the
++// Free Software Foundation; either version 2, or (at your option)
++// any later version.
++
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++// GNU General Public License for more details.
++
++// You should have received a copy of the GNU General Public License along
++// with this library; see the file COPYING. If not, write to the Free
++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++// USA.
++
++// As a special exception, you may use this file as part of a free software
++// library without restriction. Specifically, if other files instantiate
++// templates or use macros or inline functions from this file, or you compile
++// this file and link it with other files to produce an executable, this
++// file does not by itself cause the resulting executable to be covered by
++// the GNU General Public License. This exception does not however
++// invalidate any other reasons why the executable file might be covered by
++// the GNU General Public License.
++
++//
++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
++//
++
++// Written by Benjamin Kosnik <bkoz@redhat.com>
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
++ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(_S_get_c_name())
++ { _M_initialize_timepunct(); }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
++ size_t __refs)
++ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
++ _M_name_timepunct(__s)
++ {
++ char* __tmp = new char[std::strlen(__s) + 1];
++ std::strcpy(__tmp, __s);
++ _M_name_timepunct = __tmp;
++ _M_initialize_timepunct(__cloc);
++ }
++
++ template<typename _CharT>
++ __timepunct<_CharT>::~__timepunct()
++ {
++ if (_M_name_timepunct != _S_get_c_name())
++ delete [] _M_name_timepunct;
++ delete _M_data;
++ _S_destroy_c_locale(_M_c_locale_timepunct);
++ }
+--- gcc/libstdc++-v3/configure
++++ gcc/libstdc++-v3/configure
+@@ -5764,7 +5764,7 @@
+ enableval="$enable_clocale"
+
+ case "$enableval" in
+- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
++ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
+ echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
+ { (exit 1); exit 1; }; } ;;
+@@ -5789,6 +5789,9 @@
+ # Default to "generic".
+ if test $enable_clocale_flag = auto; then
+ case ${target_os} in
++ linux-uclibc*)
++ enable_clocale_flag=uclibc
++ ;;
+ linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+@@ -6019,6 +6022,76 @@
+ CTIME_CC=config/locale/generic/time_members.cc
+ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+ ;;
++ uclibc)
++ echo "$as_me:$LINENO: result: uclibc" >&5
++echo "${ECHO_T}uclibc" >&6
++
++ # Declare intention to use gettext, and add support for specific
++ # languages.
++ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
++ ALL_LINGUAS="de fr"
++
++ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
++ # Extract the first word of "msgfmt", so it can be a program name with args.
++set dummy msgfmt; ac_word=$2
++echo "$as_me:$LINENO: checking for $ac_word" >&5
++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -n "$check_msgfmt"; then
++ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_check_msgfmt="yes"
++ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++done
++
++ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
++fi
++fi
++check_msgfmt=$ac_cv_prog_check_msgfmt
++if test -n "$check_msgfmt"; then
++ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
++echo "${ECHO_T}$check_msgfmt" >&6
++else
++ echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
++ USE_NLS=yes
++ fi
++ # Export the build objects.
++ for ling in $ALL_LINGUAS; do \
++ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
++ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
++ done
++
++
++
++ CLOCALE_H=config/locale/uclibc/c_locale.h
++ CLOCALE_CC=config/locale/uclibc/c_locale.cc
++ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
++ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
++ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
++ CMESSAGES_H=config/locale/uclibc/messages_members.h
++ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
++ CMONEY_CC=config/locale/uclibc/monetary_members.cc
++ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
++ CTIME_H=config/locale/uclibc/time_members.h
++ CTIME_CC=config/locale/uclibc/time_members.cc
++ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
++ ;;
+ esac
+
+ # This is where the testsuite looks for locale catalogs, using the
+--- gcc/libstdc++-v3/include/c_compatibility/wchar.h
++++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -101,7 +101,9 @@
+ using std::wmemcpy;
+ using std::wmemmove;
+ using std::wmemset;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using std::wcsftime;
++#endif
+
+ #if _GLIBCXX_USE_C99
+ using std::wcstold;
+--- gcc/libstdc++-v3/include/c_std/std_cwchar.h
++++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
+@@ -182,7 +182,9 @@
+ using ::wcscoll;
+ using ::wcscpy;
+ using ::wcscspn;
++#if _GLIBCXX_HAVE_WCSFTIME
+ using ::wcsftime;
++#endif
+ using ::wcslen;
+ using ::wcsncat;
+ using ::wcsncmp;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/203-uclibc-locale-no__x.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/203-uclibc-locale-no__x.patch
new file mode 100644
index 0000000000..6ba47003b3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/203-uclibc-locale-no__x.patch
@@ -0,0 +1,213 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2006-03-10 15:32:37 +0100
+@@ -60,4 +60,49 @@
+ extern "C" __typeof(wctype_l) __wctype_l;
+ #endif
+
++# define __nl_langinfo_l nl_langinfo_l
++# define __strcoll_l strcoll_l
++# define __strftime_l strftime_l
++# define __strtod_l strtod_l
++# define __strtof_l strtof_l
++# define __strtold_l strtold_l
++# define __strxfrm_l strxfrm_l
++# define __newlocale newlocale
++# define __freelocale freelocale
++# define __duplocale duplocale
++# define __uselocale uselocale
++
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l iswctype_l
++# define __towlower_l towlower_l
++# define __towupper_l towupper_l
++# define __wcscoll_l wcscoll_l
++# define __wcsftime_l wcsftime_l
++# define __wcsxfrm_l wcsxfrm_l
++# define __wctype_l wctype_l
++# endif
++
++#else
++# define __nl_langinfo_l(N, L) nl_langinfo((N))
++# define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
++# define __strtod_l(S, E, L) strtod((S), (E))
++# define __strtof_l(S, E, L) strtof((S), (E))
++# define __strtold_l(S, E, L) strtold((S), (E))
++# define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
++# warning should dummy __newlocale check for C|POSIX ?
++# define __newlocale(a, b, c) NULL
++# define __freelocale(a) ((void)0)
++# define __duplocale(a) __c_locale()
++//# define __uselocale ?
++//
++# ifdef _GLIBCXX_USE_WCHAR_T
++# define __iswctype_l(C, M, L) iswctype((C), (M))
++# define __towlower_l(C, L) towlower((C))
++# define __towupper_l(C, L) towupper((C))
++# define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
++//# define __wcsftime_l(S, M, F, T, L) wcsftime((S), (M), (F), (T))
++# define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
++# define __wctype_l(S, L) wctype((S))
++# endif
++
+ #endif // GLIBC 2.3 and later
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:32:37 +0100
+@@ -39,20 +39,6 @@
+ #include <langinfo.h>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
+-#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
+-#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
+-#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
+-#define __strtof_l(S, E, L) strtof((S), (E))
+-#define __strtod_l(S, E, L) strtod((S), (E))
+-#define __strtold_l(S, E, L) strtold((S), (E))
+-#warning should dummy __newlocale check for C|POSIX ?
+-#define __newlocale(a, b, c) NULL
+-#define __freelocale(a) ((void)0)
+-#define __duplocale(a) __c_locale()
+-#endif
+-
+ namespace std
+ {
+ template<>
+--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc 2006-03-10 15:32:37 +0100
+@@ -36,13 +36,6 @@
+ #include <locale>
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
+-#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
+-#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
+-#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
+-#endif
+-
+ namespace std
+ {
+ // These are basically extensions to char_traits, and perhaps should
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:32:37 +0100
+@@ -43,10 +43,6 @@
+ #warning tailor for stub locale support
+ #endif
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+-
+ namespace std
+ {
+ // Construct and return valid pattern consisting of some combination of:
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:32:37 +0100
+@@ -41,9 +41,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc 2006-03-10 15:32:37 +0100
+@@ -40,9 +40,6 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning tailor for stub locale support
+ #endif
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __nl_langinfo_l(N, L) nl_langinfo((N))
+-#endif
+
+ namespace std
+ {
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:32:37 +0100
+@@ -38,13 +38,6 @@
+ #undef _LIBC
+ #include <bits/c++locale_internal.h>
+
+-#ifndef __UCLIBC_HAS_XLOCALE__
+-#define __wctype_l(S, L) wctype((S))
+-#define __towupper_l(C, L) towupper((C))
+-#define __towlower_l(C, L) towlower((C))
+-#define __iswctype_l(C, M, L) iswctype((C), (M))
+-#endif
+-
+ namespace std
+ {
+ // NB: The other ctype<char> specializations are in src/locale.cc and
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc 2006-03-10 15:32:37 +0100
+@@ -39,13 +39,10 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix gettext stuff
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__dcgettext(const char *domainname,
+- const char *msgid, int category);
+ #undef gettext
+-#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#define gettext(msgid) dcgettext(NULL, msgid, LC_MESSAGES)
+ #else
+-#undef gettext
+ #define gettext(msgid) (msgid)
+ #endif
+
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:32:37 +0100
+@@ -36,15 +36,11 @@
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-extern "C" char *__textdomain(const char *domainname);
+-extern "C" char *__bindtextdomain(const char *domainname,
+- const char *dirname);
+-#else
+-#undef __textdomain
+-#undef __bindtextdomain
+-#define __textdomain(D) ((void)0)
+-#define __bindtextdomain(D,P) ((void)0)
++#ifndef __UCLIBC_HAS_GETTEXT_AWARENESS__
++#undef textdomain
++#undef bindtextdomain
++#define textdomain(D) ((void)0)
++#define bindtextdomain(D,P) ((void)0)
+ #endif
+
+ // Non-virtual member functions.
+@@ -70,7 +66,7 @@
+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
+ const char* __dir) const
+ {
+- __bindtextdomain(__s.c_str(), __dir);
++ bindtextdomain(__s.c_str(), __dir);
+ return this->do_open(__s, __loc);
+ }
+
+@@ -90,7 +86,7 @@
+ {
+ // No error checking is done, assume the catalog exists and can
+ // be used.
+- __textdomain(__s.c_str());
++ textdomain(__s.c_str());
+ return 0;
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h.uclibc200no__x~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-03-10 15:32:37 +0100
+@@ -68,6 +68,7 @@
+ {
+ extern "C" __typeof(uselocale) __uselocale;
+ }
++#define __uselocale uselocale
+ #endif
+
+ namespace std
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/204-uclibc-locale-wchar_fix.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/204-uclibc-locale-wchar_fix.patch
new file mode 100644
index 0000000000..160ab35bb3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/204-uclibc-locale-wchar_fix.patch
@@ -0,0 +1,48 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:37:27 +0100
+@@ -401,7 +401,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+@@ -556,7 +556,7 @@
+ # ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+-# else
++# elif defined __UCLIBC_HAS_LOCALE__
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+ # endif
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:37:27 +0100
+@@ -127,12 +127,25 @@
+ {
+ // Named locale.
+ // NB: In the GNU model wchar_t is always 32 bit wide.
++#ifdef __UCLIBC_MJN3_ONLY__
++#warning fix this... should be numeric
++#endif
++#ifdef __UCLIBC__
++# ifdef __UCLIBC_HAS_XLOCALE__
++ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
++ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
++# elif defined __UCLIBC_HAS_LOCALE__
++ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
++ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
++# endif
++#else
+ union { char *__s; wchar_t __w; } __u;
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_data->_M_decimal_point = __u.__w;
+
+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
+ _M_data->_M_thousands_sep = __u.__w;
++#endif
+
+ if (_M_data->_M_thousands_sep == L'\0')
+ _M_data->_M_grouping = "";
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/205-uclibc-locale-update.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/205-uclibc-locale-update.patch
new file mode 100644
index 0000000000..86b2844554
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/205-uclibc-locale-update.patch
@@ -0,0 +1,347 @@
+--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
+@@ -46,16 +47,13 @@
+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- float __f = __strtof_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __f;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ float __f = __strtof_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __f;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -63,16 +61,13 @@
+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- double __d = __strtod_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __d;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ double __d = __strtod_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __d;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ template<>
+@@ -80,16 +75,13 @@
+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
+ const __c_locale& __cloc)
+ {
+- if (!(__err & ios_base::failbit))
+- {
+- char* __sanity;
+- errno = 0;
+- long double __ld = __strtold_l(__s, &__sanity, __cloc);
+- if (__sanity != __s && errno != ERANGE)
+- __v = __ld;
+- else
+- __err |= ios_base::failbit;
+- }
++ char* __sanity;
++ errno = 0;
++ long double __ld = __strtold_l(__s, &__sanity, __cloc);
++ if (__sanity != __s && errno != ERANGE)
++ __v = __ld;
++ else
++ __err |= ios_base::failbit;
+ }
+
+ void
+@@ -110,7 +102,7 @@
+ void
+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
+ {
+- if (_S_get_c_locale() != __cloc)
++ if (__cloc && _S_get_c_locale() != __cloc)
+ __freelocale(__cloc);
+ }
+
+--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ namespace std
+@@ -138,20 +143,34 @@
+ ctype<wchar_t>::
+ do_is(mask __m, wchar_t __c) const
+ {
+- // Highest bitmask in ctype_base == 10, but extra in "C"
+- // library for blank.
++ // The case of __m == ctype_base::space is particularly important,
++ // due to its use in many istream functions. Therefore we deal with
++ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
++ // is the mask corresponding to ctype_base::space. NB: an encoding
++ // change would not affect correctness!
+ bool __ret = false;
+- const size_t __bitmasksize = 11;
+- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+- if (__m & _M_bit[__bitcur]
+- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
+- {
+- __ret = true;
+- break;
+- }
++ if (__m == _M_bit[5])
++ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
++ else
++ {
++ // Highest bitmask in ctype_base == 10, but extra in "C"
++ // library for blank.
++ const size_t __bitmasksize = 11;
++ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
++ if (__m & _M_bit[__bitcur])
++ {
++ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
++ {
++ __ret = true;
++ break;
++ }
++ else if (__m == _M_bit[__bitcur])
++ break;
++ }
++ }
+ return __ret;
+ }
+-
++
+ const wchar_t*
+ ctype<wchar_t>::
+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
+@@ -47,18 +47,21 @@
+ template<typename _CharT>
+ messages<_CharT>::messages(size_t __refs)
+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
+- _M_name_messages(_S_get_c_name())
++ _M_name_messages(_S_get_c_name())
+ { }
+
+ template<typename _CharT>
+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
+ size_t __refs)
+- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
+- _M_name_messages(__s)
++ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_messages = __tmp;
++
++ // Last to avoid leaking memory if new throws.
++ _M_c_locale_messages = _S_clone_c_locale(__cloc);
+ }
+
+ template<typename _CharT>
+--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+@@ -206,7 +211,7 @@
+ }
+ break;
+ default:
+- ;
++ __ret = pattern();
+ }
+ return __ret;
+ }
+--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
+@@ -33,9 +33,14 @@
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+
++#include <features.h>
++#ifdef __UCLIBC_HAS_LOCALE__
+ #define _LIBC
+ #include <locale>
+ #undef _LIBC
++#else
++#include <locale>
++#endif
+ #include <bits/c++locale_internal.h>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
++++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
+@@ -37,25 +37,33 @@
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(_S_get_c_name())
++ _M_name_timepunct(_S_get_c_name())
+ { _M_initialize_timepunct(); }
+
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
+ size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+- _M_name_timepunct(__s)
++ _M_name_timepunct(NULL)
+ {
+- char* __tmp = new char[std::strlen(__s) + 1];
+- std::strcpy(__tmp, __s);
++ const size_t __len = std::strlen(__s) + 1;
++ char* __tmp = new char[__len];
++ std::memcpy(__tmp, __s, __len);
+ _M_name_timepunct = __tmp;
+- _M_initialize_timepunct(__cloc);
++
++ try
++ { _M_initialize_timepunct(__cloc); }
++ catch(...)
++ {
++ delete [] _M_name_timepunct;
++ __throw_exception_again;
++ }
+ }
+
+ template<typename _CharT>
+--- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
+@@ -39,21 +39,23 @@
+ #pragma GCC system_header
+
+ #include <cstring> // get std::strlen
+-#include <cstdio> // get std::snprintf or std::sprintf
++#include <cstdio> // get std::vsnprintf or std::vsprintf
+ #include <clocale>
+ #include <langinfo.h> // For codecvt
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix this
+ #endif
+-#ifdef __UCLIBC_HAS_LOCALE__
++#ifdef _GLIBCXX_USE_ICONV
+ #include <iconv.h> // For codecvt using iconv, iconv_t
+ #endif
+-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+-#include <libintl.h> // For messages
++#ifdef HAVE_LIBINTL_H
++#include <libintl.h> // For messages
+ #endif
++#include <cstdarg>
+
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning what is _GLIBCXX_C_LOCALE_GNU for
++// psm: used in os/gnu-linux/ctype_noninline.h
+ #endif
+ #define _GLIBCXX_C_LOCALE_GNU 1
+
+@@ -62,7 +64,7 @@
+ #endif
+ // #define _GLIBCXX_NUM_CATEGORIES 6
+ #define _GLIBCXX_NUM_CATEGORIES 0
+-
++
+ #ifdef __UCLIBC_HAS_XLOCALE__
+ namespace __gnu_cxx
+ {
+@@ -79,22 +81,24 @@
+ typedef int* __c_locale;
+ #endif
+
+- // Convert numeric value of type _Tv to string and return length of
+- // string. If snprintf is available use it, otherwise fall back to
+- // the unsafe sprintf which, in general, can be dangerous and should
++ // Convert numeric value of type double to string and return length of
++ // string. If vsnprintf is available use it, otherwise fall back to
++ // the unsafe vsprintf which, in general, can be dangerous and should
+ // be avoided.
+- template<typename _Tv>
+- int
+- __convert_from_v(char* __out,
+- const int __size __attribute__ ((__unused__)),
+- const char* __fmt,
+-#ifdef __UCLIBC_HAS_XCLOCALE__
+- _Tv __v, const __c_locale& __cloc, int __prec)
++ inline int
++ __convert_from_v(const __c_locale&
++#ifndef __UCLIBC_HAS_XCLOCALE__
++ __cloc __attribute__ ((__unused__))
++#endif
++ ,
++ char* __out,
++ const int __size,
++ const char* __fmt, ...)
+ {
++ va_list __args;
++#ifdef __UCLIBC_HAS_XCLOCALE__
+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
+ #else
+- _Tv __v, const __c_locale&, int __prec)
+- {
+ # ifdef __UCLIBC_HAS_LOCALE__
+ char* __old = std::setlocale(LC_ALL, NULL);
+ char* __sav = new char[std::strlen(__old) + 1];
+@@ -103,7 +107,9 @@
+ # endif
+ #endif
+
+- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
++ va_start(__args, __fmt);
++ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
++ va_end(__args);
+
+ #ifdef __UCLIBC_HAS_XCLOCALE__
+ __gnu_cxx::__uselocale(__old);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/300-libstdc++-pic.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/300-libstdc++-pic.patch
new file mode 100644
index 0000000000..560bcb237b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/300-libstdc++-pic.patch
@@ -0,0 +1,50 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- gcc/libstdc++-v3/src/Makefile.am
++++ gcc/libstdc++-v3/src/Makefile.am
+@@ -214,6 +214,12 @@
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
+
+
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Added bits to build debug library.
+ if GLIBCXX_BUILD_DEBUG
+ all-local: build_debug
+--- gcc/libstdc++-v3/src/Makefile.in
++++ gcc/libstdc++-v3/src/Makefile.in
+@@ -627,7 +627,7 @@
+
+ install-data-am: install-data-local
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
+
+ install-info: install-info-am
+
+@@ -660,6 +660,7 @@
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-data-local install-exec \
++ install-exec-local \
+ install-exec-am install-info install-info-am install-man \
+ install-strip install-toolexeclibLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+@@ -743,6 +743,13 @@
+ install_debug:
+ (cd ${debugdir} && $(MAKE) \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
++
++install-exec-local:
++ifeq ($(enable_shared),yes)
++ $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
++ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
++endif
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/302-c99-snprintf.patch
new file mode 100644
index 0000000000..dfb22d681b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h-orig 2005-04-29 00:08:41.000000000 -0500
++++ gcc-4.0.0/libstdc++-v3/include/c_std/std_cstdio.h 2005-04-29 00:08:45.000000000 -0500
+@@ -142,7 +142,7 @@
+ using ::vsprintf;
+ }
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/303-c99-complex-ugly-hack.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..2ccc80d9bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,12 @@
+--- gcc-4.0.0/libstdc++-v3/configure-old 2005-04-30 22:04:48.061603912 -0500
++++ gcc-4.0.0/libstdc++-v3/configure 2005-04-30 22:06:13.678588152 -0500
+@@ -7194,6 +7194,9 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <complex.h>
++#ifdef __UCLIBC__
++#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
++#endif
+ int
+ main ()
+ {
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/304-index_macro.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/304-index_macro.patch
new file mode 100644
index 0000000000..d8e476555d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/304-index_macro.patch
@@ -0,0 +1,24 @@
+--- gcc-4.1.0/libstdc++-v3/include/ext/rope.mps 2006-03-24 01:49:51 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/rope 2006-03-24 01:49:37 +0100
+@@ -59,6 +59,9 @@
+ #include <bits/allocator.h>
+ #include <ext/hash_fun.h>
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ # ifdef __GC
+ # define __GC_CONST const
+ # else
+--- gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h.mps 2006-03-24 01:50:04 +0100
++++ gcc-4.1.0/libstdc++-v3/include/ext/ropeimpl.h 2006-03-24 01:50:28 +0100
+@@ -53,6 +53,9 @@
+ #include <ext/memory> // For uninitialized_copy_n
+ #include <ext/numeric> // For power
+
++/* cope w/ index defined as macro, SuSv3 proposal */
++#undef index
++
+ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ using std::size_t;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/306-libstdc++-namespace.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/306-libstdc++-namespace.patch
new file mode 100644
index 0000000000..69587ca63a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/306-libstdc++-namespace.patch
@@ -0,0 +1,36 @@
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-12-22 15:23:41.000000000 +0100
+@@ -32,7 +32,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ #ifdef __UCLIBC_MJN3_ONLY__
+ #warning fix prototypes for *textdomain funcs
+ #endif
+@@ -115,3 +116,4 @@
+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
+ }
++}
+diff -rup gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h
+--- gcc-4.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 13:06:56.000000000 +0100
++++ gcc-4.2/libstdc++-v3/config/locale/uclibc/time_members.h 2006-12-22 15:20:31.000000000 +0100
+@@ -33,7 +33,8 @@
+ //
+
+ // Written by Benjamin Kosnik <bkoz@redhat.com>
+-
++namespace std
++{
+ template<typename _CharT>
+ __timepunct<_CharT>::__timepunct(size_t __refs)
+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
+@@ -74,3 +75,4 @@
+ delete _M_data;
+ _S_destroy_c_locale(_M_c_locale_timepunct);
+ }
++}
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/307-locale_facets.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/307-locale_facets.patch
new file mode 100644
index 0000000000..412f8657dc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/307-locale_facets.patch
@@ -0,0 +1,26 @@
+This patch fixes a bug into ostream::operator<<(double) due to the wrong size
+passed into the __convert_from_v method. The wrong size is then passed to
+std::snprintf function, that, on uClibc, doens't handle sized 0 buffer.
+
+Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+--- gcc-4.2.1/libstdc++-v3/include/bits/locale_facets.tcc 2006-10-17 18:43:47.000000000 +0200
++++ gcc-4.2.1-st/libstdc++-v3/include/bits/locale_facets.tcc 2007-08-22 18:54:23.000000000 +0200
+@@ -1143,7 +1143,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ const int __cs_size = __fixed ? __max_exp + __prec + 4
+ : __max_digits * 2 + __prec;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
++ __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf,
+ __prec, __v);
+ #endif
+
+@@ -1777,7 +1777,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
+ // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
+ const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+- int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
++ int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, "%.*Lf",
+ 0, __units);
+ #endif
+ string_type __digits(__len, char_type());
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/402-libbackend_dep_gcov-iov.h.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/402-libbackend_dep_gcov-iov.h.patch
new file mode 100644
index 0000000000..0bf115c45d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/402-libbackend_dep_gcov-iov.h.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.2/gcc/Makefile.in
+===================================================================
+--- gcc-4.2/gcc/Makefile.in (revision 121758)
++++ gcc-4.2/gcc/Makefile.in (working copy)
+@@ -2658,7 +2658,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H)
+ # FIXME: writing proper dependencies for this is a *LOT* of work.
+ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
+ insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
++ insn-attr.h $(DATESTAMP) $(BASEVER) $(DEVPHASE) gcov-iov.h
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
+ -DTARGET_NAME=\"$(target_noncanonical)\" \
+ -DLOCALEDIR=\"$(localedir)\" \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/800-arm-bigendian.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/800-arm-bigendian.patch
new file mode 100644
index 0000000000..07c6093379
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/800-arm-bigendian.patch
@@ -0,0 +1,67 @@
+By Lennert Buytenhek <buytenh@wantstofly.org>
+Adds support for arm*b-linux* big-endian ARM targets
+
+See http://gcc.gnu.org/PR16350
+
+--- gcc-4.2.0/gcc/config/arm/linux-elf.h
++++ gcc-4.2.0/gcc/config/arm/linux-elf.h
+@@ -28,19 +28,33 @@
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
+
++/*
++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
++ * (big endian) configurations.
++ */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
++#define TARGET_ENDIAN_OPTION "mbig-endian"
++#define TARGET_LINKER_EMULATION "armelfb_linux"
++#else
++#define TARGET_ENDIAN_DEFAULT 0
++#define TARGET_ENDIAN_OPTION "mlittle-endian"
++#define TARGET_LINKER_EMULATION "armelf_linux"
++#endif
++
+ #undef TARGET_DEFAULT_FLOAT_ABI
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
+ #undef TARGET_DEFAULT
+-#define TARGET_DEFAULT (0)
++#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
+
+ #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
+
+-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
+
+ #undef MULTILIB_DEFAULTS
+ #define MULTILIB_DEFAULTS \
+- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
++ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
+
+ /* Now we define the strings used to build the spec file. */
+ #undef LIB_SPEC
+@@ -61,7 +75,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "} \
+ -X \
+- %{mbig-endian:-EB}" \
++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+ #undef LINK_SPEC
+--- gcc-4.2.0/gcc/config.gcc.orig 2006-09-22 14:53:41.000000000 +0200
++++ gcc-4.2.0/gcc/config.gcc 2006-09-25 10:45:21.000000000 +0200
+@@ -696,6 +696,11 @@
+ tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+ tmake_file="${tmake_file} t-linux arm/t-arm"
+ case ${target} in
++ arm*b-*)
++ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
++ ;;
++ esac
++ case ${target} in
+ arm*-*-linux-*eabi)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/904-flatten-switch-stmt-00.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/904-flatten-switch-stmt-00.patch
new file mode 100644
index 0000000000..8fac37c4df
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/904-flatten-switch-stmt-00.patch
@@ -0,0 +1,153 @@
+Hi,
+
+The attached patch makes sure that we create smaller object code for
+simple switch statements. We just make sure to flatten the switch
+statement into an if-else chain, basically.
+
+This fixes a size-regression as compared to gcc-3.4, as can be seen
+below.
+
+2007-04-15 Bernhard Fischer <..>
+
+ * stmt.c (expand_case): Do not create a complex binary tree when
+ optimizing for size but rather use the simple ordered list.
+ (emit_case_nodes): do not emit jumps to the default_label when
+ optimizing for size.
+
+Not regtested so far.
+Comments?
+
+Attached is the test switch.c mentioned below.
+
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -DCHAIN -Os -o switch-CHAIN-$i.o -c switch.c ;done
+$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
+gcc-$i -UCHAIN -Os -o switch-$i.o -c switch.c ;done
+
+$ size switch-*.o
+ text data bss dec hex filename
+ 169 0 0 169 a9 switch-2.95.o
+ 115 0 0 115 73 switch-3.3.o
+ 103 0 0 103 67 switch-3.4.o
+ 124 0 0 124 7c switch-4.0.o
+ 124 0 0 124 7c switch-4.1.o
+ 124 0 0 124 7c switch-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-4.3-HEAD.o
+ 124 0 0 124 7c switch-4.3.orig-HEAD.o
+ 166 0 0 166 a6 switch-CHAIN-2.95.o
+ 111 0 0 111 6f switch-CHAIN-3.3.o
+ 95 0 0 95 5f switch-CHAIN-3.4.o
+ 95 0 0 95 5f switch-CHAIN-4.0.o
+ 95 0 0 95 5f switch-CHAIN-4.1.o
+ 95 0 0 95 5f switch-CHAIN-4.2.orig-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3-HEAD.o
+ 95 0 0 95 5f switch-CHAIN-4.3.orig-HEAD.o
+
+
+Content-Type: text/x-diff; charset=us-ascii
+Content-Disposition: attachment; filename="gcc-4.3.gcc-flatten-switch-stmt.00.diff"
+
+Index: gcc-4.2.0/gcc/stmt.c
+===================================================================
+--- gcc-4.2.0.orig/gcc/stmt.c (revision 123843)
++++ gcc-4.2.0/gcc/stmt.c (working copy)
+@@ -2517,7 +2517,11 @@ expand_case (tree exp)
+ use_cost_table
+ = (TREE_CODE (orig_type) != ENUMERAL_TYPE
+ && estimate_case_costs (case_list));
+- balance_case_nodes (&case_list, NULL);
++ /* When optimizing for size, we want a straight list to avoid
++ jumps as much as possible. This basically creates an if-else
++ chain. */
++ if (!optimize_size)
++ balance_case_nodes (&case_list, NULL);
+ emit_case_nodes (index, case_list, default_label, index_type);
+ emit_jump (default_label);
+ }
+@@ -3075,6 +3079,7 @@ emit_case_nodes (rtx index, case_node_pt
+ {
+ if (!node_has_low_bound (node, index_type))
+ {
++ if (!optimize_size) /* don't jl to the .default_label. */
+ emit_cmp_and_jump_insns (index,
+ convert_modes
+ (mode, imode,
+
+
+Content-Type: text/x-csrc; charset=us-ascii
+Content-Disposition: attachment; filename="switch.c"
+
+int
+commutative_tree_code (int code)
+{
+#define CASE(val, ret) case val:/* __asm__("# val="#val ",ret="#ret);*/ return ret;
+#ifndef CHAIN
+ switch (code)
+ {
+# if 1
+ CASE(1,3)
+ CASE(3,2)
+ CASE(5,8)
+ CASE(7,1)
+ CASE(33,4)
+ CASE(44,9)
+ CASE(55,10)
+ CASE(66,-1)
+ CASE(77,99)
+ CASE(666,0)
+# else
+ case 1:
+ return 3;
+ case 3:
+ return 2;
+ case 5:
+ return 8;
+ case 7:
+ return 1;
+ case 33:
+ return 4;
+ case 44:
+ return 9;
+ case 55:
+ return 10;
+ case 66:
+ return -1;
+ case 77:
+ return 99;
+ case 666:
+ return 0;
+# endif
+ default:
+ break;
+ }
+ return 4711;
+
+#else
+ if (code == 1)
+ return 3;
+ else if (code == 3)
+ return 2;
+ else if (code == 5)
+ return 8;
+ else if (code == 7)
+ return 1;
+ else if (code == 33)
+ return 4;
+ else if (code == 44)
+ return 9;
+ else if (code == 55)
+ return 10;
+ else if (code == 66)
+ return -1;
+ else if (code == 77)
+ return 99;
+ else if (code == 666)
+ return 0;
+ else
+ return 4711;
+#endif
+}
+
+
+--AhhlLboLdkugWU4S--
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/910-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/910-soft-float.patch
new file mode 100644
index 0000000000..3f886acbf5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/910-soft-float.patch
@@ -0,0 +1,26 @@
+--- gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/t-linux 2006-12-08 15:18:33.000000000 -0800
+@@ -4,7 +4,10 @@
+ LIBGCC2_DEBUG_CFLAGS = -g0
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+
+--- gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
++++ gcc-4.2-20061205/gcc/config/arm/linux-elf.h 2006-12-08 15:18:33.000000000 -0800
+@@ -63,7 +63,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.2.4/920-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/4.2.4/920-soft-float.patch
new file mode 100644
index 0000000000..4287bfae27
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.2.4/920-soft-float.patch
@@ -0,0 +1,21 @@
+diff -uNpr gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c
+--- gcc-4.2.1_orig/gcc/config/rs6000/darwin-ldouble.c 2007-03-05 11:54:00.000000000 -0500
++++ gcc-4.2.1/gcc/config/rs6000/darwin-ldouble.c 2008-01-31 17:51:24.000000000 -0500
+@@ -70,6 +70,8 @@ Software Foundation, 51 Franklin Street,
+ but GCC currently generates poor code when a union is used to turn
+ a long double into a pair of doubles. */
+
++#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
++
+ long double __gcc_qadd (double, double, double, double);
+ long double __gcc_qsub (double, double, double, double);
+ long double __gcc_qmul (double, double, double, double);
+@@ -219,8 +221,6 @@ __gcc_qdiv (double a, double b, double c
+ return z.ldval;
+ }
+
+-#if defined (_SOFT_FLOAT) && defined (__LONG_DOUBLE_128__)
+-
+ long double __gcc_qneg (double, double);
+ int __gcc_qeq (double, double, double, double);
+ int __gcc_qne (double, double, double, double);
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/100-uclibc-conf.patch
new file mode 100644
index 0000000000..cca8c82292
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/100-uclibc-conf.patch
@@ -0,0 +1,33 @@
+--- gcc/gcc/config/--- gcc/contrib/regression/objs-gcc.sh
++++ gcc/contrib/regression/objs-gcc.sh
+@@ -105,6 +105,10 @@
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- gcc/libjava/classpath/ltconfig
++++ gcc/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1251,7 +1251,7 @@
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/104-gnuhurd-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/104-gnuhurd-uclibc-conf.patch
new file mode 100644
index 0000000000..c04dd9ff00
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/104-gnuhurd-uclibc-conf.patch
@@ -0,0 +1,13 @@
+diff -rdup gcc-4.2.1.oorig/gcc/config.gcc gcc-4.2.1/gcc/config.gcc
+--- gcc-4.2.1.oorig/gcc/config.gcc 2007-10-01 11:52:52.000000000 +0200
++++ gcc-4.2.1/gcc/config.gcc 2007-10-01 13:22:12.000000000 +0200
+@@ -494,6 +494,9 @@ case ${target} in
+ alpha*)
+ tm_file="${cpu_type}/${cpu_type}.h alpha/elf.h alpha/linux.h alpha/linux-elf.h gnu.h ${tm_file}"
+ ;;
++ i[34567]86-*hurd*-*)
++ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/gnu.h gnu.h ${tm_file}"
++ ;;
+ i[34567]86-*-*)
+ tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h gnu.h ${tm_file}"
+ ;;
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/301-missing-execinfo_h.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..0e2092f3fb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- gcc-4.0.0/boehm-gc/include/gc.h-orig 2005-04-28 22:28:57.000000000 -0500
++++ gcc-4.0.0/boehm-gc/include/gc.h 2005-04-28 22:30:38.000000000 -0500
+@@ -500,7 +500,7 @@
+ #ifdef __linux__
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/302-c99-snprintf.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/302-c99-snprintf.patch
new file mode 100644
index 0000000000..ba51a0e1d4
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/302-c99-snprintf.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.3.0/libstdc++-v3/include/c_global/cstdio
+===================================================================
+--- gcc-4.3.0/libstdc++-v3/include/c_global/cstdio (revision 129202)
++++ gcc-4.3.0/libstdc++-v3/include/c_global/cstdio (working copy)
+@@ -144,7 +144,7 @@
+
+ _GLIBCXX_END_NAMESPACE
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined __UCLIBC__
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/305-libmudflap-susv3-legacy.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..374b1f8659
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
+Index: gcc-4.2/libmudflap/mf-hooks2.c
+===================================================================
+--- gcc-4.2/libmudflap/mf-hooks2.c (revision 119834)
++++ gcc-4.2/libmudflap/mf-hooks2.c (working copy)
+@@ -427,7 +427,7 @@
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -437,7 +437,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -447,7 +447,7 @@
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -456,7 +456,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -465,7 +465,7 @@
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/810-arm-softfloat-libgcc.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000000..1639c39a83
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,29 @@
+Index: gcc-4.3.0/gcc/config/arm/t-linux
+===================================================================
+--- gcc-4.3.0/gcc/config/arm/t-linux (revision 129896)
++++ gcc-4.3.0/gcc/config/arm/t-linux (working copy)
+@@ -3,7 +3,10 @@
+ TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
++ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
++ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
++ _fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
+Index: gcc-4.3.0/gcc/config/arm/linux-elf.h
+===================================================================
+--- gcc-4.3.0/gcc/config/arm/linux-elf.h (revision 129896)
++++ gcc-4.3.0/gcc/config/arm/linux-elf.h (working copy)
+@@ -48,7 +62,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/993-arm_insn-opinit-RTX_CODE-fixup.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/993-arm_insn-opinit-RTX_CODE-fixup.patch
new file mode 100644
index 0000000000..69f0c372d9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/993-arm_insn-opinit-RTX_CODE-fixup.patch
@@ -0,0 +1,41 @@
+gcc/ChangeLog
+2007-11-27 Bernhard Fischer <>
+
+ * config/arm/arm-protos.h (arm_vector_mode_supported_p,
+ arm_hard_regno_mode_ok, const_ok_for_arm): Do not hide non-rtx related
+ function prototypes in RTX_CODE.
+ * genopinit.c: Include tm_p.h.
+
+Index: gcc-4.3.0/gcc/config/arm/arm-protos.h
+===================================================================
+--- gcc-4.3.0/gcc/config/arm/arm-protos.h (revision 130463)
++++ gcc-4.3.0/gcc/config/arm/arm-protos.h (working copy)
+@@ -40,15 +40,14 @@
+ unsigned int);
+ extern unsigned int arm_dbx_register_number (unsigned int);
+ extern void arm_output_fn_unwind (FILE *, bool);
+-
+
+ #ifdef TREE_CODE
+ extern int arm_return_in_memory (const_tree);
+ #endif
+-#ifdef RTX_CODE
+ extern bool arm_vector_mode_supported_p (enum machine_mode);
+ extern int arm_hard_regno_mode_ok (unsigned int, enum machine_mode);
+ extern int const_ok_for_arm (HOST_WIDE_INT);
++#ifdef RTX_CODE
+ extern int arm_split_constant (RTX_CODE, enum machine_mode, rtx,
+ HOST_WIDE_INT, rtx, rtx, int);
+ extern RTX_CODE arm_canonicalize_comparison (RTX_CODE, enum machine_mode,
+Index: gcc-4.3.0/gcc/genopinit.c
+===================================================================
+--- gcc-4.3.0/gcc/genopinit.c (revision 130463)
++++ gcc-4.3.0/gcc/genopinit.c (working copy)
+@@ -486,6 +486,7 @@
+ printf ("#include \"expr.h\"\n");
+ printf ("#include \"optabs.h\"\n");
+ printf ("#include \"reload.h\"\n\n");
++ printf ("#include \"tm_p.h\"\n\n");
+
+ printf ("void\ninit_all_optabs (void)\n{\n");
+
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/995-short-enums.diff b/cleopatre/buildroot/toolchain/gcc/4.3.1/995-short-enums.diff
new file mode 100644
index 0000000000..03c470c9e4
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/995-short-enums.diff
@@ -0,0 +1,42 @@
+see gcc PR34205
+Index: gcc-4.3.0/gcc/tree.h
+===================================================================
+--- gcc-4.3.0/gcc/tree.h (revision 130511)
++++ gcc-4.3.0/gcc/tree.h (working copy)
+@@ -38,6 +38,7 @@
+
+ LAST_AND_UNUSED_TREE_CODE /* A convenient way to get a value for
+ NUM_TREE_CODES. */
++ ,__LAST_AND_UNUSED_TREE_CODE=32767 /* Force 16bit width. */
+ };
+
+ #undef DEFTREECODE
+Index: gcc-4.3.0/gcc/rtl.h
+===================================================================
+--- gcc-4.3.0/gcc/rtl.h (revision 130511)
++++ gcc-4.3.0/gcc/rtl.h (working copy)
+@@ -48,9 +48,11 @@
+ #include "rtl.def" /* rtl expressions are documented here */
+ #undef DEF_RTL_EXPR
+
+- LAST_AND_UNUSED_RTX_CODE}; /* A convenient way to get a value for
++ LAST_AND_UNUSED_RTX_CODE /* A convenient way to get a value for
+ NUM_RTX_CODE.
+ Assumes default enum value assignment. */
++ ,__LAST_AND_UNUSED_RTX_CODE=32767 /* Force 16bit width. */
++};
+
+ #define NUM_RTX_CODE ((int) LAST_AND_UNUSED_RTX_CODE)
+ /* The cast here, saves many elsewhere. */
+Index: gcc-4.3.0/gcc/c-common.h
+===================================================================
+--- gcc-4.3.0/gcc/c-common.h (revision 130511)
++++ gcc-4.3.0/gcc/c-common.h (working copy)
+@@ -125,6 +125,7 @@
+ RID_LAST_AT = RID_AT_IMPLEMENTATION,
+ RID_FIRST_PQ = RID_IN,
+ RID_LAST_PQ = RID_ONEWAY
++ ,__LAST_AND_UNUSED_RID=32767 /* Force 16bit width. */
+ };
+
+ #define OBJC_IS_AT_KEYWORD(rid) \
diff --git a/cleopatre/buildroot/toolchain/gcc/4.3.1/998-gcc-4.3.0-fix-header.00.patch b/cleopatre/buildroot/toolchain/gcc/4.3.1/998-gcc-4.3.0-fix-header.00.patch
new file mode 100644
index 0000000000..7fe59d2ddc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/4.3.1/998-gcc-4.3.0-fix-header.00.patch
@@ -0,0 +1,15 @@
+\\\\
+\\ gcc PR33200
+Index: gcc-4.3.0/gcc/config.gcc
+===================================================================
+--- gcc-4.3.0/gcc/config.gcc (revision 131628)
++++ gcc-4.3.0/gcc/config.gcc (working copy)
+@@ -2302,7 +2305,7 @@ sh-*-symbianelf* | sh[12346l]*-*-symbian
+ if test x${enable_incomplete_targets} = xyes ; then
+ tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1 SUPPORT_SH5_32MEDIA=1 SUPPORT_SH5_32MEDIA_NOFPU=1 SUPPORT_SH5_64MEDIA=1 SUPPORT_SH5_64MEDIA_NOFPU=1"
+ fi
+- use_fixproto=yes
++ # XXX: why? use_fixproto=yes
+ ;;
+ sh-*-rtemscoff*)
+ tmake_file="sh/t-sh t-rtems sh/t-rtems"
diff --git a/cleopatre/buildroot/toolchain/gcc/Config.in b/cleopatre/buildroot/toolchain/gcc/Config.in
new file mode 100644
index 0000000000..6b06c6659a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/Config.in
@@ -0,0 +1,163 @@
+# Choose gcc version.
+
+comment "GCC Options"
+
+choice
+ prompt "GCC compiler Version"
+ default BR2_GCC_VERSION_4_2_4 if !BR2_avr32
+ default BR2_GCC_VERSION_4_2_3 if BR2_avr32
+ help
+ Select the version of gcc you wish to use.
+
+ config BR2_GCC_VERSION_3_4_6
+ depends on !BR2_avr32
+ depends on BR2_DEPRECATED
+ bool "gcc 3.4.6"
+
+ config BR2_GCC_VERSION_4_0_4
+ depends on !BR2_avr32 && !BR2_nios2
+ depends on BR2_DEPRECATED
+ bool "gcc 4.0.4"
+
+ config BR2_GCC_VERSION_4_1_2
+ depends on !BR2_nios2
+ depends on BR2_EXT_GCC_VERSION_4_1_2
+ bool "gcc 4.1.2"
+
+ config BR2_GCC_VERSION_4_2_1
+ depends on !BR2_nios2
+ depends on BR2_EXT_GCC_VERSION_4_2_1
+ bool "gcc 4.2.1"
+
+ config BR2_GCC_VERSION_4_2_2
+ depends on BR2_avr32
+ depends on BR2_EXT_GCC_VERSION_4_2_2
+ bool "gcc 4.2.2"
+
+ config BR2_GCC_VERSION_4_2_3
+ depends on !BR2_nios2
+ depends on BR2_EXT_GCC_VERSION_4_2_3 || BR2_DEPRECATED
+ bool "gcc 4.2.3"
+
+ config BR2_GCC_VERSION_4_2_4
+ depends on !BR2_avr32 && !BR2_nios2
+ bool "gcc 4.2.4"
+
+ config BR2_GCC_VERSION_4_3_1
+ depends on !BR2_avr32 && !BR2_nios2
+ bool "gcc 4.3.1"
+
+# config BR2_GCC_VERSION_4_3
+# depends on !BR2_avr32 && !BR2_nios2
+# select BR2_GCC_IS_SNAP
+# bool "gcc 4.3"
+endchoice
+
+config BR2_GCC_IS_SNAP
+ depends on !BR2_avr32
+ bool
+
+config BR2_GCC_SUPPORTS_SYSROOT
+ bool
+ default n if BR2_GCC_VERSION_3_4_6 || BR2_GCC_VERSION_4_0_4 || BR2_GCC_VERSION_4_1_2
+ default y if !BR2_GCC_VERSION_3_4_6 && !BR2_GCC_VERSION_4_0_4 && !BR2_GCC_VERSION_4_1_2
+
+config BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE
+ bool
+ default n if BR2_GCC_VERSION_3_4_6 || BR2_GCC_VERSION_4_0_4 || BR2_GCC_VERSION_4_1_2 || BR2_GCC_VERSION_4_2_1 || BR2_GCC_VERSION_4_2_2 || BR2_GCC_VERSION_4_2_3 || BR2_GCC_VERSION_4_2_4
+ default y if !BR2_GCC_VERSION_3_4_6 && !BR2_GCC_VERSION_4_0_4 && !BR2_GCC_VERSION_4_1_2 && !BR2_GCC_VERSION_4_2_1 && !BR2_GCC_VERSION_4_2_2 && !BR2_GCC_VERSION_4_2_3 && !BR2_GCC_VERSION_4_2_4
+
+config BR2_GCC_SNAP_DATE
+ string "GCC snapshot date"
+ default "20070921"
+ depends on BR2_GCC_IS_SNAP
+ help
+ Enter snapshot date to use for gcc. Format is:
+ YYYYMMDD
+
+config BR2_GCC_VERSION
+ string
+ default "3.4.6" if BR2_GCC_VERSION_3_4_6
+ default "4.0.4" if BR2_GCC_VERSION_4_0_4
+ default "4.1.2" if BR2_GCC_VERSION_4_1_2
+ default "4.2.1" if BR2_GCC_VERSION_4_2_1
+ default "4.2.2" if BR2_GCC_VERSION_4_2_2
+ default "4.2.3" if BR2_GCC_VERSION_4_2_3
+ default "4.2.4" if BR2_GCC_VERSION_4_2_4
+ default "4.3.1" if BR2_GCC_VERSION_4_3_1
+ default "4.3" if BR2_GCC_VERSION_4_3
+
+config BR2_TOOLCHAIN_SYSROOT
+ bool "Enable toolchain with --sysroot support"
+ depends on BR2_GCC_SUPPORTS_SYSROOT
+ default y
+ help
+ Enables --sysroot=dir for binutils and gcc.
+ Use dir as the logical root directory for headers and libraries.
+ For example, if the compiler would normally search for headers in
+ /usr/include and libraries in /usr/lib, it will instead search
+ dir/usr/include and dir/usr/lib.
+
+ This does not work with gcc < 4.2.0 (4.1.2 gets
+ ORIGINAL_AS_FOR_TARGET wrong)
+
+config BR2_GCC_USE_SJLJ_EXCEPTIONS
+ bool "Enable setjmp/longjmp exceptions?"
+ help
+ For some platforms, proper stack unwinding works perfectly,
+ while other platforms must use setjmp/longjmp exceptions for
+ proper stack unwinding during exception handling. Most people
+ can leave this set to n.
+
+config BR2_EXTRA_GCC_CONFIG_OPTIONS
+ string "Additional gcc options"
+ default ""
+ help
+ Any additional gcc configure options you may want to include....
+
+config BR2_GCC_CROSS_CXX
+ bool "C++ cross-compiler support"
+ help
+ Build a C++ cross-compiler
+
+config BR2_GCC_CROSS_FORTRAN
+ bool "Fortran cross-compiler support"
+ depends on !BR2_avr32
+ help
+ Build a Fortran cross-compiler
+
+config BR2_INSTALL_LIBSTDCPP
+ bool "Build/install c++ compiler and libstdc++?"
+ # >= 4.2.0 work fine without LARGEFILE
+ select BR2_LARGEFILE if !BR2_GCC_SUPPORTS_SYSROOT
+ select BR2_GCC_CROSS_CXX
+ help
+ Build/install c++ compiler and libstdc++?
+
+config BR2_INSTALL_LIBGCJ
+ bool "Build/install java compiler and libgcj?"
+ depends on !BR2_avr32 && BR2_INSTALL_LIBSTDCPP
+ help
+ Build/install java compiler and libgcj?
+
+config BR2_INSTALL_OBJC
+ bool "Build/install Objective-C compiler and runtime?"
+ depends on !BR2_avr32
+ help
+ Build/install Objective-C compiler and runtime?
+
+config BR2_INSTALL_FORTRAN
+ bool "Build/install Fortran compiler and runtime?"
+ depends on !BR2_avr32
+ select BR2_PACKAGE_LIBMPFR
+ help
+ Build/install Fortran compiler and runtime?
+ Note that it is highly recommended NOT to use gfortran
+ from gcc older than 4.2.0
+
+config BR2_GCC_SHARED_LIBGCC
+ bool "Build/install a shared libgcc?"
+ default y
+ help
+ Build/install a shared libgcc library
+
diff --git a/cleopatre/buildroot/toolchain/gcc/Config.in.2 b/cleopatre/buildroot/toolchain/gcc/Config.in.2
new file mode 100644
index 0000000000..78208dcadf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/Config.in.2
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_GCC_TARGET
+ bool "native toolchain in the target filesystem"
+ help
+ If you want the target system to be able to run
+ binutils/gcc and compile native code, say Y here.
+
+config BR2_EXTRA_TARGET_GCC_CONFIG_OPTIONS
+ string "Additional target gcc options"
+ default ""
+ depends on BR2_PACKAGE_GCC_TARGET
+ help
+ Any additional target gcc options you may want to include....
+ Including, but not limited to --disable-checking etc.
+ Refer to */configure in your gcc sources.
diff --git a/cleopatre/buildroot/toolchain/gcc/Makefile.in b/cleopatre/buildroot/toolchain/gcc/Makefile.in
new file mode 100644
index 0000000000..b323f326e6
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/Makefile.in
@@ -0,0 +1,107 @@
+# gcc has a bunch of options that need to be shared with
+# both gcc-uclibc-2.95.mk and gcc-uclibc-3.x.mk, and are
+# use by other packages... So include them in this file
+# and arrange to include it soon after invoking make from
+# the top level.
+
+GCC_VERSION:=$(strip $(subst ",, $(BR2_GCC_VERSION)))
+#"))
+TARGET_OPTIMIZATION:=$(strip $(subst ",, $(BR2_TARGET_OPTIMIZATION)))
+#"))
+EXTRA_GCC_CONFIG_OPTIONS:=$(strip $(subst ",, $(BR2_EXTRA_GCC_CONFIG_OPTIONS)))
+#"))
+
+ifeq ($(strip $(subst ",, $(BR2_GCC_IS_SNAP))),y)
+#"))
+GCC_SNAP_DATE:=$(strip $(subst ",, $(BR2_GCC_SNAP_DATE)))
+#"))
+else
+GCC_SNAP_DATE:=
+endif
+#")))
+
+ifeq ($(strip $(BR2_GCC_USE_SJLJ_EXCEPTIONS)),y)
+GCC_USE_SJLJ_EXCEPTIONS:=--enable-sjlj-exceptions
+endif
+
+ifeq ($(BR2_SOFT_FLOAT),y)
+# gcc 3.4.x soft float configuration is different than previous versions.
+ifeq ($(findstring x3.4.,x$(GCC_VERSION)),x3.4.)
+ifneq ($(BR2_nios2),y)
+SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
+endif
+else
+SOFT_FLOAT_CONFIG_OPTION:=--without-float
+endif
+
+# again... there must be a better way
+ifeq ($(findstring x4.,x$(GCC_VERSION)),x4.)
+SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
+ifeq ($(BR2_SOFT_FLOAT_FP),y)
+TARGET_SOFT_FLOAT:=-mfloat-abi=softfp
+else # no fp at all
+TARGET_SOFT_FLOAT:=-mfloat-abi=soft
+endif
+else # not gcc-4.x
+TARGET_SOFT_FLOAT:=-msoft-float
+endif
+ARCH_FPU_SUFFIX:=_nofpu
+else # no softfloat support
+SOFT_FLOAT_CONFIG_OPTION:=
+TARGET_SOFT_FLOAT:=
+ARCH_FPU_SUFFIX:=
+endif
+
+# some additional defaults
+ifneq ($(strip $(subst ",,$(BR2_GCC_TARGET_ARCH))),)
+# ")))
+GCC_WITH_ARCH:=--with-arch=$(BR2_GCC_TARGET_ARCH)
+endif
+ifneq ($(strip $(subst ",,$(BR2_GCC_TARGET_TUNE))),)
+# ")))
+GCC_WITH_TUNE:=--with-tune=$(BR2_GCC_TARGET_TUNE)
+endif
+ifneq ($(strip $(subst ",,$(BR2_GCC_TARGET_ABI))),)
+# ")))
+GCC_WITH_ABI:=--with-abi=$(BR2_GCC_TARGET_ABI)
+endif
+
+# AVR32 GCC configuration
+ifeq ($(strip $(BR2_avr32)),y)
+EXTRA_GCC_CONFIG_OPTIONS+=--disable-libmudflap
+SOFT_FLOAT_CONFIG_OPTION:=
+EXTRA_GCC_CONFIG_OPTIONS+=--disable-libssp
+EXTRA_GCC_CONFIG_OPTIONS+=--with-build-time-tools=$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin \
+#EXTRA_GCC_CONFIG_OPTIONS+=--with-as=$(TARGET_CROSS)as
+endif
+
+TARGET_GCC_FLAGS= CFLAGS_FOR_TARGET="$(TARGET_CFLAGS) $(TARGET_SOFT_FLOAT)" \
+ CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS) $(TARGET_SOFT_FLOAT)" \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_SOFT_FLOAT)" \
+ BOOT_CFLAGS="$(TARGET_CFLAGS) $(TARGET_SOFT_FLOAT)"
+
+ifeq ($(strip $(BR2_PACKAGE_GCC_TARGET)),y)
+EXTRA_TARGET_GCC_CONFIG_OPTIONS:=
+
+# AVR32 target GCC configuration
+ifeq ($(strip $(BR2_avr32)),y)
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=--disable-libmudflap
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=--disable-libssp
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=--with-build-time-tools=$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin \
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=--with-as=$(TARGET_CROSS)as
+endif
+
+
+# and finally pull in config opts from the user
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=$(strip $(subst ",, $(BR2_EXTRA_TARGET_GCC_CONFIG_OPTIONS)))
+#"))
+
+ifeq ($(BR2_PREFER_IMA),y)
+# >= 4.x
+ifneq ($(findstring x3.,x$(GCC_VERSION)),x3.)
+EXTRA_TARGET_GCC_CONFIG_OPTIONS+=--enable-intermodule
+endif
+endif # BR2_PREFER_IMA=y
+
+TARGETS+=gcc_target
+endif
diff --git a/cleopatre/buildroot/toolchain/gcc/ext_source/Atmel/avr32/4.2.2-avr32-2.1.5/903-avr32-fix-removal-of-redundant-cast-operations.patch b/cleopatre/buildroot/toolchain/gcc/ext_source/Atmel/avr32/4.2.2-avr32-2.1.5/903-avr32-fix-removal-of-redundant-cast-operations.patch
new file mode 100644
index 0000000000..59ecbff4f5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/ext_source/Atmel/avr32/4.2.2-avr32-2.1.5/903-avr32-fix-removal-of-redundant-cast-operations.patch
@@ -0,0 +1,16 @@
+Index: trunk/gcc/config/avr32/avr32.c
+===================================================================
+--- trunk/gcc/config/avr32/avr32.c (revision 43495)
++++ trunk/gcc/config/avr32/avr32.c (revision 43496)
+@@ -6499,6 +6499,11 @@
+ break;
+ }
+
++ /* Check if we have a call and the register is used as an argument. */
++ if (CALL_P (scan)
++ && find_reg_fusage (scan, USE, reg) )
++ break;
++
+ if (!reg_mentioned_p (reg, PATTERN (scan)))
+ continue;
+
diff --git a/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-3.x.mk b/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-3.x.mk
new file mode 100644
index 0000000000..622adbc6e9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-3.x.mk
@@ -0,0 +1,509 @@
+# Makefile for to build a gcc/uClibc toolchain
+#
+# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
+
+# without sysroot support. Sysroot toolchain is gcc-uclibc-4.x.mk
+ifneq ($(BR2_TOOLCHAIN_SYSROOT),y)
+
+ifeq ($(GCC_SNAP_DATE),)
+GCC_OFFICIAL_VER:=$(GCC_VERSION)
+GCC_SITE:=$(BR2_GNU_MIRROR)/gcc/gcc-$(GCC_VERSION)
+#GCC_SITE:=ftp://ftp.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gcc/gcc-$(GCC_OFFICIAL_VER)
+else
+GCC_OFFICIAL_VER:=$(GCC_VERSION)-$(GCC_SNAP_DATE)
+GCC_SITE:=ftp://sources.redhat.com/pub/gcc/snapshots/$(GCC_OFFICIAL_VER)
+endif
+
+
+# redefine if using an external prepatched gcc source
+ifneq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+GCC_SITE:=$(VENDOR_SITE)
+GCC_OFFICIAL_VER:=$(GCC_VERSION)$(VENDOR_SUFFIX)$(VENDOR_GCC_RELEASE)
+GCC_PATCH_DIR:=toolchain/gcc/ext_source/$(VENDOR_PATCH_DIR)/$(GCC_OFFICIAL_VERSION)
+endif
+
+GCC_SOURCE:=gcc-$(GCC_OFFICIAL_VER).tar.bz2
+GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_OFFICIAL_VER)
+
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+ifeq ($(GCC_SNAP_DATE),)
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_VERSION)
+else
+ifneq ($(wildcard toolchain/gcc/$(GCC_OFFICIAL_VER)),)
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_OFFICIAL_VER)
+else
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_VERSION)
+endif
+endif
+endif
+
+GCC_CAT:=$(BZCAT)
+GCC_STRIP_HOST_BINARIES:=true
+
+ifeq ($(findstring x3.,x$(GCC_VERSION)),x3.)
+GCC_NO_MPFR:=y
+else
+ifneq ($(BR2_INSTALL_FORTRAN),y)
+# fortran needs gmp and mpfr
+ifeq ($(findstring 4.0.,$(GCC_VERSION)),4.0.)
+GCC_NO_MPFR:=y
+endif
+ifeq ($(findstring 4.1.,$(GCC_VERSION)),4.1.)
+GCC_NO_MPFR:=y
+endif
+endif
+endif
+
+#############################################################
+#
+# Setup some initial stuff
+#
+#############################################################
+
+
+GCC_CROSS_LANGUAGES:=c
+ifeq ($(BR2_GCC_CROSS_CXX),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),c++
+endif
+ifeq ($(BR2_GCC_CROSS_FORTRAN),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),fortran
+endif
+ifeq ($(BR2_GCC_CROSS_OBJC),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),objc
+endif
+
+
+GCC_TARGET_LANGUAGES:=c
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),c++
+endif
+ifeq ($(BR2_INSTALL_LIBGCJ),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),java
+endif
+ifeq ($(BR2_INSTALL_OBJC),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),objc
+endif
+
+GCC_TARGET_PREREQ =
+GCC_STAGING_PREREQ= $(STAGING_DIR)/usr/lib/libc.a
+
+ifndef GCC_NO_MPFR
+GCC_WITH_HOST_GMP=--with-gmp=$(GMP_HOST_DIR)
+GCC_WITH_HOST_MPFR=--with-mpfr=$(MPFR_HOST_DIR)
+
+ifeq ($(BR2_INSTALL_FORTRAN),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),fortran
+#GCC_TARGET_PREREQ += $(TARGET_DIR)/lib/libmpfr.so $(TARGET_DIR)/lib/libgmp.so
+#GCC_STAGING_PREREQ+= $(TOOL_BUILD_DIR)/mpfr/lib/libmpfr.so
+GCC_WITH_TARGET_GMP=--with-gmp="$(GMP_TARGET_DIR)"
+GCC_WITH_TARGET_MPFR=--with-mpfr="$(MPFR_TARGET_DIR)"
+endif
+endif # ifndef GCC_NO_MPFR
+
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+GCC_SHARED_LIBGCC:=--enable-shared
+else
+GCC_SHARED_LIBGCC:=--disable-shared
+endif
+
+ifneq ($(BR2_ENABLE_LOCALE),y)
+GCC_ENABLE_CLOCALE:=--disable-clocale
+endif
+
+HOST_SOURCE+=gcc-source
+
+#############################################################
+#
+# build the first pass gcc compiler
+#
+#############################################################
+GCC_BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-initial
+
+$(DL_DIR)/$(GCC_SOURCE):
+ mkdir -p $(DL_DIR)
+ $(WGET) -P $(DL_DIR) $(GCC_SITE)/$(GCC_SOURCE)
+
+gcc-unpacked: $(GCC_DIR)/.patched
+$(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
+ mkdir -p $(TOOL_BUILD_DIR)
+ $(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ $(CONFIG_UPDATE) $(GCC_DIR)
+ touch $@
+
+gcc-patched: $(GCC_DIR)/.patched
+$(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
+ # Apply any files named gcc-*.patch from the source directory to gcc
+ toolchain/patch-kernel.sh $(GCC_DIR) $(GCC_PATCH_DIR) \*.patch
+ # Note: The soft float situation has improved considerably with gcc 3.4.x.
+ # We can dispense with the custom spec files, as well as libfloat for the arm case.
+ # However, we still need a patch for arm. There's a similar patch for gcc 3.3.x
+ # which needs to be integrated so we can kill of libfloat for good, except for
+ # anyone (?) who might still be using gcc 2.95. mjn3
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ("$(strip $(ARCH))","arm")
+ toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc/$(GCC_VERSION) arm-softfloat.patch.conditional
+endif
+ifeq ("$(strip $(ARCH))","armeb")
+ toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc/$(GCC_VERSION) arm-softfloat.patch.conditional
+endif
+ # Not yet updated to 3.4.1.
+ #ifeq ("$(strip $(ARCH))","i386")
+ #toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc i386-gcc-soft-float.patch
+ #endif
+endif
+ touch $@
+
+# The --without-headers option stopped working with gcc 3.0 and has never been
+# fixed, so we need to actually have working C library header files prior to
+# the step or libgcc will not build...
+
+$(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
+ mkdir -p $(GCC_BUILD_DIR1)
+ (cd $(GCC_BUILD_DIR1); PATH=$(TARGET_PATH) \
+ $(HOST_CONFIGURE_OPTS) \
+ $(GCC_DIR)/configure \
+ --prefix=$(STAGING_DIR)/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=c \
+ --with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ --disable-__cxa_atexit \
+ --enable-target-optspace \
+ --with-gnu-ld \
+ --disable-shared \
+ $(GCC_WITH_HOST_GMP) \
+ $(GCC_WITH_HOST_MPFR) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
+ PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
+ touch $@
+
+gcc_initial=$(GCC_BUILD_DIR1)/.installed
+$(gcc_initial) $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
+ PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
+ #rm -f $(STAGING_DIR)/bin/gccbug $(STAGING_DIR)/bin/gcov
+ #rm -rf $(STAGING_DIR)/info $(STAGING_DIR)/man $(STAGING_DIR)/share/doc $(STAGING_DIR)/share/locale
+ touch $(gcc_initial)
+
+gcc_initial: uclibc-configured binutils $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc
+
+gcc_initial-clean:
+ rm -rf $(GCC_BUILD_DIR1)
+
+gcc_initial-dirclean:
+ rm -rf $(GCC_BUILD_DIR1) $(GCC_DIR)
+
+#############################################################
+#
+# second pass compiler build. Build the compiler targeting
+# the newly built shared uClibc library.
+#
+#############################################################
+#
+# Sigh... I had to rework things because using --with-gxx-include-dir
+# causes issues with include dir search order for g++. This seems to
+# have something to do with "path translations" and possibly doesn't
+# affect gcc-target. However, I haven't tested gcc-target yet so no
+# guarantees. mjn3
+
+comma:=,
+GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-final
+$(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(GCC_STAGING_PREREQ)
+ mkdir -p $(GCC_BUILD_DIR2)
+ # Important! Required for limits.h to be fixed.
+ ln -snf ../include $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
+ #-rmdir $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ #ln -snf ../lib/ $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ (cd $(GCC_BUILD_DIR2); rm -rf config.cache; \
+ $(HOST_CONFIGURE_OPTS) \
+ GCC=$(TARGET_CROSS)gcc \
+ CPP=$(TARGET_CROSS)cpp \
+ LDFLAGS_FOR_TARGET="$(patsubst %,LDFLAGS+=-Wl$(comma)%,$(TARGET_LDFLAGS)) -L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
+ $(GCC_DIR)/configure \
+ --prefix=$(STAGING_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=$(GCC_CROSS_LANGUAGES) \
+ --disable-__cxa_atexit \
+ --enable-target-optspace \
+ --with-gnu-ld \
+ $(GCC_WITH_HOST_GMP) \
+ $(GCC_WITH_HOST_MPFR) \
+ $(GCC_SHARED_LIBGCC) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(GCC_USE_SJLJ_EXCEPTIONS) \
+ $(DISABLE_LARGEFILE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
+ PATH=$(TARGET_PATH) $(MAKE) $(HOST_CONFIGURE_OPTS) CPP=$(TARGET_CROSS)cpp -C $(GCC_BUILD_DIR2) all
+ touch $@
+
+$(GCC_BUILD_DIR2)/.installed: $(GCC_BUILD_DIR2)/.compiled
+ PATH=$(TARGET_PATH) \
+ $(MAKE) $(HOST_CONFIGURE_OPTS) \
+ LDFLAGS_FOR_TARGET="$(patsubst %,LDFLAGS+=-Wl$(comma)%,$(TARGET_LDFLAGS)) -L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
+ -C $(GCC_BUILD_DIR2) install
+ if [ -d "$(STAGING_DIR)/usr/lib64" ]; then \
+ if [ ! -e "$(STAGING_DIR)/usr/lib" ]; then \
+ mkdir -p "$(STAGING_DIR)/usr/lib"; \
+ fi; \
+ mv "$(STAGING_DIR)/usr/lib64/"* "$(STAGING_DIR)/usr/lib/"; \
+ rmdir "$(STAGING_DIR)/usr/lib64"; \
+ fi
+ # Strip the host binaries
+ifeq ($(GCC_STRIP_HOST_BINARIES),true)
+ strip --strip-all -R .note -R .comment $(filter-out %-gccbug %-embedspu,$(wildcard $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-*))
+endif
+ # Make sure we have 'cc'.
+ if [ ! -e $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc ]; then \
+ ln -snf $(REAL_GNU_TARGET_NAME)-gcc \
+ $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc; \
+ fi
+ if [ ! -e $(STAGING_DIR)/usr/bin/gcc ]; then \
+ ln -snf gcc $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc; \
+ fi
+ # Set up the symlinks to enable lying about target name.
+ set -e; \
+ (cd $(STAGING_DIR)/usr; \
+ ln -snf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
+ cd bin; \
+ for app in $(REAL_GNU_TARGET_NAME)-*; do \
+ ln -snf $${app} \
+ $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
+ done; \
+ )
+ #
+ # Now for the ugly 3.3.x soft float hack...
+ #
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ($(findstring 3.3.,$(GCC_VERSION)),3.3.)
+ # Make sure we have a soft float specs file for this arch
+ if [ ! -f toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float ]; then \
+ echo soft float configured but no specs file for this arch; \
+ /bin/false; \
+ fi
+ # Replace specs file with one that defaults to soft float mode.
+ if [ ! -f $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ]; then \
+ echo staging dir specs file is missing; \
+ /bin/false; \
+ fi
+ cp toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+endif
+endif
+ #
+ # Ok... that's enough of that.
+ #
+ mkdir -p $(TARGET_DIR)/usr/lib $(TARGET_DIR)/usr/sbin
+ touch $@
+
+$(GCC_BUILD_DIR2)/.libs_installed: $(GCC_BUILD_DIR2)/.installed
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+ # These are in /lib, so...
+ rm -rf $(TARGET_DIR)/usr/lib/libgcc_s*.so*
+ -cp -dpf $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib/libgcc_s* \
+ $(TARGET_DIR)/lib/
+ -$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/lib/libgcc_s*
+endif
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+ -cp -dpf $(STAGING_DIR)/lib/libstdc++.so* $(TARGET_DIR)/usr/lib/
+ -$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/usr/lib/libstdc++.so*
+endif
+endif
+ifeq ($(BR2_INSTALL_LIBGCJ),y)
+ cp -dpf $(STAGING_DIR)/lib/libgcj.so* $(TARGET_DIR)/usr/lib/
+ cp -dpf $(STAGING_DIR)/lib/lib-org-w3c-dom.so* $(TARGET_DIR)/usr/lib/
+ cp -dpf $(STAGING_DIR)/lib/lib-org-xml-sax.so* $(TARGET_DIR)/usr/lib/
+ mkdir -p $(TARGET_DIR)/usr/lib/security
+ cp -dpf $(STAGING_DIR)/usr/lib/security/libgcj.security \
+ $(TARGET_DIR)/usr/lib/security/
+ cp -dpf $(STAGING_DIR)/usr/lib/security/classpath.security \
+ $(TARGET_DIR)/usr/lib/security/
+endif
+ touch $@
+
+cross_compiler:=$(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc
+cross_compiler gcc: gcc-config $(GCC_BUILD_DIR2)/.installed $(GCC_BUILD_DIR2)/.libs_installed \
+ $(GCC_TARGETS)
+
+gcc-source: $(DL_DIR)/$(GCC_SOURCE)
+
+gcc-config: uclibc-configured binutils gcc_initial $(LIBFLOAT_TARGET) \
+ uclibc $(GCC_BUILD_DIR2)/.configured
+
+gcc-clean:
+ rm -rf $(GCC_BUILD_DIR2)
+ for prog in cpp gcc gcc-[0-9]* protoize unprotoize gcov gccbug cc; do \
+ rm -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-$$prog; \
+ rm -f $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-$$prog; \
+ done
+
+gcc-dirclean: gcc_initial-dirclean
+ rm -rf $(GCC_BUILD_DIR2)
+
+#############################################################
+#
+# Next build target gcc compiler
+#
+#############################################################
+GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-$(GCC_VERSION)-target
+
+$(GCC_BUILD_DIR3)/.prepared: $(GCC_BUILD_DIR2)/.libs_installed $(GCC_TARGET_PREREQ)
+ mkdir -p $(GCC_BUILD_DIR3)
+ touch $@
+
+$(GCC_BUILD_DIR3)/.configured: $(GCC_BUILD_DIR3)/.prepared
+ (cd $(GCC_BUILD_DIR3); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS_FOR_BUILD="-g -O2 $(HOST_CFLAGS)" \
+ $(TARGET_GCC_FLAGS) \
+ $(GCC_DIR)/configure \
+ --prefix=/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=$(GCC_TARGET_LANGUAGES) \
+ --with-gxx-include-dir=/usr/include/c++ \
+ --disable-__cxa_atexit \
+ --with-gnu-ld \
+ --with-gnu-as \
+ $(GCC_SHARED_LIBGCC) \
+ $(GCC_WITH_TARGET_GMP) \
+ $(GCC_WITH_TARGET_MPFR) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(GCC_USE_SJLJ_EXCEPTIONS) \
+ $(DISABLE_LARGEFILE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ $(EXTRA_TARGET_GCC_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR3)/.compiled: $(GCC_BUILD_DIR3)/.configured
+ PATH=$(TARGET_PATH) \
+ $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS_FOR_BUILD="-g -O2 $(HOST_CFLAGS)" \
+ $(TARGET_GCC_FLAGS) \
+ -C $(GCC_BUILD_DIR3) all
+ touch $@
+
+#
+# gcc-lib dir changes names to gcc with 3.4.mumble
+#
+ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+else
+GCC_LIB_SUBDIR=lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+# sigh... we need to find a better way
+ifeq ($(findstring 4.0.,$(GCC_VERSION)),4.0.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+ifeq ($(findstring 4.1.,$(GCC_VERSION)),4.1.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+ifeq ($(findstring 4.2,$(GCC_VERSION)),4.2)
+ifneq ($(findstring 4.2.,$(GCC_VERSION)),4.2.)
+REAL_GCC_VERSION=$(shell cat $(GCC_DIR)/gcc/BASE-VER)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(REAL_GCC_VERSION)
+else
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+endif
+
+$(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
+ PATH=$(TARGET_PATH) \
+ $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS_FOR_BUILD="-g -O2 $(HOST_CFLAGS)" \
+ $(TARGET_GCC_FLAGS) \
+ DESTDIR=$(TARGET_DIR) \
+ -C $(GCC_BUILD_DIR3) install
+ # Remove broken specs file (cross compile flag is set).
+ rm -f $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/specs
+ #
+ # Now for the ugly 3.3.x soft float hack...
+ #
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ($(findstring 3.3.,$(GCC_VERSION)),3.3.)
+ # Add a specs file that defaults to soft float mode.
+ cp toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+ # Make sure gcc does not think we are cross compiling
+ $(SED) "s/^1/0/;" $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+endif
+endif
+ #
+ # Ok... that's enough of that.
+ #
+ -(cd $(TARGET_DIR)/bin && find -type f | xargs $(STRIPCMD) > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/bin && find -type f | xargs $(STRIPCMD) > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR) && $(STRIPCMD) cc1 cc1plus collect2 > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/lib && $(STRIPCMD) libstdc++.so.*.*.* > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/lib && $(STRIPCMD) libgcc_s*.so.*.*.* > /dev/null 2>&1)
+ #
+ rm -f $(TARGET_DIR)/usr/lib/*.la*
+ #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
+ # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+ # Work around problem of missing syslimits.h
+ if [ ! -f $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/include/syslimits.h ]; then \
+ echo "warning: working around missing syslimits.h"; \
+ cp -f $(STAGING_DIR)/usr/$(GCC_LIB_SUBDIR)/include/syslimits.h \
+ $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/include/; \
+ fi
+ # Make sure we have 'cc'.
+ if [ ! -e $(TARGET_DIR)/usr/bin/cc ]; then \
+ ln -snf gcc $(TARGET_DIR)/usr/bin/cc; \
+ fi
+ # These are in /lib, so...
+ #rm -rf $(TARGET_DIR)/usr/lib/libgcc_s*.so*
+ #touch -c $(TARGET_DIR)/usr/bin/gcc
+
+gcc_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc
+
+gcc_target-clean:
+ rm -rf $(GCC_BUILD_DIR3)
+ rm -f $(TARGET_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)*
+
+gcc_target-dirclean:
+ rm -rf $(GCC_BUILD_DIR3)
+
+endif
+# gcc-3.x only
+
+endif
diff --git a/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-4.x.mk b/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-4.x.mk
new file mode 100644
index 0000000000..698069c2cc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/gcc-uclibc-4.x.mk
@@ -0,0 +1,530 @@
+# Makefile for to build a gcc/uClibc toolchain
+#
+# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# sysroot support works with gcc >= 4.2.0 only
+ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
+
+ifeq ($(GCC_SNAP_DATE),)
+GCC_OFFICIAL_VERSION:=$(GCC_VERSION)
+GCC_SITE:=$(BR2_GNU_MIRROR)/gcc/gcc-$(GCC_VERSION)
+#GCC_SITE:=ftp://ftp.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gcc/gcc-$(GCC_OFFICIAL_VERSION)
+else
+GCC_OFFICIAL_VERSION:=$(GCC_VERSION)-$(GCC_SNAP_DATE)
+GCC_SITE:=ftp://sources.redhat.com/pub/gcc/snapshots/$(GCC_OFFICIAL_VERSION)
+endif
+
+# redefine if using an external prepatched gcc source
+ifneq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+GCC_SITE:=$(VENDOR_SITE)
+GCC_OFFICIAL_VERSION:=$(GCC_VERSION)$(VENDOR_SUFFIX)$(VENDOR_GCC_RELEASE)
+GCC_PATCH_DIR:=toolchain/gcc/ext_source/$(VENDOR_PATCH_DIR)/$(GCC_OFFICIAL_VERSION)
+endif #!BR2_TOOLCHAIN_BUILDROOT
+
+# define patch location
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) # Normal toolchain
+ifeq ($(GCC_SNAP_DATE),) # Not a snapshot
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_VERSION)
+else # Is a snapshot
+ifneq ($(wildcard toolchain/gcc/$(GCC_OFFICIAL_VERSION)),) # Snapshot patch?
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_OFFICIAL_VERSION)
+else # Normal patch to snapshot
+# Use the normal location, if the dedicated location does not exist
+GCC_PATCH_DIR:=toolchain/gcc/$(GCC_VERSION)
+endif # Snapshot patch
+endif # Not a snapshot
+endif # BR2_TOOLCHAIN_BUILDROOT
+
+GCC_SOURCE:=gcc-$(GCC_OFFICIAL_VERSION).tar.bz2
+GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_OFFICIAL_VERSION)
+GCC_CAT:=$(BZCAT)
+GCC_STRIP_HOST_BINARIES:=nope
+GCC_SRC_DIR:=$(GCC_DIR)
+
+ifeq ($(findstring x3.,x$(GCC_VERSION)),x3.)
+GCC_NO_MPFR:=y
+endif
+ifeq ($(findstring x4.0.,x$(GCC_VERSION)),x4.0.)
+GCC_NO_MPFR:=y
+endif
+
+GCC_TARGET_PREREQ=
+GCC_STAGING_PREREQ=
+
+#############################################################
+#
+# Setup some initial stuff
+#
+#############################################################
+
+GCC_STAGING_PREREQ+=$(STAGING_DIR)/usr/lib/libc.a
+
+GCC_TARGET_LANGUAGES:=c
+
+GCC_CROSS_LANGUAGES:=c
+ifeq ($(BR2_GCC_CROSS_CXX),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),c++
+endif
+ifeq ($(BR2_GCC_CROSS_FORTRAN),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),fortran
+endif
+ifeq ($(BR2_GCC_CROSS_OBJC),y)
+GCC_CROSS_LANGUAGES:=$(GCC_CROSS_LANGUAGES),objc
+endif
+
+GCC_COMMON_PREREQ=$(wildcard $(BR2_DEPENDS_DIR)/br2/install/libstdcpp*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/install/libgcj*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/install/objc*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/install/fortran*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/install/libstdcpp*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/prefer/ima*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/toolchain/sysroot*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/use/sjlj/exceptions*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/gcc/shared/libgcc*)
+GCC_TARGET_PREREQ+=$(GCC_COMMON_PREREQ) \
+$(wildcard $(BR2_DEPENDS_DIR)/br2/extra/target/gcc/config/options*)
+GCC_STAGING_PREREQ+=$(GCC_COMMON_PREREQ) \
+$(wildcard $(BR2_DEPENDS_DIR)/br2/extra/gcc/config/options*)\
+$(wildcard $(BR2_DEPENDS_DIR)/br2/gcc/cross/*)
+
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),c++
+endif
+
+ifeq ($(BR2_INSTALL_LIBGCJ),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),java
+endif
+
+ifeq ($(BR2_INSTALL_OBJC),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),objc
+endif
+
+ifndef GCC_NO_MPFR
+GCC_WITH_HOST_GMP=--with-gmp=$(GMP_HOST_DIR)
+GCC_WITH_HOST_MPFR=--with-mpfr=$(MPFR_HOST_DIR)
+
+ifeq ($(BR2_INSTALL_FORTRAN),y)
+GCC_TARGET_LANGUAGES:=$(GCC_TARGET_LANGUAGES),fortran
+#GCC_TARGET_PREREQ+=$(TARGET_DIR)/usr/lib/libmpfr.so $(TARGET_DIR)/usr/lib/libgmp.so
+#GCC_STAGING_PREREQ+=$(TOOL_BUILD_DIR)/mpfr/lib/libmpfr.so
+GCC_WITH_TARGET_GMP=--with-gmp="$(GMP_TARGET_DIR)"
+GCC_WITH_TARGET_MPFR=--with-mpfr="$(MPFR_TARGET_DIR)"
+endif
+endif # ifndef GCC_NO_MPFR
+
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+GCC_SHARED_LIBGCC:=--enable-shared
+else
+GCC_SHARED_LIBGCC:=--disable-shared
+endif
+
+ifneq ($(BR2_ENABLE_LOCALE),y)
+GCC_ENABLE_CLOCALE:=--disable-clocale
+endif
+
+ifeq ($(BR2_KERNEL_HURD),y)
+EXTRA_GCC1_CONFIG_OPTIONS+=--without-headers
+endif
+
+ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
+GCC_DECIMAL_FLOAT:=--disable-decimal-float
+endif
+
+HOST_SOURCE+=gcc-source
+
+$(DL_DIR)/$(GCC_SOURCE):
+ mkdir -p $(DL_DIR)
+ $(WGET) -P $(DL_DIR) $(GCC_SITE)/$(GCC_SOURCE)
+
+gcc-unpacked: $(GCC_DIR)/.patched
+$(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
+ mkdir -p $(TOOL_BUILD_DIR)
+ rm -rf $(GCC_DIR)
+ $(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ $(CONFIG_UPDATE) $(@D)
+ touch $@
+
+gcc-patched: $(GCC_DIR)/.patched
+$(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
+ # Apply any files named gcc-*.patch from the source directory to gcc
+ toolchain/patch-kernel.sh $(GCC_DIR) $(GCC_PATCH_DIR) \*.patch
+
+ # Note: The soft float situation has improved considerably with gcc 3.4.x.
+ # We can dispense with the custom spec files, as well as libfloat for the arm case.
+ # However, we still need a patch for arm. There's a similar patch for gcc 3.3.x
+ # which needs to be integrated so we can kill of libfloat for good, except for
+ # anyone (?) who might still be using gcc 2.95. mjn3
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ("$(strip $(ARCH))","arm")
+ toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc/$(GCC_VERSION) arm-softfloat.patch.conditional
+endif
+ifeq ("$(strip $(ARCH))","armeb")
+ toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc/$(GCC_VERSION) arm-softfloat.patch.conditional
+endif
+ # Not yet updated to 3.4.1.
+ #ifeq ("$(strip $(ARCH))","i386")
+ #toolchain/patch-kernel.sh $(GCC_DIR) toolchain/gcc i386-gcc-soft-float.patch
+ #endif
+endif
+ touch $@
+
+#############################################################
+#
+# build the first pass gcc compiler
+#
+#############################################################
+GCC_BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-initial
+
+
+# The --without-headers option stopped working with gcc 3.0 and has never been
+# fixed, so we need to actually have working C library header files prior to
+# the step or libgcc will not build...
+
+$(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
+ mkdir -p $(GCC_BUILD_DIR1)
+ (cd $(GCC_BUILD_DIR1); rm -rf config.cache; \
+ $(HOST_CONFIGURE_OPTS) \
+ $(GCC_DIR)/configure \
+ --prefix=$(STAGING_DIR)/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=c \
+ $(BR2_CONFIGURE_DEVEL_SYSROOT) \
+ --disable-__cxa_atexit \
+ --enable-target-optspace \
+ --with-gnu-ld \
+ --disable-shared \
+ $(GCC_WITH_HOST_GMP) \
+ $(GCC_WITH_HOST_MPFR) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(GCC_DECIMAL_FLOAT) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ $(EXTRA_GCC1_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
+ # gcc >= 4.3.0 have to also build all-target-libgcc
+ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
+ $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc all-target-libgcc
+else
+ $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
+endif
+ touch $@
+
+gcc_initial=$(GCC_BUILD_DIR1)/.installed
+$(gcc_initial) $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
+ # gcc >= 4.3.0 have to also install install-target-libgcc
+ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
+ PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc install-target-libgcc
+else
+ PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
+endif
+ touch $(gcc_initial)
+
+gcc_initial: uclibc-configured binutils $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc
+
+gcc_initial-clean:
+ rm -rf $(GCC_BUILD_DIR1)
+
+gcc_initial-dirclean:
+ rm -rf $(GCC_BUILD_DIR1) $(GCC_DIR)
+
+#############################################################
+#
+# second pass compiler build. Build the compiler targeting
+# the newly built shared uClibc library.
+#
+#############################################################
+#
+# Sigh... I had to rework things because using --with-gxx-include-dir
+# causes issues with include dir search order for g++. This seems to
+# have something to do with "path translations" and possibly doesn't
+# affect gcc-target. However, I haven't tested gcc-target yet so no
+# guarantees. mjn3
+
+GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-final
+$(GCC_BUILD_DIR2)/.configured: $(GCC_SRC_DIR)/.patched $(GCC_STAGING_PREREQ)
+ mkdir -p $(GCC_BUILD_DIR2)
+ # Important! Required for limits.h to be fixed.
+ ln -snf ../include/ $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
+ #-rmdir $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ #ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ (cd $(GCC_BUILD_DIR2); rm -rf config.cache; \
+ $(HOST_CONFIGURE_OPTS) \
+ $(GCC_SRC_DIR)/configure \
+ --prefix=$(BR2_SYSROOT_PREFIX)/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=$(GCC_CROSS_LANGUAGES) \
+ $(BR2_CONFIGURE_STAGING_SYSROOT) \
+ $(BR2_CONFIGURE_BUILD_TOOLS) \
+ --disable-__cxa_atexit \
+ --enable-target-optspace \
+ --with-gnu-ld \
+ $(GCC_SHARED_LIBGCC) \
+ $(GCC_WITH_HOST_GMP) \
+ $(GCC_WITH_HOST_MPFR) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(GCC_DECIMAL_FLOAT) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(GCC_USE_SJLJ_EXCEPTIONS) \
+ $(DISABLE_LARGEFILE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ $(EXTRA_GCC2_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
+ $(MAKE) -C $(GCC_BUILD_DIR2) all
+ touch $@
+
+$(GCC_BUILD_DIR2)/.installed: $(GCC_BUILD_DIR2)/.compiled
+ PATH=$(TARGET_PATH) $(MAKE) $(BR2_SYSROOT_STAGING_DESTDIR) \
+ -C $(GCC_BUILD_DIR2) install
+ if [ -d "$(STAGING_DIR)/lib64" ]; then \
+ if [ ! -e "$(STAGING_DIR)/lib" ]; then \
+ mkdir -p "$(STAGING_DIR)/lib"; \
+ fi; \
+ mv "$(STAGING_DIR)/lib64/"* "$(STAGING_DIR)/lib/"; \
+ rmdir "$(STAGING_DIR)/lib64"; \
+ fi
+ # Strip the host binaries
+ifeq ($(GCC_STRIP_HOST_BINARIES),true)
+ strip --strip-all -R .note -R .comment $(filter-out %-gccbug %-embedspu,$(wildcard $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-*))
+endif
+ # Make sure we have 'cc'.
+ if [ ! -e $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc ]; then \
+ ln -snf $(REAL_GNU_TARGET_NAME)-gcc \
+ $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-cc; \
+ fi
+ if [ ! -e $(STAGING_DIR)/usr/bin/cc ]; then \
+ ln -snf gcc $(STAGING_DIR)/usr/bin/cc; \
+ fi
+ # Set up the symlinks to enable lying about target name.
+ set -e; \
+ (cd $(STAGING_DIR); \
+ ln -snf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
+ cd usr/bin; \
+ for app in $(REAL_GNU_TARGET_NAME)-*; do \
+ ln -snf $${app} \
+ $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
+ done; \
+ )
+ #
+ # Now for the ugly 3.3.x soft float hack...
+ #
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ($(findstring 3.3.,$(GCC_VERSION)),3.3.)
+ # Make sure we have a soft float specs file for this arch
+ if [ ! -f toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float ]; then \
+ echo soft float configured but no specs file for this arch; \
+ /bin/false; \
+ fi
+ # Replace specs file with one that defaults to soft float mode.
+ if [ ! -f $(STAGING_DIR)/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ]; then \
+ echo staging dir specs file is missing; \
+ /bin/false; \
+ fi
+ cp toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float $(STAGING_DIR)/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+endif
+endif
+ #
+ # Ok... that's enough of that.
+ #
+ mkdir -p $(TARGET_DIR)/usr/lib $(TARGET_DIR)/usr/sbin
+ touch $@
+
+$(GCC_BUILD_DIR2)/.libs_installed: $(GCC_BUILD_DIR2)/.installed
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+ # These are in /lib, so...
+ rm -rf $(TARGET_DIR)/usr/lib/libgcc_s*.so*
+ -cp -dpf $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib/libgcc_s* \
+ $(TARGET_DIR)/lib/
+ -$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/lib/libgcc_s*
+endif
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+ifeq ($(BR2_GCC_SHARED_LIBGCC),y)
+ -cp -dpf $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib/libstdc++.so* \
+ $(TARGET_DIR)/usr/lib/
+ -$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/usr/lib/libstdc++.so*
+endif
+endif
+ifeq ($(BR2_INSTALL_LIBGCJ),y)
+ cp -dpf $(STAGING_DIR)/lib/libgcj.so* $(TARGET_DIR)/lib/
+ cp -dpf $(STAGING_DIR)/lib/lib-org-w3c-dom.so* $(TARGET_DIR)/lib/
+ cp -dpf $(STAGING_DIR)/lib/lib-org-xml-sax.so* $(TARGET_DIR)/lib/
+ mkdir -p $(TARGET_DIR)/usr/lib/security
+ cp -dpf $(STAGING_DIR)/usr/lib/security/libgcj.security \
+ $(TARGET_DIR)/usr/lib/security/
+ cp -dpf $(STAGING_DIR)/usr/lib/security/classpath.security \
+ $(TARGET_DIR)/usr/lib/security/
+endif
+ touch $@
+
+cross_compiler:=$(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc
+cross_compiler gcc: uclibc-configured binutils gcc_initial \
+ $(LIBFLOAT_TARGET) uclibc \
+ $(GCC_BUILD_DIR2)/.installed $(GCC_BUILD_DIR2)/.libs_installed \
+ $(GCC_TARGETS)
+
+gcc-source: $(DL_DIR)/$(GCC_SOURCE)
+
+gcc-clean:
+ rm -rf $(GCC_BUILD_DIR2)
+ for prog in cpp gcc gcc-[0-9]* protoize unprotoize gcov gccbug cc; do \
+ rm -f $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-$$prog; \
+ rm -f $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-$$prog; \
+ done
+
+gcc-dirclean: gcc_initial-dirclean
+ rm -rf $(GCC_BUILD_DIR2)
+
+#############################################################
+#
+# Next build target gcc compiler
+#
+#############################################################
+GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-$(GCC_VERSION)-target
+
+$(GCC_BUILD_DIR3)/.prepared: $(GCC_BUILD_DIR2)/.libs_installed $(GCC_TARGET_PREREQ)
+ mkdir -p $(GCC_BUILD_DIR3)
+ touch $@
+
+$(GCC_BUILD_DIR3)/.configured: $(GCC_BUILD_DIR3)/.prepared
+ (cd $(GCC_BUILD_DIR3); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_OPTS) \
+ $(TARGET_CONFIGURE_ARGS) \
+ $(TARGET_GCC_FLAGS) \
+ $(GCC_SRC_DIR)/configure \
+ --prefix=/usr \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-languages=$(GCC_TARGET_LANGUAGES) \
+ --with-gxx-include-dir=/usr/include/c++ \
+ --disable-__cxa_atexit \
+ --with-gnu-ld \
+ $(GCC_SHARED_LIBGCC) \
+ $(GCC_WITH_TARGET_GMP) \
+ $(GCC_WITH_TARGET_MPFR) \
+ $(DISABLE_NLS) \
+ $(THREADS) \
+ $(MULTILIB) \
+ $(GCC_DECIMAL_FLOAT) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
+ $(GCC_USE_SJLJ_EXCEPTIONS) \
+ $(DISABLE_LARGEFILE) \
+ $(EXTRA_GCC_CONFIG_OPTIONS) \
+ $(EXTRA_TARGET_GCC_CONFIG_OPTIONS) \
+ $(EXTRA_GCC3_CONFIG_OPTIONS) \
+ )
+ touch $@
+
+$(GCC_BUILD_DIR3)/.compiled: $(GCC_BUILD_DIR3)/.configured
+ PATH=$(TARGET_PATH) \
+ $(MAKE) -C $(GCC_BUILD_DIR3) all
+ touch $@
+
+#
+# gcc-lib dir changes names to gcc with 3.4.mumble
+#
+ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+else
+GCC_LIB_SUBDIR=lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+# sigh... we need to find a better way
+ifeq ($(findstring 4.0.,$(GCC_VERSION)),4.0.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+ifeq ($(findstring 4.1.,$(GCC_VERSION)),4.1.)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+ifeq ($(findstring 4.2,$(GCC_VERSION)),4.2)
+ifneq ($(findstring 4.2.,$(GCC_VERSION)),4.2.)
+REAL_GCC_VERSION=$(shell cat $(GCC_SRC_DIR)/gcc/BASE-VER)
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(REAL_GCC_VERSION)
+else
+GCC_LIB_SUBDIR=lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)
+endif
+endif
+
+$(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
+ PATH=$(TARGET_PATH) DESTDIR=$(TARGET_DIR) \
+ $(MAKE1) -C $(GCC_BUILD_DIR3) install
+ # Remove broken specs file (cross compile flag is set).
+ rm -f $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/specs
+ #
+ # Now for the ugly 3.3.x soft float hack...
+ #
+ifeq ($(BR2_SOFT_FLOAT),y)
+ifeq ($(findstring 3.3.,$(GCC_VERSION)),3.3.)
+ # Add a specs file that defaults to soft float mode.
+ cp toolchain/gcc/$(GCC_VERSION)/specs-$(ARCH)-soft-float $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+ # Make sure gcc does not think we are cross compiling
+ $(SED) "s/^1/0/;" $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
+endif
+endif
+ #
+ # Ok... that's enough of that.
+ #
+ -(cd $(TARGET_DIR)/bin && find -type f | xargs $(STRIPCMD) > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/bin && find -type f | xargs $(STRIPCMD) > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR) && $(STRIPCMD) cc1 cc1plus collect2 > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/usr/lib && $(STRIPCMD) libstdc++.so.*.*.* > /dev/null 2>&1)
+ -(cd $(TARGET_DIR)/lib && $(STRIPCMD) libgcc_s*.so.*.*.* > /dev/null 2>&1)
+ #
+ rm -f $(TARGET_DIR)/usr/lib/*.la*
+ #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
+ # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+ # Work around problem of missing syslimits.h
+ if [ ! -f $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/include/syslimits.h ]; then \
+ echo "warning: working around missing syslimits.h"; \
+ cp -f $(STAGING_DIR)/$(GCC_LIB_SUBDIR)/include/syslimits.h \
+ $(TARGET_DIR)/usr/$(GCC_LIB_SUBDIR)/include/; \
+ fi
+ # Make sure we have 'cc'.
+ if [ ! -e $(TARGET_DIR)/usr/bin/cc ]; then \
+ ln -snf gcc $(TARGET_DIR)/usr/bin/cc; \
+ fi
+ # These are in /lib, so...
+ #rm -rf $(TARGET_DIR)/usr/lib/libgcc_s*.so*
+ touch -c $@
+
+gcc_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc
+
+gcc_target-clean:
+ rm -rf $(GCC_BUILD_DIR3)
+ rm -f $(TARGET_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)*
+
+gcc_target-dirclean:
+ rm -rf $(GCC_BUILD_DIR3)
+
+endif
+# gcc-4.x only
diff --git a/cleopatre/buildroot/toolchain/gcc/i386-gcc-soft-float.patch b/cleopatre/buildroot/toolchain/gcc/i386-gcc-soft-float.patch
new file mode 100644
index 0000000000..97501087e2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gcc/i386-gcc-soft-float.patch
@@ -0,0 +1,61 @@
+diff -urN gcc-3.3.2-orig/gcc/config/i386/i386.h gcc-3.3.2/gcc/config/i386/i386.h
+--- gcc-3.3.2-orig/gcc/config/i386/i386.h 2003-06-25 16:18:31.000000000 -0500
++++ gcc-3.3.2/gcc/config/i386/i386.h 2003-10-22 01:46:57.000000000 -0500
+@@ -653,6 +653,7 @@
+ /* Define for XFmode or TFmode extended real floating point support.
+ The XFmode is specified by i386 ABI, while TFmode may be faster
+ due to alignment and simplifications in the address calculations. */
++#if 0
+ #define LONG_DOUBLE_TYPE_SIZE (TARGET_128BIT_LONG_DOUBLE ? 128 : 96)
+ #define MAX_LONG_DOUBLE_TYPE_SIZE 128
+ #ifdef __x86_64__
+@@ -660,6 +661,17 @@
+ #else
+ #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 96
+ #endif
++#else
++ /* Set up for x86 soft float with 64-bit long doubles, since that's
++ * all the soft float emulation supports. */
++#define LONG_DOUBLE_TYPE_SIZE (TARGET_128BIT_LONG_DOUBLE ? 128 : (TARGET_80387 ? 96 : 64))
++#define MAX_LONG_DOUBLE_TYPE_SIZE 128
++#ifdef __x86_64__
++#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
++#else
++#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE (TARGET_80387 ? 96 : 64)
++#endif
++#endif
+
+ /* Set the value of FLT_EVAL_METHOD in float.h. When using only the
+ FPU, assume that the fpcw is set to extended precision; when using
+diff -urN gcc-3.3.2-orig/gcc/config/t-linux gcc-3.3.2/gcc/config/t-linux
+--- gcc-3.3.2-orig/gcc/config/t-linux-uclibc 2003-06-04 11:56:11.000000000 -0500
++++ gcc-3.3.2/gcc/config/t-linux-uclibc 2003-10-22 01:46:39.000000000 -0500
+@@ -21,3 +21,28 @@
+ LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
+ $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h
++
++##############################################
++# We want fine grained libraries, so use the new code to build the
++# floating point emulation libraries.
++FPBIT = fp-bit.c
++DPBIT = dp-bit.c
++
++#LIB2FUNCS_EXTRA = xp-bit.c
++
++dp-bit.c: $(srcdir)/config/fp-bit.c
++ echo '#ifdef __LITTLE_ENDIAN__' > dp-bit.c
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >>dp-bit.c
++ echo '#endif' >> dp-bit.c
++ cat $(srcdir)/config/fp-bit.c >> dp-bit.c
++
++fp-bit.c: $(srcdir)/config/fp-bit.c
++ echo '#define FLOAT' > fp-bit.c
++ echo '#ifdef __LITTLE_ENDIAN__' >> fp-bit.c
++ echo '#define FLOAT_BIT_ORDER_MISMATCH' >>fp-bit.c
++ echo '#endif' >> fp-bit.c
++ cat $(srcdir)/config/fp-bit.c >> fp-bit.c
++
++#MULTILIB_OPTIONS = msoft-float
++#MULTILIB_DIRNAMES = soft-float
++
diff --git a/cleopatre/buildroot/toolchain/gdb/6.2.1/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.2.1/100-uclibc-conf.patch
new file mode 100644
index 0000000000..d3645bfeaa
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.2.1/100-uclibc-conf.patch
@@ -0,0 +1,290 @@
+diff -urN gdb-6.2-dist/bfd/config.bfd gdb-6.2/bfd/config.bfd
+--- gdb-6.2-dist/bfd/config.bfd 2004-07-09 07:32:35.000000000 -0500
++++ gdb-6.2/bfd/config.bfd 2004-08-08 04:23:19.000000000 -0500
+@@ -129,7 +129,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -139,7 +139,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu | ia64*-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -216,7 +216,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-gnu* | arm*b-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -224,7 +224,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-linux-uclibc* | arm*-*-conix* | \
+ arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks)
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+@@ -373,7 +373,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-gnu* | hppa*64*-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -384,7 +384,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu* | hppa*-*-netbsd*)
++ hppa*-*-linux-gnu* | hppa*-*-netbsd* | hppa*-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -507,7 +507,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -521,7 +521,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-gnu* | x86_64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -691,7 +691,7 @@
+ targ_defvec=hp300hpux_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux*aout*)
++ m68*-*-linux*aout* | m68*-*-linux-uclibc*)
+ targ_defvec=m68klinux_vec
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+@@ -972,8 +972,8 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
+- powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
++ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-linux-uclibc* | powerpc-*-rtems* | \
++ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss* )
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+ targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
+@@ -1009,8 +1009,8 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
+- powerpcle-*-rtems*)
++ powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-linux-uclibc* | \
++ powerpcle-*-vxworks* | powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
+@@ -1177,7 +1177,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-gnu* | sparc-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1224,7 +1224,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-gnu* | sparc64-*-linux-uclibc*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+@@ -1293,7 +1293,7 @@
+ targ_underscore=yes
+ ;;
+
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ targ_defvec=bfd_elf32_vax_vec
+ ;;
+
+diff -urN gdb-6.2-dist/bfd/configure gdb-6.2/bfd/configure
+--- gdb-6.2-dist/bfd/configure 2004-07-07 12:28:45.000000000 -0500
++++ gdb-6.2/bfd/configure 2004-08-08 04:27:01.000000000 -0500
+@@ -1698,6 +1698,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -5264,7 +5269,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -5328,7 +5333,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -5366,7 +5371,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -5470,7 +5475,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -urN gdb-6.2-dist/bfd/configure.in gdb-6.2/bfd/configure.in
+--- gdb-6.2-dist/bfd/configure.in 2004-07-07 12:28:45.000000000 -0500
++++ gdb-6.2/bfd/configure.in 2004-08-08 04:28:07.000000000 -0500
+@@ -164,7 +164,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-gnu* | alpha*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -249,7 +249,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-gnu* | i[3-7]86-*-linux-uclibc*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -290,7 +290,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-gnu* | m68*-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -378,7 +378,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-gnu* | vax-*-linux-uclibc*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+diff -urN gdb-6.2-dist/libtool.m4 gdb-6.2/libtool.m4
+--- gdb-6.2-dist/libtool.m4 2003-04-10 22:58:39.000000000 -0500
++++ gdb-6.2/libtool.m4 2004-08-08 03:48:33.000000000 -0500
+@@ -645,6 +645,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
+diff -urN gdb-6.2-dist/ltconfig gdb-6.2/ltconfig
+--- gdb-6.2-dist/ltconfig 2003-10-03 23:54:47.000000000 -0500
++++ gdb-6.2/ltconfig 2004-08-08 03:48:33.000000000 -0500
+@@ -602,7 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1259,6 +1259,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -urN gdb-6.2-dist/opcodes/configure gdb-6.2/opcodes/configure
+--- gdb-6.2-dist/opcodes/configure 2004-07-07 12:28:53.000000000 -0500
++++ gdb-6.2/opcodes/configure 2004-08-08 04:53:55.000000000 -0500
+@@ -1701,6 +1701,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd*)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff --git a/cleopatre/buildroot/toolchain/gdb/6.2.1/200-uclibc-readline-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.2.1/200-uclibc-readline-conf.patch
new file mode 100644
index 0000000000..ffe792dd05
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.2.1/200-uclibc-readline-conf.patch
@@ -0,0 +1,15 @@
+--- gdb-6.1.1-dist/readline/configure 2003-05-27 18:29:47.000000000 -0500
++++ gdb-6.1.1/readline/configure 2004-08-09 14:20:23.000000000 -0500
+@@ -6249,7 +6249,12 @@
+
+
+ echo "$as_me:$LINENO: checking for mbstate_t" >&5
++echo $ECHO_N "bash_cv_have_mbstate_t=$bash_cv_have_mbstate_t" >&6
+ echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
++if test "${bash_cv_have_mbstate_t+set}" != set; then
++ bash_cv_have_mbstate_t=yes
++ echo $ECHO_N "WARNING!! forcing to yes!!! $ECHO_C" >&6
++fi
+ if test "${bash_cv_have_mbstate_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
diff --git a/cleopatre/buildroot/toolchain/gdb/6.2.1/400-mips-coredump.patch-2.4.23-29 b/cleopatre/buildroot/toolchain/gdb/6.2.1/400-mips-coredump.patch-2.4.23-29
new file mode 100644
index 0000000000..4e17ba7bea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.2.1/400-mips-coredump.patch-2.4.23-29
@@ -0,0 +1,28 @@
+Sometime around 2.4.22-23, the mips pt_regs.h fields were reordered, breaking
+coredump handling by gdb for current kernels. Update the hardcoded constants
+to reflect the change.
+--- gdb-6.2.1/gdb/mips-linux-tdep.c-orig 2004-10-29 14:23:55.000000000 -0500
++++ gdb-6.2.1/gdb/mips-linux-tdep.c 2004-10-29 14:26:44.000000000 -0500
+@@ -53,12 +53,22 @@
+
+ #define EF_REG0 6
+ #define EF_REG31 37
++
++#if 0
+ #define EF_LO 38
+ #define EF_HI 39
+ #define EF_CP0_EPC 40
+ #define EF_CP0_BADVADDR 41
+ #define EF_CP0_STATUS 42
+ #define EF_CP0_CAUSE 43
++#else
++#define EF_CP0_STATUS 38
++#define EF_LO 39
++#define EF_HI 40
++#define EF_CP0_BADVADDR 41
++#define EF_CP0_CAUSE 42
++#define EF_CP0_EPC 43
++#endif
+
+ #define EF_SIZE 180
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.2.1/500-thread-timeout.patch b/cleopatre/buildroot/toolchain/gdb/6.2.1/500-thread-timeout.patch
new file mode 100644
index 0000000000..410fb21d55
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.2.1/500-thread-timeout.patch
@@ -0,0 +1,34 @@
+--- gdb-6.3.org/gdb/gdbserver/thread-db.c 2004-10-17 02:42:00.000000000 +0900
++++ gdb-6.3/gdb/gdbserver/thread-db.c 2005-01-27 12:19:29.000000000 +0900
+@@ -21,6 +21,7 @@
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
++#include <unistd.h>
+ #include "server.h"
+
+ #include "linux-low.h"
+@@ -142,6 +143,7 @@
+ td_event_msg_t msg;
+ td_err_e err;
+ struct inferior_linux_data *tdata;
++ int timeout;
+
+ if (debug_threads)
+ fprintf (stderr, "Thread creation event.\n");
+@@ -152,7 +154,13 @@
+ In the LinuxThreads implementation, this is safe,
+ because all events come from the manager thread
+ (except for its own creation, of course). */
+- err = td_ta_event_getmsg (thread_agent, &msg);
++ for (timeout = 0; timeout < 50000; timeout++)
++ {
++ err = td_ta_event_getmsg (thread_agent, &msg);
++ if (err != TD_NOMSG)
++ break;
++ usleep(1000);
++ }
+ if (err != TD_OK)
+ fprintf (stderr, "thread getmsg err: %s\n",
+ thread_db_err_str (err));
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.3/100-uclibc-conf.patch
new file mode 100644
index 0000000000..cc69ff33bd
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/100-uclibc-conf.patch
@@ -0,0 +1,280 @@
+--- gdb-6.3/bfd/config.bfd.orig Fri Oct 15 07:47:11 2004
++++ gdb-6.3/bfd/config.bfd Mon Feb 28 00:04:43 2005
+@@ -129,7 +129,7 @@
+ targ_defvec=ecoffalpha_little_vec
+ targ_selvecs=bfd_elf64_alpha_vec
+ ;;
+- alpha*-*-linux-gnu* | alpha*-*-elf*)
++ alpha*-*-linux-* | alpha*-*-elf*)
+ targ_defvec=bfd_elf64_alpha_vec
+ targ_selvecs=ecoffalpha_little_vec
+ ;;
+@@ -139,7 +139,7 @@
+ alpha*-*-*)
+ targ_defvec=ecoffalpha_little_vec
+ ;;
+- ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-gnu* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
++ ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
+ targ_defvec=bfd_elf64_ia64_little_vec
+ targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
+ ;;
+@@ -216,7 +216,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- armeb-*-elf | arm*b-*-linux-gnu*)
++ armeb-*-elf | arm*b-*-linux-*)
+ targ_defvec=bfd_elf32_bigarm_vec
+ targ_selvecs=bfd_elf32_littlearm_vec
+ ;;
+@@ -224,7 +224,7 @@
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
+ ;;
+- arm-*-elf | arm-*-freebsd* | arm*-*-linux-gnu* | arm*-*-conix* | \
++ arm-*-elf | arm-*-freebsd* | arm*-*-linux-* | arm*-*-conix* | \
+ arm*-*-uclinux* | arm-*-kfreebsd*-gnu | arm-*-vxworks | \
+ arm*-*-eabi* )
+ targ_defvec=bfd_elf32_littlearm_vec
+@@ -378,7 +378,7 @@
+ ;;
+
+ #ifdef BFD64
+- hppa*64*-*-linux-gnu*)
++ hppa*64*-*-linux-*)
+ targ_defvec=bfd_elf64_hppa_linux_vec
+ targ_selvecs=bfd_elf64_hppa_vec
+ ;;
+@@ -389,7 +389,7 @@
+ ;;
+ #endif
+
+- hppa*-*-linux-gnu*)
++ hppa*-*-linux-*)
+ targ_defvec=bfd_elf32_hppa_linux_vec
+ targ_selvecs=bfd_elf32_hppa_vec
+ ;;
+@@ -522,7 +522,7 @@
+ targ_selvecs=bfd_elf32_i386_vec
+ targ_underscore=yes
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ targ_defvec=bfd_elf32_i386_vec
+ targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
+ targ64_selvecs=bfd_elf64_x86_64_vec
+@@ -536,7 +536,7 @@
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec"
+ ;;
+- x86_64-*-linux-gnu*)
++ x86_64-*-linux-*)
+ targ_defvec=bfd_elf64_x86_64_vec
+ targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
+ ;;
+@@ -706,7 +706,7 @@
+ targ_defvec=hp300hpux_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux*aout*)
++ m68*-*-linux*aout* | m68*-*-linux-uclibc*)
+ targ_defvec=m68klinux_vec
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+@@ -987,7 +987,7 @@
+ ;;
+ #endif
+ powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
+- powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
++ powerpc-*-solaris2* | powerpc-*-linux-* | powerpc-*-rtems* | \
+ powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+@@ -1024,7 +1024,7 @@
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+ ;;
+ powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
+- powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
++ powerpcle-*-solaris2* | powerpcle-*-linux-* | powerpcle-*-vxworks* |\
+ powerpcle-*-rtems*)
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
+@@ -1192,7 +1192,7 @@
+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_underscore=yes
+ ;;
+- sparc-*-linux-gnu*)
++ sparc-*-linux-*)
+ targ_defvec=bfd_elf32_sparc_vec
+ targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec"
+ ;;
+@@ -1239,7 +1239,7 @@
+ targ_defvec=sunos_big_vec
+ targ_underscore=yes
+ ;;
+- sparc64-*-linux-gnu*)
++ sparc64-*-linux-*)
+ targ_defvec=bfd_elf64_sparc_vec
+ targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec"
+ ;;
+@@ -1308,7 +1308,7 @@
+ targ_underscore=yes
+ ;;
+
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ targ_defvec=bfd_elf32_vax_vec
+ ;;
+
+--- gdb-6.3/bfd/configure.orig Fri Oct 8 16:53:56 2004
++++ gdb-6.3/bfd/configure Sun Feb 27 18:32:58 2005
+@@ -3583,6 +3583,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+@@ -9914,7 +9919,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -9978,7 +9983,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+ ;;
+@@ -10016,7 +10021,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -10150,7 +10155,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+--- gdb-6.3/bfd/configure.in.orig Fri Oct 8 16:53:59 2004
++++ gdb-6.3/bfd/configure.in Sun Feb 27 18:14:41 2005
+@@ -163,7 +163,7 @@
+ alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
+ COREFILE=''
+ ;;
+- alpha*-*-linux-gnu*)
++ alpha*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/alphalinux.h"'
+ ;;
+@@ -248,7 +248,7 @@
+ TRAD_HEADER='"hosts/i386mach3.h"'
+ ;;
+ changequote(,)dnl
+- i[3-7]86-*-linux-gnu*)
++ i[3-7]86-*-linux-*)
+ changequote([,])dnl
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/i386linux.h"'
+@@ -289,7 +289,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/hp300bsd.h"'
+ ;;
+- m68*-*-linux-gnu*)
++ m68*-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/m68klinux.h"'
+ ;;
+@@ -375,7 +375,7 @@
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxult2.h"'
+ ;;
+- vax-*-linux-gnu*)
++ vax-*-linux-*)
+ COREFILE=trad-core.lo
+ TRAD_HEADER='"hosts/vaxlinux.h"'
+ ;;
+--- gdb-6.3/libtool.m4.orig Wed Jul 21 21:21:41 2004
++++ gdb-6.3/libtool.m4 Mon Feb 28 00:08:11 2005
+@@ -653,6 +653,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
+ lt_cv_file_magic_cmd=/usr/bin/file
+--- gdb-6.3/ltconfig.orig Tue Oct 5 15:34:42 2004
++++ gdb-6.3/ltconfig Sun Feb 27 18:14:41 2005
+@@ -602,7 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1270,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- gdb-6.3/opcodes/configure.orig Fri Sep 17 08:13:38 2004
++++ gdb-6.3/opcodes/configure Mon Feb 28 00:09:42 2005
+@@ -3595,6 +3595,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/200-uclibc-readline-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.3/200-uclibc-readline-conf.patch
new file mode 100644
index 0000000000..ffe792dd05
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/200-uclibc-readline-conf.patch
@@ -0,0 +1,15 @@
+--- gdb-6.1.1-dist/readline/configure 2003-05-27 18:29:47.000000000 -0500
++++ gdb-6.1.1/readline/configure 2004-08-09 14:20:23.000000000 -0500
+@@ -6249,7 +6249,12 @@
+
+
+ echo "$as_me:$LINENO: checking for mbstate_t" >&5
++echo $ECHO_N "bash_cv_have_mbstate_t=$bash_cv_have_mbstate_t" >&6
+ echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
++if test "${bash_cv_have_mbstate_t+set}" != set; then
++ bash_cv_have_mbstate_t=yes
++ echo $ECHO_N "WARNING!! forcing to yes!!! $ECHO_C" >&6
++fi
+ if test "${bash_cv_have_mbstate_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/400-mips-coredump.patch-2.4.23-29 b/cleopatre/buildroot/toolchain/gdb/6.3/400-mips-coredump.patch-2.4.23-29
new file mode 100644
index 0000000000..4e17ba7bea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/400-mips-coredump.patch-2.4.23-29
@@ -0,0 +1,28 @@
+Sometime around 2.4.22-23, the mips pt_regs.h fields were reordered, breaking
+coredump handling by gdb for current kernels. Update the hardcoded constants
+to reflect the change.
+--- gdb-6.2.1/gdb/mips-linux-tdep.c-orig 2004-10-29 14:23:55.000000000 -0500
++++ gdb-6.2.1/gdb/mips-linux-tdep.c 2004-10-29 14:26:44.000000000 -0500
+@@ -53,12 +53,22 @@
+
+ #define EF_REG0 6
+ #define EF_REG31 37
++
++#if 0
+ #define EF_LO 38
+ #define EF_HI 39
+ #define EF_CP0_EPC 40
+ #define EF_CP0_BADVADDR 41
+ #define EF_CP0_STATUS 42
+ #define EF_CP0_CAUSE 43
++#else
++#define EF_CP0_STATUS 38
++#define EF_LO 39
++#define EF_HI 40
++#define EF_CP0_BADVADDR 41
++#define EF_CP0_CAUSE 42
++#define EF_CP0_EPC 43
++#endif
+
+ #define EF_SIZE 180
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/500-thread-timeout.patch b/cleopatre/buildroot/toolchain/gdb/6.3/500-thread-timeout.patch
new file mode 100644
index 0000000000..6db0a7a474
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/500-thread-timeout.patch
@@ -0,0 +1,34 @@
+--- gdb-6.3.org/gdb/gdbserver/thread-db.c 2004-10-17 02:42:00.000000000 +0900
++++ gdb-6.3/gdb/gdbserver/thread-db.c 2005-01-27 12:19:29.000000000 +0900
+@@ -21,6 +21,7 @@
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
++#include <unistd.h>
+ #include "server.h"
+
+ #include "linux-low.h"
+@@ -142,6 +143,7 @@
+ td_event_msg_t msg;
+ td_err_e err;
+ struct inferior_linux_data *tdata;
++ int timeout;
+
+ if (debug_threads)
+ fprintf (stderr, "Thread creation event.\n");
+@@ -152,7 +154,13 @@
+ In the LinuxThreads implementation, this is safe,
+ because all events come from the manager thread
+ (except for its own creation, of course). */
+- err = td_ta_event_getmsg (thread_agent, &msg);
++ for (timeout = 0; timeout < 50000; timeout++)
++ {
++ err = td_ta_event_getmsg (thread_agent, &msg);
++ if (err != TD_NOMSG)
++ break;
++ usleep(1000);
++ }
+ if (err != TD_OK)
+ fprintf (stderr, "thread getmsg err: %s\n",
+ thread_db_err_str (err));
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/600-debian_10.selected-frame.patch b/cleopatre/buildroot/toolchain/gdb/6.3/600-debian_10.selected-frame.patch
new file mode 100644
index 0000000000..5970f9ba40
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/600-debian_10.selected-frame.patch
@@ -0,0 +1,552 @@
+2004-10-11
+
+This patch is not submitted. Many of these functions should be passing
+a frame around rather than calling get_selected_frame, but at least it
+is an improvement over deprecated_selected_frame.
+
+Index: gdb-6.3/gdb/breakpoint.c
+===================================================================
+--- gdb-6.3.orig/gdb/breakpoint.c 2004-10-08 13:30:46.000000000 -0400
++++ gdb-6.3/gdb/breakpoint.c 2004-11-09 22:55:11.231620957 -0500
+@@ -922,7 +922,7 @@ insert_bp_location (struct bp_location *
+ /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
+ took a frame parameter, so that we didn't have to change the
+ selected frame. */
+- saved_frame_id = get_frame_id (deprecated_selected_frame);
++ saved_frame_id = get_frame_id (get_selected_frame ());
+
+ /* Determine if the watchpoint is within scope. */
+ if (bpt->owner->exp_valid_block == NULL)
+@@ -5464,14 +5464,9 @@ break_at_finish_at_depth_command_1 (char
+
+ if (default_breakpoint_valid)
+ {
+- if (deprecated_selected_frame)
+- {
+- selected_pc = get_frame_pc (deprecated_selected_frame);
+- if (arg)
+- if_arg = 1;
+- }
+- else
+- error ("No selected frame.");
++ selected_pc = get_frame_pc (get_selected_frame ());
++ if (arg)
++ if_arg = 1;
+ }
+ else
+ error ("No default breakpoint address now.");
+@@ -5542,15 +5537,10 @@ break_at_finish_command_1 (char *arg, in
+ {
+ if (default_breakpoint_valid)
+ {
+- if (deprecated_selected_frame)
+- {
+- addr_string = xstrprintf ("*0x%s",
+- paddr_nz (get_frame_pc (deprecated_selected_frame)));
+- if (arg)
+- if_arg = 1;
+- }
+- else
+- error ("No selected frame.");
++ addr_string = xstrprintf ("*0x%s",
++ paddr_nz (get_frame_pc (get_selected_frame ())));
++ if (arg)
++ if_arg = 1;
+ }
+ else
+ error ("No default breakpoint address now.");
+@@ -6082,7 +6072,7 @@ until_break_command (char *arg, int from
+ {
+ struct symtabs_and_lines sals;
+ struct symtab_and_line sal;
+- struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
++ struct frame_info *prev_frame = get_prev_frame (get_selected_frame ());
+ struct breakpoint *breakpoint;
+ struct cleanup *old_chain;
+ struct continuation_arg *arg1;
+@@ -6119,7 +6109,7 @@ until_break_command (char *arg, int from
+ /* Otherwise, specify the current frame, because we want to stop only
+ at the very same frame. */
+ breakpoint = set_momentary_breakpoint (sal,
+- get_frame_id (deprecated_selected_frame),
++ get_frame_id (get_selected_frame ()),
+ bp_until);
+
+ if (!target_can_async_p ())
+Index: gdb-6.3/gdb/cli/cli-cmds.c
+===================================================================
+--- gdb-6.3.orig/gdb/cli/cli-cmds.c 2004-09-11 06:24:53.000000000 -0400
++++ gdb-6.3/gdb/cli/cli-cmds.c 2004-11-09 22:51:07.323246218 -0500
+@@ -845,10 +845,7 @@ disassemble_command (char *arg, int from
+ name = NULL;
+ if (!arg)
+ {
+- if (!deprecated_selected_frame)
+- error ("No frame selected.\n");
+-
+- pc = get_frame_pc (deprecated_selected_frame);
++ pc = get_frame_pc (get_selected_frame ());
+ if (find_pc_partial_function (pc, &name, &low, &high) == 0)
+ error ("No function contains program counter for selected frame.\n");
+ #if defined(TUI)
+Index: gdb-6.3/gdb/f-valprint.c
+===================================================================
+--- gdb-6.3.orig/gdb/f-valprint.c 2003-10-14 02:51:14.000000000 -0400
++++ gdb-6.3/gdb/f-valprint.c 2004-11-09 22:51:07.326245632 -0500
+@@ -76,7 +76,7 @@ f77_get_dynamic_lowerbound (struct type
+ switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
+ {
+ case BOUND_BY_VALUE_ON_STACK:
+- current_frame_addr = get_frame_base (deprecated_selected_frame);
++ current_frame_addr = get_frame_base (get_selected_frame ());
+ if (current_frame_addr > 0)
+ {
+ *lower_bound =
+@@ -100,7 +100,7 @@ f77_get_dynamic_lowerbound (struct type
+ break;
+
+ case BOUND_BY_REF_ON_STACK:
+- current_frame_addr = get_frame_base (deprecated_selected_frame);
++ current_frame_addr = get_frame_base (get_selected_frame ());
+ if (current_frame_addr > 0)
+ {
+ ptr_to_lower_bound =
+@@ -134,7 +134,7 @@ f77_get_dynamic_upperbound (struct type
+ switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
+ {
+ case BOUND_BY_VALUE_ON_STACK:
+- current_frame_addr = get_frame_base (deprecated_selected_frame);
++ current_frame_addr = get_frame_base (get_selected_frame ());
+ if (current_frame_addr > 0)
+ {
+ *upper_bound =
+@@ -163,7 +163,7 @@ f77_get_dynamic_upperbound (struct type
+ break;
+
+ case BOUND_BY_REF_ON_STACK:
+- current_frame_addr = get_frame_base (deprecated_selected_frame);
++ current_frame_addr = get_frame_base (get_selected_frame ());
+ if (current_frame_addr > 0)
+ {
+ ptr_to_upper_bound =
+@@ -630,10 +630,7 @@ info_common_command (char *comname, int
+ first make sure that it is visible and if so, let
+ us display its contents */
+
+- fi = deprecated_selected_frame;
+-
+- if (fi == NULL)
+- error ("No frame selected");
++ fi = get_selected_frame ();
+
+ /* The following is generally ripped off from stack.c's routine
+ print_frame_info() */
+@@ -722,10 +719,7 @@ there_is_a_visible_common_named (char *c
+ if (comname == NULL)
+ error ("Cannot deal with NULL common name!");
+
+- fi = deprecated_selected_frame;
+-
+- if (fi == NULL)
+- error ("No frame selected");
++ fi = get_selected_frame ();
+
+ /* The following is generally ripped off from stack.c's routine
+ print_frame_info() */
+Index: gdb-6.3/gdb/infcmd.c
+===================================================================
+--- gdb-6.3.orig/gdb/infcmd.c 2004-09-13 14:26:28.000000000 -0400
++++ gdb-6.3/gdb/infcmd.c 2004-11-09 22:57:37.274099559 -0500
+@@ -1214,10 +1214,8 @@ finish_command (char *arg, int from_tty)
+ error ("The \"finish\" command does not take any arguments.");
+ if (!target_has_execution)
+ error ("The program is not running.");
+- if (deprecated_selected_frame == NULL)
+- error ("No selected frame.");
+
+- frame = get_prev_frame (deprecated_selected_frame);
++ frame = get_prev_frame (get_selected_frame ());
+ if (frame == 0)
+ error ("\"finish\" not meaningful in the outermost frame.");
+
+@@ -1235,7 +1233,7 @@ finish_command (char *arg, int from_tty)
+
+ /* Find the function we will return from. */
+
+- function = find_pc_function (get_frame_pc (deprecated_selected_frame));
++ function = find_pc_function (get_frame_pc (get_selected_frame ()));
+
+ /* Print info on the selected frame, including level number but not
+ source. */
+@@ -1600,13 +1598,11 @@ registers_info (char *addr_exp, int fpre
+
+ if (!target_has_registers)
+ error ("The program has no registers now.");
+- if (deprecated_selected_frame == NULL)
+- error ("No selected frame.");
+
+ if (!addr_exp)
+ {
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+- deprecated_selected_frame, -1, fpregs);
++ get_selected_frame (), -1, fpregs);
+ return;
+ }
+
+@@ -1644,7 +1640,7 @@ registers_info (char *addr_exp, int fpre
+ if (regnum >= 0)
+ {
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+- deprecated_selected_frame, regnum, fpregs);
++ get_selected_frame (), regnum, fpregs);
+ continue;
+ }
+ }
+@@ -1658,7 +1654,7 @@ registers_info (char *addr_exp, int fpre
+ && regnum < NUM_REGS + NUM_PSEUDO_REGS)
+ {
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+- deprecated_selected_frame, regnum, fpregs);
++ get_selected_frame (), regnum, fpregs);
+ continue;
+ }
+ }
+@@ -1684,7 +1680,7 @@ registers_info (char *addr_exp, int fpre
+ if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
+ group))
+ gdbarch_print_registers_info (current_gdbarch,
+- gdb_stdout, deprecated_selected_frame,
++ gdb_stdout, get_selected_frame (),
+ regnum, fpregs);
+ }
+ continue;
+@@ -1714,8 +1710,6 @@ print_vector_info (struct gdbarch *gdbar
+ {
+ if (!target_has_registers)
+ error ("The program has no registers now.");
+- if (deprecated_selected_frame == NULL)
+- error ("No selected frame.");
+
+ if (gdbarch_print_vector_info_p (gdbarch))
+ gdbarch_print_vector_info (gdbarch, file, frame, args);
+@@ -1740,7 +1734,7 @@ print_vector_info (struct gdbarch *gdbar
+ static void
+ vector_info (char *args, int from_tty)
+ {
+- print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
++ print_vector_info (current_gdbarch, gdb_stdout, get_selected_frame (), args);
+ }
+
+
+@@ -1910,8 +1904,6 @@ print_float_info (struct gdbarch *gdbarc
+ {
+ if (!target_has_registers)
+ error ("The program has no registers now.");
+- if (deprecated_selected_frame == NULL)
+- error ("No selected frame.");
+
+ if (gdbarch_print_float_info_p (gdbarch))
+ gdbarch_print_float_info (gdbarch, file, frame, args);
+@@ -1937,7 +1929,7 @@ No floating-point info available for thi
+ static void
+ float_info (char *args, int from_tty)
+ {
+- print_float_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
++ print_float_info (current_gdbarch, gdb_stdout, get_selected_frame (), args);
+ }
+
+ static void
+Index: gdb-6.3/gdb/inflow.c
+===================================================================
+--- gdb-6.3.orig/gdb/inflow.c 2004-08-11 05:00:57.000000000 -0400
++++ gdb-6.3/gdb/inflow.c 2004-11-09 22:58:37.488338883 -0500
+@@ -591,10 +591,7 @@ kill_command (char *arg, int from_tty)
+ if (target_has_stack)
+ {
+ printf_filtered ("In %s,\n", target_longname);
+- if (deprecated_selected_frame == NULL)
+- fputs_filtered ("No selected stack frame.\n", gdb_stdout);
+- else
+- print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC);
++ print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC);
+ }
+ bfd_cache_close_all ();
+ }
+Index: gdb-6.3/gdb/infrun.c
+===================================================================
+--- gdb-6.3.orig/gdb/infrun.c 2004-09-27 13:58:08.000000000 -0400
++++ gdb-6.3/gdb/infrun.c 2004-11-09 22:51:07.351240752 -0500
+@@ -3485,7 +3485,7 @@ save_inferior_status (int restore_stack_
+
+ inf_status->registers = regcache_dup (current_regcache);
+
+- inf_status->selected_frame_id = get_frame_id (deprecated_selected_frame);
++ inf_status->selected_frame_id = get_frame_id (get_selected_frame ());
+ return inf_status;
+ }
+
+Index: gdb-6.3/gdb/mi/mi-main.c
+===================================================================
+--- gdb-6.3.orig/gdb/mi/mi-main.c 2004-09-12 11:00:42.000000000 -0400
++++ gdb-6.3/gdb/mi/mi-main.c 2004-11-09 22:53:29.998389013 -0500
+@@ -388,7 +388,7 @@ register_changed_p (int regnum)
+ {
+ char raw_buffer[MAX_REGISTER_SIZE];
+
+- if (! frame_register_read (deprecated_selected_frame, regnum, raw_buffer))
++ if (! frame_register_read (get_selected_frame (), regnum, raw_buffer))
+ return -1;
+
+ if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer,
+@@ -509,7 +509,7 @@ get_register (int regnum, int format)
+ if (format == 'N')
+ format = 0;
+
+- frame_register (deprecated_selected_frame, regnum, &optim, &lval, &addr,
++ frame_register (get_selected_frame (), regnum, &optim, &lval, &addr,
+ &realnum, buffer);
+
+ if (optim)
+Index: gdb-6.3/gdb/mn10300-tdep.c
+===================================================================
+--- gdb-6.3.orig/gdb/mn10300-tdep.c 2004-08-02 22:02:22.000000000 -0400
++++ gdb-6.3/gdb/mn10300-tdep.c 2004-11-09 22:51:07.356239776 -0500
+@@ -1154,7 +1154,7 @@ mn10300_print_register (const char *name
+ printf_filtered ("%s: ", name);
+
+ /* Get the data */
+- if (!frame_register_read (deprecated_selected_frame, regnum, raw_buffer))
++ if (!frame_register_read (get_selected_frame (), regnum, raw_buffer))
+ {
+ printf_filtered ("[invalid]");
+ return;
+Index: gdb-6.3/gdb/stack.c
+===================================================================
+--- gdb-6.3.orig/gdb/stack.c 2004-08-02 20:57:26.000000000 -0400
++++ gdb-6.3/gdb/stack.c 2004-11-09 22:51:07.361238800 -0500
+@@ -758,9 +758,7 @@ parse_frame_specification (char *frame_e
+ switch (numargs)
+ {
+ case 0:
+- if (deprecated_selected_frame == NULL)
+- error ("No selected frame.");
+- return deprecated_selected_frame;
++ return get_selected_frame ();
+ /* NOTREACHED */
+ case 1:
+ {
+@@ -902,10 +900,10 @@ frame_info (char *addr_exp, int from_tty
+ }
+ calling_frame_info = get_prev_frame (fi);
+
+- if (!addr_exp && frame_relative_level (deprecated_selected_frame) >= 0)
++ if (!addr_exp && frame_relative_level (get_selected_frame ()) >= 0)
+ {
+ printf_filtered ("Stack level %d, frame at ",
+- frame_relative_level (deprecated_selected_frame));
++ frame_relative_level (get_selected_frame ()));
+ print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
+ printf_filtered (":\n");
+ }
+@@ -1445,9 +1443,7 @@ print_frame_label_vars (struct frame_inf
+ void
+ locals_info (char *args, int from_tty)
+ {
+- if (!deprecated_selected_frame)
+- error ("No frame selected.");
+- print_frame_local_vars (deprecated_selected_frame, 0, gdb_stdout);
++ print_frame_local_vars (get_selected_frame (), 0, gdb_stdout);
+ }
+
+ static void
+@@ -1470,7 +1466,7 @@ catch_info (char *ignore, int from_tty)
+ if (!deprecated_selected_frame)
+ error ("No frame selected.");
+
+- print_frame_label_vars (deprecated_selected_frame, 0, gdb_stdout);
++ print_frame_label_vars (get_selected_frame (), 0, gdb_stdout);
+ }
+ }
+
+@@ -1537,9 +1533,7 @@ print_frame_arg_vars (struct frame_info
+ void
+ args_info (char *ignore, int from_tty)
+ {
+- if (!deprecated_selected_frame)
+- error ("No frame selected.");
+- print_frame_arg_vars (deprecated_selected_frame, gdb_stdout);
++ print_frame_arg_vars (get_selected_frame (), gdb_stdout);
+ }
+
+
+@@ -1724,7 +1718,7 @@ down_silently_base (char *count_exp)
+ if (target_has_stack == 0 || deprecated_selected_frame == 0)
+ error ("No stack.");
+
+- frame = find_relative_frame (deprecated_selected_frame, &count1);
++ frame = find_relative_frame (get_selected_frame (), &count1);
+ if (count1 != 0 && count_exp == 0)
+ {
+
+@@ -1944,7 +1938,7 @@ func_command (char *arg, int from_tty)
+
+ if (!found)
+ printf_filtered ("'%s' not within current stack frame.\n", arg);
+- else if (fp != deprecated_selected_frame)
++ else if (fp != get_selected_frame ())
+ select_and_print_frame (fp);
+ }
+
+@@ -1965,7 +1959,7 @@ get_frame_language (void)
+ instruction of another function. So we rely on
+ get_frame_address_in_block(), it provides us with a PC which is
+ guaranteed to be inside the frame's code block. */
+- s = find_pc_symtab (get_frame_address_in_block (deprecated_selected_frame));
++ s = find_pc_symtab (get_frame_address_in_block (get_selected_frame ()));
+ if (s)
+ flang = s->language;
+ else
+Index: gdb-6.3/gdb/tui/tui-disasm.c
+===================================================================
+--- gdb-6.3.orig/gdb/tui/tui-disasm.c 2004-02-24 20:10:01.000000000 -0500
++++ gdb-6.3/gdb/tui/tui-disasm.c 2004-11-09 22:51:07.370237044 -0500
+@@ -382,7 +382,7 @@ tui_vertical_disassem_scroll (enum tui_s
+
+ content = (tui_win_content) TUI_DISASM_WIN->generic.content;
+ if (cursal.symtab == (struct symtab *) NULL)
+- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
++ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));
+ else
+ s = cursal.symtab;
+
+Index: gdb-6.3/gdb/tui/tui-source.c
+===================================================================
+--- gdb-6.3.orig/gdb/tui/tui-source.c 2004-02-16 16:05:09.000000000 -0500
++++ gdb-6.3/gdb/tui/tui-source.c 2004-11-09 22:51:07.370237044 -0500
+@@ -326,7 +326,7 @@ tui_vertical_source_scroll (enum tui_scr
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ if (cursal.symtab == (struct symtab *) NULL)
+- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
++ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));
+ else
+ s = cursal.symtab;
+
+Index: gdb-6.3/gdb/tui/tui-winsource.c
+===================================================================
+--- gdb-6.3.orig/gdb/tui/tui-winsource.c 2004-02-16 16:05:09.000000000 -0500
++++ gdb-6.3/gdb/tui/tui-winsource.c 2004-11-09 22:51:07.371236848 -0500
+@@ -311,7 +311,7 @@ tui_horizontal_source_scroll (struct tui
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ if (cursal.symtab == (struct symtab *) NULL)
+- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
++ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));
+ else
+ s = cursal.symtab;
+
+Index: gdb-6.3/gdb/valops.c
+===================================================================
+--- gdb-6.3.orig/gdb/valops.c 2004-09-13 23:01:48.000000000 -0400
++++ gdb-6.3/gdb/valops.c 2004-11-09 22:51:07.374236263 -0500
+@@ -2663,15 +2663,10 @@ value_of_local (const char *name, int co
+ struct block *b;
+ struct value * ret;
+
+- if (deprecated_selected_frame == 0)
+- {
+- if (complain)
+- error ("no frame selected");
+- else
+- return 0;
+- }
++ if (!complain && deprecated_selected_frame == 0)
++ return 0;
+
+- func = get_frame_function (deprecated_selected_frame);
++ func = get_frame_function (get_selected_frame ());
+ if (!func)
+ {
+ if (complain)
+@@ -2700,7 +2695,7 @@ value_of_local (const char *name, int co
+ return NULL;
+ }
+
+- ret = read_var_value (sym, deprecated_selected_frame);
++ ret = read_var_value (sym, get_selected_frame ());
+ if (ret == 0 && complain)
+ error ("`%s' argument unreadable", name);
+ return ret;
+Index: gdb-6.3/gdb/varobj.c
+===================================================================
+--- gdb-6.3.orig/gdb/varobj.c 2004-07-26 10:53:06.000000000 -0400
++++ gdb-6.3/gdb/varobj.c 2004-11-09 22:51:07.377235677 -0500
+@@ -488,7 +488,7 @@ varobj_create (char *objname,
+ if (fi != NULL)
+ {
+ var->root->frame = get_frame_id (fi);
+- old_fi = deprecated_selected_frame;
++ old_fi = get_selected_frame ();
+ select_frame (fi);
+ }
+
+Index: gdb-6.3/gdb/testsuite/gdb.base/default.exp
+===================================================================
+--- gdb-6.3.orig/gdb/testsuite/gdb.base/default.exp 2003-03-20 09:45:50.000000000 -0500
++++ gdb-6.3/gdb/testsuite/gdb.base/default.exp 2004-11-09 22:51:07.379235287 -0500
+@@ -167,7 +167,7 @@ gdb_test "disable breakpoints" "" "disab
+ #test disable display
+ gdb_test "disable display" "" "disable display"
+ #test disassemble
+-gdb_test "disassemble" "No frame selected." "disassemble"
++gdb_test "disassemble" "No (frame selected|registers)." "disassemble"
+ #test display
+ gdb_test "display" "" "display"
+ #test do
+@@ -229,9 +229,9 @@ gdb_expect {
+ }
+
+ #test frame "f" abbreviation
+-gdb_test "f" "No stack." "frame \"f\" abbreviation"
++gdb_test "f" "No (stack|registers)." "frame \"f\" abbreviation"
+ #test frame
+-gdb_test "frame" "No stack." "frame"
++gdb_test "frame" "No (stack|registers)." "frame"
+ #test fg
+ gdb_test "fg" "The program is not being run." "fg"
+ # FIXME: fg kills the udi connection
+@@ -294,9 +294,9 @@ gdb_test "ignore" "Argument required .a
+ #test info address
+ gdb_test "info address" "Argument required." "info address"
+ #test info all-registers
+-gdb_test "info all-registers" "The program has no registers now." "info all-registers"
++gdb_test "info all-registers" "(The program has no registers now|No registers)." "info all-registers"
+ #test info args
+-gdb_test "info args" "No frame selected." "info args"
++gdb_test "info args" "No (frame selected|registers)." "info args"
+ #test info bogus-gdb-command
+ gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\". Try \"help info\".*" "info bogus-gdb-command"
+ #test info breakpoints
+@@ -320,11 +320,11 @@ gdb_test "info frame" "No stack.|No sele
+ #test info files
+ gdb_test "info files" "" "info files"
+ #test info float
+-gdb_test "info float" "The program has no registers now." "info float"
++gdb_test "info float" "(The program has no registers now|No registers)." "info float"
+ #test info functions
+ gdb_test "info functions" "All defined functions:" "info functions"
+ #test info locals
+-gdb_test "info locals" "No frame selected." "info locals"
++gdb_test "info locals" "(No frame selected|No registers)." "info locals"
+ #test info program
+ gdb_test "info program" "The program being debugged is not being run." "info program"
+ #test info registers
+@@ -352,7 +352,7 @@ gdb_test "info types" "All defined types
+ #test info variables
+ gdb_test "info variables" "All defined variables:" "info variables"
+ #test info vector
+-gdb_test "info vector" "The program has no registers now." "info vector"
++gdb_test "info vector" "(The program has no registers now|No registers)." "info vector"
+ #test info warranty
+ gdb_test "info warranty" "NO WARRANTY(\[^\r\n\]*\[\r\n\])+ *11. *BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY(\[^\r\n\]*\[\r\n\])+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN(\[^\r\n\]*\[\r\n\])+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES(\[^\r\n\]*\[\r\n\])+PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED(\[^\r\n\]*\[\r\n\])+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF(\[^\r\n\]*\[\r\n\])+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS(\[^\r\n\]*\[\r\n\])+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE(\[^\r\n\]*\[\r\n\])+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,(\[^\r\n\]*\[\r\n\])+REPAIR OR CORRECTION.(\[^\r\n\]*\[\r\n\])+ *12. *IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING(\[^\r\n\]*\[\r\n\])+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR(\[^\r\n\]*\[\r\n\])+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,(\[^\r\n\]*\[\r\n\])+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING(\[^\r\n\]*\[\r\n\])+OUT OF THE USE OR INABILITY TO USE THE PROGRAM .INCLUDING BUT NOT LIMITED(\[^\r\n\]*\[\r\n\])+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY(\[^\r\n\]*\[\r\n\])+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER(\[^\r\n\]*\[\r\n\])+PROGRAMS., EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE(\[^\r\n\]*\[\r\n\])+POSSIBILITY OF SUCH DAMAGES.*" "info warranty"
+ #test info watchpoints
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/620-debian_static-thread-db.patch b/cleopatre/buildroot/toolchain/gdb/6.3/620-debian_static-thread-db.patch
new file mode 100644
index 0000000000..c5ac5a6237
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/620-debian_static-thread-db.patch
@@ -0,0 +1,156 @@
+Status: submitted similar patch 2004-12-08
+
+This patch cleans up the initialization of thread_db. It works for static
+binaries now. The vsyscall patches hide this problem, since new static
+binaries will load the vsyscall DSO and then trigger thread_db; but
+this is still a good cleanup.
+
+Index: gdb-6.3/gdb/thread-db.c
+===================================================================
+--- gdb-6.3.orig/gdb/thread-db.c 2004-10-08 16:29:56.000000000 -0400
++++ gdb-6.3/gdb/thread-db.c 2004-11-10 00:19:30.626530413 -0500
+@@ -34,6 +34,7 @@
+ #include "target.h"
+ #include "regcache.h"
+ #include "solib-svr4.h"
++#include "observer.h"
+
+ #ifdef HAVE_GNU_LIBC_VERSION_H
+ #include <gnu/libc-version.h>
+@@ -627,59 +628,49 @@ check_thread_signals (void)
+ #endif
+ }
+
++/* Check whether thread_db is usable. This function is called when
++ an inferior is created (or otherwise acquired, e.g. attached to)
++ and when new shared libraries are loaded into a running process. */
++
+ static void
+-thread_db_new_objfile (struct objfile *objfile)
++check_for_thread_db (void)
+ {
+ td_err_e err;
++ static int already_loaded;
+
+ /* First time through, report that libthread_db was successfuly
+ loaded. Can't print this in in thread_db_load as, at that stage,
+- the interpreter and it's console haven't started. The real
+- problem here is that libthread_db is loaded too early - it should
+- only be loaded when there is a program to debug. */
+- {
+- static int dejavu;
+- if (!dejavu)
+- {
+- Dl_info info;
+- const char *library = NULL;
+- /* Try dladdr. */
+- if (dladdr ((*td_ta_new_p), &info) != 0)
+- library = info.dli_fname;
+- /* Try dlinfo? */
+- if (library == NULL)
+- /* Paranoid - don't let a NULL path slip through. */
+- library = LIBTHREAD_DB_SO;
+- printf_unfiltered ("Using host libthread_db library \"%s\".\n",
+- library);
+- dejavu = 1;
+- }
+- }
++ the interpreter and it's console haven't started. */
+
+- /* Don't attempt to use thread_db on targets which can not run
+- (core files). */
+- if (objfile == NULL || !target_has_execution)
++ if (!already_loaded)
+ {
+- /* All symbols have been discarded. If the thread_db target is
+- active, deactivate it now. */
+- if (using_thread_db)
+- {
+- gdb_assert (proc_handle.pid == 0);
+- unpush_target (&thread_db_ops);
+- using_thread_db = 0;
+- }
++ Dl_info info;
++ const char *library = NULL;
++ if (dladdr ((*td_ta_new_p), &info) != 0)
++ library = info.dli_fname;
++
++ /* Try dlinfo? */
+
+- goto quit;
++ if (library == NULL)
++ /* Paranoid - don't let a NULL path slip through. */
++ library = LIBTHREAD_DB_SO;
++
++ printf_unfiltered ("Using host libthread_db library \"%s\".\n",
++ library);
++ already_loaded = 1;
+ }
+
+ if (using_thread_db)
+ /* Nothing to do. The thread library was already detected and the
+ target vector was already activated. */
+- goto quit;
++ return;
++
++ /* Don't attempt to use thread_db on targets which can not run
++ (executables not running yet, core files) for now. */
++ if (!target_has_execution)
++ return;
+
+- /* Initialize the structure that identifies the child process. Note
+- that at this point there is no guarantee that we actually have a
+- child process. */
++ /* Initialize the structure that identifies the child process. */
+ proc_handle.pid = GET_PID (inferior_ptid);
+
+ /* Now attempt to open a connection to the thread library. */
+@@ -706,12 +697,24 @@ thread_db_new_objfile (struct objfile *o
+ thread_db_err_str (err));
+ break;
+ }
++}
++
++static void
++thread_db_new_objfile (struct objfile *objfile)
++{
++ if (objfile != NULL)
++ check_for_thread_db ();
+
+-quit:
+ if (target_new_objfile_chain)
+ target_new_objfile_chain (objfile);
+ }
+
++static void
++check_for_thread_db_observer (struct target_ops *target, int from_tty)
++{
++ check_for_thread_db ();
++}
++
+ /* Attach to a new thread. This function is called when we receive a
+ TD_CREATE event or when we iterate over all threads and find one
+ that wasn't already in our list. */
+@@ -1366,5 +1369,8 @@ _initialize_thread_db (void)
+ /* Add ourselves to objfile event chain. */
+ target_new_objfile_chain = deprecated_target_new_objfile_hook;
+ deprecated_target_new_objfile_hook = thread_db_new_objfile;
++
++ /* Register ourselves for the new inferior observer. */
++ observer_attach_inferior_created (check_for_thread_db_observer);
+ }
+ }
+Index: gdb-6.3/gdb/Makefile.in
+===================================================================
+--- gdb-6.3.orig/gdb/Makefile.in 2004-11-09 23:04:57.000000000 -0500
++++ gdb-6.3/gdb/Makefile.in 2004-11-10 00:19:26.440347022 -0500
+@@ -2626,7 +2626,8 @@ thread.o: thread.c $(defs_h) $(symtab_h)
+ $(gdbcmd_h) $(regcache_h) $(gdb_h) $(gdb_string_h) $(ui_out_h)
+ thread-db.o: thread-db.c $(defs_h) $(gdb_assert_h) $(gdb_proc_service_h) \
+ $(gdb_thread_db_h) $(bfd_h) $(gdbthread_h) $(inferior_h) \
+- $(symfile_h) $(objfiles_h) $(target_h) $(regcache_h) $(solib_svr4_h)
++ $(symfile_h) $(objfiles_h) $(target_h) $(regcache_h) $(solib_svr4_h) \
++ $(observer_h)
+ top.o: top.c $(defs_h) $(gdbcmd_h) $(call_cmds_h) $(cli_cmds_h) \
+ $(cli_script_h) $(cli_setshow_h) $(cli_decode_h) $(symtab_h) \
+ $(inferior_h) $(target_h) $(breakpoint_h) $(gdbtypes_h) \
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/630-debian_24.tracepoint-segv.patch b/cleopatre/buildroot/toolchain/gdb/6.3/630-debian_24.tracepoint-segv.patch
new file mode 100644
index 0000000000..d038ff8ecc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/630-debian_24.tracepoint-segv.patch
@@ -0,0 +1,15 @@
+Trivial. Still need to submit this.
+
+Index: gdb-6.1/gdb/tracepoint.c
+===================================================================
+--- gdb-6.1.orig/gdb/tracepoint.c 2004-04-05 13:26:43.000000000 -0400
++++ gdb-6.1/gdb/tracepoint.c 2004-04-05 13:26:45.000000000 -0400
+@@ -853,6 +853,8 @@ read_actions (struct tracepoint *t)
+ else
+ line = gdb_readline (0);
+
++ if (line == NULL || *line == EOF)
++ break;
+ linetype = validate_actionline (&line, t);
+ if (linetype == BADLINE)
+ continue; /* already warned -- collect another line */
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/640-debian_dwarf2-frame-signal-unwinder.patch b/cleopatre/buildroot/toolchain/gdb/6.3/640-debian_dwarf2-frame-signal-unwinder.patch
new file mode 100644
index 0000000000..246427ee6f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/640-debian_dwarf2-frame-signal-unwinder.patch
@@ -0,0 +1,120 @@
+Status: Checked in to HEAD after 6.3.
+
+2004-11-07 Daniel Jacobowitz <dan@debian.org>
+
+ * dwarf2-frame.c (struct dwarf2_frame_ops): Add signal_frame_p.
+ (dwarf2_frame_set_signal_frame_p, dwarf2_frame_signal_frame_p)
+ (dwarf2_signal_frame_unwind): New.
+ (dwarf2_frame_sniffer): Use dwarf2_frame_signal_frame_p.
+ * dwarf2-frame.h (dwarf2_frame_set_signal_frame_p): New prototype.
+
+Index: src/gdb/dwarf2-frame.c
+===================================================================
+RCS file: /big/fsf/rsync/src-cvs/src/gdb/dwarf2-frame.c,v
+retrieving revision 1.41
+diff -u -p -r1.41 dwarf2-frame.c
+--- src/gdb/dwarf2-frame.c 4 Nov 2004 21:15:15 -0000 1.41
++++ src/gdb/dwarf2-frame.c 7 Nov 2004 17:41:58 -0000
+@@ -471,6 +471,10 @@ struct dwarf2_frame_ops
+ {
+ /* Pre-initialize the register state REG for register REGNUM. */
+ void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *);
++
++ /* Check whether the frame preceding NEXT_FRAME will be a signal
++ trampoline. */
++ int (*signal_frame_p) (struct gdbarch *, struct frame_info *);
+ };
+
+ /* Default architecture-specific register state initialization
+@@ -547,6 +551,33 @@ dwarf2_frame_init_reg (struct gdbarch *g
+
+ ops->init_reg (gdbarch, regnum, reg);
+ }
++
++/* Set the architecture-specific signal trampoline recognition
++ function for GDBARCH to SIGNAL_FRAME_P. */
++
++void
++dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
++ int (*signal_frame_p) (struct gdbarch *,
++ struct frame_info *))
++{
++ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
++
++ ops->signal_frame_p = signal_frame_p;
++}
++
++/* Query the architecture-specific signal frame recognizer for
++ NEXT_FRAME. */
++
++static int
++dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
++ struct frame_info *next_frame)
++{
++ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
++
++ if (ops->signal_frame_p == NULL)
++ return 0;
++ return ops->signal_frame_p (gdbarch, next_frame);
++}
+
+
+ struct dwarf2_frame_cache
+@@ -841,6 +872,13 @@ static const struct frame_unwind dwarf2_
+ dwarf2_frame_prev_register
+ };
+
++static const struct frame_unwind dwarf2_signal_frame_unwind =
++{
++ SIGTRAMP_FRAME,
++ dwarf2_frame_this_id,
++ dwarf2_frame_prev_register
++};
++
+ const struct frame_unwind *
+ dwarf2_frame_sniffer (struct frame_info *next_frame)
+ {
+@@ -848,10 +886,18 @@ dwarf2_frame_sniffer (struct frame_info
+ function. frame_pc_unwind(), for a no-return next function, can
+ end up returning something past the end of this function's body. */
+ CORE_ADDR block_addr = frame_unwind_address_in_block (next_frame);
+- if (dwarf2_frame_find_fde (&block_addr))
+- return &dwarf2_frame_unwind;
++ if (!dwarf2_frame_find_fde (&block_addr))
++ return NULL;
+
+- return NULL;
++ /* On some targets, signal trampolines may have unwind information.
++ We need to recognize them so that we set the frame type
++ correctly. */
++
++ if (dwarf2_frame_signal_frame_p (get_frame_arch (next_frame),
++ next_frame))
++ return &dwarf2_signal_frame_unwind;
++
++ return &dwarf2_frame_unwind;
+ }
+
+
+Index: src/gdb/dwarf2-frame.h
+===================================================================
+RCS file: /big/fsf/rsync/src-cvs/src/gdb/dwarf2-frame.h,v
+retrieving revision 1.6
+diff -u -p -r1.6 dwarf2-frame.h
+--- src/gdb/dwarf2-frame.h 28 Feb 2004 16:59:32 -0000 1.6
++++ src/gdb/dwarf2-frame.h 7 Nov 2004 17:40:41 -0000
+@@ -79,6 +79,14 @@ extern void dwarf2_frame_set_init_reg (s
+ void (*init_reg) (struct gdbarch *, int,
+ struct dwarf2_frame_state_reg *));
+
++/* Set the architecture-specific signal trampoline recognition
++ function for GDBARCH to SIGNAL_FRAME_P. */
++
++extern void
++ dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
++ int (*signal_frame_p) (struct gdbarch *,
++ struct frame_info *));
++
+ /* Return the frame unwind methods for the function that contains PC,
+ or NULL if it can't be handled by DWARF CFI frame unwinder. */
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/650-debian_vsyscall-gdb-support.patch b/cleopatre/buildroot/toolchain/gdb/6.3/650-debian_vsyscall-gdb-support.patch
new file mode 100644
index 0000000000..e725f9c549
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/650-debian_vsyscall-gdb-support.patch
@@ -0,0 +1,245 @@
+Status: Checked in to HEAD after 6.3.
+
+2004-11-07 Andrew Cagney <cagney@redhat.com>
+ Daniel Jacobowitz <dan@debian.org>
+ Roland McGrath <roland@redhat.com>
+
+ * Makefile.in (symfile-mem.o): Update dependencies.
+ * i386-linux-tdep.c (i386_linux_dwarf_signal_frame_p): New.
+ (i386_linux_init_abi): Call dwarf2_frame_set_signal_frame_p.
+ * inf-ptrace.c (inf_ptrace_attach): Call
+ observer_notify_inferior_created.
+ * inftarg.c (child_attach): Likewise.
+ * symfile-mem.c: Include "observer.h", "auxv.h", and "elf/common.h".
+ (symbol_file_add_from_memory): Take NAME argument. Use it for
+ the new BFD's filename.
+ (add_symbol_file_from_memory_command): Update call to
+ symbol_file_add_from_memory.
+ (struct symbol_file_add_from_memory_args, add_vsyscall_page)
+ (symbol_file_add_from_memory_wrapper): New.
+ (_initialize_symfile_mem): Register add_vsyscall_page as an
+ inferior_created observer.
+
+Index: gdb-6.3/gdb/i386-linux-tdep.c
+===================================================================
+--- gdb-6.3.orig/gdb/i386-linux-tdep.c 2004-08-06 16:58:28.000000000 -0400
++++ gdb-6.3/gdb/i386-linux-tdep.c 2004-11-10 00:55:06.669398770 -0500
+@@ -27,6 +27,7 @@
+ #include "inferior.h"
+ #include "osabi.h"
+ #include "reggroups.h"
++#include "dwarf2-frame.h"
+
+ #include "gdb_string.h"
+
+@@ -244,6 +245,27 @@ i386_linux_sigtramp_p (struct frame_info
+ || strcmp ("__restore_rt", name) == 0);
+ }
+
++/* Return one if the unwound PC from NEXT_FRAME is in a signal trampoline
++ which may have DWARF-2 CFI. */
++
++static int
++i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
++ struct frame_info *next_frame)
++{
++ CORE_ADDR pc = frame_pc_unwind (next_frame);
++ char *name;
++
++ find_pc_partial_function (pc, &name, NULL, NULL);
++
++ /* If a vsyscall DSO is in use, the signal trampolines may have these
++ names. */
++ if (name && (strcmp (name, "__kernel_sigreturn") == 0
++ || strcmp (name, "__kernel_rt_sigreturn") == 0))
++ return 1;
++
++ return 0;
++}
++
+ /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
+ #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
+
+@@ -414,6 +436,8 @@ i386_linux_init_abi (struct gdbarch_info
+
+ /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
+ set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
++
++ dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
+ }
+
+ /* Provide a prototype to silence -Wmissing-prototypes. */
+Index: gdb-6.3/gdb/inf-ptrace.c
+===================================================================
+--- gdb-6.3.orig/gdb/inf-ptrace.c 2004-10-15 09:29:33.000000000 -0400
++++ gdb-6.3/gdb/inf-ptrace.c 2004-11-10 00:53:43.697615843 -0500
+@@ -220,6 +220,10 @@ inf_ptrace_attach (char *args, int from_
+
+ inferior_ptid = pid_to_ptid (pid);
+ push_target (ptrace_ops_hack);
++
++ /* Do this first, before anything has had a chance to query the
++ inferior's symbol table or similar. */
++ observer_notify_inferior_created (&current_target, from_tty);
+ }
+
+ static void
+Index: gdb-6.3/gdb/inftarg.c
+===================================================================
+--- gdb-6.3.orig/gdb/inftarg.c 2004-10-08 16:29:47.000000000 -0400
++++ gdb-6.3/gdb/inftarg.c 2004-11-10 00:53:43.711613107 -0500
+@@ -211,6 +211,10 @@ child_attach (char *args, int from_tty)
+
+ inferior_ptid = pid_to_ptid (pid);
+ push_target (&deprecated_child_ops);
++
++ /* Do this first, before anything has had a chance to query the
++ inferior's symbol table or similar. */
++ observer_notify_inferior_created (&current_target, from_tty);
+ }
+
+ #if !defined(CHILD_POST_ATTACH)
+Index: gdb-6.3/gdb/symfile-mem.c
+===================================================================
+--- gdb-6.3.orig/gdb/symfile-mem.c 2004-07-17 10:24:07.000000000 -0400
++++ gdb-6.3/gdb/symfile-mem.c 2004-11-10 00:53:43.722610958 -0500
+@@ -52,13 +52,19 @@
+ #include "target.h"
+ #include "value.h"
+ #include "symfile.h"
++#include "observer.h"
++#include "auxv.h"
++#include "elf/common.h"
+
+
+ /* Read inferior memory at ADDR to find the header of a loaded object file
+ and read its in-core symbols out of inferior memory. TEMPL is a bfd
+- representing the target's format. */
++ representing the target's format. NAME is the name to use for this
++ symbol file in messages; it can be NULL or a malloc-allocated string
++ which will be attached to the BFD. */
+ static struct objfile *
+-symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, int from_tty)
++symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
++ int from_tty)
+ {
+ struct objfile *objf;
+ struct bfd *nbfd;
+@@ -75,7 +81,10 @@ symbol_file_add_from_memory (struct bfd
+ if (nbfd == NULL)
+ error ("Failed to read a valid object file image from memory.");
+
+- nbfd->filename = xstrdup ("shared object read from target memory");
++ if (name == NULL)
++ nbfd->filename = xstrdup ("shared object read from target memory");
++ else
++ nbfd->filename = name;
+
+ if (!bfd_check_format (nbfd, bfd_object))
+ {
+@@ -129,7 +138,73 @@ add_symbol_file_from_memory_command (cha
+ error ("\
+ Must use symbol-file or exec-file before add-symbol-file-from-memory.");
+
+- symbol_file_add_from_memory (templ, addr, from_tty);
++ symbol_file_add_from_memory (templ, addr, NULL, from_tty);
++}
++
++/* Arguments for symbol_file_add_from_memory_wrapper. */
++
++struct symbol_file_add_from_memory_args
++{
++ struct bfd *bfd;
++ CORE_ADDR sysinfo_ehdr;
++ char *name;
++ int from_tty;
++};
++
++/* Wrapper function for symbol_file_add_from_memory, for
++ catch_exceptions. */
++
++static int
++symbol_file_add_from_memory_wrapper (struct ui_out *uiout, void *data)
++{
++ struct symbol_file_add_from_memory_args *args = data;
++
++ symbol_file_add_from_memory (args->bfd, args->sysinfo_ehdr, args->name,
++ args->from_tty);
++ return 0;
++}
++
++/* Try to add the symbols for the vsyscall page, if there is one. This function
++ is called via the inferior_created observer. */
++
++static void
++add_vsyscall_page (struct target_ops *target, int from_tty)
++{
++ CORE_ADDR sysinfo_ehdr;
++
++ if (target_auxv_search (target, AT_SYSINFO_EHDR, &sysinfo_ehdr) > 0
++ && sysinfo_ehdr != (CORE_ADDR) 0)
++ {
++ struct bfd *bfd;
++ struct symbol_file_add_from_memory_args args;
++
++ if (core_bfd != NULL)
++ bfd = core_bfd;
++ else if (exec_bfd != NULL)
++ bfd = exec_bfd;
++ else
++ /* FIXME: cagney/2004-05-06: Should not require an existing
++ BFD when trying to create a run-time BFD of the VSYSCALL
++ page in the inferior. Unfortunately that's the current
++ interface so for the moment bail. Introducing a
++ ``bfd_runtime'' (a BFD created using the loaded image) file
++ format should fix this. */
++ {
++ warning ("could not load vsyscall page because no executable was specified");
++ warning ("try using the \"file\" command first");
++ return;
++ }
++ args.bfd = bfd;
++ args.sysinfo_ehdr = sysinfo_ehdr;
++ xasprintf (&args.name, "system-supplied DSO at 0x%s",
++ paddr_nz (sysinfo_ehdr));
++ /* Pass zero for FROM_TTY, because the action of loading the
++ vsyscall DSO was not triggered by the user, even if the user
++ typed "run" at the TTY. */
++ args.from_tty = 0;
++ catch_exceptions (uiout, symbol_file_add_from_memory_wrapper,
++ &args, NULL, RETURN_MASK_ALL);
++ }
+ }
+
+
+@@ -143,4 +218,7 @@ Load the symbols out of memory from a dy
+ Give an expression for the address of the file's shared object file header.",
+ &cmdlist);
+
++ /* Want to know of each new inferior so that its vsyscall info can
++ be extracted. */
++ observer_attach_inferior_created (add_vsyscall_page);
+ }
+Index: gdb-6.3/gdb/Makefile.in
+===================================================================
+--- gdb-6.3.orig/gdb/Makefile.in 2004-11-10 00:29:00.000000000 -0500
++++ gdb-6.3/gdb/Makefile.in 2004-11-10 00:54:47.728100986 -0500
+@@ -2020,7 +2020,7 @@ i386-linux-nat.o: i386-linux-nat.c $(def
+ i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
+ $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
+ $(gdb_string_h) $(i386_tdep_h) $(i386_linux_tdep_h) $(glibc_tdep_h) \
+- $(solib_svr4_h)
++ $(solib_svr4_h) $(dwarf2_frame_h)
+ i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
+ $(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
+ i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
+@@ -2606,7 +2606,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
+ $(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
+ $(gdb_string_h) $(gdb_stat_h)
+ symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
+- $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
++ $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h) \
++ $(observer_h) $(auxv_h) $(elf_common_h)
+ symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
+ $(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
+ $(gdb_obstack_h) $(language_h) $(bcache_h) $(block_h) $(gdb_regex_h) \
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/660-debian_dwarf-cfa-restore.patch b/cleopatre/buildroot/toolchain/gdb/6.3/660-debian_dwarf-cfa-restore.patch
new file mode 100644
index 0000000000..8b81cca710
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/660-debian_dwarf-cfa-restore.patch
@@ -0,0 +1,23 @@
+Status: Checked in to HEAD after 6.3.
+
+2004-11-09 Daniel Jacobowitz <dan@debian.org>
+
+ * dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Correct allocated
+ size.
+
+Index: src/gdb/dwarf2-frame.c
+===================================================================
+RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
+retrieving revision 1.45
+diff -u -p -r1.45 dwarf2-frame.c
+--- src/gdb/dwarf2-frame.c 7 Nov 2004 21:16:11 -0000 1.45
++++ src/gdb/dwarf2-frame.c 9 Nov 2004 14:42:52 -0000
+@@ -162,7 +162,7 @@ dwarf2_frame_state_alloc_regs (struct dw
+ static struct dwarf2_frame_state_reg *
+ dwarf2_frame_state_copy_regs (struct dwarf2_frame_state_reg_info *rs)
+ {
+- size_t size = rs->num_regs * sizeof (struct dwarf2_frame_state_reg_info);
++ size_t size = rs->num_regs * sizeof (struct dwarf2_frame_state_reg);
+ struct dwarf2_frame_state_reg *reg;
+
+ reg = (struct dwarf2_frame_state_reg *) xmalloc (size);
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/680-debian_sim-destdir.patch b/cleopatre/buildroot/toolchain/gdb/6.3/680-debian_sim-destdir.patch
new file mode 100644
index 0000000000..71f60b5c67
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/680-debian_sim-destdir.patch
@@ -0,0 +1,53 @@
+Fix some missing uses of DESTDIR in the sim/ directories. The Debian
+packages use DESTDIR to build.
+
+%patch
+Index: gdb-6.3/sim/Makefile.in
+===================================================================
+--- gdb-6.3.orig/sim/Makefile.in 2003-09-03 14:46:52.000000000 -0400
++++ gdb-6.3/sim/Makefile.in 2004-11-10 00:39:25.381315738 -0500
+@@ -93,6 +93,7 @@ FLAGS_TO_PASS = \
+ "CC=$(CC)" \
+ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
+ "CFLAGS=$(CFLAGS)" \
++ "DESTDIR=$(DESTDIR)" \
+ "RANLIB=$(RANLIB)" \
+ "MAKEINFO=$(MAKEINFO)" \
+ "INSTALL=$(INSTALL)" \
+Index: gdb-6.3/sim/common/Make-common.in
+===================================================================
+--- gdb-6.3.orig/sim/common/Make-common.in 2003-09-08 13:24:59.000000000 -0400
++++ gdb-6.3/sim/common/Make-common.in 2004-11-10 00:39:25.383315347 -0500
+@@ -581,14 +581,14 @@ install: install-common $(SIM_EXTRA_INST
+
+ install-common: installdirs
+ n=`echo run | sed '$(program_transform_name)'`; \
+- $(INSTALL_PROGRAM) run$(EXEEXT) $(bindir)/$$n$(EXEEXT)
++ $(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
+ n=`echo libsim.a | sed s/libsim.a/lib$(target_alias)-sim.a/`; \
+- $(INSTALL_DATA) libsim.a $(libdir)/$$n ; \
+- ( cd $(libdir) ; $(RANLIB) $$n )
++ $(INSTALL_DATA) libsim.a $(DESTDIR)$(libdir)/$$n ; \
++ ( cd $(DESTDIR)$(libdir) ; $(RANLIB) $$n )
+
+ installdirs:
+- $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
+- $(SHELL) $(srcdir)/../../mkinstalldirs $(libdir)
++ $(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir)
++ $(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(libdir)
+
+ check:
+ cd ../testsuite && $(MAKE) check RUNTESTFLAGS="$(RUNTESTFLAGS)"
+Index: gdb-6.3/sim/erc32/Makefile.in
+===================================================================
+--- gdb-6.3.orig/sim/erc32/Makefile.in 2000-03-07 10:32:49.000000000 -0500
++++ gdb-6.3/sim/erc32/Makefile.in 2004-11-10 00:39:25.385314957 -0500
+@@ -53,7 +53,7 @@ end.h: end
+ # Copy the files into directories where they will be run.
+ install-sis: installdirs
+ n=`echo sis | sed '$(program_transform_name)'`; \
+- $(INSTALL_PROGRAM) sis$(EXEEXT) $(bindir)/$$n$(EXEEXT)
++ $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
+
+ clean-sis:
+ rm -f sis end end.h
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/690-debian_member-field-symtab.patch b/cleopatre/buildroot/toolchain/gdb/6.3/690-debian_member-field-symtab.patch
new file mode 100644
index 0000000000..4f5fb45c33
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/690-debian_member-field-symtab.patch
@@ -0,0 +1,35 @@
+Status: unsubmitted
+
+This patch was for Debian bug #239535. It needs to be tested, and
+submitted.
+
+Index: gdb-6.3/gdb/valops.c
+===================================================================
+--- gdb-6.3.orig/gdb/valops.c 2004-11-09 22:51:07.000000000 -0500
++++ gdb-6.3/gdb/valops.c 2004-11-10 00:43:54.036837699 -0500
+@@ -2314,8 +2314,10 @@ check_field_in (struct type *type, const
+ return 1;
+ }
+
++ /* Check each baseclass. Call check_typedef, which will follow typedefs
++ and do opaque/stub type resolution. */
+ for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
+- if (check_field_in (TYPE_BASECLASS (type, i), name))
++ if (check_field_in (check_typedef (TYPE_BASECLASS (type, i)), name))
+ return 1;
+
+ return 0;
+Index: gdb-6.3/gdb/dwarf2read.c
+===================================================================
+--- gdb-6.3.orig/gdb/dwarf2read.c 2004-10-15 20:41:00.000000000 -0400
++++ gdb-6.3/gdb/dwarf2read.c 2004-11-10 00:46:21.970935829 -0500
+@@ -2099,8 +2099,8 @@ guess_structure_name (struct partial_die
+ strlen (actual_class_name),
+ &cu->comp_unit_obstack);
+ xfree (actual_class_name);
++ break;
+ }
+- break;
+ }
+
+ child_pdi = child_pdi->die_sibling;
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/700-debian_cp-pass-by-reference.patch b/cleopatre/buildroot/toolchain/gdb/6.3/700-debian_cp-pass-by-reference.patch
new file mode 100644
index 0000000000..666d343429
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/700-debian_cp-pass-by-reference.patch
@@ -0,0 +1,464 @@
+This patch needs to be submitted for the FSF. Also, there may be testcases
+already in the GDB testsuite (currently disabled) that it would probably fix.
+
+Index: gdb-6.3/gdb/infcall.c
+===================================================================
+--- gdb-6.3.orig/gdb/infcall.c 2004-10-08 04:15:56.000000000 -0400
++++ gdb-6.3/gdb/infcall.c 2004-11-10 12:30:07.000000000 -0500
+@@ -36,6 +36,7 @@
+ #include "gdb_string.h"
+ #include "infcall.h"
+ #include "dummy-frame.h"
++#include "cp-abi.h"
+
+ /* NOTE: cagney/2003-04-16: What's the future of this code?
+
+@@ -297,8 +298,8 @@ call_function_by_hand (struct value *fun
+ {
+ CORE_ADDR sp;
+ CORE_ADDR dummy_addr;
+- struct type *value_type;
+- unsigned char struct_return;
++ struct type *value_type, *target_value_type;
++ unsigned char struct_return = 0, cp_struct_return = 0;
+ CORE_ADDR struct_addr = 0;
+ struct regcache *retbuf;
+ struct cleanup *retbuf_cleanup;
+@@ -312,6 +313,7 @@ call_function_by_hand (struct value *fun
+ struct regcache *caller_regcache;
+ struct cleanup *caller_regcache_cleanup;
+ struct frame_id dummy_id;
++ struct cleanup *args_cleanup;
+
+ if (!target_has_execution)
+ noprocess ();
+@@ -410,10 +412,31 @@ call_function_by_hand (struct value *fun
+ using_gcc = (b == NULL ? 2 : BLOCK_GCC_COMPILED (b));
+ }
+
+- /* Are we returning a value using a structure return or a normal
+- value return? */
++ /* Are we returning a value using a structure return (passing a
++ hidden argument pointing to storage) or a normal value return?
++ There are two cases: C++ ABI mandated structure return and
++ target ABI structure return. The variable STRUCT_RETURN only
++ describes the latter. The C++ version is handled by passing
++ the return location as the first parameter to the function,
++ even preceding "this". This is different from the target
++ ABI version, which is target-specific; for instance, on ia64
++ the first argument is passed in out0 but the hidden structure
++ return pointer would normally be passed in r8. */
+
+- struct_return = using_struct_return (value_type, using_gcc);
++ if (current_language->la_language == language_cplus
++ && cp_pass_by_reference (value_type))
++ {
++ cp_struct_return = 1;
++
++ /* Tell the target specific argument pushing routine not to
++ expect a value. */
++ target_value_type = builtin_type_void;
++ }
++ else
++ {
++ struct_return = using_struct_return (value_type, using_gcc);
++ target_value_type = value_type;
++ }
+
+ /* Determine the location of the breakpoint (and possibly other
+ stuff) that the called function will return to. The SPARC, for a
+@@ -432,7 +455,7 @@ call_function_by_hand (struct value *fun
+ if (INNER_THAN (1, 2))
+ {
+ sp = push_dummy_code (current_gdbarch, sp, funaddr,
+- using_gcc, args, nargs, value_type,
++ using_gcc, args, nargs, target_value_type,
+ &real_pc, &bp_addr);
+ dummy_addr = sp;
+ }
+@@ -440,7 +463,7 @@ call_function_by_hand (struct value *fun
+ {
+ dummy_addr = sp;
+ sp = push_dummy_code (current_gdbarch, sp, funaddr,
+- using_gcc, args, nargs, value_type,
++ using_gcc, args, nargs, target_value_type,
+ &real_pc, &bp_addr);
+ }
+ break;
+@@ -507,9 +530,15 @@ call_function_by_hand (struct value *fun
+ param_type = TYPE_FIELD_TYPE (ftype, i);
+ else
+ param_type = NULL;
+-
++
+ args[i] = value_arg_coerce (args[i], param_type, prototyped);
+
++ /* FIXME: Is current_language the right language? */
++ if (current_language->la_language == language_cplus
++ && param_type != NULL
++ && cp_pass_by_reference (param_type))
++ args[i] = value_addr (args[i]);
++
+ /* elz: this code is to handle the case in which the function
+ to be called has a pointer to function as parameter and the
+ corresponding actual argument is the address of a function
+@@ -607,7 +636,7 @@ You must use a pointer to function type
+ stack, if necessary. Make certain that the value is correctly
+ aligned. */
+
+- if (struct_return)
++ if (struct_return || cp_struct_return)
+ {
+ int len = TYPE_LENGTH (value_type);
+ if (INNER_THAN (1, 2))
+@@ -632,6 +661,22 @@ You must use a pointer to function type
+ }
+ }
+
++ if (cp_struct_return)
++ {
++ struct value **new_args;
++
++ /* Add the new argument to the front of the argument list. */
++ new_args = xmalloc (sizeof (struct value *) * (nargs + 1));
++ new_args[0] = value_from_pointer (lookup_pointer_type (value_type),
++ struct_addr);
++ memcpy (&new_args[1], &args[0], sizeof (struct value *) * nargs);
++ args = new_args;
++ nargs++;
++ args_cleanup = make_cleanup (xfree, args);
++ }
++ else
++ args_cleanup = make_cleanup (null_cleanup, NULL);
++
+ /* Create the dummy stack frame. Pass in the call dummy address as,
+ presumably, the ABI code knows where, in the call dummy, the
+ return address should be pointed. */
+@@ -649,6 +694,8 @@ You must use a pointer to function type
+ else
+ error ("This target does not support function calls");
+
++ do_cleanups (args_cleanup);
++
+ /* Set up a frame ID for the dummy frame so we can pass it to
+ set_momentary_breakpoint. We need to give the breakpoint a frame
+ ID so that the breakpoint code can correctly re-identify the
+@@ -839,11 +886,7 @@ the function call).", name);
+ /* Figure out the value returned by the function, return that. */
+ {
+ struct value *retval;
+- if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
+- /* If the function returns void, don't bother fetching the
+- return value. */
+- retval = allocate_value (value_type);
+- else if (struct_return)
++ if (struct_return || cp_struct_return)
+ /* NOTE: cagney/2003-09-27: This assumes that PUSH_DUMMY_CALL
+ has correctly stored STRUCT_ADDR in the target. In the past
+ that hasn't been the case, the old MIPS PUSH_ARGUMENTS
+@@ -853,6 +896,10 @@ the function call).", name);
+ "struct return convention", check that PUSH_DUMMY_CALL isn't
+ playing tricks. */
+ retval = value_at (value_type, struct_addr, NULL);
++ else if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
++ /* If the function returns void, don't bother fetching the
++ return value. */
++ retval = allocate_value (value_type);
+ else
+ {
+ /* This code only handles "register convention". */
+Index: gdb-6.3/gdb/cp-abi.h
+===================================================================
+--- gdb-6.3.orig/gdb/cp-abi.h 2003-04-12 13:41:25.000000000 -0400
++++ gdb-6.3/gdb/cp-abi.h 2004-11-10 12:30:07.000000000 -0500
+@@ -1,7 +1,7 @@
+ /* Abstraction of various C++ ABI's we support, and the info we need
+ to get from them.
+ Contributed by Daniel Berlin <dberlin@redhat.com>
+- Copyright 2001 Free Software Foundation, Inc.
++ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+@@ -145,6 +145,10 @@ extern struct type *value_rtti_type (str
+ extern int baseclass_offset (struct type *type, int index, char *valaddr,
+ CORE_ADDR address);
+
++/* Return non-zero if an argument of type TYPE should be passed by reference
++ instead of value. */
++extern int cp_pass_by_reference (struct type *type);
++
+ struct cp_abi_ops
+ {
+ const char *shortname;
+@@ -162,6 +166,7 @@ struct cp_abi_ops
+ int *using_enc);
+ int (*baseclass_offset) (struct type *type, int index, char *valaddr,
+ CORE_ADDR address);
++ int (*pass_by_reference) (struct type *type);
+ };
+
+
+Index: gdb-6.3/gdb/cp-abi.c
+===================================================================
+--- gdb-6.3.orig/gdb/cp-abi.c 2003-11-26 17:04:00.000000000 -0500
++++ gdb-6.3/gdb/cp-abi.c 2004-11-10 12:30:07.000000000 -0500
+@@ -1,5 +1,5 @@
+ /* Generic code for supporting multiple C++ ABI's
+- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
++ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+@@ -94,6 +94,14 @@ value_rtti_type (struct value *v, int *f
+ return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
+ }
+
++int
++cp_pass_by_reference (struct type *type)
++{
++ if ((current_cp_abi.pass_by_reference) == NULL)
++ return 0;
++ return (*current_cp_abi.pass_by_reference) (type);
++}
++
+ /* Set the current C++ ABI to SHORT_NAME. */
+
+ static int
+Index: gdb-6.3/gdb/gnu-v3-abi.c
+===================================================================
+--- gdb-6.3.orig/gdb/gnu-v3-abi.c 2004-03-15 15:38:08.000000000 -0500
++++ gdb-6.3/gdb/gnu-v3-abi.c 2004-11-10 12:30:07.000000000 -0500
+@@ -1,7 +1,7 @@
+ /* Abstraction of GNU v3 abi.
+ Contributed by Jim Blandy <jimb@redhat.com>
+
+- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
++ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+@@ -419,6 +419,84 @@ gnuv3_baseclass_offset (struct type *typ
+ return base_offset;
+ }
+
++/* Return nonzero if a type should be passed by reference.
++
++ The rule in the v3 ABI document comes from section 3.1.1. If the
++ type has a non-trivial copy constructor or destructor, then the
++ caller must make a copy (by calling the copy constructor if there
++ is one or perform the copy itself otherwise), pass the address of
++ the copy, and then destroy the temporary (if necessary).
++
++ For return values with non-trivial copy constructors or
++ destructors, space will be allocated in the caller, and a pointer
++ will be passed as the first argument (preceding "this").
++
++ We don't have a bulletproof mechanism for determining whether a
++ constructor or destructor is trivial. For GCC and DWARF2 debug
++ information, we can check the artificial flag.
++
++ We don't do anything with the constructors or destructors yet,
++ but we have to get the argument passing right anyway. */
++static int
++gnuv3_pass_by_reference (struct type *type)
++{
++ int fieldnum, fieldelem, basenum;
++
++ CHECK_TYPEDEF (type);
++
++ /* We're only interested in things that can have methods. */
++ if (TYPE_CODE (type) != TYPE_CODE_STRUCT
++ && TYPE_CODE (type) != TYPE_CODE_CLASS
++ && TYPE_CODE (type) != TYPE_CODE_UNION)
++ return 0;
++
++ for (fieldnum = 0; fieldnum < TYPE_NFN_FIELDS (type); fieldnum++)
++ for (fieldelem = 0; fieldelem < TYPE_FN_FIELDLIST_LENGTH (type, fieldnum);
++ fieldelem++)
++ {
++ struct fn_field *fn = TYPE_FN_FIELDLIST1 (type, fieldnum);
++ char *name = TYPE_FN_FIELDLIST_NAME (type, fieldnum);
++ struct type *fieldtype = TYPE_FN_FIELD_TYPE (fn, fieldelem);
++
++ /* If this function is marked as artificial, it is compiler-generated,
++ and we assume it is trivial. */
++ if (TYPE_FN_FIELD_ARTIFICIAL (fn, fieldelem))
++ continue;
++
++ /* If we've found a destructor, we must pass this by reference. */
++ if (name[0] == '~')
++ return 1;
++
++ /* If the mangled name of this method doesn't indicate that it
++ is a constructor, we're not interested.
++
++ FIXME drow/2004-05-27: We could do this using the name of
++ the method and the name of the class instead of dealing
++ with the mangled name. We don't have a convenient function
++ to strip off both leading scope qualifiers and trailing
++ template arguments yet. */
++ if (!is_constructor_name (TYPE_FN_FIELD_PHYSNAME (fn, fieldelem)))
++ continue;
++
++ /* If this method takes two arguments, and the second argument is
++ a reference to this class, then it is a copy constructor. */
++ if (TYPE_NFIELDS (fieldtype) == 2
++ && TYPE_CODE (TYPE_FIELD_TYPE (fieldtype, 1)) == TYPE_CODE_REF
++ && check_typedef (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (fieldtype, 1))) == type)
++ return 1;
++ }
++
++ /* Even if all the constructors and destructors were artificial, one
++ of them may have invoked a non-artificial constructor or
++ destructor in a base class. If any base class needs to be passed
++ by reference, so does this class. */
++ for (basenum = 0; basenum < TYPE_N_BASECLASSES (type); basenum++)
++ if (gnuv3_pass_by_reference (TYPE_BASECLASS (type, basenum)))
++ return 1;
++
++ return 0;
++}
++
+ static void
+ init_gnuv3_ops (void)
+ {
+@@ -434,6 +512,7 @@ init_gnuv3_ops (void)
+ gnu_v3_abi_ops.rtti_type = gnuv3_rtti_type;
+ gnu_v3_abi_ops.virtual_fn_field = gnuv3_virtual_fn_field;
+ gnu_v3_abi_ops.baseclass_offset = gnuv3_baseclass_offset;
++ gnu_v3_abi_ops.pass_by_reference = gnuv3_pass_by_reference;
+ }
+
+ extern initialize_file_ftype _initialize_gnu_v3_abi; /* -Wmissing-prototypes */
+Index: gdb-6.3/gdb/hpacc-abi.c
+===================================================================
+--- gdb-6.3.orig/gdb/hpacc-abi.c 2003-06-08 14:27:13.000000000 -0400
++++ gdb-6.3/gdb/hpacc-abi.c 2004-11-10 12:30:07.000000000 -0500
+@@ -3,7 +3,7 @@
+ Most of the real code is from HP, i've just fiddled it to fit in
+ the C++ ABI abstraction framework.
+
+- Copyright 2001 Free Software Foundation, Inc.
++ Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+Index: gdb-6.3/gdb/Makefile.in
+===================================================================
+--- gdb-6.3.orig/gdb/Makefile.in 2004-11-10 12:30:06.000000000 -0500
++++ gdb-6.3/gdb/Makefile.in 2004-11-10 12:30:07.000000000 -0500
+@@ -2073,7 +2073,7 @@ ia64-tdep.o: ia64-tdep.c $(defs_h) $(inf
+ infcall.o: infcall.c $(defs_h) $(breakpoint_h) $(target_h) $(regcache_h) \
+ $(inferior_h) $(gdb_assert_h) $(block_h) $(gdbcore_h) $(language_h) \
+ $(objfiles_h) $(gdbcmd_h) $(command_h) $(gdb_string_h) $(infcall_h) \
+- $(dummy_frame_h)
++ $(dummy_frame_h) $(cp_abi_h)
+ inf-child.o: inf-child.c $(defs_h) $(regcache_h) $(memattr_h) $(symtab_h) \
+ $(target_h) $(inferior_h) $(gdb_string_h)
+ infcmd.o: infcmd.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
+Index: gdb-6.3/gdb/testsuite/gdb.cp/pass-by-ref.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.3/gdb/testsuite/gdb.cp/pass-by-ref.exp 2004-11-11 09:48:00.498518899 -0500
+@@ -0,0 +1,38 @@
++# This testcase is part of GDB, the GNU debugger.
++
++# Copyright 2004 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++
++# Check that GDB can call C++ functions whose parameters have
++# object type, but are passed by reference.
++
++set testfile "pass-by-ref"
++set srcfile ${testfile}.cc
++set binfile ${objdir}/${subdir}/${testfile}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++if ![runto_main] then {
++ return -1
++}
++
++gdb_test "print foo (global_obj)" " = 3" "call function"
+Index: gdb-6.3/gdb/testsuite/gdb.cp/pass-by-ref.cc
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.3/gdb/testsuite/gdb.cp/pass-by-ref.cc 2004-11-11 09:44:17.815014667 -0500
+@@ -0,0 +1,57 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2004 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++ USA. */
++
++class Obj {
++public:
++ Obj ();
++ Obj (const Obj &);
++ ~Obj ();
++ int var[2];
++};
++
++int foo (Obj arg)
++{
++ return arg.var[0] + arg.var[1];
++}
++
++Obj::Obj ()
++{
++ var[0] = 1;
++ var[1] = 2;
++}
++
++Obj::Obj (const Obj &obj)
++{
++ var[0] = obj.var[0];
++ var[1] = obj.var[1];
++}
++
++Obj::~Obj ()
++{
++
++}
++
++Obj global_obj;
++
++int
++main ()
++{
++ int bar = foo (global_obj);
++ return bar;
++}
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/710-debian_thread-db-multiple-libraries.patch b/cleopatre/buildroot/toolchain/gdb/6.3/710-debian_thread-db-multiple-libraries.patch
new file mode 100644
index 0000000000..c164bd11a2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/710-debian_thread-db-multiple-libraries.patch
@@ -0,0 +1,593 @@
+Support loading two libthread_db DSOs. In this case, the LinuxThreads
+and NPTL ones.
+
+Index: gdb-6.3/gdb/thread-db.c
+===================================================================
+--- gdb-6.3.orig/gdb/thread-db.c 2004-11-10 10:46:24.000000000 -0500
++++ gdb-6.3/gdb/thread-db.c 2004-11-10 11:22:34.858812426 -0500
+@@ -79,53 +79,63 @@ static td_thragent_t *thread_agent;
+
+ /* Pointers to the libthread_db functions. */
+
+-static td_err_e (*td_init_p) (void);
++struct thread_db_pointers
++{
++ const char *filename;
++
++ td_err_e (*td_init_p) (void);
+
+-static td_err_e (*td_ta_new_p) (struct ps_prochandle * ps,
+- td_thragent_t **ta);
+-static td_err_e (*td_ta_map_id2thr_p) (const td_thragent_t *ta, thread_t pt,
+- td_thrhandle_t *__th);
+-static td_err_e (*td_ta_map_lwp2thr_p) (const td_thragent_t *ta,
+- lwpid_t lwpid, td_thrhandle_t *th);
+-static td_err_e (*td_ta_thr_iter_p) (const td_thragent_t *ta,
+- td_thr_iter_f *callback, void *cbdata_p,
+- td_thr_state_e state, int ti_pri,
+- sigset_t *ti_sigmask_p,
+- unsigned int ti_user_flags);
+-static td_err_e (*td_ta_event_addr_p) (const td_thragent_t *ta,
+- td_event_e event, td_notify_t *ptr);
+-static td_err_e (*td_ta_set_event_p) (const td_thragent_t *ta,
+- td_thr_events_t *event);
+-static td_err_e (*td_ta_event_getmsg_p) (const td_thragent_t *ta,
+- td_event_msg_t *msg);
+-
+-static td_err_e (*td_thr_validate_p) (const td_thrhandle_t *th);
+-static td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th,
+- td_thrinfo_t *infop);
+-static td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th,
+- gdb_prfpregset_t *regset);
+-static td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th,
+- prgregset_t gregs);
+-static td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th,
+- const gdb_prfpregset_t *fpregs);
+-static td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th,
+- prgregset_t gregs);
+-static td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th,
+- int event);
+-
+-static td_err_e (*td_thr_tls_get_addr_p) (const td_thrhandle_t *th,
+- void *map_address,
+- size_t offset, void **address);
++ td_err_e (*td_ta_new_p) (struct ps_prochandle * ps,
++ td_thragent_t **ta);
++ td_err_e (*td_ta_map_id2thr_p) (const td_thragent_t *ta, thread_t pt,
++ td_thrhandle_t *__th);
++ td_err_e (*td_ta_map_lwp2thr_p) (const td_thragent_t *ta,
++ lwpid_t lwpid, td_thrhandle_t *th);
++
++ td_err_e (*td_ta_thr_iter_p) (const td_thragent_t *ta,
++ td_thr_iter_f *callback, void *cbdata_p,
++ td_thr_state_e state, int ti_pri,
++ sigset_t *ti_sigmask_p,
++ unsigned int ti_user_flags);
++ td_err_e (*td_ta_event_addr_p) (const td_thragent_t *ta,
++ td_event_e event, td_notify_t *ptr);
++ td_err_e (*td_ta_set_event_p) (const td_thragent_t *ta,
++ td_thr_events_t *event);
++ td_err_e (*td_ta_event_getmsg_p) (const td_thragent_t *ta,
++ td_event_msg_t *msg);
++
++ td_err_e (*td_thr_validate_p) (const td_thrhandle_t *th);
++ td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th,
++ td_thrinfo_t *infop);
++ td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th,
++ gdb_prfpregset_t *regset);
++ td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th,
++ prgregset_t gregs);
++ td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th,
++ const gdb_prfpregset_t *fpregs);
++ td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th,
++ prgregset_t gregs);
++ td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th,
++ int event);
++
++ td_err_e (*td_thr_tls_get_addr_p) (const td_thrhandle_t *th,
++ void *map_address,
++ size_t offset, void **address);
++
++ struct thread_db_pointers *next;
++};
+
+ /* Location of the thread creation event breakpoint. The code at this
+ location in the child process will be called by the pthread library
+ whenever a new thread is created. By setting a special breakpoint
+ at this location, GDB can detect when a new thread is created. We
+ obtain this location via the td_ta_event_addr call. */
+-static CORE_ADDR td_create_bp_addr;
++CORE_ADDR td_create_bp_addr;
+
+ /* Location of the thread death event breakpoint. */
+-static CORE_ADDR td_death_bp_addr;
++CORE_ADDR td_death_bp_addr;
++
++static struct thread_db_pointers *current_pointers, *all_pointers;
+
+ /* Prototypes for local functions. */
+ static void thread_db_find_new_threads (void);
+@@ -262,7 +272,7 @@ thread_get_info_callback (const td_thrha
+ struct thread_info *thread_info;
+ ptid_t thread_ptid;
+
+- err = td_thr_get_info_p (thp, &ti);
++ err = current_pointers->td_thr_get_info_p (thp, &ti);
+ if (err != TD_OK)
+ error ("thread_get_info_callback: cannot get thread info: %s",
+ thread_db_err_str (err));
+@@ -316,8 +326,9 @@ thread_db_map_id2thr (struct thread_info
+ if (thread_info->private->th_valid)
+ return;
+
+- err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (thread_info->ptid),
+- &thread_info->private->th);
++ err = current_pointers->td_ta_map_id2thr_p (thread_agent,
++ GET_THREAD (thread_info->ptid),
++ &thread_info->private->th);
+ if (err != TD_OK)
+ {
+ if (fatal)
+@@ -340,8 +351,8 @@ thread_db_get_info (struct thread_info *
+ if (!thread_info->private->th_valid)
+ thread_db_map_id2thr (thread_info, 1);
+
+- err =
+- td_thr_get_info_p (&thread_info->private->th, &thread_info->private->ti);
++ err = current_pointers->td_thr_get_info_p (&thread_info->private->th,
++ &thread_info->private->ti);
+ if (err != TD_OK)
+ error ("thread_db_get_info: cannot get thread info: %s",
+ thread_db_err_str (err));
+@@ -365,7 +376,8 @@ thread_from_lwp (ptid_t ptid)
+
+ gdb_assert (is_lwp (ptid));
+
+- err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th);
++ err = current_pointers->td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid),
++ &th);
+ if (err != TD_OK)
+ error ("Cannot find user-level thread for LWP %ld: %s",
+ GET_LWP (ptid), thread_db_err_str (err));
+@@ -420,85 +432,102 @@ verbose_dlsym (void *handle, const char
+ return sym;
+ }
+
+-static int
+-thread_db_load (void)
++static struct thread_db_pointers *
++thread_db_load (const char *name)
+ {
++ struct thread_db_pointers *ptrs;
++ Dl_info info;
+ void *handle;
+ td_err_e err;
+
+- handle = dlopen (LIBTHREAD_DB_SO, RTLD_NOW);
++ ptrs = xcalloc (1, sizeof (struct thread_db_pointers));
++
++ handle = dlopen (name, RTLD_NOW);
+ if (handle == NULL)
+ {
+- fprintf_filtered (gdb_stderr, "\n\ndlopen failed on '%s' - %s\n",
+- LIBTHREAD_DB_SO, dlerror ());
+- fprintf_filtered (gdb_stderr,
+- "GDB will not be able to debug pthreads.\n\n");
++ if (all_pointers == NULL)
++ {
++ fprintf_filtered (gdb_stderr, "\n\ndlopen failed on '%s' - %s\n",
++ name, dlerror ());
++ fprintf_filtered (gdb_stderr,
++ "GDB will not be able to debug pthreads.\n\n");
++ }
+ return 0;
+ }
+
+ /* Initialize pointers to the dynamic library functions we will use.
+ Essential functions first. */
+
+- td_init_p = verbose_dlsym (handle, "td_init");
+- if (td_init_p == NULL)
++ ptrs->td_init_p = verbose_dlsym (handle, "td_init");
++ if (ptrs->td_init_p == NULL)
+ return 0;
+
+- td_ta_new_p = verbose_dlsym (handle, "td_ta_new");
+- if (td_ta_new_p == NULL)
++ ptrs->td_ta_new_p = verbose_dlsym (handle, "td_ta_new");
++ if (ptrs->td_ta_new_p == NULL)
+ return 0;
+
+- td_ta_map_id2thr_p = verbose_dlsym (handle, "td_ta_map_id2thr");
+- if (td_ta_map_id2thr_p == NULL)
++ ptrs->td_ta_map_id2thr_p = verbose_dlsym (handle, "td_ta_map_id2thr");
++ if (ptrs->td_ta_map_id2thr_p == NULL)
+ return 0;
+
+- td_ta_map_lwp2thr_p = verbose_dlsym (handle, "td_ta_map_lwp2thr");
+- if (td_ta_map_lwp2thr_p == NULL)
++ ptrs->td_ta_map_lwp2thr_p = verbose_dlsym (handle, "td_ta_map_lwp2thr");
++ if (ptrs->td_ta_map_lwp2thr_p == NULL)
+ return 0;
+
+- td_ta_thr_iter_p = verbose_dlsym (handle, "td_ta_thr_iter");
+- if (td_ta_thr_iter_p == NULL)
++ ptrs->td_ta_thr_iter_p = verbose_dlsym (handle, "td_ta_thr_iter");
++ if (ptrs->td_ta_thr_iter_p == NULL)
+ return 0;
+
+- td_thr_validate_p = verbose_dlsym (handle, "td_thr_validate");
+- if (td_thr_validate_p == NULL)
++ ptrs->td_thr_validate_p = verbose_dlsym (handle, "td_thr_validate");
++ if (ptrs->td_thr_validate_p == NULL)
+ return 0;
+
+- td_thr_get_info_p = verbose_dlsym (handle, "td_thr_get_info");
+- if (td_thr_get_info_p == NULL)
++ ptrs->td_thr_get_info_p = verbose_dlsym (handle, "td_thr_get_info");
++ if (ptrs->td_thr_get_info_p == NULL)
+ return 0;
+
+- td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
+- if (td_thr_getfpregs_p == NULL)
++ ptrs->td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
++ if (ptrs->td_thr_getfpregs_p == NULL)
+ return 0;
+
+- td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
+- if (td_thr_getgregs_p == NULL)
++ ptrs->td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
++ if (ptrs->td_thr_getgregs_p == NULL)
+ return 0;
+
+- td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
+- if (td_thr_setfpregs_p == NULL)
++ ptrs->td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
++ if (ptrs->td_thr_setfpregs_p == NULL)
+ return 0;
+
+- td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
+- if (td_thr_setgregs_p == NULL)
++ ptrs->td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
++ if (ptrs->td_thr_setgregs_p == NULL)
+ return 0;
+
+ /* Initialize the library. */
+- err = td_init_p ();
++ err = ptrs->td_init_p ();
+ if (err != TD_OK)
+ {
+ warning ("Cannot initialize libthread_db: %s", thread_db_err_str (err));
++ xfree (ptrs);
+ return 0;
+ }
+
+ /* These are not essential. */
+- td_ta_event_addr_p = dlsym (handle, "td_ta_event_addr");
+- td_ta_set_event_p = dlsym (handle, "td_ta_set_event");
+- td_ta_event_getmsg_p = dlsym (handle, "td_ta_event_getmsg");
+- td_thr_event_enable_p = dlsym (handle, "td_thr_event_enable");
+- td_thr_tls_get_addr_p = dlsym (handle, "td_thr_tls_get_addr");
++ ptrs->td_ta_event_addr_p = dlsym (handle, "td_ta_event_addr");
++ ptrs->td_ta_set_event_p = dlsym (handle, "td_ta_set_event");
++ ptrs->td_ta_event_getmsg_p = dlsym (handle, "td_ta_event_getmsg");
++ ptrs->td_thr_event_enable_p = dlsym (handle, "td_thr_event_enable");
++ ptrs->td_thr_tls_get_addr_p = dlsym (handle, "td_thr_tls_get_addr");
++
++ if (dladdr (ptrs->td_ta_new_p, &info) != 0)
++ ptrs->filename = info.dli_fname;
++
++ /* Try dlinfo? */
++
++ if (ptrs->filename == NULL)
++ /* Paranoid - don't let a NULL path slip through. */
++ ptrs->filename = name;
+
+- return 1;
++ return ptrs;
+ }
+
+ static td_err_e
+@@ -508,7 +537,7 @@ enable_thread_event (td_thragent_t *thre
+ td_err_e err;
+
+ /* Get the breakpoint address for thread EVENT. */
+- err = td_ta_event_addr_p (thread_agent, event, &notify);
++ err = current_pointers->td_ta_event_addr_p (thread_agent, event, &notify);
+ if (err != TD_OK)
+ return err;
+
+@@ -534,8 +563,10 @@ enable_thread_event_reporting (void)
+
+ /* We cannot use the thread event reporting facility if these
+ functions aren't available. */
+- if (td_ta_event_addr_p == NULL || td_ta_set_event_p == NULL
+- || td_ta_event_getmsg_p == NULL || td_thr_event_enable_p == NULL)
++ if (current_pointers->td_ta_event_addr_p == NULL
++ || current_pointers->td_ta_set_event_p == NULL
++ || current_pointers->td_ta_event_getmsg_p == NULL
++ || current_pointers->td_thr_event_enable_p == NULL)
+ return;
+
+ /* Set the process wide mask saying which events we're interested in. */
+@@ -552,7 +583,7 @@ enable_thread_event_reporting (void)
+ #endif
+ td_event_addset (&events, TD_DEATH);
+
+- err = td_ta_set_event_p (thread_agent, &events);
++ err = current_pointers->td_ta_set_event_p (thread_agent, &events);
+ if (err != TD_OK)
+ {
+ warning ("Unable to set global thread event mask: %s",
+@@ -592,7 +623,7 @@ disable_thread_event_reporting (void)
+ /* Set the process wide mask saying we aren't interested in any
+ events anymore. */
+ td_event_emptyset (&events);
+- td_ta_set_event_p (thread_agent, &events);
++ current_pointers->td_ta_set_event_p (thread_agent, &events);
+
+ /* Delete thread event breakpoints, if any. */
+ remove_thread_event_breakpoints ();
+@@ -635,7 +666,6 @@ check_thread_signals (void)
+ static void
+ check_for_thread_db (void)
+ {
+- td_err_e err;
+ static int already_loaded;
+
+ /* First time through, report that libthread_db was successfuly
+@@ -644,19 +674,8 @@ check_for_thread_db (void)
+
+ if (!already_loaded)
+ {
+- Dl_info info;
+- const char *library = NULL;
+- if (dladdr ((*td_ta_new_p), &info) != 0)
+- library = info.dli_fname;
+-
+- /* Try dlinfo? */
+-
+- if (library == NULL)
+- /* Paranoid - don't let a NULL path slip through. */
+- library = LIBTHREAD_DB_SO;
+-
+ printf_unfiltered ("Using host libthread_db library \"%s\".\n",
+- library);
++ all_pointers->filename);
+ already_loaded = 1;
+ }
+
+@@ -674,28 +693,34 @@ check_for_thread_db (void)
+ proc_handle.pid = GET_PID (inferior_ptid);
+
+ /* Now attempt to open a connection to the thread library. */
+- err = td_ta_new_p (&proc_handle, &thread_agent);
+- switch (err)
++ for (current_pointers = all_pointers;
++ current_pointers != NULL;
++ current_pointers = current_pointers->next)
+ {
+- case TD_NOLIBTHREAD:
+- /* No thread library was detected. */
+- break;
+-
+- case TD_OK:
+- printf_unfiltered ("[Thread debugging using libthread_db enabled]\n");
++ td_err_e err;
++ err = current_pointers->td_ta_new_p (&proc_handle, &thread_agent);
++ switch (err)
++ {
++ case TD_NOLIBTHREAD:
++ /* No thread library was detected. */
++ break;
+
+- /* The thread library was detected. Activate the thread_db target. */
+- push_target (&thread_db_ops);
+- using_thread_db = 1;
++ case TD_OK:
++ printf_unfiltered ("[Thread debugging using libthread_db enabled]\n");
+
+- enable_thread_event_reporting ();
+- thread_db_find_new_threads ();
+- break;
++ /* The thread library was detected. Activate the thread_db target. */
++ push_target (&thread_db_ops);
++ using_thread_db = 1;
++
++ enable_thread_event_reporting ();
++ thread_db_find_new_threads ();
++ return;
+
+- default:
+- warning ("Cannot initialize thread debugging library: %s",
+- thread_db_err_str (err));
+- break;
++ default:
++ warning ("Cannot initialize thread debugging library: %s",
++ thread_db_err_str (err));
++ break;
++ }
+ }
+ }
+
+@@ -766,7 +791,7 @@ attach_thread (ptid_t ptid, const td_thr
+ #endif
+
+ /* Enable thread event reporting for this thread. */
+- err = td_thr_event_enable_p (th_p, 1);
++ err = current_pointers->td_thr_event_enable_p (th_p, 1);
+ if (err != TD_OK)
+ error ("Cannot enable thread event reporting for %s: %s",
+ target_pid_to_str (ptid), thread_db_err_str (err));
+@@ -892,7 +917,7 @@ check_event (ptid_t ptid)
+
+ do
+ {
+- err = td_ta_event_getmsg_p (thread_agent, &msg);
++ err = current_pointers->td_ta_event_getmsg_p (thread_agent, &msg);
+ if (err != TD_OK)
+ {
+ if (err == TD_NOMSG)
+@@ -902,7 +927,7 @@ check_event (ptid_t ptid)
+ thread_db_err_str (err));
+ }
+
+- err = td_thr_get_info_p (msg.th_p, &ti);
++ err = current_pointers->td_thr_get_info_p (msg.th_p, &ti);
+ if (err != TD_OK)
+ error ("Cannot get thread info: %s", thread_db_err_str (err));
+
+@@ -1015,12 +1040,14 @@ thread_db_fetch_registers (int regno)
+ thread_info = find_thread_pid (inferior_ptid);
+ thread_db_map_id2thr (thread_info, 1);
+
+- err = td_thr_getgregs_p (&thread_info->private->th, gregset);
++ err = current_pointers->td_thr_getgregs_p (&thread_info->private->th,
++ gregset);
+ if (err != TD_OK)
+ error ("Cannot fetch general-purpose registers for thread %ld: %s",
+ (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
+
+- err = td_thr_getfpregs_p (&thread_info->private->th, &fpregset);
++ err = current_pointers->td_thr_getfpregs_p (&thread_info->private->th,
++ &fpregset);
+ if (err != TD_OK)
+ error ("Cannot get floating-point registers for thread %ld: %s",
+ (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
+@@ -1062,11 +1089,13 @@ thread_db_store_registers (int regno)
+ fill_gregset ((gdb_gregset_t *) gregset, -1);
+ fill_fpregset (&fpregset, -1);
+
+- err = td_thr_setgregs_p (&thread_info->private->th, gregset);
++ err = current_pointers->td_thr_setgregs_p (&thread_info->private->th,
++ gregset);
+ if (err != TD_OK)
+ error ("Cannot store general-purpose registers for thread %ld: %s",
+ (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
+- err = td_thr_setfpregs_p (&thread_info->private->th, &fpregset);
++ err = current_pointers->td_thr_setfpregs_p (&thread_info->private->th,
++ &fpregset);
+ if (err != TD_OK)
+ error ("Cannot store floating-point registers for thread %ld: %s",
+ (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
+@@ -1136,15 +1165,14 @@ thread_db_thread_alive (ptid_t ptid)
+ if (!thread_info->private->th_valid)
+ return 0;
+
+- err = td_thr_validate_p (&thread_info->private->th);
++ err = current_pointers->td_thr_validate_p (&thread_info->private->th);
+ if (err != TD_OK)
+ return 0;
+
+ if (!thread_info->private->ti_valid)
+ {
+- err =
+- td_thr_get_info_p (&thread_info->private->th,
+- &thread_info->private->ti);
++ err = current_pointers->td_thr_get_info_p
++ (&thread_info->private->th, &thread_info->private->ti);
+ if (err != TD_OK)
+ return 0;
+ thread_info->private->ti_valid = 1;
+@@ -1170,7 +1198,7 @@ find_new_threads_callback (const td_thrh
+ td_err_e err;
+ ptid_t ptid;
+
+- err = td_thr_get_info_p (th_p, &ti);
++ err = current_pointers->td_thr_get_info_p (th_p, &ti);
+ if (err != TD_OK)
+ error ("find_new_threads_callback: cannot get thread info: %s",
+ thread_db_err_str (err));
+@@ -1192,9 +1220,10 @@ thread_db_find_new_threads (void)
+ td_err_e err;
+
+ /* Iterate over all user-space threads to discover new threads. */
+- err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL,
+- TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
+- TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
++ err = current_pointers->td_ta_thr_iter_p
++ (thread_agent, find_new_threads_callback, NULL,
++ TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
++ TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+ if (err != TD_OK)
+ error ("Cannot find new threads: %s", thread_db_err_str (err));
+ }
+@@ -1257,7 +1286,7 @@ thread_db_get_thread_local_address (ptid
+ struct thread_info *thread_info;
+
+ /* glibc doesn't provide the needed interface. */
+- if (!td_thr_tls_get_addr_p)
++ if (!current_pointers->td_thr_tls_get_addr_p)
+ error ("Cannot find thread-local variables in this thread library.");
+
+ /* Get the address of the link map for this objfile. */
+@@ -1279,8 +1308,8 @@ thread_db_get_thread_local_address (ptid
+ thread_db_map_id2thr (thread_info, 1);
+
+ /* Finally, get the address of the variable. */
+- err = td_thr_tls_get_addr_p (&thread_info->private->th, (void *) lm,
+- offset, &address);
++ err = current_pointers->td_thr_tls_get_addr_p
++ (&thread_info->private->th, (void *) lm, offset, &address);
+
+ #ifdef THREAD_DB_HAS_TD_NOTALLOC
+ /* The memory hasn't been allocated, yet. */
+@@ -1360,17 +1389,49 @@ init_thread_db_ops (void)
+ void
+ _initialize_thread_db (void)
+ {
++ struct thread_db_pointers *ptrs;
++ const char *p;
++
+ /* Only initialize the module if we can load libthread_db. */
+- if (thread_db_load ())
+- {
+- init_thread_db_ops ();
+- add_target (&thread_db_ops);
++ ptrs = thread_db_load (LIBTHREAD_DB_SO);
++ if (ptrs == NULL)
++ return;
++
++ all_pointers = ptrs;
+
+- /* Add ourselves to objfile event chain. */
+- target_new_objfile_chain = deprecated_target_new_objfile_hook;
+- deprecated_target_new_objfile_hook = thread_db_new_objfile;
++ /* Some GNU/Linux systems have more than one binary-compatible copy
++ of libthread_db. If we can find a second one, load that too.
++ The inferior may force the use of a different threading package
++ than we expect. Our guess for the location is somewhat hokey:
++ strip out anything between /lib (or /lib64) and LIBTHREAD_DB_SO.
++ If we loaded the NPTL libthread_db by default, this may find us
++ the LinuxThreads copy. */
++ p = strrchr (ptrs->filename, '/');
++ while (p != NULL && p > ptrs->filename)
++ {
++ const char *component;
+
+- /* Register ourselves for the new inferior observer. */
+- observer_attach_inferior_created (check_for_thread_db_observer);
++ component = memrchr (ptrs->filename, '/', p - ptrs->filename);
++ if (component != NULL && strncmp (component, "/lib", 4) == 0)
++ {
++ char *new_name = xmalloc (p - ptrs->filename + 2
++ + strlen (LIBTHREAD_DB_SO));
++ memcpy (new_name, ptrs->filename, p - ptrs->filename + 1);
++ strcpy (new_name + (p - ptrs->filename) + 1, LIBTHREAD_DB_SO);
++ ptrs->next = thread_db_load (new_name);
++ xfree (new_name);
++ break;
++ }
++ p = component;
+ }
++
++ init_thread_db_ops ();
++ add_target (&thread_db_ops);
++
++ /* Add ourselves to objfile event chain. */
++ target_new_objfile_chain = deprecated_target_new_objfile_hook;
++ deprecated_target_new_objfile_hook = thread_db_new_objfile;
++
++ /* Register ourselves for the new inferior observer. */
++ observer_attach_inferior_created (check_for_thread_db_observer);
+ }
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/720-debian_static-threads-test.patch b/cleopatre/buildroot/toolchain/gdb/6.3/720-debian_static-threads-test.patch
new file mode 100644
index 0000000000..448c9b1d7c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/720-debian_static-threads-test.patch
@@ -0,0 +1,36 @@
+Update staticthreads.exp to handle debugging info in libpthread.a.
+
+Index: gdb-6.3/gdb/testsuite/gdb.threads/staticthreads.exp
+===================================================================
+--- gdb-6.3.orig/gdb/testsuite/gdb.threads/staticthreads.exp 2004-11-10 10:35:15.000000000 -0500
++++ gdb-6.3/gdb/testsuite/gdb.threads/staticthreads.exp 2004-11-10 11:22:48.671121466 -0500
+@@ -53,6 +53,10 @@ gdb_test_multiple "continue" "$test" {
+ -re " sem_post .*$gdb_prompt " {
+ pass "$test"
+ }
++ -re " (.*_)sem_post .*$gdb_prompt " {
++ # Glibc uses aliases for internal symbols; match __new_sem_post.
++ pass "$test"
++ }
+ -re "Program received signal .*$gdb_prompt " {
+ kfail gdb/1328 "$test"
+ }
+@@ -64,8 +68,16 @@ gdb_test_multiple "continue" "$test" {
+
+ rerun_to_main
+ gdb_test "handle SIG32 nostop noprint pass"
+-set test "Handle SIG32 helps"
+-gdb_test "continue" " sem_post .*" "handle SIG32 helps"
++set test "handle SIG32 helps"
++gdb_test_multiple "continue" "$test" {
++ -re " sem_post .*$gdb_prompt $" {
++ pass "$test"
++ }
++ -re " (.*_)sem_post .*$gdb_prompt $" {
++ # Glibc uses aliases for internal symbols; match __new_sem_post.
++ pass "$test"
++ }
++}
+
+
+ # See if info threads produces anything approaching a thread list.
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/730-debian_gdb-fix-tracefork-check.patch b/cleopatre/buildroot/toolchain/gdb/6.3/730-debian_gdb-fix-tracefork-check.patch
new file mode 100644
index 0000000000..9890d80c3e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/730-debian_gdb-fix-tracefork-check.patch
@@ -0,0 +1,225 @@
+Status: submitted for comments
+
+2004-11-12 Daniel Jacobowitz <dan@debian.org>
+
+ * linux-nat.c (my_waitpid): New function.
+ (linux_test_for_tracefork): Make more robust and verbose. Take
+ an ORIGINAL_PID argument and test for PTRACE_SETOPTIONS first.
+ (linux_supports_tracefork, linux_supports_tracevforkdone): Take a PID
+ argument. Update calls to linux_test_for_tracefork.
+ (linux_enable_event_reporting, child_follow_fork)
+ (child_insert_fork_catchpoint, child_insert_vfork_catchpoint)
+ (child_insert_exec_catchpoint): Update calls to
+ linux_supports_tracefork and linux_supports_tracevforkdone.
+
+Index: gdb-6.3/gdb/linux-nat.c
+===================================================================
+--- gdb-6.3.orig/gdb/linux-nat.c 2004-10-08 16:29:47.000000000 -0400
++++ gdb-6.3/gdb/linux-nat.c 2004-11-13 16:41:51.368720845 -0500
+@@ -150,18 +150,47 @@ linux_tracefork_child (void)
+ exit (0);
+ }
+
+-/* Determine if PTRACE_O_TRACEFORK can be used to follow fork events. We
++/* Wrapper function for waitpid which handles EINTR. */
++
++static int
++my_waitpid (int pid, int *status, int flags)
++{
++ int ret;
++ do
++ {
++ ret = waitpid (pid, status, flags);
++ }
++ while (ret == -1 && errno == EINTR);
++
++ return ret;
++}
++
++/* Determine if PTRACE_O_TRACEFORK can be used to follow fork events.
++
++ First, we try to enable fork tracing on ORIGINAL_PID. If this fails,
++ we know that the feature is not available. This may change the tracing
++ options for ORIGINAL_PID, but we'll be setting them shortly anyway.
++
++ However, if it succeeds, we don't know for sure that the feature is
++ available; old versions of PTRACE_SETOPTIONS ignored unknown options. We
+ create a child process, attach to it, use PTRACE_SETOPTIONS to enable
+- fork tracing, and let it fork. If the process exits, we assume that
+- we can't use TRACEFORK; if we get the fork notification, and we can
+- extract the new child's PID, then we assume that we can. */
++ fork tracing, and let it fork. If the process exits, we assume that we
++ can't use TRACEFORK; if we get the fork notification, and we can extract
++ the new child's PID, then we assume that we can. */
+
+ static void
+-linux_test_for_tracefork (void)
++linux_test_for_tracefork (int original_pid)
+ {
+ int child_pid, ret, status;
+ long second_pid;
+
++ linux_supports_tracefork_flag = 0;
++ linux_supports_tracevforkdone_flag = 0;
++
++ ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACEFORK);
++ if (ret != 0)
++ return;
++
+ child_pid = fork ();
+ if (child_pid == -1)
+ perror_with_name ("linux_test_for_tracefork: fork");
+@@ -169,7 +198,7 @@ linux_test_for_tracefork (void)
+ if (child_pid == 0)
+ linux_tracefork_child ();
+
+- ret = waitpid (child_pid, &status, 0);
++ ret = my_waitpid (child_pid, &status, 0);
+ if (ret == -1)
+ perror_with_name ("linux_test_for_tracefork: waitpid");
+ else if (ret != child_pid)
+@@ -177,13 +206,23 @@ linux_test_for_tracefork (void)
+ if (! WIFSTOPPED (status))
+ error ("linux_test_for_tracefork: waitpid: unexpected status %d.", status);
+
+- linux_supports_tracefork_flag = 0;
+-
+ ret = ptrace (PTRACE_SETOPTIONS, child_pid, 0, PTRACE_O_TRACEFORK);
+ if (ret != 0)
+ {
+- ptrace (PTRACE_KILL, child_pid, 0, 0);
+- waitpid (child_pid, &status, 0);
++ ret = ptrace (PTRACE_KILL, child_pid, 0, 0);
++ if (ret != 0)
++ {
++ warning ("linux_test_for_tracefork: failed to kill child");
++ return;
++ }
++
++ ret = my_waitpid (child_pid, &status, 0);
++ if (ret != child_pid)
++ warning ("linux_test_for_tracefork: failed to wait for killed child");
++ else if (!WIFSIGNALED (status))
++ warning ("linux_test_for_tracefork: unexpected wait status 0x%x from "
++ "killed child", status);
++
+ return;
+ }
+
+@@ -192,8 +231,12 @@ linux_test_for_tracefork (void)
+ PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORKDONE);
+ linux_supports_tracevforkdone_flag = (ret == 0);
+
+- ptrace (PTRACE_CONT, child_pid, 0, 0);
+- ret = waitpid (child_pid, &status, 0);
++ ret = ptrace (PTRACE_CONT, child_pid, 0, 0);
++ if (ret != 0)
++ warning ("linux_test_for_tracefork: failed to resume child");
++
++ ret = my_waitpid (child_pid, &status, 0);
++
+ if (ret == child_pid && WIFSTOPPED (status)
+ && status >> 16 == PTRACE_EVENT_FORK)
+ {
+@@ -204,34 +247,38 @@ linux_test_for_tracefork (void)
+ int second_status;
+
+ linux_supports_tracefork_flag = 1;
+- waitpid (second_pid, &second_status, 0);
+- ptrace (PTRACE_DETACH, second_pid, 0, 0);
++ my_waitpid (second_pid, &second_status, 0);
++ ret = ptrace (PTRACE_KILL, second_pid, 0, 0);
++ if (ret != 0)
++ warning ("linux_test_for_tracefork: failed to kill second child");
+ }
+ }
++ else
++ warning ("linux_test_for_tracefork: unexpected result from waitpid "
++ "(%d, status 0x%x)", ret, status);
+
+- if (WIFSTOPPED (status))
+- {
+- ptrace (PTRACE_DETACH, child_pid, 0, 0);
+- waitpid (child_pid, &status, 0);
+- }
++ ret = ptrace (PTRACE_KILL, child_pid, 0, 0);
++ if (ret != 0)
++ warning ("linux_test_for_tracefork: failed to kill child");
++ my_waitpid (child_pid, &status, 0);
+ }
+
+ /* Return non-zero iff we have tracefork functionality available.
+ This function also sets linux_supports_tracefork_flag. */
+
+ static int
+-linux_supports_tracefork (void)
++linux_supports_tracefork (int pid)
+ {
+ if (linux_supports_tracefork_flag == -1)
+- linux_test_for_tracefork ();
++ linux_test_for_tracefork (pid);
+ return linux_supports_tracefork_flag;
+ }
+
+ static int
+-linux_supports_tracevforkdone (void)
++linux_supports_tracevforkdone (int pid)
+ {
+ if (linux_supports_tracefork_flag == -1)
+- linux_test_for_tracefork ();
++ linux_test_for_tracefork (pid);
+ return linux_supports_tracevforkdone_flag;
+ }
+
+@@ -242,12 +289,12 @@ linux_enable_event_reporting (ptid_t pti
+ int pid = ptid_get_pid (ptid);
+ int options;
+
+- if (! linux_supports_tracefork ())
++ if (! linux_supports_tracefork (pid))
+ return;
+
+ options = PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACEEXEC
+ | PTRACE_O_TRACECLONE;
+- if (linux_supports_tracevforkdone ())
++ if (linux_supports_tracevforkdone (pid))
+ options |= PTRACE_O_TRACEVFORKDONE;
+
+ /* Do not enable PTRACE_O_TRACEEXIT until GDB is more prepared to support
+@@ -308,7 +355,8 @@ child_follow_fork (int follow_child)
+
+ if (has_vforked)
+ {
+- if (linux_supports_tracevforkdone ())
++ gdb_assert (linux_supports_tracefork_flag >= 0);
++ if (linux_supports_tracevforkdone (0))
+ {
+ int status;
+
+@@ -476,7 +524,7 @@ linux_handle_extended_wait (int pid, int
+ int
+ child_insert_fork_catchpoint (int pid)
+ {
+- if (! linux_supports_tracefork ())
++ if (! linux_supports_tracefork (pid))
+ error ("Your system does not support fork catchpoints.");
+
+ return 0;
+@@ -485,7 +533,7 @@ child_insert_fork_catchpoint (int pid)
+ int
+ child_insert_vfork_catchpoint (int pid)
+ {
+- if (!linux_supports_tracefork ())
++ if (!linux_supports_tracefork (pid))
+ error ("Your system does not support vfork catchpoints.");
+
+ return 0;
+@@ -494,7 +542,7 @@ child_insert_vfork_catchpoint (int pid)
+ int
+ child_insert_exec_catchpoint (int pid)
+ {
+- if (!linux_supports_tracefork ())
++ if (!linux_supports_tracefork (pid))
+ error ("Your system does not support exec catchpoints.");
+
+ return 0;
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/740-debian_make-cv-type-crash.patch b/cleopatre/buildroot/toolchain/gdb/6.3/740-debian_make-cv-type-crash.patch
new file mode 100644
index 0000000000..4e0b8cd72a
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/740-debian_make-cv-type-crash.patch
@@ -0,0 +1,132 @@
+2004-11-04 Jim Blandy <jimb@redhat.com>
+
+ * gdbtypes.c (make_qualified_type): Doc fix. Add assertion to
+ prevent cross-objfile references.
+ (make_cv_type): Doc fix. Don't create cross-objfile references,
+ even for stub types.
+ (replace_type): Add assertion to prevent cross-objfile references.
+ (check_typedef): Never resolve a stub type by copying over a type
+ from another file.
+
+Index: src/gdb/gdbtypes.c
+===================================================================
+RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbtypes.c,v
+retrieving revision 1.92
+retrieving revision 1.93
+diff -u -p -r1.92 -r1.93
+--- src/gdb/gdbtypes.c 8 Aug 2004 17:18:16 -0000 1.92
++++ src/gdb/gdbtypes.c 4 Nov 2004 17:50:16 -0000 1.93
+@@ -433,7 +433,9 @@ address_space_int_to_name (int space_fla
+ }
+
+ /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
+- If STORAGE is non-NULL, create the new type instance there. */
++
++ If STORAGE is non-NULL, create the new type instance there.
++ STORAGE must be in the same obstack as TYPE. */
+
+ static struct type *
+ make_qualified_type (struct type *type, int new_flags,
+@@ -453,6 +455,12 @@ make_qualified_type (struct type *type,
+ ntype = alloc_type_instance (type);
+ else
+ {
++ /* If STORAGE was provided, it had better be in the same objfile as
++ TYPE. Otherwise, we can't link it into TYPE's cv chain: if one
++ objfile is freed and the other kept, we'd have dangling
++ pointers. */
++ gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
++
+ ntype = storage;
+ TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
+ TYPE_CHAIN (ntype) = ntype;
+@@ -501,11 +509,12 @@ make_type_with_address_space (struct typ
+ CNST is a flag for setting the const attribute
+ VOLTL is a flag for setting the volatile attribute
+ TYPE is the base type whose variant we are creating.
+- TYPEPTR, if nonzero, points
+- to a pointer to memory where the reference type should be stored.
+- If *TYPEPTR is zero, update it to point to the reference type we return.
+- We allocate new memory if needed. */
+
++ If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
++ storage to hold the new qualified type; *TYPEPTR and TYPE must be
++ in the same objfile. Otherwise, allocate fresh memory for the new
++ type whereever TYPE lives. If TYPEPTR is non-zero, set it to the
++ new type we construct. */
+ struct type *
+ make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
+ {
+@@ -524,20 +533,19 @@ make_cv_type (int cnst, int voltl, struc
+
+ if (typeptr && *typeptr != NULL)
+ {
+- /* Objfile is per-core-type. This const-qualified type had best
+- belong to the same objfile as the type it is qualifying, unless
+- we are overwriting a stub type, in which case the safest thing
+- to do is to copy the core type into the new objfile. */
+-
+- gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type)
+- || TYPE_STUB (*typeptr));
+- if (TYPE_OBJFILE (*typeptr) != TYPE_OBJFILE (type))
+- {
+- TYPE_MAIN_TYPE (*typeptr)
+- = TYPE_ALLOC (*typeptr, sizeof (struct main_type));
+- *TYPE_MAIN_TYPE (*typeptr)
+- = *TYPE_MAIN_TYPE (type);
+- }
++ /* TYPE and *TYPEPTR must be in the same objfile. We can't have
++ a C-V variant chain that threads across objfiles: if one
++ objfile gets freed, then the other has a broken C-V chain.
++
++ This code used to try to copy over the main type from TYPE to
++ *TYPEPTR if they were in different objfiles, but that's
++ wrong, too: TYPE may have a field list or member function
++ lists, which refer to types of their own, etc. etc. The
++ whole shebang would need to be copied over recursively; you
++ can't have inter-objfile pointers. The only thing to do is
++ to leave stub types as stub types, and look them up afresh by
++ name each time you encounter them. */
++ gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type));
+ }
+
+ ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL);
+@@ -562,6 +570,12 @@ replace_type (struct type *ntype, struct
+ {
+ struct type *chain;
+
++ /* These two types had better be in the same objfile. Otherwise,
++ the assignment of one type's main type structure to the other
++ will produce a type with references to objects (names; field
++ lists; etc.) allocated on an objfile other than its own. */
++ gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype));
++
+ *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
+
+ /* The type length is not a part of the main type. Update it for each
+@@ -1416,8 +1430,24 @@ check_typedef (struct type *type)
+ return type;
+ }
+ newtype = lookup_transparent_type (name);
++
+ if (newtype)
+- make_cv_type (is_const, is_volatile, newtype, &type);
++ {
++ /* If the resolved type and the stub are in the same objfile,
++ then replace the stub type with the real deal. But if
++ they're in separate objfiles, leave the stub alone; we'll
++ just look up the transparent type every time we call
++ check_typedef. We can't create pointers between types
++ allocated to different objfiles, since they may have
++ different lifetimes. Trying to copy NEWTYPE over to TYPE's
++ objfile is pointless, too, since you'll have to move over any
++ other types NEWTYPE refers to, which could be an unbounded
++ amount of stuff. */
++ if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type))
++ make_cv_type (is_const, is_volatile, newtype, &type);
++ else
++ type = newtype;
++ }
+ }
+ /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
+ else if (TYPE_STUB (type) && !currently_reading_symtab)
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/750-debian_sparc-singlestep.patch b/cleopatre/buildroot/toolchain/gdb/6.3/750-debian_sparc-singlestep.patch
new file mode 100644
index 0000000000..904883c2fc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/750-debian_sparc-singlestep.patch
@@ -0,0 +1,37 @@
+Status: submitted for comments
+
+2004-11-13 Daniel Jacobowitz <dan@debian.org>
+
+ * sparc-tdep.c (sparc_software_single_step): Handle stepping to NULL.
+
+Index: gdb-6.3/gdb/sparc-tdep.c
+===================================================================
+--- gdb-6.3.orig/gdb/sparc-tdep.c 2004-06-06 22:02:55.000000000 -0400
++++ gdb-6.3/gdb/sparc-tdep.c 2004-11-13 17:06:05.000000000 -0500
+@@ -1026,10 +1026,10 @@
+
+ if (insert_breakpoints_p)
+ {
+- CORE_ADDR pc;
++ CORE_ADDR pc, orig_npc;
+
+ pc = sparc_address_from_register (tdep->pc_regnum);
+- npc = sparc_address_from_register (tdep->npc_regnum);
++ orig_npc = npc = sparc_address_from_register (tdep->npc_regnum);
+
+ /* Analyze the instruction at PC. */
+ nnpc = sparc_analyze_control_transfer (pc, &npc);
+@@ -1039,9 +1039,10 @@
+ target_insert_breakpoint (nnpc, nnpc_save);
+
+ /* Assert that we have set at least one breakpoint, and that
+- they're not set at the same spot. */
+- gdb_assert (npc != 0 || nnpc != 0);
+- gdb_assert (nnpc != npc);
++ they're not set at the same spot - unless we're going
++ from here straight to NULL, i.e. a call or jump to 0. */
++ gdb_assert (npc != 0 || nnpc != 0 || orig_npc == 0);
++ gdb_assert (nnpc != npc || orig_npc == 0);
+ }
+ else
+ {
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/760-debian_vsyscall-bfd-close-result.patch b/cleopatre/buildroot/toolchain/gdb/6.3/760-debian_vsyscall-bfd-close-result.patch
new file mode 100644
index 0000000000..56002bed0c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/760-debian_vsyscall-bfd-close-result.patch
@@ -0,0 +1,20 @@
+2004-10-24 Daniel Jacobowitz <dan@debian.org>
+
+ * opncls.c (bfd_close): Return TRUE for BFD_IN_MEMORY.
+
+Index: src/bfd/opncls.c
+===================================================================
+RCS file: /big/fsf/rsync/src-cvs/src/bfd/opncls.c,v
+retrieving revision 1.25
+diff -u -p -r1.25 opncls.c
+--- src/bfd/opncls.c 10 Oct 2004 13:58:05 -0000 1.25
++++ src/bfd/opncls.c 24 Oct 2004 17:52:53 -0000
+@@ -598,7 +598,7 @@ bfd_close (bfd *abfd)
+ if (!(abfd->flags & BFD_IN_MEMORY))
+ ret = abfd->iovec->bclose (abfd);
+ else
+- ret = 0;
++ ret = TRUE;
+
+ /* If the file was open for writing and is now executable,
+ make it so. */
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/770-debian_vfork-done-spelling.patch b/cleopatre/buildroot/toolchain/gdb/6.3/770-debian_vfork-done-spelling.patch
new file mode 100644
index 0000000000..f65db8d091
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/770-debian_vfork-done-spelling.patch
@@ -0,0 +1,31 @@
+Index: gdb-6.3/gdb/linux-nat.c
+===================================================================
+--- gdb-6.3.orig/gdb/linux-nat.c 2004-11-14 00:36:41.000000000 -0500
++++ gdb-6.3/gdb/linux-nat.c 2004-11-15 11:51:43.954161476 -0500
+@@ -69,7 +69,7 @@
+ #define PTRACE_EVENT_VFORK 2
+ #define PTRACE_EVENT_CLONE 3
+ #define PTRACE_EVENT_EXEC 4
+-#define PTRACE_EVENT_VFORKDONE 5
++#define PTRACE_EVENT_VFORK_DONE 5
+ #define PTRACE_EVENT_EXIT 6
+
+ #endif /* PTRACE_EVENT_FORK */
+@@ -362,7 +362,7 @@ child_follow_fork (int follow_child)
+
+ ptrace (PTRACE_CONT, parent_pid, 0, 0);
+ waitpid (parent_pid, &status, __WALL);
+- if ((status >> 16) != PTRACE_EVENT_VFORKDONE)
++ if ((status >> 16) != PTRACE_EVENT_VFORK_DONE)
+ warning ("Unexpected waitpid result %06x when waiting for "
+ "vfork-done", status);
+ }
+@@ -434,7 +434,7 @@ child_follow_fork (int follow_child)
+ generally not encounter vfork (vfork is defined to fork
+ in libpthread.so).
+
+- The holding part is very easy if we have VFORKDONE events;
++ The holding part is very easy if we have VFORK_DONE events;
+ but keeping track of both processes is beyond GDB at the
+ moment. So we don't expose the parent to the rest of GDB.
+ Instead we quietly hold onto it until such time as we can
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/780-debian_gdbserver-rdynamic.patch b/cleopatre/buildroot/toolchain/gdb/6.3/780-debian_gdbserver-rdynamic.patch
new file mode 100644
index 0000000000..0311dde390
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/780-debian_gdbserver-rdynamic.patch
@@ -0,0 +1,675 @@
+Status: Commited to GDB after 6.3.
+
+Index: gdb-6.3/gdb/gdbserver/acinclude.m4
+===================================================================
+--- gdb-6.3.orig/gdb/gdbserver/acinclude.m4 2002-06-11 13:32:39.000000000 -0400
++++ gdb-6.3/gdb/gdbserver/acinclude.m4 2004-12-07 17:19:31.115089905 -0500
+@@ -13,6 +13,7 @@ AC_DEFUN([SRV_CHECK_THREAD_DB],
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}],
+ [td_ta_new();],
+ [srv_cv_thread_db="-lthread_db"],
+@@ -32,10 +33,11 @@ AC_DEFUN([SRV_CHECK_THREAD_DB],
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}],
+ [td_ta_new();],
+ [srv_cv_thread_db="$thread_db"],
+ [srv_cv_thread_db=no])
++ ]])
+ LIBS="$old_LIBS"
+- ]])
+ )])
+Index: gdb-6.3/gdb/gdbserver/configure
+===================================================================
+--- gdb-6.3.orig/gdb/gdbserver/configure 2004-10-16 12:18:54.000000000 -0400
++++ gdb-6.3/gdb/gdbserver/configure 2004-12-07 17:22:17.343129771 -0500
+@@ -28,6 +28,7 @@ program_suffix=NONE
+ program_transform_name=s,x,x,
+ silent=
+ site=
++sitefile=
+ srcdir=
+ target=NONE
+ verbose=
+@@ -142,6 +143,7 @@ Configuration:
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
++ --site-file=FILE use FILE as the site file
+ --version print the version of autoconf that created configure
+ Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+@@ -312,6 +314,11 @@ EOF
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
++ -site-file | --site-file | --site-fil | --site-fi | --site-f)
++ ac_prev=sitefile ;;
++ -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
++ sitefile="$ac_optarg" ;;
++
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+@@ -477,12 +484,16 @@ fi
+ srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+ # Prefer explicitly selected file to automatically selected ones.
+-if test -z "$CONFIG_SITE"; then
+- if test "x$prefix" != xNONE; then
+- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+- else
+- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
++if test -z "$sitefile"; then
++ if test -z "$CONFIG_SITE"; then
++ if test "x$prefix" != xNONE; then
++ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
++ else
++ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
++ fi
+ fi
++else
++ CONFIG_SITE="$sitefile"
+ fi
+ for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+@@ -526,7 +537,7 @@ fi
+ # Extract the first word of "gcc", so it can be a program name with args.
+ set dummy gcc; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:530: checking for $ac_word" >&5
++echo "configure:541: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -556,7 +567,7 @@ if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+ set dummy cc; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:560: checking for $ac_word" >&5
++echo "configure:571: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -607,7 +618,7 @@ fi
+ # Extract the first word of "cl", so it can be a program name with args.
+ set dummy cl; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:611: checking for $ac_word" >&5
++echo "configure:622: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -639,7 +650,7 @@ fi
+ fi
+
+ echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+-echo "configure:643: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
++echo "configure:654: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ ac_ext=c
+ # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+@@ -650,12 +661,12 @@ cross_compiling=$ac_cv_prog_cc_cross
+
+ cat > conftest.$ac_ext << EOF
+
+-#line 654 "configure"
++#line 665 "configure"
+ #include "confdefs.h"
+
+ main(){return(0);}
+ EOF
+-if { (eval echo configure:659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+@@ -681,12 +692,12 @@ if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+-echo "configure:685: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
++echo "configure:696: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+ echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+ cross_compiling=$ac_cv_prog_cc_cross
+
+ echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+-echo "configure:690: checking whether we are using GNU C" >&5
++echo "configure:701: checking whether we are using GNU C" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -695,7 +706,7 @@ else
+ yes;
+ #endif
+ EOF
+-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
++if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:710: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+ else
+ ac_cv_prog_gcc=no
+@@ -714,7 +725,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+-echo "configure:718: checking whether ${CC-cc} accepts -g" >&5
++echo "configure:729: checking whether ${CC-cc} accepts -g" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -793,7 +804,7 @@ else { echo "configure: error: can not r
+ fi
+
+ echo $ac_n "checking host system type""... $ac_c" 1>&6
+-echo "configure:797: checking host system type" >&5
++echo "configure:808: checking host system type" >&5
+
+ host_alias=$host
+ case "$host_alias" in
+@@ -814,7 +825,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+ echo "$ac_t""$host" 1>&6
+
+ echo $ac_n "checking target system type""... $ac_c" 1>&6
+-echo "configure:818: checking target system type" >&5
++echo "configure:829: checking target system type" >&5
+
+ target_alias=$target
+ case "$target_alias" in
+@@ -832,7 +843,7 @@ target_os=`echo $target | sed 's/^\([^-]
+ echo "$ac_t""$target" 1>&6
+
+ echo $ac_n "checking build system type""... $ac_c" 1>&6
+-echo "configure:836: checking build system type" >&5
++echo "configure:847: checking build system type" >&5
+
+ build_alias=$build
+ case "$build_alias" in
+@@ -867,7 +878,7 @@ test "$host_alias" != "$target_alias" &&
+ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+ # ./install, which can be erroneously created by make from ./install.sh.
+ echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+-echo "configure:871: checking for a BSD compatible install" >&5
++echo "configure:882: checking for a BSD compatible install" >&5
+ if test -z "$INSTALL"; then
+ if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+@@ -921,7 +932,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA=
+
+
+ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+-echo "configure:925: checking how to run the C preprocessor" >&5
++echo "configure:936: checking how to run the C preprocessor" >&5
+ # On Suns, sometimes $CPP names a directory.
+ if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+@@ -936,13 +947,13 @@ else
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+-#line 940 "configure"
++#line 951 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:946: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+ :
+@@ -953,13 +964,13 @@ else
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+-#line 957 "configure"
++#line 968 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:963: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:974: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+ :
+@@ -970,13 +981,13 @@ else
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+-#line 974 "configure"
++#line 985 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:980: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+ :
+@@ -1001,12 +1012,12 @@ fi
+ echo "$ac_t""$CPP" 1>&6
+
+ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+-echo "configure:1005: checking for ANSI C header files" >&5
++echo "configure:1016: checking for ANSI C header files" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1010 "configure"
++#line 1021 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ #include <stdarg.h>
+@@ -1014,7 +1025,7 @@ else
+ #include <float.h>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1029: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+ rm -rf conftest*
+@@ -1031,7 +1042,7 @@ rm -f conftest*
+ if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat > conftest.$ac_ext <<EOF
+-#line 1035 "configure"
++#line 1046 "configure"
+ #include "confdefs.h"
+ #include <string.h>
+ EOF
+@@ -1049,7 +1060,7 @@ fi
+ if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat > conftest.$ac_ext <<EOF
+-#line 1053 "configure"
++#line 1064 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ EOF
+@@ -1070,7 +1081,7 @@ if test "$cross_compiling" = yes; then
+ :
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1074 "configure"
++#line 1085 "configure"
+ #include "confdefs.h"
+ #include <ctype.h>
+ #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+@@ -1081,7 +1092,7 @@ if (XOR (islower (i), ISLOWER (i)) || to
+ exit (0); }
+
+ EOF
+-if { (eval echo configure:1085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+ :
+ else
+@@ -1109,17 +1120,17 @@ for ac_hdr in sgtty.h termio.h termios.h
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:1113: checking for $ac_hdr" >&5
++echo "configure:1124: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1118 "configure"
++#line 1129 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1123: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1134: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+ rm -rf conftest*
+@@ -1147,12 +1158,12 @@ done
+
+
+ echo $ac_n "checking whether strerror must be declared""... $ac_c" 1>&6
+-echo "configure:1151: checking whether strerror must be declared" >&5
++echo "configure:1162: checking whether strerror must be declared" >&5
+ if eval "test \"`echo '$''{'bfd_cv_decl_needed_strerror'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1156 "configure"
++#line 1167 "configure"
+ #include "confdefs.h"
+
+ #include <stdio.h>
+@@ -1173,7 +1184,7 @@ int main() {
+ char *(*pfn) = (char *(*)) strerror
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1188: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_decl_needed_strerror=no
+ else
+@@ -1205,19 +1216,19 @@ fi
+
+ if test "${srv_linux_regsets}" = "yes"; then
+ echo $ac_n "checking for PTRACE_GETREGS""... $ac_c" 1>&6
+-echo "configure:1209: checking for PTRACE_GETREGS" >&5
++echo "configure:1220: checking for PTRACE_GETREGS" >&5
+ if eval "test \"`echo '$''{'gdbsrv_cv_have_ptrace_getregs'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1214 "configure"
++#line 1225 "configure"
+ #include "confdefs.h"
+ #include <sys/ptrace.h>
+ int main() {
+ PTRACE_GETREGS;
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ gdbsrv_cv_have_ptrace_getregs=yes
+ else
+@@ -1238,19 +1249,19 @@ EOF
+ fi
+
+ echo $ac_n "checking for PTRACE_GETFPXREGS""... $ac_c" 1>&6
+-echo "configure:1242: checking for PTRACE_GETFPXREGS" >&5
++echo "configure:1253: checking for PTRACE_GETFPXREGS" >&5
+ if eval "test \"`echo '$''{'gdbsrv_cv_have_ptrace_getfpxregs'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1247 "configure"
++#line 1258 "configure"
+ #include "confdefs.h"
+ #include <sys/ptrace.h>
+ int main() {
+ PTRACE_GETFPXREGS;
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ gdbsrv_cv_have_ptrace_getfpxregs=yes
+ else
+@@ -1273,12 +1284,12 @@ fi
+
+ if test "$ac_cv_header_sys_procfs_h" = yes; then
+ echo $ac_n "checking for lwpid_t in sys/procfs.h""... $ac_c" 1>&6
+-echo "configure:1277: checking for lwpid_t in sys/procfs.h" >&5
++echo "configure:1288: checking for lwpid_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpid_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1282 "configure"
++#line 1293 "configure"
+ #include "confdefs.h"
+
+ #define _SYSCALL32
+@@ -1287,7 +1298,7 @@ int main() {
+ lwpid_t avar
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1291: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1302: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_lwpid_t=yes
+ else
+@@ -1309,12 +1320,12 @@ EOF
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpid_t" 1>&6
+
+ echo $ac_n "checking for psaddr_t in sys/procfs.h""... $ac_c" 1>&6
+-echo "configure:1313: checking for psaddr_t in sys/procfs.h" >&5
++echo "configure:1324: checking for psaddr_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psaddr_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1318 "configure"
++#line 1329 "configure"
+ #include "confdefs.h"
+
+ #define _SYSCALL32
+@@ -1323,7 +1334,7 @@ int main() {
+ psaddr_t avar
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1338: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_psaddr_t=yes
+ else
+@@ -1345,12 +1356,12 @@ EOF
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_psaddr_t" 1>&6
+
+ echo $ac_n "checking for prgregset_t in sys/procfs.h""... $ac_c" 1>&6
+-echo "configure:1349: checking for prgregset_t in sys/procfs.h" >&5
++echo "configure:1360: checking for prgregset_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prgregset_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1354 "configure"
++#line 1365 "configure"
+ #include "confdefs.h"
+
+ #define _SYSCALL32
+@@ -1359,7 +1370,7 @@ int main() {
+ prgregset_t avar
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1363: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1374: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prgregset_t=yes
+ else
+@@ -1381,12 +1392,12 @@ EOF
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_prgregset_t" 1>&6
+
+ echo $ac_n "checking for prfpregset_t in sys/procfs.h""... $ac_c" 1>&6
+-echo "configure:1385: checking for prfpregset_t in sys/procfs.h" >&5
++echo "configure:1396: checking for prfpregset_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prfpregset_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1390 "configure"
++#line 1401 "configure"
+ #include "confdefs.h"
+
+ #define _SYSCALL32
+@@ -1395,7 +1406,7 @@ int main() {
+ prfpregset_t avar
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_prfpregset_t=yes
+ else
+@@ -1421,7 +1432,7 @@ EOF
+
+ if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then
+ echo $ac_n "checking whether prfpregset_t type is broken""... $ac_c" 1>&6
+-echo "configure:1425: checking whether prfpregset_t type is broken" >&5
++echo "configure:1436: checking whether prfpregset_t type is broken" >&5
+ if eval "test \"`echo '$''{'gdb_cv_prfpregset_t_broken'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1429,7 +1440,7 @@ else
+ gdb_cv_prfpregset_t_broken=yes
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1433 "configure"
++#line 1444 "configure"
+ #include "confdefs.h"
+ #include <sys/procfs.h>
+ int main ()
+@@ -1439,7 +1450,7 @@ else
+ return 0;
+ }
+ EOF
+-if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:1454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+ gdb_cv_prfpregset_t_broken=no
+ else
+@@ -1463,12 +1474,12 @@ EOF
+ fi
+
+ echo $ac_n "checking for elf_fpregset_t in sys/procfs.h""... $ac_c" 1>&6
+-echo "configure:1467: checking for elf_fpregset_t in sys/procfs.h" >&5
++echo "configure:1478: checking for elf_fpregset_t in sys/procfs.h" >&5
+ if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_elf_fpregset_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ cat > conftest.$ac_ext <<EOF
+-#line 1472 "configure"
++#line 1483 "configure"
+ #include "confdefs.h"
+
+ #define _SYSCALL32
+@@ -1477,7 +1488,7 @@ int main() {
+ elf_fpregset_t avar
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ bfd_cv_have_sys_procfs_type_elf_fpregset_t=yes
+ else
+@@ -1506,14 +1517,14 @@ USE_THREAD_DB=
+
+ if test "$srv_linux_thread_db" = "yes"; then
+ echo $ac_n "checking for libthread_db""... $ac_c" 1>&6
+-echo "configure:1510: checking for libthread_db" >&5
++echo "configure:1521: checking for libthread_db" >&5
+ if eval "test \"`echo '$''{'srv_cv_thread_db'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+ else
+ old_LIBS="$LIBS"
+ LIBS="$LIBS -lthread_db"
+ cat > conftest.$ac_ext <<EOF
+-#line 1517 "configure"
++#line 1528 "configure"
+ #include "confdefs.h"
+ void ps_pglobal_lookup() {}
+ void ps_pdread() {}
+@@ -1522,12 +1533,13 @@ void ps_pglobal_lookup() {}
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}
+ int main() {
+ td_ta_new();
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ srv_cv_thread_db="-lthread_db"
+ else
+@@ -1543,7 +1555,7 @@ else
+ fi
+ LIBS="$old_LIBS `eval echo "$thread_db"`"
+ cat > conftest.$ac_ext <<EOF
+-#line 1547 "configure"
++#line 1559 "configure"
+ #include "confdefs.h"
+ void ps_pglobal_lookup() {}
+ void ps_pdread() {}
+@@ -1552,12 +1564,13 @@ void ps_pglobal_lookup() {}
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}
+ int main() {
+ td_ta_new();
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ srv_cv_thread_db="$thread_db"
+ else
+@@ -1567,11 +1580,11 @@ else
+ srv_cv_thread_db=no
+ fi
+ rm -f conftest*
+- LIBS="$old_LIBS"
+-
++
+ fi
+
+ echo "$ac_t""$srv_cv_thread_db" 1>&6
++ LIBS="$old_LIBS"
+
+ fi
+ rm -f conftest*
+@@ -1585,14 +1598,14 @@ rm -f conftest*
+ old_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -rdynamic"
+ cat > conftest.$ac_ext <<EOF
+-#line 1589 "configure"
++#line 1602 "configure"
+ #include "confdefs.h"
+
+ int main() {
+
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ RDYNAMIC=-rdynamic
+ else
+Index: gdb-6.3/gdb/gdbserver/aclocal.m4
+===================================================================
+--- gdb-6.3.orig/gdb/gdbserver/aclocal.m4 2002-06-11 13:32:39.000000000 -0400
++++ gdb-6.3/gdb/gdbserver/aclocal.m4 2004-12-07 17:22:00.382495519 -0500
+@@ -1,4 +1,4 @@
+-dnl aclocal.m4 generated automatically by aclocal 1.4-p4
++dnl aclocal.m4 generated automatically by aclocal 1.4
+
+ dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+ dnl This file is free software; the Free Software Foundation
+@@ -25,6 +25,7 @@ AC_DEFUN([SRV_CHECK_THREAD_DB],
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}],
+ [td_ta_new();],
+ [srv_cv_thread_db="-lthread_db"],
+@@ -44,11 +45,12 @@ AC_DEFUN([SRV_CHECK_THREAD_DB],
+ void ps_lsetregs() {}
+ void ps_lgetfpregs() {}
+ void ps_lsetfpregs() {}
++ void ps_get_thread_area() {}
+ void ps_getpid() {}],
+ [td_ta_new();],
+ [srv_cv_thread_db="$thread_db"],
+ [srv_cv_thread_db=no])
++ ]])
+ LIBS="$old_LIBS"
+- ]])
+ )])
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/790-debian_dwarf2-cfi-warning.patch b/cleopatre/buildroot/toolchain/gdb/6.3/790-debian_dwarf2-cfi-warning.patch
new file mode 100644
index 0000000000..cfb3d95de5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/790-debian_dwarf2-cfi-warning.patch
@@ -0,0 +1,39 @@
+Status: Unsuitable for upstream (at least, without a lot of arguing).
+
+GCC does not specify the state of every last register in the CIE. Since
+GCC's focus is on correctness of runtime unwinding, any registers which
+have to be unwound will be specified; but unmodified registers will not
+be explicitly marked. (How about modified, call-clobbered registers?
+I'm not sure if they are marked as unavailable.)
+
+GDB issues a noisy warning about this. The warning is generally not useful,
+and we can get it extremely frequently (any time we load a new CIE).
+
+This patch disables the warning. Alternately we could set the complaints
+threshold to zero, or implement a default frame init-register method for
+every architecture. But someday the compiler will support using different
+calling conventions for internal functions, so that's not much of a stopgap.
+ARM has a complex algorithm for handling this, involving scanning all CIEs -
+benefit not completely clear outside of the ARM context of flexible register
+sets.
+
+Index: gdb-6.3/gdb/dwarf2-frame.c
+===================================================================
+--- gdb-6.3.orig/gdb/dwarf2-frame.c 2004-11-15 11:54:57.000000000 -0500
++++ gdb-6.3/gdb/dwarf2-frame.c 2004-12-08 18:02:23.896409471 -0500
+@@ -705,9 +705,12 @@ dwarf2_frame_cache (struct frame_info *n
+ table. We need a way of iterating through all the valid
+ DWARF2 register numbers. */
+ if (fs->regs.reg[column].how == DWARF2_FRAME_REG_UNSPECIFIED)
+- complaint (&symfile_complaints,
+- "Incomplete CFI data; unspecified registers at 0x%s",
+- paddr (fs->pc));
++ {
++ if (0)
++ complaint (&symfile_complaints,
++ "Incomplete CFI data; unspecified registers at 0x%s",
++ paddr (fs->pc));
++ }
+ else
+ cache->reg[regnum] = fs->regs.reg[column];
+ }
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/800-debian_linux-use-underscore-exit.patch b/cleopatre/buildroot/toolchain/gdb/6.3/800-debian_linux-use-underscore-exit.patch
new file mode 100644
index 0000000000..198918ccce
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/800-debian_linux-use-underscore-exit.patch
@@ -0,0 +1,22 @@
+Status: committed upstream after 6.3. Fixes some terminal mangling in
+gdbtui.
+
+2004-12-04 Daniel Jacobowitz <dan@debian.org>
+
+ PR tui/1703
+ * linux-nat.c (linux_tracefork_child): Use _exit instead of exit.
+ Suggested by Joshua Neuheisel.
+
+Index: gdb-6.3/gdb/linux-nat.c
+===================================================================
+--- gdb-6.3.orig/gdb/linux-nat.c 2004-12-08 18:22:04.996973094 -0500
++++ gdb-6.3/gdb/linux-nat.c 2004-12-08 18:22:20.386956067 -0500
+@@ -147,7 +147,7 @@ linux_tracefork_child (void)
+ ptrace (PTRACE_TRACEME, 0, 0, 0);
+ kill (getpid (), SIGSTOP);
+ fork ();
+- exit (0);
++ _exit (0);
+ }
+
+ /* Wrapper function for waitpid which handles EINTR. */
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/810-debian_bfd-no-kylix-crash.patch b/cleopatre/buildroot/toolchain/gdb/6.3/810-debian_bfd-no-kylix-crash.patch
new file mode 100644
index 0000000000..9aba5ca236
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/810-debian_bfd-no-kylix-crash.patch
@@ -0,0 +1,47 @@
+Status: committed upstream after 6.3.
+
+Fix a crash triggered by Kylix libraries.
+
+2004-12-06 Daniel Jacobowitz <dan@debian.org>
+
+ Suggested by Fergal Daly <fergal@esatclear.ie>:
+ * simple.c (simple_dummy_multiple_definition): New function.
+ (bfd_simple_get_relocated_section_contents): Use it.
+
+Index: src/bfd/simple.c
+===================================================================
+RCS file: /cvs/src/src/bfd/simple.c,v
+retrieving revision 1.19
+retrieving revision 1.20
+Index: gdb-6.3/bfd/simple.c
+===================================================================
+--- gdb-6.3.orig/bfd/simple.c 2004-09-24 03:07:19.000000000 -0400
++++ gdb-6.3/bfd/simple.c 2004-12-08 18:25:58.415216808 -0500
+@@ -78,6 +78,19 @@ simple_dummy_unattached_reloc (struct bf
+ return TRUE;
+ }
+
++static bfd_boolean
++simple_dummy_multiple_definition (struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
++ const char *name ATTRIBUTE_UNUSED,
++ bfd *obfd ATTRIBUTE_UNUSED,
++ asection *osec ATTRIBUTE_UNUSED,
++ bfd_vma oval ATTRIBUTE_UNUSED,
++ bfd *nbfd ATTRIBUTE_UNUSED,
++ asection *nsec ATTRIBUTE_UNUSED,
++ bfd_vma nval ATTRIBUTE_UNUSED)
++{
++ return TRUE;
++}
++
+ struct saved_output_info
+ {
+ bfd_vma offset;
+@@ -172,6 +185,7 @@ bfd_simple_get_relocated_section_content
+ callbacks.reloc_overflow = simple_dummy_reloc_overflow;
+ callbacks.reloc_dangerous = simple_dummy_reloc_dangerous;
+ callbacks.unattached_reloc = simple_dummy_unattached_reloc;
++ callbacks.multiple_definition = simple_dummy_multiple_definition;
+
+ memset (&link_order, 0, sizeof (link_order));
+ link_order.next = NULL;
diff --git a/cleopatre/buildroot/toolchain/gdb/6.3/820-debian_disable-linux-fork-messages.patch b/cleopatre/buildroot/toolchain/gdb/6.3/820-debian_disable-linux-fork-messages.patch
new file mode 100644
index 0000000000..60730abc19
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.3/820-debian_disable-linux-fork-messages.patch
@@ -0,0 +1,46 @@
+Status: Proposed upstream after 6.3, not yet committed.
+
+2004-12-06 Daniel Jacobowitz <dan@debian.org>
+
+ * linux-nat.c (child_follow_fork): Call target_terminal_ours before
+ printing output. Use fprintf_unfiltered. Only print output when
+ debugging.
+
+Index: gdb-6.3/gdb/linux-nat.c
+===================================================================
+--- gdb-6.3.orig/gdb/linux-nat.c 2004-12-08 18:22:20.386956067 -0500
++++ gdb-6.3/gdb/linux-nat.c 2004-12-08 18:28:49.995585970 -0500
+@@ -347,9 +347,13 @@ child_follow_fork (int follow_child)
+ also, but they'll be reinserted below. */
+ detach_breakpoints (child_pid);
+
+- fprintf_filtered (gdb_stdout,
+- "Detaching after fork from child process %d.\n",
+- child_pid);
++ if (debug_linux_nat)
++ {
++ target_terminal_ours ();
++ fprintf_unfiltered (gdb_stdlog,
++ "Detaching after fork from child process %d.\n",
++ child_pid);
++ }
+
+ ptrace (PTRACE_DETACH, child_pid, 0, 0);
+
+@@ -418,9 +422,13 @@ child_follow_fork (int follow_child)
+ /* Before detaching from the parent, remove all breakpoints from it. */
+ remove_breakpoints ();
+
+- fprintf_filtered (gdb_stdout,
+- "Attaching after fork to child process %d.\n",
+- child_pid);
++ if (debug_linux_nat)
++ {
++ target_terminal_ours ();
++ fprintf_unfiltered (gdb_stdlog,
++ "Attaching after fork to child process %d.\n",
++ child_pid);
++ }
+
+ /* If we're vforking, we may want to hold on to the parent until
+ the child exits or execs. At exec time we can remove the old
diff --git a/cleopatre/buildroot/toolchain/gdb/6.4/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.4/100-uclibc-conf.patch
new file mode 100644
index 0000000000..9d8fd4e69c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.4/100-uclibc-conf.patch
@@ -0,0 +1,78 @@
+--- gdb-6.3/bfd/configure.orig Fri Oct 8 16:53:56 2004
++++ gdb-6.3/bfd/configure Sun Feb 27 18:32:58 2005
+@@ -3583,6 +3583,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- gdb-6.3/libtool.m4.orig Wed Jul 21 21:21:41 2004
++++ gdb-6.3/libtool.m4 Mon Feb 28 00:08:11 2005
+@@ -653,6 +653,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
+ lt_cv_file_magic_cmd=/usr/bin/file
+--- gdb-6.3/ltconfig.orig Tue Oct 5 15:34:42 2004
++++ gdb-6.3/ltconfig Sun Feb 27 18:14:41 2005
+@@ -602,7 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1270,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- gdb-6.3/opcodes/configure.orig Fri Sep 17 08:13:38 2004
++++ gdb-6.3/opcodes/configure Mon Feb 28 00:09:42 2005
+@@ -3595,6 +3595,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
diff --git a/cleopatre/buildroot/toolchain/gdb/6.4/200-uclibc-readline-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.4/200-uclibc-readline-conf.patch
new file mode 100644
index 0000000000..ffe792dd05
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.4/200-uclibc-readline-conf.patch
@@ -0,0 +1,15 @@
+--- gdb-6.1.1-dist/readline/configure 2003-05-27 18:29:47.000000000 -0500
++++ gdb-6.1.1/readline/configure 2004-08-09 14:20:23.000000000 -0500
+@@ -6249,7 +6249,12 @@
+
+
+ echo "$as_me:$LINENO: checking for mbstate_t" >&5
++echo $ECHO_N "bash_cv_have_mbstate_t=$bash_cv_have_mbstate_t" >&6
+ echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
++if test "${bash_cv_have_mbstate_t+set}" != set; then
++ bash_cv_have_mbstate_t=yes
++ echo $ECHO_N "WARNING!! forcing to yes!!! $ECHO_C" >&6
++fi
+ if test "${bash_cv_have_mbstate_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
diff --git a/cleopatre/buildroot/toolchain/gdb/6.4/400-mips-coredump.patch-2.4.23-29 b/cleopatre/buildroot/toolchain/gdb/6.4/400-mips-coredump.patch-2.4.23-29
new file mode 100644
index 0000000000..4e17ba7bea
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.4/400-mips-coredump.patch-2.4.23-29
@@ -0,0 +1,28 @@
+Sometime around 2.4.22-23, the mips pt_regs.h fields were reordered, breaking
+coredump handling by gdb for current kernels. Update the hardcoded constants
+to reflect the change.
+--- gdb-6.2.1/gdb/mips-linux-tdep.c-orig 2004-10-29 14:23:55.000000000 -0500
++++ gdb-6.2.1/gdb/mips-linux-tdep.c 2004-10-29 14:26:44.000000000 -0500
+@@ -53,12 +53,22 @@
+
+ #define EF_REG0 6
+ #define EF_REG31 37
++
++#if 0
+ #define EF_LO 38
+ #define EF_HI 39
+ #define EF_CP0_EPC 40
+ #define EF_CP0_BADVADDR 41
+ #define EF_CP0_STATUS 42
+ #define EF_CP0_CAUSE 43
++#else
++#define EF_CP0_STATUS 38
++#define EF_LO 39
++#define EF_HI 40
++#define EF_CP0_BADVADDR 41
++#define EF_CP0_CAUSE 42
++#define EF_CP0_EPC 43
++#endif
+
+ #define EF_SIZE 180
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.4/500-thread-timeout.patch b/cleopatre/buildroot/toolchain/gdb/6.4/500-thread-timeout.patch
new file mode 100644
index 0000000000..6db0a7a474
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.4/500-thread-timeout.patch
@@ -0,0 +1,34 @@
+--- gdb-6.3.org/gdb/gdbserver/thread-db.c 2004-10-17 02:42:00.000000000 +0900
++++ gdb-6.3/gdb/gdbserver/thread-db.c 2005-01-27 12:19:29.000000000 +0900
+@@ -21,6 +21,7 @@
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
++#include <unistd.h>
+ #include "server.h"
+
+ #include "linux-low.h"
+@@ -142,6 +143,7 @@
+ td_event_msg_t msg;
+ td_err_e err;
+ struct inferior_linux_data *tdata;
++ int timeout;
+
+ if (debug_threads)
+ fprintf (stderr, "Thread creation event.\n");
+@@ -152,7 +154,13 @@
+ In the LinuxThreads implementation, this is safe,
+ because all events come from the manager thread
+ (except for its own creation, of course). */
+- err = td_ta_event_getmsg (thread_agent, &msg);
++ for (timeout = 0; timeout < 50000; timeout++)
++ {
++ err = td_ta_event_getmsg (thread_agent, &msg);
++ if (err != TD_NOMSG)
++ break;
++ usleep(1000);
++ }
+ if (err != TD_OK)
+ fprintf (stderr, "thread getmsg err: %s\n",
+ thread_db_err_str (err));
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.4/600-fix-compile-flag-mismatch.patch b/cleopatre/buildroot/toolchain/gdb/6.4/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000000..659a5f03a8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.4/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,87 @@
+diff -ur gdb-6.4/gdb/configure gdb-6.4-patched/gdb/configure
+--- gdb-6.4/gdb/configure 2005-07-25 10:08:40.000000000 -0500
++++ gdb-6.4-patched/gdb/configure 2007-02-05 13:22:36.000000000 -0600
+@@ -309,7 +309,7 @@
+ # include <unistd.h>
+ #endif"
+
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ ac_subdirs_all="$ac_subdirs_all gdbtk"
+ ac_subdirs_all="$ac_subdirs_all multi-ice"
+ ac_subdirs_all="$ac_subdirs_all gdbserver"
+@@ -5940,7 +5940,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ . $srcdir/configure.host
+diff -ur gdb-6.4/gdb/gdbserver/configure gdb-6.4-patched/gdb/gdbserver/configure
+--- gdb-6.4/gdb/gdbserver/configure 2005-09-17 18:14:37.000000000 -0500
++++ gdb-6.4-patched/gdb/gdbserver/configure 2007-02-05 13:22:58.000000000 -0600
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val`" != "`echo $ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+diff -ur gdb-6.4/gdb/testsuite/configure gdb-6.4-patched/gdb/testsuite/configure
+--- gdb-6.4/gdb/testsuite/configure 2005-04-11 09:13:12.000000000 -0500
++++ gdb-6.4-patched/gdb/testsuite/configure 2007-02-05 13:22:36.000000000 -0600
+@@ -1248,7 +1248,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val" != "`echo $ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+diff -ur gdb-6.4/Makefile.in gdb-6.4-patched/Makefile.in
+--- gdb-6.4/Makefile.in 2005-12-01 23:29:54.000000000 -0600
++++ gdb-6.4-patched/Makefile.in 2007-02-05 13:22:36.000000000 -0600
+@@ -383,7 +383,7 @@
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+
+ # If GCC_FOR_TARGET is not overriden on the command line, then this
+@@ -423,7 +423,7 @@
+ fi; \
+ fi`
+
+-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CXXFLAGS_FOR_TARGET = $(strip $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
+
+ GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
+diff -ur gdb-6.4/Makefile.tpl gdb-6.4-patched/Makefile.tpl
+--- gdb-6.4/Makefile.tpl 2005-10-22 05:37:55.000000000 -0500
++++ gdb-6.4-patched/Makefile.tpl 2007-02-05 13:22:36.000000000 -0600
+@@ -386,7 +386,7 @@
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+
+ # If GCC_FOR_TARGET is not overriden on the command line, then this
+@@ -426,7 +426,7 @@
+ fi; \
+ fi`
+
+-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CXXFLAGS_FOR_TARGET = $(strip $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
+
+ GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
diff --git a/cleopatre/buildroot/toolchain/gdb/6.5/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.5/100-uclibc-conf.patch
new file mode 100644
index 0000000000..33f0af9251
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.5/100-uclibc-conf.patch
@@ -0,0 +1,78 @@
+--- a/bfd/configure
++++ b/bfd/configure
+@@ -3580,6 +3580,11 @@
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+--- a/libtool.m4
++++ b/libtool.m4
+@@ -751,6 +751,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
+ lt_cv_file_magic_cmd=/usr/bin/file
+--- a/ltconfig
++++ b/ltconfig
+@@ -602,7 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1270,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+--- a/opcodes/configure
++++ b/opcodes/configure
+@@ -3591,6 +3591,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
diff --git a/cleopatre/buildroot/toolchain/gdb/6.5/200-uclibc-readline-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.5/200-uclibc-readline-conf.patch
new file mode 100644
index 0000000000..e05eaa4df5
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.5/200-uclibc-readline-conf.patch
@@ -0,0 +1,15 @@
+--- a/readline/configure
++++ b/readline/configure
+@@ -7871,7 +7871,12 @@
+
+
+ echo "$as_me:$LINENO: checking for mbstate_t" >&5
++echo $ECHO_N "bash_cv_have_mbstate_t=$bash_cv_have_mbstate_t" >&6
+ echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
++if test "${bash_cv_have_mbstate_t+set}" != set; then
++ bash_cv_have_mbstate_t=yes
++ echo $ECHO_N "WARNING!! forcing to yes!!! $ECHO_C" >&6
++fi
+ if test "${bash_cv_have_mbstate_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
diff --git a/cleopatre/buildroot/toolchain/gdb/6.5/400-mips-coredump.patch-2.4.23-29 b/cleopatre/buildroot/toolchain/gdb/6.5/400-mips-coredump.patch-2.4.23-29
new file mode 100644
index 0000000000..d00740d076
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.5/400-mips-coredump.patch-2.4.23-29
@@ -0,0 +1,28 @@
+Sometime around 2.4.22-23, the mips pt_regs.h fields were reordered, breaking
+coredump handling by gdb for current kernels. Update the hardcoded constants
+to reflect the change.
+--- a/gdb/mips-linux-tdep.h
++++ b/gdb/mips-linux-tdep.h
+@@ -41,12 +41,22 @@
+
+ #define EF_REG0 6
+ #define EF_REG31 37
++
++#if 0
+ #define EF_LO 38
+ #define EF_HI 39
+ #define EF_CP0_EPC 40
+ #define EF_CP0_BADVADDR 41
+ #define EF_CP0_STATUS 42
+ #define EF_CP0_CAUSE 43
++#else
++#define EF_CP0_STATUS 38
++#define EF_LO 39
++#define EF_HI 40
++#define EF_CP0_BADVADDR 41
++#define EF_CP0_CAUSE 42
++#define EF_CP0_EPC 43
++#endif
+
+ #define EF_SIZE 180
+
diff --git a/cleopatre/buildroot/toolchain/gdb/6.5/500-thread-timeout.patch b/cleopatre/buildroot/toolchain/gdb/6.5/500-thread-timeout.patch
new file mode 100644
index 0000000000..9380253b79
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.5/500-thread-timeout.patch
@@ -0,0 +1,33 @@
+--- a/gdb/gdbserver/thread-db.c
++++ b/gdb/gdbserver/thread-db.c
+@@ -21,6 +21,7 @@
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
++#include <unistd.h>
+ #include "server.h"
+
+ #include "linux-low.h"
+@@ -134,6 +135,7 @@
+ td_event_msg_t msg;
+ td_err_e err;
+ struct inferior_linux_data *tdata;
++ int timeout;
+
+ if (debug_threads)
+ fprintf (stderr, "Thread creation event.\n");
+@@ -144,7 +146,13 @@
+ In the LinuxThreads implementation, this is safe,
+ because all events come from the manager thread
+ (except for its own creation, of course). */
+- err = td_ta_event_getmsg (thread_agent, &msg);
++ for (timeout = 0; timeout < 50000; timeout++)
++ {
++ err = td_ta_event_getmsg (thread_agent, &msg);
++ if (err != TD_NOMSG)
++ break;
++ usleep(1000);
++ }
+ if (err != TD_OK)
+ fprintf (stderr, "thread getmsg err: %s\n",
+ thread_db_err_str (err));
diff --git a/cleopatre/buildroot/toolchain/gdb/6.5/600-fix-compile-flag-mismatch.patch b/cleopatre/buildroot/toolchain/gdb/6.5/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000000..08100bfb83
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.5/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,64 @@
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -309,7 +309,7 @@
+ # include <unistd.h>
+ #endif"
+
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ ac_subdirs_all="$ac_subdirs_all gdbtk"
+ ac_subdirs_all="$ac_subdirs_all multi-ice"
+ ac_subdirs_all="$ac_subdirs_all gdbserver"
+@@ -5939,7 +5939,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val`" != "`echo $ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/gdb/testsuite/configure
++++ b/gdb/testsuite/configure
+@@ -1248,7 +1248,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val" != "`echo $ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -329,7 +329,7 @@
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+ CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+--- a/Makefile.tpl
++++ b/Makefile.tpl
+@@ -332,7 +332,7 @@
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+ CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
diff --git a/cleopatre/buildroot/toolchain/gdb/6.6/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/6.6/100-uclibc-conf.patch
new file mode 100644
index 0000000000..a790b6f0f1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.6/100-uclibc-conf.patch
@@ -0,0 +1,82 @@
+diff -rNdup gdb-6.6.orig/bfd/configure gdb-6.6/bfd/configure
+--- gdb-6.6.orig/bfd/configure 2006-10-25 08:49:20.000000000 +0200
++++ gdb-6.6/bfd/configure 2007-05-14 10:35:50.000000000 +0200
+@@ -3579,6 +3579,11 @@ linux-gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -rNdup gdb-6.6.orig/libtool.m4 gdb-6.6/libtool.m4
+--- gdb-6.6.orig/libtool.m4 2005-12-27 17:37:57.000000000 +0100
++++ gdb-6.6/libtool.m4 2007-05-14 10:35:50.000000000 +0200
+@@ -751,6 +751,11 @@ netbsd* | knetbsd*-gnu)
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
+ lt_cv_file_magic_cmd=/usr/bin/file
+diff -rNdup gdb-6.6.orig/ltconfig gdb-6.6/ltconfig
+--- gdb-6.6.orig/ltconfig 2006-07-04 22:31:03.000000000 +0200
++++ gdb-6.6/ltconfig 2007-05-14 10:35:50.000000000 +0200
+@@ -602,7 +602,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1270,24 @@ linux-gnu*)
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -rNdup gdb-6.6.orig/opcodes/configure gdb-6.6/opcodes/configure
+--- gdb-6.6.orig/opcodes/configure 2006-10-25 08:49:20.000000000 +0200
++++ gdb-6.6/opcodes/configure 2007-05-14 10:35:50.000000000 +0200
+@@ -3590,6 +3590,11 @@ netbsd* | knetbsd*-gnu)
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
diff --git a/cleopatre/buildroot/toolchain/gdb/6.6/600-fix-compile-flag-mismatch.patch b/cleopatre/buildroot/toolchain/gdb/6.6/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000000..60f0ace653
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.6/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,69 @@
+diff -rduNp gdb-6.6-100/Makefile.in gdb-6.6/Makefile.in
+--- gdb-6.6-100/Makefile.in 2006-12-18 08:21:19.000000000 +0100
++++ gdb-6.6/Makefile.in 2007-05-14 10:54:29.000000000 +0200
+@@ -331,7 +331,7 @@ COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+ CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+diff -rduNp gdb-6.6-100/Makefile.tpl gdb-6.6/Makefile.tpl
+--- gdb-6.6-100/Makefile.tpl 2006-11-15 00:26:39.000000000 +0100
++++ gdb-6.6/Makefile.tpl 2007-05-14 10:54:29.000000000 +0200
+@@ -334,7 +334,7 @@ COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_
+ # CFLAGS will be just -g. We want to ensure that TARGET libraries
+ # (which we know are built with gcc) are built with optimizations so
+ # prepend -O2 when setting CFLAGS_FOR_TARGET.
+-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
++CFLAGS_FOR_TARGET = $(strip $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
+ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+ CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
+diff -rduNp gdb-6.6-100/gdb/configure gdb-6.6/gdb/configure
+--- gdb-6.6-100/gdb/configure 2006-12-17 16:38:59.000000000 +0100
++++ gdb-6.6/gdb/configure 2007-05-14 10:55:41.000000000 +0200
+@@ -272,7 +272,7 @@ PACKAGE_STRING=
+ PACKAGE_BUGREPORT=
+
+ ac_unique_file="main.c"
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ # Factoring default headers for most tests.
+ ac_includes_default="\
+ #include <stdio.h>
+@@ -3055,7 +3055,7 @@ _ACEOF
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
+diff -rduNp gdb-6.6-100/gdb/gdbserver/configure gdb-6.6/gdb/gdbserver/configure
+--- gdb-6.6-100/gdb/gdbserver/configure 2006-11-22 01:10:19.000000000 +0100
++++ gdb-6.6/gdb/gdbserver/configure 2007-05-14 10:54:29.000000000 +0200
+@@ -1239,7 +1239,7 @@ echo "$as_me: error: \`$ac_var' was not
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val`" != "`echo $ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+diff -rduNp gdb-6.6-100/gdb/testsuite/configure gdb-6.6/gdb/testsuite/configure
+--- gdb-6.6-100/gdb/testsuite/configure 2006-06-21 15:57:21.000000000 +0200
++++ gdb-6.6/gdb/testsuite/configure 2007-05-14 10:54:29.000000000 +0200
+@@ -1248,7 +1248,7 @@ echo "$as_me: error: \`$ac_var' was not
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo $ac_old_val" != "`echo $ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
diff --git a/cleopatre/buildroot/toolchain/gdb/6.6/700-nios2-6.6.patch b/cleopatre/buildroot/toolchain/gdb/6.6/700-nios2-6.6.patch
new file mode 100644
index 0000000000..509bcbd816
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.6/700-nios2-6.6.patch
@@ -0,0 +1,7978 @@
+diff --git a/bfd/Makefile.am b/bfd/Makefile.am
+index 435b30b..488c4ab 100644
+--- a/bfd/Makefile.am
++++ b/bfd/Makefile.am
+@@ -92,6 +92,7 @@ ALL_MACHINES = \
+ cpu-maxq.lo \
+ cpu-mcore.lo \
+ cpu-mips.lo \
++ cpu-nios2.lo \
+ cpu-mmix.lo \
+ cpu-mt.lo \
+ cpu-msp430.lo \
+@@ -156,6 +157,7 @@ ALL_MACHINES_CFILES = \
+ cpu-maxq.c \
+ cpu-mcore.c \
+ cpu-mips.c \
++ cpu-nios2.c \
+ cpu-mmix.c \
+ cpu-mt.c \
+ cpu-msp430.c \
+@@ -270,6 +272,7 @@ BFD32_BACKENDS = \
+ elf32-mips.lo \
+ elf32-mt.lo \
+ elf32-msp430.lo \
++ elf32-nios2.lo \
+ elf32-openrisc.lo \
+ elf32-or32.lo \
+ elf32-pj.lo \
+@@ -446,6 +449,7 @@ BFD32_BACKENDS_CFILES = \
+ elf32-mips.c \
+ elf32-mt.c \
+ elf32-msp430.c \
++ elf32-nios2.c \
+ elf32-openrisc.c \
+ elf32-or32.c \
+ elf32-pj.c \
+@@ -1065,6 +1069,7 @@ cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-maxq.lo: cpu-maxq.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mcore.lo: cpu-mcore.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mips.lo: cpu-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
++cpu-nios2.lo: cpu-nios2.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mmix.lo: cpu-mmix.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mt.lo: cpu-mt.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-msp430.lo: cpu-msp430.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+@@ -1428,6 +1433,10 @@ elf32-msp430.lo: elf32-msp430.c $(INCDIR)/filenames.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/msp430.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
++elf32-nios2.lo: elf32-nios2.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
++ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/elf/nios2.h \
++ $(INCDIR)/elf/reloc-macros.h elf32-target.h
+ elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+diff --git a/bfd/Makefile.in b/bfd/Makefile.in
+index 5bde689..5e57321 100644
+--- a/bfd/Makefile.in
++++ b/bfd/Makefile.in
+@@ -327,6 +327,7 @@ ALL_MACHINES = \
+ cpu-mt.lo \
+ cpu-msp430.lo \
+ cpu-or32.lo \
++ cpu-nios2.lo \
+ cpu-ns32k.lo \
+ cpu-openrisc.lo \
+ cpu-pdp11.lo \
+@@ -391,6 +392,7 @@ ALL_MACHINES_CFILES = \
+ cpu-mt.c \
+ cpu-msp430.c \
+ cpu-or32.c \
++ cpu-nios2.c \
+ cpu-ns32k.c \
+ cpu-openrisc.c \
+ cpu-pdp11.c \
+@@ -502,6 +504,7 @@ BFD32_BACKENDS = \
+ elf32-mips.lo \
+ elf32-mt.lo \
+ elf32-msp430.lo \
++ elf32-nios2.lo \
+ elf32-openrisc.lo \
+ elf32-or32.lo \
+ elf32-pj.lo \
+@@ -678,6 +681,7 @@ BFD32_BACKENDS_CFILES = \
+ elf32-mips.c \
+ elf32-mt.c \
+ elf32-msp430.c \
++ elf32-nios2.c \
+ elf32-openrisc.c \
+ elf32-or32.c \
+ elf32-pj.c \
+@@ -1626,6 +1630,7 @@ cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-maxq.lo: cpu-maxq.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mcore.lo: cpu-mcore.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mips.lo: cpu-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
++cpu-nios2.lo: cpu-nios2.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mmix.lo: cpu-mmix.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-mt.lo: cpu-mt.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+ cpu-msp430.lo: cpu-msp430.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+@@ -1989,6 +1994,10 @@ elf32-msp430.lo: elf32-msp430.c $(INCDIR)/filenames.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(INCDIR)/elf/msp430.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
++elf32-nios2.lo: elf32-nios2.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
++ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
++ $(INCDIR)/elf/external.h $(INCDIR)/elf/nios2.h \
++ $(INCDIR)/elf/reloc-macros.h elf32-target.h
+ elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+diff --git a/bfd/archures.c b/bfd/archures.c
+index 5029cb0..ece60b4 100644
+--- a/bfd/archures.c
++++ b/bfd/archures.c
+@@ -381,6 +381,8 @@ DESCRIPTION
+ . bfd_arch_maxq, {* Dallas MAXQ 10/20 *}
+ .#define bfd_mach_maxq10 10
+ .#define bfd_mach_maxq20 20
++. bfd_arch_nios2,
++.#define bfd_mach_nios2 1
+ . bfd_arch_z80,
+ .#define bfd_mach_z80strict 1 {* No undocumented opcodes. *}
+ .#define bfd_mach_z80 3 {* With ixl, ixh, iyl, and iyh. *}
+@@ -462,6 +464,7 @@ extern const bfd_arch_info_type bfd_mn10300_arch;
+ extern const bfd_arch_info_type bfd_msp430_arch;
+ extern const bfd_arch_info_type bfd_mt_arch;
+ extern const bfd_arch_info_type bfd_ns32k_arch;
++extern const bfd_arch_info_type bfd_nios2_arch;
+ extern const bfd_arch_info_type bfd_openrisc_arch;
+ extern const bfd_arch_info_type bfd_or32_arch;
+ extern const bfd_arch_info_type bfd_pdp11_arch;
+@@ -530,6 +533,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
+ &bfd_mn10300_arch,
+ &bfd_mt_arch,
+ &bfd_msp430_arch,
++ &bfd_nios2_arch,
+ &bfd_ns32k_arch,
+ &bfd_openrisc_arch,
+ &bfd_or32_arch,
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index 8f2af8b..f5c51d6 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -2010,6 +2010,8 @@ enum bfd_architecture
+ bfd_arch_maxq, /* Dallas MAXQ 10/20 */
+ #define bfd_mach_maxq10 10
+ #define bfd_mach_maxq20 20
++ bfd_arch_nios2,
++#define bfd_mach_nios2 1
+ bfd_arch_z80,
+ #define bfd_mach_z80strict 1 /* No undocumented opcodes. */
+ #define bfd_mach_z80 3 /* With ixl, ixh, iyl, and iyh. */
+@@ -4271,6 +4273,23 @@ internally by the linker after analysis of a
+ BFD_RELOC_XTENSA_ASM_EXPAND. */
+ BFD_RELOC_XTENSA_ASM_SIMPLIFY,
+
++/* Relocations used by the Altera New Jersey core */
++ BFD_RELOC_NIOS2_S16,
++ BFD_RELOC_NIOS2_U16,
++ BFD_RELOC_NIOS2_CALL26,
++ BFD_RELOC_NIOS2_IMM5,
++ BFD_RELOC_NIOS2_CACHE_OPX,
++ BFD_RELOC_NIOS2_IMM6,
++ BFD_RELOC_NIOS2_IMM8,
++ BFD_RELOC_NIOS2_HI16,
++ BFD_RELOC_NIOS2_LO16,
++ BFD_RELOC_NIOS2_HIADJ16,
++ BFD_RELOC_NIOS2_GPREL,
++ BFD_RELOC_NIOS2_UJMP,
++ BFD_RELOC_NIOS2_CJMP,
++ BFD_RELOC_NIOS2_CALLR,
++ BFD_RELOC_NIOS2_ALIGN,
++
+ /* 8 bit signed offset in (ix+d) or (iy+d). */
+ BFD_RELOC_Z80_DISP8,
+
+diff --git a/bfd/config.bfd b/bfd/config.bfd
+old mode 100755
+new mode 100644
+index 9b81db7..fa86103
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -88,6 +88,7 @@ m68*) targ_archs=bfd_m68k_arch ;;
+ m88*) targ_archs=bfd_m88k_arch ;;
+ maxq*) targ_archs=bfd_maxq_arch ;;
+ mips*) targ_archs=bfd_mips_arch ;;
++nios2*) targ_archs=bfd_nios2_arch ;;
+ or32*) targ_archs=bfd_or32_arch ;;
+ pdp11*) targ_archs=bfd_pdp11_arch ;;
+ pj*) targ_archs="bfd_pj_arch bfd_i386_arch";;
+@@ -985,6 +986,21 @@ case "${targ}" in
+ targ_underscore=yes
+ ;;
+
++ nios2eb-*-*)
++ targ_defvec=bfd_elf32_bignios2_vec
++ targ_selvecs=bfd_elf32_littlenios2_vec
++ ;;
++
++ nios2el-*-*)
++ targ_defvec=bfd_elf32_littlenios2_vec
++ targ_selvecs=bfd_elf32_bignios2_vec
++ ;;
++
++ nios2-*-*)
++ targ_defvec=bfd_elf32_littlenios2_vec
++ targ_selvecs=bfd_elf32_bignios2_vec
++ ;;
++
+ openrisc-*-elf)
+ targ_defvec=bfd_elf32_openrisc_vec
+ ;;
+diff --git a/bfd/configure b/bfd/configure
+index bc138ff..a64fef5 100755
+--- a/bfd/configure
++++ b/bfd/configure
+@@ -10846,6 +10846,8 @@ do
+ bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf32_littlemips_vxworks_vec)
+ tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
++ bfd_elf32_littlenios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
++ bfd_elf32_bignios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
+ bfd_elf32_m32c_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;;
+ bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
+ bfd_elf32_m32rle_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
+diff --git a/bfd/configure.in b/bfd/configure.in
+index fa0d50f..eb1e5f6 100644
+--- a/bfd/configure.in
++++ b/bfd/configure.in
+@@ -655,6 +655,8 @@ do
+ bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
++ bfd_elf32_littlenios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
++ bfd_elf32_bignios2_vec) tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
+ bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
+ bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;;
+ bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";;
+diff --git a/bfd/cpu-nios2.c b/bfd/cpu-nios2.c
+new file mode 100644
+index 0000000..c8f39c9
+--- /dev/null
++++ b/bfd/cpu-nios2.c
+@@ -0,0 +1,70 @@
++/* bfd back-end for Altera Nios II support
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include "bfd.h"
++#include "sysdep.h"
++#include "libbfd.h"
++
++static const bfd_arch_info_type *nios2_compatible
++ (const bfd_arch_info_type *, const bfd_arch_info_type *);
++
++/* The default routine tests bits_per_word, which is wrong on mips as
++ mips word size doesn't correlate with reloc size. */
++
++static const bfd_arch_info_type *
++nios2_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
++{
++ if (a->arch != b->arch)
++ return NULL;
++
++ /* Machine compatibility is checked in
++ _bfd_mips_elf_merge_private_bfd_data. */
++
++ return a;
++}
++
++#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
++ { \
++ BITS_WORD, /* bits in a word */ \
++ BITS_ADDR, /* bits in an address */ \
++ 8, /* 8 bits in a byte */ \
++ bfd_arch_nios2, \
++ NUMBER, \
++ "nios2", \
++ PRINT, \
++ 3, \
++ DEFAULT, \
++ nios2_compatible, \
++ bfd_default_scan, \
++ NEXT, \
++ }
++
++#define NN(index) (&arch_info_struct[(index) + 1])
++
++static const bfd_arch_info_type arch_info_struct[] =
++{
++ N (32, 32, bfd_mach_nios2, "nios2", FALSE, 0),
++};
++
++/* There is only one architecture - but we give the default a machine number of 0
++ so the linker can distinguish it */
++const bfd_arch_info_type bfd_nios2_arch =
++N (32, 32, 0, "nios2", TRUE, &arch_info_struct[0]);
+diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
+new file mode 100644
+index 0000000..f9ba1a0
+--- /dev/null
++++ b/bfd/elf32-nios2.c
+@@ -0,0 +1,2193 @@
++/* New Jersey-specific support for 32-bit ELF
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++/* This file handles Altera New Jersey ELF targets */
++
++#include "bfd.h"
++#include "sysdep.h"
++#include "libbfd.h"
++#include "bfdlink.h"
++#include "genlink.h"
++#include "elf-bfd.h"
++#include "elf/nios2.h"
++#include "opcode/nios2.h"
++
++/* use RELA relocations*/
++#ifndef USE_RELA
++#define USE_RELA
++#endif
++
++#ifdef USE_REL
++#undef USE_REL
++#endif
++
++/* Function prototypes */
++
++static reloc_howto_type *nios2_elf32_bfd_reloc_type_lookup
++ (bfd *, bfd_reloc_code_real_type);
++
++static bfd_boolean nios2_elf32_relax_section
++ (bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
++
++static bfd_boolean nios2_elf32_relax_delete_bytes
++ (bfd *, asection *, bfd_vma, int);
++
++static reloc_howto_type *nios2_elf32_rtype_to_howto
++ (unsigned int r_type, bfd_boolean rela_p);
++
++static void nios2_elf32_info_to_howto
++ (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst);
++
++static bfd_boolean nios2_elf32_relocate_section
++ (bfd * output_bfd, struct bfd_link_info * info, bfd * input_bfd,
++ asection * input_section, bfd_byte * contents,
++ Elf_Internal_Rela * relocs, Elf_Internal_Sym * local_syms,
++ asection ** local_sections);
++
++static reloc_howto_type *lookup_howto (unsigned int rtype);
++
++static bfd_reloc_status_type nios2_elf_final_gp
++ (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *,
++ struct bfd_link_info *);
++
++static bfd_boolean nios2_elf_assign_gp
++ (bfd *, bfd_vma *, struct bfd_link_info *);
++
++static bfd_reloc_status_type nios2_elf32_ignore_reloc
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_hi16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_lo16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_hiadj16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_pcrel16_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_call26_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_gprel_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_ujmp_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_cjmp_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_callr_relocate
++ (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
++
++static bfd_reloc_status_type nios2_elf32_do_hi16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_lo16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_hiadj16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_pcrel16_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_call26_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_gprel_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_ujmp_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_cjmp_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++static bfd_reloc_status_type nios2_elf32_do_callr_relocate
++ (bfd *, reloc_howto_type *, asection *,
++ bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
++
++
++static void nios2_elf32_post_process_headers
++ (bfd *, struct bfd_link_info *);
++
++static bfd_boolean nios2_elf32_section_from_shdr
++ (bfd *, Elf_Internal_Shdr *, const char *name, int shindex);
++
++static bfd_boolean nios2_elf32_section_flags
++ (flagword *, const Elf_Internal_Shdr *);
++
++static bfd_boolean nios2_elf32_fake_sections
++ (bfd *, Elf_Internal_Shdr *, asection *);
++
++
++
++static bfd_boolean nios2_elf32_check_relocs
++ (bfd *, struct bfd_link_info *, asection *,
++ const Elf_Internal_Rela *);
++
++static asection *nios2_elf32_gc_mark_hook (asection * sec,
++ struct bfd_link_info *
++ info,
++ Elf_Internal_Rela * rel,
++ struct elf_link_hash_entry
++ * h,
++ Elf_Internal_Sym * sym);
++
++
++/* target vector */
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
++
++/* The relocation table used for SHT_REL sections. */
++
++static reloc_howto_type elf_nios2_howto_table_rel[] = {
++ /* No relocation. */
++ HOWTO (R_NIOS2_NONE, /* type */
++ 0, /* rightshift */
++ 0, /* size (0 = byte, 1 = short, 2 = long) */
++ 0, /* bitsize */
++ FALSE, /* pc_relative */
++ 0, /* bitpos */
++ complain_overflow_dont, /* complain_on_overflow */
++ bfd_elf_generic_reloc, /* special_function */
++ "R_NIOS2_NONE", /* name */
++ FALSE, /* partial_inplace */
++ 0, /* src_mask */
++ 0, /* dst_mask */
++ FALSE), /* pcrel_offset */
++
++ /* 16-bit signed immediate relocation */
++ HOWTO (R_NIOS2_S16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_signed, /* complain on overflow */
++ bfd_elf_generic_reloc, /* special function */
++ "R_NIOS2_S16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ FALSE), /* pcrel_offset */
++
++ /* 16-bit unsigned immediate relocation */
++ HOWTO (R_NIOS2_U16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_unsigned, /* complain on overflow */
++ bfd_elf_generic_reloc, /* special function */
++ "R_NIOS2_U16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ FALSE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_PCREL16, /* type */
++ 0, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 16, /* bitsize */
++ TRUE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_signed, /* complain on overflow */
++ nios2_elf32_pcrel16_relocate, /* special function */
++ "R_NIOS2_PCREL16", /* name */
++ FALSE, /* partial_inplace */
++ 0x003fffc0, /* src_mask */
++ 0x003fffc0, /* dest_mask */
++ TRUE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_CALL26, /* type */
++ 2, /* rightshift */
++ 2, /* size (0 = byte, 1 = short, 2 = long) */
++ 26, /* bitsize */
++ FALSE, /* pc_relative */
++ 6, /* bitpos */
++ complain_overflow_dont, /* complain on overflow */
++ nios2_elf32_call26_relocate, /* special function */
++ "R_NIOS2_CALL26", /* name */
++ FALSE, /* partial_inplace */
++ 0xffffffc0, /* src_mask */
++ 0xffffffc0, /* dst_mask */
++ FALSE), /* pcrel_offset */
++
++ HOWTO (R_NIOS2_IMM5,
++ 0,
++ 2,
++ 5,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM5",
++ FALSE,
++ 0x000007c0,
++ 0x000007c0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CACHE_OPX,
++ 0,
++ 2,
++ 5,
++ FALSE,
++ 22,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_CACHE_OPX",
++ FALSE,
++ 0x07c00000,
++ 0x07c00000,
++ FALSE),
++
++ HOWTO (R_NIOS2_IMM6,
++ 0,
++ 2,
++ 6,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM6",
++ FALSE,
++ 0x00000fc0,
++ 0x00000fc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_IMM8,
++ 0,
++ 2,
++ 8,
++ FALSE,
++ 6,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_IMM8",
++ FALSE,
++ 0x00003fc0,
++ 0x00003fc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_HI16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_hi16_relocate,
++ "R_NIOS2_HI16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_LO16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_lo16_relocate,
++ "R_NIOS2_LO16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_HIADJ16,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_hiadj16_relocate,
++ "R_NIOS2_HIADJ16",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_32,
++ 0,
++ 2, /* long */
++ 32,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC32",
++ FALSE,
++ 0xffffffff,
++ 0xffffffff,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_16,
++ 0,
++ 1, /* short */
++ 16,
++ FALSE,
++ 0,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC16",
++ FALSE,
++ 0x0000ffff,
++ 0x0000ffff,
++ FALSE),
++
++ HOWTO (R_NIOS2_BFD_RELOC_8,
++ 0,
++ 0, /* byte */
++ 8,
++ FALSE,
++ 0,
++ complain_overflow_bitfield,
++ bfd_elf_generic_reloc,
++ "R_NIOS2_BFD_RELOC8",
++ FALSE,
++ 0x000000ff,
++ 0x000000ff,
++ FALSE),
++
++ HOWTO (R_NIOS2_GPREL,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_gprel_relocate,
++ "R_NIOS2_GPREL",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_GNU_VTINHERIT,
++ 0,
++ 2, /* short */
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ NULL,
++ "R_NIOS2_GNU_VTINHERIT",
++ FALSE,
++ 0,
++ 0,
++ FALSE),
++
++ HOWTO (R_NIOS2_GNU_VTENTRY,
++ 0,
++ 2, /* byte */
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ _bfd_elf_rel_vtable_reloc_fn,
++ "R_NIOS2_GNU_VTENTRY",
++ FALSE,
++ 0,
++ 0,
++ FALSE),
++
++ HOWTO (R_NIOS2_UJMP,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_ujmp_relocate,
++ "R_NIOS2_UJMP",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CJMP,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_cjmp_relocate,
++ "R_NIOS2_CJMP",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_CALLR,
++ 0,
++ 2,
++ 32,
++ FALSE,
++ 6,
++ complain_overflow_dont,
++ nios2_elf32_callr_relocate,
++ "R_NIOS2_CALLR",
++ FALSE,
++ 0x003fffc0,
++ 0x003fffc0,
++ FALSE),
++
++ HOWTO (R_NIOS2_ALIGN,
++ 0,
++ 2,
++ 0,
++ FALSE,
++ 0,
++ complain_overflow_dont,
++ nios2_elf32_ignore_reloc,
++ "R_NIOS2_ALIGN",
++ FALSE,
++ 0,
++ 0,
++ TRUE),
++
++/* add other relocations here */
++};
++
++static unsigned char elf_code_to_howto_index[R_NIOS2_ILLEGAL + 1];
++
++static reloc_howto_type *
++lookup_howto (unsigned int rtype)
++{
++ static int initialized = 0;
++ int i;
++ int howto_tbl_size = (int) (sizeof (elf_nios2_howto_table_rel)
++ / sizeof (elf_nios2_howto_table_rel[0]));
++
++ if (!initialized)
++ {
++ initialized = 1;
++ memset (elf_code_to_howto_index, 0xff,
++ sizeof (elf_code_to_howto_index));
++ for (i = 0; i < howto_tbl_size; i++)
++ elf_code_to_howto_index[elf_nios2_howto_table_rel[i].type] = i;
++ }
++
++ BFD_ASSERT (rtype <= R_NIOS2_ILLEGAL);
++ i = elf_code_to_howto_index[rtype];
++ if (i >= howto_tbl_size)
++ return 0;
++ return elf_nios2_howto_table_rel + i;
++}
++
++/*
++ map for converting BFD reloc types to New Jersey
++ reloc types
++ */
++struct elf_reloc_map
++{
++ bfd_reloc_code_real_type bfd_val;
++ enum elf_nios2_reloc_type elf_val;
++};
++
++static const struct elf_reloc_map nios2_reloc_map[] = {
++ {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
++ {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
++ {BFD_RELOC_16_PCREL, R_NIOS2_PCREL16},
++ {BFD_RELOC_NIOS2_CALL26, R_NIOS2_CALL26},
++ {BFD_RELOC_NIOS2_IMM5, R_NIOS2_IMM5},
++ {BFD_RELOC_NIOS2_CACHE_OPX, R_NIOS2_CACHE_OPX},
++ {BFD_RELOC_NIOS2_IMM6, R_NIOS2_IMM6},
++ {BFD_RELOC_NIOS2_IMM8, R_NIOS2_IMM8},
++ {BFD_RELOC_NIOS2_HI16, R_NIOS2_HI16},
++ {BFD_RELOC_NIOS2_LO16, R_NIOS2_LO16},
++ {BFD_RELOC_NIOS2_HIADJ16, R_NIOS2_HIADJ16},
++ {BFD_RELOC_32, R_NIOS2_BFD_RELOC_32},
++ {BFD_RELOC_16, R_NIOS2_BFD_RELOC_16},
++ {BFD_RELOC_8, R_NIOS2_BFD_RELOC_8},
++ {BFD_RELOC_NIOS2_GPREL, R_NIOS2_GPREL},
++ {BFD_RELOC_VTABLE_INHERIT, R_NIOS2_GNU_VTINHERIT},
++ {BFD_RELOC_VTABLE_ENTRY, R_NIOS2_GNU_VTENTRY},
++ {BFD_RELOC_NIOS2_UJMP, R_NIOS2_UJMP},
++ {BFD_RELOC_NIOS2_CJMP, R_NIOS2_CJMP},
++ {BFD_RELOC_NIOS2_CALLR, R_NIOS2_CALLR},
++ {BFD_RELOC_NIOS2_ALIGN, R_NIOS2_ALIGN},
++};
++
++/* Given a BFD reloc type, return a howto structure. */
++
++static reloc_howto_type *
++nios2_elf32_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
++ bfd_reloc_code_real_type code)
++{
++ int i;
++ for (i = 0;
++ i < (int) (sizeof (nios2_reloc_map) / sizeof (struct elf_reloc_map));
++ ++i)
++ {
++ if (nios2_reloc_map[i].bfd_val == code)
++ return &elf_nios2_howto_table_rel[(int) nios2_reloc_map[i].elf_val];
++ }
++
++ return NULL;
++}
++
++/* Helper function for nios2_elf32_info_to_howto */
++
++static reloc_howto_type *
++nios2_elf32_rtype_to_howto (unsigned int r_type,
++ bfd_boolean rela_p ATTRIBUTE_UNUSED)
++{
++ BFD_ASSERT (r_type < R_NIOS2_ILLEGAL);
++ return &elf_nios2_howto_table_rel[r_type];
++}
++
++/* Given a ELF32 relocation, fill in a arelent structure */
++
++static void
++nios2_elf32_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr,
++ Elf_Internal_Rela * dst)
++{
++ unsigned int r_type;
++
++ r_type = ELF32_R_TYPE (dst->r_info);
++ cache_ptr->howto = nios2_elf32_rtype_to_howto (r_type, FALSE);
++
++ // FIXME - do we need to do anything else here???
++}
++
++/* The assembler has output long jmp/call sequences for all calls
++ * and pc-relative branches that it cannot guarantee are within
++ * range, so the linker must attempt to "relax" these sequences to
++ * short branches and calls if it can. Since we only relax in one
++ * direction - long to short - we don't need to see whether each
++ * relaxation invalidates any others
++ *
++ *
++ **/
++static bfd_boolean
++nios2_elf32_relax_section (bfd * abfd,
++ asection * sec,
++ struct bfd_link_info *link_info, bfd_boolean * again)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ Elf_Internal_Rela *internal_relocs;
++ Elf_Internal_Rela *irel, *irelend;
++ bfd_byte *contents = NULL;
++ Elf_Internal_Sym *isymbuf = NULL;
++
++ /* Assume nothing changes. */
++ *again = FALSE;
++
++ /* We don't have to do anything for a relocatable link, if
++ this section does not have relocs, or if this is not a
++ code section. */
++ if (link_info->relocatable
++ || (sec->flags & SEC_RELOC) == 0
++ || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0)
++ return TRUE;
++
++ /* If this is the first time we have been called for this section,
++ initialize the cooked size. */
++ if (sec->size == 0)
++ sec->size = sec->rawsize;
++
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++
++ /* Get a copy of the native relocations. */
++ internal_relocs = (_bfd_elf_link_read_relocs
++ (abfd, sec, (void *) NULL, (Elf_Internal_Rela *) NULL,
++ link_info->keep_memory));
++ if (internal_relocs == NULL)
++ goto error_return;
++
++ /* Walk through them looking for relaxing opportunities. */
++ irelend = internal_relocs + sec->reloc_count;
++ for (irel = internal_relocs; irel < irelend; irel++)
++ {
++ bfd_vma symval;
++
++ /* If this isn't something that can be relaxed, then ignore
++ this reloc. */
++ if (ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_UJMP
++ && ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_CJMP
++ && ELF32_R_TYPE (irel->r_info) != (int) R_NIOS2_CALLR)
++ {
++ continue;
++ }
++
++ /* Get the section contents if we haven't done so already. */
++ if (contents == NULL)
++ {
++ /* Get cached copy if it exists. */
++ if (elf_section_data (sec)->this_hdr.contents != NULL)
++ contents = elf_section_data (sec)->this_hdr.contents;
++ else
++ {
++ /* Go get them off disk. */
++ contents = (bfd_byte *) bfd_malloc (sec->rawsize);
++ if (contents == NULL)
++ goto error_return;
++
++ if (!bfd_get_section_contents (abfd, sec, contents,
++ (file_ptr) 0, sec->rawsize))
++ goto error_return;
++ }
++ }
++
++ /* Read this BFD's local symbols if we haven't done so already. */
++ if (isymbuf == NULL && symtab_hdr->sh_info != 0)
++ {
++ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
++ if (isymbuf == NULL)
++ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
++ symtab_hdr->sh_info, 0,
++ NULL, NULL, NULL);
++ if (isymbuf == NULL)
++ goto error_return;
++ }
++
++ /* Get the value of the symbol referred to by the reloc. */
++ if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
++ {
++ /* A local symbol. */
++ Elf_Internal_Sym *isym;
++ asection *sym_sec;
++
++ isym = isymbuf + ELF32_R_SYM (irel->r_info);
++ if (isym->st_shndx == SHN_UNDEF)
++ sym_sec = bfd_und_section_ptr;
++ else if (isym->st_shndx == SHN_ABS)
++ sym_sec = bfd_abs_section_ptr;
++ else if (isym->st_shndx == SHN_COMMON)
++ sym_sec = bfd_com_section_ptr;
++ else
++ sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
++ symval = (isym->st_value
++ + sym_sec->output_section->vma + sym_sec->output_offset);
++ }
++ else
++ {
++ unsigned long indx;
++ struct elf_link_hash_entry *h;
++
++ /* An external symbol. */
++ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
++ h = elf_sym_hashes (abfd)[indx];
++ BFD_ASSERT (h != NULL);
++ if (h->root.type != bfd_link_hash_defined
++ && h->root.type != bfd_link_hash_defweak)
++ {
++ /* This appears to be a reference to an undefined
++ symbol. Just ignore it--it will be caught by the
++ regular reloc processing. */
++ continue;
++ }
++
++ symval = (h->root.u.def.value
++ + h->root.u.def.section->output_section->vma
++ + h->root.u.def.section->output_offset);
++ }
++
++ /* For simplicity of coding, we are going to modify the section
++ contents, the section relocs, and the BFD symbol table. We
++ must tell the rest of the code not to free up this
++ information. It would be possible to instead create a table
++ of changes which have to be made, as is done in coff-mips.c;
++ that would be more work, but would require less memory when
++ the linker is run. */
++
++ /* try to turn :
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * callr at
++ * into:
++ * call symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_CALLR)
++ {
++ bfd_vma targ_addr = symval + irel->r_addend;
++ bfd_vma curr_addr = (sec->output_section->vma + sec->output_offset);
++ bfd_vma targ_page, curr_page;
++ targ_page = targ_addr & 0xf0000000;
++ curr_page = curr_addr & 0xf0000000;
++
++ if (targ_page == curr_page)
++ {
++ /* change the opcode to a call */
++ bfd_put_32 (abfd, OP_MATCH_CALL, contents + irel->r_offset);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_CALL26);
++
++ /* delete the next two instructions */
++ if (!nios2_elf32_relax_delete_bytes (abfd, sec,
++ irel->r_offset + 4, 8))
++ goto error_return;
++
++ /* NG FIXME - I'm putting this in for now, but I don't think we need it */
++ *again = TRUE;
++ }
++ }
++
++ /* try to turn :
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * jmp at
++ * into:
++ * br symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_UJMP)
++ {
++ bfd_vma pcrel_offset;
++ Elf_Internal_Rela *irelalign = NULL;
++ Elf_Internal_Rela *irela = elf_section_data (sec)->relocs;
++ Elf_Internal_Rela *irelend = irel + sec->reloc_count;
++
++ for (; irela < irelend; irela++)
++ {
++ if (ELF32_R_TYPE (irela->r_info) == (int) R_NIOS2_ALIGN
++ && irela->r_offset > irel->r_offset + 4
++ && 8 < (1 << irela->r_addend))
++ {
++ irelalign = irela;
++ break;
++ }
++ }
++
++ /* calculate the pcrelative offset from current location */
++ pcrel_offset = symval;
++ pcrel_offset -= (sec->output_section->vma + sec->output_offset);
++ pcrel_offset += irel->r_addend;
++
++ /* we need to compute the pcrel_offset from the next instruction */
++ pcrel_offset -= (irel->r_offset + 4);
++
++ /* does this value fit in 16 bits */
++ if ((irelalign == NULL && (long) pcrel_offset <= 0x8004
++ && (long) pcrel_offset >= -0x8000) || (irelalign != NULL
++ && (long) pcrel_offset
++ <= 0x7ffc
++ && (long) pcrel_offset
++ >= -0x8000))
++ {
++ /* change the opcode to an unconditional branch */
++ bfd_put_32 (abfd, OP_MATCH_BR, contents + irel->r_offset);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_PCREL16);
++
++ /* delete the next two instructions */
++ if (!nios2_elf32_relax_delete_bytes (abfd, sec,
++ irel->r_offset + 4, 8))
++ goto error_return;
++
++ /* NG FIXME - I'm putting this in for now, but I don't think we need it */
++ *again = TRUE;
++ }
++ }
++
++ /* try to turn :
++ * b{cond} a, b skip
++ * movhi at, %hi(symbol)
++ * movui at, %lo(symbol)
++ * jmp at
++ * skip:
++ * ...
++ * into:
++ * br{opp_cond} a, b, symbol
++ */
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_CJMP)
++ {
++ bfd_vma pcrel_offset;
++ Elf_Internal_Rela *irelalign = NULL;
++ Elf_Internal_Rela *irela = elf_section_data (sec)->relocs;
++ Elf_Internal_Rela *irelend = irel + sec->reloc_count;
++
++ for (; irela < irelend; irela++)
++ {
++ if (ELF32_R_TYPE (irela->r_info) == (int) R_NIOS2_ALIGN
++ && irela->r_offset > irel->r_offset + 4
++ && 8 < (1 << irela->r_addend))
++ {
++ irelalign = irela;
++ break;
++ }
++ }
++
++ /* calculate the pcrelative offset from current location */
++ pcrel_offset = symval;
++ pcrel_offset -= (sec->output_section->vma + sec->output_offset);
++ pcrel_offset += irel->r_addend;
++
++ /* we need to compute the pcrel_offset from this instruction
++ * ie the movhi */
++ pcrel_offset -= (irel->r_offset);
++
++ /* does this value fit in 16 bits */
++ if ((irelalign == NULL && (long) pcrel_offset <= 0x8008
++ && (long) pcrel_offset >= -0x8000) || (irelalign != NULL
++ && (long) pcrel_offset
++ <= 0x7ffc
++ && (long) pcrel_offset
++ >= -0x8000))
++ {
++ unsigned long opcode, op_a, op_b;
++ /* get the conditional branch opcode */
++ opcode = bfd_get_32 (abfd, contents + irel->r_offset - 4);
++ /* reverse the condition */
++ switch (opcode & OP_MASK_OP)
++ {
++ case OP_MATCH_BEQ:
++ opcode = (opcode & ~OP_MASK_OP) | OP_MATCH_BNE;
++ break;
++ case OP_MATCH_BNE:
++ opcode = (opcode & ~OP_MASK_OP) | OP_MATCH_BEQ;
++ break;
++ case OP_MATCH_BGE:
++ case OP_MATCH_BGEU:
++ case OP_MATCH_BLT:
++ case OP_MATCH_BLTU:
++ /* swap the operands */
++ op_a = (opcode & OP_MASK_RRT) << 5;
++ op_b = (opcode & OP_MASK_RRS) >> 5;
++ opcode =
++ (opcode & ~(OP_MASK_RRS | OP_MASK_RRT)) | op_a | op_b;
++ break;
++ default:
++ fprintf (stderr,
++ "relaxation error - expecting conditional branch, aborting\n");
++ abort ();
++ break;
++ }
++
++ /* we must set the branch target to zero so that the skip over the jmp doesn't get
++ * added to the jmp */
++ opcode = opcode & (~OP_MASK_IMM16);
++
++ /* change the opcode to the reversed conditional branch */
++ bfd_put_32 (abfd, opcode, contents + irel->r_offset - 4);
++ /* Note that we've changed the relocs, section contents, etc. */
++ elf_section_data (sec)->relocs = internal_relocs;
++ elf_section_data (sec)->this_hdr.contents = contents;
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++
++ /* Fix the relocation's type. */
++ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
++ R_NIOS2_PCREL16);
++
++ /* this relocation's offset has also been reduced by 4 bytes */
++ irel->r_offset -= 4;
++
++ /* delete the next three instructions */
++ if (!nios2_elf32_relax_delete_bytes (abfd, sec,
++ irel->r_offset + 4, 12))
++ goto error_return;
++
++ /* NG FIXME - I'm putting this in for now, but I don't think we need it */
++ *again = TRUE;
++ }
++ }
++
++ /* otherwise, leave alone */
++ }
++
++ if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
++ {
++ if (!link_info->keep_memory)
++ free (isymbuf);
++ else
++ {
++ /* Cache the symbols for elf_link_input_bfd. */
++ symtab_hdr->contents = (unsigned char *) isymbuf;
++ }
++ }
++
++ if (contents != NULL
++ && elf_section_data (sec)->this_hdr.contents != contents)
++ {
++ if (!link_info->keep_memory)
++ free (contents);
++ else
++ {
++ /* Cache the section contents for elf_link_input_bfd. */
++ elf_section_data (sec)->this_hdr.contents = contents;
++ }
++ }
++
++ if (internal_relocs != NULL
++ && elf_section_data (sec)->relocs != internal_relocs)
++ free (internal_relocs);
++
++
++ return TRUE;
++
++error_return:
++ if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
++ free (isymbuf);
++ if (contents != NULL
++ && elf_section_data (sec)->this_hdr.contents != contents)
++ free (contents);
++ if (internal_relocs != NULL
++ && elf_section_data (sec)->relocs != internal_relocs)
++ free (internal_relocs);
++
++ return FALSE;
++}
++
++/* Delete some bytes from a section while relaxing.
++ * Copied from mn10200 port */
++
++static bfd_boolean
++nios2_elf32_relax_delete_bytes (bfd * abfd,
++ asection * sec, bfd_vma addr, int count)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ unsigned int sec_shndx;
++ bfd_byte *contents;
++ Elf_Internal_Rela *irel, *irelend;
++ Elf_Internal_Rela *irelalign;
++ bfd_vma toaddr;
++ Elf_Internal_Sym *isym;
++ Elf_Internal_Sym *isymend;
++ struct elf_link_hash_entry **sym_hashes;
++ struct elf_link_hash_entry **end_hashes;
++ unsigned int symcount;
++ asection *asec;
++
++ sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
++
++ contents = elf_section_data (sec)->this_hdr.contents;
++
++ /* The deletion must stop at the next ALIGN reloc for an aligment
++ power larger than the number of bytes we are deleting. */
++
++ irelalign = NULL;
++ /* +1 because we need to readjust symbols at end of section */
++ toaddr = sec->size + 1;
++
++ irel = elf_section_data (sec)->relocs;
++ irelend = irel + sec->reloc_count;
++
++ for (; irel < irelend; irel++)
++ {
++ if (ELF32_R_TYPE (irel->r_info) == (int) R_NIOS2_ALIGN
++ && irel->r_offset > addr && count < (1 << irel->r_addend))
++ {
++ irelalign = irel;
++ /* +1 because we need to readjust symbols at end of section */
++ toaddr = irel->r_offset + 1;
++ break;
++ }
++ }
++
++
++ /* Actually delete the bytes. */
++ memmove (contents + addr, contents + addr + count,
++ (size_t) ((toaddr - 1) - addr - count));
++
++ if (irelalign == NULL)
++ sec->size -= count;
++ else
++ {
++ int i;
++
++#define NOP_OPCODE (0x0001883a)
++
++ BFD_ASSERT ((count & 3) == 0);
++ for (i = 0; i < count; i += 4)
++ bfd_put_32 (abfd, (bfd_vma) NOP_OPCODE,
++ contents + (toaddr - 1) - count + i);
++ }
++
++ /* get the symbol table */
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++ isym = (Elf_Internal_Sym *) symtab_hdr->contents;
++
++ /* Adjust all the reloc offsets in this section. */
++ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
++ {
++ /* Get the new reloc address. */
++ if ((irel->r_offset > addr && irel->r_offset < toaddr))
++ irel->r_offset -= count;
++ }
++
++ /* Adjust relocations against targets in this section whose positions
++ * have moved as a result of the relaxation */
++
++ for (asec = abfd->sections; asec; asec = asec->next)
++ {
++ irelend = elf_section_data (asec)->relocs + asec->reloc_count;
++ for (irel = elf_section_data (asec)->relocs; irel < irelend; irel++)
++ {
++ Elf_Internal_Sym *sym;
++ /* if the symbol which this reloc is against doesn't change
++ * we need to change the reloc addend */
++
++ sym = isym + ELF32_R_SYM (irel->r_info);
++ if (sym->st_shndx == sec_shndx
++ && !(sym->st_value > addr && sym->st_value < toaddr)
++ && sym->st_value + irel->r_addend > addr
++ && sym->st_value + irel->r_addend < toaddr)
++ {
++ irel->r_addend -= count;
++ }
++
++ }
++ }
++
++ /* Adjust the local symbols defined in this section. */
++ for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
++ {
++ if (isym->st_shndx == sec_shndx
++ && isym->st_value > addr && isym->st_value < toaddr)
++ isym->st_value -= count;
++
++
++ }
++
++ /* Now adjust the global symbols defined in this section. */
++ symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
++ - symtab_hdr->sh_info);
++ sym_hashes = elf_sym_hashes (abfd);
++ end_hashes = sym_hashes + symcount;
++ for (; sym_hashes < end_hashes; sym_hashes++)
++ {
++ struct elf_link_hash_entry *sym_hash = *sym_hashes;
++ if ((sym_hash->root.type == bfd_link_hash_defined
++ || sym_hash->root.type == bfd_link_hash_defweak)
++ && sym_hash->root.u.def.section == sec
++ && sym_hash->root.u.def.value > addr
++ && sym_hash->root.u.def.value < toaddr)
++ {
++ sym_hash->root.u.def.value -= count;
++ }
++ }
++
++ return TRUE;
++}
++
++struct bfd_link_info *nios2_link_info = NULL;
++
++/*
++void
++_bfd_set_link_info (info)
++ struct bfd_link_info *info;
++{
++ nios2_link_info = info;
++}
++*/
++
++bfd_boolean linker_force_make_executable = FALSE;
++
++/*
++void
++_bfd_set_force_make_executable (force)
++ bfd_boolean force;
++{
++ linker_force_make_executable = force;
++}
++*/
++
++/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
++ dangerous relocation. */
++
++static bfd_boolean
++nios2_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp, struct bfd_link_info *info)
++{
++
++ bfd_boolean gp_found;
++ struct bfd_hash_entry *h;
++ struct bfd_link_hash_entry *lh;
++
++ /* If we've already figured out what GP will be, just return it. */
++ *pgp = _bfd_get_gp_value (output_bfd);
++ if (*pgp)
++ return TRUE;
++
++ h = bfd_hash_lookup (&info->hash->table, "_gp", FALSE, FALSE);
++ lh = (struct bfd_link_hash_entry *) h;
++lookup:
++ if (lh)
++ {
++ switch (lh->type)
++ {
++ case bfd_link_hash_undefined:
++ case bfd_link_hash_undefweak:
++ case bfd_link_hash_common:
++ gp_found = FALSE;
++ break;
++ case bfd_link_hash_defined:
++ case bfd_link_hash_defweak:
++ gp_found = TRUE;
++ *pgp = lh->u.def.value;
++ break;
++ case bfd_link_hash_indirect:
++ case bfd_link_hash_warning:
++ lh = lh->u.i.link;
++ /* @@FIXME ignoring warning for now */
++ goto lookup;
++ case bfd_link_hash_new:
++ default:
++ abort ();
++ }
++ }
++ else
++ gp_found = FALSE;
++
++ if (!gp_found)
++ {
++ /* Only get the error once. */
++ *pgp = 4;
++ _bfd_set_gp_value (output_bfd, *pgp);
++ return FALSE;
++ }
++
++ _bfd_set_gp_value (output_bfd, *pgp);
++
++ return TRUE;
++}
++
++/* We have to figure out the gp value, so that we can adjust the
++ symbol value correctly. We look up the symbol _gp in the output
++ BFD. If we can't find it, we're stuck. We cache it in the ELF
++ target data. We don't need to adjust the symbol value for an
++ external symbol if we are producing relocatable output. */
++
++static bfd_reloc_status_type
++nios2_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
++ char **error_message, bfd_vma *pgp, struct bfd_link_info *info)
++{
++ if (bfd_is_und_section (symbol->section) && !relocatable)
++ {
++ *pgp = 0;
++ return bfd_reloc_undefined;
++ }
++
++ *pgp = _bfd_get_gp_value (output_bfd);
++ if (*pgp == 0 && (!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0))
++ {
++ /* if this is called without link_info, then
++ we cannot be doing a final link */
++ if (info == NULL)
++ relocatable = TRUE;
++
++ if (relocatable)
++ {
++ /* Make up a value. */
++ *pgp = symbol->section->output_section->vma + 0x4000;
++ _bfd_set_gp_value (output_bfd, *pgp);
++ }
++ else if (!nios2_elf_assign_gp (output_bfd, pgp, info))
++ {
++ *error_message =
++ (char *)
++ _("global pointer relative relocation when _gp not defined");
++ return bfd_reloc_dangerous;
++ }
++ }
++
++ return bfd_reloc_ok;
++}
++
++
++/* Relocations that require special handling */
++
++/* This is for relocations used only when relaxing to ensure
++ * changes in size of section don't screw up .align */
++static bfd_reloc_status_type
++nios2_elf32_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
++ asymbol *symbol ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED,
++ asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++ if (output_bfd != NULL)
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_hi16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data,
++ asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_hi16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_lo16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_lo16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_hiadj16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd,
++ char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_hiadj16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_pcrel16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd,
++ char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_pcrel16_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_call26_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
++{
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_call26_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_gprel_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg)
++{
++ bfd_vma relocation;
++ bfd_vma gp;
++ bfd_reloc_status_type r;
++
++
++/* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ relocation = symbol->value
++ + symbol->section->output_section->vma + symbol->section->output_offset;
++
++ if ((r =
++ nios2_elf_final_gp (abfd, symbol, FALSE, msg, &gp,
++ nios2_link_info)) == bfd_reloc_ok)
++ {
++ relocation = relocation + reloc_entry->addend - gp;
++ reloc_entry->addend = 0;
++ if ((signed) relocation < -32768 || (signed) relocation > 32767)
++ {
++ *msg = _("global pointer relative address out of range");
++ r = bfd_reloc_outofrange;
++ }
++ else
++ {
++ r = nios2_elf32_do_gprel_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ relocation, reloc_entry->addend);
++ }
++ }
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_ujmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_ujmp_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_cjmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++ return nios2_elf32_do_cjmp_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ + symbol->section->output_section->vma
++ + symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_callr_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
++ void *data, asection *input_section, bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
++{
++ /* This part is from bfd_elf_generic_reloc. */
++ if (output_bfd != (bfd *) NULL
++ && (symbol->flags & BSF_SECTION_SYM) == 0
++ && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
++ {
++ reloc_entry->address += input_section->output_offset;
++ return bfd_reloc_ok;
++ }
++
++ if (output_bfd != NULL)
++ /* FIXME: See bfd_perform_relocation. Is this right? */
++ return bfd_reloc_ok;
++
++
++ return nios2_elf32_do_callr_relocate (abfd, reloc_entry->howto,
++ input_section,
++ data, reloc_entry->address,
++ (symbol->value
++ +
++ symbol->section->output_section->
++ vma +
++ symbol->section->output_offset),
++ reloc_entry->addend);
++}
++
++/* Do the relocations which require special handling */
++
++static bfd_reloc_status_type
++nios2_elf32_do_hi16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value = (symbol_value >> 16) & 0xffff;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++
++static bfd_reloc_status_type
++nios2_elf32_do_lo16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value = symbol_value & 0xffff;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_hiadj16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data, bfd_vma offset,
++ bfd_vma symbol_value, bfd_vma addend)
++{
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_value =
++ ((symbol_value >> 16) & 0xffff) + ((symbol_value >> 15) & 0x01);
++ return _bfd_final_link_relocate (howto, abfd, input_section, data, offset,
++ symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_pcrel16_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ // NIOS2 pc relative relocations are relative to the next 32-bit instruction so we need
++ // to subtract 4 before doing a final_link_relocate
++ symbol_value = symbol_value + addend - 4;
++ addend = 0;
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_call26_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ /* check that the relocation is in the same page as the current address */
++ if (((symbol_value + addend) & 0xf0000000)
++ != ((input_section->output_section->vma + offset) & 0xf0000000))
++ return bfd_reloc_overflow;
++
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++
++static bfd_reloc_status_type
++nios2_elf32_do_gprel_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ // because we need the output_bfd, the special handling is done
++ // in nios2_elf32_relocate_section or in nios2_elf32_gprel_relocate
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_value, addend);
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_ujmp_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_cjmp_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++static bfd_reloc_status_type
++nios2_elf32_do_callr_relocate (bfd *abfd, reloc_howto_type *howto,
++ asection *input_section ATTRIBUTE_UNUSED, bfd_byte *data,
++ bfd_vma offset, bfd_vma symbol_value, bfd_vma addend)
++{
++ bfd_vma symbol_lo16, symbol_hi16;
++ bfd_reloc_status_type r;
++ symbol_value = symbol_value + addend;
++ addend = 0;
++ symbol_hi16 = (symbol_value >> 16) & 0xffff;
++ symbol_lo16 = symbol_value & 0xffff;
++
++ r = _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset, symbol_hi16, addend);
++
++ if (r == bfd_reloc_ok)
++ return _bfd_final_link_relocate (howto, abfd, input_section,
++ data, offset + 4, symbol_lo16, addend);
++
++ return r;
++}
++
++/*
++ The function nios2_elf32_relocate_section is used by the linker
++ to perform relocations
++*/
++static bfd_boolean
++nios2_elf32_relocate_section (bfd * output_bfd,
++ struct bfd_link_info *info,
++ bfd * input_bfd,
++ asection * input_section,
++ bfd_byte * contents,
++ Elf_Internal_Rela * relocs,
++ Elf_Internal_Sym * local_syms,
++ asection ** local_sections)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ struct elf_link_hash_entry **sym_hashes;
++ Elf_Internal_Rela *rel;
++ Elf_Internal_Rela *relend;
++
++ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
++ sym_hashes = elf_sym_hashes (input_bfd);
++ relend = relocs + input_section->reloc_count;
++
++// size_t psymalloc = 0;
++// _bfd_generic_link_output_symbols(output_bfd, input_bfd, info, &psymalloc);
++ for (rel = relocs; rel < relend; rel++)
++ {
++ reloc_howto_type *howto;
++ unsigned long r_symndx;
++ Elf_Internal_Sym *sym;
++ asection *sec;
++ struct elf_link_hash_entry *h;
++ bfd_vma relocation;
++ bfd_vma gp;
++ bfd_reloc_status_type r = bfd_reloc_ok;
++ const char *name = NULL;
++ int r_type;
++ const char *msg;
++
++ msg = (const char *) NULL;
++
++ r_type = ELF32_R_TYPE (rel->r_info);
++
++ r_symndx = ELF32_R_SYM (rel->r_info);
++
++ if (info->relocatable)
++ {
++ /* This is a relocatable link. We don't have to change
++ anything, unless the reloc is against a section symbol,
++ in which case we have to adjust according to where the
++ section symbol winds up in the output section. */
++ if (r_symndx < symtab_hdr->sh_info)
++ {
++ sym = local_syms + r_symndx;
++
++ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
++ {
++ sec = local_sections[r_symndx];
++ rel->r_addend += sec->output_offset + sym->st_value;
++ }
++ }
++ continue;
++ }
++
++ /* This is a final link. */
++ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
++ h = NULL;
++ sym = NULL;
++ sec = NULL;
++
++ if (r_symndx < symtab_hdr->sh_info)
++ {
++ sym = local_syms + r_symndx;
++ sec = local_sections[r_symndx];
++
++ relocation = (sec->output_section->vma
++ + sec->output_offset + sym->st_value);
++
++ // this ensures that relocations against duplicated symbols
++ // in merged sections that have been removed are fixed up against
++ // the remaining symbol and not the one that has been removed
++ if ((sec->flags & SEC_MERGE)
++ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
++ {
++ rel->r_addend =
++ _bfd_elf_rel_local_sym (output_bfd, sym, &sec, rel->r_addend);
++ rel->r_addend -= relocation;
++ rel->r_addend += sec->output_section->vma + sec->output_offset;
++ }
++
++ name = bfd_elf_string_from_elf_section
++ (input_bfd, symtab_hdr->sh_link, sym->st_name);
++
++ name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
++ }
++ else
++ {
++ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
++
++ while (h->root.type == bfd_link_hash_indirect
++ || h->root.type == bfd_link_hash_warning)
++ h = (struct elf_link_hash_entry *) h->root.u.i.link;
++
++ name = h->root.root.string;
++
++ if (h->root.type == bfd_link_hash_defined
++ || h->root.type == bfd_link_hash_defweak)
++ {
++ sec = h->root.u.def.section;
++
++ relocation = (h->root.u.def.value
++ + sec->output_section->vma + sec->output_offset);
++ }
++ else if (h->root.type == bfd_link_hash_undefweak)
++ {
++ relocation = 0;
++ }
++ else
++ {
++ if (!((*info->callbacks->undefined_symbol)
++ (info, h->root.root.string, input_bfd,
++ input_section, rel->r_offset, TRUE)))
++ return FALSE;
++ relocation = 0;
++ }
++ }
++
++ if (howto != NULL)
++ {
++ switch (howto->type)
++ {
++ case R_NIOS2_HI16:
++ r =
++ nios2_elf32_do_hi16_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_LO16:
++ r =
++ nios2_elf32_do_lo16_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_HIADJ16:
++ r =
++ nios2_elf32_do_hiadj16_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_PCREL16:
++ r =
++ nios2_elf32_do_pcrel16_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_GPREL:
++ // turns an absolute address into a gp-relative address
++ if (!nios2_elf_assign_gp (output_bfd, &gp, info))
++ {
++ msg =
++ _
++ ("global pointer relative relocation when _gp not defined");
++ r = bfd_reloc_dangerous;
++ }
++ else
++ {
++ relocation = relocation + rel->r_addend - gp;
++ rel->r_addend = 0;
++ if ((signed) relocation < -32768
++ || (signed) relocation > 32767)
++ {
++ msg = _("global pointer relative address out of range");
++ r = bfd_reloc_outofrange;
++ }
++ else
++ {
++ r =
++ _bfd_final_link_relocate (howto, input_bfd,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ }
++ }
++
++ break;
++ case R_NIOS2_UJMP:
++ r =
++ nios2_elf32_do_ujmp_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_CJMP:
++ r =
++ nios2_elf32_do_cjmp_relocate (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ case R_NIOS2_CALLR:
++ r =
++ nios2_elf32_do_callr_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_CALL26:
++ r =
++ nios2_elf32_do_call26_relocate (input_bfd, howto,
++ input_section, contents,
++ rel->r_offset, relocation,
++ rel->r_addend);
++ break;
++ case R_NIOS2_ALIGN:
++ r = bfd_reloc_ok;
++ /* comment - for symmetry this would be
++ r = nios2_elf32_do_ignore_reloc (input_bfd, howto, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ but do_ignore_reloc would do no more than return bfd_reloc_ok */
++ break;
++ default:
++ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
++ contents, rel->r_offset,
++ relocation, rel->r_addend);
++ break;
++ }
++ }
++ else
++ {
++ r = bfd_reloc_notsupported;
++ }
++
++ if (r != bfd_reloc_ok)
++ {
++ if (h != NULL)
++ name = h->root.root.string;
++ else
++ {
++ name = (bfd_elf_string_from_elf_section
++ (input_bfd, symtab_hdr->sh_link, sym->st_name));
++ if (name == NULL || *name == '\0')
++ name = bfd_section_name (input_bfd, sec);
++ }
++
++ switch (r)
++ {
++ case bfd_reloc_overflow:
++ r = info->callbacks->reloc_overflow
++ (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0,
++ input_bfd, input_section, rel->r_offset);
++ break;
++
++ case bfd_reloc_undefined:
++ r = info->callbacks->undefined_symbol
++ (info, name, input_bfd, input_section, rel->r_offset, TRUE);
++ break;
++
++ case bfd_reloc_outofrange:
++ if (msg == NULL)
++ msg = _("relocation out of range");
++ break;
++
++ case bfd_reloc_notsupported:
++ if (msg == NULL)
++ msg = _("unsupported relocation");
++ break;
++
++ case bfd_reloc_dangerous:
++ if (msg == NULL)
++ msg = _("dangerous relocation");
++ break;
++
++ default:
++ if (msg == NULL)
++ msg = _("unknown error");
++ break;
++ }
++
++ if (msg)
++ {
++ r = info->callbacks->warning
++ (info, msg, name, input_bfd, input_section, rel->r_offset);
++ return linker_force_make_executable;
++ }
++ }
++ }
++ return TRUE;
++}
++
++
++
++/* Handle an NIOS2 specific section when reading an object file. This
++ is called when elfcode.h finds a section with an unknown type.
++ FIXME: We need to handle the SHF_NIOS2_GPREL flag */
++
++static bfd_boolean
++nios2_elf32_section_from_shdr (bfd *abfd,
++ Elf_Internal_Shdr *hdr, const char *name, int shindex)
++{
++ asection *newsect;
++
++ /* NG - I'm keeping this code commented out at the moment
++ in case we add a .mdebug section */
++
++ /*
++ switch (hdr->sh_type)
++ {
++ case SHT_NIOS2_DEBUG:
++ if (strcmp (name, ".mdebug") != 0)
++ return FALSE;
++ break;
++ default:
++ return FALSE;
++ }
++ */
++
++ if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
++ return FALSE;
++
++ newsect = hdr->bfd_section;
++
++ /* ditto */
++ /*
++ if (hdr->sh_type == SHT_NIOS2_DEBUG)
++ {
++ if (! bfd_set_section_flags (abfd, newsect,
++ (bfd_get_section_flags (abfd, newsect)
++ | SEC_DEBUGGING)))
++ return FALSE;
++ }
++ */
++ return TRUE;
++}
++
++/* Convert NIOS2 specific section flags to bfd internal section flags. */
++
++static bfd_boolean
++nios2_elf32_section_flags (flagword *flags, const Elf_Internal_Shdr *hdr)
++{
++ if (hdr->sh_flags & SHF_NIOS2_GPREL)
++ *flags |= SEC_SMALL_DATA;
++
++ return TRUE;
++}
++
++/* Set the correct type for an NIOS2 ELF section. We do this by the
++ section name, which is a hack, but ought to work. */
++
++static bfd_boolean
++nios2_elf32_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
++ Elf_Internal_Shdr *hdr, asection *sec)
++{
++ register const char *name;
++
++ name = bfd_get_section_name (abfd, sec);
++
++ if (strcmp (name, ".mdebug") == 0)
++ {
++ /* we don't yet have an .mdebug section, but I'm leaving this here
++ in case we ever do
++ hdr->sh_type = SHT_NIOS2_DEBUG;
++
++ if ((abfd->flags & DYNAMIC) != 0 )
++ hdr->sh_entsize = 0;
++ else
++ hdr->sh_entsize = 1;
++ */
++ }
++ else if ((sec->flags & SEC_SMALL_DATA)
++ || strcmp (name, ".sdata") == 0
++ || strcmp (name, ".sbss") == 0
++ || strcmp (name, ".lit4") == 0 || strcmp (name, ".lit8") == 0)
++ hdr->sh_flags |= SHF_NIOS2_GPREL;
++
++ return TRUE;
++}
++
++/* Look through the relocs for a section during the first phase.
++ Since we don't do .gots or .plts, we just need to consider the
++ virtual table relocs for gc. */
++
++static bfd_boolean
++nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
++ asection *sec, const Elf_Internal_Rela *relocs)
++{
++ Elf_Internal_Shdr *symtab_hdr;
++ struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
++ const Elf_Internal_Rela *rel;
++ const Elf_Internal_Rela *rel_end;
++
++ if (info->relocatable)
++ return TRUE;
++
++ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
++ sym_hashes = elf_sym_hashes (abfd);
++ sym_hashes_end =
++ sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
++ if (!elf_bad_symtab (abfd))
++ sym_hashes_end -= symtab_hdr->sh_info;
++
++ rel_end = relocs + sec->reloc_count;
++ for (rel = relocs; rel < rel_end; rel++)
++ {
++ struct elf_link_hash_entry *h;
++ unsigned long r_symndx;
++
++ r_symndx = ELF32_R_SYM (rel->r_info);
++ if (r_symndx < symtab_hdr->sh_info)
++ h = NULL;
++ else
++ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
++
++ switch (ELF32_R_TYPE (rel->r_info))
++ {
++ /* This relocation describes the C++ object vtable hierarchy.
++ Reconstruct it for later use during GC. */
++ case R_NIOS2_GNU_VTINHERIT:
++ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
++ return FALSE;
++ break;
++
++ /* This relocation describes which C++ vtable entries are actually
++ used. Record for later use during GC. */
++ case R_NIOS2_GNU_VTENTRY:
++ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
++ return FALSE;
++ break;
++ }
++ }
++
++ return TRUE;
++}
++
++
++/* Return the section that should be marked against GC for a given
++ relocation. */
++
++asection *
++nios2_elf32_gc_mark_hook (asection *sec,
++ struct bfd_link_info *info ATTRIBUTE_UNUSED,
++ Elf_Internal_Rela *rel, struct elf_link_hash_entry *h,
++ Elf_Internal_Sym *sym)
++{
++ if (h != NULL)
++ {
++ switch (ELF32_R_TYPE (rel->r_info))
++ {
++ case R_NIOS2_GNU_VTINHERIT:
++ case R_NIOS2_GNU_VTENTRY:
++ break;
++
++ default:
++ switch (h->root.type)
++ {
++ case bfd_link_hash_defined:
++ case bfd_link_hash_defweak:
++ return h->root.u.def.section;
++
++ case bfd_link_hash_common:
++ return h->root.u.c.p->section;
++
++ default:
++ break;
++ }
++ }
++ }
++ else
++ return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
++
++ return NULL;
++}
++
++/*
++ NG ??? I'm marking the sections as standalone ie. I'm linking for
++ standalone embedded applications, not for UNIX System V or any other
++ OS/ABI - this may need to change when we deal with embedded PIC or
++ dynamic linking
++*/
++
++static void
++nios2_elf32_post_process_headers (bfd *abfd,
++ struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
++{
++ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
++
++ i_ehdrp = elf_elfheader (abfd);
++ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_STANDALONE;
++}
++
++#define ELF_ARCH bfd_arch_nios2
++#define ELF_MACHINE_CODE EM_ALTERA_NIOS2
++
++/* for now we just make this 1, as we have no MMU in New Jersey */
++
++#define ELF_MAXPAGESIZE 1
++
++/* relocation table lookup macros */
++
++#define bfd_elf32_bfd_reloc_type_lookup nios2_elf32_bfd_reloc_type_lookup
++
++/* JUMP_TABLE_LINK macros */
++
++#define bfd_elf32_bfd_relax_section nios2_elf32_relax_section
++
++/* elf_info_to_howto (using RELA relocations) */
++
++#define elf_info_to_howto nios2_elf32_info_to_howto
++
++/* elf backend functions */
++
++#define elf_backend_can_gc_sections 1
++
++#define elf_backend_relocate_section nios2_elf32_relocate_section
++#define elf_backend_section_from_shdr nios2_elf32_section_from_shdr
++#define elf_backend_section_flags nios2_elf32_section_flags
++#define elf_backend_fake_sections nios2_elf32_fake_sections
++#define elf_backend_post_process_headers nios2_elf32_post_process_headers
++#define elf_backend_check_relocs nios2_elf32_check_relocs
++
++#define elf_backend_gc_mark_hook nios2_elf32_gc_mark_hook
++
++
++
++/* Support for SGI-ish mips targets. */
++#define TARGET_LITTLE_SYM bfd_elf32_littlenios2_vec
++#define TARGET_LITTLE_NAME "elf32-littlenios2"
++#define TARGET_BIG_SYM bfd_elf32_bignios2_vec
++#define TARGET_BIG_NAME "elf32-bignios2"
++
++#include "elf32-target.h"
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index 1b8c8d7..c66a23d 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -4733,6 +4733,39 @@ ENUMDOC
+ msp430 specific relocation codes
+
+ ENUM
++ BFD_RELOC_NIOS2_S16
++ENUMX
++ BFD_RELOC_NIOS2_U16
++ENUMX
++ BFD_RELOC_NIOS2_CALL26
++ENUMX
++ BFD_RELOC_NIOS2_IMM5
++ENUMX
++ BFD_RELOC_NIOS2_CACHE_OPX
++ENUMX
++ BFD_RELOC_NIOS2_IMM6
++ENUMX
++ BFD_RELOC_NIOS2_IMM8
++ENUMX
++ BFD_RELOC_NIOS2_HI16
++ENUMX
++ BFD_RELOC_NIOS2_LO16
++ENUMX
++ BFD_RELOC_NIOS2_HIADJ16
++ENUMX
++ BFD_RELOC_NIOS2_GPREL
++ENUMX
++ BFD_RELOC_NIOS2_UJMP
++ENUMX
++ BFD_RELOC_NIOS2_CJMP
++ENUMX
++ BFD_RELOC_NIOS2_CALLR
++ENUMX
++ BFD_RELOC_NIOS2_ALIGN
++ENUMDOC
++ Relocations used by the Altera Nios II core
++
++ENUM
+ BFD_RELOC_IQ2000_OFFSET_16
+ ENUMX
+ BFD_RELOC_IQ2000_OFFSET_21
+diff --git a/bfd/targets.c b/bfd/targets.c
+index 71e3337..d5f6d60 100644
+--- a/bfd/targets.c
++++ b/bfd/targets.c
+@@ -619,6 +619,8 @@ extern const bfd_target bfd_elf32_ntradbigmips_vec;
+ extern const bfd_target bfd_elf32_ntradlittlemips_vec;
+ extern const bfd_target bfd_elf32_openrisc_vec;
+ extern const bfd_target bfd_elf32_or32_big_vec;
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
+ extern const bfd_target bfd_elf32_pj_vec;
+ extern const bfd_target bfd_elf32_pjl_vec;
+ extern const bfd_target bfd_elf32_powerpc_vec;
+@@ -819,6 +821,8 @@ extern const bfd_target sco5_core_vec;
+ extern const bfd_target trad_core_vec;
+
+ extern const bfd_target bfd_elf32_am33lin_vec;
++extern const bfd_target bfd_elf32_littlenios2_vec;
++extern const bfd_target bfd_elf32_bignios2_vec;
+ static const bfd_target * const _bfd_target_vector[] =
+ {
+ #ifdef SELECT_VECS
+@@ -923,6 +927,8 @@ static const bfd_target * const _bfd_target_vector[] =
+ &bfd_elf32_littlearm_vxworks_vec,
+ &bfd_elf32_littlemips_vec,
+ &bfd_elf32_littlemips_vxworks_vec,
++ &bfd_elf32_littlenios2_vec,
++ &bfd_elf32_bignios2_vec,
+ &bfd_elf32_m32c_vec,
+ &bfd_elf32_m32r_vec,
+ &bfd_elf32_m32rle_vec,
+diff --git a/config.sub b/config.sub
+index fab0aa3..462e7c6 100755
+--- a/config.sub
++++ b/config.sub
+@@ -270,7 +270,7 @@ case $basic_machine in
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+- | nios | nios2 \
++ | nios2 | nios2eb | nios2el \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+diff --git a/configure.in b/configure.in
+index a4befda..f2e34c7 100644
+--- a/configure.in
++++ b/configure.in
+@@ -740,6 +740,9 @@ case "${target}" in
+ mips*-*-*)
+ noconfigdirs="$noconfigdirs gprof ${libgcj}"
+ ;;
++ nios2*-*-*)
++ noconfigdirs="$noconfigdirs ld"
++ ;;
+ romp-*-*)
+ noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
+ ;;
+diff --git a/gdb/Makefile.in b/gdb/Makefile.in
+index 14fd58b..eac9489 100644
+--- a/gdb/Makefile.in
++++ b/gdb/Makefile.in
+@@ -593,6 +593,7 @@ libiberty_h = $(INCLUDE_DIR)/libiberty.h
+ libbfd_h = $(BFD_SRC)/libbfd.h
+ remote_sim_h = $(INCLUDE_DIR)/gdb/remote-sim.h
+ demangle_h = $(INCLUDE_DIR)/demangle.h
++nios2_h = $(INCLUDE_DIR)/opcode/nios2.h
+ obstack_h = $(INCLUDE_DIR)/obstack.h
+ opcode_m68hc11_h = $(INCLUDE_DIR)/opcode/m68hc11.h
+ readline_h = $(READLINE_SRC)/readline.h
+@@ -2399,6 +2400,7 @@ ms1-tdep.o: ms1-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) $(frame_base_h) \
+ $(trad_frame_h) $(inferior_h) $(dwarf2_frame_h) $(infcall_h) \
+ $(gdb_assert_h)
+ nbsd-tdep.o: nbsd-tdep.c $(defs_h) $(gdb_string_h) $(solib_svr4_h)
++nios2-tdep.o: nios2-tdep.c $(defs_h) $(symtab_h) $(frame_h) $(nios2_h)
+ nlmread.o: nlmread.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \
+ $(objfiles_h) $(buildsym_h) $(stabsread_h) $(block_h)
+ nto-procfs.o: nto-procfs.c $(defs_h) $(gdb_dirent_h) $(exceptions_h) \
+diff --git a/gdb/config/nios2/nios2.mt b/gdb/config/nios2/nios2.mt
+new file mode 100644
+index 0000000..63413b4
+--- /dev/null
++++ b/gdb/config/nios2/nios2.mt
+@@ -0,0 +1,4 @@
++# Target: Altera New Jersey Processor machine (NIOS2)
++TDEPFILES= nios2-tdep.o
++
++
+diff --git a/gdb/config/nios2/tm-nios2.h b/gdb/config/nios2/tm-nios2.h
+new file mode 100644
+index 0000000..2962b6b
+--- /dev/null
++++ b/gdb/config/nios2/tm-nios2.h
+@@ -0,0 +1,28 @@
++/* Definitions to target GDB to New Jersey targets.
++ Copyright 1986, 1987, 1988, 1989, 1991, 1993, 1994,
++ 1995, 1996, 1997, 1998, 1999, 2000, 2003
++ by Peter Brookes (pbrookes@altera.com)
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#ifndef TM_NIOS2_H
++#define TM_NIOS2_H
++
++#define GDB_MULTI_ARCH 1
++
++#endif /* TM_NIOS2_H */
+diff --git a/gdb/configure.tgt b/gdb/configure.tgt
+index dd2e719..7222f59 100644
+--- a/gdb/configure.tgt
++++ b/gdb/configure.tgt
+@@ -20,6 +20,7 @@ m68hc11*|m6811*) gdb_target_cpu=m68hc11 ;;
+ m68*) gdb_target_cpu=m68k ;;
+ m88*) gdb_target_cpu=m88k ;;
+ mips*) gdb_target_cpu=mips ;;
++nios2*) gdb_target_cpu=nios2 ;;
+ powerpc*) gdb_target_cpu=powerpc ;;
+ sparc*) gdb_target_cpu=sparc ;;
+ thumb*) gdb_target_cpu=arm ;;
+@@ -155,6 +156,8 @@ mn10300-*-*) gdb_target=mn10300 ;;
+
+ mt-*-*) gdb_target=mt ;;
+
++nios2*-*-*) gdb_target=nios2 ;;
++
+ powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
+ gdb_target=nbsd ;;
+ powerpc-*-openbsd*) gdb_target=obsd ;;
+diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
+index 9748c95..b3fb5f8 100644
+--- a/gdb/gdbserver/Makefile.in
++++ b/gdb/gdbserver/Makefile.in
+@@ -280,6 +280,7 @@ linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)
+ linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h)
+ linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \
+ $(gdb_proc_service_h)
++linux-nios2-low.o: linux-nios2-low.c $(linux_low_h) $(server_h)
+ linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)
+ linux-ppc64-low.o: linux-ppc64-low.c $(linux_low_h) $(server_h)
+ linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
+@@ -318,6 +319,9 @@ reg-m68k.c : $(srcdir)/../regformats/reg-m68k.dat $(regdat_sh)
+ reg-mips.o : reg-mips.c $(regdef_h)
+ reg-mips.c : $(srcdir)/../regformats/reg-mips.dat $(regdat_sh)
+ sh $(regdat_sh) $(srcdir)/../regformats/reg-mips.dat reg-mips.c
++reg-nios2.o : reg-nios2.c $(regdef_h)
++reg-nios2.c : $(srcdir)/../regformats/reg-nios2.dat $(regdat_sh)
++ sh $(regdat_sh) $(srcdir)/../regformats/reg-nios2.dat reg-nios2.c
+ reg-ppc.o : reg-ppc.c $(regdef_h)
+ reg-ppc.c : $(srcdir)/../regformats/reg-ppc.dat $(regdat_sh)
+ sh $(regdat_sh) $(srcdir)/../regformats/reg-ppc.dat reg-ppc.c
+diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
+index 5a4792c..fdc847c 100644
+--- a/gdb/gdbserver/configure.srv
++++ b/gdb/gdbserver/configure.srv
+@@ -72,6 +72,10 @@ case "${target}" in
+ srv_linux_usrregs=yes
+ srv_linux_thread_db=yes
+ ;;
++ nios2-*-linux*) srv_regobj=reg-nios2.o
++ srv_tgtobj="linux-low.o linux-nios2-low.o"
++ srv_linux_usrregs=yes
++ ;;
+ powerpc64-*-linux*) srv_regobj=reg-ppc64.o
+ srv_tgtobj="linux-low.o linux-ppc64-low.o"
+ srv_linux_usrregs=yes
+diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c
+new file mode 100644
+index 0000000..1fab749
+--- /dev/null
++++ b/gdb/gdbserver/linux-nios2-low.c
+@@ -0,0 +1,89 @@
++/* GNU/Linux/Nios2 specific low level interface for the remote server for GDB */
++
++#include "server.h"
++#include "linux-low.h"
++
++#ifdef HAVE_SYS_REG_H
++#include <sys/reg.h>
++#endif
++
++#include <asm/ptrace.h>
++
++static int nios2_regmap[] =
++{
++ -1, PTR_R1 * 4, PTR_R2 * 4, PTR_R3 * 4,
++ PTR_R4 * 4, PTR_R5 * 4, PTR_R6 * 4, PTR_R7 * 4,
++ PTR_R8 * 4, PTR_R9 * 4, PTR_R10 * 4, PTR_R11 * 4,
++ PTR_R12 * 4, PTR_R13 * 4, PTR_R14 * 4, PTR_R15 * 4, /* reg 15 */
++ PTR_R16 * 4, PTR_R17 * 4, PTR_R18 * 4, PTR_R19 * 4,
++ PTR_R20 * 4, PTR_R21 * 4, PTR_R22 * 4, PTR_R23 * 4,
++ -1, -1, PTR_GP * 4, PTR_SP * 4,
++ PTR_FP * 4, -1, -1, PTR_RA * 4, /* reg 31 */
++ PTR_PC * 4, -1, -1, -1,
++ -1, -1, -1, -1,
++ -1, -1, -1, -1
++};
++
++#define nios2_num_regs (sizeof(nios2_regmap) / sizeof(nios2_regmap[0]))
++
++static int
++nios2_cannot_store_register (int regno)
++{
++ return (regno >= 33);
++}
++
++static int
++nios2_cannot_fetch_register (int regno)
++{
++ return (regno >= 33);
++}
++
++static CORE_ADDR
++nios2_get_pc ()
++{
++ unsigned long pc;
++ collect_register_by_name ("pc", &pc);
++ return pc;
++}
++
++static void
++nios2_set_pc (CORE_ADDR pc)
++{
++ unsigned long newpc = pc;
++ supply_register_by_name ("pc", &newpc);
++}
++
++#if 0
++static const unsigned long nios2_breakpoint = 0x003da03a;
++#else
++static const unsigned long nios2_breakpoint = 0x003b687a; /* Trap instr. w/imm=0x01 */
++#endif
++#define nios2_breakpoint_len 4
++
++static int
++nios2_breakpoint_at (CORE_ADDR where)
++{
++ unsigned long insn;
++
++ (*the_target->read_memory) (where, (char *) &insn, nios2_breakpoint_len);
++ if (insn == nios2_breakpoint)
++ return 1;
++
++ /* If necessary, recognize more trap instructions here. GDB only uses the
++ one. */
++ return 0;
++}
++
++struct linux_target_ops the_low_target = {
++ nios2_num_regs,
++ nios2_regmap,
++ nios2_cannot_fetch_register,
++ nios2_cannot_store_register,
++ nios2_get_pc,
++ nios2_set_pc,
++ (const char *) &nios2_breakpoint,
++ nios2_breakpoint_len,
++ NULL,
++ 0,
++ nios2_breakpoint_at,
++};
+diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
+new file mode 100644
+index 0000000..e0712dd
+--- /dev/null
++++ b/gdb/nios2-tdep.c
+@@ -0,0 +1,1610 @@
++/* Target-machine dependent code for Nios2, for GDB.
++ Copyright (C) 2003-2005
++ by Peter Brookes (pbrookes@altera.com)
++ and Andrew Draper (adraper@altera.com)
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#include "defs.h"
++#include "frame.h"
++#include "frame-unwind.h"
++#include "frame-base.h"
++#include "trad-frame.h"
++#include "dwarf2-frame.h"
++#include "symtab.h"
++#include "inferior.h"
++#include "gdbtypes.h"
++#include "gdbcore.h"
++#include "gdbcmd.h"
++#include "target.h"
++#include "dis-asm.h"
++#include "regcache.h"
++#include "value.h"
++#include "symfile.h"
++#include "arch-utils.h"
++#include "floatformat.h"
++#include "gdb_assert.h"
++
++/* To get entry_point_address. */
++#include "objfiles.h"
++
++/* Nios II ISA specific encodings and macros */
++#include "opcode/nios2.h"
++
++/* Macros */
++
++#define Z_REGNUM 0 /* Zero */
++#define R2_REGNUM 2 /* used for return value */
++#define R3_REGNUM 3 /* used for return value */
++/* used for hidden zero argument to store ptr to struct return value */
++#define R4_REGNUM 4
++#define R7_REGNUM 7
++#define GP_REGNUM 26 /* Global Pointer */
++#undef SP_REGNUM
++#define SP_REGNUM 27 /* Stack Pointer */
++#undef FP_REGNUM
++#define FP_REGNUM 28 /* Frame Pointer */
++#define EA_REGNUM 29 /* Exception address */
++#define BA_REGNUM 30 /* Breakpoint return address */
++#define RA_REGNUM 31 /* Return address */
++#undef PC_REGNUM
++#define PC_REGNUM 32
++#define STATUS_REGNUM 33 /* Ctrl registers */
++#define ESTATUS_REGNUM 34
++#define BSTATUS_REGNUM 35
++#define IENABLE_REGNUM 36
++#define IPENDING_REGNUM 37
++#define CPUID_REGNUM 38
++#define PTEADDR_REGNUM 41
++#define TLBACC_REGNUM 42
++#define TLBMISC_REGNUM 43
++#define FIRST_ARGREG R4_REGNUM
++#define LAST_ARGREG R7_REGNUM
++/* Number of all registers */
++#define NIOS2_NUM_REGS (44)
++/* The maximum register number displayed to the user, */
++/* as a result of typing "info reg" at the gdb prompt */
++#define NIOS2_MAX_REG_DISPLAYED_REGNUM (38)
++
++#define NIOS2_OPCODE_SIZE 4
++
++/* Structures */
++struct register_info
++{
++ int size;
++ char *name;
++ struct type **type;
++};
++
++/* The current value in the register is the value in r[base] at the start of
++ * the function + offset ; unless base < 0 in which case it's unknown.
++ */
++typedef struct
++{
++ int reg;
++ unsigned int offset;
++
++} REG_VALUE;
++
++
++typedef struct
++{
++ int basereg;
++ CORE_ADDR addr;
++
++} REG_SAVED;
++
++struct nios2_unwind_cache
++{
++ /* The frame's base, optionally used by the high-level debug info. */
++ CORE_ADDR base;
++
++ /* The previous frame's inner most stack address. Used as this
++ frame ID's stack_addr. */
++ CORE_ADDR cfa;
++
++ /* The address of the first instruction in this function */
++ CORE_ADDR pc;
++
++ /* Which register holds the return address for the frame. */
++ int return_regnum;
++
++ /* Table indicating what changes have been made to each register */
++ REG_VALUE reg_value[NIOS2_NUM_REGS];
++
++ /* Table indicating where each register has been saved. */
++ REG_SAVED reg_saved[NIOS2_NUM_REGS];
++};
++
++
++/* Function prototypes */
++CORE_ADDR nios2_saved_pc_after_call (struct frame_info *fi);
++
++/* nios2_register_info_table[i] is the number of bytes of storage in
++ GDB's register array occupied by register i. */
++static struct register_info nios2_register_info_table[] = {
++ /* 0 */ {4, "zero", &builtin_type_uint32},
++ /* 1 */ {4, "at", &builtin_type_uint32},
++ /* 2 */ {4, "r2", &builtin_type_uint32},
++ /* 3 */ {4, "r3", &builtin_type_uint32},
++ /* 4 */ {4, "r4", &builtin_type_uint32},
++ /* 5 */ {4, "r5", &builtin_type_uint32},
++ /* 6 */ {4, "r6", &builtin_type_uint32},
++ /* 7 */ {4, "r7", &builtin_type_uint32},
++ /* 8 */ {4, "r8", &builtin_type_uint32},
++ /* 9 */ {4, "r9", &builtin_type_uint32},
++ /* 10 */ {4, "r10", &builtin_type_uint32},
++ /* 11 */ {4, "r11", &builtin_type_uint32},
++ /* 12 */ {4, "r12", &builtin_type_uint32},
++ /* 13 */ {4, "r13", &builtin_type_uint32},
++ /* 14 */ {4, "r14", &builtin_type_uint32},
++ /* 15 */ {4, "r15", &builtin_type_uint32},
++ /* 16 */ {4, "r16", &builtin_type_uint32},
++ /* 17 */ {4, "r17", &builtin_type_uint32},
++ /* 18 */ {4, "r18", &builtin_type_uint32},
++ /* 19 */ {4, "r19", &builtin_type_uint32},
++ /* 20 */ {4, "r20", &builtin_type_uint32},
++ /* 21 */ {4, "r21", &builtin_type_uint32},
++ /* 22 */ {4, "r22", &builtin_type_uint32},
++ /* 23 */ {4, "r23", &builtin_type_uint32},
++ /* 24 */ {4, "et", &builtin_type_uint32},
++ /* 25 */ {4, "bt", &builtin_type_uint32},
++ /* 26 */ {4, "gp", &builtin_type_uint32},
++ /* 27 */ {4, "sp", &builtin_type_uint32},
++ /* 28 */ {4, "fp", &builtin_type_uint32},
++ /* 29 */ {4, "ea", &builtin_type_uint32},
++ /* 30 */ {4, "ba", &builtin_type_uint32},
++ /* 31 */ {4, "ra", &builtin_type_uint32},
++ /* 32 */ {4, "pc", &builtin_type_uint32},
++ /* 33 */ {4, "status", &builtin_type_uint32},
++ /* 34 */ {4, "estatus", &builtin_type_uint32},
++ /* 35 */ {4, "bstatus", &builtin_type_uint32},
++ /* 36 */ {4, "ienable", &builtin_type_uint32},
++ /* 37 */ {4, "ipending", &builtin_type_uint32},
++ /* 38 */ {4, "cpuid", &builtin_type_uint32},
++ /* 39 */ {4, "ctl6", &builtin_type_uint32},
++ /* 40 */ {4, "ctl7", &builtin_type_uint32},
++ /* 41 */ {4, "pteaddr", &builtin_type_uint32},
++ /* 42 */ {4, "tlbacc", &builtin_type_uint32},
++ /* 43 */ {4, "tlbmisc", &builtin_type_uint32}
++};
++
++/* This array is a mapping from Dwarf-2 register
++ numbering to GDB's */
++static int nios2_dwarf2gdb_regno_map[] = {
++ 0, 1, 2, 3,
++ 4, 5, 6, 7,
++ 8, 9, 10, 11,
++ 12, 13, 14, 15,
++ 16, 17, 18, 19,
++ 20, 21, 22, 23,
++ 24, 25,
++ GP_REGNUM, /* 26 */
++ SP_REGNUM, /* 27 */
++ FP_REGNUM, /* 28 */
++ EA_REGNUM, /* 29 */
++ BA_REGNUM, /* 30 */
++ RA_REGNUM, /* 31 */
++ PC_REGNUM, /* 32 */
++ STATUS_REGNUM, /* 33 */
++ ESTATUS_REGNUM, /* 34 */
++ BSTATUS_REGNUM, /* 35 */
++ IENABLE_REGNUM, /* 36 */
++ IPENDING_REGNUM, /* 37 */
++ 38, 39, 40, 41, 42, 43
++};
++
++/* Dwarf-2 <-> GDB register numbers mapping. */
++int
++nios2_dwarf_reg_to_regnum (int dw_reg)
++{
++ if (dw_reg < 0 || dw_reg > NIOS2_NUM_REGS)
++ {
++ warning ("Dwarf-2 uses unmapped register #%d\n", dw_reg);
++ return dw_reg;
++ }
++
++ return nios2_dwarf2gdb_regno_map[dw_reg];
++}
++
++/* Same as read_memory_u6signed_integer, but don't report an error if
++ can't read. */
++int
++nios2_read_memory_unsigned_integer (CORE_ADDR memaddr, int len, ULONGEST *ret)
++{
++ char buf[sizeof (ULONGEST)];
++ int error;
++
++ error = target_read_memory (memaddr, buf, len);
++ if (error != 0)
++ return 0;
++ else
++ {
++ *ret = extract_unsigned_integer (buf, len);
++ return 1;
++ }
++}
++
++/* Find the name for the specified NIOS2 regno */
++static const char *
++nios2_register_name (int regno)
++{
++ /* Don't display any registers after NIOS2_MAX_REG_DISPLAYED_REGNUM */
++ if (regno < 0)
++ return NULL;
++ else if (regno > NIOS2_MAX_REG_DISPLAYED_REGNUM)
++ return NULL;
++ return nios2_register_info_table[regno].name;
++}
++
++/* Returns the default type for register N. */
++static struct type *
++nios2_register_type (struct gdbarch *gdbarch, int regno)
++{
++/* FIXME Do we need some checks on regno ? */
++ return *nios2_register_info_table[regno].type;
++}
++
++/* nios2_register_byte_table[i] is the offset into the register file of the
++ start of register number i. We initialize this from
++ nios2_register_info_table. */
++int nios2_register_byte_table[NIOS2_NUM_REGS];
++
++/* Index within `registers' of the first byte of the space for register REGNO. */
++int
++nios2_register_byte (int regno)
++{
++ return nios2_register_byte_table[regno];
++}
++
++/* Number of bytes of storage in the actual machine representation for
++ register 'regno'. */
++static int
++nios2_register_raw_size (int regno)
++{
++ return nios2_register_info_table[regno].size;
++}
++
++/* Number of bytes of storage in the program's representation for
++ register 'regno'. */
++static int
++nios2_register_virtual_size (int regno)
++{
++ return nios2_register_info_table[regno].size;
++}
++
++/* Return the GDB type object for the "standard" data type
++ of data in register 'regno'. */
++static struct type *
++nios2_register_virtual_type (int regno)
++{
++ return *nios2_register_info_table[regno].type;
++}
++
++/* Does this register need conversion betwen raw and virtual formats */
++int
++nios2_register_convertible (int regno)
++{
++ if (nios2_register_raw_size (regno) == nios2_register_virtual_size (regno))
++ return 0;
++ else
++ return 1;
++}
++
++
++
++/* Given a return value in `regcache' with a type `valtype',
++ extract and copy its value into `valbuf'. */
++/* FIXME: check this function*/
++void
++nios2_extract_return_value (struct type *valtype, struct regcache *regcache, void *valbuf)
++{
++#ifdef PORTINGTO61
++ int len = TYPE_LENGTH (valtype);
++
++ /* pointer types are returned in register r2,
++ up to 16-bit types in r2
++ up to 32-bit types in r2,r3 */
++ if (len <= nios2_register_raw_size (R2_REGNUM))
++ memcpy (valbuf, regbuf + REGISTER_BYTE (R2_REGNUM), len);
++ else if (len <= (nios2_register_raw_size (R2_REGNUM)
++ + nios2_register_raw_size (R3_REGNUM)))
++ memcpy (valbuf, regbuf + REGISTER_BYTE (R2_REGNUM), len);
++ else
++ {
++ /* Can I get the returned value here ? */
++ memset(valbuf, 0, len);
++ }
++#endif
++}
++
++/* Write into appropriate registers a function return value
++ of type TYPE, given in virtual format. */
++/* FIXME: check if required */
++void
++nios2_store_return_value (struct type *valtype, void *valbuf)
++{
++#ifdef PORTINGTO61
++ int len = TYPE_LENGTH (valtype);
++
++ /* return values of up to 8 bytes are returned in $r2 $r3 */
++
++ if (len <= nios2_register_raw_size (R2_REGNUM))
++ write_register_bytes (REGISTER_BYTE (R2_REGNUM),
++ valbuf,
++ len);
++ else if (len <= (nios2_register_raw_size (R2_REGNUM)
++ + nios2_register_raw_size (R3_REGNUM)))
++ write_register_bytes (REGISTER_BYTE (R2_REGNUM),
++ valbuf,
++ len);
++#endif
++}
++
++#ifdef PORTINGTO61
++
++/* Setup the function arguments for calling a function in the inferior. */
++static CORE_ADDR
++nios2_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
++ int struct_return, CORE_ADDR struct_addr)
++{
++ int argreg;
++ int argnum;
++ struct stack_arg
++ {
++ int len;
++ char *val;
++ } *stack_args;
++ int nstack_args = 0;
++
++ stack_args = (struct stack_arg *) alloca (nargs * sizeof (struct stack_arg));
++
++ /* The lowest register number containing arguments */
++ argreg = FIRST_ARGREG;
++
++ /* Align the stack. It will be needed
++ if we call a function which has argument overflow. */
++ sp &= ~3;
++
++ /* If this function returns a struct which does not fit in the
++ return registers, we must pass a buffer to the function
++ which it can use to save the return value. */
++ if (struct_return)
++ write_register (R2_REGNUM, struct_addr);
++
++ /* FIXME: what about unions? */
++ for (argnum = 0; argnum < nargs; argnum++)
++ {
++ char *val = (char *) VALUE_CONTENTS (args[argnum]);
++ int len = TYPE_LENGTH (VALUE_TYPE (args[argnum]));
++ struct type *type = VALUE_TYPE (args[argnum]);
++ int olen;
++
++ if ((argreg <= LAST_ARGREG && len <= (LAST_ARGREG - argreg + 1) * DEPRECATED_REGISTER_SIZE)
++ || (TYPE_CODE (type) == TYPE_CODE_STRUCT))
++ {
++ /* Something that will fit entirely into registers or go on the stack. */
++ while (len > 0 && argreg <= LAST_ARGREG)
++ { write_register (argreg, extract_unsigned_integer (val, DEPRECATED_REGISTER_SIZE));
++
++ argreg++;
++ val += DEPRECATED_REGISTER_SIZE;
++ len -= DEPRECATED_REGISTER_SIZE;
++ }
++
++ /* Any remainder for the stack is noted below... */
++ }
++ else if (TYPE_CODE (VALUE_TYPE (args[argnum])) != TYPE_CODE_STRUCT
++ && len > DEPRECATED_REGISTER_SIZE)
++ {
++ /* All subsequent args go onto the stack. */
++ argnum = LAST_ARGREG + 1;
++ }
++
++ if (len > 0)
++ {
++ /* Note that this must be saved onto the stack */
++ stack_args[nstack_args].val = val;
++ stack_args[nstack_args].len = len;
++ nstack_args++;
++ }
++ }
++
++ /* We're done with registers and stack allocation. Now do the actual
++ stack pushes. */
++ while (nstack_args--)
++ {
++ sp -= stack_args[nstack_args].len;
++ write_memory (sp, stack_args[nstack_args].val, stack_args[nstack_args].len);
++ }
++
++ /* Return adjusted stack pointer. */
++ return sp;
++}
++
++/* Function: push_return_address (pc)
++ Set up the return address for the inferior function call.*/
++/* FIXME: Check if required */
++static CORE_ADDR
++nios2_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
++{
++ write_register (RA_REGNUM, CALL_DUMMY_ADDRESS ());
++ return sp;
++}
++
++/* Extract from an array regcache containing the (raw) register state
++ the address in which a function should return its structure value,
++ as a CORE_ADDR (or an expression that can be used as one). */
++/* FIXME: Check if required */
++
++static CORE_ADDR
++nios2_extract_struct_value_address (char *regbuf)
++{
++ return (extract_address ((regbuf) + REGISTER_BYTE (R4_REGNUM),
++ REGISTER_RAW_SIZE (R4_REGNUM)));
++}
++
++/* Store the address of the place in which to copy the structure the
++ subroutine will return. This is called from call_function. */
++
++/* FIXME: Check if required */
++static void
++nios2_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
++{
++ write_register (R4_REGNUM, (addr));
++}
++#endif
++
++
++/* This function analyzes the function prologue and tries to work
++ out where registers are saved and how long the prologue is.
++ The prologue will consist of the following parts:
++ 1) Optional profiling instrumentation. The old version uses six
++ instructions. We step over this if there is an exact match.
++ nextpc r8
++ mov r9, ra
++ movhi r10, %hiadj(.LP2)
++ addi r10, r10, %lo(.LP2)
++ call mcount
++ mov ra, r9
++ The new version uses two or three instructions (the last of
++ these might get merged in with the STW which saves RA to the
++ stack). We interpret these.
++ mov r8, ra
++ call mcount
++ mov ra, r8
++
++ 2) Optional interrupt entry decision. Again, we step over
++ this if there is an exact match.
++ rdctl et,estatus
++ andi et,et,1
++ beq et,zero, <software_exception>
++ rdctl et,ipending
++ beq et,zero, <software_exception>
++
++ 3) A stack adjustment or stack which, which will be one of:
++ addi sp, sp, -constant
++ or:
++ movi r8, constant
++ sub sp, sp, r8
++ or
++ movhi r8, constant
++ addi r8, r8, constant
++ sub sp, sp, r8
++ or
++ movhi rx, %hiadj(newstack)
++ addhi rx, rx, %lo(newstack)
++ stw sp, constant(rx)
++ mov sp, rx
++
++ 4) An optional stack check, which can take either of these forms:
++ bgeu sp, rx, +8
++ break 3
++ or
++ bltu sp, rx, .Lstack_overflow
++ ...
++ .Lstack_overflow:
++ break 3
++
++ 5) Saving any registers which need to be saved. These will
++ normally just be stored onto the stack:
++ stw rx, constant(sp)
++ but in the large frame case will use r8 as an offset back
++ to the cfa:
++ add r8, r8, sp
++ stw rx, -constant(r8)
++
++ Saving control registers looks slightly different:
++ rdctl rx, ctlN
++ stw rx, constant(sp)
++
++ 6) An optional FP setup, either if the user has requested a
++ frame pointer or if the function calls alloca.
++ This is always:
++ mov fp, sp
++
++ The prologue instructions may be interleaved, and the register
++ saves and FP setup can occur in either order.
++
++ To cope with all this variability we decode all the instructions
++ from the start of the prologue until we hit a branch, call or
++ return. For each of the instructions mentioned in 3, 4 and 5 we
++ handle the limited cases of stores to the stack and operations
++ on constant values.
++ */
++
++typedef struct
++{
++ unsigned int insn;
++ unsigned int mask;
++} wild_insn;
++
++static const wild_insn profiler_insn[] =
++{
++ { 0x0010e03a, 0x00000000 }, // nextpc r8
++ { 0xf813883a, 0x00000000 }, // mov r9,ra
++ { 0x02800034, 0x003FFFC0 }, // movhi r10,257
++ { 0x52800004, 0x003FFFC0 }, // addi r10,r10,-31992
++ { 0x00000000, 0xFFFFFFC0 }, // call <mcount>
++ { 0x483f883a, 0x00000000 } // mov ra,r9
++};
++
++static const wild_insn irqentry_insn[] =
++{
++ { 0x0031307a, 0x00000000 }, // rdctl et,estatus
++ { 0xc600004c, 0x00000000 }, // andi et,et,1
++ { 0xc0000026, 0x003FFFC0 }, // beq et,zero, <software_exception>
++ { 0x0031313a, 0x00000000 }, // rdctl et,ipending
++ { 0xc0000026, 0x003FFFC0 } // beq et,zero, <software_exception>
++};
++
++static void
++nios2_setup_default(struct nios2_unwind_cache *cache)
++{
++ int i;
++
++ for (i = 0; i < NIOS2_NUM_REGS; i++)
++ {
++ /* All registers start off holding their previous values */
++ cache->reg_value[i].reg = i;
++ cache->reg_value[i].offset = 0;
++
++ /* All registers start off not saved */
++ cache->reg_saved[i].basereg = -1;
++ cache->reg_saved[i].addr = 0;
++ }
++}
++
++static int
++nios2_match_sequence(CORE_ADDR start_pc, const wild_insn * sequence, int count)
++{
++ CORE_ADDR pc = start_pc;
++ int i;
++ unsigned int insn;
++
++ for (i = 0 ; i < count ; i++)
++ {
++ insn = read_memory_unsigned_integer (pc, NIOS2_OPCODE_SIZE);
++ if ((insn & ~sequence[i].mask) != sequence[i].insn)
++ return 0;
++
++ pc += NIOS2_OPCODE_SIZE;
++ }
++
++ return 1;
++}
++
++
++CORE_ADDR
++nios2_analyze_prologue (const CORE_ADDR start_pc, const CORE_ADDR current_pc,
++ struct nios2_unwind_cache *cache, struct frame_info *next_frame)
++{
++ /* Maximum lines of prologue to check */
++ /* Note that this number should not be too large, else we can potentially */
++ /* end up iterating through unmapped memory */
++ CORE_ADDR limit_pc = start_pc + 200;
++ int regno;
++
++ /* Does the frame set up the FP register? */
++ int base_reg = 0;
++
++ REG_VALUE * value = cache->reg_value;
++ REG_VALUE temp_value[NIOS2_NUM_REGS];
++
++ int i;
++
++ /* Save the starting PC so we can correct the pc after running */
++ /* through the prolog, using symbol info */
++ CORE_ADDR pc = start_pc;
++
++ /* Is this an exception handler? */
++ int exception_handler = 0;
++
++ /* What was the original value of SP (or fake original value for
++ * functions which switch stacks?
++ */
++ CORE_ADDR frame_high;
++
++ /* Is this the end of the prologue? */
++ int within_prologue = 1;
++
++ CORE_ADDR prologue_end;
++
++ /* Is this the innermost function? */
++ int innermost = (frame_relative_level(next_frame) < 0);
++
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog,
++ "{ nios2_analyze_prologue start=0x%s, current=0x%s ",
++ paddr_nz (start_pc), paddr_nz (current_pc));
++#endif
++
++ /* Set up the default values of the registers. */
++ nios2_setup_default(cache);
++
++ /* If the first few instructions are the profile entry then skip over them. */
++ /* Newer versions of the compiler use more efficient profiling code. */
++ if (nios2_match_sequence(pc, profiler_insn, sizeof(profiler_insn)/sizeof(profiler_insn[0])))
++ pc += sizeof(profiler_insn)/sizeof(profiler_insn[0]) * NIOS2_OPCODE_SIZE;
++
++ /* If the first few are an interrupt entry then skip over them too */
++ if (nios2_match_sequence(pc, irqentry_insn, sizeof(irqentry_insn)/sizeof(irqentry_insn[0])))
++ {
++ pc += sizeof(irqentry_insn)/sizeof(irqentry_insn[0]) * NIOS2_OPCODE_SIZE;
++ exception_handler = 1;
++ }
++
++ prologue_end = start_pc;
++
++ /* Find the prologue instructions. */
++ /* Fortunately we're in 32bit paradise */
++ while (pc < limit_pc && within_prologue)
++ {
++ /* Present instruction. */
++ unsigned int insn;
++
++ int prologue_insn = 0;
++
++ if (pc == current_pc)
++ {
++ /*
++ * When we reach the current PC we must save the current register
++ * state (for the backtrace) but keep analysing because there might
++ * be more to find out (eg. is this an exception handler).
++ */
++ memcpy(temp_value, value, sizeof(temp_value));
++ value = temp_value;
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "*");
++#endif
++ }
++
++ insn = read_memory_unsigned_integer (pc, NIOS2_OPCODE_SIZE);
++ pc += NIOS2_OPCODE_SIZE;
++
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "[%08X]", insn);
++#endif
++
++ /* The following instructions can appear in the prologue */
++
++ if ((insn & 0x0001FFFF) == 0x0001883A)
++ {
++ /* ADD rc, ra, rb (also used for MOV) */
++
++ int ra = GET_IW_A(insn);
++ int rb = GET_IW_B(insn);
++ int rc = GET_IW_C(insn);
++
++ if (rc == SP_REGNUM && rb == 0 && value[ra].reg == cache->reg_saved[SP_REGNUM].basereg)
++ {
++ /* If the previous value of SP is available somewhere near the new
++ * stack pointer value then this is a stack switch.
++ */
++
++ /* If any registers were saved on the stack before then we can't backtrace
++ * into them now.
++ */
++ for (i = 0 ; i < NIOS2_NUM_REGS ; i++)
++ {
++ if (cache->reg_saved[i].basereg == SP_REGNUM)
++ cache->reg_saved[i].basereg = -1;
++ if (value[i].reg == SP_REGNUM)
++ value[i].reg = -1;
++ }
++
++ /* Create a fake "high water mark" 4 bytes above where SP was stored
++ * and fake up the registers to be consistent with that.
++ */
++ value[SP_REGNUM].reg = SP_REGNUM;
++ value[SP_REGNUM].offset = value[ra].offset - cache->reg_saved[SP_REGNUM].addr - 4;
++
++ cache->reg_saved[SP_REGNUM].basereg = SP_REGNUM;
++ cache->reg_saved[SP_REGNUM].addr = -4;
++ }
++
++ else if (rc != 0)
++ {
++ if (value[rb].reg == 0)
++ value[rc].reg = value[ra].reg;
++ else if (value[ra].reg == 0)
++ value[rc].reg = value[rb].reg;
++ else
++ value[rc].reg = -1;
++
++ value[rc].offset = value[ra].offset + value[rb].offset;
++ }
++ prologue_insn = 1;
++ }
++
++ else if ((insn & 0x0001FFFF) == 0x0001983A)
++ {
++ /* SUB rc, ra, rb */
++
++ int ra = GET_IW_A(insn);
++ int rb = GET_IW_B(insn);
++ int rc = GET_IW_C(insn);
++
++ if (rc != 0)
++ {
++ if (value[rb].reg == 0)
++ value[rc].reg = value[ra].reg;
++ else
++ value[rc].reg = -1;
++
++ value[rc].offset = value[ra].offset - value[rb].offset;
++ }
++ }
++
++ else if ((insn & 0x0000003F) == 0x00000004)
++ {
++ /* ADDI rb, ra, immed (also used for MOVI) */
++ short immed = GET_IW_IMM16(insn);
++ int ra = GET_IW_A(insn);
++ int rb = GET_IW_B(insn);
++
++ if (rb == SP_REGNUM)
++ {
++ /* The first stack adjustment is part of the prologue. Any subsequent
++ stack adjustments are either down to alloca or the epilogue so stop
++ analysing when we hit them. */
++ if (value[rb].offset != 0 || value[ra].reg != SP_REGNUM)
++ break;
++ }
++
++ if (rb != 0)
++ {
++ value[rb].reg = value[ra].reg;
++ value[rb].offset = value[ra].offset + immed;
++ }
++
++ prologue_insn = 1;
++ }
++
++ else if ((insn & 0x0000003F) == 0x00000034)
++ {
++ /* ORHI rb, ra, immed (also used for MOVHI) */
++ unsigned int immed = GET_IW_IMM16(insn);
++ int ra = GET_IW_A(insn);
++ int rb = GET_IW_B(insn);
++
++ if (rb != 0)
++ {
++ value[rb].reg = (value[ra].reg == 0) ? 0 : -1;
++ value[rb].offset = value[ra].offset | (immed << 16);
++ }
++ }
++
++ else if (((insn & IW_OP_MASK) == OP_STW || (insn & IW_OP_MASK) == OP_STWIO))
++ {
++ /* STW rb, immediate(ra) */
++
++ short immed16 = GET_IW_IMM16(insn);
++ int ra = GET_IW_A(insn);
++ int rb = GET_IW_B(insn);
++
++ /* Are we storing the original value of a register? For exception handlers
++ * the value of EA-4 (return address from interrupts etc) is sometimes stored.
++ */
++ int orig = value[rb].reg;
++ if (orig > 0 && (value[rb].offset == 0 || (orig == EA_REGNUM && value[rb].offset == -4)))
++ {
++ /* We are most interested in stores to the stack, but will also take note
++ * of stores to other places as they might be useful later.
++ */
++ if ((value[ra].reg == SP_REGNUM && cache->reg_saved[orig].basereg != SP_REGNUM) ||
++ cache->reg_saved[orig].basereg == -1)
++ {
++ if (pc < current_pc)
++ {
++ /* Save off callee saved registers */
++ cache->reg_saved[orig].basereg = value[ra].reg;
++ cache->reg_saved[orig].addr = value[ra].offset + GET_IW_IMM16(insn);
++ }
++
++ prologue_insn = 1;
++
++ if (orig == EA_REGNUM || orig == ESTATUS_REGNUM)
++ exception_handler = 1;
++ }
++ }
++ }
++
++ else if ((insn & 0xFFC1F83F) == 0x0001303A)
++ {
++ /* RDCTL rC, ctlN */
++ int rc = GET_IW_C(insn);
++ int n = GET_IW_CONTROL_REGNUM(insn);
++
++ if (rc != 0)
++ {
++ value[rc].reg = STATUS_REGNUM + n;
++ value[rc].offset = 0;
++ }
++
++ prologue_insn = 1;
++ }
++
++ else if ((insn & 0x0000003F) == 0 &&
++ value[8].reg == RA_REGNUM && value[8].offset == 0 &&
++ value[SP_REGNUM].reg == SP_REGNUM && value[SP_REGNUM].offset == 0)
++ {
++ /* A CALL instruction. This is treated as a call to mcount if ra
++ * has been stored into r8 beforehand and if it's before the stack adjust.
++ * mcount corrupts r2-r3, r9-r15 & ra
++ */
++ for (i = 2 ; i <= 3 ; i++)
++ value[i].reg = -1;
++ for (i = 9 ; i <= 15 ; i++)
++ value[i].reg = -1;
++ value[RA_REGNUM].reg = -1;
++
++ prologue_insn = 1;
++ }
++
++ else if ((insn & 0xF83FFFFF) == 0xD800012E)
++ {
++ /* BGEU sp, rx, +8
++ * BREAK 3
++ * This instruction sequence is used in stack checking - we can ignore it
++ */
++ unsigned int next_insn = read_memory_unsigned_integer(pc, NIOS2_OPCODE_SIZE);
++
++ if (next_insn != 0x003DA0FA)
++ within_prologue = 0;
++ else
++ pc += NIOS2_OPCODE_SIZE;
++ }
++
++ else if ((insn & 0xF800003F) == 0xD8000036)
++ {
++ /* BLTU sp, rx, .Lstackoverflow
++ * If the location branched to holds a BREAK 3 instruction then this is
++ * also stack overflow detection. We can ignore it.
++ */
++ CORE_ADDR target_pc = pc + ((insn & 0x3FFFC0) >> 6);
++ unsigned int target_insn = read_memory_unsigned_integer(target_pc, NIOS2_OPCODE_SIZE);
++
++ if (target_insn != 0x003DA0FA)
++ within_prologue = 0;
++ }
++
++ /* Any other instructions are allowed to be moved up into the prologue. If we
++ reach a branch, call or return then the prologue is considered over */
++ /* We also consider a second stack adjustment as terminating the prologue (see
++ above) */
++
++ else
++ {
++ switch (GET_IW_OP(insn))
++ {
++ case OP_BEQ:
++ case OP_BGE:
++ case OP_BGEU:
++ case OP_BLT:
++ case OP_BLTU:
++ case OP_BNE:
++ case OP_BR:
++ case OP_CALL:
++ within_prologue = 0;
++ break;
++ case OP_OPX:
++ if (GET_IW_OPX(insn) == OPX_RET ||
++ GET_IW_OPX(insn) == OPX_ERET ||
++ GET_IW_OPX(insn) == OPX_BRET ||
++ GET_IW_OPX(insn) == OPX_CALLR ||
++ GET_IW_OPX(insn) == OPX_JMP)
++ {
++ within_prologue = 0;
++ }
++ default:
++ break;
++ }
++ }
++
++ if (prologue_insn)
++ prologue_end = pc;
++ }
++
++ /* Are we within the function epilogue? If so then we should go back to the
++ original register values */
++ if (innermost && current_pc > start_pc)
++ {
++ /* First check whether the previous instruction was a stack
++ adjustment. */
++ unsigned int insn = read_memory_unsigned_integer (current_pc - NIOS2_OPCODE_SIZE, NIOS2_OPCODE_SIZE);
++
++ if ((insn & 0xFFC0003C) == 0xDEC00004 || /* ADDI sp, sp, */
++ (insn & 0xFFC1FFFF) == 0xDEC1883A || /* ADD sp, sp, */
++ (insn & 0xFFC0003F) == 0xDEC00017) /* LDW sp, constant(sp) */
++ {
++ /* Then check if it's followed by a return or a tail call */
++ insn = read_memory_unsigned_integer (current_pc, NIOS2_OPCODE_SIZE);
++
++ if (insn == 0xF800283A || /* RET */
++ insn == 0xE800083A || /* ERET */
++ (insn & 0x07FFFFFF) == 0x0000683A || /* JMP */
++ (insn & 0xFFC0003F) == 6) /* BR */
++ {
++ /* Go back to default value of the registers */
++ nios2_setup_default(cache);
++ }
++ }
++ }
++
++ /* Exception handlers use a different return address register. */
++ if (exception_handler)
++ cache->return_regnum = EA_REGNUM;
++
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "\n-> retreg=%d, ", cache->return_regnum);
++#endif
++
++ if (cache->reg_value[FP_REGNUM].reg == SP_REGNUM)
++ {
++ /* If the FP now holds an offset from the CFA then this is a normal
++ frame which uses the frame pointer. */
++ base_reg = FP_REGNUM;
++ }
++ else if (cache->reg_value[SP_REGNUM].reg == SP_REGNUM)
++ {
++ /* FP doesn't hold an offset from the CFA. If SP still holds an
++ offset from the CFA then we might be in a function which omits
++ the frame pointer, or we might be partway through the prologue.
++ In both cases we can find the CFA using SP. */
++ base_reg = SP_REGNUM;
++ }
++ else
++ {
++ /* Somehow the stack pointer has been corrupted. We can't return. */
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "<can't reach cfa> }\n");
++#endif
++ return 0;
++ }
++
++ if (cache->reg_value[base_reg].offset == 0 ||
++ cache->reg_saved[RA_REGNUM].basereg != SP_REGNUM ||
++ cache->reg_saved[cache->return_regnum].basereg != SP_REGNUM)
++ {
++ /*
++ * If the frame didn't adjust the stack, didn't save RA or didn't save
++ * EA in an exception handler then it must either be a leaf function
++ * (doesn't call any other functions) or it can't return. If it has
++ * called another function then it can't be a leaf, so set base == 0
++ * to indicate that we can't backtrace past it.
++ */
++
++ if (!innermost)
++ {
++ /* If it isn't the innermost function then it can't be a leaf, unless
++ * it was interrupted. Check whether RA for this frame is the same
++ * as PC. If so then it probably wan't interrupted.
++ */
++ char buf[8];
++ CORE_ADDR ra;
++
++ frame_unwind_register (next_frame, RA_REGNUM, buf);
++ ra = extract_typed_address (buf, builtin_type_void_func_ptr);
++
++ if (ra == current_pc)
++ {
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "<noreturn ADJUST 0x%s, r31@r%d+?>, r%d@r%d+?> }\n",
++ paddr_nz(cache->reg_value[base_reg].offset),
++ cache->reg_saved[RA_REGNUM].basereg,
++ cache->return_regnum, cache->reg_saved[cache->return_regnum].basereg);
++#endif
++ return 0;
++ }
++ }
++ }
++
++ /* Get the value of whichever register we are using for the base. */
++ cache->base = frame_unwind_register_unsigned (next_frame, base_reg);
++
++ /* What was the value of SP at the start of this function (or just
++ * after the stack switch).
++ */
++ frame_high = cache->base - cache->reg_value[base_reg].offset;
++
++ /* Adjust all the saved registers such that they contain addresses
++ instead of offsets. */
++ for (i = 0; i < NIOS2_NUM_REGS; i++)
++ if (cache->reg_saved[i].basereg == SP_REGNUM)
++ {
++ cache->reg_saved[i].basereg = Z_REGNUM;
++ cache->reg_saved[i].addr += frame_high;
++ }
++
++ for (i = 0; i < NIOS2_NUM_REGS; i++)
++ if (cache->reg_saved[i].basereg == GP_REGNUM)
++ {
++ CORE_ADDR gp = frame_unwind_register_unsigned (next_frame, GP_REGNUM);
++
++ for ( ; i < NIOS2_NUM_REGS; i++)
++ if (cache->reg_saved[i].basereg == GP_REGNUM)
++ {
++ cache->reg_saved[i].basereg = Z_REGNUM;
++ cache->reg_saved[i].addr += gp;
++ }
++ }
++
++ /* Work out what the value of SP was on the first instruction of this
++ * function. If we didn't switch stacks then this can be trivially
++ * computed from the base address.
++ */
++ if (cache->reg_saved[SP_REGNUM].basereg == Z_REGNUM)
++ {
++ cache->cfa = read_memory_unsigned_integer(cache->reg_saved[SP_REGNUM].addr, 4);
++ }
++ else
++ cache->cfa = frame_high;
++
++ /* Exception handlers restore ESTATUS into STATUS. */
++ if (exception_handler)
++ {
++ cache->reg_saved[STATUS_REGNUM] = cache->reg_saved[ESTATUS_REGNUM];
++ cache->reg_saved[ESTATUS_REGNUM].basereg = -1;
++ }
++
++#ifdef DEBUG_PRINT
++ fprintf_unfiltered (gdb_stdlog, "cfa=0x%s }\n", paddr_nz(cache->cfa));
++#endif
++
++ return prologue_end;
++}
++
++struct frame_info *
++setup_arbitrary_frame (int argc, CORE_ADDR *argv)
++{
++ if (argc != 2)
++ error ("Nios II frame specifications require two arguments: sp and pc");
++
++ return create_new_frame (argv[0], argv[1]);
++}
++
++#ifdef PORTINGTO61
++/* Should be handled by unwind informations. */
++/* However, doing this manually until we can find */
++/* use the CFA information to examine the stack */
++void
++nios2_frame_init_saved_regs (struct frame_info *fi)
++{
++ CORE_ADDR ip;
++
++ /* Examine the entire prologue. */
++ register int frameless_p = 0;
++
++ /* Has this frame's registers already been initialized? */
++ if (fi->saved_regs)
++ return;
++
++ frame_saved_regs_zalloc (fi);
++
++ ip = get_pc_function_start (fi->pc);
++ nios2_examine (ip, fi, frameless_p);
++}
++#endif
++
++
++/* Given a PC value corresponding to the start of a function, return the PC
++ of the first instruction after the function prologue. */
++
++CORE_ADDR
++nios2_skip_prologue (CORE_ADDR start_pc)
++{
++ CORE_ADDR func_addr, func_end;
++ struct symtab_and_line sal;
++ CORE_ADDR pc_after_prologue;
++
++ /* If we have line debugging information, then the end of the prologue
++ should the first assembly instruction of the first source line. */
++ if (find_pc_partial_function (start_pc, NULL, &func_addr, &func_end))
++ {
++ sal = find_pc_line (func_addr, 0);
++ if (sal.end > 0 && sal.end < func_end)
++ return sal.end;
++ }
++
++ return start_pc;
++}
++
++/* nios2_software_single_step() is called just before we want to resume
++ the inferior, if we want to single-step it but there is no hardware
++ or kernel single-step support (NIOS2 on GNU/Linux for example). We find
++ the target of the coming instruction and breakpoint it.
++
++ single_step is also called just after the inferior stops. If we had
++ set up a simulated single-step, we undo our damage. */
++
++void
++nios2_software_single_step (enum target_signal sig, int insert_breakpoints_p)
++{
++ int ii;
++ unsigned int insn;
++ CORE_ADDR pc;
++ CORE_ADDR breaks[2];
++ int imme;
++
++ if (insert_breakpoints_p)
++ {
++ pc = read_pc ();
++ breaks[0] = pc + 4;
++ breaks[1] = -1;
++ insn = read_memory_unsigned_integer (pc, 4);
++
++ /* Calculate the destination of a branch/jump */
++ switch (GET_IW_OP(insn))
++ {
++ /* I-type branch */
++ case OP_BEQ:
++ case OP_BGE:
++ case OP_BGEU:
++ case OP_BLT:
++ case OP_BLTU:
++ case OP_BNE:
++ imme = (short) GET_IW_IMM16(insn);
++ breaks[1] = pc + 4 + imme;
++ break;
++ case OP_BR:
++ imme = (short) GET_IW_IMM16(insn);
++ breaks[0] = pc + 4 + imme;
++ break;
++ /* J-type branch */
++ case OP_CALL:
++ case OP_JMPI:
++ imme = GET_IW_IMM26(insn);
++ breaks[0] = (pc & 0xf0000000) | (imme * 4);
++ break;
++ /* R-type branch */
++ case OP_OPX:
++ switch (GET_IW_OPX(insn))
++ {
++ case OPX_CALLR:
++ case OPX_JMP:
++ case OPX_RET:
++ imme = read_register (GET_IW_A(insn));
++ breaks[0] = imme;
++ break;
++ }
++ break;
++ }
++
++ /* Don't put two breakpoints on the same address. */
++ if (breaks[1] == breaks[0])
++ breaks[1] = -1;
++
++ for (ii = 0; ii < 2; ++ii)
++ {
++ /* ignore invalid breakpoint. */
++ if (breaks[ii] == -1)
++ continue;
++ insert_single_step_breakpoint (breaks[ii]);
++ }
++ }
++ else
++ remove_single_step_breakpoints ();
++
++}
++
++const unsigned char*
++nios2_breakpoint_from_pc (CORE_ADDR *bp_addr, int *bp_size)
++{
++ /* break encoding: 31->27 26->22 21->17 16->11 10->6 5->0 */
++ /* 00000 00000 0x1e 0x34 00000 0x3a */
++ /* 00000 00000 11110 110100 00000 111010 */
++ /* In bytes: 00000000 00111101 10100000 00111010 */
++ /* 0x0 0x3d 0xa0 0x3a */
++#if 0
++ static unsigned char breakpoint[] = {0x3a, 0xa0, 0x3d, 0x0};
++#else
++ static unsigned char breakpoint[] = {0x7a, 0x68, 0x3b, 0x0}; /* Trap instr. w/imm=0x01 */
++#endif
++ *bp_size = 4;
++ return breakpoint;
++}
++
++
++int
++gdb_print_insn_nios2 (bfd_vma memaddr, disassemble_info *info)
++{
++ if (info->endian == BFD_ENDIAN_BIG)
++ {
++ return print_insn_big_nios2 (memaddr, info);
++ }
++ else
++ {
++ return print_insn_little_nios2 (memaddr, info);
++ }
++}
++
++
++
++/* Adjust the address downward (direction of stack growth) so that it
++ is correctly aligned for a new stack frame. */
++
++/* ??? Big endian issues here? */
++
++static CORE_ADDR
++nios2_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
++{
++ return align_down (addr, 4);
++}
++
++
++
++/* We don't convert anything at the moment */
++static int
++nios2_convert_register_p (int regnum, struct type *type)
++{
++ return 0;
++}
++
++static void
++nios2_register_to_value (struct frame_info *frame, int regnum,
++ struct type *type, void *to)
++{
++ get_frame_register (frame, regnum + 0, (char *) to + 0);
++ get_frame_register (frame, regnum + 0, (char *) to + 0);
++}
++
++static void
++nios2_value_to_register (struct frame_info *frame, int regnum,
++ struct type *type, const void *from)
++{
++ put_frame_register (frame, regnum + 0, (const char *) from + 0);
++ put_frame_register (frame, regnum + 0, (const char *) from + 0);
++}
++
++/* Determine, for architecture GDBARCH, how a return value of TYPE
++ should be returned. If it is supposed to be returned in registers,
++ and READBUF is non-zero, read the appropriate value from REGCACHE,
++ and copy it into READBUF. If WRITEBUF is non-zero, write the value
++ from WRITEBUF into REGCACHE. */
++
++static enum return_value_convention
++nios2_return_value (struct gdbarch *gdbarch, struct type *type,
++ struct regcache *regcache, void *readbuf,
++ const void *writebuf)
++{
++ enum type_code code = TYPE_CODE (type);
++
++ /* FIXME PBrookes add struct return function */
++ if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
++ /*&& !nios2_reg_struct_return_p (gdbarch, type)*/)
++ return RETURN_VALUE_STRUCT_CONVENTION;
++
++
++ if (readbuf)
++ nios2_extract_return_value (type, regcache, readbuf);
++ if (writebuf)
++ nios2_store_return_value (type, regcache);
++
++ return RETURN_VALUE_REGISTER_CONVENTION;
++}
++
++/* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that
++ dummy frame. The frame ID's base needs to match the TOS value
++ saved by save_dummy_frame_tos() and returned from
++ nios2_push_dummy_call, and the PC needs to match the dummy frame's
++ breakpoint. */
++
++static struct frame_id
++nios2_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
++{
++ return frame_id_build (frame_unwind_register_unsigned (next_frame, SP_REGNUM),
++ frame_pc_unwind (next_frame));
++}
++
++static CORE_ADDR
++nios2_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
++{
++ char buf[8];
++
++ frame_unwind_register (next_frame, PC_REGNUM, buf);
++ return extract_typed_address (buf, builtin_type_void_func_ptr);
++}
++
++
++/* Frame base handling. */
++
++struct nios2_unwind_cache *
++nios2_frame_unwind_cache (struct frame_info *next_frame,
++ void **this_prologue_cache)
++{
++ CORE_ADDR current_pc;
++ struct nios2_unwind_cache *cache;
++ int i;
++
++ if (*this_prologue_cache)
++ return *this_prologue_cache;
++
++ cache = FRAME_OBSTACK_ZALLOC (struct nios2_unwind_cache);
++ (*this_prologue_cache) = cache;
++
++ /* Zero all fields. */
++ cache->base = 0;
++ cache->cfa = 0;
++ cache->pc = 0;
++
++ cache->return_regnum = RA_REGNUM;
++
++ nios2_setup_default(cache);
++
++ cache->pc = frame_func_unwind (next_frame);
++ current_pc = frame_pc_unwind (next_frame);
++
++ /* Prologue analysis does the rest... */
++ if (cache->pc != 0)
++ nios2_analyze_prologue (cache->pc, current_pc, cache, next_frame);
++
++ return cache;
++}
++
++static void
++nios2_frame_this_id (struct frame_info *next_frame, void **this_cache,
++ struct frame_id *this_id)
++{
++ struct nios2_unwind_cache *cache =
++ nios2_frame_unwind_cache (next_frame, this_cache);
++
++ /* This marks the outermost frame. */
++ if (cache->base == 0)
++ return;
++
++ (*this_id) = frame_id_build (cache->cfa, cache->pc);
++}
++
++static void
++nios2_frame_prev_register (struct frame_info *next_frame, void **this_cache,
++ int regnum, int *optimizedp,
++ enum lval_type *lvalp, CORE_ADDR *addrp,
++ int *realnump, void *valuep)
++{
++ struct nios2_unwind_cache *cache =
++ nios2_frame_unwind_cache (next_frame, this_cache);
++
++ gdb_assert (regnum >= 0);
++
++ /* The PC of the previous frame is stored in the RA register of
++ the current frame. Frob regnum so that we pull the value from
++ the correct place. */
++ if (regnum == PC_REGNUM)
++ regnum = cache->return_regnum;
++
++ /* If we've worked out where a register is stored then load it from there.
++ */
++ if (regnum < NIOS2_NUM_REGS && cache->reg_saved[regnum].basereg == Z_REGNUM)
++ {
++ *optimizedp = 0;
++ *lvalp = lval_memory;
++ *addrp = cache->reg_saved[regnum].addr;
++ *realnump = -1;
++ if (valuep)
++ {
++ /* Read the value in from memory. */
++ read_memory (*addrp, valuep,
++ register_size (current_gdbarch, regnum));
++ }
++ return;
++ }
++
++ if (regnum == SP_REGNUM && cache->cfa)
++ {
++ *optimizedp = 0;
++ *lvalp = not_lval;
++ *addrp = 0;
++ *realnump = -1;
++ if (valuep)
++ {
++ /* Store the value. */
++ store_unsigned_integer (valuep, 8, cache->cfa);
++ }
++ return;
++ }
++
++ frame_register_unwind (next_frame, regnum,
++ optimizedp, lvalp, addrp, realnump, valuep);
++}
++
++
++
++static const struct frame_unwind nios2_frame_unwind =
++{
++ NORMAL_FRAME,
++ nios2_frame_this_id,
++ nios2_frame_prev_register
++};
++
++static CORE_ADDR
++nios2_frame_base_address (struct frame_info *next_frame, void **this_cache)
++{
++ struct nios2_unwind_cache *info
++ = nios2_frame_unwind_cache (next_frame, this_cache);
++ return info->base;
++}
++
++static const struct frame_base nios2_frame_base =
++{
++ &nios2_frame_unwind,
++ nios2_frame_base_address,
++ nios2_frame_base_address,
++ nios2_frame_base_address
++};
++
++static const struct frame_unwind *
++nios2_frame_sniffer (struct frame_info *next_frame)
++{
++ return &nios2_frame_unwind;
++}
++
++
++static struct gdbarch *
++nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
++{
++ struct gdbarch *gdbarch;
++ int register_bytes, i;
++
++ /* Change the register names based on the current machine type. */
++ if (info.bfd_arch_info->arch != bfd_arch_nios2)
++ return NULL;
++
++ /* None found, create a new architecture from the information
++ provided. We don't have any architecture specific state, so just
++ pass in 0 for the struct gdbarch_tdep parameter. */
++ gdbarch = gdbarch_alloc (&info, NULL);
++
++ /* Data type sizes. */
++ set_gdbarch_ptr_bit (gdbarch, 32);
++ set_gdbarch_addr_bit (gdbarch, 32);
++ set_gdbarch_short_bit (gdbarch, 16);
++ set_gdbarch_int_bit (gdbarch, 32);
++ set_gdbarch_long_bit (gdbarch, 32);
++ set_gdbarch_long_long_bit (gdbarch, 64);
++ set_gdbarch_float_bit (gdbarch, 32);
++ set_gdbarch_double_bit (gdbarch, 64);
++
++ switch (info.byte_order)
++ {
++ case BFD_ENDIAN_BIG:
++ set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_big);
++ set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_big);
++ break;
++
++ case BFD_ENDIAN_LITTLE:
++ set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
++ set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_little);
++ break;
++
++ default:
++ internal_error (__FILE__, __LINE__,
++ "nios2_gdbarch_init: bad byte ordering");
++ break;
++ }
++
++ /* The register set. */
++ set_gdbarch_num_regs (gdbarch, NIOS2_NUM_REGS);
++ set_gdbarch_sp_regnum (gdbarch, SP_REGNUM);
++ set_gdbarch_pc_regnum (gdbarch, PC_REGNUM); /* Pseudo register PC */
++
++ set_gdbarch_register_name (gdbarch, nios2_register_name);
++ /* Length of ordinary registers used in push_word and a few other
++ places. DEPRECATED_REGISTER_RAW_SIZE is the real way to know how
++ big a register is. */
++/* FIXME
++ set_gdbarch_deprecated_register_size (gdbarch, 4);
++ set_gdbarch_deprecated_register_virtual_type (gdbarch,
++ nios2_register_virtual_type);
++*/
++
++ set_gdbarch_register_type (gdbarch, nios2_register_type);
++
++ /* The "default" register numbering scheme for AMD64 is referred to
++ as the "DWARF Register Number Mapping" in the System V psABI.
++ The preferred debugging format for all known Nios II targets is
++ actually DWARF2, and GCC doesn't seem to support DWARF (that is
++ DWARF-1), but we provide the same mapping just in case. This
++ mapping is also used for stabs, which GCC does support. */
++ set_gdbarch_stab_reg_to_regnum (gdbarch, nios2_dwarf_reg_to_regnum);
++ set_gdbarch_dwarf_reg_to_regnum (gdbarch, nios2_dwarf_reg_to_regnum);
++ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, nios2_dwarf_reg_to_regnum);
++
++ set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
++
++ /* Call dummy code. */
++ set_gdbarch_frame_align (gdbarch, nios2_frame_align);
++
++ /* Some registers require conversion from raw format to virtual format. */
++/* FIXME
++ set_gdbarch_deprecated_register_convertible (gdbarch, nios2_register_convertible);
++*/
++
++ set_gdbarch_convert_register_p (gdbarch, nios2_convert_register_p);
++ set_gdbarch_register_to_value (gdbarch, nios2_register_to_value);
++ set_gdbarch_value_to_register (gdbarch, nios2_value_to_register);
++
++ set_gdbarch_return_value (gdbarch, nios2_return_value);
++
++ set_gdbarch_skip_prologue (gdbarch, nios2_skip_prologue);
++ set_gdbarch_breakpoint_from_pc (gdbarch, nios2_breakpoint_from_pc);
++ set_gdbarch_software_single_step (gdbarch, nios2_software_single_step);
++
++ set_gdbarch_unwind_dummy_id (gdbarch, nios2_unwind_dummy_id);
++ set_gdbarch_unwind_pc (gdbarch, nios2_unwind_pc);
++
++ /* The dwarf2 unwinder will normally produce the best results if the
++ debug information is available, so register it first. */
++ frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
++
++ /* FIXME: PBrookes - copied from AMD64-TDEP.c (kettenis/20021026):
++ This is ELF-specific. Fine for now, since all supported NIOS II
++ targets are ELF, but that might change in the future. */
++/* FIXME again.. Does not exist anymore...
++ set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
++*/
++
++ frame_unwind_append_sniffer (gdbarch, nios2_frame_sniffer);
++
++ frame_base_set_default (gdbarch, &nios2_frame_base);
++
++ set_gdbarch_print_insn (gdbarch, gdb_print_insn_nios2);
++
++ return gdbarch;
++}
++
++void
++_initialize_nios2_tdep (void)
++{
++ register_gdbarch_init (bfd_arch_nios2, nios2_gdbarch_init);
++
++ int i, offset = 0;
++
++ /* Do not display anything after NIOS2_MAX_REG_DISPLAYED_REGNUM */
++ for (i = 0; i <= NIOS2_MAX_REG_DISPLAYED_REGNUM; i++)
++ {
++ nios2_register_byte_table[i] = offset;
++ offset += nios2_register_info_table[i].size;
++ }
++
++ for (i = NIOS2_MAX_REG_DISPLAYED_REGNUM + 1; i <= NIOS2_NUM_REGS; i++)
++ {
++ nios2_register_byte_table[i] = -1;
++ }
++
++}
+diff --git a/gdb/regformats/reg-nios2.dat b/gdb/regformats/reg-nios2.dat
+new file mode 100644
+index 0000000..77b39a9
+--- /dev/null
++++ b/gdb/regformats/reg-nios2.dat
+@@ -0,0 +1,46 @@
++name:nios2
++expedite:sp,fp,pc
++32:zero
++32:at
++32:r2
++32:r3
++32:r4
++32:r5
++32:r6
++32:r7
++32:r8
++32:r9
++32:r10
++32:r11
++32:r12
++32:r13
++32:r14
++32:r15
++32:r16
++32:r17
++32:r18
++32:r19
++32:r20
++32:r21
++32:r22
++32:r23
++32:et
++32:bt
++32:gp
++32:sp
++32:fp
++32:ea
++32:ba
++32:ra
++32:pc
++32:status
++32:estatus
++32:bstatus
++32:ienable
++32:ipending
++32:cpuid
++32:ctl6
++32:ctl7
++32:pteaddr
++32:tlbacc
++32:tlbmisc
+diff --git a/gdb/testsuite/config/nios2-iss.exp b/gdb/testsuite/config/nios2-iss.exp
+new file mode 100644
+index 0000000..624f831
+--- /dev/null
++++ b/gdb/testsuite/config/nios2-iss.exp
+@@ -0,0 +1,233 @@
++# Test framework for GDB (remote protocol) using a "gdbserver",
++# ie. a debug agent running as a native process on the same or
++# a different host.
++
++# Copyright 2000, 2002 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++# This file was written by Michael Snyder. (msnyder@redhat.com)
++
++#
++# This module to be used for testing gdb with a "gdbserver"
++# built either from libremote or from gdb/gdbserver.
++#
++
++# Load the basic testing library, and the remote stuff.
++load_lib ../config/monitor.exp
++
++#
++# To be addressed or set in your baseboard config file:
++#
++# set_board_info gdb_protocol "remote"
++# Unles you have a gdbserver that uses a different protocol...
++#
++# set_board_info use_gdb_stub 1
++# This tells the rest of the test suite not to do things
++# like "run" which don't work well on remote targets.
++#
++# set_board_info gdb,do_reload_on_run 1
++# Unles you have a gdbserver that can handle multiple sessions.
++#
++# set_board_info noargs 1
++# At present there is no provision in the remote protocol
++# for passing arguments. This test framework does not
++# address the issue, so it's best to set this variable
++# in your baseboard configuration file.
++# FIXME: there's no reason why the test harness couldn't
++# pass commandline args when it spawns gdbserver.
++#
++# set_board_info gdb,noinferiorio 1
++# Neither the traditional gdbserver nor the one in libremote
++# can presently capture stdout and relay it to GDB via the
++# 'O' packet. This means that tests involving printf will
++# fail unles you set this varibale in your baseboard
++# configuration file.
++#
++# set_board_info gdb,no_hardware_watchpoints 1
++# Unles you have a gdbserver that supports hardware watchpoints.
++# FIXME: gdb should detect if the target doesn't support them,
++# and fall back to using software watchpoints.
++#
++# set_board_info gdb_server_prog
++# This will be the path to the gdbserver program you want to test.
++# Defaults to "gdbserver".
++#
++# set_board_info sockethost
++# The name of the host computer whose socket is being used.
++# Defaults to "localhost". Note: old gdbserver requires
++# that you define this, but libremote/gdbserver does not.
++#
++# set_board_info socketport
++# Port id to use for socket connection. If not set explicitly,
++# it will start at "9996" and increment for each use.
++#
++
++
++
++#
++# gdb_load -- load a file into the debugger.
++# return a -1 if anything goes wrong.
++#
++
++global server_exec;
++global portnum;
++set portnum "9996";
++
++proc gdb_load { arg } {
++ global host_exec;
++ global server_exec;
++ global portnum;
++ global verbose;
++ global gdb_prompt;
++
++ regsub "/cygdrive/c" $arg "c:" arg
++ regsub "/cygdrive/d" $arg "d:" arg
++ regsub "/cygdrive/e" $arg "e:" arg
++ regsub "/cygdrive/q" $arg "q:" arg
++ regsub "/cygdrive/r" $arg "r:" arg
++
++ # Always kill and restart quest (or try to before loading)
++ slay quest
++ slay gdb
++
++ # Port id -- either specified in baseboard file, or managed here.
++ if [target_info exists gdb,socketport] {
++ set portnum [target_info gdb,socketport];
++ } else {
++ # Bump the port number to avoid conflicts with hung ports.
++ incr portnum;
++ }
++
++ verbose "gdb_load : portnum = $portnum arg = $arg"
++ # Extract the local and remote host ids from the target board struct.
++
++ if [target_info exists sockethost] {
++ set debughost [target_info sockethost];
++ } else {
++ set debughost "localhost:";
++ }
++ # Extract the protocol
++ if [target_info exists gdb_protocol] {
++ set protocol [target_info gdb_protocol];
++ } else {
++ set protocol "remote";
++ }
++
++ # Extract the name of the gdbserver, if known (default 'gdbserver').
++ if [target_info exists gdb_server_prog] {
++ set gdbserver [target_info gdb_server_prog];
++ } else {
++ set gdbserver "gdbserver";
++ }
++
++ verbose "gdbserver is set to $gdbserver"
++ # Extract the socket hostname
++ if [target_info exists sockethost] {
++ set sockethost [target_info sockethost];
++ } else {
++ set sockethost ""
++ }
++
++ # Export the host:port pair.
++ set gdbport $debughost$portnum;
++ verbose "gdbport is now $gdbport"
++ # Remember new exec file.
++ if { $arg == "" } {
++ if { ! [info exists host_exec] } {
++ send_gdb "info files\n";
++ gdb_expect 30 {
++ -re "Symbols from \"(\[^\"\]+)\"" {
++ set host_exec $expect_out(1,string);
++ exp_continue;
++ }
++ -re "Local exec file:\[\r\n\]+\[ \t\]*`(\[^'\]+)'," {
++ set host_exec $expect_out(1,string);
++ exp_continue;
++ }
++ -re "$gdb_prompt $" { }
++ }
++ }
++ } else {
++ set host_exec $arg
++ if [info exists server_exec] { unset server_exec }
++ }
++
++ # Fire off the debug agent
++ if [target_info exists gdb_server_args] {
++ # This flavour of gdbserver takes as arguments those specified
++ # in the board configuration file
++ set custom_args [target_info gdb_server_args];
++ set launch_return [eval remote_spawn host \{ $gdbserver $custom_args \} $arg ]
++ verbose "spawned $gdbserver $custom_args $arg with return code $launch_return"
++ } else {
++ # This flavour of gdbserver takes as arguments the port information
++ # and the name of the executable file to be debugged.
++ set server_spawn_id [remote_spawn target\
++ "$gdbserver $sockethost$portnum "]
++ verbose "remote_spawn $gdbserver $sockethost$portnum"
++ }
++
++ # We can't call close, because if gdbserver is local then that means
++ # that it will get a SIGHUP.
++ ## close -i $server_spawn_id
++ #wait -nowait -i $server_spawn_id
++
++ # Give it a little time to establish
++ sleep 1
++
++ # tell gdb what file we are debugging
++ if { $arg != "" } {
++ if [gdb_file_cmd $arg] {
++ return -1;
++ }
++ }
++ verbose "gdb_file_cmd has been called with $arg"
++
++ # attach to the "serial port"
++ gdb_target_cmd $protocol $gdbport;
++
++ # do the real load if needed
++ if [target_info exists gdb_server_do_load] {
++ send_gdb "load\n"
++ set timeout 2400
++ verbose "Timeout is now $timeout seconds" 2
++ gdb_expect {
++ -re ".*$gdb_prompt $" {
++ if $verbose>1 then {
++ send_user "Loaded $arg into $GDB\n"
++ }
++ set timeout 30
++ verbose "Timeout is now $timeout seconds" 2
++ return 1
++ }
++ -re "$gdb_prompt $" {
++ if $verbose>1 then {
++ perror "GDB couldn't load."
++ }
++ }
++ timeout {
++ if $verbose>1 then {
++ perror "Timed out trying to load $arg."
++ }
++ }
++ }
++ }
++
++ return 0;
++}
+diff --git a/include/dis-asm.h b/include/dis-asm.h
+index af48e85..e3d84ab 100644
+--- a/include/dis-asm.h
++++ b/include/dis-asm.h
+@@ -280,6 +280,8 @@ extern int print_insn_xtensa (bfd_vma, disassemble_info *);
+ extern int print_insn_z80 (bfd_vma, disassemble_info *);
+ extern int print_insn_z8001 (bfd_vma, disassemble_info *);
+ extern int print_insn_z8002 (bfd_vma, disassemble_info *);
++extern int print_insn_little_nios2 (bfd_vma, disassemble_info *);
++extern int print_insn_big_nios2 (bfd_vma, disassemble_info *);
+
+ extern disassembler_ftype arc_get_disassembler (void *);
+ extern disassembler_ftype cris_get_disassembler (bfd *);
+diff --git a/include/elf/nios2.h b/include/elf/nios2.h
+new file mode 100644
+index 0000000..ef810c5
+--- /dev/null
++++ b/include/elf/nios2.h
+@@ -0,0 +1,65 @@
++/* Altera New Jersey ELF support for BFD
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of BFD, the Binary File Descriptor library.
++
++This program is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++/* This file holds definitions specific to the Altera New Jersey ELF ABI. Note
++ that most of this is not actually implemented by BFD. */
++
++#ifndef _ELF_NIOS2_H
++#define _ELF_NIOS2_H
++
++#include "elf/reloc-macros.h"
++
++/* the order of these numbers must match the order in
++ the elf_nios2_howto_table_rel table for the lookup
++ function to work properly */
++
++START_RELOC_NUMBERS (elf_nios2_reloc_type)
++ RELOC_NUMBER (R_NIOS2_NONE, 0)
++ RELOC_NUMBER (R_NIOS2_S16, 1)
++ RELOC_NUMBER (R_NIOS2_U16, 2)
++ RELOC_NUMBER (R_NIOS2_PCREL16, 3)
++ RELOC_NUMBER (R_NIOS2_CALL26, 4)
++ RELOC_NUMBER (R_NIOS2_IMM5, 5)
++ RELOC_NUMBER (R_NIOS2_CACHE_OPX, 6)
++ RELOC_NUMBER (R_NIOS2_IMM6, 7)
++ RELOC_NUMBER (R_NIOS2_IMM8, 8)
++ RELOC_NUMBER (R_NIOS2_HI16, 9)
++ RELOC_NUMBER (R_NIOS2_LO16, 10)
++ RELOC_NUMBER (R_NIOS2_HIADJ16, 11)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_32, 12)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_16, 13)
++ RELOC_NUMBER (R_NIOS2_BFD_RELOC_8, 14)
++ RELOC_NUMBER (R_NIOS2_GPREL, 15)
++ RELOC_NUMBER (R_NIOS2_GNU_VTINHERIT, 16)
++ RELOC_NUMBER (R_NIOS2_GNU_VTENTRY, 17)
++ RELOC_NUMBER (R_NIOS2_UJMP, 18)
++ RELOC_NUMBER (R_NIOS2_CJMP, 19)
++ RELOC_NUMBER (R_NIOS2_CALLR, 20)
++ RELOC_NUMBER (R_NIOS2_ALIGN, 21)
++ RELOC_NUMBER (R_NIOS2_ILLEGAL, 22)
++END_RELOC_NUMBERS (R_NIOS2_maxext)
++
++/* Processor specific section flags */
++
++/* This is used to mark gp-relative sections */
++#define SHF_NIOS2_GPREL 0x10000000
++
++#endif //_ELF_NIOS2_H
+diff --git a/include/opcode/nios2-isa.h b/include/opcode/nios2-isa.h
+new file mode 100644
+index 0000000..0023880
+--- /dev/null
++++ b/include/opcode/nios2-isa.h
+@@ -0,0 +1,1860 @@
++/*
++ * This file defines Nios II instruction set constants.
++ * To include it in assembly code (.S file), define ALT_ASM_SRC
++ * before including this file.
++ *
++ * This file is automatically generated by gen_isa.pl - do not edit
++ */
++
++#ifndef _NIOS2_ISA_H_
++#define _NIOS2_ISA_H_
++
++/* OP instruction opcode values (index is OP field) */
++#define NUM_OP_INSTS 64
++
++#ifndef ALT_ASM_SRC
++extern const char* op_names[NUM_OP_INSTS];
++#endif /* ALT_ASM_SRC */
++
++/* OPX instruction opcode values (index is OPX field) */
++#define NUM_OPX_INSTS 64
++
++#ifndef ALT_ASM_SRC
++extern const char* opx_names[NUM_OPX_INSTS];
++#endif /* ALT_ASM_SRC */
++
++/* Constants for instruction fields and ISA */
++#define CPU_RESET_EXC_ID 1
++#define DIV_ERROR_EXC_ID 9
++#define DTLB_MISS_EXC_ID 15
++#define DTLB_PERM_EXC_ID 16
++#define FAST_INTR_EXC_ID 3
++#define HBREAK_EXC_ID 0
++#define ITLB_MISS_EXC_ID 13
++#define ITLB_PERM_EXC_ID 14
++#define MISALIGNED_DATA_ADDR_EXC_ID 7
++#define MISALIGNED_TARGET_PC_EXC_ID 8
++#define NMI_EXC_ID 2
++#define NORM_INTR_EXC_ID 4
++#define SBREAK_EXC_ID 6
++#define SLAVE_DATA_ACCESS_ERROR_EXC_ID 18
++#define SLAVE_INST_ACCESS_ERROR_EXC_ID 17
++#define SUPERVISOR_DATA_ADDR_EXC_ID 12
++#define SUPERVISOR_INST_ADDR_EXC_ID 10
++#define SUPERVISOR_INST_EXC_ID 11
++#define TRAP_EXC_ID 5
++#define AT_REGNUM 1
++#define BRETADDR_REGNUM 30
++#define BSTATUS_REG_LSB 2
++#define BSTATUS_REG_MMU_LSB 0
++#define BSTATUS_REG_MMU_MSB 2
++#define BSTATUS_REG_MMU_SZ 3
++#define BSTATUS_REG_MMU_MASK 0x7
++#define BSTATUS_REG_NO_MMU_LSB 0
++#define BSTATUS_REG_NO_MMU_MSB 0
++#define BSTATUS_REG_NO_MMU_SZ 1
++#define BSTATUS_REG_NO_MMU_MASK 0x1
++#define BSTATUS_REG_REGNUM 2
++#define BSTATUS_REG_SZ 3
++#define BSTATUS_REG_MASK 0x7
++#define BT_REGNUM 25
++#define CACHE_MAX_BYTES 65536
++#define CACHE_MAX_LINE_BYTES 32
++#define CACHE_MIN_LINE_BYTES 4
++#define COMPARE_OP_EQ 0x0
++#define COMPARE_OP_GE 0x1
++#define COMPARE_OP_LSB 3
++#define COMPARE_OP_LT 0x2
++#define COMPARE_OP_MSB 4
++#define COMPARE_OP_NE 0x3
++#define COMPARE_OP_SZ 2
++#define COMPARE_OP_MASK 0x3
++#define CPUID_REG_LSB 0
++#define CPUID_REG_MSB 31
++#define CPUID_REG_REGNUM 5
++#define CPUID_REG_SZ 32
++#define CPUID_REG_MASK 0xffffffff
++#define DATAPATH_LOG2_SZ 5
++#define DATAPATH_LOG2_MASK 0x1f
++#define DATAPATH_LSB 0
++#define DATAPATH_MSB 31
++#define DATAPATH_SZ 32
++#define DATAPATH_MASK 0xffffffff
++#define EMPTY_CRST_IW 127034
++#define EMPTY_HBREAK_IW 4040762
++#define EMPTY_INTR_IW 3926074
++#define EMPTY_NOP_IW 100410
++#define EMPTY_RET_IW 4160759866
++#define ERETADDR_REGNUM 29
++#define ESTATUS_REG_LSB 0
++#define ESTATUS_REG_MMU_LSB 0
++#define ESTATUS_REG_MMU_MSB 2
++#define ESTATUS_REG_MMU_SZ 3
++#define ESTATUS_REG_MMU_MASK 0x7
++#define ESTATUS_REG_MSB 2
++#define ESTATUS_REG_NO_MMU_LSB 0
++#define ESTATUS_REG_NO_MMU_MSB 0
++#define ESTATUS_REG_NO_MMU_SZ 1
++#define ESTATUS_REG_NO_MMU_MASK 0x1
++#define ESTATUS_REG_REGNUM 1
++#define ESTATUS_REG_SZ 3
++#define ESTATUS_REG_MASK 0x7
++#define ET_REGNUM 24
++#define EXCEPTION_REG_LSB 0
++#define EXCEPTION_REG_MEA_LSB 0
++#define EXCEPTION_REG_MEA_MSB 0
++#define EXCEPTION_REG_MEA_SZ 1
++#define EXCEPTION_REG_MEA_MASK 0x1
++#define EXCEPTION_REG_MEE_LSB 1
++#define EXCEPTION_REG_MEE_MSB 1
++#define EXCEPTION_REG_MEE_SZ 1
++#define EXCEPTION_REG_MEE_MASK 0x1
++#define EXCEPTION_REG_MSB 1
++#define EXCEPTION_REG_REGNUM 7
++#define EXCEPTION_REG_SZ 2
++#define EXCEPTION_REG_MASK 0x3
++#define FP_REGNUM 28
++#define FSTATUS_REG_REGNUM 11
++#define GP_REGNUM 26
++#define IENABLE_REG_LSB 0
++#define IENABLE_REG_MSB 31
++#define IENABLE_REG_REGNUM 3
++#define IENABLE_REG_SZ 32
++#define IENABLE_REG_MASK 0xffffffff
++#define IPENDING_REG_LSB 0
++#define IPENDING_REG_MSB 31
++#define IPENDING_REG_REGNUM 4
++#define IPENDING_REG_SZ 32
++#define IPENDING_REG_MASK 0xffffffff
++#define IW_A_LSB 27
++#define IW_A_MSB 31
++#define IW_A_SZ 5
++#define IW_A_MASK 0x1f
++#define IW_B_LSB 22
++#define IW_B_MSB 26
++#define IW_B_SZ 5
++#define IW_B_MASK 0x1f
++#define IW_C_LSB 17
++#define IW_C_MSB 21
++#define IW_C_SZ 5
++#define IW_C_MASK 0x1f
++#define IW_CONTROL_REGNUM_BASE 0
++#define IW_CONTROL_REGNUM_LSB 6
++#define IW_CONTROL_REGNUM_MSB 9
++#define IW_CONTROL_REGNUM_SZ 4
++#define IW_CONTROL_REGNUM_MASK 0xf
++#define IW_CUSTOM_N_LSB 6
++#define IW_CUSTOM_N_MSB 13
++#define IW_CUSTOM_N_SZ 8
++#define IW_CUSTOM_N_MASK 0xff
++#define IW_CUSTOM_READRA_LSB 16
++#define IW_CUSTOM_READRA_MSB 16
++#define IW_CUSTOM_READRA_SZ 1
++#define IW_CUSTOM_READRA_MASK 0x1
++#define IW_CUSTOM_READRB_LSB 15
++#define IW_CUSTOM_READRB_MSB 15
++#define IW_CUSTOM_READRB_SZ 1
++#define IW_CUSTOM_READRB_MASK 0x1
++#define IW_CUSTOM_WRITERC_LSB 14
++#define IW_CUSTOM_WRITERC_MSB 14
++#define IW_CUSTOM_WRITERC_SZ 1
++#define IW_CUSTOM_WRITERC_MASK 0x1
++#define IW_IMM16_LSB 6
++#define IW_IMM16_MSB 21
++#define IW_IMM16_SZ 16
++#define IW_IMM16_MASK 0xffff
++#define IW_IMM26_LSB 6
++#define IW_IMM26_MSB 31
++#define IW_IMM26_SZ 26
++#define IW_IMM26_MASK 0x3ffffff
++#define IW_MEMSZ_BYTE 0x0
++#define IW_MEMSZ_HWORD 0x1
++#define IW_MEMSZ_LSB 3
++#define IW_MEMSZ_MSB 4
++#define IW_MEMSZ_SZ 2
++#define IW_MEMSZ_MASK 0x3
++#define IW_MEMSZ_WORD 0x2
++#define IW_MEMSZ_WORD_MSB 0x1
++#define IW_OP_LSB 0
++#define IW_OP_MSB 5
++#define IW_OP_SZ 6
++#define IW_OP_MASK 0x3f
++#define IW_OPX_LSB 11
++#define IW_OPX_MSB 16
++#define IW_OPX_SZ 6
++#define IW_OPX_MASK 0x3f
++#define IW_SHIFT_IMM5_LSB 6
++#define IW_SHIFT_IMM5_MSB 10
++#define IW_SHIFT_IMM5_SZ 5
++#define IW_SHIFT_IMM5_MASK 0x1f
++#define IW_SZ 32
++#define IW_MASK 0xffffffff
++#define IW_TRAP_BREAK_IMM5_LSB 6
++#define IW_TRAP_BREAK_IMM5_MSB 10
++#define IW_TRAP_BREAK_IMM5_SZ 5
++#define IW_TRAP_BREAK_IMM5_MASK 0x1f
++#define JMP_CALLR_VS_RET_IS_RET 0
++#define JMP_CALLR_VS_RET_OPX_BIT 3
++#define LOGIC_OP_AND 0x1
++#define LOGIC_OP_LSB 3
++#define LOGIC_OP_MSB 4
++#define LOGIC_OP_NOR 0x0
++#define LOGIC_OP_OR 0x2
++#define LOGIC_OP_SZ 2
++#define LOGIC_OP_MASK 0x3
++#define LOGIC_OP_XOR 0x3
++#define MMU_ADDR_BYPASS_TLB 0x3
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE 0x0
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB 29
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_MSB 29
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_SZ 1
++#define MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK 0x1
++#define MMU_ADDR_BYPASS_TLB_LSB 30
++#define MMU_ADDR_BYPASS_TLB_MSB 31
++#define MMU_ADDR_BYPASS_TLB_PADDR_LSB 0
++#define MMU_ADDR_BYPASS_TLB_PADDR_MSB 28
++#define MMU_ADDR_BYPASS_TLB_PADDR_SZ 29
++#define MMU_ADDR_BYPASS_TLB_PADDR_MASK 0x1fffffff
++#define MMU_ADDR_BYPASS_TLB_SZ 2
++#define MMU_ADDR_BYPASS_TLB_MASK 0x3
++#define MMU_ADDR_IO_REGION 0x7
++#define MMU_ADDR_IO_REGION_LSB 29
++#define MMU_ADDR_IO_REGION_MSB 31
++#define MMU_ADDR_IO_REGION_SZ 3
++#define MMU_ADDR_IO_REGION_MASK 0x7
++#define MMU_ADDR_IO_REGION_VPN 0xe0000
++#define MMU_ADDR_KERNEL_MMU_REGION 0x2
++#define MMU_ADDR_KERNEL_MMU_REGION_LSB 30
++#define MMU_ADDR_KERNEL_MMU_REGION_MSB 31
++#define MMU_ADDR_KERNEL_MMU_REGION_SZ 2
++#define MMU_ADDR_KERNEL_MMU_REGION_MASK 0x3
++#define MMU_ADDR_KERNEL_REGION 0x6
++#define MMU_ADDR_KERNEL_REGION_INT 6
++#define MMU_ADDR_KERNEL_REGION_LSB 29
++#define MMU_ADDR_KERNEL_REGION_MSB 31
++#define MMU_ADDR_KERNEL_REGION_SZ 3
++#define MMU_ADDR_KERNEL_REGION_MASK 0x7
++#define MMU_ADDR_PAGE_OFFSET_LSB 0
++#define MMU_ADDR_PAGE_OFFSET_MSB 11
++#define MMU_ADDR_PAGE_OFFSET_SZ 12
++#define MMU_ADDR_PAGE_OFFSET_MASK 0xfff
++#define MMU_ADDR_PFN_LSB 12
++#define MMU_ADDR_PFN_MSB 31
++#define MMU_ADDR_PFN_SZ 20
++#define MMU_ADDR_PFN_MASK 0xfffff
++#define MMU_ADDR_USER_REGION 0x0
++#define MMU_ADDR_USER_REGION_LSB 31
++#define MMU_ADDR_USER_REGION_MSB 31
++#define MMU_ADDR_USER_REGION_SZ 1
++#define MMU_ADDR_USER_REGION_MASK 0x1
++#define MMU_ADDR_VPN_LSB 12
++#define MMU_ADDR_VPN_MSB 31
++#define MMU_ADDR_VPN_SZ 20
++#define MMU_ADDR_VPN_MASK 0xfffff
++#define PTEADDR_REG_LSB 0
++#define PTEADDR_REG_MSB 31
++#define PTEADDR_REG_PTBASE_LSB 22
++#define PTEADDR_REG_PTBASE_MSB 31
++#define PTEADDR_REG_PTBASE_SZ 10
++#define PTEADDR_REG_PTBASE_MASK 0x3ff
++#define PTEADDR_REG_REGNUM 8
++#define PTEADDR_REG_RSV_LSB 0
++#define PTEADDR_REG_RSV_MSB 1
++#define PTEADDR_REG_RSV_SZ 2
++#define PTEADDR_REG_RSV_MASK 0x3
++#define PTEADDR_REG_SZ 32
++#define PTEADDR_REG_MASK 0xffffffff
++#define PTEADDR_REG_VPN_LSB 2
++#define PTEADDR_REG_VPN_MSB 21
++#define PTEADDR_REG_VPN_SZ 20
++#define PTEADDR_REG_VPN_MASK 0xfffff
++#define REGNUM_SZ 5
++#define REGNUM_MASK 0x1f
++#define RETADDR_REGNUM 31
++#define RF_ADDR_SZ 5
++#define RF_ADDR_MASK 0x1f
++#define RF_NUM_REG 32
++#define SIM_REG_LSB 0
++#define SIM_REG_MSB 3
++#define SIM_REG_PERF_CNT_CLR_LSB 2
++#define SIM_REG_PERF_CNT_CLR_MSB 2
++#define SIM_REG_PERF_CNT_CLR_SZ 1
++#define SIM_REG_PERF_CNT_CLR_MASK 0x1
++#define SIM_REG_PERF_CNT_EN_LSB 1
++#define SIM_REG_PERF_CNT_EN_MSB 1
++#define SIM_REG_PERF_CNT_EN_SZ 1
++#define SIM_REG_PERF_CNT_EN_MASK 0x1
++#define SIM_REG_REGNUM 6
++#define SIM_REG_SHOW_DTLB_LSB 4
++#define SIM_REG_SHOW_DTLB_MSB 4
++#define SIM_REG_SHOW_DTLB_SZ 1
++#define SIM_REG_SHOW_DTLB_MASK 0x1
++#define SIM_REG_SHOW_ITLB_LSB 3
++#define SIM_REG_SHOW_ITLB_MSB 3
++#define SIM_REG_SHOW_ITLB_SZ 1
++#define SIM_REG_SHOW_ITLB_MASK 0x1
++#define SIM_REG_SHOW_MMU_REGS_LSB 5
++#define SIM_REG_SHOW_MMU_REGS_MSB 5
++#define SIM_REG_SHOW_MMU_REGS_SZ 1
++#define SIM_REG_SHOW_MMU_REGS_MASK 0x1
++#define SIM_REG_STOP_LSB 0
++#define SIM_REG_STOP_MSB 0
++#define SIM_REG_STOP_SZ 1
++#define SIM_REG_STOP_MASK 0x1
++#define SIM_REG_SZ 4
++#define SIM_REG_MASK 0xf
++#define SP_REGNUM 27
++#define STATUS_REG_EH_LSB 2
++#define STATUS_REG_EH_MSB 2
++#define STATUS_REG_EH_SZ 1
++#define STATUS_REG_EH_MASK 0x1
++#define STATUS_REG_LSB 0
++#define STATUS_REG_MMU_LSB 0
++#define STATUS_REG_MMU_MSB 2
++#define STATUS_REG_MMU_RSV_LSB 3
++#define STATUS_REG_MMU_RSV_MSB 31
++#define STATUS_REG_MMU_RSV_SZ 29
++#define STATUS_REG_MMU_RSV_MASK 0x1fffffff
++#define STATUS_REG_MMU_SZ 3
++#define STATUS_REG_MMU_MASK 0x7
++#define STATUS_REG_MSB 2
++#define STATUS_REG_NO_MMU_LSB 0
++#define STATUS_REG_NO_MMU_MSB 0
++#define STATUS_REG_NO_MMU_RSV_LSB 1
++#define STATUS_REG_NO_MMU_RSV_MSB 31
++#define STATUS_REG_NO_MMU_RSV_SZ 31
++#define STATUS_REG_NO_MMU_RSV_MASK 0x7fffffff
++#define STATUS_REG_NO_MMU_SZ 1
++#define STATUS_REG_NO_MMU_MASK 0x1
++#define STATUS_REG_PIE_LSB 0
++#define STATUS_REG_PIE_MSB 0
++#define STATUS_REG_PIE_SZ 1
++#define STATUS_REG_PIE_MASK 0x1
++#define STATUS_REG_REGNUM 0
++#define STATUS_REG_SZ 3
++#define STATUS_REG_MASK 0x7
++#define STATUS_REG_U_LSB 1
++#define STATUS_REG_U_MSB 1
++#define STATUS_REG_U_SZ 1
++#define STATUS_REG_U_MASK 0x1
++#define TLB_MAX_ENTRIES 1024
++#define TLB_MAX_LINES 512
++#define TLB_MAX_PID_SZ 14
++#define TLB_MAX_PID_MASK 0x3fff
++#define TLB_MAX_PTR_SZ 10
++#define TLB_MAX_PTR_MASK 0x3ff
++#define TLB_MAX_WAYS 8
++#define TLB_MIN_PID_SZ 1
++#define TLB_MIN_PID_MASK 0x1
++#define TLB_MIN_PTR_SZ 7
++#define TLB_MIN_PTR_MASK 0x7f
++#define TLB_MIN_WAYS 2
++#define TLBACC_REG_C_LSB 24
++#define TLBACC_REG_C_MSB 24
++#define TLBACC_REG_C_SZ 1
++#define TLBACC_REG_C_MASK 0x1
++#define TLBACC_REG_G_LSB 20
++#define TLBACC_REG_G_MSB 20
++#define TLBACC_REG_G_SZ 1
++#define TLBACC_REG_G_MASK 0x1
++#define TLBACC_REG_IG_LSB 25
++#define TLBACC_REG_IG_MSB 31
++#define TLBACC_REG_IG_SZ 7
++#define TLBACC_REG_IG_MASK 0x7f
++#define TLBACC_REG_LSB 0
++#define TLBACC_REG_MSB 24
++#define TLBACC_REG_PFN_LSB 0
++#define TLBACC_REG_PFN_MSB 19
++#define TLBACC_REG_PFN_SZ 20
++#define TLBACC_REG_PFN_MASK 0xfffff
++#define TLBACC_REG_R_LSB 23
++#define TLBACC_REG_R_MSB 23
++#define TLBACC_REG_R_SZ 1
++#define TLBACC_REG_R_MASK 0x1
++#define TLBACC_REG_REGNUM 9
++#define TLBACC_REG_SZ 25
++#define TLBACC_REG_MASK 0x1ffffff
++#define TLBACC_REG_W_LSB 22
++#define TLBACC_REG_W_MSB 22
++#define TLBACC_REG_W_SZ 1
++#define TLBACC_REG_W_MASK 0x1
++#define TLBACC_REG_X_LSB 21
++#define TLBACC_REG_X_MSB 21
++#define TLBACC_REG_X_SZ 1
++#define TLBACC_REG_X_MASK 0x1
++#define TLBMISC_REG_BAD_LSB 2
++#define TLBMISC_REG_BAD_MSB 2
++#define TLBMISC_REG_BAD_SZ 1
++#define TLBMISC_REG_BAD_MASK 0x1
++#define TLBMISC_REG_D_LSB 0
++#define TLBMISC_REG_D_MSB 0
++#define TLBMISC_REG_D_SZ 1
++#define TLBMISC_REG_D_MASK 0x1
++#define TLBMISC_REG_DBL_LSB 3
++#define TLBMISC_REG_DBL_MSB 3
++#define TLBMISC_REG_DBL_SZ 1
++#define TLBMISC_REG_DBL_MASK 0x1
++#define TLBMISC_REG_LSB 0
++#define TLBMISC_REG_MSB 23
++#define TLBMISC_REG_PERM_LSB 1
++#define TLBMISC_REG_PERM_MSB 1
++#define TLBMISC_REG_PERM_SZ 1
++#define TLBMISC_REG_PERM_MASK 0x1
++#define TLBMISC_REG_PID_LSB 4
++#define TLBMISC_REG_PID_MSB 17
++#define TLBMISC_REG_PID_SZ 14
++#define TLBMISC_REG_PID_MASK 0x3fff
++#define TLBMISC_REG_RD_LSB 24
++#define TLBMISC_REG_RD_MSB 24
++#define TLBMISC_REG_RD_SZ 1
++#define TLBMISC_REG_RD_MASK 0x1
++#define TLBMISC_REG_REGNUM 10
++#define TLBMISC_REG_RSV0_LSB 18
++#define TLBMISC_REG_RSV0_MSB 19
++#define TLBMISC_REG_RSV0_SZ 2
++#define TLBMISC_REG_RSV0_MASK 0x3
++#define TLBMISC_REG_RSV1_LSB 25
++#define TLBMISC_REG_RSV1_MSB 31
++#define TLBMISC_REG_RSV1_SZ 7
++#define TLBMISC_REG_RSV1_MASK 0x7f
++#define TLBMISC_REG_SZ 24
++#define TLBMISC_REG_MASK 0xffffff
++#define TLBMISC_REG_WAY_LSB 20
++#define TLBMISC_REG_WAY_MSB 22
++#define TLBMISC_REG_WAY_SZ 3
++#define TLBMISC_REG_WAY_MASK 0x7
++#define TLBMISC_REG_WE_LSB 23
++#define TLBMISC_REG_WE_MSB 23
++#define TLBMISC_REG_WE_SZ 1
++#define TLBMISC_REG_WE_MASK 0x1
++
++/* Macros to extract instruction fields */
++#define GET_IW_A(Iw) \
++ (((Iw) >> IW_A_LSB) & IW_A_MASK)
++#define SET_IW_A(Iw, Val) \
++ Iw = (((Iw) & (~(IW_A_MASK << IW_A_LSB))) | \
++ (((Val) & IW_A_MASK) << IW_A_LSB))
++#define GET_IW_B(Iw) \
++ (((Iw) >> IW_B_LSB) & IW_B_MASK)
++#define SET_IW_B(Iw, Val) \
++ Iw = (((Iw) & (~(IW_B_MASK << IW_B_LSB))) | \
++ (((Val) & IW_B_MASK) << IW_B_LSB))
++#define GET_IW_C(Iw) \
++ (((Iw) >> IW_C_LSB) & IW_C_MASK)
++#define SET_IW_C(Iw, Val) \
++ Iw = (((Iw) & (~(IW_C_MASK << IW_C_LSB))) | \
++ (((Val) & IW_C_MASK) << IW_C_LSB))
++#define GET_IW_CONTROL_REGNUM(Iw) \
++ (((Iw) >> IW_CONTROL_REGNUM_LSB) & IW_CONTROL_REGNUM_MASK)
++#define SET_IW_CONTROL_REGNUM(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CONTROL_REGNUM_MASK << IW_CONTROL_REGNUM_LSB))) | \
++ (((Val) & IW_CONTROL_REGNUM_MASK) << IW_CONTROL_REGNUM_LSB))
++#define GET_IW_CUSTOM_N(Iw) \
++ (((Iw) >> IW_CUSTOM_N_LSB) & IW_CUSTOM_N_MASK)
++#define SET_IW_CUSTOM_N(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_N_MASK << IW_CUSTOM_N_LSB))) | \
++ (((Val) & IW_CUSTOM_N_MASK) << IW_CUSTOM_N_LSB))
++#define GET_IW_CUSTOM_READRA(Iw) \
++ (((Iw) >> IW_CUSTOM_READRA_LSB) & IW_CUSTOM_READRA_MASK)
++#define SET_IW_CUSTOM_READRA(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_READRA_MASK << IW_CUSTOM_READRA_LSB))) | \
++ (((Val) & IW_CUSTOM_READRA_MASK) << IW_CUSTOM_READRA_LSB))
++#define GET_IW_CUSTOM_READRB(Iw) \
++ (((Iw) >> IW_CUSTOM_READRB_LSB) & IW_CUSTOM_READRB_MASK)
++#define SET_IW_CUSTOM_READRB(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_READRB_MASK << IW_CUSTOM_READRB_LSB))) | \
++ (((Val) & IW_CUSTOM_READRB_MASK) << IW_CUSTOM_READRB_LSB))
++#define GET_IW_CUSTOM_WRITERC(Iw) \
++ (((Iw) >> IW_CUSTOM_WRITERC_LSB) & IW_CUSTOM_WRITERC_MASK)
++#define SET_IW_CUSTOM_WRITERC(Iw, Val) \
++ Iw = (((Iw) & (~(IW_CUSTOM_WRITERC_MASK << IW_CUSTOM_WRITERC_LSB))) | \
++ (((Val) & IW_CUSTOM_WRITERC_MASK) << IW_CUSTOM_WRITERC_LSB))
++#define GET_IW_IMM16(Iw) \
++ (((Iw) >> IW_IMM16_LSB) & IW_IMM16_MASK)
++#define SET_IW_IMM16(Iw, Val) \
++ Iw = (((Iw) & (~(IW_IMM16_MASK << IW_IMM16_LSB))) | \
++ (((Val) & IW_IMM16_MASK) << IW_IMM16_LSB))
++#define GET_IW_IMM26(Iw) \
++ (((Iw) >> IW_IMM26_LSB) & IW_IMM26_MASK)
++#define SET_IW_IMM26(Iw, Val) \
++ Iw = (((Iw) & (~(IW_IMM26_MASK << IW_IMM26_LSB))) | \
++ (((Val) & IW_IMM26_MASK) << IW_IMM26_LSB))
++#define GET_IW_MEMSZ(Iw) \
++ (((Iw) >> IW_MEMSZ_LSB) & IW_MEMSZ_MASK)
++#define SET_IW_MEMSZ(Iw, Val) \
++ Iw = (((Iw) & (~(IW_MEMSZ_MASK << IW_MEMSZ_LSB))) | \
++ (((Val) & IW_MEMSZ_MASK) << IW_MEMSZ_LSB))
++#define GET_IW_OP(Iw) \
++ (((Iw) >> IW_OP_LSB) & IW_OP_MASK)
++#define SET_IW_OP(Iw, Val) \
++ Iw = (((Iw) & (~(IW_OP_MASK << IW_OP_LSB))) | \
++ (((Val) & IW_OP_MASK) << IW_OP_LSB))
++#define GET_IW_OPX(Iw) \
++ (((Iw) >> IW_OPX_LSB) & IW_OPX_MASK)
++#define SET_IW_OPX(Iw, Val) \
++ Iw = (((Iw) & (~(IW_OPX_MASK << IW_OPX_LSB))) | \
++ (((Val) & IW_OPX_MASK) << IW_OPX_LSB))
++#define GET_IW_SHIFT_IMM5(Iw) \
++ (((Iw) >> IW_SHIFT_IMM5_LSB) & IW_SHIFT_IMM5_MASK)
++#define SET_IW_SHIFT_IMM5(Iw, Val) \
++ Iw = (((Iw) & (~(IW_SHIFT_IMM5_MASK << IW_SHIFT_IMM5_LSB))) | \
++ (((Val) & IW_SHIFT_IMM5_MASK) << IW_SHIFT_IMM5_LSB))
++#define GET_IW_TRAP_BREAK_IMM5(Iw) \
++ (((Iw) >> IW_TRAP_BREAK_IMM5_LSB) & IW_TRAP_BREAK_IMM5_MASK)
++#define SET_IW_TRAP_BREAK_IMM5(Iw, Val) \
++ Iw = (((Iw) & (~(IW_TRAP_BREAK_IMM5_MASK << IW_TRAP_BREAK_IMM5_LSB))) | \
++ (((Val) & IW_TRAP_BREAK_IMM5_MASK) << IW_TRAP_BREAK_IMM5_LSB))
++
++/* Macros to extract control register fields */
++#define GET_BSTATUS_REG_MMU(Reg) \
++ (((Reg) >> BSTATUS_REG_MMU_LSB) & BSTATUS_REG_MMU_MASK)
++#define SET_BSTATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(BSTATUS_REG_MMU_MASK << BSTATUS_REG_MMU_LSB))) | \
++ (((Val) & BSTATUS_REG_MMU_MASK) << BSTATUS_REG_MMU_LSB))
++#define GET_BSTATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> BSTATUS_REG_NO_MMU_LSB) & BSTATUS_REG_NO_MMU_MASK)
++#define SET_BSTATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(BSTATUS_REG_NO_MMU_MASK << BSTATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & BSTATUS_REG_NO_MMU_MASK) << BSTATUS_REG_NO_MMU_LSB))
++#define GET_ESTATUS_REG_MMU(Reg) \
++ (((Reg) >> ESTATUS_REG_MMU_LSB) & ESTATUS_REG_MMU_MASK)
++#define SET_ESTATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(ESTATUS_REG_MMU_MASK << ESTATUS_REG_MMU_LSB))) | \
++ (((Val) & ESTATUS_REG_MMU_MASK) << ESTATUS_REG_MMU_LSB))
++#define GET_ESTATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> ESTATUS_REG_NO_MMU_LSB) & ESTATUS_REG_NO_MMU_MASK)
++#define SET_ESTATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(ESTATUS_REG_NO_MMU_MASK << ESTATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & ESTATUS_REG_NO_MMU_MASK) << ESTATUS_REG_NO_MMU_LSB))
++#define GET_EXCEPTION_REG_MEA(Reg) \
++ (((Reg) >> EXCEPTION_REG_MEA_LSB) & EXCEPTION_REG_MEA_MASK)
++#define SET_EXCEPTION_REG_MEA(Reg, Val) \
++ Reg = (((Reg) & (~(EXCEPTION_REG_MEA_MASK << EXCEPTION_REG_MEA_LSB))) | \
++ (((Val) & EXCEPTION_REG_MEA_MASK) << EXCEPTION_REG_MEA_LSB))
++#define GET_EXCEPTION_REG_MEE(Reg) \
++ (((Reg) >> EXCEPTION_REG_MEE_LSB) & EXCEPTION_REG_MEE_MASK)
++#define SET_EXCEPTION_REG_MEE(Reg, Val) \
++ Reg = (((Reg) & (~(EXCEPTION_REG_MEE_MASK << EXCEPTION_REG_MEE_LSB))) | \
++ (((Val) & EXCEPTION_REG_MEE_MASK) << EXCEPTION_REG_MEE_LSB))
++#define GET_PTEADDR_REG_PTBASE(Reg) \
++ (((Reg) >> PTEADDR_REG_PTBASE_LSB) & PTEADDR_REG_PTBASE_MASK)
++#define SET_PTEADDR_REG_PTBASE(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_PTBASE_MASK << PTEADDR_REG_PTBASE_LSB))) | \
++ (((Val) & PTEADDR_REG_PTBASE_MASK) << PTEADDR_REG_PTBASE_LSB))
++#define GET_PTEADDR_REG_RSV(Reg) \
++ (((Reg) >> PTEADDR_REG_RSV_LSB) & PTEADDR_REG_RSV_MASK)
++#define SET_PTEADDR_REG_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_RSV_MASK << PTEADDR_REG_RSV_LSB))) | \
++ (((Val) & PTEADDR_REG_RSV_MASK) << PTEADDR_REG_RSV_LSB))
++#define GET_PTEADDR_REG_VPN(Reg) \
++ (((Reg) >> PTEADDR_REG_VPN_LSB) & PTEADDR_REG_VPN_MASK)
++#define SET_PTEADDR_REG_VPN(Reg, Val) \
++ Reg = (((Reg) & (~(PTEADDR_REG_VPN_MASK << PTEADDR_REG_VPN_LSB))) | \
++ (((Val) & PTEADDR_REG_VPN_MASK) << PTEADDR_REG_VPN_LSB))
++#define GET_SIM_REG_PERF_CNT_CLR(Reg) \
++ (((Reg) >> SIM_REG_PERF_CNT_CLR_LSB) & SIM_REG_PERF_CNT_CLR_MASK)
++#define SET_SIM_REG_PERF_CNT_CLR(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_PERF_CNT_CLR_MASK << SIM_REG_PERF_CNT_CLR_LSB))) | \
++ (((Val) & SIM_REG_PERF_CNT_CLR_MASK) << SIM_REG_PERF_CNT_CLR_LSB))
++#define GET_SIM_REG_PERF_CNT_EN(Reg) \
++ (((Reg) >> SIM_REG_PERF_CNT_EN_LSB) & SIM_REG_PERF_CNT_EN_MASK)
++#define SET_SIM_REG_PERF_CNT_EN(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_PERF_CNT_EN_MASK << SIM_REG_PERF_CNT_EN_LSB))) | \
++ (((Val) & SIM_REG_PERF_CNT_EN_MASK) << SIM_REG_PERF_CNT_EN_LSB))
++#define GET_SIM_REG_SHOW_DTLB(Reg) \
++ (((Reg) >> SIM_REG_SHOW_DTLB_LSB) & SIM_REG_SHOW_DTLB_MASK)
++#define SET_SIM_REG_SHOW_DTLB(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_DTLB_MASK << SIM_REG_SHOW_DTLB_LSB))) | \
++ (((Val) & SIM_REG_SHOW_DTLB_MASK) << SIM_REG_SHOW_DTLB_LSB))
++#define GET_SIM_REG_SHOW_ITLB(Reg) \
++ (((Reg) >> SIM_REG_SHOW_ITLB_LSB) & SIM_REG_SHOW_ITLB_MASK)
++#define SET_SIM_REG_SHOW_ITLB(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_ITLB_MASK << SIM_REG_SHOW_ITLB_LSB))) | \
++ (((Val) & SIM_REG_SHOW_ITLB_MASK) << SIM_REG_SHOW_ITLB_LSB))
++#define GET_SIM_REG_SHOW_MMU_REGS(Reg) \
++ (((Reg) >> SIM_REG_SHOW_MMU_REGS_LSB) & SIM_REG_SHOW_MMU_REGS_MASK)
++#define SET_SIM_REG_SHOW_MMU_REGS(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_SHOW_MMU_REGS_MASK << SIM_REG_SHOW_MMU_REGS_LSB))) | \
++ (((Val) & SIM_REG_SHOW_MMU_REGS_MASK) << SIM_REG_SHOW_MMU_REGS_LSB))
++#define GET_SIM_REG_STOP(Reg) \
++ (((Reg) >> SIM_REG_STOP_LSB) & SIM_REG_STOP_MASK)
++#define SET_SIM_REG_STOP(Reg, Val) \
++ Reg = (((Reg) & (~(SIM_REG_STOP_MASK << SIM_REG_STOP_LSB))) | \
++ (((Val) & SIM_REG_STOP_MASK) << SIM_REG_STOP_LSB))
++#define GET_STATUS_REG_EH(Reg) \
++ (((Reg) >> STATUS_REG_EH_LSB) & STATUS_REG_EH_MASK)
++#define SET_STATUS_REG_EH(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_EH_MASK << STATUS_REG_EH_LSB))) | \
++ (((Val) & STATUS_REG_EH_MASK) << STATUS_REG_EH_LSB))
++#define GET_STATUS_REG_MMU(Reg) \
++ (((Reg) >> STATUS_REG_MMU_LSB) & STATUS_REG_MMU_MASK)
++#define SET_STATUS_REG_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_MMU_MASK << STATUS_REG_MMU_LSB))) | \
++ (((Val) & STATUS_REG_MMU_MASK) << STATUS_REG_MMU_LSB))
++#define GET_STATUS_REG_MMU_RSV(Reg) \
++ (((Reg) >> STATUS_REG_MMU_RSV_LSB) & STATUS_REG_MMU_RSV_MASK)
++#define SET_STATUS_REG_MMU_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_MMU_RSV_MASK << STATUS_REG_MMU_RSV_LSB))) | \
++ (((Val) & STATUS_REG_MMU_RSV_MASK) << STATUS_REG_MMU_RSV_LSB))
++#define GET_STATUS_REG_NO_MMU(Reg) \
++ (((Reg) >> STATUS_REG_NO_MMU_LSB) & STATUS_REG_NO_MMU_MASK)
++#define SET_STATUS_REG_NO_MMU(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_NO_MMU_MASK << STATUS_REG_NO_MMU_LSB))) | \
++ (((Val) & STATUS_REG_NO_MMU_MASK) << STATUS_REG_NO_MMU_LSB))
++#define GET_STATUS_REG_NO_MMU_RSV(Reg) \
++ (((Reg) >> STATUS_REG_NO_MMU_RSV_LSB) & STATUS_REG_NO_MMU_RSV_MASK)
++#define SET_STATUS_REG_NO_MMU_RSV(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_NO_MMU_RSV_MASK << STATUS_REG_NO_MMU_RSV_LSB))) | \
++ (((Val) & STATUS_REG_NO_MMU_RSV_MASK) << STATUS_REG_NO_MMU_RSV_LSB))
++#define GET_STATUS_REG_PIE(Reg) \
++ (((Reg) >> STATUS_REG_PIE_LSB) & STATUS_REG_PIE_MASK)
++#define SET_STATUS_REG_PIE(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_PIE_MASK << STATUS_REG_PIE_LSB))) | \
++ (((Val) & STATUS_REG_PIE_MASK) << STATUS_REG_PIE_LSB))
++#define GET_STATUS_REG_U(Reg) \
++ (((Reg) >> STATUS_REG_U_LSB) & STATUS_REG_U_MASK)
++#define SET_STATUS_REG_U(Reg, Val) \
++ Reg = (((Reg) & (~(STATUS_REG_U_MASK << STATUS_REG_U_LSB))) | \
++ (((Val) & STATUS_REG_U_MASK) << STATUS_REG_U_LSB))
++#define GET_TLBACC_REG_C(Reg) \
++ (((Reg) >> TLBACC_REG_C_LSB) & TLBACC_REG_C_MASK)
++#define SET_TLBACC_REG_C(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_C_MASK << TLBACC_REG_C_LSB))) | \
++ (((Val) & TLBACC_REG_C_MASK) << TLBACC_REG_C_LSB))
++#define GET_TLBACC_REG_G(Reg) \
++ (((Reg) >> TLBACC_REG_G_LSB) & TLBACC_REG_G_MASK)
++#define SET_TLBACC_REG_G(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_G_MASK << TLBACC_REG_G_LSB))) | \
++ (((Val) & TLBACC_REG_G_MASK) << TLBACC_REG_G_LSB))
++#define GET_TLBACC_REG_IG(Reg) \
++ (((Reg) >> TLBACC_REG_IG_LSB) & TLBACC_REG_IG_MASK)
++#define SET_TLBACC_REG_IG(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_IG_MASK << TLBACC_REG_IG_LSB))) | \
++ (((Val) & TLBACC_REG_IG_MASK) << TLBACC_REG_IG_LSB))
++#define GET_TLBACC_REG_PFN(Reg) \
++ (((Reg) >> TLBACC_REG_PFN_LSB) & TLBACC_REG_PFN_MASK)
++#define SET_TLBACC_REG_PFN(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_PFN_MASK << TLBACC_REG_PFN_LSB))) | \
++ (((Val) & TLBACC_REG_PFN_MASK) << TLBACC_REG_PFN_LSB))
++#define GET_TLBACC_REG_R(Reg) \
++ (((Reg) >> TLBACC_REG_R_LSB) & TLBACC_REG_R_MASK)
++#define SET_TLBACC_REG_R(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_R_MASK << TLBACC_REG_R_LSB))) | \
++ (((Val) & TLBACC_REG_R_MASK) << TLBACC_REG_R_LSB))
++#define GET_TLBACC_REG_W(Reg) \
++ (((Reg) >> TLBACC_REG_W_LSB) & TLBACC_REG_W_MASK)
++#define SET_TLBACC_REG_W(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_W_MASK << TLBACC_REG_W_LSB))) | \
++ (((Val) & TLBACC_REG_W_MASK) << TLBACC_REG_W_LSB))
++#define GET_TLBACC_REG_X(Reg) \
++ (((Reg) >> TLBACC_REG_X_LSB) & TLBACC_REG_X_MASK)
++#define SET_TLBACC_REG_X(Reg, Val) \
++ Reg = (((Reg) & (~(TLBACC_REG_X_MASK << TLBACC_REG_X_LSB))) | \
++ (((Val) & TLBACC_REG_X_MASK) << TLBACC_REG_X_LSB))
++#define GET_TLBMISC_REG_BAD(Reg) \
++ (((Reg) >> TLBMISC_REG_BAD_LSB) & TLBMISC_REG_BAD_MASK)
++#define SET_TLBMISC_REG_BAD(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_BAD_MASK << TLBMISC_REG_BAD_LSB))) | \
++ (((Val) & TLBMISC_REG_BAD_MASK) << TLBMISC_REG_BAD_LSB))
++#define GET_TLBMISC_REG_D(Reg) \
++ (((Reg) >> TLBMISC_REG_D_LSB) & TLBMISC_REG_D_MASK)
++#define SET_TLBMISC_REG_D(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_D_MASK << TLBMISC_REG_D_LSB))) | \
++ (((Val) & TLBMISC_REG_D_MASK) << TLBMISC_REG_D_LSB))
++#define GET_TLBMISC_REG_DBL(Reg) \
++ (((Reg) >> TLBMISC_REG_DBL_LSB) & TLBMISC_REG_DBL_MASK)
++#define SET_TLBMISC_REG_DBL(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_DBL_MASK << TLBMISC_REG_DBL_LSB))) | \
++ (((Val) & TLBMISC_REG_DBL_MASK) << TLBMISC_REG_DBL_LSB))
++#define GET_TLBMISC_REG_PERM(Reg) \
++ (((Reg) >> TLBMISC_REG_PERM_LSB) & TLBMISC_REG_PERM_MASK)
++#define SET_TLBMISC_REG_PERM(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_PERM_MASK << TLBMISC_REG_PERM_LSB))) | \
++ (((Val) & TLBMISC_REG_PERM_MASK) << TLBMISC_REG_PERM_LSB))
++#define GET_TLBMISC_REG_PID(Reg) \
++ (((Reg) >> TLBMISC_REG_PID_LSB) & TLBMISC_REG_PID_MASK)
++#define SET_TLBMISC_REG_PID(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_PID_MASK << TLBMISC_REG_PID_LSB))) | \
++ (((Val) & TLBMISC_REG_PID_MASK) << TLBMISC_REG_PID_LSB))
++#define GET_TLBMISC_REG_RD(Reg) \
++ (((Reg) >> TLBMISC_REG_RD_LSB) & TLBMISC_REG_RD_MASK)
++#define SET_TLBMISC_REG_RD(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RD_MASK << TLBMISC_REG_RD_LSB))) | \
++ (((Val) & TLBMISC_REG_RD_MASK) << TLBMISC_REG_RD_LSB))
++#define GET_TLBMISC_REG_RSV0(Reg) \
++ (((Reg) >> TLBMISC_REG_RSV0_LSB) & TLBMISC_REG_RSV0_MASK)
++#define SET_TLBMISC_REG_RSV0(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RSV0_MASK << TLBMISC_REG_RSV0_LSB))) | \
++ (((Val) & TLBMISC_REG_RSV0_MASK) << TLBMISC_REG_RSV0_LSB))
++#define GET_TLBMISC_REG_RSV1(Reg) \
++ (((Reg) >> TLBMISC_REG_RSV1_LSB) & TLBMISC_REG_RSV1_MASK)
++#define SET_TLBMISC_REG_RSV1(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_RSV1_MASK << TLBMISC_REG_RSV1_LSB))) | \
++ (((Val) & TLBMISC_REG_RSV1_MASK) << TLBMISC_REG_RSV1_LSB))
++#define GET_TLBMISC_REG_WAY(Reg) \
++ (((Reg) >> TLBMISC_REG_WAY_LSB) & TLBMISC_REG_WAY_MASK)
++#define SET_TLBMISC_REG_WAY(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_WAY_MASK << TLBMISC_REG_WAY_LSB))) | \
++ (((Val) & TLBMISC_REG_WAY_MASK) << TLBMISC_REG_WAY_LSB))
++#define GET_TLBMISC_REG_WE(Reg) \
++ (((Reg) >> TLBMISC_REG_WE_LSB) & TLBMISC_REG_WE_MASK)
++#define SET_TLBMISC_REG_WE(Reg, Val) \
++ Reg = (((Reg) & (~(TLBMISC_REG_WE_MASK << TLBMISC_REG_WE_LSB))) | \
++ (((Val) & TLBMISC_REG_WE_MASK) << TLBMISC_REG_WE_LSB))
++
++/* Macros to extract MMU fields */
++#define GET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB) & MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK << MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_CACHEABLE_MASK) << MMU_ADDR_BYPASS_TLB_CACHEABLE_LSB))
++#define GET_MMU_ADDR_BYPASS_TLB(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_LSB) & MMU_ADDR_BYPASS_TLB_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_MASK << MMU_ADDR_BYPASS_TLB_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_MASK) << MMU_ADDR_BYPASS_TLB_LSB))
++#define GET_MMU_ADDR_BYPASS_TLB_PADDR(Addr) \
++ (((Addr) >> MMU_ADDR_BYPASS_TLB_PADDR_LSB) & MMU_ADDR_BYPASS_TLB_PADDR_MASK)
++#define SET_MMU_ADDR_BYPASS_TLB_PADDR(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_BYPASS_TLB_PADDR_MASK << MMU_ADDR_BYPASS_TLB_PADDR_LSB))) | \
++ (((Val) & MMU_ADDR_BYPASS_TLB_PADDR_MASK) << MMU_ADDR_BYPASS_TLB_PADDR_LSB))
++#define GET_MMU_ADDR_IO_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_IO_REGION_LSB) & MMU_ADDR_IO_REGION_MASK)
++#define SET_MMU_ADDR_IO_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_IO_REGION_MASK << MMU_ADDR_IO_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_IO_REGION_MASK) << MMU_ADDR_IO_REGION_LSB))
++#define GET_MMU_ADDR_KERNEL_MMU_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_KERNEL_MMU_REGION_LSB) & MMU_ADDR_KERNEL_MMU_REGION_MASK)
++#define SET_MMU_ADDR_KERNEL_MMU_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_KERNEL_MMU_REGION_MASK << MMU_ADDR_KERNEL_MMU_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_KERNEL_MMU_REGION_MASK) << MMU_ADDR_KERNEL_MMU_REGION_LSB))
++#define GET_MMU_ADDR_KERNEL_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_KERNEL_REGION_LSB) & MMU_ADDR_KERNEL_REGION_MASK)
++#define SET_MMU_ADDR_KERNEL_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_KERNEL_REGION_MASK << MMU_ADDR_KERNEL_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_KERNEL_REGION_MASK) << MMU_ADDR_KERNEL_REGION_LSB))
++#define GET_MMU_ADDR_PAGE_OFFSET(Addr) \
++ (((Addr) >> MMU_ADDR_PAGE_OFFSET_LSB) & MMU_ADDR_PAGE_OFFSET_MASK)
++#define SET_MMU_ADDR_PAGE_OFFSET(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_PAGE_OFFSET_MASK << MMU_ADDR_PAGE_OFFSET_LSB))) | \
++ (((Val) & MMU_ADDR_PAGE_OFFSET_MASK) << MMU_ADDR_PAGE_OFFSET_LSB))
++#define GET_MMU_ADDR_PFN(Addr) \
++ (((Addr) >> MMU_ADDR_PFN_LSB) & MMU_ADDR_PFN_MASK)
++#define SET_MMU_ADDR_PFN(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_PFN_MASK << MMU_ADDR_PFN_LSB))) | \
++ (((Val) & MMU_ADDR_PFN_MASK) << MMU_ADDR_PFN_LSB))
++#define GET_MMU_ADDR_USER_REGION(Addr) \
++ (((Addr) >> MMU_ADDR_USER_REGION_LSB) & MMU_ADDR_USER_REGION_MASK)
++#define SET_MMU_ADDR_USER_REGION(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_USER_REGION_MASK << MMU_ADDR_USER_REGION_LSB))) | \
++ (((Val) & MMU_ADDR_USER_REGION_MASK) << MMU_ADDR_USER_REGION_LSB))
++#define GET_MMU_ADDR_VPN(Addr) \
++ (((Addr) >> MMU_ADDR_VPN_LSB) & MMU_ADDR_VPN_MASK)
++#define SET_MMU_ADDR_VPN(Addr, Val) \
++ Addr = (((Addr) & (~(MMU_ADDR_VPN_MASK << MMU_ADDR_VPN_LSB))) | \
++ (((Val) & MMU_ADDR_VPN_MASK) << MMU_ADDR_VPN_LSB))
++
++/* OP instruction values */
++#define OP_ADDI 4
++#define OP_ANDHI 44
++#define OP_ANDI 12
++#define OP_BEQ 38
++#define OP_BGE 14
++#define OP_BGEU 46
++#define OP_BLT 22
++#define OP_BLTU 54
++#define OP_BNE 30
++#define OP_BR 6
++#define OP_CALL 0
++#define OP_CMPEQI 32
++#define OP_CMPGEI 8
++#define OP_CMPGEUI 40
++#define OP_CMPLTI 16
++#define OP_CMPLTUI 48
++#define OP_CMPNEI 24
++#define OP_CUSTOM 50
++#define OP_FLUSHD 59
++#define OP_FLUSHDA 27
++#define OP_INITD 51
++#define OP_JMPI 1
++#define OP_LDB 7
++#define OP_LDBIO 39
++#define OP_LDBU 3
++#define OP_LDBUIO 35
++#define OP_LDH 15
++#define OP_LDHIO 47
++#define OP_LDHU 11
++#define OP_LDHUIO 43
++#define OP_LDW 23
++#define OP_LDWIO 55
++#define OP_MULI 36
++#define OP_OPX 58
++#define OP_ORHI 52
++#define OP_ORI 20
++#define OP_STB 5
++#define OP_STBIO 37
++#define OP_STH 13
++#define OP_STHIO 45
++#define OP_STW 21
++#define OP_STWIO 53
++#define OP_XORHI 60
++#define OP_XORI 28
++
++/* OPX instruction values */
++#define OPX_ADD 49
++#define OPX_AND 14
++#define OPX_BREAK 52
++#define OPX_BRET 9
++#define OPX_CALLR 29
++#define OPX_CMPEQ 32
++#define OPX_CMPGE 8
++#define OPX_CMPGEU 40
++#define OPX_CMPLT 16
++#define OPX_CMPLTU 48
++#define OPX_CMPNE 24
++#define OPX_CRST 62
++#define OPX_DIV 37
++#define OPX_DIVU 36
++#define OPX_ERET 1
++#define OPX_FLUSHI 12
++#define OPX_FLUSHP 4
++#define OPX_HBREAK 53
++#define OPX_INITI 41
++#define OPX_INTR 61
++#define OPX_JMP 13
++#define OPX_MUL 39
++#define OPX_MULXSS 31
++#define OPX_MULXSU 23
++#define OPX_MULXUU 7
++#define OPX_NEXTPC 28
++#define OPX_NOR 6
++#define OPX_OR 22
++#define OPX_RDCTL 38
++#define OPX_RET 5
++#define OPX_ROL 3
++#define OPX_ROLI 2
++#define OPX_ROR 11
++#define OPX_SLL 19
++#define OPX_SLLI 18
++#define OPX_SRA 59
++#define OPX_SRAI 58
++#define OPX_SRL 27
++#define OPX_SRLI 26
++#define OPX_SUB 57
++#define OPX_SYNC 54
++#define OPX_TRAP 45
++#define OPX_WRCTL 46
++#define OPX_XOR 30
++
++/* Macros to detect sub-opcode instructions */
++#define IS_OPX_INST(Iw) (GET_IW_OP(Iw) == OP_OPX)
++#define IS_CUSTOM_INST(Iw) (GET_IW_OP(Iw) == OP_CUSTOM)
++
++/* Instruction property macros */
++#define IW_PROP_RESERVED_OP(Iw) (0)
++
++#define IW_PROP_RESERVED_OPX(Iw) (0)
++
++#define IW_PROP_RESERVED(Iw) (0)
++
++#define IW_PROP_SUPERVISOR_ONLY(Iw) ( \
++ (op_prop_supervisor_only[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_supervisor_only[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_supervisor_only[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_supervisor_only[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_INITI_FLUSHI(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_INITI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_FLUSHI) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSH_PIPE(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_flush_pipe[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_flush_pipe[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_INDIRECT_NON_TRAP(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_jmp_indirect_non_trap[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_jmp_indirect_non_trap[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_INDIRECT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_jmp_indirect[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_jmp_indirect[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMP_DIRECT(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) || \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_LSW(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_MULI)) || \
++ ((GET_IW_OPX((Iw)) == OPX_MUL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MULX(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_mulx[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mulx[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MUL(Iw) ( \
++ (op_prop_mul[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_mul[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mul[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mul[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DIV_UNSIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIVU) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DIV_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIV) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DIV(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_DIVU) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_DIV) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_UNIMPLEMENTED(Iw) (0)
++
++#define IW_PROP_IMPLICIT_DST_RETADDR(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) \
++ ) \
++ \
++)
++
++#define IW_PROP_IMPLICIT_DST_ERETADDR(Iw) (0)
++
++#define IW_PROP_EXCEPTION(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_TRAP) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_INTR) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BREAK(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_BREAK) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_HBREAK) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CRST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_CRST) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_WR_CTL_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_wr_ctl_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_wr_ctl_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_UNCOND_CTI_NON_BR(Iw) ( \
++ (op_prop_uncond_cti_non_br[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_uncond_cti_non_br[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_uncond_cti_non_br[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_uncond_cti_non_br[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_RETADDR(Iw) ( \
++ (op_prop_retaddr[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_retaddr[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_retaddr[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_retaddr[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_LEFT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SLLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SLL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_LOGICAL(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_logical[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_logical[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROT_LEFT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_ROLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_ROL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_ROT_LEFT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_left[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_left[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_RIGHT_LOGICAL(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SRLI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SRL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_RIGHT_ARITH(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_SRAI) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_SRA) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_RIGHT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_right[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_right[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROT_RIGHT(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_ROR) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_SHIFT_ROT_RIGHT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_right[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_right[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_ROT(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SHIFT_ROT_IMM(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_shift_rot_imm[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_shift_rot_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ROTATE(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_rotate[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_rotate[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_logic_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_logic_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_HI_IMM16(Iw) ( \
++ (op_prop_logic_hi_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_hi_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_LO_IMM16(Iw) ( \
++ (op_prop_logic_lo_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC_IMM16(Iw) ( \
++ (op_prop_logic_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOGIC(Iw) ( \
++ (op_prop_logic[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_logic[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_logic[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_logic[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_UNSIGNED_LO_IMM16(Iw) ( \
++ (op_prop_unsigned_lo_imm16[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_unsigned_lo_imm16[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_unsigned_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_unsigned_lo_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ARITH_IMM16(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_ADDI)) || \
++ ((GET_IW_OP((Iw)) == OP_MULI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_IMM16(Iw) ( \
++ (op_prop_cmp_imm16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_imm16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_JMPI(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_IMM16_WITH_CALL_JMPI(Iw) ( \
++ (op_prop_cmp_imm16_with_call_jmpi[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_imm16_with_call_jmpi[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_REG(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_reg[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC_IMM5(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_src_imm5[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src_imm5[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_LT(Iw) ( \
++ (op_prop_cmp_with_lt[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_lt[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_lt[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_lt[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_EQ(Iw) ( \
++ (op_prop_cmp_with_eq[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_eq[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_GE(Iw) ( \
++ (op_prop_cmp_with_ge[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_with_ge[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_with_ge[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_with_ge[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP_WITH_NE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CMPNEI)) || \
++ ((GET_IW_OPX((Iw)) == OPX_CMPNE) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_CMP_ALU_SIGNED(Iw) ( \
++ (op_prop_cmp_alu_signed[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp_alu_signed[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp_alu_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp_alu_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_CMP(Iw) ( \
++ (op_prop_cmp[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_cmp[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_cmp[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_cmp[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_WITH_LT(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BLT)) || \
++ ((GET_IW_OP((Iw)) == OP_BLTU)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_WITH_GE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BGE)) || \
++ ((GET_IW_OP((Iw)) == OP_BGEU)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_WITH_EQ(Iw) ( \
++ (op_prop_br_with_eq[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br_with_eq[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_WITH_NE(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BNE)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_ALU_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BGE)) || \
++ ((GET_IW_OP((Iw)) == OP_BLT)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR_COND(Iw) ( \
++ (op_prop_br_cond[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br_cond[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_BR_UNCOND(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_BR)) \
++ ) \
++ \
++)
++
++#define IW_PROP_BR(Iw) ( \
++ (op_prop_br[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_br[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ALU_SUB(Iw) ( \
++ (op_prop_alu_sub[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_alu_sub[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_alu_sub[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_alu_sub[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_FORCE_XOR(Iw) ( \
++ (op_prop_force_xor[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_force_xor[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_force_xor[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_force_xor[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD8(Iw) ( \
++ (op_prop_load8[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load8[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD16(Iw) ( \
++ (op_prop_load16[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load16[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD32(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_LDW)) || \
++ ((GET_IW_OP((Iw)) == OP_LDWIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_LOAD_SIGNED(Iw) ( \
++ (op_prop_load_signed[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_UNSIGNED(Iw) ( \
++ (op_prop_load_unsigned[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_unsigned[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD(Iw) ( \
++ (op_prop_load[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_INITD_FLUSHD_FLUSHDA(Iw) ( \
++ (op_prop_load_initd_flushd_flushda[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_initd_flushd_flushda[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_NON_IO(Iw) ( \
++ (op_prop_load_non_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_non_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE8(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STB)) || \
++ ((GET_IW_OP((Iw)) == OP_STBIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE16(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STH)) || \
++ ((GET_IW_OP((Iw)) == OP_STHIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE32(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_STW)) || \
++ ((GET_IW_OP((Iw)) == OP_STWIO)) \
++ ) \
++ \
++)
++
++#define IW_PROP_STORE(Iw) ( \
++ (op_prop_store[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE_NON_IO(Iw) ( \
++ (op_prop_store_non_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store_non_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MEM(Iw) ( \
++ (op_prop_mem[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mem[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_INITD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_INITD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_INITD_FLUSHD(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_INITD)) || \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHDA(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHDA)) \
++ ) \
++ \
++)
++
++#define IW_PROP_FLUSHD_FLUSHDA(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_FLUSHD)) || \
++ ((GET_IW_OP((Iw)) == OP_FLUSHDA)) \
++ ) \
++ \
++)
++
++#define IW_PROP_INITD_FLUSHD_FLUSHDA(Iw) ( \
++ (op_prop_initd_flushd_flushda[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_initd_flushd_flushda[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_LOAD_IO(Iw) ( \
++ (op_prop_load_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_load_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_STORE_IO(Iw) ( \
++ (op_prop_store_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_store_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MEM_IO(Iw) ( \
++ (op_prop_mem_io[GET_IW_OP(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_mem_io[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_ARITH(Iw) ( \
++ (op_prop_arith[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_arith[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_arith[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_arith[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_A_NOT_SRC(Iw) ( \
++ ( \
++ ((GET_IW_OP((Iw)) == OP_CALL)) || \
++ ((GET_IW_OP((Iw)) == OP_JMPI)) \
++ ) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_READRA(Iw)) \
++)
++
++#define IW_PROP_B_NOT_SRC(Iw) ( \
++ (op_prop_b_not_src[GET_IW_OP(Iw)]) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_READRB(Iw)))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_b_not_src[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_IGNORE_DST(Iw) ( \
++ (op_prop_ignore_dst[GET_IW_OP(Iw)]) \
++ || (IS_CUSTOM_INST(Iw) && !GET_IW_CUSTOM_WRITERC(Iw)))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_ignore_dst[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC2_CHOOSE_IMM(Iw) ( \
++ (op_prop_src2_choose_imm[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src2_choose_imm[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src2_choose_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src2_choose_imm[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_WRCTL_INST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_WRCTL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_RDCTL_INST(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_RDCTL) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SRC1_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) || \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSU) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SRC2_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_MUL_SHIFT_SRC1_SIGNED(Iw) ( \
++ (IS_OPX_INST(Iw) && opx_prop_mul_shift_src1_signed[GET_IW_OPX(Iw)]))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_mul_shift_src1_signed[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_MUL_SHIFT_SRC2_SIGNED(Iw) ( \
++ ( \
++ ((GET_IW_OPX((Iw)) == OPX_MULXSS) && IS_OPX_INST(Iw)) \
++ ) \
++ \
++)
++
++#define IW_PROP_DONT_DISPLAY_DST_REG(Iw) ( \
++ (op_prop_dont_display_dst_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_dst_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_dst_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_dst_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DONT_DISPLAY_SRC1_REG(Iw) ( \
++ (op_prop_dont_display_src1_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_src1_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_src1_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_src1_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_DONT_DISPLAY_SRC2_REG(Iw) ( \
++ (op_prop_dont_display_src2_reg[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_dont_display_src2_reg[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_dont_display_src2_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_dont_display_src2_reg[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC1_NO_X(Iw) ( \
++ (op_prop_src1_no_x[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src1_no_x[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src1_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src1_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#define IW_PROP_SRC2_NO_X(Iw) ( \
++ (op_prop_src2_no_x[GET_IW_OP(Iw)] || \
++ (IS_OPX_INST(Iw) && opx_prop_src2_no_x[GET_IW_OPX(Iw)])))
++
++#ifndef ALT_ASM_SRC
++extern unsigned char op_prop_src2_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++#ifndef ALT_ASM_SRC
++extern unsigned char opx_prop_src2_no_x[64];
++#endif /* ALT_ASM_SRC */
++
++/* Instruction types */
++#define INST_TYPE_OP 0
++#define INST_TYPE_OPX 1
++
++/* Canonical instruction codes independent of encoding */
++#define CALL_INST_CODE 0
++#define JMPI_INST_CODE 1
++#define LDBU_INST_CODE 2
++#define ADDI_INST_CODE 3
++#define STB_INST_CODE 4
++#define BR_INST_CODE 5
++#define LDB_INST_CODE 6
++#define CMPGEI_INST_CODE 7
++#define LDHU_INST_CODE 8
++#define ANDI_INST_CODE 9
++#define STH_INST_CODE 10
++#define BGE_INST_CODE 11
++#define LDH_INST_CODE 12
++#define CMPLTI_INST_CODE 13
++#define ORI_INST_CODE 14
++#define STW_INST_CODE 15
++#define BLT_INST_CODE 16
++#define LDW_INST_CODE 17
++#define CMPNEI_INST_CODE 18
++#define FLUSHDA_INST_CODE 19
++#define XORI_INST_CODE 20
++#define BNE_INST_CODE 21
++#define CMPEQI_INST_CODE 22
++#define LDBUIO_INST_CODE 23
++#define MULI_INST_CODE 24
++#define STBIO_INST_CODE 25
++#define BEQ_INST_CODE 26
++#define LDBIO_INST_CODE 27
++#define CMPGEUI_INST_CODE 28
++#define LDHUIO_INST_CODE 29
++#define ANDHI_INST_CODE 30
++#define STHIO_INST_CODE 31
++#define BGEU_INST_CODE 32
++#define LDHIO_INST_CODE 33
++#define CMPLTUI_INST_CODE 34
++#define CUSTOM_INST_CODE 35
++#define INITD_INST_CODE 36
++#define ORHI_INST_CODE 37
++#define STWIO_INST_CODE 38
++#define BLTU_INST_CODE 39
++#define LDWIO_INST_CODE 40
++#define FLUSHD_INST_CODE 41
++#define XORHI_INST_CODE 42
++#define ERET_INST_CODE 43
++#define ROLI_INST_CODE 44
++#define ROL_INST_CODE 45
++#define FLUSHP_INST_CODE 46
++#define RET_INST_CODE 47
++#define NOR_INST_CODE 48
++#define MULXUU_INST_CODE 49
++#define CMPGE_INST_CODE 50
++#define BRET_INST_CODE 51
++#define ROR_INST_CODE 52
++#define FLUSHI_INST_CODE 53
++#define JMP_INST_CODE 54
++#define AND_INST_CODE 55
++#define CMPLT_INST_CODE 56
++#define SLLI_INST_CODE 57
++#define SLL_INST_CODE 58
++#define OR_INST_CODE 59
++#define MULXSU_INST_CODE 60
++#define CMPNE_INST_CODE 61
++#define SRLI_INST_CODE 62
++#define SRL_INST_CODE 63
++#define NEXTPC_INST_CODE 64
++#define CALLR_INST_CODE 65
++#define XOR_INST_CODE 66
++#define MULXSS_INST_CODE 67
++#define CMPEQ_INST_CODE 68
++#define DIVU_INST_CODE 69
++#define DIV_INST_CODE 70
++#define RDCTL_INST_CODE 71
++#define MUL_INST_CODE 72
++#define CMPGEU_INST_CODE 73
++#define INITI_INST_CODE 74
++#define TRAP_INST_CODE 75
++#define WRCTL_INST_CODE 76
++#define CMPLTU_INST_CODE 77
++#define ADD_INST_CODE 78
++#define BREAK_INST_CODE 79
++#define HBREAK_INST_CODE 80
++#define SYNC_INST_CODE 81
++#define SUB_INST_CODE 82
++#define SRAI_INST_CODE 83
++#define SRA_INST_CODE 84
++#define INTR_INST_CODE 85
++#define CRST_INST_CODE 86
++#define RSV_INST_CODE 87
++#define NUM_NIOS2_INST_CODES 88
++
++#ifndef ALT_ASM_SRC
++/* Instruction information entry */
++typedef struct {
++ const char* name; /* Assembly-language instruction name */
++ int instType; /* INST_TYPE_OP or INST_TYPE_OPX */
++ unsigned opcode; /* Value of instruction word OP/OPX field */
++} Nios2InstInfo;
++
++extern Nios2InstInfo nios2InstInfo[NUM_NIOS2_INST_CODES];
++#endif /* ALT_ASM_SRC */
++
++/* Returns the instruction code given the 32-bit instruction word */
++#define GET_INST_CODE(Iw) \
++ (IS_OPX_INST(Iw) ? opxToInstCode[GET_IW_OPX(Iw)] : opToInstCode[GET_IW_OP(Iw)])
++
++#ifndef ALT_ASM_SRC
++extern int opToInstCode[64];
++extern int opxToInstCode[64];
++#endif /* ALT_ASM_SRC */
++
++/*
++ * MMU Memory Region Macros
++ */
++#define USER_REGION_MIN_VADDR 0x00000000
++#define USER_REGION_MAX_VADDR 0x7fffffff
++#define KERNEL_MMU_REGION_MIN_VADDR 0x80000000
++#define KERNEL_MMU_REGION_MAX_VADDR 0xbfffffff
++#define KERNEL_REGION_MIN_VADDR 0xc0000000
++#define KERNEL_REGION_MAX_VADDR 0xdfffffff
++#define IO_REGION_MIN_VADDR 0xe0000000
++#define IO_REGION_MAX_VADDR 0xffffffff
++
++#define MMU_PAGE_SIZE (0x1 << (MMU_ADDR_PAGE_OFFSET_SZ))
++
++#define isMmuUserRegion(Vaddr) \
++ (GET_MMU_ADDR_USER_REGION(Vaddr) == MMU_ADDR_USER_REGION)
++#define isMmuKernelMmuRegion(Vaddr) \
++ (GET_MMU_ADDR_KERNEL_MMU_REGION(Vaddr) == MMU_ADDR_KERNEL_MMU_REGION)
++#define isMmuKernelRegion(Vaddr) \
++ (GET_MMU_ADDR_KERNEL_REGION(Vaddr) == MMU_ADDR_KERNEL_REGION)
++#define isMmuIORegion(Vaddr) \
++ (GET_MMU_ADDR_IO_REGION(Vaddr) == MMU_ADDR_IO_REGION)
++
++/* Does this virtual address bypass the TLB? */
++#define vaddrBypassTlb(Vaddr) \
++ (GET_MMU_ADDR_BYPASS_TLB(Vaddr) == MMU_ADDR_BYPASS_TLB)
++
++/* If TLB is bypassed, is the address cacheable or uncachable. */
++#define vaddrBypassTlbCacheable(Vaddr) \
++ (GET_MMU_ADDR_BYPASS_TLB_CACHEABLE(Vaddr) == MMU_ADDR_BYPASS_TLB_CACHEABLE)
++
++/*
++ * Compute physical address for regions that bypass the TLB.
++ * Just need to clear some top bits.
++ */
++#define bypassTlbVaddrToPaddr(Vaddr) \
++ ((Vaddr) & (MMU_ADDR_BYPASS_TLB_PADDR_MASK << MMU_ADDR_BYPASS_TLB_PADDR_LSB))
++
++/*
++ * Will the physical address fit in the Kernel/IO region virtual address space?
++ */
++#define fitsInKernelRegion(Paddr) \
++ (GET_MMU_ADDR_KERNEL_REGION(Paddr) == 0)
++#define fitsInIORegion(Paddr) \
++ (GET_MMU_ADDR_IO_REGION(Paddr) == 0)
++
++/* Convert a physical address to a Kernel/IO region virtual address. */
++#define paddrToKernelRegionVaddr(Paddr) \
++ ((Paddr) | (MMU_ADDR_KERNEL_REGION << MMU_ADDR_KERNEL_REGION_LSB))
++#define paddrToIORegionVaddr(Paddr) \
++ ((Paddr) | (MMU_ADDR_IO_REGION << MMU_ADDR_IO_REGION_LSB))
++
++/*
++ * Convert a virtual address to a Kernel/IO region virtual address.
++ * Uses bypassTlbVaddrToPaddr to clear top bits.
++ */
++#define vaddrToKernelRegionVaddr(Vaddr) \
++ paddrToKernelRegionVaddr(bypassTlbVaddrToPaddr(Vaddr))
++#define vaddrToIORegionVaddr(Vaddr) \
++ paddrToIORegionVaddr(bypassTlbVaddrToPaddr(Vaddr))
++
++/* Convert between VPN/PFN and virtual/physical addresses. */
++#define vpnToVaddr(Vpn) ((Vpn) << MMU_ADDR_VPN_LSB)
++#define pfnToPaddr(Pfn) ((Pfn) << MMU_ADDR_PFN_LSB)
++#define vaddrToVpn(Vaddr) GET_MMU_ADDR_VPN(Vaddr)
++#define paddrToPfn(Paddr) GET_MMU_ADDR_PFN(Paddr)
++
++/* Bitwise OR with a KERNEL region address to make it an IO region address */
++#define KERNEL_TO_IO_REGION 0x20000000
++
++#endif /* _NIOS2_ISA_H_ */
+diff --git a/include/opcode/nios2.h b/include/opcode/nios2.h
+new file mode 100644
+index 0000000..992bb80
+--- /dev/null
++++ b/include/opcode/nios2.h
+@@ -0,0 +1,361 @@
++/* nios2.h. Altera New Jersey opcode list for GAS, the GNU assembler.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#ifndef _NIOS2_H_
++#define _NIOS2_H_
++
++
++/****************************************************************************
++ * This file contains structures, bit masks and shift counts used
++ * by the GNU toolchain to define the New Jersey instruction set and
++ * access various opcode fields.
++ ****************************************************************************/
++
++enum overflow_type
++{
++ call_target_overflow = 0,
++ branch_target_overflow,
++ address_offset_overflow,
++ signed_immed16_overflow,
++ unsigned_immed16_overflow,
++ unsigned_immed5_overflow,
++ custom_opcode_overflow,
++ no_overflow
++};
++
++/*---------------------------------------------------------------------------
++ This structure holds information for a particular instruction
++ ---------------------------------------------------------------------------*/
++
++/* match When assembling, this
++ opcode is modified by the arguments to produce the actual opcode
++ that is used. If pinfo is INSN_MACRO, then this is 0. */
++
++/* mask If pinfo is not INSN_MACRO, then this is a bit mask for the
++ relevant portions of the opcode when disassembling. If the
++ actual opcode anded with the match field equals the opcode field,
++ then we have found the correct instruction. If pinfo is
++ INSN_MACRO, then this field is the macro identifier. */
++
++/* For a macro, this is INSN_MACRO. Otherwise, it is a collection
++ of bits describing the instruction, notably any relevant hazard
++ information. */
++
++struct nios2_opcode
++{
++ const char *name; /* The name of the instruction. */
++ const char *args; /* A string describing the arguments for this instruction. */
++ const char *args_test; /* Like args, but with an extra argument for the expected opcode */
++ unsigned long num_args; /* the number of arguments the instruction takes */
++ unsigned long match; /* The basic opcode for the instruction. */
++ unsigned long mask; /* mask for the opcode field of the instruction */
++ unsigned long pinfo; /* is this a real instruction or instruction macro */
++ enum overflow_type overflow_msg; /* msg template used to generate informative message when fixup overflows */
++};
++
++/* This value is used in the nios2_opcode.pinfo field to indicate that the instruction
++ is a macro or pseudo-op. This requires special treatment by the assembler, and is
++ used by the disassembler to determine whether to check for a nop */
++#define NIOS2_INSN_MACRO 0x80000000
++#define NIOS2_INSN_MACRO_MOV 0x80000001
++#define NIOS2_INSN_MACRO_MOVI 0x80000002
++#define NIOS2_INSN_MACRO_MOVIA 0x80000004
++
++#define NIOS2_INSN_RELAXABLE 0x40000000
++#define NIOS2_INSN_UBRANCH 0x00000010
++#define NIOS2_INSN_CBRANCH 0x00000020
++#define NIOS2_INSN_CALL 0x00000040
++
++#define NIOS2_INSN_ADDI 0x00000080
++#define NIOS2_INSN_ANDI 0x00000100
++#define NIOS2_INSN_ORI 0x00000200
++#define NIOS2_INSN_XORI 0x00000400
++
++
++
++/* Associates a register name ($6) with a 5-bit index (eg 6) */
++struct nios2_reg
++{
++ const char *name;
++ const int index;
++};
++
++
++/* -------------------------------------------------------------------------
++ Bitfield masks for New Jersey instructions
++ -------------------------------------------------------------------------*/
++
++/* These are bit masks and shift counts to use to access the various
++ fields of an instruction. */
++
++/* Macros for getting and setting an instruction field */
++#define GET_INSN_FIELD(X, i) ((i) & OP_MASK_##X) >> OP_SH_##X
++#define SET_INSN_FIELD(X, i, j) (i) = ((i) &~ (OP_MASK_##X)) | ((j) << OP_SH_##X)
++
++
++/*
++ We include the auto-generated file nios2-isa.h and define the mask
++ and shifts below in terms of those in nios2-isa.h. This ensures
++ that the binutils and hardware are always in sync
++*/
++
++#include "nios2-isa.h"
++
++#define OP_MASK_OP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_OP IW_OP_LSB
++
++
++/* Masks and shifts for I-type instructions */
++
++#define OP_MASK_IOP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_IOP IW_OP_LSB
++
++#define OP_MASK_IMM16 (IW_IMM16_MASK << IW_IMM16_LSB)
++#define OP_SH_IMM16 IW_IMM16_LSB
++
++#define OP_MASK_IRD (IW_B_MASK << IW_B_LSB) // the same as T for I-type
++#define OP_SH_IRD IW_B_LSB
++
++#define OP_MASK_IRT (IW_B_MASK << IW_B_LSB)
++#define OP_SH_IRT IW_B_LSB
++
++#define OP_MASK_IRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_IRS IW_A_LSB
++
++/* Masks and shifts for R-type instructions */
++
++#define OP_MASK_ROP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_ROP IW_OP_LSB
++
++#define OP_MASK_ROPX (IW_OPX_MASK << IW_OPX_LSB)
++#define OP_SH_ROPX IW_OPX_LSB
++
++#define OP_MASK_RRD (IW_C_MASK << IW_C_LSB)
++#define OP_SH_RRD IW_C_LSB
++
++#define OP_MASK_RRT (IW_B_MASK << IW_B_LSB)
++#define OP_SH_RRT IW_B_LSB
++
++#define OP_MASK_RRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_RRS IW_A_LSB
++
++/* Masks and shifts for J-type instructions */
++
++#define OP_MASK_JOP (IW_OP_MASK << IW_OP_LSB)
++#define OP_SH_JOP IW_OP_LSB
++
++#define OP_MASK_IMM26 (IW_IMM26_MASK << IW_IMM26_LSB)
++#define OP_SH_IMM26 IW_IMM26_LSB
++
++/* Masks and shifts for CTL instructions */
++
++#define OP_MASK_RCTL 0x000007c0
++#define OP_SH_RCTL 6
++
++/* break instruction imm5 field */
++#define OP_MASK_TRAP_IMM5 0x000007c0
++#define OP_SH_TRAP_IMM5 6
++
++/* instruction imm5 field */
++#define OP_MASK_IMM5 (IW_SHIFT_IMM5_MASK << IW_SHIFT_IMM5_LSB)
++#define OP_SH_IMM5 IW_SHIFT_IMM5_LSB
++
++/* cache operation fields (type j,i(s)) */
++#define OP_MASK_CACHE_OPX (IW_B_MASK << IW_B_LSB)
++#define OP_SH_CACHE_OPX IW_B_LSB
++#define OP_MASK_CACHE_RRS (IW_A_MASK << IW_A_LSB)
++#define OP_SH_CACHE_RRS IW_A_LSB
++
++/* custom instruction masks */
++#define OP_MASK_CUSTOM_A 0x00010000
++#define OP_SH_CUSTOM_A 16
++
++#define OP_MASK_CUSTOM_B 0x00008000
++#define OP_SH_CUSTOM_B 15
++
++#define OP_MASK_CUSTOM_C 0x00004000
++#define OP_SH_CUSTOM_C 14
++
++#define OP_MASK_CUSTOM_N 0x00003fc0
++#define OP_SH_CUSTOM_N 6
++#define OP_MAX_CUSTOM_N 255
++
++/*
++ The following macros define the opcode matches for each
++ instruction
++ code & OP_MASK_INST == OP_MATCH_INST
++ */
++
++/* OP instruction matches */
++#define OP_MATCH_ADDI OP_ADDI
++#define OP_MATCH_ANDHI OP_ANDHI
++#define OP_MATCH_ANDI OP_ANDI
++#define OP_MATCH_BEQ OP_BEQ
++#define OP_MATCH_BGE OP_BGE
++#define OP_MATCH_BGEU OP_BGEU
++#define OP_MATCH_BLT OP_BLT
++#define OP_MATCH_BLTU OP_BLTU
++#define OP_MATCH_BNE OP_BNE
++#define OP_MATCH_BR OP_BR
++#define OP_MATCH_FLUSHD OP_FLUSHD
++#define OP_MATCH_FLUSHDA OP_FLUSHDA
++#define OP_MATCH_INITD OP_INITD
++#define OP_MATCH_CALL OP_CALL
++#define OP_MATCH_CMPEQI OP_CMPEQI
++#define OP_MATCH_CMPGEI OP_CMPGEI
++#define OP_MATCH_CMPGEUI OP_CMPGEUI
++#define OP_MATCH_CMPLTI OP_CMPLTI
++#define OP_MATCH_CMPLTUI OP_CMPLTUI
++#define OP_MATCH_CMPNEI OP_CMPNEI
++#define OP_MATCH_JMPI OP_JMPI
++#define OP_MATCH_LDB OP_LDB
++#define OP_MATCH_LDBIO OP_LDBIO
++#define OP_MATCH_LDBU OP_LDBU
++#define OP_MATCH_LDBUIO OP_LDBUIO
++#define OP_MATCH_LDH OP_LDH
++#define OP_MATCH_LDHIO OP_LDHIO
++#define OP_MATCH_LDHU OP_LDHU
++#define OP_MATCH_LDHUIO OP_LDHUIO
++#define OP_MATCH_LDW OP_LDW
++#define OP_MATCH_LDWIO OP_LDWIO
++#define OP_MATCH_MULI OP_MULI
++#define OP_MATCH_OPX OP_OPX
++#define OP_MATCH_ORHI OP_ORHI
++#define OP_MATCH_ORI OP_ORI
++#define OP_MATCH_STB OP_STB
++#define OP_MATCH_STBIO OP_STBIO
++#define OP_MATCH_STH OP_STH
++#define OP_MATCH_STHIO OP_STHIO
++#define OP_MATCH_STW OP_STW
++#define OP_MATCH_STWIO OP_STWIO
++#define OP_MATCH_CUSTOM OP_CUSTOM
++#define OP_MATCH_XORHI OP_XORHI
++#define OP_MATCH_XORI OP_XORI
++#define OP_MATCH_OPX OP_OPX
++
++
++
++/* OPX instruction values */
++#define OP_MATCH_ADD ((OPX_ADD << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_AND ((OPX_AND << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_BREAK ((0x1e << 17) | (OPX_BREAK << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_BRET ((0xf0000000) | (OPX_BRET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CALLR ((0x1f << 17) | (OPX_CALLR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPEQ ((OPX_CMPEQ << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPGE ((OPX_CMPGE << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPGEU ((OPX_CMPGEU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPLT ((OPX_CMPLT << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPLTU ((OPX_CMPLTU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_CMPNE ((OPX_CMPNE << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_DIV ((OPX_DIV << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_DIVU ((OPX_DIVU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_JMP ((OPX_JMP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MUL ((OPX_MUL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXSS ((OPX_MULXSS << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXSU ((OPX_MULXSU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_MULXUU ((OPX_MULXUU << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_NEXTPC ((OPX_NEXTPC << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_NOR ((OPX_NOR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_OR ((OPX_OR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_RDCTL ((OPX_RDCTL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_RET ((0xf8000000) | (OPX_RET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROL ((OPX_ROL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROLI ((OPX_ROLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ROR ((OPX_ROR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SLL ((OPX_SLL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SLLI ((OPX_SLLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRA ((OPX_SRA << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRAI ((OPX_SRAI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRL ((OPX_SRL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SRLI ((OPX_SRLI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SUB ((OPX_SUB << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_SYNC ((OPX_SYNC << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_TRAP ((0x1d << 17) | (OPX_TRAP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_ERET ((0xe8000000) | (OPX_ERET << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_WRCTL ((OPX_WRCTL << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_XOR ((OPX_XOR << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_FLUSHI ((OPX_FLUSHI << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_FLUSHP ((OPX_FLUSHP << IW_OPX_LSB) | (OP_OPX))
++#define OP_MATCH_INITI ((OPX_INITI << IW_OPX_LSB) | (OP_OPX))
++
++/*
++ Some unusual op masks
++*/
++#define OP_MASK_BREAK ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP) & 0xfffff03f)
++#define OP_MASK_CALLR ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_JMP ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SYNC ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_TRAP ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP) & 0xfffff83f)
++#define OP_MASK_WRCTL ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP)) /*& 0xfffff83f */
++#define OP_MASK_NEXTPC ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_FLUSHI ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_INITI ((OP_MASK_RRT | OP_MASK_RRD | OP_MASK_ROPX | OP_MASK_OP))
++
++#define OP_MASK_ROLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SLLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SRAI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_SRLI ((OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP))
++#define OP_MASK_RDCTL ((OP_MASK_RRS | OP_MASK_RRT | OP_MASK_ROPX | OP_MASK_OP)) /*& 0xfffff83f */
++
++#ifndef OP_MASK
++#define OP_MASK 0xffffffff
++#endif
++
++/* These are the data structures we use to hold the instruction information */
++
++extern const struct nios2_opcode nios2_builtin_opcodes[];
++extern const int bfd_nios2_num_builtin_opcodes;
++extern struct nios2_opcode *nios2_opcodes;
++extern int bfd_nios2_num_opcodes;
++
++/* These are the data structures used to hold the operand parsing information */
++//extern const struct nios2_arg_parser nios2_arg_parsers[];
++//extern struct nios2_arg_parser* nios2_arg_parsers;
++//extern const int nios2_num_builtin_arg_parsers;
++//extern int nios2_num_arg_parsers;
++
++/* These are the data structures used to hold the register information */
++extern const struct nios2_reg nios2_builtin_regs[];
++extern struct nios2_reg *nios2_regs;
++extern const int nios2_num_builtin_regs;
++extern int nios2_num_regs;
++
++/* Machine-independent macro for number of opcodes */
++
++#define NUMOPCODES bfd_nios2_num_opcodes
++#define NUMREGISTERS nios2_num_regs;
++
++/* these are used in disassembly to get the correct register names */
++#define NUMREGNAMES 32
++#define NUMCTLREGNAMES 32
++#define CTLREGBASE 42
++#define COPROCREGBASE 83
++#define NUMCOPROCREGNAMES 32
++
++
++/* this is made extern so that the assembler can use it to find out
++ what instruction caused an error */
++extern const struct nios2_opcode *nios2_find_opcode_hash (unsigned long);
++
++/* overflow message strings used in the assembler */
++extern char *overflow_msgs[];
++
++#endif // _NIOS2_H
+diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
+index ebd252f..a7ca06b 100644
+--- a/opcodes/Makefile.am
++++ b/opcodes/Makefile.am
+@@ -146,6 +146,13 @@ CFILES = \
+ mt-dis.c \
+ mt-ibld.c \
+ mt-opc.c \
++ nios2-opc.c \
++ nios2-dis.c \
++ ms1-asm.c \
++ ms1-desc.c \
++ ms1-dis.c \
++ ms1-ibld.c \
++ ms1-opc.c \
+ ns32k-dis.c \
+ openrisc-asm.c \
+ openrisc-desc.c \
+@@ -281,6 +288,8 @@ ALL_MACHINES = \
+ mt-dis.lo \
+ mt-ibld.lo \
+ mt-opc.lo \
++ nios2-opc.lo \
++ nios2-dis.lo \
+ ns32k-dis.lo \
+ openrisc-asm.lo \
+ openrisc-desc.lo \
+@@ -980,6 +989,13 @@ mt-opc.lo: mt-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ mt-desc.h $(INCDIR)/opcode/cgen-bitset.h $(INCDIR)/opcode/cgen.h \
+ $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h mt-opc.h \
+ $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
++nios2-opc.lo: nios2-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/opcode/nios2.h
++nios2-dis.lo: nios2-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/nios2.h \
++ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
++ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
++ $(INCDIR)/elf/nios2.h $(INCDIR)/elf/reloc-macros.h
+ ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/ns32k.h \
+diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
+index 85003e6..9e3baae 100644
+--- a/opcodes/Makefile.in
++++ b/opcodes/Makefile.in
+@@ -360,6 +360,8 @@ CFILES = \
+ mt-dis.c \
+ mt-ibld.c \
+ mt-opc.c \
++ nios2-opc.c \
++ nios2-dis.c \
+ ns32k-dis.c \
+ openrisc-asm.c \
+ openrisc-desc.c \
+@@ -495,6 +497,8 @@ ALL_MACHINES = \
+ mt-dis.lo \
+ mt-ibld.lo \
+ mt-opc.lo \
++ nios2-opc.lo \
++ nios2-dis.lo \
+ ns32k-dis.lo \
+ openrisc-asm.lo \
+ openrisc-desc.lo \
+@@ -1517,6 +1521,13 @@ mt-opc.lo: mt-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ mt-desc.h $(INCDIR)/opcode/cgen-bitset.h $(INCDIR)/opcode/cgen.h \
+ $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h mt-opc.h \
+ $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
++nios2-opc.lo: nios2-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/opcode/nios2.h
++nios2-dis.lo: nios2-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
++ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/nios2.h \
++ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
++ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
++ $(INCDIR)/elf/nios2.h $(INCDIR)/elf/reloc-macros.h
+ ns32k-dis.lo: ns32k-dis.c $(BFD_H) $(INCDIR)/ansidecl.h \
+ $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/opcode/ns32k.h \
+diff --git a/opcodes/configure b/opcodes/configure
+index 8e3e27e..a28cc46 100755
+--- a/opcodes/configure
++++ b/opcodes/configure
+@@ -6561,6 +6561,7 @@ if test x${all_targets} = xfalse ; then
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_mt_arch) ta="$ta mt-asm.lo mt-desc.lo mt-dis.lo mt-ibld.lo mt-opc.lo" using_cgen=yes ;;
+ bfd_msp430_arch) ta="$ta msp430-dis.lo" ;;
++ bfd_nios2_arch) ta="$ta nios2-opc.lo nios2-dis.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
+ bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
+diff --git a/opcodes/configure.in b/opcodes/configure.in
+index d937784..c9df814 100644
+--- a/opcodes/configure.in
++++ b/opcodes/configure.in
+@@ -190,6 +190,7 @@ if test x${all_targets} = xfalse ; then
+ bfd_mn10300_arch) ta="$ta m10300-dis.lo m10300-opc.lo" ;;
+ bfd_mt_arch) ta="$ta mt-asm.lo mt-desc.lo mt-dis.lo mt-ibld.lo mt-opc.lo" using_cgen=yes ;;
+ bfd_msp430_arch) ta="$ta msp430-dis.lo" ;;
++ bfd_nios2_arch) ta="$ta nios2-opc.lo nios2-dis.lo" ;;
+ bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;;
+ bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
+ bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
+diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
+index ca28f56..dfacbb9 100644
+--- a/opcodes/disassemble.c
++++ b/opcodes/disassemble.c
+@@ -80,6 +80,7 @@
+ #define ARCH_xtensa
+ #define ARCH_z80
+ #define ARCH_z8k
++#define ARCH_nios2
+ #define INCLUDE_SHMEDIA
+ #endif
+
+@@ -424,6 +425,14 @@ disassembler (abfd)
+ disassemble = print_insn_iq2000;
+ break;
+ #endif
++#ifdef ARCH_nios2
++ case bfd_arch_nios2:
++ if (bfd_big_endian (abfd))
++ disassemble = print_insn_big_nios2;
++ else
++ disassemble = print_insn_little_nios2;
++ break;
++#endif
+ #ifdef ARCH_m32c
+ case bfd_arch_m32c:
+ disassemble = print_insn_m32c;
+diff --git a/opcodes/nios2-dis.c b/opcodes/nios2-dis.c
+new file mode 100644
+index 0000000..ac9eb0d
+--- /dev/null
++++ b/opcodes/nios2-dis.c
+@@ -0,0 +1,462 @@
++/* nios2-dis.c -- Altera New Jersey disassemble routines.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include <stdlib.h>
++#include <assert.h>
++#include <string.h>
++#include "dis-asm.h"
++#include "opcode/nios2.h"
++
++/* No symbol table is available when this code runs out in an embedded
++ system as when it is used for disassembler support in a monitor. */
++
++#if !defined(EMBEDDED_ENV)
++#define SYMTAB_AVAILABLE 1
++#include "elf-bfd.h"
++#include "elf/nios2.h"
++#endif
++
++/* length of New Jersey instruction in bytes */
++#define INSNLEN 4
++
++/* helper function prototypes */
++static int nios2_disassemble (bfd_vma, unsigned long, disassemble_info *);
++static void nios2_init_opcode_hash (void);
++
++
++static int nios2_print_insn_arg (const char *argptr, unsigned long opcode,
++ bfd_vma address, disassemble_info * info);
++
++
++/* print_insn_nios2 is the main disassemble function for New Jersey.
++ The function diassembler(abfd) (source in disassemble.c) returns a
++ pointer to this either print_insn_big_nios2 or
++ print_insn_little_nios2, which in turn call this function, when the
++ bfd machine type is New Jersey. print_insn_nios2 reads the
++ instruction word at the address given, and prints the disassembled
++ instruction on the stream info->stream using info->fprintf_func. */
++
++static int
++print_insn_nios2 (bfd_vma address, disassemble_info * info,
++ enum bfd_endian endianness)
++{
++ /* buffer into which the instruction bytes are written */
++ bfd_byte buffer[INSNLEN];
++ /* used to indicate return status from function calls */
++ int status;
++
++ assert (info != NULL);
++
++ status = (*info->read_memory_func) (address, buffer, INSNLEN, info);
++ if (status == 0)
++ {
++ unsigned long insn;
++ if (endianness == BFD_ENDIAN_BIG)
++ insn = (unsigned long) bfd_getb32 (buffer);
++ else
++ insn = (unsigned long) bfd_getl32 (buffer);
++ status = nios2_disassemble (address, insn, info);
++ }
++ else
++ {
++ (*info->memory_error_func) (status, address, info);
++ status = -1;
++ }
++ return status;
++}
++
++int
++print_insn_big_nios2 (bfd_vma address, disassemble_info * info)
++{
++ return print_insn_nios2 (address, info, BFD_ENDIAN_BIG);
++}
++
++int
++print_insn_little_nios2 (bfd_vma address, disassemble_info * info)
++{
++ return print_insn_nios2 (address, info, BFD_ENDIAN_LITTLE);
++}
++
++/* Data structures used by the opcode hash table */
++
++typedef struct _nios2_opcode_hash
++{
++ const struct nios2_opcode *opcode;
++ struct _nios2_opcode_hash *next;
++} nios2_opcode_hash;
++
++static bfd_boolean nios2_hash_init = 0;
++static nios2_opcode_hash *nios2_hash[(OP_MASK_OP) + 1];
++
++/* separate hash table for pseudo-ops */
++static nios2_opcode_hash *nios2_ps_hash[(OP_MASK_OP) + 1];
++
++/* Function to initialize the opcode hash table */
++
++void
++nios2_init_opcode_hash ()
++{
++ unsigned int i;
++ register const struct nios2_opcode *op;
++ nios2_opcode_hash *tmp_hash;
++
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ nios2_hash[0] = NULL;
++ }
++ for (i = 0; i <= OP_MASK_OP; i++)
++ {
++ for (op = nios2_opcodes; op < &nios2_opcodes[NUMOPCODES]; op++)
++ {
++ if ((op->pinfo & NIOS2_INSN_MACRO) == NIOS2_INSN_MACRO)
++ {
++ if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP) &&
++ (op->
++ pinfo & (NIOS2_INSN_MACRO_MOV | NIOS2_INSN_MACRO_MOVI) &
++ 0x7fffffff) != 0)
++ {
++ tmp_hash = nios2_ps_hash[i];
++ if (tmp_hash == NULL)
++ {
++ tmp_hash =
++ (nios2_opcode_hash *)
++ malloc (sizeof (nios2_opcode_hash));
++ nios2_ps_hash[i] = tmp_hash;
++ }
++ else
++ {
++ while (tmp_hash->next != NULL)
++ tmp_hash = tmp_hash->next;
++ tmp_hash->next =
++ (nios2_opcode_hash *)
++ malloc (sizeof (nios2_opcode_hash));
++ tmp_hash = tmp_hash->next;
++ }
++ if (tmp_hash == NULL)
++ {
++ fprintf (stderr,
++ "error allocating memory...broken disassembler\n");
++ abort ();
++ }
++ tmp_hash->opcode = op;
++ tmp_hash->next = NULL;
++ }
++ }
++ else if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP))
++ {
++ tmp_hash = nios2_hash[i];
++ if (tmp_hash == NULL)
++ {
++ tmp_hash =
++ (nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
++ nios2_hash[i] = tmp_hash;
++ }
++ else
++ {
++ while (tmp_hash->next != NULL)
++ tmp_hash = tmp_hash->next;
++ tmp_hash->next =
++ (nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
++ tmp_hash = tmp_hash->next;
++ }
++ if (tmp_hash == NULL)
++ {
++ fprintf (stderr,
++ "error allocating memory...broken disassembler\n");
++ abort ();
++ }
++ tmp_hash->opcode = op;
++ tmp_hash->next = NULL;
++ }
++ }
++ }
++ nios2_hash_init = 1;
++#ifdef DEBUG_HASHTABLE
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ printf ("index: 0x%02X ops: ", i);
++ tmp_hash = nios2_hash[i];
++ if (tmp_hash != NULL)
++ {
++ while (tmp_hash != NULL)
++ {
++ printf ("%s ", tmp_hash->opcode->name);
++ tmp_hash = tmp_hash->next;
++ }
++ }
++ printf ("\n");
++ }
++
++ for (i = 0; i <= OP_MASK_OP; ++i)
++ {
++ printf ("index: 0x%02X ops: ", i);
++ tmp_hash = nios2_ps_hash[i];
++ if (tmp_hash != NULL)
++ {
++ while (tmp_hash != NULL)
++ {
++ printf ("%s ", tmp_hash->opcode->name);
++ tmp_hash = tmp_hash->next;
++ }
++ }
++ printf ("\n");
++ }
++#endif
++}
++
++/* Function which returns a pointer to an nios2_opcode struct for
++ a given instruction opcode, or NULL if there is an error */
++
++const struct nios2_opcode *
++nios2_find_opcode_hash (unsigned long opcode)
++{
++ nios2_opcode_hash *entry;
++
++ /* Build a hash table to shorten the search time. */
++ if (!nios2_hash_init)
++ {
++ nios2_init_opcode_hash ();
++ }
++
++ /* first look in the pseudo-op hashtable */
++ entry = nios2_ps_hash[(opcode >> OP_SH_OP) & OP_MASK_OP];
++
++ /* look for a match and if we get one, this is the instruction we decode */
++ while (entry != NULL)
++ {
++ if ((entry->opcode->match) == (opcode & entry->opcode->mask))
++ return entry->opcode;
++ else
++ entry = entry->next;
++ }
++
++ /* if we haven't yet returned, then we need to look in the main
++ hashtable */
++ entry = nios2_hash[(opcode >> OP_SH_OP) & OP_MASK_OP];
++
++ if (entry == NULL)
++ return NULL;
++
++
++ while (entry != NULL)
++ {
++ if ((entry->opcode->match) == (opcode & entry->opcode->mask))
++ return entry->opcode;
++ else
++ entry = entry->next;
++ }
++
++ return NULL;
++}
++
++/* nios2_disassemble does all the work of disassembling a New Jersey
++ instruction opcode */
++
++int
++nios2_disassemble (bfd_vma address, unsigned long opcode,
++ disassemble_info * info)
++{
++ const struct nios2_opcode *op;
++ const char *argstr;
++
++ info->bytes_per_line = INSNLEN;
++ info->bytes_per_chunk = INSNLEN;
++ info->display_endian = info->endian;
++ info->insn_info_valid = 1;
++ info->branch_delay_insns = 0;
++ info->data_size = 0;
++ info->insn_type = dis_nonbranch;
++ info->target = 0;
++ info->target2 = 0;
++
++ /* Find the major opcode and use this to disassemble
++ the instruction and its arguments */
++ op = nios2_find_opcode_hash (opcode);
++
++ if (op != NULL)
++ {
++ bfd_boolean is_nop = FALSE;
++ if (op->pinfo == NIOS2_INSN_MACRO_MOV)
++ {
++ /* check for mov r0, r0 and if it is
++ change to nop */
++ int dst, src;
++ dst = GET_INSN_FIELD (RRD, opcode);
++ src = GET_INSN_FIELD (RRS, opcode);
++ if (dst == 0 && src == 0)
++ {
++ (*info->fprintf_func) (info->stream, "nop");
++ is_nop = TRUE;
++ }
++ else
++ {
++ (*info->fprintf_func) (info->stream, "%s", op->name);
++ }
++ }
++ else
++ {
++ (*info->fprintf_func) (info->stream, "%s", op->name);
++ }
++
++ if (!is_nop)
++ {
++ argstr = op->args;
++ if (argstr != NULL && *argstr != '\0')
++ {
++ (*info->fprintf_func) (info->stream, "\t");
++ while (*argstr != '\0')
++ {
++ nios2_print_insn_arg (argstr, opcode, address, info);
++ ++argstr;
++ }
++ }
++ }
++ }
++ else
++ {
++ /* Handle undefined instructions. */
++ info->insn_type = dis_noninsn;
++ (*info->fprintf_func) (info->stream, "0x%x", (unsigned int) opcode);
++ }
++ // this tells the caller how far to advance the program counter
++ return INSNLEN;
++}
++
++/* The function nios2_print_insn_arg uses the character pointed
++ to by argptr to determine how it print the next token or separator
++ character in the arguments to an instruction */
++int
++nios2_print_insn_arg (const char *argptr,
++ unsigned long opcode, bfd_vma address,
++ disassemble_info * info)
++{
++ unsigned long i = 0;
++ unsigned long reg_base;
++
++ assert (argptr != NULL);
++ assert (info != NULL);
++
++ switch (*argptr)
++ {
++ case ',':
++ case '(':
++ case ')':
++ (*info->fprintf_func) (info->stream, "%c", *argptr);
++ break;
++ case 'd':
++ i = GET_INSN_FIELD (RRD, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_C, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 's':
++ i = GET_INSN_FIELD (RRS, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_A, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 't':
++ i = GET_INSN_FIELD (RRT, opcode);
++
++ if (GET_INSN_FIELD (OP, opcode) == OP_MATCH_CUSTOM
++ && GET_INSN_FIELD (CUSTOM_B, opcode) == 0)
++ reg_base = COPROCREGBASE;
++ else
++ reg_base = 0;
++
++ if (i < NUMREGNAMES)
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[i + reg_base].name);
++ else
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ case 'i':
++ /* 16-bit signed immediate */
++ i = (signed) (GET_INSN_FIELD (IMM16, opcode) << 16) >> 16;
++ (*info->fprintf_func) (info->stream, "%d", (int) i);
++ break;
++ case 'u':
++ /* 16-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM16, opcode);
++ (*info->fprintf_func) (info->stream, "%d", (int) i);
++ break;
++ case 'o':
++ /* 16-bit signed immediate address offset */
++ i = (signed) (GET_INSN_FIELD (IMM16, opcode) << 16) >> 16;
++ address = address + 4 + i; /* NG changed to byte offset 1/9/03 */
++ (*info->print_address_func) (address, info);
++ break;
++ case 'p':
++ /* 5-bit unsigned immediate */
++ i = GET_INSN_FIELD (CACHE_OPX, opcode);
++ (*info->fprintf_func) (info->stream, "%d", (int) i);
++ break;
++ case 'j':
++ /* 5-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM5, opcode);
++ (*info->fprintf_func) (info->stream, "%d", (int) i);
++ break;
++ case 'l':
++ /* 8-bit unsigned immediate */
++ /* FIXME - not yet implemented */
++ i = GET_INSN_FIELD (CUSTOM_N, opcode);
++ (*info->fprintf_func) (info->stream, "%u", (int) i);
++ break;
++ case 'm':
++ /* 26-bit unsigned immediate */
++ i = GET_INSN_FIELD (IMM26, opcode);
++ /* this translates to an address because its only used in call instructions */
++ address = (address & 0xf0000000) | (i << 2);
++ (*info->print_address_func) (address, info);
++ break;
++ case 'c':
++ i = GET_INSN_FIELD (IMM5, opcode); /* ctrl register index */
++ (*info->fprintf_func) (info->stream, "%s",
++ nios2_regs[CTLREGBASE + i].name);
++ break;
++ case 'b':
++ i = GET_INSN_FIELD (IMM5, opcode);
++ (*info->fprintf_func) (info->stream, "%d", (int) i);
++ break;
++ default:
++ (*info->fprintf_func) (info->stream, "unknown");
++ break;
++ }
++ return 0;
++}
+diff --git a/opcodes/nios2-opc.c b/opcodes/nios2-opc.c
+new file mode 100644
+index 0000000..c860207
+--- /dev/null
++++ b/opcodes/nios2-opc.c
+@@ -0,0 +1,320 @@
++/* nios2-opc.c -- Altera New Jersey opcode list.
++
++ Copyright (C) 2003
++ by Nigel Gray (ngray@altera.com).
++
++This file is part of GDB, GAS, and the GNU binutils.
++
++GDB, GAS, and the GNU binutils are free software; you can redistribute
++them and/or modify them under the terms of the GNU General Public
++License as published by the Free Software Foundation; either version
++1, or (at your option) any later version.
++
++GDB, GAS, and the GNU binutils are distributed in the hope that they
++will be useful, but WITHOUT ANY WARRANTY; without even the implied
++warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
++the GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this file; see the file COPYING. If not, write to the Free
++Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#include <stdio.h>
++#include "opcode/nios2.h"
++
++/* Register string table */
++
++const struct nios2_reg nios2_builtin_regs[] = {
++ {"zero", 0},
++ {"at", 1}, // assembler temporary
++ {"r2", 2},
++ {"r3", 3},
++ {"r4", 4},
++ {"r5", 5},
++ {"r6", 6},
++ {"r7", 7},
++ {"r8", 8},
++ {"r9", 9},
++ {"r10", 10},
++ {"r11", 11},
++ {"r12", 12},
++ {"r13", 13},
++ {"r14", 14},
++ {"r15", 15},
++ {"r16", 16},
++ {"r17", 17},
++ {"r18", 18},
++ {"r19", 19},
++ {"r20", 20},
++ {"r21", 21},
++ {"r22", 22},
++ {"r23", 23},
++ {"et", 24},
++ {"bt", 25},
++ {"gp", 26}, /* global pointer */
++ {"sp", 27}, /* stack pointer */
++ {"fp", 28}, /* frame pointer */
++ {"ea", 29}, /* exception return address */
++ {"ba", 30}, /* breakpoint return address */
++ {"ra", 31}, /* return address */
++
++ /* alternative names for special registers */
++ {"r0", 0},
++ {"r1", 1},
++ {"r24", 24},
++ {"r25", 25},
++ {"r26", 26},
++ {"r27", 27},
++ {"r28", 28},
++ {"r29", 29},
++ {"r30", 30},
++ {"r31", 31},
++
++ /* control register names */
++ {"status", 0},
++ {"estatus", 1},
++ {"bstatus", 2},
++ {"ienable", 3},
++ {"ipending", 4},
++ {"cpuid", 5},
++ {"ctl6", 6},
++ {"ctl7", 7},
++ {"pteaddr", 8},
++ {"tlbacc", 9},
++ {"tlbmisc", 10},
++ {"fstatus", 11},
++ {"ctl12", 12},
++ {"ctl13", 13},
++ {"ctl14", 14},
++ {"ctl15", 15},
++ {"ctl16", 16},
++ {"ctl17", 17},
++ {"ctl18", 18},
++ {"ctl19", 19},
++ {"ctl20", 20},
++ {"ctl21", 21},
++ {"ctl22", 22},
++ {"ctl23", 23},
++ {"ctl24", 24},
++ {"ctl25", 25},
++ {"ctl26", 26},
++ {"ctl27", 27},
++ {"ctl28", 28},
++ {"ctl29", 29},
++ {"ctl30", 30},
++ {"ctl31", 31},
++
++ /* alternative names for special control registers */
++ {"ctl0", 0},
++ {"ctl1", 1},
++ {"ctl2", 2},
++ {"ctl3", 3},
++ {"ctl4", 4},
++ {"ctl5", 5},
++ {"ctl8", 8},
++ {"ctl9", 9},
++ {"ctl10", 10},
++ {"ctl11", 11},
++
++ /* coprocessor register names */
++ {"c0", 0},
++ {"c1", 1},
++ {"c2", 2},
++ {"c3", 3},
++ {"c4", 4},
++ {"c5", 5},
++ {"c6", 6},
++ {"c7", 7},
++ {"c8", 8},
++ {"c9", 9},
++ {"c10", 10},
++ {"c11", 11},
++ {"c12", 12},
++ {"c13", 13},
++ {"c14", 14},
++ {"c15", 15},
++ {"c16", 16},
++ {"c17", 17},
++ {"c18", 18},
++ {"c19", 19},
++ {"c20", 20},
++ {"c21", 21},
++ {"c22", 22},
++ {"c23", 23},
++ {"c24", 24},
++ {"c25", 25},
++ {"c26", 26},
++ {"c27", 27},
++ {"c28", 28},
++ {"c29", 29},
++ {"c30", 30},
++ {"c31", 31},
++};
++
++#define NIOS2_NUM_REGS \
++ ((sizeof nios2_builtin_regs) / (sizeof (nios2_builtin_regs[0])))
++const int nios2_num_builtin_regs = NIOS2_NUM_REGS;
++
++/* const removed from the following to allow for dynamic extensions to the
++ * built-in instruction set. */
++struct nios2_reg *nios2_regs = (struct nios2_reg *) nios2_builtin_regs;
++int nios2_num_regs = NIOS2_NUM_REGS;
++#undef NIOS2_NUM_REGS
++
++/* overflow message string templates */
++
++char *overflow_msgs[] = {
++ "call target address 0x%08x out of range 0x%08x to 0x%08x",
++ "branch offset %d out of range %d to %d",
++ "%s offset %d out of range %d to %d",
++ "immediate value %d out of range %d to %d",
++ "immediate value %u out of range %u to %u",
++ "immediate value %u out of range %u to %u",
++ "custom instruction opcode %u out of range %u to %u",
++};
++
++
++
++/*--------------------------------------------------------------------------------
++ This is the opcode table used by the New Jersey GNU as, disassembler and GDB
++ --------------------------------------------------------------------------------*/
++
++/*
++ The following letters can appear in the args field of the nios2_opcode
++ structure:
++
++ c - a 5-bit control register index or break opcode
++ d - a 5-bit destination register index
++ s - a 5-bit left source register index
++ t - a 5-bit right source register index
++ i - a 16-bit signed immediate
++ u - a 16-bit unsigned immediate
++
++ j - a 5-bit unsigned immediate
++ k - a 6-bit unsigned immediate
++ l - an 8-bit unsigned immediate
++ m - a 26-bit unsigned immediate
++*/
++
++/* *INDENT-OFF* */
++/* FIXME: Re-format for GNU standards */
++const struct nios2_opcode nios2_builtin_opcodes[] =
++{
++ /* name, args, args_test num_args, match, mask, pinfo */
++ {"add", "d,s,t", "d,s,t,E", 3, OP_MATCH_ADD, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"addi", "t,s,i", "t,s,i,E", 3, OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_ADDI, signed_immed16_overflow },
++ {"subi", "t,s,i", "t,s,i,E", 3, OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"and", "d,s,t", "d,s,t,E", 3, OP_MATCH_AND, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"andhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ANDHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"andi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ANDI, OP_MASK_IOP, NIOS2_INSN_ANDI, unsigned_immed16_overflow },
++ {"beq", "s,t,o", "s,t,o,E", 3, OP_MATCH_BEQ, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bge", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgeu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgt", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bgtu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"ble", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bleu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"blt", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bltu", "s,t,o", "s,t,o,E", 3, OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"bne", "s,t,o", "s,t,o,E", 3, OP_MATCH_BNE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow },
++ {"br", "o", "o,E", 1, OP_MATCH_BR, OP_MASK_IOP, NIOS2_INSN_UBRANCH, branch_target_overflow },
++ {"break", "b", "b,E", 1, OP_MATCH_BREAK, OP_MASK_BREAK, 0, no_overflow },
++ {"bret", "", "E", 0, OP_MATCH_BRET, OP_MASK, 0, no_overflow },
++ {"flushd", "i(s)", "i(s)E", 2, OP_MATCH_FLUSHD, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"flushda", "i(s)", "i(s)E", 2, OP_MATCH_FLUSHDA, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"flushi", "s", "s,E", 1, OP_MATCH_FLUSHI, OP_MASK_FLUSHI, 0, no_overflow },
++ {"flushp", "", "E", 0, OP_MATCH_FLUSHP, OP_MASK, 0, no_overflow },
++ {"initd", "i(s)", "i(s)E", 2, OP_MATCH_INITD, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"initi", "s", "s,E", 1, OP_MATCH_INITI, OP_MASK_INITI, 0, no_overflow },
++ {"call", "m", "m,E", 1, OP_MATCH_CALL, OP_MASK_IOP, NIOS2_INSN_CALL, call_target_overflow },
++ {"callr", "s", "s,E", 1, OP_MATCH_CALLR, OP_MASK_CALLR, 0, no_overflow },
++ {"cmpeq", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPEQ, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpeqi", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPEQI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpge", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpgei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPGEI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpgeu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpgeui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPGEUI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"cmpgt", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpgti", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPGEI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"cmpgtu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpgtui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPGEUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow },
++ {"cmple", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmplei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPLTI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow },
++ {"cmpleu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow },
++ {"cmpleui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPLTUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow },
++ {"cmplt", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmplti", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPLTI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"cmpltu", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpltui", "t,s,u", "t,s,u,E", 3, OP_MATCH_CMPLTUI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"cmpne", "d,s,t", "d,s,t,E", 3, OP_MATCH_CMPNE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"cmpnei", "t,s,i", "t,s,i,E", 3, OP_MATCH_CMPNEI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"div", "d,s,t", "d,s,t,E", 3, OP_MATCH_DIV, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"divu", "d,s,t", "d,s,t,E", 3, OP_MATCH_DIVU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"jmp", "s", "s,E", 1, OP_MATCH_JMP, OP_MASK_JMP, 0, no_overflow },
++ {"jmpi", "m", "m,E", 1, OP_MATCH_JMPI, OP_MASK_IOP, 0, no_overflow },
++ {"ldb", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDB, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbu", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBU, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldbuio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDBUIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldh", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDH, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhu", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHU, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldhuio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDHUIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldw", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDW, OP_MASK_IOP, 0, address_offset_overflow },
++ {"ldwio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_LDWIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"mov", "d,s", "d,s,E", 2, OP_MATCH_ADD, OP_MASK_RRT|OP_MASK_ROPX|OP_MASK_ROP, NIOS2_INSN_MACRO_MOV, no_overflow },
++ {"movhi", "t,u", "t,u,E", 2, OP_MATCH_ORHI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, unsigned_immed16_overflow },
++ {"movui", "t,u", "t,u,E", 2, OP_MATCH_ORI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, unsigned_immed16_overflow },
++ {"movi", "t,i", "t,i,E", 2, OP_MATCH_ADDI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI, signed_immed16_overflow },
++ /* movia expands to two instructions so there is no mask or match */
++ {"movia", "t,o", "t,o,E", 2, OP_MATCH_ORHI, OP_MASK_IOP, NIOS2_INSN_MACRO_MOVIA, no_overflow },
++ {"mul", "d,s,t", "d,s,t,E", 3, OP_MATCH_MUL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"muli", "t,s,i", "t,s,i,E", 3, OP_MATCH_MULI, OP_MASK_IOP, 0, signed_immed16_overflow },
++ {"mulxss", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXSS, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"mulxsu", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXSU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"mulxuu", "d,s,t", "d,s,t,E", 3, OP_MATCH_MULXUU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"nextpc", "d", "d,E", 1, OP_MATCH_NEXTPC, OP_MASK_NEXTPC, 0, no_overflow },
++ {"nop", "", "E", 0, OP_MATCH_ADD, OP_MASK, NIOS2_INSN_MACRO_MOV, no_overflow },
++ {"nor", "d,s,t", "d,s,t,E", 3, OP_MATCH_NOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"or", "d,s,t", "d,s,t,E", 3, OP_MATCH_OR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"orhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_ORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"ori", "t,s,u", "t,s,u,E", 3, OP_MATCH_ORI, OP_MASK_IOP, NIOS2_INSN_ORI, unsigned_immed16_overflow },
++ {"rdctl", "d,c", "d,c,E", 2, OP_MATCH_RDCTL, OP_MASK_RDCTL, 0, no_overflow },
++ {"ret", "", "E", 0, OP_MATCH_RET, OP_MASK, 0, no_overflow },
++ {"rol", "d,s,t", "d,s,t,E", 3, OP_MATCH_ROL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"roli", "d,s,j", "d,s,j,E", 3, OP_MATCH_ROLI, OP_MASK_ROLI, 0, unsigned_immed5_overflow },
++ {"ror", "d,s,t", "d,s,t,E", 3, OP_MATCH_ROR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"sll", "d,s,t", "d,s,t,E", 3, OP_MATCH_SLL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"slli", "d,s,j", "d,s,j,E", 3, OP_MATCH_SLLI, OP_MASK_SLLI, 0, unsigned_immed5_overflow },
++ {"sra", "d,s,t", "d,s,t,E", 3, OP_MATCH_SRA, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"srai", "d,s,j", "d,s,j,E", 3, OP_MATCH_SRAI, OP_MASK_SRAI, 0, unsigned_immed5_overflow },
++ {"srl", "d,s,t", "d,s,t,E", 3, OP_MATCH_SRL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"srli", "d,s,j", "d,s,j,E", 3, OP_MATCH_SRLI, OP_MASK_SRLI, 0, unsigned_immed5_overflow },
++ {"stb", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STB, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stbio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STBIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sth", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STH, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sthio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STHIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stw", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STW, OP_MASK_IOP, 0, address_offset_overflow },
++ {"stwio", "t,i(s)", "t,i(s)E", 3, OP_MATCH_STWIO, OP_MASK_IOP, 0, address_offset_overflow },
++ {"sub", "d,s,t", "d,s,t,E", 3, OP_MATCH_SUB, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"sync", "", "E", 0, OP_MATCH_SYNC, OP_MASK_SYNC, 0, no_overflow },
++ {"trap", "", "E", 0, OP_MATCH_TRAP, OP_MASK_TRAP, 0, no_overflow },
++ {"eret", "", "E", 0, OP_MATCH_ERET, OP_MASK, 0, no_overflow },
++ {"custom", "l,d,s,t", "l,d,s,t,E", 4, OP_MATCH_CUSTOM, OP_MASK_ROP, 0, custom_opcode_overflow },
++ {"wrctl", "c,s", "c,s,E", 2, OP_MATCH_WRCTL, OP_MASK_WRCTL, 0, no_overflow },
++ {"xor", "d,s,t", "d,s,t,E", 3, OP_MATCH_XOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow },
++ {"xorhi", "t,s,u", "t,s,u,E", 3, OP_MATCH_XORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow },
++ {"xori", "t,s,u", "t,s,u,E", 3, OP_MATCH_XORI, OP_MASK_IOP, NIOS2_INSN_XORI, unsigned_immed16_overflow }
++};
++/* *INDENT-ON* */
++
++#define NIOS2_NUM_OPCODES \
++ ((sizeof nios2_builtin_opcodes) / (sizeof (nios2_builtin_opcodes[0])))
++const int bfd_nios2_num_builtin_opcodes = NIOS2_NUM_OPCODES;
++
++/* const removed from the following to allow for dynamic extensions to the
++ * built-in instruction set. */
++struct nios2_opcode *nios2_opcodes =
++ (struct nios2_opcode *) nios2_builtin_opcodes;
++int bfd_nios2_num_opcodes = NIOS2_NUM_OPCODES;
++#undef NIOS2_NUM_OPCODES
diff --git a/cleopatre/buildroot/toolchain/gdb/6.7.1/600-fix-compile-flag-mismatch.patch b/cleopatre/buildroot/toolchain/gdb/6.7.1/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000000..13b72bb96d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.7.1/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,31 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -272,7 +272,7 @@
+ PACKAGE_BUGREPORT=
+
+ ac_unique_file="main.c"
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ # Factoring default headers for most tests.
+ ac_includes_default="\
+ #include <stdio.h>
+@@ -3077,7 +3077,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
diff --git a/cleopatre/buildroot/toolchain/gdb/6.8/600-fix-compile-flag-mismatch.patch b/cleopatre/buildroot/toolchain/gdb/6.8/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000000..13b72bb96d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/6.8/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,31 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -272,7 +272,7 @@
+ PACKAGE_BUGREPORT=
+
+ ac_unique_file="main.c"
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ # Factoring default headers for most tests.
+ ac_includes_default="\
+ #include <stdio.h>
+@@ -3077,7 +3077,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
diff --git a/cleopatre/buildroot/toolchain/gdb/Config.in b/cleopatre/buildroot/toolchain/gdb/Config.in
new file mode 100644
index 0000000000..ffa437168c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/Config.in
@@ -0,0 +1,70 @@
+comment "Gdb Options"
+
+config BR2_PACKAGE_GDB
+ bool "Build gdb debugger for the Target"
+ select BR2_PACKAGE_NCURSES
+ help
+ Build the full gdb debugger to run on the target.
+
+config BR2_PACKAGE_GDB_SERVER
+ bool "Build gdb server for the Target"
+ help
+ Build the gdbserver stub to run on the target.
+ A full gdb is needed to debug the progam.
+
+config BR2_PACKAGE_GDB_HOST
+ bool "Build gdb for the Host"
+ help
+ Build gdb to run on the host to debug programs run on the target.
+
+choice
+ prompt "GDB debugger Version"
+ default BR2_GDB_VERSION_6_6 if !BR2_avr32
+ default BR2_GDB_VERSION_6_7_1 if BR2_avr32
+ depends on BR2_PACKAGE_GDB || BR2_PACKAGE_GDB_SERVER || BR2_PACKAGE_GDB_HOST
+ help
+ Select the version of gdb you wish to use.
+
+ config BR2_GDB_VERSION_6_2_1
+ bool "gdb 6.2.1"
+ depends on !BR2_avr32 && !BR2_nios2
+
+ config BR2_GDB_VERSION_6_3
+ bool "gdb 6.3"
+ depends on !BR2_avr32 && !BR2_nios2
+
+ config BR2_GDB_VERSION_6_4
+ bool "gdb 6.4"
+ depends on !BR2_nios2
+
+ config BR2_GDB_VERSION_6_5
+ bool "gdb 6.5"
+ depends on !BR2_avr32 && !BR2_nios2
+
+ config BR2_GDB_VERSION_6_6
+ bool "gdb 6.6"
+ depends on !BR2_avr32
+
+ config BR2_GDB_VERSION_6_7_1
+ bool "gdb 6.7.1"
+
+ config BR2_GDB_VERSION_6_8
+ bool "gdb 6.8"
+ depends on !BR2_avr32
+
+ config BR2_GDB_VERSION_SNAPSHOT
+ bool "gdb snapshot"
+ depends on !BR2_avr32 && !BR2_nios2
+
+endchoice
+
+config BR2_GDB_VERSION
+ string
+ default "6.2.1" if BR2_GDB_VERSION_6_2_1
+ default "6.3" if BR2_GDB_VERSION_6_3
+ default "6.4" if BR2_GDB_VERSION_6_4
+ default "6.5" if BR2_GDB_VERSION_6_5
+ default "6.6" if BR2_GDB_VERSION_6_6
+ default "6.7.1" if BR2_GDB_VERSION_6_7_1
+ default "6.8" if BR2_GDB_VERSION_6_8
+ default "snapshot" if BR2_GDB_VERSION_SNAPSHOT
diff --git a/cleopatre/buildroot/toolchain/gdb/Config.in.2 b/cleopatre/buildroot/toolchain/gdb/Config.in.2
new file mode 100644
index 0000000000..6eafa60791
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/Config.in.2
@@ -0,0 +1,54 @@
+# Keep this in sync with Config.in
+# Why don't you use Config.in in the first place?
+
+comment "Gdb Options"
+
+config BR2_PACKAGE_GDB
+ bool "Build gdb debugger for the Target"
+ select BR2_PACKAGE_NCURSES
+ help
+ Build the full gdb debugger to run on the target.
+
+config BR2_PACKAGE_GDB_SERVER
+ bool "Build gdb server for the Target"
+ help
+ Build the gdbserver stub to run on the target.
+ A full gdb is needed to debug the progam.
+
+config BR2_PACKAGE_GDB_HOST
+ bool "Build gdb for the Host"
+ help
+ Build gdb to run on the host to debug programs run on the target.
+
+choice
+ prompt "GDB debugger Version"
+ default BR2_GDB_VERSION_6_3
+ depends on BR2_PACKAGE_GDB || BR2_PACKAGE_GDB_SERVER || BR2_PACKAGE_GDB_HOST
+ help
+ Select the version of gdb you wish to use.
+
+ config BR2_EXT_GDB_VERSION_6_2_1
+ bool "gdb 6.2.1"
+
+ config BR2_EXT_GDB_VERSION_6_3
+ bool "gdb 6.3"
+
+ config BR2_EXT_GDB_VERSION_6_4
+ bool "gdb 6.4"
+
+ config BR2_EXT_GDB_VERSION_6_5
+ bool "gdb 6.5"
+
+ config BR2_EXT_GDB_VERSION_SNAPSHOT
+ bool "gdb snapshot"
+
+endchoice
+
+config BR2_EXT_GDB_VERSION
+ string
+ default "6.2.1" if BR2_EXT_GDB_VERSION_6_2_1
+ default "6.3" if BR2_EXT_GDB_VERSION_6_3
+ default "6.4" if BR2_EXT_GDB_VERSION_6_4
+ default "6.5" if BR2_EXT_GDB_VERSION_6_5
+ default "6.6" if BR2_EXT_GDB_VERSION_6_6
+ default "snapshot" if BR2_EXT_GDB_VERSION_SNAPSHOT
diff --git a/cleopatre/buildroot/toolchain/gdb/gdb.mk b/cleopatre/buildroot/toolchain/gdb/gdb.mk
new file mode 100644
index 0000000000..6220cd9cbd
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/gdb.mk
@@ -0,0 +1,255 @@
+######################################################################
+#
+# gdb
+#
+######################################################################
+ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
+GDB_VERSION:=$(strip $(subst ",, $(BR2_GDB_VERSION)))
+#"))
+else
+GDB_VERSION:=$(strip $(subst ",, $(BR2_EXT_GDB_VERSION)))
+#"))
+endif
+
+ifeq ($(GDB_VERSION),snapshot)
+# Be aware that this changes daily....
+GDB_SITE:=ftp://sources.redhat.com/pub/gdb/snapshots/current
+GDB_SOURCE:=gdb.tar.bz2
+GDB_CAT:=$(BZCAT)
+GDB_DIR:=$(TOOL_BUILD_DIR)/gdb-$(GDB_VERSION)
+GDB_PATCH_DIR:=toolchain/gdb/$(GDB_VERSION)
+else
+
+GDB_OFFICIAL_VERSION:=$(GDB_VERSION)$(VENDOR_SUFFIX)$(VENDOR_GDB_RELEASE)
+
+GDB_SOURCE:=gdb-$(GDB_OFFICIAL_VERSION).tar.bz2
+GDB_CAT:=$(BZCAT)
+
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_SOURCE),y)
+GDB_SITE:=$(VENDOR_SITE)
+GDB_PATCH_DIR:=toolchain/gdb/ext_source/$(VENDOR_PATCH_DIR)/$(GDB_OFFICIAL_VERSION)
+else
+GDB_SITE:=$(BR2_GNU_MIRROR)/gdb
+GDB_PATCH_DIR:=toolchain/gdb/$(GDB_OFFICIAL_VERSION)
+endif
+
+GDB_DIR:=$(TOOL_BUILD_DIR)/gdb-$(GDB_OFFICIAL_VERSION)
+
+# NOTE: This option should not be used with gdb versions 6.4 and above.
+ifeq ($(GDB_VERSION),6.2.1)
+DISABLE_GDBMI:=--disable-gdbmi
+endif
+
+ifeq ($(GDB_VERSION),6.3)
+DISABLE_GDBMI:=--disable-gdbmi
+endif
+endif
+
+$(DL_DIR)/$(GDB_SOURCE):
+ $(WGET) -P $(DL_DIR) $(GDB_SITE)/$(GDB_SOURCE)
+
+gdb-unpacked: $(GDB_DIR)/.unpacked
+$(GDB_DIR)/.unpacked: $(DL_DIR)/$(GDB_SOURCE)
+ mkdir -p $(TOOL_BUILD_DIR)
+ $(GDB_CAT) $(DL_DIR)/$(GDB_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ifeq ($(GDB_VERSION),snapshot)
+ GDB_REAL_DIR=$(shell \
+ tar jtf $(DL_DIR)/$(GDB_SOURCE) | head -1 | cut -d"/" -f1)
+ ln -sf $(TOOL_BUILD_DIR)/$(shell tar jtf $(DL_DIR)/$(GDB_SOURCE) | head -1 | cut -d"/" -f1) $(GDB_DIR)
+endif
+ toolchain/patch-kernel.sh $(GDB_DIR) $(GDB_PATCH_DIR) \*.patch
+ $(CONFIG_UPDATE) $(GDB_DIR)
+ touch $@
+
+gdb-patched: $(GDB_DIR)/.unpacked
+$(GDB_DIR)/.patched: $(GDB_DIR)/.unpacked
+ toolchain/patch-kernel.sh $(GDB_DIR) $(GDB_PATCH_DIR) \*.patch
+ $(CONFIG_UPDATE) $(GDB_DIR)
+ touch $@
+
+gdb-dirclean:
+ rm -rf $(GDB_DIR)
+
+######################################################################
+#
+# gdb target
+#
+######################################################################
+
+GDB_TARGET_DIR:=$(BUILD_DIR)/gdb-$(GDB_VERSION)-target
+
+GDB_TARGET_CONFIGURE_VARS:= \
+ ac_cv_type_uintptr_t=yes \
+ gt_cv_func_gettext_libintl=yes \
+ ac_cv_func_dcgettext=yes \
+ gdb_cv_func_sigsetjmp=yes \
+ bash_cv_func_strcoll_broken=no \
+ bash_cv_must_reinstall_sighandlers=no \
+ bash_cv_func_sigsetjmp=present \
+ bash_cv_have_mbstate_t=yes
+
+$(GDB_TARGET_DIR)/.configured: $(GDB_DIR)/.patched
+ mkdir -p $(GDB_TARGET_DIR)
+ (cd $(GDB_TARGET_DIR); \
+ gdb_cv_func_sigsetjmp=yes \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS_FOR_TARGET="$(TARGET_CFLAGS) $(TARGET_LDFLAGS) -Wno-error" \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_LDFLAGS) -Wno-error" \
+ $(GDB_TARGET_CONFIGURE_VARS) \
+ $(GDB_DIR)/configure \
+ --cache-file=/dev/null \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --prefix=/usr \
+ $(DISABLE_NLS) \
+ --without-uiout $(DISABLE_GDBMI) \
+ --disable-tui --disable-gdbtk --without-x \
+ --disable-sim --enable-gdbserver \
+ --without-included-gettext \
+ --disable-werror \
+ )
+ifeq ($(BR2_ENABLE_LOCALE),y)
+ -$(SED) "s,^INTL *=.*,INTL = -lintl,g;" $(GDB_DIR)/gdb/Makefile
+endif
+ touch $@
+
+$(GDB_TARGET_DIR)/gdb/gdb: $(GDB_TARGET_DIR)/.configured
+ $(MAKE) CC=$(TARGET_CC) MT_CFLAGS="$(TARGET_CFLAGS)" \
+ -C $(GDB_TARGET_DIR)
+ $(STRIPCMD) $(GDB_TARGET_DIR)/gdb/gdb
+
+$(TARGET_DIR)/usr/bin/gdb: $(GDB_TARGET_DIR)/gdb/gdb
+ install -c -D $(GDB_TARGET_DIR)/gdb/gdb $(TARGET_DIR)/usr/bin/gdb
+
+gdb_target: ncurses $(TARGET_DIR)/usr/bin/gdb
+
+gdb_target-source: $(DL_DIR)/$(GDB_SOURCE)
+
+gdb_target-clean:
+ -$(MAKE) -C $(GDB_DIR) clean
+
+gdb_target-dirclean:
+ rm -rf $(GDB_DIR)
+
+######################################################################
+#
+# gdbserver
+#
+######################################################################
+
+GDB_SERVER_DIR:=$(BUILD_DIR)/gdbserver-$(GDB_VERSION)
+
+$(GDB_SERVER_DIR)/.configured: $(GDB_DIR)/.unpacked
+ mkdir -p $(GDB_SERVER_DIR)
+ (cd $(GDB_SERVER_DIR); \
+ $(TARGET_CONFIGURE_OPTS) \
+ gdb_cv_func_sigsetjmp=yes \
+ bash_cv_have_mbstate_t=yes \
+ $(GDB_DIR)/gdb/gdbserver/configure \
+ --cache-file=/dev/null \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc \
+ --datadir=/usr/share \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ --includedir=$(STAGING_DIR)/usr/include \
+ $(DISABLE_NLS) \
+ --without-uiout $(DISABLE_GDBMI) \
+ --disable-tui --disable-gdbtk --without-x \
+ --without-included-gettext \
+ )
+ touch $@
+
+$(GDB_SERVER_DIR)/gdbserver: $(GDB_SERVER_DIR)/.configured
+ $(MAKE) CC=$(TARGET_CC) MT_CFLAGS="$(TARGET_CFLAGS)" \
+ -C $(GDB_SERVER_DIR)
+ $(STRIPCMD) $(GDB_SERVER_DIR)/gdbserver
+
+$(TARGET_DIR)/usr/bin/gdbserver: $(GDB_SERVER_DIR)/gdbserver
+ifeq ($(strip $(BR2_CROSS_TOOLCHAIN_TARGET_UTILS)),y)
+ mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/target_utils
+ install -c $(GDB_SERVER_DIR)/gdbserver \
+ $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/target_utils/gdbserver
+endif
+ install -c -D $(GDB_SERVER_DIR)/gdbserver $(TARGET_DIR)/usr/bin/gdbserver
+
+gdbserver: $(TARGET_DIR)/usr/bin/gdbserver
+
+gdbserver-clean:
+ -$(MAKE) -C $(GDB_SERVER_DIR) clean
+
+gdbserver-dirclean:
+ rm -rf $(GDB_SERVER_DIR)
+
+######################################################################
+#
+# gdb on host
+#
+######################################################################
+
+GDB_HOST_DIR:=$(TOOL_BUILD_DIR)/gdbhost-$(GDB_VERSION)
+
+$(GDB_HOST_DIR)/.configured: $(GDB_DIR)/.unpacked
+ mkdir -p $(GDB_HOST_DIR)
+ (cd $(GDB_HOST_DIR); \
+ gdb_cv_func_sigsetjmp=yes \
+ bash_cv_have_mbstate_t=yes \
+ $(GDB_DIR)/configure \
+ --cache-file=/dev/null \
+ --prefix=$(STAGING_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ $(DISABLE_NLS) \
+ --without-uiout $(DISABLE_GDBMI) \
+ --disable-tui --disable-gdbtk --without-x \
+ --without-included-gettext \
+ --enable-threads \
+ --disable-werror \
+ )
+ touch $@
+
+$(GDB_HOST_DIR)/gdb/gdb: $(GDB_HOST_DIR)/.configured
+ $(MAKE) -C $(GDB_HOST_DIR)
+ strip $(GDB_HOST_DIR)/gdb/gdb
+
+$(TARGET_CROSS)gdb: $(GDB_HOST_DIR)/gdb/gdb
+ install -c $(GDB_HOST_DIR)/gdb/gdb $(TARGET_CROSS)gdb
+ ln -snf ../../bin/$(REAL_GNU_TARGET_NAME)-gdb \
+ $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/gdb
+ ln -snf $(REAL_GNU_TARGET_NAME)-gdb \
+ $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-gdb
+
+gdbhost: $(TARGET_CROSS)gdb
+
+gdbhost-clean:
+ -$(MAKE) -C $(GDB_HOST_DIR) clean
+
+gdbhost-dirclean:
+ rm -rf $(GDB_HOST_DIR)
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+ifeq ($(strip $(BR2_PACKAGE_GDB)),y)
+TARGETS+=gdb_target
+endif
+
+ifeq ($(strip $(BR2_PACKAGE_GDB_SERVER)),y)
+TARGETS+=gdbserver
+endif
+
+ifeq ($(strip $(BR2_PACKAGE_GDB_HOST)),y)
+TARGETS+=gdbhost
+endif
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/100-uclibc-conf.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/100-uclibc-conf.patch
new file mode 100644
index 0000000000..d86e2875dd
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/100-uclibc-conf.patch
@@ -0,0 +1,94 @@
+diff -urN gdb-6.3.50.20050915/bfd/config.bfd gdb-6.3.50.20050915-patched/bfd/config.bfd
+--- gdb-6.3.50.20050915/bfd/config.bfd 2005-08-30 11:06:00.000000000 -0500
++++ gdb-6.3.50.20050915-patched/bfd/config.bfd 2005-09-15 20:08:49.000000000 -0500
+@@ -725,7 +725,7 @@
+ targ_defvec=hp300hpux_vec
+ targ_underscore=yes
+ ;;
+- m68*-*-linux*aout*)
++ m68*-*-linux*aout* | m68*-*-linux-uclibc*)
+ targ_defvec=m68klinux_vec
+ targ_selvecs=bfd_elf32_m68k_vec
+ targ_underscore=yes
+diff -urN gdb-6.3.50.20050915/bfd/configure gdb-6.3.50.20050915-patched/bfd/configure
+--- gdb-6.3.50.20050915/bfd/configure 2005-08-26 04:47:43.000000000 -0500
++++ gdb-6.3.50.20050915-patched/bfd/configure 2005-09-15 20:09:54.000000000 -0500
+@@ -3585,6 +3585,11 @@
+ lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ netbsd* | knetbsd*-gnu)
+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+diff -urN gdb-6.3.50.20050915/libtool.m4 gdb-6.3.50.20050915-patched/libtool.m4
+--- gdb-6.3.50.20050915/libtool.m4 2005-07-15 21:36:38.000000000 -0500
++++ gdb-6.3.50.20050915-patched/libtool.m4 2005-09-15 20:13:33.000000000 -0500
+@@ -653,6 +653,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
+ lt_cv_file_magic_cmd=/usr/bin/file
+diff -urN gdb-6.3.50.20050915/ltconfig gdb-6.3.50.20050915-patched/ltconfig
+--- gdb-6.3.50.20050915/ltconfig 2005-07-15 21:36:38.000000000 -0500
++++ gdb-6.3.50.20050915-patched/ltconfig 2005-09-15 21:23:35.000000000 -0500
+@@ -602,7 +602,7 @@
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1270,6 +1270,24 @@
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
++linux-uclibc*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
++ soname_spec='${libname}${release}.so$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ # Note: copied from linux-gnu, and may not be appropriate.
++ hardcode_into_libs=yes
++ # Assume using the uClibc dynamic linker.
++ dynamic_linker="uClibc ld.so"
++ ;;
++
+ netbsd*)
+ need_lib_prefix=no
+ need_version=no
+diff -urN gdb-6.3.50.20050915/opcodes/configure gdb-6.3.50.20050915-patched/opcodes/configure
+--- gdb-6.3.50.20050915/opcodes/configure 2005-08-17 22:49:00.000000000 -0500
++++ gdb-6.3.50.20050915-patched/opcodes/configure 2005-09-15 21:22:20.000000000 -0500
+@@ -3596,6 +3596,11 @@
+ fi
+ ;;
+
++linux-uclibc*)
++ lt_cv_deplibs_check_method=pass_all
++ lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
++ ;;
++
+ newsos6)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/200-uclibc-readline-conf.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/200-uclibc-readline-conf.patch
new file mode 100644
index 0000000000..288161ee5e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/200-uclibc-readline-conf.patch
@@ -0,0 +1,16 @@
+diff -urN gdb-6.3.50.20050915/readline/configure gdb-6.3.50.20050915-patched/readline/configure
+--- gdb-6.3.50.20050915/readline/configure 2005-07-03 03:22:47.000000000 -0500
++++ gdb-6.3.50.20050915-patched/readline/configure 2005-09-15 22:25:00.000000000 -0500
+@@ -6723,7 +6723,12 @@
+
+
+ echo "$as_me:$LINENO: checking for mbstate_t" >&5
++echo $ECHO_N "bash_cv_have_mbstate_t=$bash_cv_have_mbstate_t" >&6
+ echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
++if test "${bash_cv_have_mbstate_t+set}" != set; then
++ bash_cv_have_mbstate_t=yes
++ echo $ECHO_N "WARNING!! forcing to yes!!! $ECHO_C" >&6
++fi
+ if test "${bash_cv_have_mbstate_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-coredump.patch-2.4.23-29 b/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-coredump.patch-2.4.23-29
new file mode 100644
index 0000000000..b7136bf8a2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-coredump.patch-2.4.23-29
@@ -0,0 +1,30 @@
+Sometime around 2.4.22-23, the mips pt_regs.h fields were reordered, breaking
+coredump handling by gdb for current kernels. Update the hardcoded constants
+to reflect the change.
+--
+diff -urN gdb-6.3.50.20050915/gdb/mips-linux-tdep.c gdb-6.3.50.20050915-patched/gdb/mips-linux-tdep.c
+--- gdb-6.3.50.20050915/gdb/mips-linux-tdep.c 2005-04-02 16:59:34.000000000 -0600
++++ gdb-6.3.50.20050915-patched/gdb/mips-linux-tdep.c 2005-09-15 22:33:13.000000000 -0500
+@@ -54,12 +54,22 @@
+
+ #define EF_REG0 6
+ #define EF_REG31 37
++
++#if 0
+ #define EF_LO 38
+ #define EF_HI 39
+ #define EF_CP0_EPC 40
+ #define EF_CP0_BADVADDR 41
+ #define EF_CP0_STATUS 42
+ #define EF_CP0_CAUSE 43
++#else
++#define EF_CP0_STATUS 38
++#define EF_LO 39
++#define EF_HI 40
++#define EF_CP0_BADVADDR 41
++#define EF_CP0_CAUSE 42
++#define EF_CP0_EPC 43
++#endif
+
+ #define EF_SIZE 180
+
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-nptl-support.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-nptl-support.patch
new file mode 100644
index 0000000000..50be6ac410
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/400-mips-nptl-support.patch
@@ -0,0 +1,143 @@
+2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * linux-mips-low.c: Include "gdb_proc_service.h".
+ (PTRACE_GET_THREAD_AREA): Define.
+ (ps_get_thread_area): New function.
+ * Makefile.in: Update dependencies for linux-mips-low.o,
+ linux-i386-low.o, and linux-x86-64-low.o.
+
+2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * linux-mips-low.c: Include "gdb_proc_service.h".
+ (PTRACE_GET_THREAD_AREA): Define.
+ (ps_get_thread_area): New function.
+ * Makefile.in (mips-linux-nat.o): Update dependencies.
+--
+diff -urN gdb-6.3.50.20050915/gdb/Makefile.in gdb-6.3.50.20050915-patched/gdb/Makefile.in
+--- gdb-6.3.50.20050915/gdb/Makefile.in 2005-09-10 13:11:01.000000000 -0500
++++ gdb-6.3.50.20050915-patched/gdb/Makefile.in 2005-09-15 19:24:39.000000000 -0500
+@@ -2282,7 +2282,7 @@
+ $(gdb_string_h) $(mips_tdep_h) $(solib_svr4_h)
+ mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h)
+ mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) $(target_h) \
+- $(linux_nat_h)
++ $(linux_nat_h) $(gdb_proc_service_h)
+ mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \
+ $(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \
+ $(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \
+diff -urN gdb-6.3.50.20050915/gdb/gdbserver/Makefile.in gdb-6.3.50.20050915-patched/gdb/gdbserver/Makefile.in
+--- gdb-6.3.50.20050915/gdb/gdbserver/Makefile.in 2005-05-28 17:09:04.000000000 -0500
++++ gdb-6.3.50.20050915-patched/gdb/gdbserver/Makefile.in 2005-09-15 19:20:01.000000000 -0500
+@@ -267,15 +267,18 @@
+ linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h)
+ linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h)
+ linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h)
+-linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h)
++linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) \
++ $(gdb_proc_service_h)
+ linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)
+ linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h)
+-linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h)
++linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \
++ $(gdb_proc_service_h)
+ linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)
+ linux-ppc64-low.o: linux-ppc64-low.c $(linux_low_h) $(server_h)
+ linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
+ linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
+-linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h)
++linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) \
++ $(gdb_proc_service_h)
+
+ reg-arm.o : reg-arm.c $(regdef_h)
+ reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
+diff -urN gdb-6.3.50.20050915/gdb/gdbserver/linux-mips-low.c gdb-6.3.50.20050915-patched/gdb/gdbserver/linux-mips-low.c
+--- gdb-6.3.50.20050915/gdb/gdbserver/linux-mips-low.c 2005-06-12 20:59:22.000000000 -0500
++++ gdb-6.3.50.20050915-patched/gdb/gdbserver/linux-mips-low.c 2005-09-15 19:16:54.000000000 -0500
+@@ -22,6 +22,26 @@
+ #include "server.h"
+ #include "linux-low.h"
+
++#include <sys/ptrace.h>
++
++/* Correct for all GNU/Linux targets (for quite some time). */
++#define GDB_GREGSET_T elf_gregset_t
++#define GDB_FPREGSET_T elf_fpregset_t
++
++#ifndef HAVE_ELF_FPREGSET_T
++/* Make sure we have said types. Not all platforms bring in <linux/elf.h>
++ via <sys/procfs.h>. */
++#ifdef HAVE_LINUX_ELF_H
++#include <linux/elf.h>
++#endif
++#endif
++
++#include "../gdb_proc_service.h"
++
++#ifndef PTRACE_GET_THREAD_AREA
++#define PTRACE_GET_THREAD_AREA 25
++#endif
++
+ #ifdef HAVE_SYS_REG_H
+ #include <sys/reg.h>
+ #endif
+@@ -140,6 +160,23 @@
+ return 0;
+ }
+
++/* Fetch the thread-local storage pointer for libthread_db. */
++
++ps_err_e
++ps_get_thread_area (const struct ps_prochandle *ph,
++ lwpid_t lwpid, int idx, void **base)
++{
++ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
++ return PS_ERR;
++
++ /* IDX is the bias from the thread pointer to the beginning of the
++ thread descriptor. It has to be subtracted due to implementation
++ quirks in libthread_db. */
++ *base = (void *) ((char *)*base - idx);
++
++ return PS_OK;
++}
++
+ struct linux_target_ops the_low_target = {
+ mips_num_regs,
+ mips_regmap,
+diff -urN gdb-6.3.50.20050915/gdb/mips-linux-nat.c gdb-6.3.50.20050915-patched/gdb/mips-linux-nat.c
+--- gdb-6.3.50.20050915/gdb/mips-linux-nat.c 2005-09-10 13:11:04.000000000 -0500
++++ gdb-6.3.50.20050915-patched/gdb/mips-linux-nat.c 2005-09-15 19:16:54.000000000 -0500
+@@ -24,6 +24,12 @@
+ #include "target.h"
+ #include "linux-nat.h"
+
++#include "gdb_proc_service.h"
++
++#ifndef PTRACE_GET_THREAD_AREA
++#define PTRACE_GET_THREAD_AREA 25
++#endif
++
+ /* Pseudo registers can not be read. ptrace does not provide a way to
+ read (or set) MIPS_PS_REGNUM, and there's no point in reading or
+ setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
+@@ -72,3 +78,20 @@
+ {
+ add_target (linux_target ());
+ }
++
++/* Fetch the thread-local storage pointer for libthread_db. */
++
++ps_err_e
++ps_get_thread_area (const struct ps_prochandle *ph,
++ lwpid_t lwpid, int idx, void **base)
++{
++ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
++ return PS_ERR;
++
++ /* IDX is the bias from the thread pointer to the beginning of the
++ thread descriptor. It has to be subtracted due to implementation
++ quirks in libthread_db. */
++ *base = (void *) ((char *)*base - idx);
++
++ return PS_OK;
++}
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/500-thread-timeout.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/500-thread-timeout.patch
new file mode 100644
index 0000000000..6db0a7a474
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/500-thread-timeout.patch
@@ -0,0 +1,34 @@
+--- gdb-6.3.org/gdb/gdbserver/thread-db.c 2004-10-17 02:42:00.000000000 +0900
++++ gdb-6.3/gdb/gdbserver/thread-db.c 2005-01-27 12:19:29.000000000 +0900
+@@ -21,6 +21,7 @@
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
++#include <unistd.h>
+ #include "server.h"
+
+ #include "linux-low.h"
+@@ -142,6 +143,7 @@
+ td_event_msg_t msg;
+ td_err_e err;
+ struct inferior_linux_data *tdata;
++ int timeout;
+
+ if (debug_threads)
+ fprintf (stderr, "Thread creation event.\n");
+@@ -152,7 +154,13 @@
+ In the LinuxThreads implementation, this is safe,
+ because all events come from the manager thread
+ (except for its own creation, of course). */
+- err = td_ta_event_getmsg (thread_agent, &msg);
++ for (timeout = 0; timeout < 50000; timeout++)
++ {
++ err = td_ta_event_getmsg (thread_agent, &msg);
++ if (err != TD_NOMSG)
++ break;
++ usleep(1000);
++ }
+ if (err != TD_OK)
+ fprintf (stderr, "thread getmsg err: %s\n",
+ thread_db_err_str (err));
+
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/680-debian_sim-destdir.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/680-debian_sim-destdir.patch
new file mode 100644
index 0000000000..1663f5505d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/680-debian_sim-destdir.patch
@@ -0,0 +1,14 @@
+Fix some missing uses of DESTDIR in the sim/ directories. The Debian
+packages use DESTDIR to build.
+--
+diff -ur gdb-6.3.50.20050915/sim/Makefile.in gdb-6.3.50.20050915-patched/sim/Makefile.in
+--- gdb-6.3.50.20050915/sim/Makefile.in 2005-01-28 18:53:13.000000000 -0600
++++ gdb-6.3.50.20050915-patched/sim/Makefile.in 2005-09-15 23:17:42.000000000 -0500
+@@ -93,6 +93,7 @@
+ "CC=$(CC)" \
+ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
+ "CFLAGS=$(CFLAGS)" \
++ "DESTDIR=$(DESTDIR)" \
+ "CHILLFLAGS=$(CHILLFLAGS)" \
+ "CHILL=$(CHILL_FOR_TARGET)" \
+ "CHILL_FOR_TARGET=$(CHILL_FOR_TARGET)" \
diff --git a/cleopatre/buildroot/toolchain/gdb/snapshot/690-debian_member-field-symtab.patch b/cleopatre/buildroot/toolchain/gdb/snapshot/690-debian_member-field-symtab.patch
new file mode 100644
index 0000000000..54d43ad64d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/gdb/snapshot/690-debian_member-field-symtab.patch
@@ -0,0 +1,20 @@
+Status: unsubmitted
+
+This patch was for Debian bug #239535. It needs to be tested, and
+submitted.
+--
+diff -ur gdb-6.3.50.20050915/gdb/valops.c gdb-6.3.50.20050915-patched/gdb/valops.c
+--- gdb-6.3.50.20050915/gdb/valops.c 2005-05-26 23:39:32.000000000 -0500
++++ gdb-6.3.50.20050915-patched/gdb/valops.c 2005-09-15 23:21:49.000000000 -0500
+@@ -2256,8 +2256,10 @@
+ return 1;
+ }
+
++ /* Check each baseclass. Call check_typedef, which will follow typedefs
++ and do opaque/stub type resolution. */
+ for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
+- if (check_field_in (TYPE_BASECLASS (type, i), name))
++ if (check_field_in (check_typedef (TYPE_BASECLASS (type, i)), name))
+ return 1;
+
+ return 0;
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/Config.in b/cleopatre/buildroot/toolchain/kernel-headers/Config.in
new file mode 100644
index 0000000000..c512ae22bb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/Config.in
@@ -0,0 +1,138 @@
+# Choose the kernel headers to use for kernel-headers target. This is
+# ignored if you are building your own kernel or using the system kernel.
+#
+
+comment "Kernel Header Options"
+
+choice
+ prompt "Kernel Headers"
+ default BR2_KERNEL_HEADERS_2_6_25
+
+ help
+ Select the version of kernel header files you wish to use.
+ You must select the correct set of header files to match
+ the kernel you intend to use on your target system.
+
+ For the snapshot, you have to provide the
+ linux-2.6.tar.bz2 tarball in your download dir.
+
+ config BR2_KERNEL_HEADERS_2_4_25
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.4.25 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_4_27
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.4.27 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_4_29
+ depends on !BR2_avr32 && !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.4.29 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_4_31
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.4.31 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_9
+ depends on !BR2_avr32 && BR2_DEPRECATED
+ bool "Linux 2.6.9 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_11
+ depends on !BR2_avr32 && BR2_DEPRECATED
+ bool "Linux 2.6.11 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_12
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.12 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_20_4
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.20.4 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_20
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.20.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_21_5
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.21.5 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_21
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.21.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_22_1
+ depends on !BR2_avr32 && !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.22.1 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_22_10
+ depends on !BR2_nios2 && BR2_DEPRECATED
+ bool "Linux 2.6.22.10 kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_22
+ depends on BR2_DEPRECATED
+ bool "Linux 2.6.22.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_23
+ depends on BR2_DEPRECATED
+ bool "Linux 2.6.23.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_24
+ depends on BR2_RECENT
+ bool "Linux 2.6.24.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_2_6_25
+ bool "Linux 2.6.25.x kernel headers"
+
+ config BR2_KERNEL_HEADERS_SNAP
+ bool "Linux 2.6 snapshot"
+
+endchoice
+
+config BR2_KERNEL_HEADERS_IPMI
+ bool "use ipmi kernel patches"
+ depends on BR2_KERNEL_HEADERS_2_6_20_4 || BR2_KERNEL_HEADERS_2_6_21_5 || BR2_KERNEL_HEADERS_2_6_22_1
+ help
+ Apply patches which add IPMI sensor support.
+
+config BR2_KERNEL_HEADERS_LZMA
+ bool "use lzma initramfs kernel patches"
+ depends on BR2_KERNEL_HEADERS_2_6_21_5 || BR2_KERNEL_HEADERS_2_6_22_1
+ help
+ Apply patches which allow for lzma compressed
+ initramfs filesystems. This requires the lzma
+ program in your development environment.
+
+config BR2_KERNEL_HEADERS_RT
+ bool "use realtime (-rt) kernel patches"
+ depends on BR2_KERNEL_HEADERS_2_6_21_5 || BR2_KERNEL_HEADERS_2_6_22_1
+ help
+ Apply Ingo's realtime extensions to linux
+
+config BR2_KERNEL_HEADERS_PATCH_DIR
+ bool "Add additional headers from $(KERNEL_HEADERS_PATCH_DIR)"
+ depends on BR2_KERNEL_HEADERS_2_6_20_4 || BR2_KERNEL_HEADERS_2_6_21_5 || BR2_KERNEL_HEADERS_2_6_22_1 || BR2_KERNEL_HEADERS_2_6_22_10
+ help
+ Apply additional kernel patches defined by KERNEL_HEADERS_PATCH_DIR
+ in your board directory.
+
+config BR2_DEFAULT_KERNEL_HEADERS
+ string
+ default "2.4.25" if BR2_KERNEL_HEADERS_2_4_25
+ default "2.4.27" if BR2_KERNEL_HEADERS_2_4_27
+ default "2.4.29" if BR2_KERNEL_HEADERS_2_4_29
+ default "2.4.31" if BR2_KERNEL_HEADERS_2_4_31
+ default "2.6.9" if BR2_KERNEL_HEADERS_2_6_9
+ default "2.6.11" if BR2_KERNEL_HEADERS_2_6_11
+ default "2.6.12" if BR2_KERNEL_HEADERS_2_6_12
+ default "2.6.20.4" if BR2_KERNEL_HEADERS_2_6_20_4
+ default "2.6.20.20" if BR2_KERNEL_HEADERS_2_6_20
+ default "2.6.21.5" if BR2_KERNEL_HEADERS_2_6_21_5
+ default "2.6.21.7" if BR2_KERNEL_HEADERS_2_6_21
+ default "2.6.22.1" if BR2_KERNEL_HEADERS_2_6_22_1
+ default "2.6.22.10" if BR2_KERNEL_HEADERS_2_6_22_10
+ default "2.6.22.10" if BR2_KERNEL_HEADERS_2_6_22
+ default "2.6.23" if BR2_KERNEL_HEADERS_2_6_23
+ default "2.6.24.7" if BR2_KERNEL_HEADERS_2_6_24
+ default "2.6.25.10" if BR2_KERNEL_HEADERS_2_6_25
+ default "2.6" if BR2_KERNEL_HEADERS_SNAP
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.20.4-ipmisensors-20070314-1214.patch b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.20.4-ipmisensors-20070314-1214.patch
new file mode 100644
index 0000000000..aca57c37b0
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.20.4-ipmisensors-20070314-1214.patch
@@ -0,0 +1,1914 @@
+diff -rduNp linux-2.6.20.3.orig/drivers/char/ipmi/ipmi_msghandler.c linux-2.6.20.3/drivers/char/ipmi/ipmi_msghandler.c
+--- linux-2.6.20.3.orig/drivers/char/ipmi/ipmi_msghandler.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/char/ipmi/ipmi_msghandler.c 2007-03-14 14:23:02.000000000 +0100
+@@ -1954,6 +1954,24 @@ static void remove_proc_entries(ipmi_smi
+ #endif /* CONFIG_PROC_FS */
+ }
+
++/*
++ * Retrieves the bmc_device struct for a given ipmi interface number (or NULL if none).
++ */
++struct device *ipmi_get_bmcdevice(int if_num)
++{
++ ipmi_smi_t intf;
++ mutex_lock(&ipmi_interfaces_mutex);
++ list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
++ if (intf->intf_num == if_num){
++ mutex_unlock(&ipmi_interfaces_mutex);
++ return &intf->bmc->dev->dev;
++ }
++ }
++ mutex_unlock(&ipmi_interfaces_mutex);
++
++ return NULL;
++}
++
+ static int __find_bmc_guid(struct device *dev, void *data)
+ {
+ unsigned char *id = data;
+@@ -4183,3 +4201,4 @@ EXPORT_SYMBOL(ipmi_get_my_LUN);
+ EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
+ EXPORT_SYMBOL(ipmi_user_set_run_to_completion);
+ EXPORT_SYMBOL(ipmi_free_recv_msg);
++EXPORT_SYMBOL(ipmi_get_bmcdevice);
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/Kconfig linux-2.6.20.3/drivers/hwmon/Kconfig
+--- linux-2.6.20.3.orig/drivers/hwmon/Kconfig 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/Kconfig 2007-03-14 14:23:02.000000000 +0100
+@@ -218,6 +218,16 @@ config SENSORS_GL520SM
+ This driver can also be built as a module. If so, the module
+ will be called gl520sm.
+
++config SENSORS_IPMI
++ tristate "IPMI Hardware Monitoring Support"
++ depends on HWMON && IPMI_HANDLER && EXPERIMENTAL
++ help
++ If you say yes here you get support for sensors monitored by
++ an IPMI baseboard management controller (BMC).
++
++ This driver can also be built as a module. If so, the module
++ will be called ipmisensors.
++
+ config SENSORS_IT87
+ tristate "ITE IT87xx and compatibles"
+ depends on HWMON && I2C
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/Makefile linux-2.6.20.3/drivers/hwmon/Makefile
+--- linux-2.6.20.3.orig/drivers/hwmon/Makefile 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/Makefile 2007-03-14 14:23:02.000000000 +0100
+@@ -28,6 +28,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
+ obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
+ obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+ obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
++obj-$(CONFIG_SENSORS_IPMI) += ipmisensors.o
+ obj-$(CONFIG_SENSORS_IT87) += it87.o
+ obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
+ obj-$(CONFIG_SENSORS_LM63) += lm63.o
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.c linux-2.6.20.3/drivers/hwmon/ipmisensors.c
+--- linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/ipmisensors.c 2007-03-14 14:44:42.000000000 +0100
+@@ -0,0 +1,1552 @@
++/*
++ * ipmisensors.c - lm-sensors/hwmon interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/init.h>
++#include <linux/module.h>
++#include <linux/param.h>
++#include <linux/hwmon.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/device.h>
++#include <linux/hwmon.h>
++
++#include "ipmisensors.h"
++
++/****** Function Prototypes ******/
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg);
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc);
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset);
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index);
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr);
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data);
++static int ipmisensors_intf_registered(int ipmi_intf);
++static int ipmisensors_bmc_registered(struct device *bmc);
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address);
++static void ipmisensors_unregister_bmc(int ipmi_intf);
++static void ipmisensors_unregister_bmc_all(void);
++static void ipmisensors_new_smi(int if_num, struct device *dev);
++static void ipmisensors_smi_gone(int if_num);
++static void ipmisensors_update_bmc(struct work_struct *);
++static void ipmisensors_cleanup(void);
++
++/****** Static Vars ******/
++
++/* set when module is being removed */
++static int cleanup = 0;
++
++/* ipmisensors driver data */
++static struct ipmisensors_data driver_data = {
++ .driver_name = "bmc",
++ .bmc_data = LIST_HEAD_INIT(driver_data.bmc_data),
++ .interfaces = 0,
++ .smi_watcher = {
++ .owner = THIS_MODULE,
++ .new_smi = ipmisensors_new_smi,
++ .smi_gone = ipmisensors_smi_gone,
++ },
++ .ipmi_hndlrs = {
++ .ipmi_recv_hndl = ipmisensors_msg_handler,
++ },
++};
++
++/* sensor refresh workqueue */
++static struct workqueue_struct *ipmisensors_workqueue;
++
++/****** SDR List Functions ******/
++/**
++ * Creates a new sdrdata struct, or returns NULL if insufficient memory.
++ */
++static struct sdrdata *ipmisensors_new_sdr(void)
++{
++ struct sdrdata *sdr;
++
++ sdr = kmem_cache_alloc(driver_data.sdrdata_cache, GFP_ATOMIC);
++ if (sdr) {
++ memset(sdr, 0, sizeof(struct sdrdata));
++ } else {
++ printk(KERN_ERR
++ "ipmisensors: Couldn't allocate memory for new SDR\n");
++ }
++
++ return sdr;
++}
++
++/**
++ * Adds the given sdrdata struct to the given bmc's SDR list.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static inline void ipmisensors_add_sdr(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ list_add(&sdr->list, &bmc->sdrs);
++ printk(KERN_DEBUG
++ "ipmisensors: SDR %d: type 0x%02x (%s)\n",
++ bmc->sdr_count, sdr->stype, sdr->id);
++ bmc->sdr_count++;
++}
++
++/**
++ * Cleanup the sdr list for the given BMC.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_sdr_cleanup(struct ipmisensors_bmc_data *bmc)
++{
++ struct sdrdata *cursor, *next;
++
++ /* find and free each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ device_remove_file(bmc->dev, &cursor->attr.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_min.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_max.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_label.dev_attr);
++
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++
++ list_del(&cursor->list);
++ kmem_cache_free(driver_data.sdrdata_cache, cursor);
++ }
++}
++
++/* worker function for workqueue ipmisensors_workqueue */
++static void ipmisensors_update_bmc(struct work_struct *work)
++{
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, update_work.work);
++
++ /* don't start an update cycle if one already in progress */
++ if (bmc->state != STATE_READING) {
++ struct sdrdata *cursor, *next;
++ bmc->state = STATE_READING;
++ printk(KERN_DEBUG "ipmisensors: starting update\n");
++
++ /* init semaphore to 1 for update cycle */
++ sema_init(&bmc->update_semaphore, 1);
++
++ /* update each sdr reading */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ ipmisensors_get_reading(bmc, cursor);
++ }
++ }
++
++ /* wait for readings (need timeout?) */
++ down_interruptible(&bmc->update_semaphore);
++
++ printk(KERN_DEBUG "ipmisensors: update complete\n");
++
++ bmc->state = STATE_DONE;
++
++ /* if the module isn't cleaning up, schedule another update */
++ if (!cleanup)
++ queue_delayed_work(ipmisensors_workqueue, &bmc->update_work,
++ bmc->update_period * HZ);
++}
++
++/****** IPMI Message Sending ******/
++
++/**
++ * Send a message to the IPMI BMC
++ *
++ * @bmc: the bmc to send the message to.
++ * @msgid: the message id to use.
++ * @msg: the ipmi message structure.
++ */
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg)
++{
++ if (msg->data == NULL)
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x\n", msg->cmd);
++ else
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x 0x%x 0x%x\n",
++ msg->cmd, msg->data[0], msg->data[1]);
++
++ /* This should be ipmi_request, but Corey had to remove
++ * that due to it being unused at the moment, as soon as
++ * this makes it into the kernel we should request it be re-instated.
++ */
++ ipmi_request_settime(bmc->user, &bmc->address, msgid, msg, bmc, 0,
++ -1, 0);
++}
++
++/**
++ * Compose and send a "reserve SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_RESERVE_SDR;
++ bmc->tx_message.data_len = 0;
++ bmc->tx_message.data = NULL;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Componse and send a "get SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @res_id:
++ * @record:
++ * @offset:
++ */
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset)
++{
++ printk(KERN_DEBUG "ipmisensors: Get SDR 0x%x 0x%x 0x%x\n",
++ res_id, record, offset);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SDR;
++ bmc->tx_message.data_len = 6;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = res_id & 0xff;
++ bmc->tx_msg_data[1] = res_id >> 8;
++ bmc->tx_msg_data[2] = record & 0xff;
++ bmc->tx_msg_data[3] = record >> 8;
++ bmc->tx_msg_data[4] = offset;
++ bmc->tx_msg_data[5] = bmc->ipmi_sdr_partial_size;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "set sensor threshold" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @id: the ipmi id number of the sensor.
++ * @value: the new value for the threshold.
++ * @lim_index: the index in the lim[] array for which this value applies.
++ */
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index)
++{
++ int i;
++
++ printk(KERN_DEBUG "ipmisensors: Set SDR Threshold %d %d %d\n",
++ number, value, lim_index);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_SET_SENSOR_THRESHOLD;
++ bmc->tx_message.data_len = 8;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = number & 0xff;
++ bmc->tx_msg_data[1] = 0x01 << lim_index;
++
++ if (lim_index > 5 || lim_index < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Error - ipmisensors_set_sensor_threshold given invalid lim_index\n");
++ return;
++ }
++
++ for (i = 2; i < 8; i++)
++ bmc->tx_msg_data[i] = 0x00;
++
++ bmc->tx_msg_data[lim_index] = value && 0xff;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "get sensor reading" message for the given sdr.
++ *
++ * @bmc: the bmc to send the message to.
++ * @sdr: the sdr of the sensor to get the reading for.
++ */
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_SENSOR_EVENT_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SENSOR_STATE_READING;
++ bmc->tx_message.data_len = 1;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = sdr->number;
++ bmc->current_sdr = sdr;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++ down_interruptible(&bmc->update_semaphore);
++}
++
++/****** IPMI Message Receiving ******/
++
++/**
++ * Process an sensor reading response message.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_reading_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ struct sdrdata *sdr = bmc->current_sdr;
++
++ if (sdr == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error ipmisensors_rcv_reading with NULL sdr\n");
++ return;
++ }
++
++ sdr->reading = msg->data[1];
++ sdr->status = msg->data[2];
++ sdr->thresholds = msg->data[3];
++
++ printk(KERN_DEBUG "ipmisensors: sensor %d (type %d) reading %d\n",
++ sdr->number, sdr->stype, msg->data[1]);
++
++ up(&bmc->update_semaphore);
++}
++
++/**
++ * Unpack based on string type, convert to normal, null terminate.
++ */
++static void ipmisensors_sprintf(u8 * to, u8 * from, u8 type, u8 length)
++{
++ static const u8 *bcdplus = "0123456789 -.:,_";
++ int i;
++
++ switch (type) {
++ case 0: /* unicode */
++ for (i = 0; i < length; i++)
++ *to++ = (*from++ & 0x7f);
++ *to = 0;
++ break;
++ case 1: /* BCD Plus */
++ for (i = 0; i < length; i++)
++ *to++ = bcdplus[*from++ & 0x0f];
++ *to = 0;
++ break;
++ case 2: /* packed ascii *//* if not a mult. of 3 this will run over */
++ for (i = 0; i < length; i += 3) {
++ *to++ = *from & 0x3f;
++ *to++ = *from >> 6 | ((*(from+1) & 0xf) << 2);
++ from++;
++ *to++ = *from >> 4 | ((*(from+1) & 0x3) << 4);
++ from++;
++ *to++ = (*from++ >> 2) & 0x3f;
++ }
++ *to = 0;
++ break;
++ case 3: /* normal */
++ if (length > 1)
++ memcpy(to, from, length);
++ to[length] = 0;
++ break;
++ }
++}
++
++/* IPMI V1.5 Section 30 */
++static const int exps[] =
++ { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
++
++/* Return 0 for fan, 2 for temp, 3 for voltage
++ We could make it variable based on the accuracy (= log10(m * 10**k2));
++ this would work for /proc output, however libsensors resolution
++ is statically set in lib/chips.c */
++static int decplaces(struct sdrdata *sd)
++{
++ switch (sd->stype) {
++ case STYPE_TEMP:
++ return 2;
++ case STYPE_CURR:
++ case STYPE_VOLT:
++ return 3;
++ case STYPE_FAN:
++ default:
++ return 0;
++ }
++}
++
++/* convert a raw value to a reading. IMPI V1.5 Section 30 */
++static long conv_val(int value, struct sdrdata *sd)
++{
++ u8 k1, k2;
++ long r;
++
++ r = value * sd->m;
++ k1 = sd->k & 0x0f;
++ k2 = sd->k >> 4;
++ if (k1 < 8)
++ r += sd->b * exps[k1];
++ else
++ r += sd->b / exps[16 - k1];
++ r *= exps[decplaces(sd)];
++ if (k2 < 8) {
++ if (sd->linear != 7)
++ r *= exps[k2];
++ else
++ /* this will always truncate to 0: r = 1 / (exps[k2] * r); */
++ r = 0;
++ } else {
++ if (sd->linear != 7)
++ r /= exps[16 - k2];
++ else {
++ if (r != 0)
++ /* 1 / x * 10 ** (-m) == 10 ** m / x */
++ r = exps[16 - k2] / r;
++ else
++ r = 0;
++ }
++ }
++
++ return r;
++}
++
++static const char *threshold_text[] = {
++ "upper non-recoverable threshold",
++ "upper critical threshold",
++ "upper non-critical threshold",
++ "lower non-recoverable threshold",
++ "lower critical threshold",
++ "lower non-critical threshold",
++ "positive-going hysteresis",
++ "negative-going hysteresis" /* unused */
++};
++
++/* select two out of the 8 possible readable thresholds, and place indexes into the limits
++ array into lim1 and lim2. Set writable flags */
++static void ipmisensors_select_thresholds(struct sdrdata *sd)
++{
++ u8 capab = sd->capab;
++ u16 mask = sd->thresh_mask;
++ int tmp;
++
++ sd->lim1 = -1;
++ sd->lim2 = -1;
++ sd->lim1_write = 0;
++ sd->lim2_write = 0;
++
++ if (((capab & 0x0c) == 0x04) || /* readable thresholds ? */
++ ((capab & 0x0c) == 0x08)) {
++ /* select upper threshold */
++ if (mask & 0x10) { /* upper crit */
++ sd->lim1 = 1;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x1000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x20) { /* upper non-recov */
++ sd->lim1 = 0;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x2000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x08) { /* upper non-crit */
++ sd->lim1 = 2;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0800))
++ sd->lim1_write = 1;
++ }
++
++ /* select lower threshold */
++ if ((((capab & 0x30) == 0x10) || /* readable ? */
++ ((capab & 0x30) == 0x20)) && /* pos hyst */
++ sd->stype == STYPE_TEMP)
++ sd->lim2 = 6;
++ else if (mask & 0x02) { /* lower crit */
++ sd->lim2 = 4;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0200))
++ sd->lim2_write = 1;
++ } else if (mask & 0x04) { /* lower non-recov */
++ sd->lim2 = 3;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0400))
++ sd->lim2_write = 1;
++ } else if (mask & 0x01) { /* lower non-crit */
++ sd->lim2 = 5;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0100))
++ sd->lim2_write = 1;
++ }
++ }
++
++ /* swap lim1/lim2 if m < 0 or function is 1/x (but not both!) */
++ if ((sd->m < 0 && sd->linear != 7) || (sd->m >= 0 && sd->linear == 7)) {
++ tmp = sd->lim1;
++ sd->lim1 = sd->lim2;
++ sd->lim2 = tmp;
++ }
++
++ if (sd->lim1 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for upper limit\n",
++ threshold_text[sd->lim1]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable upper limit\n");
++
++ if (sd->lim2 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for lower limit\n",
++ threshold_text[sd->lim2]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable lower limit\n");
++}
++
++/************* sysfs callback functions *********/
++static ssize_t show_update_period(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ return snprintf(buf, 20, "%d\n", aattr->bmc->update_period);
++}
++
++static ssize_t store_update_period(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ aattr->bmc->update_period = simple_strtoul(buf, NULL, 10);;
++ return count;
++};
++
++static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ return snprintf(buf, 20, "%ld\n",
++ conv_val(sattr->sdr->reading, sattr->sdr));
++}
++
++static ssize_t show_sensor_max(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long max = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim1 >= 0)
++ max = conv_val(sattr->sdr->limits[sattr->sdr->lim1],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", max);
++}
++
++static ssize_t show_sensor_min(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long min = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim2 >= 0)
++ min = conv_val(sattr->sdr->limits[sattr->sdr->lim2],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", min);
++};
++
++static ssize_t show_sensor_label(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ u8 label[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ ipmisensors_sprintf(label, sattr->sdr->id, sattr->sdr->string_type,
++ sattr->sdr->id_length);
++ return snprintf(buf, 20, "%s\n", label);
++};
++
++static ssize_t store_sensor_max(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set max on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim1);
++ return count;
++};
++
++static ssize_t store_sensor_min(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set min on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim2);
++ return count;
++};
++
++static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++ return snprintf(buf, 20, "%d\n", aattr->bmc->alarms);
++};
++
++static ssize_t show_name(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ return snprintf(buf, 20, "%s\n", driver_data.driver_name);
++};
++
++/* work function to build the sysfs entries using the ipmi sdrs */
++static void ipmisensors_build_sysfs(struct work_struct *work)
++{
++ int temps = 0, volts = 0, currs = 0, fans = 0;
++ struct sdrdata *cursor, *next;
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, sysfs_work);
++
++ /* find and create entries for each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++
++ cursor->attr_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_max_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_min_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ return;
++ }
++ }
++
++ if (cursor->attr_name == NULL || cursor->attr_max_name == NULL
++ || cursor->attr_min_name == NULL
++ || cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "temp%d_input", ++temps);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "temp%d_max", temps);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "temp%d_min", temps);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "temp%d_label", temps);
++ break;
++ case (STYPE_VOLT):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "in%d_input", ++volts);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "in%d_max", volts);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "in%d_min", volts);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "in%d_label", volts);
++ break;
++ case (STYPE_CURR):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "curr%d_input", ++currs);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "curr%d_max", currs);
++ sprintf(cursor->attr_min_name, "curr%d_min", currs);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "curr%d_label", currs);
++ break;
++ case (STYPE_FAN):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "fan%d_input", ++fans);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "fan%d_max", fans);
++ sprintf(cursor->attr_min_name, "fan%d_min", fans);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "fan%d_label", fans);
++ break;
++ default:
++ printk(KERN_INFO "ipmisensors: unkown sensor type\n");
++ continue;
++ }
++
++ cursor->attr.dev_attr.attr.name = cursor->attr_name;
++ cursor->attr.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr.dev_attr.show = show_sensor;
++ cursor->attr.dev_attr.store = NULL;
++ cursor->attr.sdr = cursor;
++
++ cursor->attr_min.dev_attr.attr.name = cursor->attr_min_name;
++ cursor->attr_min.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_min.dev_attr.show = show_sensor_min;
++ cursor->attr_min.sdr = cursor;
++
++ if (cursor->lim2_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_min.dev_attr.store = store_sensor_min;
++ cursor->attr_min.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_min.dev_attr.store = NULL;
++ cursor->attr_min.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ cursor->attr_max.dev_attr.attr.name = cursor->attr_max_name;
++ cursor->attr_max.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_max.dev_attr.show = show_sensor_max;
++ cursor->attr_max.sdr = cursor;
++
++ if (cursor->lim1_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_max.dev_attr.store = store_sensor_max;
++ cursor->attr_max.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_max.dev_attr.store = NULL;
++ cursor->attr_max.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label.dev_attr.attr.name =
++ cursor->attr_label_name;
++ cursor->attr_label.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr_label.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_label.dev_attr.show = show_sensor_label;
++ cursor->attr_label.dev_attr.store = NULL;
++ cursor->attr_label.sdr = cursor;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registering sensor %d: (type 0x%.2x) "
++ "(fmt=%d; m=%d; b=%d; k1=%d; k2=%d; cap=0x%.2x; mask=0x%.4x)\n",
++ cursor->number, cursor->stype, cursor->format, cursor->m,
++ cursor->b, cursor->k & 0xf, cursor->k >> 4,
++ cursor->capab, cursor->thresh_mask);
++
++ if (cursor->id_length > 0) {
++ ipmisensors_sprintf(id, cursor->id, cursor->string_type,
++ cursor->id_length);
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label temp%d \"%s\"\n",
++ temps, id);
++ break;
++ case (STYPE_VOLT):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label in%d \"%s\"\n",
++ volts, id);
++ break;
++ case (STYPE_CURR):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label curr%d \"%s\"\n",
++ currs, id);
++ break;
++ case (STYPE_FAN):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label fan%d \"%s\"\n",
++ fans, id);
++ break;
++ }
++ }
++
++ ipmisensors_select_thresholds(cursor);
++
++ if (cursor->linear != 0 && cursor->linear != 7) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: nonlinear function 0x%.2x unsupported, expect bad results\n",
++ cursor->number, cursor->linear);
++ }
++
++ if ((cursor->format & 0x03) == 0x02) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: 1's complement format unsupported, expect bad results\n",
++ cursor->number);
++ } else if ((cursor->format & 0x03) == 0x03) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: threshold sensor only, no readings available",
++ cursor->number);
++ }
++
++ if (cursor->lim1_write || cursor->lim2_write)
++ cursor->attr.dev_attr.attr.mode = 0644;
++ else
++ cursor->attr.dev_attr.attr.mode = 0444;
++
++ if (device_create_file(bmc->dev, &cursor->attr.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_min.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_max.dev_attr) < 0
++ || (cursor->id_length >
++ 0 ? device_create_file(bmc->dev,
++ &cursor->attr_label.dev_attr) <
++ 0 : 0)
++ ) {
++ printk(KERN_INFO
++ "ipmisensors: sysfs file creation failed for SDR %d (%s).\n",
++ cursor->number, cursor->id);
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++ }
++
++ bmc->alarms_attr.dev_attr.attr.name = "alarms";
++ bmc->alarms_attr.dev_attr.attr.mode = S_IRUGO;
++ bmc->alarms_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->alarms_attr.dev_attr.show = show_alarms;
++ bmc->alarms_attr.dev_attr.store = NULL;
++ bmc->alarms_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->alarms_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'alarms'");
++ return;
++ }
++
++ bmc->name_attr.attr.name = "name";
++ bmc->name_attr.attr.mode = S_IRUGO;
++ bmc->name_attr.attr.owner = THIS_MODULE;
++ bmc->name_attr.show = show_name;
++
++ if (device_create_file(bmc->dev, &bmc->name_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'name'");
++ return;
++ }
++
++ bmc->update_attr.dev_attr.attr.name = "update_period";
++ bmc->update_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ bmc->update_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->update_attr.dev_attr.show = show_update_period;
++ bmc->update_attr.dev_attr.store = store_update_period;
++ bmc->update_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->update_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'update_period'");
++ return;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registered %d temp, %d volt, %d current, %d fan sensors\n",
++ temps, volts, currs, fans);
++
++ /* This completes the initialization. We can now kickoff the
++ * periodic update of the bmc sensor's values by scheduling
++ * the first work.
++ */
++ queue_work(ipmisensors_workqueue, &bmc->update_work.work);
++
++}
++
++/**
++ * Process an SDR response message, save the SDRs we like in the sdr
++ * list for the given BMC.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_sdr_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ u16 record;
++ int type;
++ int stype;
++ int id_length;
++ int i;
++ int ipmi_ver = 0;
++ unsigned char *data;
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct sdrdata *sdr;
++
++ if (msg->data[0] != 0) {
++ /* cut request in half and try again */
++ bmc->ipmi_sdr_partial_size /= 2;
++ if (bmc->ipmi_sdr_partial_size < 8) {
++ printk(KERN_INFO
++ "ipmisensors: IPMI buffers too small, giving up\n");
++ bmc->state = STATE_DONE;
++ return;
++ }
++ printk(KERN_DEBUG
++ "ipmisensors: Reducing SDR request size to %d\n",
++ bmc->ipmi_sdr_partial_size);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ if (bmc->ipmi_sdr_partial_size < IPMI_SDR_SIZE) {
++ if (bmc->rx_msg_data_offset == 0) {
++ memcpy(bmc->rx_msg_data, msg->data,
++ bmc->ipmi_sdr_partial_size + 3);
++ bmc->rx_msg_data_offset =
++ bmc->ipmi_sdr_partial_size + 3;
++ } else {
++ memcpy(bmc->rx_msg_data + bmc->rx_msg_data_offset,
++ msg->data + 3, bmc->ipmi_sdr_partial_size);
++ bmc->rx_msg_data_offset += bmc->ipmi_sdr_partial_size;
++ }
++ if (bmc->rx_msg_data_offset > bmc->rx_msg_data[7] + 7) {
++ /* got last chunk */
++ bmc->rx_msg_data_offset = 0;
++ data = bmc->rx_msg_data;
++ } else {
++ /* get more */
++ record =
++ (bmc->rx_msg_data[4] << 8) | bmc->rx_msg_data[3];
++ ipmisensors_get_sdr(bmc, bmc->resid, record,
++ bmc->rx_msg_data_offset - 3);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ } else {
++ /* got it in one chunk */
++ data = msg->data;
++ }
++
++ bmc->nextrecord = (data[2] << 8) | data[1];
++
++ /* If the ipmi version is 0.9 we have to remap some things.
++ * Yes this is very ugly, but we aren't the ones who
++ * implemented an incomplete spec!
++ */
++ ipmi_ver = data[5];
++
++ type = data[6];
++ /* known SDR type */
++ if (type == 1 || type == 2) {
++ stype = data[(ipmi_ver == 0x90 ? 16 : 15)];
++ /* known sensor type */
++ if (stype <= STYPE_MAX) {
++ if (data[(ipmi_ver == 0x90 ? 17 : 16)] != 0x01) {
++ if (type == 1)
++ ipmisensors_sprintf(id, &data[51],
++ data[50] >> 6,
++ data[50] & 0x1f);
++ else
++ ipmisensors_sprintf(id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 :
++ 35)],
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] >> 6,
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] & 0x1f);
++ printk(KERN_INFO
++ "ipmisensors: skipping non-threshold sensor \"%s\"\n",
++ id);
++ } else {
++ /* add entry to sdrd table */
++ sdr = ipmisensors_new_sdr();
++ if (!sdr) {
++ printk(KERN_ERR
++ "ipmisensors: could not allocate memory for new SDR");
++ return;
++ }
++ sdr->bmc = bmc;
++ sdr->stype = stype;
++ sdr->number = data[10];
++ sdr->capab = data[(ipmi_ver == 0x90 ? 15 : 14)];
++ sdr->thresh_mask =
++ (((u16) data[(ipmi_ver == 0x90 ? 21 : 22)])
++ << 8) | data[21];
++ if (type == 1) {
++ sdr->format =
++ data[(ipmi_ver ==
++ 0x90 ? 22 : 24)] >> 6;
++ sdr->linear =
++ data[(ipmi_ver ==
++ 0x90 ? 25 : 26)] & 0x7f;
++ sdr->m =
++ data[(ipmi_ver == 0x90 ? 26 : 27)];
++ sdr->m |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 27 : 28)]
++ & 0xc0)) << 2;
++ if (sdr->m & 0x0200) {
++ /* sign extend */
++ sdr->m |= 0xfc00;
++ }
++ sdr->b =
++ data[(ipmi_ver == 0x90 ? 28 : 29)];
++ sdr->b |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 29 : 30)]
++ & 0xc0)) << 2;
++ if (sdr->b & 0x0200) {
++ /* sign extend */
++ sdr->b |= 0xfc00;
++ }
++ sdr->k =
++ data[(ipmi_ver == 0x90 ? 31 : 32)];
++ sdr->nominal =
++ data[(ipmi_ver == 0x90 ? 33 : 34)];
++ for (i = 0; i < SDR_LIMITS; i++) {
++ /* assume readable */
++ sdr->limits[i] =
++ data[(ipmi_ver ==
++ 0x90 ? 40 : 39) + i];
++ }
++ sdr->string_type = data[50] >> 6;
++ id_length = data[50] & 0x1f;
++ memcpy(sdr->id, &data[51], id_length);
++ sdr->id_length = id_length;
++ } else {
++ sdr->m = 1;
++ sdr->b = 0;
++ sdr->k = 0;
++ sdr->string_type =
++ data[(ipmi_ver ==
++ 0x90 ? 29 : 34)] >> 6;
++ id_length = data[34] & 0x1f;
++ if (id_length > 0) {
++ memcpy(sdr->id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 : 35)],
++ id_length);
++ }
++ sdr->id_length = id_length;
++ /* limits?? */
++ if (ipmi_ver == 0x90) {
++ memcpy(sdr->id,
++ &data[30], id_length);
++ sdr->id_length = id_length;
++ }
++ }
++ ipmisensors_add_sdr(bmc, sdr);
++ }
++ }
++ /* peek at the other SDR types */
++ } else if (type == 0x10 || type == 0x11 || type == 0x12) {
++ ipmisensors_sprintf(id, data + 19, data[18] >> 6,
++ data[18] & 0x1f);
++ if (type == 0x10) {
++ printk(KERN_INFO
++ "ipmisensors: Generic Device acc=0x%x; slv=0x%x; lun=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[13], id);
++ } else if (type == 0x11) {
++ printk(KERN_INFO
++ "ipmisensors: FRU Device acc=0x%x; slv=0x%x; log=0x%x; ch=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[11], data[13],
++ id);
++ } else {
++ printk(KERN_INFO
++ "ipmisensors: Mgmt Ctllr Device slv=0x%x; \"%s\"\n",
++ data[8], id);
++ }
++ } else if (type == 0x14) {
++ printk(KERN_INFO
++ "ipmisensors: Message Channel Info Records:\n");
++ for (i = 0; i < 8; i++) {
++ printk(KERN_INFO "ipmisensors: Channel %d info 0x%x\n",
++ i, data[9 + i]);
++ }
++ } else {
++ printk(KERN_INFO "ipmisensors: Skipping SDR type 0x%x\n", type);
++ }
++ if (ipmi_ver != 0x90) {
++ if (bmc->nextrecord >= 6224) {
++ /*YJ stop sensor scan on poweredge 1750 */
++ bmc->nextrecord = 0xffff;
++ }
++ }
++
++ if (bmc->nextrecord == 0xFFFF) {
++ if (bmc->sdr_count == 0) {
++ printk(KERN_INFO
++ "ipmisensors: No recognized sensors found.\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_INFO "ipmisensors: all sensors detected\n");
++ bmc->state = STATE_SYSTABLE;
++
++ /* Schedule sysfs build/registration work */
++ INIT_WORK(&bmc->sysfs_work, ipmisensors_build_sysfs);
++ queue_work(ipmisensors_workqueue, &bmc->sysfs_work);
++ }
++ } else {
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ }
++}
++
++/**
++ * Process incoming messages based on internal state
++ *
++ * @bmc: the bmc the message is from.
++ * @msg: the ipmi message to process.
++ */
++static void ipmisensors_rcv_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ switch (bmc->state) {
++ case STATE_INIT:
++ case STATE_RESERVE:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got first resid 0x%.4x\n",
++ bmc->resid);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_SDR:
++ case STATE_SDRPARTIAL:
++ ipmisensors_rcv_sdr_msg(bmc, msg);
++ break;
++
++ case STATE_READING:
++ ipmisensors_rcv_reading_msg(bmc, msg);
++ break;
++
++ case STATE_UNCANCEL:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got new resid 0x%.4x\n",
++ bmc->resid);
++
++ bmc->rx_msg_data_offset = 0;
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_DONE:
++ case STATE_SYSTABLE:
++ break;
++ default:
++ bmc->state = STATE_INIT;
++ }
++}
++
++/**
++ * Callback to handle a received IPMI message from a given BMC.
++ *
++ * @msg: the received message.
++ * @handler_data: a pointer to the particular bmc ipmisensors_bmc_data struct.
++ */
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data)
++{
++ struct ipmisensors_bmc_data *bmc =
++ (struct ipmisensors_bmc_data *)user_msg_data;
++
++ if (msg->msg.data[0] != 0)
++ printk(KERN_WARNING
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x\n",
++ msg->msg.data[0], msg->msg.netfn, msg->msg.cmd);
++
++ if (bmc != NULL && ipmisensors_intf_registered(bmc->interface_id)) {
++ if (bmc->state == STATE_SDR &&
++ msg->msg.data[0] == IPMI_INVALID_RESERVATION_ID) {
++ /* reservation cancelled, get new resid */
++ if (++bmc->errorcount > 275) {
++ printk(KERN_ERR
++ "ipmisensors: Too many reservations cancelled, giving up\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_DEBUG
++ "ipmisensors: resid 0x%04x cancelled, getting new one\n",
++ bmc->resid);
++
++ ipmisensors_reserve_sdr(bmc);
++ bmc->state = STATE_UNCANCEL;
++ }
++ } else if (msg->msg.data[0] != IPMI_CC_NO_ERROR &&
++ msg->msg.data[0] != IPMI_ERR_RETURNING_REQ_BYTES &&
++ msg->msg.data[0] != IPMI_ERR_PROVIDING_RESPONSE) {
++ printk(KERN_ERR
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x; state = %d; probably fatal.\n",
++ msg->msg.data[0], msg->msg.netfn & 0xfe,
++ msg->msg.cmd, bmc->state);
++ } else {
++ printk(KERN_DEBUG "ipmisensors: received message\n");
++ ipmisensors_rcv_msg(bmc, &msg->msg);
++ }
++
++ } else {
++ printk(KERN_WARNING
++ "ipmisensors: Response for non-registered BMC\n");
++ if (bmc != NULL)
++ printk(KERN_DEBUG "ipmisensors: BMC ID: %d\n",
++ bmc->interface_id);
++ else
++ printk(KERN_DEBUG "ipmisensors: BMC NULL!\n");
++ }
++
++ ipmi_free_recv_msg(msg);
++}
++
++/****** IPMI Interface Initialization ******/
++
++/**
++ * Return true if the given ipmi interface has been registered.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static int ipmisensors_intf_registered(int ipmi_intf)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Return true if the given BMC has been registered.
++ *
++ * @bmc: The BMC device.
++ */
++static int ipmisensors_bmc_registered(struct device *bmc)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->dev == bmc) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Register new IPMI BMC interface. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address)
++{
++ int error;
++
++ /* allocate a new ipmisensors_bmc_data struct */
++
++ struct ipmisensors_bmc_data *bmc = (struct ipmisensors_bmc_data *)
++ kmalloc(sizeof(struct ipmisensors_bmc_data), GFP_KERNEL);
++
++ /* initialize members */
++ INIT_LIST_HEAD(&bmc->sdrs);
++ bmc->interface_id = ipmi_intf;
++
++ bmc->address = *address;
++
++ bmc->sdr_count = 0;
++ bmc->msgid = 0;
++ bmc->ipmi_sdr_partial_size = IPMI_CHUNK_SIZE;
++ bmc->state = STATE_INIT;
++ bmc->errorcount = 0;
++ bmc->rx_msg_data_offset = 0;
++ bmc->dev = ipmi_get_bmcdevice(ipmi_intf);
++
++ /* default to 3 second min update interval */
++ bmc->update_period = 3;
++
++ if (bmc->dev == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error, couldn't get BMC device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Create IPMI messaging interface user */
++ error = ipmi_create_user(bmc->interface_id, &driver_data.ipmi_hndlrs,
++ bmc, &bmc->user);
++ if (error < 0) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register user with ipmi interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC as a HWMON class device */
++ bmc->class_dev = hwmon_device_register(bmc->dev);
++
++ if (IS_ERR(bmc->class_dev)) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register hwmon class device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC in the driver */
++ if (ipmisensors_bmc_registered(bmc->dev)) {
++ printk(KERN_ERR
++ "ipmisensors: BMC on interface %d already registered\n",
++ bmc->interface_id);
++ hwmon_device_unregister(bmc->class_dev);
++ kfree(bmc);
++ return;
++ }
++
++ ipmi_get_version(bmc->user, &bmc->ipmi_version_major,
++ &bmc->ipmi_version_minor);
++
++ /* finally add the new bmc data to the bmc data list */
++ list_add_tail(&bmc->list, &driver_data.bmc_data);
++ driver_data.interfaces++;
++
++ printk(KERN_INFO
++ "ipmisensors: Registered IPMI %d.%d BMC over interface %d\n",
++ bmc->ipmi_version_major,
++ bmc->ipmi_version_minor, bmc->interface_id);
++
++ /* Send a reserve SDR command to the bmc */
++ ipmisensors_reserve_sdr(bmc);
++
++ /* initialize the bmc's update work struct */
++ INIT_DELAYED_WORK(&bmc->update_work, ipmisensors_update_bmc);
++}
++
++/**
++ * Callback for when an IPMI BMC is gone. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_unregister_bmc(int ipmi_intf)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ list_del(&cursor->list);
++ printk(KERN_DEBUG
++ "ipmisensors: cancelling queued work\n");
++ /* cancel update work queued for this bmc */
++ cancel_delayed_work(&cursor->update_work);
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev,
++ &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev,
++ &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ driver_data.interfaces--;
++ }
++ }
++
++}
++
++/**
++ * Unregister all registered bmcs.
++ */
++static void ipmisensors_unregister_bmc_all(void)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ list_del(&cursor->list);
++
++ /* cancel update work queued for this bmc */
++ printk(KERN_DEBUG "ipmisensors: cancelling queued work\n");
++ cancel_delayed_work(&cursor->update_work);
++
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev, &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev, &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ }
++
++ driver_data.interfaces = 0;
++}
++
++/**
++ * Callback for when a new IPMI SMI type interface is found.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_new_smi(int if_num, struct device *dev)
++{
++ struct ipmi_addr smi_address = {
++ IPMI_SYSTEM_INTERFACE_ADDR_TYPE,
++ IPMI_BMC_CHANNEL,
++ {0},
++ };
++
++ /* calls the generic new interface function */
++ ipmisensors_register_bmc(if_num, &smi_address);
++}
++
++/**
++ * Callback for when an exisiting IPMI SMI type interface is gone.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_smi_gone(int if_num)
++{
++ if (driver_data.interfaces > 0) {
++ ipmisensors_unregister_bmc(if_num);
++ }
++}
++
++/**
++ * Initialize the module.
++ */
++static int __init ipmisensors_init(void)
++{
++ int error;
++ printk(KERN_INFO "ipmisensors - IPMI BMC sensors interface\n");
++
++ /* init cache managers */
++ driver_data.sdrdata_cache =
++ kmem_cache_create("ipmisensors_sdrdata", sizeof(struct sdrdata), 0,
++ 0, NULL, NULL);
++ driver_data.sysfsattr_cache =
++ kmem_cache_create("ipmisensors_sysfsattr",
++ sizeof(struct ipmisensors_device_attribute), 0, 0,
++ NULL, NULL);
++
++ if (!driver_data.sdrdata_cache || !driver_data.sysfsattr_cache) {
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++ return -ENOMEM;
++ }
++
++ /* register IPMI interface callback(s) */
++ error = ipmi_smi_watcher_register(&driver_data.smi_watcher);
++ if (error) {
++ printk(KERN_WARNING
++ "ipmisensors: can't register smi watcher\n");
++ return error;
++ }
++
++ /* create work queue, keep it simple, single-threaded */
++ ipmisensors_workqueue =
++ create_singlethread_workqueue("ipmisensors_workqueue");
++
++ return 0;
++}
++
++/**
++ * Cleanup
++ */
++static void ipmisensors_cleanup(void)
++{
++ /* start cleanup */
++ cleanup = 1;
++
++ /* unregister bmcs */
++ printk(KERN_DEBUG "ipmisensors: unregister bmcs\n");
++ ipmi_smi_watcher_unregister(&driver_data.smi_watcher);
++ ipmisensors_unregister_bmc_all();
++
++ /* flush & destroy work queue */
++ printk(KERN_DEBUG "ipmisensors: destroy workqueue\n");
++ flush_workqueue(ipmisensors_workqueue);
++ destroy_workqueue(ipmisensors_workqueue);
++
++ /* remove cache managers */
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++}
++
++/**
++ * Cleanup and exit the module
++ */
++static void __exit ipmisensors_exit(void)
++{
++ ipmisensors_cleanup();
++ printk(KERN_DEBUG "ipmisensors: cleanup finished\n");
++}
++
++MODULE_AUTHOR("Yani Ioannou <yani.ioannou@gmail.com>");
++MODULE_DESCRIPTION("IPMI BMC sensors");
++MODULE_LICENSE("GPL");
++
++module_init(ipmisensors_init);
++module_exit(ipmisensors_exit);
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.h linux-2.6.20.3/drivers/hwmon/ipmisensors.h
+--- linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/ipmisensors.h 2007-03-14 14:41:23.000000000 +0100
+@@ -0,0 +1,240 @@
++/*
++ * ipmisensors.h - lm_sensors interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/ipmi.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/workqueue.h>
++
++/* SDR defs */
++#define STYPE_TEMP 0x01
++#define STYPE_VOLT 0x02
++#define STYPE_CURR 0x03
++#define STYPE_FAN 0x04
++
++#define SDR_LIMITS 8
++#define SDR_MAX_ID_LENGTH 16
++#define SDR_MAX_UNPACKED_ID_LENGTH ((SDR_MAX_ID_LENGTH * 4 / 3) + 2)
++
++/* the last sensor type we are interested in */
++#define STYPE_MAX 4
++
++#define IPMI_SDR_SIZE 67
++#define IPMI_CHUNK_SIZE 16
++
++#define MAX_FILENAME_LENGTH 30
++
++struct ipmisensors_device_attribute {
++ struct device_attribute dev_attr;
++ struct sdrdata *sdr;
++};
++#define to_ipmisensors_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_device_attribute, dev_attr)
++
++#define IPMISENSORS_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
++struct ipmisensors_attribute sensor_dev_attr_##_name = { \
++ .dev_attr = __ATTR(_name,_mode,_show,_store), \
++ .index = _index, \
++}
++
++struct ipmisensors_bmc_device_attribute {
++ struct device_attribute dev_attr;
++ struct ipmisensors_bmc_data *bmc;
++};
++#define to_ipmisensors_bmc_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_bmc_device_attribute, dev_attr)
++
++/**
++ * &struct_sdrdata stores the IPMI Sensor Data Record (SDR) data, as recieved from the BMC, along with the corresponding sysfs attributes
++ */
++struct sdrdata {
++ struct list_head list;
++ /* retrieved from SDR, not expected to change */
++ /* Sensor Type Code */
++ u8 stype;
++ u8 number;
++ /* Sensor Capability Code */
++ u8 capab;
++ u16 thresh_mask;
++ u8 format;
++ u8 linear;
++ s16 m;
++ s16 b;
++ u8 k;
++ u8 nominal;
++ u8 limits[SDR_LIMITS];
++ /* index into limits for reported upper and lower limit */
++ int lim1, lim2;
++ u8 lim1_write, lim2_write;
++ u8 string_type;
++ u8 id_length;
++ u8 id[SDR_MAX_ID_LENGTH];
++ /* retrieved from reading */
++ u8 reading;
++ u8 status;
++ u8 thresholds;
++ /* sensor's bmc */
++ struct ipmisensors_bmc_data *bmc;
++ /* sysfs entries */
++ struct ipmisensors_device_attribute attr;
++ char *attr_name;
++ struct ipmisensors_device_attribute attr_min;
++ char *attr_min_name;
++ struct ipmisensors_device_attribute attr_max;
++ char *attr_max_name;
++ struct ipmisensors_device_attribute attr_label;
++ char *attr_label_name;
++
++};
++
++/**
++ * &struct_ipmisensors_data stores the data for the ipmisensors driver.
++ */
++struct ipmisensors_data {
++ /* Driver struct */
++ char *driver_name;
++
++ /* Linked list of ipmisensors_bmc_data structs, one for each BMC */
++ struct list_head bmc_data;
++
++ /* Number of ipmi interfaces (and hence ipmisensors_data structs). */
++ int interfaces;
++
++ /* IPMI kernel interface - SMI watcher */
++ struct ipmi_smi_watcher smi_watcher;
++
++ /* IPMI kernel interface - user handlers */
++ struct ipmi_user_hndl ipmi_hndlrs;
++
++ /* Cache manager for sdrdata cache */
++ struct kmem_cache *sdrdata_cache;
++
++ /* Cache manager for ipmi_sensor_device_attribute cache */
++ struct kmem_cache *sysfsattr_cache;
++};
++
++/**
++ * &states: enumeration of state codes for a bmc specific ipmisensors
++ */
++enum states {
++ STATE_INIT,
++ STATE_RESERVE,
++ STATE_SDR,
++ STATE_SDRPARTIAL,
++ STATE_READING,
++ STATE_UNCANCEL,
++ STATE_SYSTABLE,
++ STATE_DONE
++};
++
++/**
++ * &struct_ipmisensors_bmc_data stores the data for a particular IPMI BMC.
++ */
++struct ipmisensors_bmc_data {
++ struct list_head list;
++
++ /* The IPMI interface number */
++ int interface_id;
++
++ /* The IPMI address */
++ struct ipmi_addr address;
++
++ /* List of sdrdata structs (sdrs) recieved from the BMC */
++ struct list_head sdrs;
++
++ /* Count of the number of sdrs stored in the sdr list */
++ int sdr_count;
++
++ /* next message id */
++ int msgid;
++
++ /* The ipmi interface 'user' used to access this particular bmc */
++ ipmi_user_t user;
++
++ /* BMC IPMI Version (major) */
++ unsigned char ipmi_version_major;
++
++ /* BMC IPMI Version (minor) */
++ unsigned char ipmi_version_minor;
++
++ /* The size of the SDR request message */
++ int ipmi_sdr_partial_size;
++
++ /* transmit message buffer */
++ struct kernel_ipmi_msg tx_message;
++
++ /* ipmi transmited data buffer */
++ unsigned char tx_msg_data[IPMI_MAX_MSG_LENGTH + 50]; /* why the +50 in bmcsensors? */
++
++ /* ipmi recieved data buffer */
++ unsigned char rx_msg_data[IPMI_MAX_MSG_LENGTH + 50];
++
++ /* current recieve buffer offset */
++ int rx_msg_data_offset;
++
++ /* The id of then next SDR record to read during update cycle */
++ u16 nextrecord;
++
++ /* BMC SDR Reservation ID */
++ u16 resid;
++
++ /* Alarm status */
++ u8 alarms;
++
++ /* The cumalative error count for this bmc */
++ int errorcount;
++
++ /* The current state of this bmc w.r.t. ipmisensors (see enum states) */
++ int state;
++
++ /* The current sdr for which a reading is pending */
++ struct sdrdata *current_sdr;
++
++ /* The BMC's device struct */
++ struct device *dev;
++
++ /* hwmon class device */
++ struct class_device *class_dev;
++
++ /* hwmon device name */
++ struct device_attribute name_attr;
++
++ /* alarms attribute */
++ struct ipmisensors_bmc_device_attribute alarms_attr;
++
++ /* update_period attribute */
++ struct ipmisensors_bmc_device_attribute update_attr;
++
++ /* lower bound on time between updates (in seconds) */
++ unsigned int update_period;
++
++ /* semaphore used to do a headcount of the SDR readings we are waiting
++ * on in a given bmc update */
++ struct semaphore update_semaphore;
++
++ /* bmc's work struct for updating sensors */
++ struct delayed_work update_work;
++
++ /* bmc's work struct for building the sysfs workqueue */
++ struct work_struct sysfs_work;
++};
+diff -rduNp linux-2.6.20.3.orig/include/linux/ipmi.h linux-2.6.20.3/include/linux/ipmi.h
+--- linux-2.6.20.3.orig/include/linux/ipmi.h 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/include/linux/ipmi.h 2007-03-14 14:23:02.000000000 +0100
+@@ -300,6 +300,9 @@ int ipmi_create_user(unsigned int
+ safe, too. */
+ int ipmi_destroy_user(ipmi_user_t user);
+
++/* Get the IPMI BMC's device struct */
++struct device *ipmi_get_bmcdevice(int ipmi_intf);
++
+ /* Get the IPMI version of the BMC we are talking to. */
+ void ipmi_get_version(ipmi_user_t user,
+ unsigned char *major,
+diff -rduNp linux-2.6.20.3.orig/include/linux/ipmi_msgdefs.h linux-2.6.20.3/include/linux/ipmi_msgdefs.h
+--- linux-2.6.20.3.orig/include/linux/ipmi_msgdefs.h 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/include/linux/ipmi_msgdefs.h 2007-03-14 14:23:02.000000000 +0100
+@@ -45,6 +45,7 @@
+
+ #define IPMI_NETFN_APP_REQUEST 0x06
+ #define IPMI_NETFN_APP_RESPONSE 0x07
++#define IPMI_GET_DEVICE_GUID_CMD 0x08
+ #define IPMI_GET_DEVICE_ID_CMD 0x01
+ #define IPMI_COLD_RESET_CMD 0x02
+ #define IPMI_WARM_RESET_CMD 0x03
+@@ -57,6 +58,11 @@
+ #define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
+ #define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
+ #define IPMI_GET_CHANNEL_INFO_CMD 0x42
++#define IPMI_RESERVE_SDR 0x22
++#define IPMI_GET_SDR 0x23
++#define IPMI_GET_SENSOR_STATE_READING 0x2D
++#define IPMI_SET_SENSOR_HYSTERESIS 0x24
++#define IPMI_SET_SENSOR_THRESHOLD 0x26
+
+ #define IPMI_NETFN_STORAGE_REQUEST 0x0a
+ #define IPMI_NETFN_STORAGE_RESPONSE 0x0b
+@@ -79,10 +85,13 @@
+ #define IPMI_NODE_BUSY_ERR 0xc0
+ #define IPMI_INVALID_COMMAND_ERR 0xc1
+ #define IPMI_TIMEOUT_ERR 0xc3
++#define IPMI_INVALID_RESERVATION_ID 0xc5
+ #define IPMI_ERR_MSG_TRUNCATED 0xc6
+ #define IPMI_REQ_LEN_INVALID_ERR 0xc7
+ #define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
+ #define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
++#define IPMI_ERR_RETURNING_REQ_BYTES 0xca
++#define IPMI_ERR_PROVIDING_RESPONSE 0xce
+ #define IPMI_LOST_ARBITRATION_ERR 0x81
+ #define IPMI_BUS_ERR 0x82
+ #define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.21.5-007-ipmisensors-20070314-1214.patch b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.21.5-007-ipmisensors-20070314-1214.patch
new file mode 100644
index 0000000000..aca57c37b0
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.21.5-007-ipmisensors-20070314-1214.patch
@@ -0,0 +1,1914 @@
+diff -rduNp linux-2.6.20.3.orig/drivers/char/ipmi/ipmi_msghandler.c linux-2.6.20.3/drivers/char/ipmi/ipmi_msghandler.c
+--- linux-2.6.20.3.orig/drivers/char/ipmi/ipmi_msghandler.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/char/ipmi/ipmi_msghandler.c 2007-03-14 14:23:02.000000000 +0100
+@@ -1954,6 +1954,24 @@ static void remove_proc_entries(ipmi_smi
+ #endif /* CONFIG_PROC_FS */
+ }
+
++/*
++ * Retrieves the bmc_device struct for a given ipmi interface number (or NULL if none).
++ */
++struct device *ipmi_get_bmcdevice(int if_num)
++{
++ ipmi_smi_t intf;
++ mutex_lock(&ipmi_interfaces_mutex);
++ list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
++ if (intf->intf_num == if_num){
++ mutex_unlock(&ipmi_interfaces_mutex);
++ return &intf->bmc->dev->dev;
++ }
++ }
++ mutex_unlock(&ipmi_interfaces_mutex);
++
++ return NULL;
++}
++
+ static int __find_bmc_guid(struct device *dev, void *data)
+ {
+ unsigned char *id = data;
+@@ -4183,3 +4201,4 @@ EXPORT_SYMBOL(ipmi_get_my_LUN);
+ EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
+ EXPORT_SYMBOL(ipmi_user_set_run_to_completion);
+ EXPORT_SYMBOL(ipmi_free_recv_msg);
++EXPORT_SYMBOL(ipmi_get_bmcdevice);
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/Kconfig linux-2.6.20.3/drivers/hwmon/Kconfig
+--- linux-2.6.20.3.orig/drivers/hwmon/Kconfig 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/Kconfig 2007-03-14 14:23:02.000000000 +0100
+@@ -218,6 +218,16 @@ config SENSORS_GL520SM
+ This driver can also be built as a module. If so, the module
+ will be called gl520sm.
+
++config SENSORS_IPMI
++ tristate "IPMI Hardware Monitoring Support"
++ depends on HWMON && IPMI_HANDLER && EXPERIMENTAL
++ help
++ If you say yes here you get support for sensors monitored by
++ an IPMI baseboard management controller (BMC).
++
++ This driver can also be built as a module. If so, the module
++ will be called ipmisensors.
++
+ config SENSORS_IT87
+ tristate "ITE IT87xx and compatibles"
+ depends on HWMON && I2C
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/Makefile linux-2.6.20.3/drivers/hwmon/Makefile
+--- linux-2.6.20.3.orig/drivers/hwmon/Makefile 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/Makefile 2007-03-14 14:23:02.000000000 +0100
+@@ -28,6 +28,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
+ obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
+ obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+ obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
++obj-$(CONFIG_SENSORS_IPMI) += ipmisensors.o
+ obj-$(CONFIG_SENSORS_IT87) += it87.o
+ obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
+ obj-$(CONFIG_SENSORS_LM63) += lm63.o
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.c linux-2.6.20.3/drivers/hwmon/ipmisensors.c
+--- linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/ipmisensors.c 2007-03-14 14:44:42.000000000 +0100
+@@ -0,0 +1,1552 @@
++/*
++ * ipmisensors.c - lm-sensors/hwmon interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/init.h>
++#include <linux/module.h>
++#include <linux/param.h>
++#include <linux/hwmon.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/device.h>
++#include <linux/hwmon.h>
++
++#include "ipmisensors.h"
++
++/****** Function Prototypes ******/
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg);
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc);
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset);
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index);
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr);
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data);
++static int ipmisensors_intf_registered(int ipmi_intf);
++static int ipmisensors_bmc_registered(struct device *bmc);
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address);
++static void ipmisensors_unregister_bmc(int ipmi_intf);
++static void ipmisensors_unregister_bmc_all(void);
++static void ipmisensors_new_smi(int if_num, struct device *dev);
++static void ipmisensors_smi_gone(int if_num);
++static void ipmisensors_update_bmc(struct work_struct *);
++static void ipmisensors_cleanup(void);
++
++/****** Static Vars ******/
++
++/* set when module is being removed */
++static int cleanup = 0;
++
++/* ipmisensors driver data */
++static struct ipmisensors_data driver_data = {
++ .driver_name = "bmc",
++ .bmc_data = LIST_HEAD_INIT(driver_data.bmc_data),
++ .interfaces = 0,
++ .smi_watcher = {
++ .owner = THIS_MODULE,
++ .new_smi = ipmisensors_new_smi,
++ .smi_gone = ipmisensors_smi_gone,
++ },
++ .ipmi_hndlrs = {
++ .ipmi_recv_hndl = ipmisensors_msg_handler,
++ },
++};
++
++/* sensor refresh workqueue */
++static struct workqueue_struct *ipmisensors_workqueue;
++
++/****** SDR List Functions ******/
++/**
++ * Creates a new sdrdata struct, or returns NULL if insufficient memory.
++ */
++static struct sdrdata *ipmisensors_new_sdr(void)
++{
++ struct sdrdata *sdr;
++
++ sdr = kmem_cache_alloc(driver_data.sdrdata_cache, GFP_ATOMIC);
++ if (sdr) {
++ memset(sdr, 0, sizeof(struct sdrdata));
++ } else {
++ printk(KERN_ERR
++ "ipmisensors: Couldn't allocate memory for new SDR\n");
++ }
++
++ return sdr;
++}
++
++/**
++ * Adds the given sdrdata struct to the given bmc's SDR list.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static inline void ipmisensors_add_sdr(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ list_add(&sdr->list, &bmc->sdrs);
++ printk(KERN_DEBUG
++ "ipmisensors: SDR %d: type 0x%02x (%s)\n",
++ bmc->sdr_count, sdr->stype, sdr->id);
++ bmc->sdr_count++;
++}
++
++/**
++ * Cleanup the sdr list for the given BMC.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_sdr_cleanup(struct ipmisensors_bmc_data *bmc)
++{
++ struct sdrdata *cursor, *next;
++
++ /* find and free each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ device_remove_file(bmc->dev, &cursor->attr.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_min.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_max.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_label.dev_attr);
++
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++
++ list_del(&cursor->list);
++ kmem_cache_free(driver_data.sdrdata_cache, cursor);
++ }
++}
++
++/* worker function for workqueue ipmisensors_workqueue */
++static void ipmisensors_update_bmc(struct work_struct *work)
++{
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, update_work.work);
++
++ /* don't start an update cycle if one already in progress */
++ if (bmc->state != STATE_READING) {
++ struct sdrdata *cursor, *next;
++ bmc->state = STATE_READING;
++ printk(KERN_DEBUG "ipmisensors: starting update\n");
++
++ /* init semaphore to 1 for update cycle */
++ sema_init(&bmc->update_semaphore, 1);
++
++ /* update each sdr reading */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ ipmisensors_get_reading(bmc, cursor);
++ }
++ }
++
++ /* wait for readings (need timeout?) */
++ down_interruptible(&bmc->update_semaphore);
++
++ printk(KERN_DEBUG "ipmisensors: update complete\n");
++
++ bmc->state = STATE_DONE;
++
++ /* if the module isn't cleaning up, schedule another update */
++ if (!cleanup)
++ queue_delayed_work(ipmisensors_workqueue, &bmc->update_work,
++ bmc->update_period * HZ);
++}
++
++/****** IPMI Message Sending ******/
++
++/**
++ * Send a message to the IPMI BMC
++ *
++ * @bmc: the bmc to send the message to.
++ * @msgid: the message id to use.
++ * @msg: the ipmi message structure.
++ */
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg)
++{
++ if (msg->data == NULL)
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x\n", msg->cmd);
++ else
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x 0x%x 0x%x\n",
++ msg->cmd, msg->data[0], msg->data[1]);
++
++ /* This should be ipmi_request, but Corey had to remove
++ * that due to it being unused at the moment, as soon as
++ * this makes it into the kernel we should request it be re-instated.
++ */
++ ipmi_request_settime(bmc->user, &bmc->address, msgid, msg, bmc, 0,
++ -1, 0);
++}
++
++/**
++ * Compose and send a "reserve SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_RESERVE_SDR;
++ bmc->tx_message.data_len = 0;
++ bmc->tx_message.data = NULL;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Componse and send a "get SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @res_id:
++ * @record:
++ * @offset:
++ */
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset)
++{
++ printk(KERN_DEBUG "ipmisensors: Get SDR 0x%x 0x%x 0x%x\n",
++ res_id, record, offset);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SDR;
++ bmc->tx_message.data_len = 6;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = res_id & 0xff;
++ bmc->tx_msg_data[1] = res_id >> 8;
++ bmc->tx_msg_data[2] = record & 0xff;
++ bmc->tx_msg_data[3] = record >> 8;
++ bmc->tx_msg_data[4] = offset;
++ bmc->tx_msg_data[5] = bmc->ipmi_sdr_partial_size;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "set sensor threshold" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @id: the ipmi id number of the sensor.
++ * @value: the new value for the threshold.
++ * @lim_index: the index in the lim[] array for which this value applies.
++ */
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index)
++{
++ int i;
++
++ printk(KERN_DEBUG "ipmisensors: Set SDR Threshold %d %d %d\n",
++ number, value, lim_index);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_SET_SENSOR_THRESHOLD;
++ bmc->tx_message.data_len = 8;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = number & 0xff;
++ bmc->tx_msg_data[1] = 0x01 << lim_index;
++
++ if (lim_index > 5 || lim_index < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Error - ipmisensors_set_sensor_threshold given invalid lim_index\n");
++ return;
++ }
++
++ for (i = 2; i < 8; i++)
++ bmc->tx_msg_data[i] = 0x00;
++
++ bmc->tx_msg_data[lim_index] = value && 0xff;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "get sensor reading" message for the given sdr.
++ *
++ * @bmc: the bmc to send the message to.
++ * @sdr: the sdr of the sensor to get the reading for.
++ */
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_SENSOR_EVENT_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SENSOR_STATE_READING;
++ bmc->tx_message.data_len = 1;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = sdr->number;
++ bmc->current_sdr = sdr;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++ down_interruptible(&bmc->update_semaphore);
++}
++
++/****** IPMI Message Receiving ******/
++
++/**
++ * Process an sensor reading response message.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_reading_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ struct sdrdata *sdr = bmc->current_sdr;
++
++ if (sdr == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error ipmisensors_rcv_reading with NULL sdr\n");
++ return;
++ }
++
++ sdr->reading = msg->data[1];
++ sdr->status = msg->data[2];
++ sdr->thresholds = msg->data[3];
++
++ printk(KERN_DEBUG "ipmisensors: sensor %d (type %d) reading %d\n",
++ sdr->number, sdr->stype, msg->data[1]);
++
++ up(&bmc->update_semaphore);
++}
++
++/**
++ * Unpack based on string type, convert to normal, null terminate.
++ */
++static void ipmisensors_sprintf(u8 * to, u8 * from, u8 type, u8 length)
++{
++ static const u8 *bcdplus = "0123456789 -.:,_";
++ int i;
++
++ switch (type) {
++ case 0: /* unicode */
++ for (i = 0; i < length; i++)
++ *to++ = (*from++ & 0x7f);
++ *to = 0;
++ break;
++ case 1: /* BCD Plus */
++ for (i = 0; i < length; i++)
++ *to++ = bcdplus[*from++ & 0x0f];
++ *to = 0;
++ break;
++ case 2: /* packed ascii *//* if not a mult. of 3 this will run over */
++ for (i = 0; i < length; i += 3) {
++ *to++ = *from & 0x3f;
++ *to++ = *from >> 6 | ((*(from+1) & 0xf) << 2);
++ from++;
++ *to++ = *from >> 4 | ((*(from+1) & 0x3) << 4);
++ from++;
++ *to++ = (*from++ >> 2) & 0x3f;
++ }
++ *to = 0;
++ break;
++ case 3: /* normal */
++ if (length > 1)
++ memcpy(to, from, length);
++ to[length] = 0;
++ break;
++ }
++}
++
++/* IPMI V1.5 Section 30 */
++static const int exps[] =
++ { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
++
++/* Return 0 for fan, 2 for temp, 3 for voltage
++ We could make it variable based on the accuracy (= log10(m * 10**k2));
++ this would work for /proc output, however libsensors resolution
++ is statically set in lib/chips.c */
++static int decplaces(struct sdrdata *sd)
++{
++ switch (sd->stype) {
++ case STYPE_TEMP:
++ return 2;
++ case STYPE_CURR:
++ case STYPE_VOLT:
++ return 3;
++ case STYPE_FAN:
++ default:
++ return 0;
++ }
++}
++
++/* convert a raw value to a reading. IMPI V1.5 Section 30 */
++static long conv_val(int value, struct sdrdata *sd)
++{
++ u8 k1, k2;
++ long r;
++
++ r = value * sd->m;
++ k1 = sd->k & 0x0f;
++ k2 = sd->k >> 4;
++ if (k1 < 8)
++ r += sd->b * exps[k1];
++ else
++ r += sd->b / exps[16 - k1];
++ r *= exps[decplaces(sd)];
++ if (k2 < 8) {
++ if (sd->linear != 7)
++ r *= exps[k2];
++ else
++ /* this will always truncate to 0: r = 1 / (exps[k2] * r); */
++ r = 0;
++ } else {
++ if (sd->linear != 7)
++ r /= exps[16 - k2];
++ else {
++ if (r != 0)
++ /* 1 / x * 10 ** (-m) == 10 ** m / x */
++ r = exps[16 - k2] / r;
++ else
++ r = 0;
++ }
++ }
++
++ return r;
++}
++
++static const char *threshold_text[] = {
++ "upper non-recoverable threshold",
++ "upper critical threshold",
++ "upper non-critical threshold",
++ "lower non-recoverable threshold",
++ "lower critical threshold",
++ "lower non-critical threshold",
++ "positive-going hysteresis",
++ "negative-going hysteresis" /* unused */
++};
++
++/* select two out of the 8 possible readable thresholds, and place indexes into the limits
++ array into lim1 and lim2. Set writable flags */
++static void ipmisensors_select_thresholds(struct sdrdata *sd)
++{
++ u8 capab = sd->capab;
++ u16 mask = sd->thresh_mask;
++ int tmp;
++
++ sd->lim1 = -1;
++ sd->lim2 = -1;
++ sd->lim1_write = 0;
++ sd->lim2_write = 0;
++
++ if (((capab & 0x0c) == 0x04) || /* readable thresholds ? */
++ ((capab & 0x0c) == 0x08)) {
++ /* select upper threshold */
++ if (mask & 0x10) { /* upper crit */
++ sd->lim1 = 1;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x1000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x20) { /* upper non-recov */
++ sd->lim1 = 0;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x2000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x08) { /* upper non-crit */
++ sd->lim1 = 2;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0800))
++ sd->lim1_write = 1;
++ }
++
++ /* select lower threshold */
++ if ((((capab & 0x30) == 0x10) || /* readable ? */
++ ((capab & 0x30) == 0x20)) && /* pos hyst */
++ sd->stype == STYPE_TEMP)
++ sd->lim2 = 6;
++ else if (mask & 0x02) { /* lower crit */
++ sd->lim2 = 4;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0200))
++ sd->lim2_write = 1;
++ } else if (mask & 0x04) { /* lower non-recov */
++ sd->lim2 = 3;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0400))
++ sd->lim2_write = 1;
++ } else if (mask & 0x01) { /* lower non-crit */
++ sd->lim2 = 5;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0100))
++ sd->lim2_write = 1;
++ }
++ }
++
++ /* swap lim1/lim2 if m < 0 or function is 1/x (but not both!) */
++ if ((sd->m < 0 && sd->linear != 7) || (sd->m >= 0 && sd->linear == 7)) {
++ tmp = sd->lim1;
++ sd->lim1 = sd->lim2;
++ sd->lim2 = tmp;
++ }
++
++ if (sd->lim1 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for upper limit\n",
++ threshold_text[sd->lim1]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable upper limit\n");
++
++ if (sd->lim2 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for lower limit\n",
++ threshold_text[sd->lim2]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable lower limit\n");
++}
++
++/************* sysfs callback functions *********/
++static ssize_t show_update_period(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ return snprintf(buf, 20, "%d\n", aattr->bmc->update_period);
++}
++
++static ssize_t store_update_period(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ aattr->bmc->update_period = simple_strtoul(buf, NULL, 10);;
++ return count;
++};
++
++static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ return snprintf(buf, 20, "%ld\n",
++ conv_val(sattr->sdr->reading, sattr->sdr));
++}
++
++static ssize_t show_sensor_max(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long max = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim1 >= 0)
++ max = conv_val(sattr->sdr->limits[sattr->sdr->lim1],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", max);
++}
++
++static ssize_t show_sensor_min(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long min = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim2 >= 0)
++ min = conv_val(sattr->sdr->limits[sattr->sdr->lim2],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", min);
++};
++
++static ssize_t show_sensor_label(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ u8 label[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ ipmisensors_sprintf(label, sattr->sdr->id, sattr->sdr->string_type,
++ sattr->sdr->id_length);
++ return snprintf(buf, 20, "%s\n", label);
++};
++
++static ssize_t store_sensor_max(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set max on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim1);
++ return count;
++};
++
++static ssize_t store_sensor_min(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set min on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim2);
++ return count;
++};
++
++static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++ return snprintf(buf, 20, "%d\n", aattr->bmc->alarms);
++};
++
++static ssize_t show_name(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ return snprintf(buf, 20, "%s\n", driver_data.driver_name);
++};
++
++/* work function to build the sysfs entries using the ipmi sdrs */
++static void ipmisensors_build_sysfs(struct work_struct *work)
++{
++ int temps = 0, volts = 0, currs = 0, fans = 0;
++ struct sdrdata *cursor, *next;
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, sysfs_work);
++
++ /* find and create entries for each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++
++ cursor->attr_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_max_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_min_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ return;
++ }
++ }
++
++ if (cursor->attr_name == NULL || cursor->attr_max_name == NULL
++ || cursor->attr_min_name == NULL
++ || cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "temp%d_input", ++temps);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "temp%d_max", temps);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "temp%d_min", temps);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "temp%d_label", temps);
++ break;
++ case (STYPE_VOLT):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "in%d_input", ++volts);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "in%d_max", volts);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "in%d_min", volts);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "in%d_label", volts);
++ break;
++ case (STYPE_CURR):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "curr%d_input", ++currs);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "curr%d_max", currs);
++ sprintf(cursor->attr_min_name, "curr%d_min", currs);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "curr%d_label", currs);
++ break;
++ case (STYPE_FAN):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "fan%d_input", ++fans);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "fan%d_max", fans);
++ sprintf(cursor->attr_min_name, "fan%d_min", fans);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "fan%d_label", fans);
++ break;
++ default:
++ printk(KERN_INFO "ipmisensors: unkown sensor type\n");
++ continue;
++ }
++
++ cursor->attr.dev_attr.attr.name = cursor->attr_name;
++ cursor->attr.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr.dev_attr.show = show_sensor;
++ cursor->attr.dev_attr.store = NULL;
++ cursor->attr.sdr = cursor;
++
++ cursor->attr_min.dev_attr.attr.name = cursor->attr_min_name;
++ cursor->attr_min.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_min.dev_attr.show = show_sensor_min;
++ cursor->attr_min.sdr = cursor;
++
++ if (cursor->lim2_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_min.dev_attr.store = store_sensor_min;
++ cursor->attr_min.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_min.dev_attr.store = NULL;
++ cursor->attr_min.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ cursor->attr_max.dev_attr.attr.name = cursor->attr_max_name;
++ cursor->attr_max.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_max.dev_attr.show = show_sensor_max;
++ cursor->attr_max.sdr = cursor;
++
++ if (cursor->lim1_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_max.dev_attr.store = store_sensor_max;
++ cursor->attr_max.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_max.dev_attr.store = NULL;
++ cursor->attr_max.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label.dev_attr.attr.name =
++ cursor->attr_label_name;
++ cursor->attr_label.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr_label.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_label.dev_attr.show = show_sensor_label;
++ cursor->attr_label.dev_attr.store = NULL;
++ cursor->attr_label.sdr = cursor;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registering sensor %d: (type 0x%.2x) "
++ "(fmt=%d; m=%d; b=%d; k1=%d; k2=%d; cap=0x%.2x; mask=0x%.4x)\n",
++ cursor->number, cursor->stype, cursor->format, cursor->m,
++ cursor->b, cursor->k & 0xf, cursor->k >> 4,
++ cursor->capab, cursor->thresh_mask);
++
++ if (cursor->id_length > 0) {
++ ipmisensors_sprintf(id, cursor->id, cursor->string_type,
++ cursor->id_length);
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label temp%d \"%s\"\n",
++ temps, id);
++ break;
++ case (STYPE_VOLT):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label in%d \"%s\"\n",
++ volts, id);
++ break;
++ case (STYPE_CURR):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label curr%d \"%s\"\n",
++ currs, id);
++ break;
++ case (STYPE_FAN):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label fan%d \"%s\"\n",
++ fans, id);
++ break;
++ }
++ }
++
++ ipmisensors_select_thresholds(cursor);
++
++ if (cursor->linear != 0 && cursor->linear != 7) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: nonlinear function 0x%.2x unsupported, expect bad results\n",
++ cursor->number, cursor->linear);
++ }
++
++ if ((cursor->format & 0x03) == 0x02) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: 1's complement format unsupported, expect bad results\n",
++ cursor->number);
++ } else if ((cursor->format & 0x03) == 0x03) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: threshold sensor only, no readings available",
++ cursor->number);
++ }
++
++ if (cursor->lim1_write || cursor->lim2_write)
++ cursor->attr.dev_attr.attr.mode = 0644;
++ else
++ cursor->attr.dev_attr.attr.mode = 0444;
++
++ if (device_create_file(bmc->dev, &cursor->attr.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_min.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_max.dev_attr) < 0
++ || (cursor->id_length >
++ 0 ? device_create_file(bmc->dev,
++ &cursor->attr_label.dev_attr) <
++ 0 : 0)
++ ) {
++ printk(KERN_INFO
++ "ipmisensors: sysfs file creation failed for SDR %d (%s).\n",
++ cursor->number, cursor->id);
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++ }
++
++ bmc->alarms_attr.dev_attr.attr.name = "alarms";
++ bmc->alarms_attr.dev_attr.attr.mode = S_IRUGO;
++ bmc->alarms_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->alarms_attr.dev_attr.show = show_alarms;
++ bmc->alarms_attr.dev_attr.store = NULL;
++ bmc->alarms_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->alarms_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'alarms'");
++ return;
++ }
++
++ bmc->name_attr.attr.name = "name";
++ bmc->name_attr.attr.mode = S_IRUGO;
++ bmc->name_attr.attr.owner = THIS_MODULE;
++ bmc->name_attr.show = show_name;
++
++ if (device_create_file(bmc->dev, &bmc->name_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'name'");
++ return;
++ }
++
++ bmc->update_attr.dev_attr.attr.name = "update_period";
++ bmc->update_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ bmc->update_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->update_attr.dev_attr.show = show_update_period;
++ bmc->update_attr.dev_attr.store = store_update_period;
++ bmc->update_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->update_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'update_period'");
++ return;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registered %d temp, %d volt, %d current, %d fan sensors\n",
++ temps, volts, currs, fans);
++
++ /* This completes the initialization. We can now kickoff the
++ * periodic update of the bmc sensor's values by scheduling
++ * the first work.
++ */
++ queue_work(ipmisensors_workqueue, &bmc->update_work.work);
++
++}
++
++/**
++ * Process an SDR response message, save the SDRs we like in the sdr
++ * list for the given BMC.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_sdr_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ u16 record;
++ int type;
++ int stype;
++ int id_length;
++ int i;
++ int ipmi_ver = 0;
++ unsigned char *data;
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct sdrdata *sdr;
++
++ if (msg->data[0] != 0) {
++ /* cut request in half and try again */
++ bmc->ipmi_sdr_partial_size /= 2;
++ if (bmc->ipmi_sdr_partial_size < 8) {
++ printk(KERN_INFO
++ "ipmisensors: IPMI buffers too small, giving up\n");
++ bmc->state = STATE_DONE;
++ return;
++ }
++ printk(KERN_DEBUG
++ "ipmisensors: Reducing SDR request size to %d\n",
++ bmc->ipmi_sdr_partial_size);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ if (bmc->ipmi_sdr_partial_size < IPMI_SDR_SIZE) {
++ if (bmc->rx_msg_data_offset == 0) {
++ memcpy(bmc->rx_msg_data, msg->data,
++ bmc->ipmi_sdr_partial_size + 3);
++ bmc->rx_msg_data_offset =
++ bmc->ipmi_sdr_partial_size + 3;
++ } else {
++ memcpy(bmc->rx_msg_data + bmc->rx_msg_data_offset,
++ msg->data + 3, bmc->ipmi_sdr_partial_size);
++ bmc->rx_msg_data_offset += bmc->ipmi_sdr_partial_size;
++ }
++ if (bmc->rx_msg_data_offset > bmc->rx_msg_data[7] + 7) {
++ /* got last chunk */
++ bmc->rx_msg_data_offset = 0;
++ data = bmc->rx_msg_data;
++ } else {
++ /* get more */
++ record =
++ (bmc->rx_msg_data[4] << 8) | bmc->rx_msg_data[3];
++ ipmisensors_get_sdr(bmc, bmc->resid, record,
++ bmc->rx_msg_data_offset - 3);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ } else {
++ /* got it in one chunk */
++ data = msg->data;
++ }
++
++ bmc->nextrecord = (data[2] << 8) | data[1];
++
++ /* If the ipmi version is 0.9 we have to remap some things.
++ * Yes this is very ugly, but we aren't the ones who
++ * implemented an incomplete spec!
++ */
++ ipmi_ver = data[5];
++
++ type = data[6];
++ /* known SDR type */
++ if (type == 1 || type == 2) {
++ stype = data[(ipmi_ver == 0x90 ? 16 : 15)];
++ /* known sensor type */
++ if (stype <= STYPE_MAX) {
++ if (data[(ipmi_ver == 0x90 ? 17 : 16)] != 0x01) {
++ if (type == 1)
++ ipmisensors_sprintf(id, &data[51],
++ data[50] >> 6,
++ data[50] & 0x1f);
++ else
++ ipmisensors_sprintf(id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 :
++ 35)],
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] >> 6,
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] & 0x1f);
++ printk(KERN_INFO
++ "ipmisensors: skipping non-threshold sensor \"%s\"\n",
++ id);
++ } else {
++ /* add entry to sdrd table */
++ sdr = ipmisensors_new_sdr();
++ if (!sdr) {
++ printk(KERN_ERR
++ "ipmisensors: could not allocate memory for new SDR");
++ return;
++ }
++ sdr->bmc = bmc;
++ sdr->stype = stype;
++ sdr->number = data[10];
++ sdr->capab = data[(ipmi_ver == 0x90 ? 15 : 14)];
++ sdr->thresh_mask =
++ (((u16) data[(ipmi_ver == 0x90 ? 21 : 22)])
++ << 8) | data[21];
++ if (type == 1) {
++ sdr->format =
++ data[(ipmi_ver ==
++ 0x90 ? 22 : 24)] >> 6;
++ sdr->linear =
++ data[(ipmi_ver ==
++ 0x90 ? 25 : 26)] & 0x7f;
++ sdr->m =
++ data[(ipmi_ver == 0x90 ? 26 : 27)];
++ sdr->m |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 27 : 28)]
++ & 0xc0)) << 2;
++ if (sdr->m & 0x0200) {
++ /* sign extend */
++ sdr->m |= 0xfc00;
++ }
++ sdr->b =
++ data[(ipmi_ver == 0x90 ? 28 : 29)];
++ sdr->b |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 29 : 30)]
++ & 0xc0)) << 2;
++ if (sdr->b & 0x0200) {
++ /* sign extend */
++ sdr->b |= 0xfc00;
++ }
++ sdr->k =
++ data[(ipmi_ver == 0x90 ? 31 : 32)];
++ sdr->nominal =
++ data[(ipmi_ver == 0x90 ? 33 : 34)];
++ for (i = 0; i < SDR_LIMITS; i++) {
++ /* assume readable */
++ sdr->limits[i] =
++ data[(ipmi_ver ==
++ 0x90 ? 40 : 39) + i];
++ }
++ sdr->string_type = data[50] >> 6;
++ id_length = data[50] & 0x1f;
++ memcpy(sdr->id, &data[51], id_length);
++ sdr->id_length = id_length;
++ } else {
++ sdr->m = 1;
++ sdr->b = 0;
++ sdr->k = 0;
++ sdr->string_type =
++ data[(ipmi_ver ==
++ 0x90 ? 29 : 34)] >> 6;
++ id_length = data[34] & 0x1f;
++ if (id_length > 0) {
++ memcpy(sdr->id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 : 35)],
++ id_length);
++ }
++ sdr->id_length = id_length;
++ /* limits?? */
++ if (ipmi_ver == 0x90) {
++ memcpy(sdr->id,
++ &data[30], id_length);
++ sdr->id_length = id_length;
++ }
++ }
++ ipmisensors_add_sdr(bmc, sdr);
++ }
++ }
++ /* peek at the other SDR types */
++ } else if (type == 0x10 || type == 0x11 || type == 0x12) {
++ ipmisensors_sprintf(id, data + 19, data[18] >> 6,
++ data[18] & 0x1f);
++ if (type == 0x10) {
++ printk(KERN_INFO
++ "ipmisensors: Generic Device acc=0x%x; slv=0x%x; lun=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[13], id);
++ } else if (type == 0x11) {
++ printk(KERN_INFO
++ "ipmisensors: FRU Device acc=0x%x; slv=0x%x; log=0x%x; ch=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[11], data[13],
++ id);
++ } else {
++ printk(KERN_INFO
++ "ipmisensors: Mgmt Ctllr Device slv=0x%x; \"%s\"\n",
++ data[8], id);
++ }
++ } else if (type == 0x14) {
++ printk(KERN_INFO
++ "ipmisensors: Message Channel Info Records:\n");
++ for (i = 0; i < 8; i++) {
++ printk(KERN_INFO "ipmisensors: Channel %d info 0x%x\n",
++ i, data[9 + i]);
++ }
++ } else {
++ printk(KERN_INFO "ipmisensors: Skipping SDR type 0x%x\n", type);
++ }
++ if (ipmi_ver != 0x90) {
++ if (bmc->nextrecord >= 6224) {
++ /*YJ stop sensor scan on poweredge 1750 */
++ bmc->nextrecord = 0xffff;
++ }
++ }
++
++ if (bmc->nextrecord == 0xFFFF) {
++ if (bmc->sdr_count == 0) {
++ printk(KERN_INFO
++ "ipmisensors: No recognized sensors found.\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_INFO "ipmisensors: all sensors detected\n");
++ bmc->state = STATE_SYSTABLE;
++
++ /* Schedule sysfs build/registration work */
++ INIT_WORK(&bmc->sysfs_work, ipmisensors_build_sysfs);
++ queue_work(ipmisensors_workqueue, &bmc->sysfs_work);
++ }
++ } else {
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ }
++}
++
++/**
++ * Process incoming messages based on internal state
++ *
++ * @bmc: the bmc the message is from.
++ * @msg: the ipmi message to process.
++ */
++static void ipmisensors_rcv_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ switch (bmc->state) {
++ case STATE_INIT:
++ case STATE_RESERVE:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got first resid 0x%.4x\n",
++ bmc->resid);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_SDR:
++ case STATE_SDRPARTIAL:
++ ipmisensors_rcv_sdr_msg(bmc, msg);
++ break;
++
++ case STATE_READING:
++ ipmisensors_rcv_reading_msg(bmc, msg);
++ break;
++
++ case STATE_UNCANCEL:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got new resid 0x%.4x\n",
++ bmc->resid);
++
++ bmc->rx_msg_data_offset = 0;
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_DONE:
++ case STATE_SYSTABLE:
++ break;
++ default:
++ bmc->state = STATE_INIT;
++ }
++}
++
++/**
++ * Callback to handle a received IPMI message from a given BMC.
++ *
++ * @msg: the received message.
++ * @handler_data: a pointer to the particular bmc ipmisensors_bmc_data struct.
++ */
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data)
++{
++ struct ipmisensors_bmc_data *bmc =
++ (struct ipmisensors_bmc_data *)user_msg_data;
++
++ if (msg->msg.data[0] != 0)
++ printk(KERN_WARNING
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x\n",
++ msg->msg.data[0], msg->msg.netfn, msg->msg.cmd);
++
++ if (bmc != NULL && ipmisensors_intf_registered(bmc->interface_id)) {
++ if (bmc->state == STATE_SDR &&
++ msg->msg.data[0] == IPMI_INVALID_RESERVATION_ID) {
++ /* reservation cancelled, get new resid */
++ if (++bmc->errorcount > 275) {
++ printk(KERN_ERR
++ "ipmisensors: Too many reservations cancelled, giving up\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_DEBUG
++ "ipmisensors: resid 0x%04x cancelled, getting new one\n",
++ bmc->resid);
++
++ ipmisensors_reserve_sdr(bmc);
++ bmc->state = STATE_UNCANCEL;
++ }
++ } else if (msg->msg.data[0] != IPMI_CC_NO_ERROR &&
++ msg->msg.data[0] != IPMI_ERR_RETURNING_REQ_BYTES &&
++ msg->msg.data[0] != IPMI_ERR_PROVIDING_RESPONSE) {
++ printk(KERN_ERR
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x; state = %d; probably fatal.\n",
++ msg->msg.data[0], msg->msg.netfn & 0xfe,
++ msg->msg.cmd, bmc->state);
++ } else {
++ printk(KERN_DEBUG "ipmisensors: received message\n");
++ ipmisensors_rcv_msg(bmc, &msg->msg);
++ }
++
++ } else {
++ printk(KERN_WARNING
++ "ipmisensors: Response for non-registered BMC\n");
++ if (bmc != NULL)
++ printk(KERN_DEBUG "ipmisensors: BMC ID: %d\n",
++ bmc->interface_id);
++ else
++ printk(KERN_DEBUG "ipmisensors: BMC NULL!\n");
++ }
++
++ ipmi_free_recv_msg(msg);
++}
++
++/****** IPMI Interface Initialization ******/
++
++/**
++ * Return true if the given ipmi interface has been registered.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static int ipmisensors_intf_registered(int ipmi_intf)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Return true if the given BMC has been registered.
++ *
++ * @bmc: The BMC device.
++ */
++static int ipmisensors_bmc_registered(struct device *bmc)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->dev == bmc) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Register new IPMI BMC interface. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address)
++{
++ int error;
++
++ /* allocate a new ipmisensors_bmc_data struct */
++
++ struct ipmisensors_bmc_data *bmc = (struct ipmisensors_bmc_data *)
++ kmalloc(sizeof(struct ipmisensors_bmc_data), GFP_KERNEL);
++
++ /* initialize members */
++ INIT_LIST_HEAD(&bmc->sdrs);
++ bmc->interface_id = ipmi_intf;
++
++ bmc->address = *address;
++
++ bmc->sdr_count = 0;
++ bmc->msgid = 0;
++ bmc->ipmi_sdr_partial_size = IPMI_CHUNK_SIZE;
++ bmc->state = STATE_INIT;
++ bmc->errorcount = 0;
++ bmc->rx_msg_data_offset = 0;
++ bmc->dev = ipmi_get_bmcdevice(ipmi_intf);
++
++ /* default to 3 second min update interval */
++ bmc->update_period = 3;
++
++ if (bmc->dev == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error, couldn't get BMC device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Create IPMI messaging interface user */
++ error = ipmi_create_user(bmc->interface_id, &driver_data.ipmi_hndlrs,
++ bmc, &bmc->user);
++ if (error < 0) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register user with ipmi interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC as a HWMON class device */
++ bmc->class_dev = hwmon_device_register(bmc->dev);
++
++ if (IS_ERR(bmc->class_dev)) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register hwmon class device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC in the driver */
++ if (ipmisensors_bmc_registered(bmc->dev)) {
++ printk(KERN_ERR
++ "ipmisensors: BMC on interface %d already registered\n",
++ bmc->interface_id);
++ hwmon_device_unregister(bmc->class_dev);
++ kfree(bmc);
++ return;
++ }
++
++ ipmi_get_version(bmc->user, &bmc->ipmi_version_major,
++ &bmc->ipmi_version_minor);
++
++ /* finally add the new bmc data to the bmc data list */
++ list_add_tail(&bmc->list, &driver_data.bmc_data);
++ driver_data.interfaces++;
++
++ printk(KERN_INFO
++ "ipmisensors: Registered IPMI %d.%d BMC over interface %d\n",
++ bmc->ipmi_version_major,
++ bmc->ipmi_version_minor, bmc->interface_id);
++
++ /* Send a reserve SDR command to the bmc */
++ ipmisensors_reserve_sdr(bmc);
++
++ /* initialize the bmc's update work struct */
++ INIT_DELAYED_WORK(&bmc->update_work, ipmisensors_update_bmc);
++}
++
++/**
++ * Callback for when an IPMI BMC is gone. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_unregister_bmc(int ipmi_intf)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ list_del(&cursor->list);
++ printk(KERN_DEBUG
++ "ipmisensors: cancelling queued work\n");
++ /* cancel update work queued for this bmc */
++ cancel_delayed_work(&cursor->update_work);
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev,
++ &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev,
++ &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ driver_data.interfaces--;
++ }
++ }
++
++}
++
++/**
++ * Unregister all registered bmcs.
++ */
++static void ipmisensors_unregister_bmc_all(void)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ list_del(&cursor->list);
++
++ /* cancel update work queued for this bmc */
++ printk(KERN_DEBUG "ipmisensors: cancelling queued work\n");
++ cancel_delayed_work(&cursor->update_work);
++
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev, &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev, &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ }
++
++ driver_data.interfaces = 0;
++}
++
++/**
++ * Callback for when a new IPMI SMI type interface is found.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_new_smi(int if_num, struct device *dev)
++{
++ struct ipmi_addr smi_address = {
++ IPMI_SYSTEM_INTERFACE_ADDR_TYPE,
++ IPMI_BMC_CHANNEL,
++ {0},
++ };
++
++ /* calls the generic new interface function */
++ ipmisensors_register_bmc(if_num, &smi_address);
++}
++
++/**
++ * Callback for when an exisiting IPMI SMI type interface is gone.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_smi_gone(int if_num)
++{
++ if (driver_data.interfaces > 0) {
++ ipmisensors_unregister_bmc(if_num);
++ }
++}
++
++/**
++ * Initialize the module.
++ */
++static int __init ipmisensors_init(void)
++{
++ int error;
++ printk(KERN_INFO "ipmisensors - IPMI BMC sensors interface\n");
++
++ /* init cache managers */
++ driver_data.sdrdata_cache =
++ kmem_cache_create("ipmisensors_sdrdata", sizeof(struct sdrdata), 0,
++ 0, NULL, NULL);
++ driver_data.sysfsattr_cache =
++ kmem_cache_create("ipmisensors_sysfsattr",
++ sizeof(struct ipmisensors_device_attribute), 0, 0,
++ NULL, NULL);
++
++ if (!driver_data.sdrdata_cache || !driver_data.sysfsattr_cache) {
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++ return -ENOMEM;
++ }
++
++ /* register IPMI interface callback(s) */
++ error = ipmi_smi_watcher_register(&driver_data.smi_watcher);
++ if (error) {
++ printk(KERN_WARNING
++ "ipmisensors: can't register smi watcher\n");
++ return error;
++ }
++
++ /* create work queue, keep it simple, single-threaded */
++ ipmisensors_workqueue =
++ create_singlethread_workqueue("ipmisensors_workqueue");
++
++ return 0;
++}
++
++/**
++ * Cleanup
++ */
++static void ipmisensors_cleanup(void)
++{
++ /* start cleanup */
++ cleanup = 1;
++
++ /* unregister bmcs */
++ printk(KERN_DEBUG "ipmisensors: unregister bmcs\n");
++ ipmi_smi_watcher_unregister(&driver_data.smi_watcher);
++ ipmisensors_unregister_bmc_all();
++
++ /* flush & destroy work queue */
++ printk(KERN_DEBUG "ipmisensors: destroy workqueue\n");
++ flush_workqueue(ipmisensors_workqueue);
++ destroy_workqueue(ipmisensors_workqueue);
++
++ /* remove cache managers */
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++}
++
++/**
++ * Cleanup and exit the module
++ */
++static void __exit ipmisensors_exit(void)
++{
++ ipmisensors_cleanup();
++ printk(KERN_DEBUG "ipmisensors: cleanup finished\n");
++}
++
++MODULE_AUTHOR("Yani Ioannou <yani.ioannou@gmail.com>");
++MODULE_DESCRIPTION("IPMI BMC sensors");
++MODULE_LICENSE("GPL");
++
++module_init(ipmisensors_init);
++module_exit(ipmisensors_exit);
+diff -rduNp linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.h linux-2.6.20.3/drivers/hwmon/ipmisensors.h
+--- linux-2.6.20.3.orig/drivers/hwmon/ipmisensors.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.20.3/drivers/hwmon/ipmisensors.h 2007-03-14 14:41:23.000000000 +0100
+@@ -0,0 +1,240 @@
++/*
++ * ipmisensors.h - lm_sensors interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/ipmi.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/workqueue.h>
++
++/* SDR defs */
++#define STYPE_TEMP 0x01
++#define STYPE_VOLT 0x02
++#define STYPE_CURR 0x03
++#define STYPE_FAN 0x04
++
++#define SDR_LIMITS 8
++#define SDR_MAX_ID_LENGTH 16
++#define SDR_MAX_UNPACKED_ID_LENGTH ((SDR_MAX_ID_LENGTH * 4 / 3) + 2)
++
++/* the last sensor type we are interested in */
++#define STYPE_MAX 4
++
++#define IPMI_SDR_SIZE 67
++#define IPMI_CHUNK_SIZE 16
++
++#define MAX_FILENAME_LENGTH 30
++
++struct ipmisensors_device_attribute {
++ struct device_attribute dev_attr;
++ struct sdrdata *sdr;
++};
++#define to_ipmisensors_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_device_attribute, dev_attr)
++
++#define IPMISENSORS_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
++struct ipmisensors_attribute sensor_dev_attr_##_name = { \
++ .dev_attr = __ATTR(_name,_mode,_show,_store), \
++ .index = _index, \
++}
++
++struct ipmisensors_bmc_device_attribute {
++ struct device_attribute dev_attr;
++ struct ipmisensors_bmc_data *bmc;
++};
++#define to_ipmisensors_bmc_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_bmc_device_attribute, dev_attr)
++
++/**
++ * &struct_sdrdata stores the IPMI Sensor Data Record (SDR) data, as recieved from the BMC, along with the corresponding sysfs attributes
++ */
++struct sdrdata {
++ struct list_head list;
++ /* retrieved from SDR, not expected to change */
++ /* Sensor Type Code */
++ u8 stype;
++ u8 number;
++ /* Sensor Capability Code */
++ u8 capab;
++ u16 thresh_mask;
++ u8 format;
++ u8 linear;
++ s16 m;
++ s16 b;
++ u8 k;
++ u8 nominal;
++ u8 limits[SDR_LIMITS];
++ /* index into limits for reported upper and lower limit */
++ int lim1, lim2;
++ u8 lim1_write, lim2_write;
++ u8 string_type;
++ u8 id_length;
++ u8 id[SDR_MAX_ID_LENGTH];
++ /* retrieved from reading */
++ u8 reading;
++ u8 status;
++ u8 thresholds;
++ /* sensor's bmc */
++ struct ipmisensors_bmc_data *bmc;
++ /* sysfs entries */
++ struct ipmisensors_device_attribute attr;
++ char *attr_name;
++ struct ipmisensors_device_attribute attr_min;
++ char *attr_min_name;
++ struct ipmisensors_device_attribute attr_max;
++ char *attr_max_name;
++ struct ipmisensors_device_attribute attr_label;
++ char *attr_label_name;
++
++};
++
++/**
++ * &struct_ipmisensors_data stores the data for the ipmisensors driver.
++ */
++struct ipmisensors_data {
++ /* Driver struct */
++ char *driver_name;
++
++ /* Linked list of ipmisensors_bmc_data structs, one for each BMC */
++ struct list_head bmc_data;
++
++ /* Number of ipmi interfaces (and hence ipmisensors_data structs). */
++ int interfaces;
++
++ /* IPMI kernel interface - SMI watcher */
++ struct ipmi_smi_watcher smi_watcher;
++
++ /* IPMI kernel interface - user handlers */
++ struct ipmi_user_hndl ipmi_hndlrs;
++
++ /* Cache manager for sdrdata cache */
++ struct kmem_cache *sdrdata_cache;
++
++ /* Cache manager for ipmi_sensor_device_attribute cache */
++ struct kmem_cache *sysfsattr_cache;
++};
++
++/**
++ * &states: enumeration of state codes for a bmc specific ipmisensors
++ */
++enum states {
++ STATE_INIT,
++ STATE_RESERVE,
++ STATE_SDR,
++ STATE_SDRPARTIAL,
++ STATE_READING,
++ STATE_UNCANCEL,
++ STATE_SYSTABLE,
++ STATE_DONE
++};
++
++/**
++ * &struct_ipmisensors_bmc_data stores the data for a particular IPMI BMC.
++ */
++struct ipmisensors_bmc_data {
++ struct list_head list;
++
++ /* The IPMI interface number */
++ int interface_id;
++
++ /* The IPMI address */
++ struct ipmi_addr address;
++
++ /* List of sdrdata structs (sdrs) recieved from the BMC */
++ struct list_head sdrs;
++
++ /* Count of the number of sdrs stored in the sdr list */
++ int sdr_count;
++
++ /* next message id */
++ int msgid;
++
++ /* The ipmi interface 'user' used to access this particular bmc */
++ ipmi_user_t user;
++
++ /* BMC IPMI Version (major) */
++ unsigned char ipmi_version_major;
++
++ /* BMC IPMI Version (minor) */
++ unsigned char ipmi_version_minor;
++
++ /* The size of the SDR request message */
++ int ipmi_sdr_partial_size;
++
++ /* transmit message buffer */
++ struct kernel_ipmi_msg tx_message;
++
++ /* ipmi transmited data buffer */
++ unsigned char tx_msg_data[IPMI_MAX_MSG_LENGTH + 50]; /* why the +50 in bmcsensors? */
++
++ /* ipmi recieved data buffer */
++ unsigned char rx_msg_data[IPMI_MAX_MSG_LENGTH + 50];
++
++ /* current recieve buffer offset */
++ int rx_msg_data_offset;
++
++ /* The id of then next SDR record to read during update cycle */
++ u16 nextrecord;
++
++ /* BMC SDR Reservation ID */
++ u16 resid;
++
++ /* Alarm status */
++ u8 alarms;
++
++ /* The cumalative error count for this bmc */
++ int errorcount;
++
++ /* The current state of this bmc w.r.t. ipmisensors (see enum states) */
++ int state;
++
++ /* The current sdr for which a reading is pending */
++ struct sdrdata *current_sdr;
++
++ /* The BMC's device struct */
++ struct device *dev;
++
++ /* hwmon class device */
++ struct class_device *class_dev;
++
++ /* hwmon device name */
++ struct device_attribute name_attr;
++
++ /* alarms attribute */
++ struct ipmisensors_bmc_device_attribute alarms_attr;
++
++ /* update_period attribute */
++ struct ipmisensors_bmc_device_attribute update_attr;
++
++ /* lower bound on time between updates (in seconds) */
++ unsigned int update_period;
++
++ /* semaphore used to do a headcount of the SDR readings we are waiting
++ * on in a given bmc update */
++ struct semaphore update_semaphore;
++
++ /* bmc's work struct for updating sensors */
++ struct delayed_work update_work;
++
++ /* bmc's work struct for building the sysfs workqueue */
++ struct work_struct sysfs_work;
++};
+diff -rduNp linux-2.6.20.3.orig/include/linux/ipmi.h linux-2.6.20.3/include/linux/ipmi.h
+--- linux-2.6.20.3.orig/include/linux/ipmi.h 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/include/linux/ipmi.h 2007-03-14 14:23:02.000000000 +0100
+@@ -300,6 +300,9 @@ int ipmi_create_user(unsigned int
+ safe, too. */
+ int ipmi_destroy_user(ipmi_user_t user);
+
++/* Get the IPMI BMC's device struct */
++struct device *ipmi_get_bmcdevice(int ipmi_intf);
++
+ /* Get the IPMI version of the BMC we are talking to. */
+ void ipmi_get_version(ipmi_user_t user,
+ unsigned char *major,
+diff -rduNp linux-2.6.20.3.orig/include/linux/ipmi_msgdefs.h linux-2.6.20.3/include/linux/ipmi_msgdefs.h
+--- linux-2.6.20.3.orig/include/linux/ipmi_msgdefs.h 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.3/include/linux/ipmi_msgdefs.h 2007-03-14 14:23:02.000000000 +0100
+@@ -45,6 +45,7 @@
+
+ #define IPMI_NETFN_APP_REQUEST 0x06
+ #define IPMI_NETFN_APP_RESPONSE 0x07
++#define IPMI_GET_DEVICE_GUID_CMD 0x08
+ #define IPMI_GET_DEVICE_ID_CMD 0x01
+ #define IPMI_COLD_RESET_CMD 0x02
+ #define IPMI_WARM_RESET_CMD 0x03
+@@ -57,6 +58,11 @@
+ #define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
+ #define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
+ #define IPMI_GET_CHANNEL_INFO_CMD 0x42
++#define IPMI_RESERVE_SDR 0x22
++#define IPMI_GET_SDR 0x23
++#define IPMI_GET_SENSOR_STATE_READING 0x2D
++#define IPMI_SET_SENSOR_HYSTERESIS 0x24
++#define IPMI_SET_SENSOR_THRESHOLD 0x26
+
+ #define IPMI_NETFN_STORAGE_REQUEST 0x0a
+ #define IPMI_NETFN_STORAGE_RESPONSE 0x0b
+@@ -79,10 +85,13 @@
+ #define IPMI_NODE_BUSY_ERR 0xc0
+ #define IPMI_INVALID_COMMAND_ERR 0xc1
+ #define IPMI_TIMEOUT_ERR 0xc3
++#define IPMI_INVALID_RESERVATION_ID 0xc5
+ #define IPMI_ERR_MSG_TRUNCATED 0xc6
+ #define IPMI_REQ_LEN_INVALID_ERR 0xc7
+ #define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
+ #define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
++#define IPMI_ERR_RETURNING_REQ_BYTES 0xca
++#define IPMI_ERR_PROVIDING_RESPONSE 0xce
+ #define IPMI_LOST_ARBITRATION_ERR 0x81
+ #define IPMI_BUS_ERR 0x82
+ #define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.1-007-ipmisensors-20070314-1214.patch b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.1-007-ipmisensors-20070314-1214.patch
new file mode 100644
index 0000000000..5fe74954f3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.1-007-ipmisensors-20070314-1214.patch
@@ -0,0 +1,1914 @@
+diff -rduNp linux-2.6.22.1.oorig2/drivers/char/ipmi/ipmi_msghandler.c linux-2.6.22.1/drivers/char/ipmi/ipmi_msghandler.c
+--- linux-2.6.22.1.oorig2/drivers/char/ipmi/ipmi_msghandler.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/char/ipmi/ipmi_msghandler.c 2007-07-24 14:22:26.000000000 +0200
+@@ -1953,6 +1953,24 @@ static void remove_proc_entries(ipmi_smi
+ #endif /* CONFIG_PROC_FS */
+ }
+
++/*
++ * Retrieves the bmc_device struct for a given ipmi interface number (or NULL if none).
++ */
++struct device *ipmi_get_bmcdevice(int if_num)
++{
++ ipmi_smi_t intf;
++ mutex_lock(&ipmi_interfaces_mutex);
++ list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
++ if (intf->intf_num == if_num){
++ mutex_unlock(&ipmi_interfaces_mutex);
++ return &intf->bmc->dev->dev;
++ }
++ }
++ mutex_unlock(&ipmi_interfaces_mutex);
++
++ return NULL;
++}
++
+ static int __find_bmc_guid(struct device *dev, void *data)
+ {
+ unsigned char *id = data;
+@@ -4196,3 +4214,4 @@ EXPORT_SYMBOL(ipmi_get_my_LUN);
+ EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
+ EXPORT_SYMBOL(ipmi_user_set_run_to_completion);
+ EXPORT_SYMBOL(ipmi_free_recv_msg);
++EXPORT_SYMBOL(ipmi_get_bmcdevice);
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/Kconfig linux-2.6.22.1/drivers/hwmon/Kconfig
+--- linux-2.6.22.1.oorig2/drivers/hwmon/Kconfig 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/hwmon/Kconfig 2007-07-24 14:22:26.000000000 +0200
+@@ -248,6 +248,16 @@ config SENSORS_CORETEMP
+ sensor inside your CPU. Supported all are all known variants
+ of Intel Core family.
+
++config SENSORS_IPMI
++ tristate "IPMI Hardware Monitoring Support"
++ depends on HWMON && IPMI_HANDLER && EXPERIMENTAL
++ help
++ If you say yes here you get support for sensors monitored by
++ an IPMI baseboard management controller (BMC).
++
++ This driver can also be built as a module. If so, the module
++ will be called ipmisensors.
++
+ config SENSORS_IT87
+ tristate "ITE IT87xx and compatibles"
+ depends on I2C
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/Makefile linux-2.6.22.1/drivers/hwmon/Makefile
+--- linux-2.6.22.1.oorig2/drivers/hwmon/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/hwmon/Makefile 2007-07-24 14:22:26.000000000 +0200
+@@ -32,6 +32,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
+ obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
+ obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+ obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
++obj-$(CONFIG_SENSORS_IPMI) += ipmisensors.o
+ obj-$(CONFIG_SENSORS_IT87) += it87.o
+ obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
+ obj-$(CONFIG_SENSORS_LM63) += lm63.o
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.c linux-2.6.22.1/drivers/hwmon/ipmisensors.c
+--- linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/drivers/hwmon/ipmisensors.c 2007-07-24 14:22:26.000000000 +0200
+@@ -0,0 +1,1552 @@
++/*
++ * ipmisensors.c - lm-sensors/hwmon interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/init.h>
++#include <linux/module.h>
++#include <linux/param.h>
++#include <linux/hwmon.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/device.h>
++#include <linux/hwmon.h>
++
++#include "ipmisensors.h"
++
++/****** Function Prototypes ******/
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg);
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc);
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset);
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index);
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr);
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data);
++static int ipmisensors_intf_registered(int ipmi_intf);
++static int ipmisensors_bmc_registered(struct device *bmc);
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address);
++static void ipmisensors_unregister_bmc(int ipmi_intf);
++static void ipmisensors_unregister_bmc_all(void);
++static void ipmisensors_new_smi(int if_num, struct device *dev);
++static void ipmisensors_smi_gone(int if_num);
++static void ipmisensors_update_bmc(struct work_struct *);
++static void ipmisensors_cleanup(void);
++
++/****** Static Vars ******/
++
++/* set when module is being removed */
++static int cleanup = 0;
++
++/* ipmisensors driver data */
++static struct ipmisensors_data driver_data = {
++ .driver_name = "bmc",
++ .bmc_data = LIST_HEAD_INIT(driver_data.bmc_data),
++ .interfaces = 0,
++ .smi_watcher = {
++ .owner = THIS_MODULE,
++ .new_smi = ipmisensors_new_smi,
++ .smi_gone = ipmisensors_smi_gone,
++ },
++ .ipmi_hndlrs = {
++ .ipmi_recv_hndl = ipmisensors_msg_handler,
++ },
++};
++
++/* sensor refresh workqueue */
++static struct workqueue_struct *ipmisensors_workqueue;
++
++/****** SDR List Functions ******/
++/**
++ * Creates a new sdrdata struct, or returns NULL if insufficient memory.
++ */
++static struct sdrdata *ipmisensors_new_sdr(void)
++{
++ struct sdrdata *sdr;
++
++ sdr = kmem_cache_alloc(driver_data.sdrdata_cache, GFP_ATOMIC);
++ if (sdr) {
++ memset(sdr, 0, sizeof(struct sdrdata));
++ } else {
++ printk(KERN_ERR
++ "ipmisensors: Couldn't allocate memory for new SDR\n");
++ }
++
++ return sdr;
++}
++
++/**
++ * Adds the given sdrdata struct to the given bmc's SDR list.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static inline void ipmisensors_add_sdr(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ list_add(&sdr->list, &bmc->sdrs);
++ printk(KERN_DEBUG
++ "ipmisensors: SDR %d: type 0x%02x (%s)\n",
++ bmc->sdr_count, sdr->stype, sdr->id);
++ bmc->sdr_count++;
++}
++
++/**
++ * Cleanup the sdr list for the given BMC.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_sdr_cleanup(struct ipmisensors_bmc_data *bmc)
++{
++ struct sdrdata *cursor, *next;
++
++ /* find and free each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ device_remove_file(bmc->dev, &cursor->attr.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_min.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_max.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_label.dev_attr);
++
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++
++ list_del(&cursor->list);
++ kmem_cache_free(driver_data.sdrdata_cache, cursor);
++ }
++}
++
++/* worker function for workqueue ipmisensors_workqueue */
++static void ipmisensors_update_bmc(struct work_struct *work)
++{
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, update_work.work);
++
++ /* don't start an update cycle if one already in progress */
++ if (bmc->state != STATE_READING) {
++ struct sdrdata *cursor, *next;
++ bmc->state = STATE_READING;
++ printk(KERN_DEBUG "ipmisensors: starting update\n");
++
++ /* init semaphore to 1 for update cycle */
++ sema_init(&bmc->update_semaphore, 1);
++
++ /* update each sdr reading */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ ipmisensors_get_reading(bmc, cursor);
++ }
++ }
++
++ /* wait for readings (need timeout?) */
++ down_interruptible(&bmc->update_semaphore);
++
++ printk(KERN_DEBUG "ipmisensors: update complete\n");
++
++ bmc->state = STATE_DONE;
++
++ /* if the module isn't cleaning up, schedule another update */
++ if (!cleanup)
++ queue_delayed_work(ipmisensors_workqueue, &bmc->update_work,
++ bmc->update_period * HZ);
++}
++
++/****** IPMI Message Sending ******/
++
++/**
++ * Send a message to the IPMI BMC
++ *
++ * @bmc: the bmc to send the message to.
++ * @msgid: the message id to use.
++ * @msg: the ipmi message structure.
++ */
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg)
++{
++ if (msg->data == NULL)
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x\n", msg->cmd);
++ else
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x 0x%x 0x%x\n",
++ msg->cmd, msg->data[0], msg->data[1]);
++
++ /* This should be ipmi_request, but Corey had to remove
++ * that due to it being unused at the moment, as soon as
++ * this makes it into the kernel we should request it be re-instated.
++ */
++ ipmi_request_settime(bmc->user, &bmc->address, msgid, msg, bmc, 0,
++ -1, 0);
++}
++
++/**
++ * Compose and send a "reserve SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_RESERVE_SDR;
++ bmc->tx_message.data_len = 0;
++ bmc->tx_message.data = NULL;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Componse and send a "get SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @res_id:
++ * @record:
++ * @offset:
++ */
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset)
++{
++ printk(KERN_DEBUG "ipmisensors: Get SDR 0x%x 0x%x 0x%x\n",
++ res_id, record, offset);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SDR;
++ bmc->tx_message.data_len = 6;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = res_id & 0xff;
++ bmc->tx_msg_data[1] = res_id >> 8;
++ bmc->tx_msg_data[2] = record & 0xff;
++ bmc->tx_msg_data[3] = record >> 8;
++ bmc->tx_msg_data[4] = offset;
++ bmc->tx_msg_data[5] = bmc->ipmi_sdr_partial_size;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "set sensor threshold" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @id: the ipmi id number of the sensor.
++ * @value: the new value for the threshold.
++ * @lim_index: the index in the lim[] array for which this value applies.
++ */
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index)
++{
++ int i;
++
++ printk(KERN_DEBUG "ipmisensors: Set SDR Threshold %d %d %d\n",
++ number, value, lim_index);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_SET_SENSOR_THRESHOLD;
++ bmc->tx_message.data_len = 8;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = number & 0xff;
++ bmc->tx_msg_data[1] = 0x01 << lim_index;
++
++ if (lim_index > 5 || lim_index < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Error - ipmisensors_set_sensor_threshold given invalid lim_index\n");
++ return;
++ }
++
++ for (i = 2; i < 8; i++)
++ bmc->tx_msg_data[i] = 0x00;
++
++ bmc->tx_msg_data[lim_index] = value && 0xff;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "get sensor reading" message for the given sdr.
++ *
++ * @bmc: the bmc to send the message to.
++ * @sdr: the sdr of the sensor to get the reading for.
++ */
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_SENSOR_EVENT_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SENSOR_STATE_READING;
++ bmc->tx_message.data_len = 1;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = sdr->number;
++ bmc->current_sdr = sdr;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++ down_interruptible(&bmc->update_semaphore);
++}
++
++/****** IPMI Message Receiving ******/
++
++/**
++ * Process an sensor reading response message.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_reading_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ struct sdrdata *sdr = bmc->current_sdr;
++
++ if (sdr == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error ipmisensors_rcv_reading with NULL sdr\n");
++ return;
++ }
++
++ sdr->reading = msg->data[1];
++ sdr->status = msg->data[2];
++ sdr->thresholds = msg->data[3];
++
++ printk(KERN_DEBUG "ipmisensors: sensor %d (type %d) reading %d\n",
++ sdr->number, sdr->stype, msg->data[1]);
++
++ up(&bmc->update_semaphore);
++}
++
++/**
++ * Unpack based on string type, convert to normal, null terminate.
++ */
++static void ipmisensors_sprintf(u8 * to, u8 * from, u8 type, u8 length)
++{
++ static const u8 *bcdplus = "0123456789 -.:,_";
++ int i;
++
++ switch (type) {
++ case 0: /* unicode */
++ for (i = 0; i < length; i++)
++ *to++ = (*from++ & 0x7f);
++ *to = 0;
++ break;
++ case 1: /* BCD Plus */
++ for (i = 0; i < length; i++)
++ *to++ = bcdplus[*from++ & 0x0f];
++ *to = 0;
++ break;
++ case 2: /* packed ascii *//* if not a mult. of 3 this will run over */
++ for (i = 0; i < length; i += 3) {
++ *to++ = *from & 0x3f;
++ *to++ = *from >> 6 | ((*(from+1) & 0xf) << 2);
++ from++;
++ *to++ = *from >> 4 | ((*(from+1) & 0x3) << 4);
++ from++;
++ *to++ = (*from++ >> 2) & 0x3f;
++ }
++ *to = 0;
++ break;
++ case 3: /* normal */
++ if (length > 1)
++ memcpy(to, from, length);
++ to[length] = 0;
++ break;
++ }
++}
++
++/* IPMI V1.5 Section 30 */
++static const int exps[] =
++ { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
++
++/* Return 0 for fan, 2 for temp, 3 for voltage
++ We could make it variable based on the accuracy (= log10(m * 10**k2));
++ this would work for /proc output, however libsensors resolution
++ is statically set in lib/chips.c */
++static int decplaces(struct sdrdata *sd)
++{
++ switch (sd->stype) {
++ case STYPE_TEMP:
++ return 2;
++ case STYPE_CURR:
++ case STYPE_VOLT:
++ return 3;
++ case STYPE_FAN:
++ default:
++ return 0;
++ }
++}
++
++/* convert a raw value to a reading. IMPI V1.5 Section 30 */
++static long conv_val(int value, struct sdrdata *sd)
++{
++ u8 k1, k2;
++ long r;
++
++ r = value * sd->m;
++ k1 = sd->k & 0x0f;
++ k2 = sd->k >> 4;
++ if (k1 < 8)
++ r += sd->b * exps[k1];
++ else
++ r += sd->b / exps[16 - k1];
++ r *= exps[decplaces(sd)];
++ if (k2 < 8) {
++ if (sd->linear != 7)
++ r *= exps[k2];
++ else
++ /* this will always truncate to 0: r = 1 / (exps[k2] * r); */
++ r = 0;
++ } else {
++ if (sd->linear != 7)
++ r /= exps[16 - k2];
++ else {
++ if (r != 0)
++ /* 1 / x * 10 ** (-m) == 10 ** m / x */
++ r = exps[16 - k2] / r;
++ else
++ r = 0;
++ }
++ }
++
++ return r;
++}
++
++static const char *threshold_text[] = {
++ "upper non-recoverable threshold",
++ "upper critical threshold",
++ "upper non-critical threshold",
++ "lower non-recoverable threshold",
++ "lower critical threshold",
++ "lower non-critical threshold",
++ "positive-going hysteresis",
++ "negative-going hysteresis" /* unused */
++};
++
++/* select two out of the 8 possible readable thresholds, and place indexes into the limits
++ array into lim1 and lim2. Set writable flags */
++static void ipmisensors_select_thresholds(struct sdrdata *sd)
++{
++ u8 capab = sd->capab;
++ u16 mask = sd->thresh_mask;
++ int tmp;
++
++ sd->lim1 = -1;
++ sd->lim2 = -1;
++ sd->lim1_write = 0;
++ sd->lim2_write = 0;
++
++ if (((capab & 0x0c) == 0x04) || /* readable thresholds ? */
++ ((capab & 0x0c) == 0x08)) {
++ /* select upper threshold */
++ if (mask & 0x10) { /* upper crit */
++ sd->lim1 = 1;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x1000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x20) { /* upper non-recov */
++ sd->lim1 = 0;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x2000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x08) { /* upper non-crit */
++ sd->lim1 = 2;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0800))
++ sd->lim1_write = 1;
++ }
++
++ /* select lower threshold */
++ if ((((capab & 0x30) == 0x10) || /* readable ? */
++ ((capab & 0x30) == 0x20)) && /* pos hyst */
++ sd->stype == STYPE_TEMP)
++ sd->lim2 = 6;
++ else if (mask & 0x02) { /* lower crit */
++ sd->lim2 = 4;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0200))
++ sd->lim2_write = 1;
++ } else if (mask & 0x04) { /* lower non-recov */
++ sd->lim2 = 3;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0400))
++ sd->lim2_write = 1;
++ } else if (mask & 0x01) { /* lower non-crit */
++ sd->lim2 = 5;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0100))
++ sd->lim2_write = 1;
++ }
++ }
++
++ /* swap lim1/lim2 if m < 0 or function is 1/x (but not both!) */
++ if ((sd->m < 0 && sd->linear != 7) || (sd->m >= 0 && sd->linear == 7)) {
++ tmp = sd->lim1;
++ sd->lim1 = sd->lim2;
++ sd->lim2 = tmp;
++ }
++
++ if (sd->lim1 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for upper limit\n",
++ threshold_text[sd->lim1]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable upper limit\n");
++
++ if (sd->lim2 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for lower limit\n",
++ threshold_text[sd->lim2]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable lower limit\n");
++}
++
++/************* sysfs callback functions *********/
++static ssize_t show_update_period(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ return snprintf(buf, 20, "%d\n", aattr->bmc->update_period);
++}
++
++static ssize_t store_update_period(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ aattr->bmc->update_period = simple_strtoul(buf, NULL, 10);;
++ return count;
++};
++
++static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ return snprintf(buf, 20, "%ld\n",
++ conv_val(sattr->sdr->reading, sattr->sdr));
++}
++
++static ssize_t show_sensor_max(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long max = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim1 >= 0)
++ max = conv_val(sattr->sdr->limits[sattr->sdr->lim1],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", max);
++}
++
++static ssize_t show_sensor_min(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long min = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim2 >= 0)
++ min = conv_val(sattr->sdr->limits[sattr->sdr->lim2],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", min);
++};
++
++static ssize_t show_sensor_label(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ u8 label[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ ipmisensors_sprintf(label, sattr->sdr->id, sattr->sdr->string_type,
++ sattr->sdr->id_length);
++ return snprintf(buf, 20, "%s\n", label);
++};
++
++static ssize_t store_sensor_max(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set max on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim1);
++ return count;
++};
++
++static ssize_t store_sensor_min(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set min on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim2);
++ return count;
++};
++
++static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++ return snprintf(buf, 20, "%d\n", aattr->bmc->alarms);
++};
++
++static ssize_t show_name(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ return snprintf(buf, 20, "%s\n", driver_data.driver_name);
++};
++
++/* work function to build the sysfs entries using the ipmi sdrs */
++static void ipmisensors_build_sysfs(struct work_struct *work)
++{
++ int temps = 0, volts = 0, currs = 0, fans = 0;
++ struct sdrdata *cursor, *next;
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, sysfs_work);
++
++ /* find and create entries for each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++
++ cursor->attr_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_max_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_min_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ return;
++ }
++ }
++
++ if (cursor->attr_name == NULL || cursor->attr_max_name == NULL
++ || cursor->attr_min_name == NULL
++ || cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "temp%d_input", ++temps);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "temp%d_max", temps);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "temp%d_min", temps);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "temp%d_label", temps);
++ break;
++ case (STYPE_VOLT):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "in%d_input", ++volts);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "in%d_max", volts);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "in%d_min", volts);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "in%d_label", volts);
++ break;
++ case (STYPE_CURR):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "curr%d_input", ++currs);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "curr%d_max", currs);
++ sprintf(cursor->attr_min_name, "curr%d_min", currs);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "curr%d_label", currs);
++ break;
++ case (STYPE_FAN):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "fan%d_input", ++fans);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "fan%d_max", fans);
++ sprintf(cursor->attr_min_name, "fan%d_min", fans);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "fan%d_label", fans);
++ break;
++ default:
++ printk(KERN_INFO "ipmisensors: unkown sensor type\n");
++ continue;
++ }
++
++ cursor->attr.dev_attr.attr.name = cursor->attr_name;
++ cursor->attr.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr.dev_attr.show = show_sensor;
++ cursor->attr.dev_attr.store = NULL;
++ cursor->attr.sdr = cursor;
++
++ cursor->attr_min.dev_attr.attr.name = cursor->attr_min_name;
++ cursor->attr_min.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_min.dev_attr.show = show_sensor_min;
++ cursor->attr_min.sdr = cursor;
++
++ if (cursor->lim2_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_min.dev_attr.store = store_sensor_min;
++ cursor->attr_min.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_min.dev_attr.store = NULL;
++ cursor->attr_min.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ cursor->attr_max.dev_attr.attr.name = cursor->attr_max_name;
++ cursor->attr_max.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_max.dev_attr.show = show_sensor_max;
++ cursor->attr_max.sdr = cursor;
++
++ if (cursor->lim1_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_max.dev_attr.store = store_sensor_max;
++ cursor->attr_max.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_max.dev_attr.store = NULL;
++ cursor->attr_max.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label.dev_attr.attr.name =
++ cursor->attr_label_name;
++ cursor->attr_label.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr_label.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_label.dev_attr.show = show_sensor_label;
++ cursor->attr_label.dev_attr.store = NULL;
++ cursor->attr_label.sdr = cursor;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registering sensor %d: (type 0x%.2x) "
++ "(fmt=%d; m=%d; b=%d; k1=%d; k2=%d; cap=0x%.2x; mask=0x%.4x)\n",
++ cursor->number, cursor->stype, cursor->format, cursor->m,
++ cursor->b, cursor->k & 0xf, cursor->k >> 4,
++ cursor->capab, cursor->thresh_mask);
++
++ if (cursor->id_length > 0) {
++ ipmisensors_sprintf(id, cursor->id, cursor->string_type,
++ cursor->id_length);
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label temp%d \"%s\"\n",
++ temps, id);
++ break;
++ case (STYPE_VOLT):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label in%d \"%s\"\n",
++ volts, id);
++ break;
++ case (STYPE_CURR):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label curr%d \"%s\"\n",
++ currs, id);
++ break;
++ case (STYPE_FAN):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label fan%d \"%s\"\n",
++ fans, id);
++ break;
++ }
++ }
++
++ ipmisensors_select_thresholds(cursor);
++
++ if (cursor->linear != 0 && cursor->linear != 7) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: nonlinear function 0x%.2x unsupported, expect bad results\n",
++ cursor->number, cursor->linear);
++ }
++
++ if ((cursor->format & 0x03) == 0x02) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: 1's complement format unsupported, expect bad results\n",
++ cursor->number);
++ } else if ((cursor->format & 0x03) == 0x03) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: threshold sensor only, no readings available",
++ cursor->number);
++ }
++
++ if (cursor->lim1_write || cursor->lim2_write)
++ cursor->attr.dev_attr.attr.mode = 0644;
++ else
++ cursor->attr.dev_attr.attr.mode = 0444;
++
++ if (device_create_file(bmc->dev, &cursor->attr.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_min.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_max.dev_attr) < 0
++ || (cursor->id_length >
++ 0 ? device_create_file(bmc->dev,
++ &cursor->attr_label.dev_attr) <
++ 0 : 0)
++ ) {
++ printk(KERN_INFO
++ "ipmisensors: sysfs file creation failed for SDR %d (%s).\n",
++ cursor->number, cursor->id);
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++ }
++
++ bmc->alarms_attr.dev_attr.attr.name = "alarms";
++ bmc->alarms_attr.dev_attr.attr.mode = S_IRUGO;
++ bmc->alarms_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->alarms_attr.dev_attr.show = show_alarms;
++ bmc->alarms_attr.dev_attr.store = NULL;
++ bmc->alarms_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->alarms_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'alarms'");
++ return;
++ }
++
++ bmc->name_attr.attr.name = "name";
++ bmc->name_attr.attr.mode = S_IRUGO;
++ bmc->name_attr.attr.owner = THIS_MODULE;
++ bmc->name_attr.show = show_name;
++
++ if (device_create_file(bmc->dev, &bmc->name_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'name'");
++ return;
++ }
++
++ bmc->update_attr.dev_attr.attr.name = "update_period";
++ bmc->update_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ bmc->update_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->update_attr.dev_attr.show = show_update_period;
++ bmc->update_attr.dev_attr.store = store_update_period;
++ bmc->update_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->update_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'update_period'");
++ return;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registered %d temp, %d volt, %d current, %d fan sensors\n",
++ temps, volts, currs, fans);
++
++ /* This completes the initialization. We can now kickoff the
++ * periodic update of the bmc sensor's values by scheduling
++ * the first work.
++ */
++ queue_work(ipmisensors_workqueue, &bmc->update_work.work);
++
++}
++
++/**
++ * Process an SDR response message, save the SDRs we like in the sdr
++ * list for the given BMC.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_sdr_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ u16 record;
++ int type;
++ int stype;
++ int id_length;
++ int i;
++ int ipmi_ver = 0;
++ unsigned char *data;
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct sdrdata *sdr;
++
++ if (msg->data[0] != 0) {
++ /* cut request in half and try again */
++ bmc->ipmi_sdr_partial_size /= 2;
++ if (bmc->ipmi_sdr_partial_size < 8) {
++ printk(KERN_INFO
++ "ipmisensors: IPMI buffers too small, giving up\n");
++ bmc->state = STATE_DONE;
++ return;
++ }
++ printk(KERN_DEBUG
++ "ipmisensors: Reducing SDR request size to %d\n",
++ bmc->ipmi_sdr_partial_size);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ if (bmc->ipmi_sdr_partial_size < IPMI_SDR_SIZE) {
++ if (bmc->rx_msg_data_offset == 0) {
++ memcpy(bmc->rx_msg_data, msg->data,
++ bmc->ipmi_sdr_partial_size + 3);
++ bmc->rx_msg_data_offset =
++ bmc->ipmi_sdr_partial_size + 3;
++ } else {
++ memcpy(bmc->rx_msg_data + bmc->rx_msg_data_offset,
++ msg->data + 3, bmc->ipmi_sdr_partial_size);
++ bmc->rx_msg_data_offset += bmc->ipmi_sdr_partial_size;
++ }
++ if (bmc->rx_msg_data_offset > bmc->rx_msg_data[7] + 7) {
++ /* got last chunk */
++ bmc->rx_msg_data_offset = 0;
++ data = bmc->rx_msg_data;
++ } else {
++ /* get more */
++ record =
++ (bmc->rx_msg_data[4] << 8) | bmc->rx_msg_data[3];
++ ipmisensors_get_sdr(bmc, bmc->resid, record,
++ bmc->rx_msg_data_offset - 3);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ } else {
++ /* got it in one chunk */
++ data = msg->data;
++ }
++
++ bmc->nextrecord = (data[2] << 8) | data[1];
++
++ /* If the ipmi version is 0.9 we have to remap some things.
++ * Yes this is very ugly, but we aren't the ones who
++ * implemented an incomplete spec!
++ */
++ ipmi_ver = data[5];
++
++ type = data[6];
++ /* known SDR type */
++ if (type == 1 || type == 2) {
++ stype = data[(ipmi_ver == 0x90 ? 16 : 15)];
++ /* known sensor type */
++ if (stype <= STYPE_MAX) {
++ if (data[(ipmi_ver == 0x90 ? 17 : 16)] != 0x01) {
++ if (type == 1)
++ ipmisensors_sprintf(id, &data[51],
++ data[50] >> 6,
++ data[50] & 0x1f);
++ else
++ ipmisensors_sprintf(id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 :
++ 35)],
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] >> 6,
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] & 0x1f);
++ printk(KERN_INFO
++ "ipmisensors: skipping non-threshold sensor \"%s\"\n",
++ id);
++ } else {
++ /* add entry to sdrd table */
++ sdr = ipmisensors_new_sdr();
++ if (!sdr) {
++ printk(KERN_ERR
++ "ipmisensors: could not allocate memory for new SDR");
++ return;
++ }
++ sdr->bmc = bmc;
++ sdr->stype = stype;
++ sdr->number = data[10];
++ sdr->capab = data[(ipmi_ver == 0x90 ? 15 : 14)];
++ sdr->thresh_mask =
++ (((u16) data[(ipmi_ver == 0x90 ? 21 : 22)])
++ << 8) | data[21];
++ if (type == 1) {
++ sdr->format =
++ data[(ipmi_ver ==
++ 0x90 ? 22 : 24)] >> 6;
++ sdr->linear =
++ data[(ipmi_ver ==
++ 0x90 ? 25 : 26)] & 0x7f;
++ sdr->m =
++ data[(ipmi_ver == 0x90 ? 26 : 27)];
++ sdr->m |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 27 : 28)]
++ & 0xc0)) << 2;
++ if (sdr->m & 0x0200) {
++ /* sign extend */
++ sdr->m |= 0xfc00;
++ }
++ sdr->b =
++ data[(ipmi_ver == 0x90 ? 28 : 29)];
++ sdr->b |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 29 : 30)]
++ & 0xc0)) << 2;
++ if (sdr->b & 0x0200) {
++ /* sign extend */
++ sdr->b |= 0xfc00;
++ }
++ sdr->k =
++ data[(ipmi_ver == 0x90 ? 31 : 32)];
++ sdr->nominal =
++ data[(ipmi_ver == 0x90 ? 33 : 34)];
++ for (i = 0; i < SDR_LIMITS; i++) {
++ /* assume readable */
++ sdr->limits[i] =
++ data[(ipmi_ver ==
++ 0x90 ? 40 : 39) + i];
++ }
++ sdr->string_type = data[50] >> 6;
++ id_length = data[50] & 0x1f;
++ memcpy(sdr->id, &data[51], id_length);
++ sdr->id_length = id_length;
++ } else {
++ sdr->m = 1;
++ sdr->b = 0;
++ sdr->k = 0;
++ sdr->string_type =
++ data[(ipmi_ver ==
++ 0x90 ? 29 : 34)] >> 6;
++ id_length = data[34] & 0x1f;
++ if (id_length > 0) {
++ memcpy(sdr->id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 : 35)],
++ id_length);
++ }
++ sdr->id_length = id_length;
++ /* limits?? */
++ if (ipmi_ver == 0x90) {
++ memcpy(sdr->id,
++ &data[30], id_length);
++ sdr->id_length = id_length;
++ }
++ }
++ ipmisensors_add_sdr(bmc, sdr);
++ }
++ }
++ /* peek at the other SDR types */
++ } else if (type == 0x10 || type == 0x11 || type == 0x12) {
++ ipmisensors_sprintf(id, data + 19, data[18] >> 6,
++ data[18] & 0x1f);
++ if (type == 0x10) {
++ printk(KERN_INFO
++ "ipmisensors: Generic Device acc=0x%x; slv=0x%x; lun=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[13], id);
++ } else if (type == 0x11) {
++ printk(KERN_INFO
++ "ipmisensors: FRU Device acc=0x%x; slv=0x%x; log=0x%x; ch=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[11], data[13],
++ id);
++ } else {
++ printk(KERN_INFO
++ "ipmisensors: Mgmt Ctllr Device slv=0x%x; \"%s\"\n",
++ data[8], id);
++ }
++ } else if (type == 0x14) {
++ printk(KERN_INFO
++ "ipmisensors: Message Channel Info Records:\n");
++ for (i = 0; i < 8; i++) {
++ printk(KERN_INFO "ipmisensors: Channel %d info 0x%x\n",
++ i, data[9 + i]);
++ }
++ } else {
++ printk(KERN_INFO "ipmisensors: Skipping SDR type 0x%x\n", type);
++ }
++ if (ipmi_ver != 0x90) {
++ if (bmc->nextrecord >= 6224) {
++ /*YJ stop sensor scan on poweredge 1750 */
++ bmc->nextrecord = 0xffff;
++ }
++ }
++
++ if (bmc->nextrecord == 0xFFFF) {
++ if (bmc->sdr_count == 0) {
++ printk(KERN_INFO
++ "ipmisensors: No recognized sensors found.\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_INFO "ipmisensors: all sensors detected\n");
++ bmc->state = STATE_SYSTABLE;
++
++ /* Schedule sysfs build/registration work */
++ INIT_WORK(&bmc->sysfs_work, ipmisensors_build_sysfs);
++ queue_work(ipmisensors_workqueue, &bmc->sysfs_work);
++ }
++ } else {
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ }
++}
++
++/**
++ * Process incoming messages based on internal state
++ *
++ * @bmc: the bmc the message is from.
++ * @msg: the ipmi message to process.
++ */
++static void ipmisensors_rcv_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ switch (bmc->state) {
++ case STATE_INIT:
++ case STATE_RESERVE:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got first resid 0x%.4x\n",
++ bmc->resid);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_SDR:
++ case STATE_SDRPARTIAL:
++ ipmisensors_rcv_sdr_msg(bmc, msg);
++ break;
++
++ case STATE_READING:
++ ipmisensors_rcv_reading_msg(bmc, msg);
++ break;
++
++ case STATE_UNCANCEL:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got new resid 0x%.4x\n",
++ bmc->resid);
++
++ bmc->rx_msg_data_offset = 0;
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_DONE:
++ case STATE_SYSTABLE:
++ break;
++ default:
++ bmc->state = STATE_INIT;
++ }
++}
++
++/**
++ * Callback to handle a received IPMI message from a given BMC.
++ *
++ * @msg: the received message.
++ * @handler_data: a pointer to the particular bmc ipmisensors_bmc_data struct.
++ */
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data)
++{
++ struct ipmisensors_bmc_data *bmc =
++ (struct ipmisensors_bmc_data *)user_msg_data;
++
++ if (msg->msg.data[0] != 0)
++ printk(KERN_WARNING
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x\n",
++ msg->msg.data[0], msg->msg.netfn, msg->msg.cmd);
++
++ if (bmc != NULL && ipmisensors_intf_registered(bmc->interface_id)) {
++ if (bmc->state == STATE_SDR &&
++ msg->msg.data[0] == IPMI_INVALID_RESERVATION_ID) {
++ /* reservation cancelled, get new resid */
++ if (++bmc->errorcount > 275) {
++ printk(KERN_ERR
++ "ipmisensors: Too many reservations cancelled, giving up\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_DEBUG
++ "ipmisensors: resid 0x%04x cancelled, getting new one\n",
++ bmc->resid);
++
++ ipmisensors_reserve_sdr(bmc);
++ bmc->state = STATE_UNCANCEL;
++ }
++ } else if (msg->msg.data[0] != IPMI_CC_NO_ERROR &&
++ msg->msg.data[0] != IPMI_ERR_RETURNING_REQ_BYTES &&
++ msg->msg.data[0] != IPMI_ERR_PROVIDING_RESPONSE) {
++ printk(KERN_ERR
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x; state = %d; probably fatal.\n",
++ msg->msg.data[0], msg->msg.netfn & 0xfe,
++ msg->msg.cmd, bmc->state);
++ } else {
++ printk(KERN_DEBUG "ipmisensors: received message\n");
++ ipmisensors_rcv_msg(bmc, &msg->msg);
++ }
++
++ } else {
++ printk(KERN_WARNING
++ "ipmisensors: Response for non-registered BMC\n");
++ if (bmc != NULL)
++ printk(KERN_DEBUG "ipmisensors: BMC ID: %d\n",
++ bmc->interface_id);
++ else
++ printk(KERN_DEBUG "ipmisensors: BMC NULL!\n");
++ }
++
++ ipmi_free_recv_msg(msg);
++}
++
++/****** IPMI Interface Initialization ******/
++
++/**
++ * Return true if the given ipmi interface has been registered.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static int ipmisensors_intf_registered(int ipmi_intf)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Return true if the given BMC has been registered.
++ *
++ * @bmc: The BMC device.
++ */
++static int ipmisensors_bmc_registered(struct device *bmc)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->dev == bmc) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Register new IPMI BMC interface. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address)
++{
++ int error;
++
++ /* allocate a new ipmisensors_bmc_data struct */
++
++ struct ipmisensors_bmc_data *bmc = (struct ipmisensors_bmc_data *)
++ kmalloc(sizeof(struct ipmisensors_bmc_data), GFP_KERNEL);
++
++ /* initialize members */
++ INIT_LIST_HEAD(&bmc->sdrs);
++ bmc->interface_id = ipmi_intf;
++
++ bmc->address = *address;
++
++ bmc->sdr_count = 0;
++ bmc->msgid = 0;
++ bmc->ipmi_sdr_partial_size = IPMI_CHUNK_SIZE;
++ bmc->state = STATE_INIT;
++ bmc->errorcount = 0;
++ bmc->rx_msg_data_offset = 0;
++ bmc->dev = ipmi_get_bmcdevice(ipmi_intf);
++
++ /* default to 3 second min update interval */
++ bmc->update_period = 3;
++
++ if (bmc->dev == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error, couldn't get BMC device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Create IPMI messaging interface user */
++ error = ipmi_create_user(bmc->interface_id, &driver_data.ipmi_hndlrs,
++ bmc, &bmc->user);
++ if (error < 0) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register user with ipmi interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC as a HWMON class device */
++ bmc->class_dev = hwmon_device_register(bmc->dev);
++
++ if (IS_ERR(bmc->class_dev)) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register hwmon class device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC in the driver */
++ if (ipmisensors_bmc_registered(bmc->dev)) {
++ printk(KERN_ERR
++ "ipmisensors: BMC on interface %d already registered\n",
++ bmc->interface_id);
++ hwmon_device_unregister(bmc->class_dev);
++ kfree(bmc);
++ return;
++ }
++
++ ipmi_get_version(bmc->user, &bmc->ipmi_version_major,
++ &bmc->ipmi_version_minor);
++
++ /* finally add the new bmc data to the bmc data list */
++ list_add_tail(&bmc->list, &driver_data.bmc_data);
++ driver_data.interfaces++;
++
++ printk(KERN_INFO
++ "ipmisensors: Registered IPMI %d.%d BMC over interface %d\n",
++ bmc->ipmi_version_major,
++ bmc->ipmi_version_minor, bmc->interface_id);
++
++ /* Send a reserve SDR command to the bmc */
++ ipmisensors_reserve_sdr(bmc);
++
++ /* initialize the bmc's update work struct */
++ INIT_DELAYED_WORK(&bmc->update_work, ipmisensors_update_bmc);
++}
++
++/**
++ * Callback for when an IPMI BMC is gone. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_unregister_bmc(int ipmi_intf)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ list_del(&cursor->list);
++ printk(KERN_DEBUG
++ "ipmisensors: cancelling queued work\n");
++ /* cancel update work queued for this bmc */
++ cancel_delayed_work(&cursor->update_work);
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev,
++ &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev,
++ &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ driver_data.interfaces--;
++ }
++ }
++
++}
++
++/**
++ * Unregister all registered bmcs.
++ */
++static void ipmisensors_unregister_bmc_all(void)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ list_del(&cursor->list);
++
++ /* cancel update work queued for this bmc */
++ printk(KERN_DEBUG "ipmisensors: cancelling queued work\n");
++ cancel_delayed_work(&cursor->update_work);
++
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev, &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev, &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ }
++
++ driver_data.interfaces = 0;
++}
++
++/**
++ * Callback for when a new IPMI SMI type interface is found.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_new_smi(int if_num, struct device *dev)
++{
++ struct ipmi_addr smi_address = {
++ IPMI_SYSTEM_INTERFACE_ADDR_TYPE,
++ IPMI_BMC_CHANNEL,
++ {0},
++ };
++
++ /* calls the generic new interface function */
++ ipmisensors_register_bmc(if_num, &smi_address);
++}
++
++/**
++ * Callback for when an exisiting IPMI SMI type interface is gone.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_smi_gone(int if_num)
++{
++ if (driver_data.interfaces > 0) {
++ ipmisensors_unregister_bmc(if_num);
++ }
++}
++
++/**
++ * Initialize the module.
++ */
++static int __init ipmisensors_init(void)
++{
++ int error;
++ printk(KERN_INFO "ipmisensors - IPMI BMC sensors interface\n");
++
++ /* init cache managers */
++ driver_data.sdrdata_cache =
++ kmem_cache_create("ipmisensors_sdrdata", sizeof(struct sdrdata), 0,
++ 0, NULL, NULL);
++ driver_data.sysfsattr_cache =
++ kmem_cache_create("ipmisensors_sysfsattr",
++ sizeof(struct ipmisensors_device_attribute), 0, 0,
++ NULL, NULL);
++
++ if (!driver_data.sdrdata_cache || !driver_data.sysfsattr_cache) {
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++ return -ENOMEM;
++ }
++
++ /* register IPMI interface callback(s) */
++ error = ipmi_smi_watcher_register(&driver_data.smi_watcher);
++ if (error) {
++ printk(KERN_WARNING
++ "ipmisensors: can't register smi watcher\n");
++ return error;
++ }
++
++ /* create work queue, keep it simple, single-threaded */
++ ipmisensors_workqueue =
++ create_singlethread_workqueue("ipmisensors_workqueue");
++
++ return 0;
++}
++
++/**
++ * Cleanup
++ */
++static void ipmisensors_cleanup(void)
++{
++ /* start cleanup */
++ cleanup = 1;
++
++ /* unregister bmcs */
++ printk(KERN_DEBUG "ipmisensors: unregister bmcs\n");
++ ipmi_smi_watcher_unregister(&driver_data.smi_watcher);
++ ipmisensors_unregister_bmc_all();
++
++ /* flush & destroy work queue */
++ printk(KERN_DEBUG "ipmisensors: destroy workqueue\n");
++ flush_workqueue(ipmisensors_workqueue);
++ destroy_workqueue(ipmisensors_workqueue);
++
++ /* remove cache managers */
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++}
++
++/**
++ * Cleanup and exit the module
++ */
++static void __exit ipmisensors_exit(void)
++{
++ ipmisensors_cleanup();
++ printk(KERN_DEBUG "ipmisensors: cleanup finished\n");
++}
++
++MODULE_AUTHOR("Yani Ioannou <yani.ioannou@gmail.com>");
++MODULE_DESCRIPTION("IPMI BMC sensors");
++MODULE_LICENSE("GPL");
++
++module_init(ipmisensors_init);
++module_exit(ipmisensors_exit);
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.h linux-2.6.22.1/drivers/hwmon/ipmisensors.h
+--- linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/drivers/hwmon/ipmisensors.h 2007-07-24 14:22:26.000000000 +0200
+@@ -0,0 +1,240 @@
++/*
++ * ipmisensors.h - lm_sensors interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/ipmi.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/workqueue.h>
++
++/* SDR defs */
++#define STYPE_TEMP 0x01
++#define STYPE_VOLT 0x02
++#define STYPE_CURR 0x03
++#define STYPE_FAN 0x04
++
++#define SDR_LIMITS 8
++#define SDR_MAX_ID_LENGTH 16
++#define SDR_MAX_UNPACKED_ID_LENGTH ((SDR_MAX_ID_LENGTH * 4 / 3) + 2)
++
++/* the last sensor type we are interested in */
++#define STYPE_MAX 4
++
++#define IPMI_SDR_SIZE 67
++#define IPMI_CHUNK_SIZE 16
++
++#define MAX_FILENAME_LENGTH 30
++
++struct ipmisensors_device_attribute {
++ struct device_attribute dev_attr;
++ struct sdrdata *sdr;
++};
++#define to_ipmisensors_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_device_attribute, dev_attr)
++
++#define IPMISENSORS_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
++struct ipmisensors_attribute sensor_dev_attr_##_name = { \
++ .dev_attr = __ATTR(_name,_mode,_show,_store), \
++ .index = _index, \
++}
++
++struct ipmisensors_bmc_device_attribute {
++ struct device_attribute dev_attr;
++ struct ipmisensors_bmc_data *bmc;
++};
++#define to_ipmisensors_bmc_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_bmc_device_attribute, dev_attr)
++
++/**
++ * &struct_sdrdata stores the IPMI Sensor Data Record (SDR) data, as recieved from the BMC, along with the corresponding sysfs attributes
++ */
++struct sdrdata {
++ struct list_head list;
++ /* retrieved from SDR, not expected to change */
++ /* Sensor Type Code */
++ u8 stype;
++ u8 number;
++ /* Sensor Capability Code */
++ u8 capab;
++ u16 thresh_mask;
++ u8 format;
++ u8 linear;
++ s16 m;
++ s16 b;
++ u8 k;
++ u8 nominal;
++ u8 limits[SDR_LIMITS];
++ /* index into limits for reported upper and lower limit */
++ int lim1, lim2;
++ u8 lim1_write, lim2_write;
++ u8 string_type;
++ u8 id_length;
++ u8 id[SDR_MAX_ID_LENGTH];
++ /* retrieved from reading */
++ u8 reading;
++ u8 status;
++ u8 thresholds;
++ /* sensor's bmc */
++ struct ipmisensors_bmc_data *bmc;
++ /* sysfs entries */
++ struct ipmisensors_device_attribute attr;
++ char *attr_name;
++ struct ipmisensors_device_attribute attr_min;
++ char *attr_min_name;
++ struct ipmisensors_device_attribute attr_max;
++ char *attr_max_name;
++ struct ipmisensors_device_attribute attr_label;
++ char *attr_label_name;
++
++};
++
++/**
++ * &struct_ipmisensors_data stores the data for the ipmisensors driver.
++ */
++struct ipmisensors_data {
++ /* Driver struct */
++ char *driver_name;
++
++ /* Linked list of ipmisensors_bmc_data structs, one for each BMC */
++ struct list_head bmc_data;
++
++ /* Number of ipmi interfaces (and hence ipmisensors_data structs). */
++ int interfaces;
++
++ /* IPMI kernel interface - SMI watcher */
++ struct ipmi_smi_watcher smi_watcher;
++
++ /* IPMI kernel interface - user handlers */
++ struct ipmi_user_hndl ipmi_hndlrs;
++
++ /* Cache manager for sdrdata cache */
++ struct kmem_cache *sdrdata_cache;
++
++ /* Cache manager for ipmi_sensor_device_attribute cache */
++ struct kmem_cache *sysfsattr_cache;
++};
++
++/**
++ * &states: enumeration of state codes for a bmc specific ipmisensors
++ */
++enum states {
++ STATE_INIT,
++ STATE_RESERVE,
++ STATE_SDR,
++ STATE_SDRPARTIAL,
++ STATE_READING,
++ STATE_UNCANCEL,
++ STATE_SYSTABLE,
++ STATE_DONE
++};
++
++/**
++ * &struct_ipmisensors_bmc_data stores the data for a particular IPMI BMC.
++ */
++struct ipmisensors_bmc_data {
++ struct list_head list;
++
++ /* The IPMI interface number */
++ int interface_id;
++
++ /* The IPMI address */
++ struct ipmi_addr address;
++
++ /* List of sdrdata structs (sdrs) recieved from the BMC */
++ struct list_head sdrs;
++
++ /* Count of the number of sdrs stored in the sdr list */
++ int sdr_count;
++
++ /* next message id */
++ int msgid;
++
++ /* The ipmi interface 'user' used to access this particular bmc */
++ ipmi_user_t user;
++
++ /* BMC IPMI Version (major) */
++ unsigned char ipmi_version_major;
++
++ /* BMC IPMI Version (minor) */
++ unsigned char ipmi_version_minor;
++
++ /* The size of the SDR request message */
++ int ipmi_sdr_partial_size;
++
++ /* transmit message buffer */
++ struct kernel_ipmi_msg tx_message;
++
++ /* ipmi transmited data buffer */
++ unsigned char tx_msg_data[IPMI_MAX_MSG_LENGTH + 50]; /* why the +50 in bmcsensors? */
++
++ /* ipmi recieved data buffer */
++ unsigned char rx_msg_data[IPMI_MAX_MSG_LENGTH + 50];
++
++ /* current recieve buffer offset */
++ int rx_msg_data_offset;
++
++ /* The id of then next SDR record to read during update cycle */
++ u16 nextrecord;
++
++ /* BMC SDR Reservation ID */
++ u16 resid;
++
++ /* Alarm status */
++ u8 alarms;
++
++ /* The cumalative error count for this bmc */
++ int errorcount;
++
++ /* The current state of this bmc w.r.t. ipmisensors (see enum states) */
++ int state;
++
++ /* The current sdr for which a reading is pending */
++ struct sdrdata *current_sdr;
++
++ /* The BMC's device struct */
++ struct device *dev;
++
++ /* hwmon class device */
++ struct class_device *class_dev;
++
++ /* hwmon device name */
++ struct device_attribute name_attr;
++
++ /* alarms attribute */
++ struct ipmisensors_bmc_device_attribute alarms_attr;
++
++ /* update_period attribute */
++ struct ipmisensors_bmc_device_attribute update_attr;
++
++ /* lower bound on time between updates (in seconds) */
++ unsigned int update_period;
++
++ /* semaphore used to do a headcount of the SDR readings we are waiting
++ * on in a given bmc update */
++ struct semaphore update_semaphore;
++
++ /* bmc's work struct for updating sensors */
++ struct delayed_work update_work;
++
++ /* bmc's work struct for building the sysfs workqueue */
++ struct work_struct sysfs_work;
++};
+diff -rduNp linux-2.6.22.1.oorig2/include/linux/ipmi.h linux-2.6.22.1/include/linux/ipmi.h
+--- linux-2.6.22.1.oorig2/include/linux/ipmi.h 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/include/linux/ipmi.h 2007-07-24 14:22:26.000000000 +0200
+@@ -300,6 +300,9 @@ int ipmi_create_user(unsigned int
+ safe, too. */
+ int ipmi_destroy_user(ipmi_user_t user);
+
++/* Get the IPMI BMC's device struct */
++struct device *ipmi_get_bmcdevice(int ipmi_intf);
++
+ /* Get the IPMI version of the BMC we are talking to. */
+ void ipmi_get_version(ipmi_user_t user,
+ unsigned char *major,
+diff -rduNp linux-2.6.22.1.oorig2/include/linux/ipmi_msgdefs.h linux-2.6.22.1/include/linux/ipmi_msgdefs.h
+--- linux-2.6.22.1.oorig2/include/linux/ipmi_msgdefs.h 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/include/linux/ipmi_msgdefs.h 2007-07-24 14:22:26.000000000 +0200
+@@ -45,6 +45,7 @@
+
+ #define IPMI_NETFN_APP_REQUEST 0x06
+ #define IPMI_NETFN_APP_RESPONSE 0x07
++#define IPMI_GET_DEVICE_GUID_CMD 0x08
+ #define IPMI_GET_DEVICE_ID_CMD 0x01
+ #define IPMI_COLD_RESET_CMD 0x02
+ #define IPMI_WARM_RESET_CMD 0x03
+@@ -57,6 +58,11 @@
+ #define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
+ #define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
+ #define IPMI_GET_CHANNEL_INFO_CMD 0x42
++#define IPMI_RESERVE_SDR 0x22
++#define IPMI_GET_SDR 0x23
++#define IPMI_GET_SENSOR_STATE_READING 0x2D
++#define IPMI_SET_SENSOR_HYSTERESIS 0x24
++#define IPMI_SET_SENSOR_THRESHOLD 0x26
+
+ #define IPMI_NETFN_STORAGE_REQUEST 0x0a
+ #define IPMI_NETFN_STORAGE_RESPONSE 0x0b
+@@ -79,10 +85,13 @@
+ #define IPMI_NODE_BUSY_ERR 0xc0
+ #define IPMI_INVALID_COMMAND_ERR 0xc1
+ #define IPMI_TIMEOUT_ERR 0xc3
++#define IPMI_INVALID_RESERVATION_ID 0xc5
+ #define IPMI_ERR_MSG_TRUNCATED 0xc6
+ #define IPMI_REQ_LEN_INVALID_ERR 0xc7
+ #define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
+ #define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
++#define IPMI_ERR_RETURNING_REQ_BYTES 0xca
++#define IPMI_ERR_PROVIDING_RESPONSE 0xce
+ #define IPMI_LOST_ARBITRATION_ERR 0x81
+ #define IPMI_BUS_ERR 0x82
+ #define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.9-007-ipmisensors-20070314-1214.patch b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.9-007-ipmisensors-20070314-1214.patch
new file mode 100644
index 0000000000..5fe74954f3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/ipmi/linux-2.6.22.9-007-ipmisensors-20070314-1214.patch
@@ -0,0 +1,1914 @@
+diff -rduNp linux-2.6.22.1.oorig2/drivers/char/ipmi/ipmi_msghandler.c linux-2.6.22.1/drivers/char/ipmi/ipmi_msghandler.c
+--- linux-2.6.22.1.oorig2/drivers/char/ipmi/ipmi_msghandler.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/char/ipmi/ipmi_msghandler.c 2007-07-24 14:22:26.000000000 +0200
+@@ -1953,6 +1953,24 @@ static void remove_proc_entries(ipmi_smi
+ #endif /* CONFIG_PROC_FS */
+ }
+
++/*
++ * Retrieves the bmc_device struct for a given ipmi interface number (or NULL if none).
++ */
++struct device *ipmi_get_bmcdevice(int if_num)
++{
++ ipmi_smi_t intf;
++ mutex_lock(&ipmi_interfaces_mutex);
++ list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
++ if (intf->intf_num == if_num){
++ mutex_unlock(&ipmi_interfaces_mutex);
++ return &intf->bmc->dev->dev;
++ }
++ }
++ mutex_unlock(&ipmi_interfaces_mutex);
++
++ return NULL;
++}
++
+ static int __find_bmc_guid(struct device *dev, void *data)
+ {
+ unsigned char *id = data;
+@@ -4196,3 +4214,4 @@ EXPORT_SYMBOL(ipmi_get_my_LUN);
+ EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
+ EXPORT_SYMBOL(ipmi_user_set_run_to_completion);
+ EXPORT_SYMBOL(ipmi_free_recv_msg);
++EXPORT_SYMBOL(ipmi_get_bmcdevice);
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/Kconfig linux-2.6.22.1/drivers/hwmon/Kconfig
+--- linux-2.6.22.1.oorig2/drivers/hwmon/Kconfig 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/hwmon/Kconfig 2007-07-24 14:22:26.000000000 +0200
+@@ -248,6 +248,16 @@ config SENSORS_CORETEMP
+ sensor inside your CPU. Supported all are all known variants
+ of Intel Core family.
+
++config SENSORS_IPMI
++ tristate "IPMI Hardware Monitoring Support"
++ depends on HWMON && IPMI_HANDLER && EXPERIMENTAL
++ help
++ If you say yes here you get support for sensors monitored by
++ an IPMI baseboard management controller (BMC).
++
++ This driver can also be built as a module. If so, the module
++ will be called ipmisensors.
++
+ config SENSORS_IT87
+ tristate "ITE IT87xx and compatibles"
+ depends on I2C
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/Makefile linux-2.6.22.1/drivers/hwmon/Makefile
+--- linux-2.6.22.1.oorig2/drivers/hwmon/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/hwmon/Makefile 2007-07-24 14:22:26.000000000 +0200
+@@ -32,6 +32,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
+ obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
+ obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+ obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
++obj-$(CONFIG_SENSORS_IPMI) += ipmisensors.o
+ obj-$(CONFIG_SENSORS_IT87) += it87.o
+ obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
+ obj-$(CONFIG_SENSORS_LM63) += lm63.o
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.c linux-2.6.22.1/drivers/hwmon/ipmisensors.c
+--- linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/drivers/hwmon/ipmisensors.c 2007-07-24 14:22:26.000000000 +0200
+@@ -0,0 +1,1552 @@
++/*
++ * ipmisensors.c - lm-sensors/hwmon interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/init.h>
++#include <linux/module.h>
++#include <linux/param.h>
++#include <linux/hwmon.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/device.h>
++#include <linux/hwmon.h>
++
++#include "ipmisensors.h"
++
++/****** Function Prototypes ******/
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg);
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc);
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset);
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index);
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr);
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data);
++static int ipmisensors_intf_registered(int ipmi_intf);
++static int ipmisensors_bmc_registered(struct device *bmc);
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address);
++static void ipmisensors_unregister_bmc(int ipmi_intf);
++static void ipmisensors_unregister_bmc_all(void);
++static void ipmisensors_new_smi(int if_num, struct device *dev);
++static void ipmisensors_smi_gone(int if_num);
++static void ipmisensors_update_bmc(struct work_struct *);
++static void ipmisensors_cleanup(void);
++
++/****** Static Vars ******/
++
++/* set when module is being removed */
++static int cleanup = 0;
++
++/* ipmisensors driver data */
++static struct ipmisensors_data driver_data = {
++ .driver_name = "bmc",
++ .bmc_data = LIST_HEAD_INIT(driver_data.bmc_data),
++ .interfaces = 0,
++ .smi_watcher = {
++ .owner = THIS_MODULE,
++ .new_smi = ipmisensors_new_smi,
++ .smi_gone = ipmisensors_smi_gone,
++ },
++ .ipmi_hndlrs = {
++ .ipmi_recv_hndl = ipmisensors_msg_handler,
++ },
++};
++
++/* sensor refresh workqueue */
++static struct workqueue_struct *ipmisensors_workqueue;
++
++/****** SDR List Functions ******/
++/**
++ * Creates a new sdrdata struct, or returns NULL if insufficient memory.
++ */
++static struct sdrdata *ipmisensors_new_sdr(void)
++{
++ struct sdrdata *sdr;
++
++ sdr = kmem_cache_alloc(driver_data.sdrdata_cache, GFP_ATOMIC);
++ if (sdr) {
++ memset(sdr, 0, sizeof(struct sdrdata));
++ } else {
++ printk(KERN_ERR
++ "ipmisensors: Couldn't allocate memory for new SDR\n");
++ }
++
++ return sdr;
++}
++
++/**
++ * Adds the given sdrdata struct to the given bmc's SDR list.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static inline void ipmisensors_add_sdr(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ list_add(&sdr->list, &bmc->sdrs);
++ printk(KERN_DEBUG
++ "ipmisensors: SDR %d: type 0x%02x (%s)\n",
++ bmc->sdr_count, sdr->stype, sdr->id);
++ bmc->sdr_count++;
++}
++
++/**
++ * Cleanup the sdr list for the given BMC.
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_sdr_cleanup(struct ipmisensors_bmc_data *bmc)
++{
++ struct sdrdata *cursor, *next;
++
++ /* find and free each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ device_remove_file(bmc->dev, &cursor->attr.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_min.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_max.dev_attr);
++ device_remove_file(bmc->dev, &cursor->attr_label.dev_attr);
++
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++
++ list_del(&cursor->list);
++ kmem_cache_free(driver_data.sdrdata_cache, cursor);
++ }
++}
++
++/* worker function for workqueue ipmisensors_workqueue */
++static void ipmisensors_update_bmc(struct work_struct *work)
++{
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, update_work.work);
++
++ /* don't start an update cycle if one already in progress */
++ if (bmc->state != STATE_READING) {
++ struct sdrdata *cursor, *next;
++ bmc->state = STATE_READING;
++ printk(KERN_DEBUG "ipmisensors: starting update\n");
++
++ /* init semaphore to 1 for update cycle */
++ sema_init(&bmc->update_semaphore, 1);
++
++ /* update each sdr reading */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ ipmisensors_get_reading(bmc, cursor);
++ }
++ }
++
++ /* wait for readings (need timeout?) */
++ down_interruptible(&bmc->update_semaphore);
++
++ printk(KERN_DEBUG "ipmisensors: update complete\n");
++
++ bmc->state = STATE_DONE;
++
++ /* if the module isn't cleaning up, schedule another update */
++ if (!cleanup)
++ queue_delayed_work(ipmisensors_workqueue, &bmc->update_work,
++ bmc->update_period * HZ);
++}
++
++/****** IPMI Message Sending ******/
++
++/**
++ * Send a message to the IPMI BMC
++ *
++ * @bmc: the bmc to send the message to.
++ * @msgid: the message id to use.
++ * @msg: the ipmi message structure.
++ */
++static void ipmisensors_send_message(struct ipmisensors_bmc_data *bmc,
++ long msgid, struct kernel_ipmi_msg *msg)
++{
++ if (msg->data == NULL)
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x\n", msg->cmd);
++ else
++ printk(KERN_DEBUG "ipmisensors: Send 0x%x 0x%x 0x%x\n",
++ msg->cmd, msg->data[0], msg->data[1]);
++
++ /* This should be ipmi_request, but Corey had to remove
++ * that due to it being unused at the moment, as soon as
++ * this makes it into the kernel we should request it be re-instated.
++ */
++ ipmi_request_settime(bmc->user, &bmc->address, msgid, msg, bmc, 0,
++ -1, 0);
++}
++
++/**
++ * Compose and send a "reserve SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ */
++static void ipmisensors_reserve_sdr(struct ipmisensors_bmc_data *bmc)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_RESERVE_SDR;
++ bmc->tx_message.data_len = 0;
++ bmc->tx_message.data = NULL;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Componse and send a "get SDR" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @res_id:
++ * @record:
++ * @offset:
++ */
++static void ipmisensors_get_sdr(struct ipmisensors_bmc_data *bmc, u16 res_id,
++ u16 record, u8 offset)
++{
++ printk(KERN_DEBUG "ipmisensors: Get SDR 0x%x 0x%x 0x%x\n",
++ res_id, record, offset);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SDR;
++ bmc->tx_message.data_len = 6;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = res_id & 0xff;
++ bmc->tx_msg_data[1] = res_id >> 8;
++ bmc->tx_msg_data[2] = record & 0xff;
++ bmc->tx_msg_data[3] = record >> 8;
++ bmc->tx_msg_data[4] = offset;
++ bmc->tx_msg_data[5] = bmc->ipmi_sdr_partial_size;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "set sensor threshold" message
++ *
++ * @bmc: the bmc to send the message to.
++ * @id: the ipmi id number of the sensor.
++ * @value: the new value for the threshold.
++ * @lim_index: the index in the lim[] array for which this value applies.
++ */
++static void ipmisensors_set_sensor_threshold(struct ipmisensors_bmc_data *bmc,
++ u8 number, int value,
++ int lim_index)
++{
++ int i;
++
++ printk(KERN_DEBUG "ipmisensors: Set SDR Threshold %d %d %d\n",
++ number, value, lim_index);
++ bmc->tx_message.netfn = IPMI_NETFN_STORAGE_REQUEST;
++ bmc->tx_message.cmd = IPMI_SET_SENSOR_THRESHOLD;
++ bmc->tx_message.data_len = 8;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = number & 0xff;
++ bmc->tx_msg_data[1] = 0x01 << lim_index;
++
++ if (lim_index > 5 || lim_index < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Error - ipmisensors_set_sensor_threshold given invalid lim_index\n");
++ return;
++ }
++
++ for (i = 2; i < 8; i++)
++ bmc->tx_msg_data[i] = 0x00;
++
++ bmc->tx_msg_data[lim_index] = value && 0xff;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++}
++
++/**
++ * Compose and send a "get sensor reading" message for the given sdr.
++ *
++ * @bmc: the bmc to send the message to.
++ * @sdr: the sdr of the sensor to get the reading for.
++ */
++static void ipmisensors_get_reading(struct ipmisensors_bmc_data *bmc,
++ struct sdrdata *sdr)
++{
++ bmc->tx_message.netfn = IPMI_NETFN_SENSOR_EVENT_REQUEST;
++ bmc->tx_message.cmd = IPMI_GET_SENSOR_STATE_READING;
++ bmc->tx_message.data_len = 1;
++ bmc->tx_message.data = bmc->tx_msg_data;
++ bmc->tx_msg_data[0] = sdr->number;
++ bmc->current_sdr = sdr;
++
++ ipmisensors_send_message(bmc, bmc->msgid++, &bmc->tx_message);
++ down_interruptible(&bmc->update_semaphore);
++}
++
++/****** IPMI Message Receiving ******/
++
++/**
++ * Process an sensor reading response message.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_reading_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ struct sdrdata *sdr = bmc->current_sdr;
++
++ if (sdr == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error ipmisensors_rcv_reading with NULL sdr\n");
++ return;
++ }
++
++ sdr->reading = msg->data[1];
++ sdr->status = msg->data[2];
++ sdr->thresholds = msg->data[3];
++
++ printk(KERN_DEBUG "ipmisensors: sensor %d (type %d) reading %d\n",
++ sdr->number, sdr->stype, msg->data[1]);
++
++ up(&bmc->update_semaphore);
++}
++
++/**
++ * Unpack based on string type, convert to normal, null terminate.
++ */
++static void ipmisensors_sprintf(u8 * to, u8 * from, u8 type, u8 length)
++{
++ static const u8 *bcdplus = "0123456789 -.:,_";
++ int i;
++
++ switch (type) {
++ case 0: /* unicode */
++ for (i = 0; i < length; i++)
++ *to++ = (*from++ & 0x7f);
++ *to = 0;
++ break;
++ case 1: /* BCD Plus */
++ for (i = 0; i < length; i++)
++ *to++ = bcdplus[*from++ & 0x0f];
++ *to = 0;
++ break;
++ case 2: /* packed ascii *//* if not a mult. of 3 this will run over */
++ for (i = 0; i < length; i += 3) {
++ *to++ = *from & 0x3f;
++ *to++ = *from >> 6 | ((*(from+1) & 0xf) << 2);
++ from++;
++ *to++ = *from >> 4 | ((*(from+1) & 0x3) << 4);
++ from++;
++ *to++ = (*from++ >> 2) & 0x3f;
++ }
++ *to = 0;
++ break;
++ case 3: /* normal */
++ if (length > 1)
++ memcpy(to, from, length);
++ to[length] = 0;
++ break;
++ }
++}
++
++/* IPMI V1.5 Section 30 */
++static const int exps[] =
++ { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
++
++/* Return 0 for fan, 2 for temp, 3 for voltage
++ We could make it variable based on the accuracy (= log10(m * 10**k2));
++ this would work for /proc output, however libsensors resolution
++ is statically set in lib/chips.c */
++static int decplaces(struct sdrdata *sd)
++{
++ switch (sd->stype) {
++ case STYPE_TEMP:
++ return 2;
++ case STYPE_CURR:
++ case STYPE_VOLT:
++ return 3;
++ case STYPE_FAN:
++ default:
++ return 0;
++ }
++}
++
++/* convert a raw value to a reading. IMPI V1.5 Section 30 */
++static long conv_val(int value, struct sdrdata *sd)
++{
++ u8 k1, k2;
++ long r;
++
++ r = value * sd->m;
++ k1 = sd->k & 0x0f;
++ k2 = sd->k >> 4;
++ if (k1 < 8)
++ r += sd->b * exps[k1];
++ else
++ r += sd->b / exps[16 - k1];
++ r *= exps[decplaces(sd)];
++ if (k2 < 8) {
++ if (sd->linear != 7)
++ r *= exps[k2];
++ else
++ /* this will always truncate to 0: r = 1 / (exps[k2] * r); */
++ r = 0;
++ } else {
++ if (sd->linear != 7)
++ r /= exps[16 - k2];
++ else {
++ if (r != 0)
++ /* 1 / x * 10 ** (-m) == 10 ** m / x */
++ r = exps[16 - k2] / r;
++ else
++ r = 0;
++ }
++ }
++
++ return r;
++}
++
++static const char *threshold_text[] = {
++ "upper non-recoverable threshold",
++ "upper critical threshold",
++ "upper non-critical threshold",
++ "lower non-recoverable threshold",
++ "lower critical threshold",
++ "lower non-critical threshold",
++ "positive-going hysteresis",
++ "negative-going hysteresis" /* unused */
++};
++
++/* select two out of the 8 possible readable thresholds, and place indexes into the limits
++ array into lim1 and lim2. Set writable flags */
++static void ipmisensors_select_thresholds(struct sdrdata *sd)
++{
++ u8 capab = sd->capab;
++ u16 mask = sd->thresh_mask;
++ int tmp;
++
++ sd->lim1 = -1;
++ sd->lim2 = -1;
++ sd->lim1_write = 0;
++ sd->lim2_write = 0;
++
++ if (((capab & 0x0c) == 0x04) || /* readable thresholds ? */
++ ((capab & 0x0c) == 0x08)) {
++ /* select upper threshold */
++ if (mask & 0x10) { /* upper crit */
++ sd->lim1 = 1;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x1000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x20) { /* upper non-recov */
++ sd->lim1 = 0;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x2000))
++ sd->lim1_write = 1;
++ } else if (mask & 0x08) { /* upper non-crit */
++ sd->lim1 = 2;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0800))
++ sd->lim1_write = 1;
++ }
++
++ /* select lower threshold */
++ if ((((capab & 0x30) == 0x10) || /* readable ? */
++ ((capab & 0x30) == 0x20)) && /* pos hyst */
++ sd->stype == STYPE_TEMP)
++ sd->lim2 = 6;
++ else if (mask & 0x02) { /* lower crit */
++ sd->lim2 = 4;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0200))
++ sd->lim2_write = 1;
++ } else if (mask & 0x04) { /* lower non-recov */
++ sd->lim2 = 3;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0400))
++ sd->lim2_write = 1;
++ } else if (mask & 0x01) { /* lower non-crit */
++ sd->lim2 = 5;
++ if ((capab & 0x0c) == 0x08 && (mask & 0x0100))
++ sd->lim2_write = 1;
++ }
++ }
++
++ /* swap lim1/lim2 if m < 0 or function is 1/x (but not both!) */
++ if ((sd->m < 0 && sd->linear != 7) || (sd->m >= 0 && sd->linear == 7)) {
++ tmp = sd->lim1;
++ sd->lim1 = sd->lim2;
++ sd->lim2 = tmp;
++ }
++
++ if (sd->lim1 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for upper limit\n",
++ threshold_text[sd->lim1]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable upper limit\n");
++
++ if (sd->lim2 >= 0)
++ printk(KERN_INFO "ipmisensors: using %s for lower limit\n",
++ threshold_text[sd->lim2]);
++ else
++ printk(KERN_DEBUG "ipmisensors: no readable lower limit\n");
++}
++
++/************* sysfs callback functions *********/
++static ssize_t show_update_period(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ return snprintf(buf, 20, "%d\n", aattr->bmc->update_period);
++}
++
++static ssize_t store_update_period(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++
++ aattr->bmc->update_period = simple_strtoul(buf, NULL, 10);;
++ return count;
++};
++
++static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ return snprintf(buf, 20, "%ld\n",
++ conv_val(sattr->sdr->reading, sattr->sdr));
++}
++
++static ssize_t show_sensor_max(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long max = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim1 >= 0)
++ max = conv_val(sattr->sdr->limits[sattr->sdr->lim1],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", max);
++}
++
++static ssize_t show_sensor_min(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ long min = 0;
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ if (sattr->sdr->lim2 >= 0)
++ min = conv_val(sattr->sdr->limits[sattr->sdr->lim2],
++ sattr->sdr);
++ return snprintf(buf, 20, "%ld\n", min);
++};
++
++static ssize_t show_sensor_label(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ u8 label[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++
++ ipmisensors_sprintf(label, sattr->sdr->id, sattr->sdr->string_type,
++ sattr->sdr->id_length);
++ return snprintf(buf, 20, "%s\n", label);
++};
++
++static ssize_t store_sensor_max(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set max on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim1);
++ return count;
++};
++
++static ssize_t store_sensor_min(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ long val = simple_strtoul(buf, NULL, 10);
++ struct ipmisensors_device_attribute *sattr =
++ to_ipmisensors_dev_attr(attr);
++ printk(KERN_DEBUG "ipmisensors: set min on sensor #%d to %ld",
++ sattr->sdr->number, val);
++ ipmisensors_set_sensor_threshold(sattr->sdr->bmc, sattr->sdr->number,
++ val, sattr->sdr->lim2);
++ return count;
++};
++
++static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct ipmisensors_bmc_device_attribute *aattr =
++ to_ipmisensors_bmc_dev_attr(attr);
++ return snprintf(buf, 20, "%d\n", aattr->bmc->alarms);
++};
++
++static ssize_t show_name(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ return snprintf(buf, 20, "%s\n", driver_data.driver_name);
++};
++
++/* work function to build the sysfs entries using the ipmi sdrs */
++static void ipmisensors_build_sysfs(struct work_struct *work)
++{
++ int temps = 0, volts = 0, currs = 0, fans = 0;
++ struct sdrdata *cursor, *next;
++ struct ipmisensors_bmc_data *bmc = container_of(work, struct ipmisensors_bmc_data, sysfs_work);
++
++ /* find and create entries for each sdr data struct */
++ list_for_each_entry_safe(cursor, next, &bmc->sdrs, list) {
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++
++ cursor->attr_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_max_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++ cursor->attr_min_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label_name =
++ (char *)kmalloc(sizeof(char) * MAX_FILENAME_LENGTH,
++ GFP_KERNEL);
++
++ if (cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ return;
++ }
++ }
++
++ if (cursor->attr_name == NULL || cursor->attr_max_name == NULL
++ || cursor->attr_min_name == NULL
++ || cursor->attr_label_name == NULL) {
++ printk(KERN_INFO
++ "ipmisensors: Out of memory (kmalloc failed)");
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "temp%d_input", ++temps);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "temp%d_max", temps);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "temp%d_min", temps);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "temp%d_label", temps);
++ break;
++ case (STYPE_VOLT):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "in%d_input", ++volts);
++ /* create min, max attributes */
++ snprintf(cursor->attr_max_name, MAX_FILENAME_LENGTH,
++ "in%d_max", volts);
++ snprintf(cursor->attr_min_name, MAX_FILENAME_LENGTH,
++ "in%d_min", volts);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "in%d_label", volts);
++ break;
++ case (STYPE_CURR):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "curr%d_input", ++currs);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "curr%d_max", currs);
++ sprintf(cursor->attr_min_name, "curr%d_min", currs);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "curr%d_label", currs);
++ break;
++ case (STYPE_FAN):
++ /* create the name of the sensor */
++ snprintf(cursor->attr_name, MAX_FILENAME_LENGTH,
++ "fan%d_input", ++fans);
++ /* create min, max attributes */
++ sprintf(cursor->attr_max_name, "fan%d_max", fans);
++ sprintf(cursor->attr_min_name, "fan%d_min", fans);
++ /* create the label of the sensor */
++ snprintf(cursor->attr_label_name, MAX_FILENAME_LENGTH,
++ "fan%d_label", fans);
++ break;
++ default:
++ printk(KERN_INFO "ipmisensors: unkown sensor type\n");
++ continue;
++ }
++
++ cursor->attr.dev_attr.attr.name = cursor->attr_name;
++ cursor->attr.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr.dev_attr.show = show_sensor;
++ cursor->attr.dev_attr.store = NULL;
++ cursor->attr.sdr = cursor;
++
++ cursor->attr_min.dev_attr.attr.name = cursor->attr_min_name;
++ cursor->attr_min.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_min.dev_attr.show = show_sensor_min;
++ cursor->attr_min.sdr = cursor;
++
++ if (cursor->lim2_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_min.dev_attr.store = store_sensor_min;
++ cursor->attr_min.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_min.dev_attr.store = NULL;
++ cursor->attr_min.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ cursor->attr_max.dev_attr.attr.name = cursor->attr_max_name;
++ cursor->attr_max.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_max.dev_attr.show = show_sensor_max;
++ cursor->attr_max.sdr = cursor;
++
++ if (cursor->lim1_write) {
++ printk(KERN_INFO
++ "ipmisensors: You have a writable sensor threshold! Send me an e-mail at <yani.ioannou@gmail.com>.\n");
++ cursor->attr_max.dev_attr.store = store_sensor_max;
++ cursor->attr_max.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ } else {
++ cursor->attr_max.dev_attr.store = NULL;
++ cursor->attr_max.dev_attr.attr.mode = S_IRUGO;
++ }
++
++ if (cursor->id_length > 0) {
++ cursor->attr_label.dev_attr.attr.name =
++ cursor->attr_label_name;
++ cursor->attr_label.dev_attr.attr.mode = S_IRUGO;
++ cursor->attr_label.dev_attr.attr.owner = THIS_MODULE;
++ cursor->attr_label.dev_attr.show = show_sensor_label;
++ cursor->attr_label.dev_attr.store = NULL;
++ cursor->attr_label.sdr = cursor;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registering sensor %d: (type 0x%.2x) "
++ "(fmt=%d; m=%d; b=%d; k1=%d; k2=%d; cap=0x%.2x; mask=0x%.4x)\n",
++ cursor->number, cursor->stype, cursor->format, cursor->m,
++ cursor->b, cursor->k & 0xf, cursor->k >> 4,
++ cursor->capab, cursor->thresh_mask);
++
++ if (cursor->id_length > 0) {
++ ipmisensors_sprintf(id, cursor->id, cursor->string_type,
++ cursor->id_length);
++ switch (cursor->stype) {
++ case (STYPE_TEMP):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label temp%d \"%s\"\n",
++ temps, id);
++ break;
++ case (STYPE_VOLT):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label in%d \"%s\"\n",
++ volts, id);
++ break;
++ case (STYPE_CURR):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label curr%d \"%s\"\n",
++ currs, id);
++ break;
++ case (STYPE_FAN):
++ printk(KERN_INFO
++ "ipmisensors: sensors.conf: label fan%d \"%s\"\n",
++ fans, id);
++ break;
++ }
++ }
++
++ ipmisensors_select_thresholds(cursor);
++
++ if (cursor->linear != 0 && cursor->linear != 7) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: nonlinear function 0x%.2x unsupported, expect bad results\n",
++ cursor->number, cursor->linear);
++ }
++
++ if ((cursor->format & 0x03) == 0x02) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: 1's complement format unsupported, expect bad results\n",
++ cursor->number);
++ } else if ((cursor->format & 0x03) == 0x03) {
++ printk(KERN_INFO
++ "ipmisensors: sensor %d: threshold sensor only, no readings available",
++ cursor->number);
++ }
++
++ if (cursor->lim1_write || cursor->lim2_write)
++ cursor->attr.dev_attr.attr.mode = 0644;
++ else
++ cursor->attr.dev_attr.attr.mode = 0444;
++
++ if (device_create_file(bmc->dev, &cursor->attr.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_min.dev_attr) < 0
++ || device_create_file(bmc->dev,
++ &cursor->attr_max.dev_attr) < 0
++ || (cursor->id_length >
++ 0 ? device_create_file(bmc->dev,
++ &cursor->attr_label.dev_attr) <
++ 0 : 0)
++ ) {
++ printk(KERN_INFO
++ "ipmisensors: sysfs file creation failed for SDR %d (%s).\n",
++ cursor->number, cursor->id);
++ kfree(cursor->attr_name);
++ kfree(cursor->attr_max_name);
++ kfree(cursor->attr_min_name);
++ kfree(cursor->attr_label_name);
++ return;
++ }
++ }
++
++ bmc->alarms_attr.dev_attr.attr.name = "alarms";
++ bmc->alarms_attr.dev_attr.attr.mode = S_IRUGO;
++ bmc->alarms_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->alarms_attr.dev_attr.show = show_alarms;
++ bmc->alarms_attr.dev_attr.store = NULL;
++ bmc->alarms_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->alarms_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'alarms'");
++ return;
++ }
++
++ bmc->name_attr.attr.name = "name";
++ bmc->name_attr.attr.mode = S_IRUGO;
++ bmc->name_attr.attr.owner = THIS_MODULE;
++ bmc->name_attr.show = show_name;
++
++ if (device_create_file(bmc->dev, &bmc->name_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'name'");
++ return;
++ }
++
++ bmc->update_attr.dev_attr.attr.name = "update_period";
++ bmc->update_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
++ bmc->update_attr.dev_attr.attr.owner = THIS_MODULE;
++ bmc->update_attr.dev_attr.show = show_update_period;
++ bmc->update_attr.dev_attr.store = store_update_period;
++ bmc->update_attr.bmc = bmc;
++
++ if (device_create_file(bmc->dev, &bmc->update_attr.dev_attr) < 0) {
++ printk(KERN_INFO
++ "ipmisensors: Failed to create sysfs entry 'update_period'");
++ return;
++ }
++
++ printk(KERN_INFO
++ "ipmisensors: registered %d temp, %d volt, %d current, %d fan sensors\n",
++ temps, volts, currs, fans);
++
++ /* This completes the initialization. We can now kickoff the
++ * periodic update of the bmc sensor's values by scheduling
++ * the first work.
++ */
++ queue_work(ipmisensors_workqueue, &bmc->update_work.work);
++
++}
++
++/**
++ * Process an SDR response message, save the SDRs we like in the sdr
++ * list for the given BMC.
++ *
++ * @bmc: the bmc the message is from
++ * @msg: the IPMI SDR response message
++ */
++static void ipmisensors_rcv_sdr_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ u16 record;
++ int type;
++ int stype;
++ int id_length;
++ int i;
++ int ipmi_ver = 0;
++ unsigned char *data;
++ u8 id[SDR_MAX_UNPACKED_ID_LENGTH];
++ struct sdrdata *sdr;
++
++ if (msg->data[0] != 0) {
++ /* cut request in half and try again */
++ bmc->ipmi_sdr_partial_size /= 2;
++ if (bmc->ipmi_sdr_partial_size < 8) {
++ printk(KERN_INFO
++ "ipmisensors: IPMI buffers too small, giving up\n");
++ bmc->state = STATE_DONE;
++ return;
++ }
++ printk(KERN_DEBUG
++ "ipmisensors: Reducing SDR request size to %d\n",
++ bmc->ipmi_sdr_partial_size);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ if (bmc->ipmi_sdr_partial_size < IPMI_SDR_SIZE) {
++ if (bmc->rx_msg_data_offset == 0) {
++ memcpy(bmc->rx_msg_data, msg->data,
++ bmc->ipmi_sdr_partial_size + 3);
++ bmc->rx_msg_data_offset =
++ bmc->ipmi_sdr_partial_size + 3;
++ } else {
++ memcpy(bmc->rx_msg_data + bmc->rx_msg_data_offset,
++ msg->data + 3, bmc->ipmi_sdr_partial_size);
++ bmc->rx_msg_data_offset += bmc->ipmi_sdr_partial_size;
++ }
++ if (bmc->rx_msg_data_offset > bmc->rx_msg_data[7] + 7) {
++ /* got last chunk */
++ bmc->rx_msg_data_offset = 0;
++ data = bmc->rx_msg_data;
++ } else {
++ /* get more */
++ record =
++ (bmc->rx_msg_data[4] << 8) | bmc->rx_msg_data[3];
++ ipmisensors_get_sdr(bmc, bmc->resid, record,
++ bmc->rx_msg_data_offset - 3);
++ bmc->state = STATE_SDR;
++ return;
++ }
++ } else {
++ /* got it in one chunk */
++ data = msg->data;
++ }
++
++ bmc->nextrecord = (data[2] << 8) | data[1];
++
++ /* If the ipmi version is 0.9 we have to remap some things.
++ * Yes this is very ugly, but we aren't the ones who
++ * implemented an incomplete spec!
++ */
++ ipmi_ver = data[5];
++
++ type = data[6];
++ /* known SDR type */
++ if (type == 1 || type == 2) {
++ stype = data[(ipmi_ver == 0x90 ? 16 : 15)];
++ /* known sensor type */
++ if (stype <= STYPE_MAX) {
++ if (data[(ipmi_ver == 0x90 ? 17 : 16)] != 0x01) {
++ if (type == 1)
++ ipmisensors_sprintf(id, &data[51],
++ data[50] >> 6,
++ data[50] & 0x1f);
++ else
++ ipmisensors_sprintf(id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 :
++ 35)],
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] >> 6,
++ data[(ipmi_ver ==
++ 0x90 ? 29 :
++ 34)] & 0x1f);
++ printk(KERN_INFO
++ "ipmisensors: skipping non-threshold sensor \"%s\"\n",
++ id);
++ } else {
++ /* add entry to sdrd table */
++ sdr = ipmisensors_new_sdr();
++ if (!sdr) {
++ printk(KERN_ERR
++ "ipmisensors: could not allocate memory for new SDR");
++ return;
++ }
++ sdr->bmc = bmc;
++ sdr->stype = stype;
++ sdr->number = data[10];
++ sdr->capab = data[(ipmi_ver == 0x90 ? 15 : 14)];
++ sdr->thresh_mask =
++ (((u16) data[(ipmi_ver == 0x90 ? 21 : 22)])
++ << 8) | data[21];
++ if (type == 1) {
++ sdr->format =
++ data[(ipmi_ver ==
++ 0x90 ? 22 : 24)] >> 6;
++ sdr->linear =
++ data[(ipmi_ver ==
++ 0x90 ? 25 : 26)] & 0x7f;
++ sdr->m =
++ data[(ipmi_ver == 0x90 ? 26 : 27)];
++ sdr->m |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 27 : 28)]
++ & 0xc0)) << 2;
++ if (sdr->m & 0x0200) {
++ /* sign extend */
++ sdr->m |= 0xfc00;
++ }
++ sdr->b =
++ data[(ipmi_ver == 0x90 ? 28 : 29)];
++ sdr->b |= ((u16)
++ (data
++ [(ipmi_ver ==
++ 0x90 ? 29 : 30)]
++ & 0xc0)) << 2;
++ if (sdr->b & 0x0200) {
++ /* sign extend */
++ sdr->b |= 0xfc00;
++ }
++ sdr->k =
++ data[(ipmi_ver == 0x90 ? 31 : 32)];
++ sdr->nominal =
++ data[(ipmi_ver == 0x90 ? 33 : 34)];
++ for (i = 0; i < SDR_LIMITS; i++) {
++ /* assume readable */
++ sdr->limits[i] =
++ data[(ipmi_ver ==
++ 0x90 ? 40 : 39) + i];
++ }
++ sdr->string_type = data[50] >> 6;
++ id_length = data[50] & 0x1f;
++ memcpy(sdr->id, &data[51], id_length);
++ sdr->id_length = id_length;
++ } else {
++ sdr->m = 1;
++ sdr->b = 0;
++ sdr->k = 0;
++ sdr->string_type =
++ data[(ipmi_ver ==
++ 0x90 ? 29 : 34)] >> 6;
++ id_length = data[34] & 0x1f;
++ if (id_length > 0) {
++ memcpy(sdr->id,
++ &data[(ipmi_ver ==
++ 0x90 ? 30 : 35)],
++ id_length);
++ }
++ sdr->id_length = id_length;
++ /* limits?? */
++ if (ipmi_ver == 0x90) {
++ memcpy(sdr->id,
++ &data[30], id_length);
++ sdr->id_length = id_length;
++ }
++ }
++ ipmisensors_add_sdr(bmc, sdr);
++ }
++ }
++ /* peek at the other SDR types */
++ } else if (type == 0x10 || type == 0x11 || type == 0x12) {
++ ipmisensors_sprintf(id, data + 19, data[18] >> 6,
++ data[18] & 0x1f);
++ if (type == 0x10) {
++ printk(KERN_INFO
++ "ipmisensors: Generic Device acc=0x%x; slv=0x%x; lun=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[13], id);
++ } else if (type == 0x11) {
++ printk(KERN_INFO
++ "ipmisensors: FRU Device acc=0x%x; slv=0x%x; log=0x%x; ch=0x%x; type=0x%x; \"%s\"\n",
++ data[8], data[9], data[10], data[11], data[13],
++ id);
++ } else {
++ printk(KERN_INFO
++ "ipmisensors: Mgmt Ctllr Device slv=0x%x; \"%s\"\n",
++ data[8], id);
++ }
++ } else if (type == 0x14) {
++ printk(KERN_INFO
++ "ipmisensors: Message Channel Info Records:\n");
++ for (i = 0; i < 8; i++) {
++ printk(KERN_INFO "ipmisensors: Channel %d info 0x%x\n",
++ i, data[9 + i]);
++ }
++ } else {
++ printk(KERN_INFO "ipmisensors: Skipping SDR type 0x%x\n", type);
++ }
++ if (ipmi_ver != 0x90) {
++ if (bmc->nextrecord >= 6224) {
++ /*YJ stop sensor scan on poweredge 1750 */
++ bmc->nextrecord = 0xffff;
++ }
++ }
++
++ if (bmc->nextrecord == 0xFFFF) {
++ if (bmc->sdr_count == 0) {
++ printk(KERN_INFO
++ "ipmisensors: No recognized sensors found.\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_INFO "ipmisensors: all sensors detected\n");
++ bmc->state = STATE_SYSTABLE;
++
++ /* Schedule sysfs build/registration work */
++ INIT_WORK(&bmc->sysfs_work, ipmisensors_build_sysfs);
++ queue_work(ipmisensors_workqueue, &bmc->sysfs_work);
++ }
++ } else {
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ }
++}
++
++/**
++ * Process incoming messages based on internal state
++ *
++ * @bmc: the bmc the message is from.
++ * @msg: the ipmi message to process.
++ */
++static void ipmisensors_rcv_msg(struct ipmisensors_bmc_data *bmc,
++ struct kernel_ipmi_msg *msg)
++{
++ switch (bmc->state) {
++ case STATE_INIT:
++ case STATE_RESERVE:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got first resid 0x%.4x\n",
++ bmc->resid);
++
++ ipmisensors_get_sdr(bmc, 0, 0, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_SDR:
++ case STATE_SDRPARTIAL:
++ ipmisensors_rcv_sdr_msg(bmc, msg);
++ break;
++
++ case STATE_READING:
++ ipmisensors_rcv_reading_msg(bmc, msg);
++ break;
++
++ case STATE_UNCANCEL:
++ bmc->resid = (((u16) msg->data[2]) << 8) | msg->data[1];
++
++ printk(KERN_DEBUG "ipmisensors: Got new resid 0x%.4x\n",
++ bmc->resid);
++
++ bmc->rx_msg_data_offset = 0;
++ ipmisensors_get_sdr(bmc, 0, bmc->nextrecord, 0);
++ bmc->state = STATE_SDR;
++ break;
++
++ case STATE_DONE:
++ case STATE_SYSTABLE:
++ break;
++ default:
++ bmc->state = STATE_INIT;
++ }
++}
++
++/**
++ * Callback to handle a received IPMI message from a given BMC.
++ *
++ * @msg: the received message.
++ * @handler_data: a pointer to the particular bmc ipmisensors_bmc_data struct.
++ */
++static void ipmisensors_msg_handler(struct ipmi_recv_msg *msg,
++ void *user_msg_data)
++{
++ struct ipmisensors_bmc_data *bmc =
++ (struct ipmisensors_bmc_data *)user_msg_data;
++
++ if (msg->msg.data[0] != 0)
++ printk(KERN_WARNING
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x\n",
++ msg->msg.data[0], msg->msg.netfn, msg->msg.cmd);
++
++ if (bmc != NULL && ipmisensors_intf_registered(bmc->interface_id)) {
++ if (bmc->state == STATE_SDR &&
++ msg->msg.data[0] == IPMI_INVALID_RESERVATION_ID) {
++ /* reservation cancelled, get new resid */
++ if (++bmc->errorcount > 275) {
++ printk(KERN_ERR
++ "ipmisensors: Too many reservations cancelled, giving up\n");
++ bmc->state = STATE_DONE;
++ } else {
++ printk(KERN_DEBUG
++ "ipmisensors: resid 0x%04x cancelled, getting new one\n",
++ bmc->resid);
++
++ ipmisensors_reserve_sdr(bmc);
++ bmc->state = STATE_UNCANCEL;
++ }
++ } else if (msg->msg.data[0] != IPMI_CC_NO_ERROR &&
++ msg->msg.data[0] != IPMI_ERR_RETURNING_REQ_BYTES &&
++ msg->msg.data[0] != IPMI_ERR_PROVIDING_RESPONSE) {
++ printk(KERN_ERR
++ "ipmisensors: Error 0x%x on cmd 0x%x/0x%x; state = %d; probably fatal.\n",
++ msg->msg.data[0], msg->msg.netfn & 0xfe,
++ msg->msg.cmd, bmc->state);
++ } else {
++ printk(KERN_DEBUG "ipmisensors: received message\n");
++ ipmisensors_rcv_msg(bmc, &msg->msg);
++ }
++
++ } else {
++ printk(KERN_WARNING
++ "ipmisensors: Response for non-registered BMC\n");
++ if (bmc != NULL)
++ printk(KERN_DEBUG "ipmisensors: BMC ID: %d\n",
++ bmc->interface_id);
++ else
++ printk(KERN_DEBUG "ipmisensors: BMC NULL!\n");
++ }
++
++ ipmi_free_recv_msg(msg);
++}
++
++/****** IPMI Interface Initialization ******/
++
++/**
++ * Return true if the given ipmi interface has been registered.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static int ipmisensors_intf_registered(int ipmi_intf)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Return true if the given BMC has been registered.
++ *
++ * @bmc: The BMC device.
++ */
++static int ipmisensors_bmc_registered(struct device *bmc)
++{
++ int found = 0;
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->dev == bmc) {
++ found++;
++ }
++ }
++
++ return found;
++}
++
++/**
++ * Register new IPMI BMC interface. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_register_bmc(int ipmi_intf, struct ipmi_addr *address)
++{
++ int error;
++
++ /* allocate a new ipmisensors_bmc_data struct */
++
++ struct ipmisensors_bmc_data *bmc = (struct ipmisensors_bmc_data *)
++ kmalloc(sizeof(struct ipmisensors_bmc_data), GFP_KERNEL);
++
++ /* initialize members */
++ INIT_LIST_HEAD(&bmc->sdrs);
++ bmc->interface_id = ipmi_intf;
++
++ bmc->address = *address;
++
++ bmc->sdr_count = 0;
++ bmc->msgid = 0;
++ bmc->ipmi_sdr_partial_size = IPMI_CHUNK_SIZE;
++ bmc->state = STATE_INIT;
++ bmc->errorcount = 0;
++ bmc->rx_msg_data_offset = 0;
++ bmc->dev = ipmi_get_bmcdevice(ipmi_intf);
++
++ /* default to 3 second min update interval */
++ bmc->update_period = 3;
++
++ if (bmc->dev == NULL) {
++ printk(KERN_ERR
++ "ipmisensors: Error, couldn't get BMC device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Create IPMI messaging interface user */
++ error = ipmi_create_user(bmc->interface_id, &driver_data.ipmi_hndlrs,
++ bmc, &bmc->user);
++ if (error < 0) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register user with ipmi interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC as a HWMON class device */
++ bmc->class_dev = hwmon_device_register(bmc->dev);
++
++ if (IS_ERR(bmc->class_dev)) {
++ printk(KERN_ERR
++ "ipmisensors: Error, unable to register hwmon class device for interface %d\n",
++ bmc->interface_id);
++ kfree(bmc);
++ return;
++ }
++
++ /* Register the BMC in the driver */
++ if (ipmisensors_bmc_registered(bmc->dev)) {
++ printk(KERN_ERR
++ "ipmisensors: BMC on interface %d already registered\n",
++ bmc->interface_id);
++ hwmon_device_unregister(bmc->class_dev);
++ kfree(bmc);
++ return;
++ }
++
++ ipmi_get_version(bmc->user, &bmc->ipmi_version_major,
++ &bmc->ipmi_version_minor);
++
++ /* finally add the new bmc data to the bmc data list */
++ list_add_tail(&bmc->list, &driver_data.bmc_data);
++ driver_data.interfaces++;
++
++ printk(KERN_INFO
++ "ipmisensors: Registered IPMI %d.%d BMC over interface %d\n",
++ bmc->ipmi_version_major,
++ bmc->ipmi_version_minor, bmc->interface_id);
++
++ /* Send a reserve SDR command to the bmc */
++ ipmisensors_reserve_sdr(bmc);
++
++ /* initialize the bmc's update work struct */
++ INIT_DELAYED_WORK(&bmc->update_work, ipmisensors_update_bmc);
++}
++
++/**
++ * Callback for when an IPMI BMC is gone. Interface indpendent callback created
++ * for flexibility in adding new types of interface callbacks in future.
++ *
++ * @ipmi_intf: The IPMI interface number.
++ */
++static void ipmisensors_unregister_bmc(int ipmi_intf)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ if (cursor->interface_id == ipmi_intf) {
++ list_del(&cursor->list);
++ printk(KERN_DEBUG
++ "ipmisensors: cancelling queued work\n");
++ /* cancel update work queued for this bmc */
++ cancel_delayed_work(&cursor->update_work);
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev,
++ &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev,
++ &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ driver_data.interfaces--;
++ }
++ }
++
++}
++
++/**
++ * Unregister all registered bmcs.
++ */
++static void ipmisensors_unregister_bmc_all(void)
++{
++ struct ipmisensors_bmc_data *cursor, *next;
++
++ /* find and free the ipmisensors_bmc_data struct */
++ list_for_each_entry_safe(cursor, next, &driver_data.bmc_data, list) {
++ list_del(&cursor->list);
++
++ /* cancel update work queued for this bmc */
++ printk(KERN_DEBUG "ipmisensors: cancelling queued work\n");
++ cancel_delayed_work(&cursor->update_work);
++
++ printk(KERN_DEBUG
++ "ipmisensors: waiting for update to finish\n");
++ /* wait for readings to finish */
++ while (cursor->state != STATE_DONE) ;
++
++ device_remove_file(cursor->dev, &cursor->alarms_attr.dev_attr);
++ device_remove_file(cursor->dev, &cursor->update_attr.dev_attr);
++ hwmon_device_unregister(cursor->class_dev);
++ ipmisensors_sdr_cleanup(cursor);
++ ipmi_destroy_user(cursor->user);
++
++ printk(KERN_INFO
++ "ipmisensors: Unegistered IPMI interface %d\n",
++ cursor->interface_id);
++
++ kfree(cursor);
++ }
++
++ driver_data.interfaces = 0;
++}
++
++/**
++ * Callback for when a new IPMI SMI type interface is found.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_new_smi(int if_num, struct device *dev)
++{
++ struct ipmi_addr smi_address = {
++ IPMI_SYSTEM_INTERFACE_ADDR_TYPE,
++ IPMI_BMC_CHANNEL,
++ {0},
++ };
++
++ /* calls the generic new interface function */
++ ipmisensors_register_bmc(if_num, &smi_address);
++}
++
++/**
++ * Callback for when an exisiting IPMI SMI type interface is gone.
++ *
++ * @if_num: The IPMI interface number.
++ */
++static void ipmisensors_smi_gone(int if_num)
++{
++ if (driver_data.interfaces > 0) {
++ ipmisensors_unregister_bmc(if_num);
++ }
++}
++
++/**
++ * Initialize the module.
++ */
++static int __init ipmisensors_init(void)
++{
++ int error;
++ printk(KERN_INFO "ipmisensors - IPMI BMC sensors interface\n");
++
++ /* init cache managers */
++ driver_data.sdrdata_cache =
++ kmem_cache_create("ipmisensors_sdrdata", sizeof(struct sdrdata), 0,
++ 0, NULL, NULL);
++ driver_data.sysfsattr_cache =
++ kmem_cache_create("ipmisensors_sysfsattr",
++ sizeof(struct ipmisensors_device_attribute), 0, 0,
++ NULL, NULL);
++
++ if (!driver_data.sdrdata_cache || !driver_data.sysfsattr_cache) {
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++ return -ENOMEM;
++ }
++
++ /* register IPMI interface callback(s) */
++ error = ipmi_smi_watcher_register(&driver_data.smi_watcher);
++ if (error) {
++ printk(KERN_WARNING
++ "ipmisensors: can't register smi watcher\n");
++ return error;
++ }
++
++ /* create work queue, keep it simple, single-threaded */
++ ipmisensors_workqueue =
++ create_singlethread_workqueue("ipmisensors_workqueue");
++
++ return 0;
++}
++
++/**
++ * Cleanup
++ */
++static void ipmisensors_cleanup(void)
++{
++ /* start cleanup */
++ cleanup = 1;
++
++ /* unregister bmcs */
++ printk(KERN_DEBUG "ipmisensors: unregister bmcs\n");
++ ipmi_smi_watcher_unregister(&driver_data.smi_watcher);
++ ipmisensors_unregister_bmc_all();
++
++ /* flush & destroy work queue */
++ printk(KERN_DEBUG "ipmisensors: destroy workqueue\n");
++ flush_workqueue(ipmisensors_workqueue);
++ destroy_workqueue(ipmisensors_workqueue);
++
++ /* remove cache managers */
++ if (driver_data.sdrdata_cache)
++ kmem_cache_destroy(driver_data.sdrdata_cache);
++ if (driver_data.sysfsattr_cache)
++ kmem_cache_destroy(driver_data.sysfsattr_cache);
++}
++
++/**
++ * Cleanup and exit the module
++ */
++static void __exit ipmisensors_exit(void)
++{
++ ipmisensors_cleanup();
++ printk(KERN_DEBUG "ipmisensors: cleanup finished\n");
++}
++
++MODULE_AUTHOR("Yani Ioannou <yani.ioannou@gmail.com>");
++MODULE_DESCRIPTION("IPMI BMC sensors");
++MODULE_LICENSE("GPL");
++
++module_init(ipmisensors_init);
++module_exit(ipmisensors_exit);
+diff -rduNp linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.h linux-2.6.22.1/drivers/hwmon/ipmisensors.h
+--- linux-2.6.22.1.oorig2/drivers/hwmon/ipmisensors.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/drivers/hwmon/ipmisensors.h 2007-07-24 14:22:26.000000000 +0200
+@@ -0,0 +1,240 @@
++/*
++ * ipmisensors.h - lm_sensors interface to IPMI sensors.
++ *
++ * Copyright (C) 2004-2006 Yani Ioannou <yani.ioannou@gmail.com>
++ *
++ * Adapted from bmcsensors (lm-sensors for linux 2.4)
++ * bmcsensors (C) Mark D. Studebaker <mdsxyz123@yahoo.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/ipmi.h>
++#include <linux/list.h>
++#include <linux/slab.h>
++#include <linux/workqueue.h>
++
++/* SDR defs */
++#define STYPE_TEMP 0x01
++#define STYPE_VOLT 0x02
++#define STYPE_CURR 0x03
++#define STYPE_FAN 0x04
++
++#define SDR_LIMITS 8
++#define SDR_MAX_ID_LENGTH 16
++#define SDR_MAX_UNPACKED_ID_LENGTH ((SDR_MAX_ID_LENGTH * 4 / 3) + 2)
++
++/* the last sensor type we are interested in */
++#define STYPE_MAX 4
++
++#define IPMI_SDR_SIZE 67
++#define IPMI_CHUNK_SIZE 16
++
++#define MAX_FILENAME_LENGTH 30
++
++struct ipmisensors_device_attribute {
++ struct device_attribute dev_attr;
++ struct sdrdata *sdr;
++};
++#define to_ipmisensors_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_device_attribute, dev_attr)
++
++#define IPMISENSORS_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
++struct ipmisensors_attribute sensor_dev_attr_##_name = { \
++ .dev_attr = __ATTR(_name,_mode,_show,_store), \
++ .index = _index, \
++}
++
++struct ipmisensors_bmc_device_attribute {
++ struct device_attribute dev_attr;
++ struct ipmisensors_bmc_data *bmc;
++};
++#define to_ipmisensors_bmc_dev_attr(_dev_attr) \
++ container_of(_dev_attr, struct ipmisensors_bmc_device_attribute, dev_attr)
++
++/**
++ * &struct_sdrdata stores the IPMI Sensor Data Record (SDR) data, as recieved from the BMC, along with the corresponding sysfs attributes
++ */
++struct sdrdata {
++ struct list_head list;
++ /* retrieved from SDR, not expected to change */
++ /* Sensor Type Code */
++ u8 stype;
++ u8 number;
++ /* Sensor Capability Code */
++ u8 capab;
++ u16 thresh_mask;
++ u8 format;
++ u8 linear;
++ s16 m;
++ s16 b;
++ u8 k;
++ u8 nominal;
++ u8 limits[SDR_LIMITS];
++ /* index into limits for reported upper and lower limit */
++ int lim1, lim2;
++ u8 lim1_write, lim2_write;
++ u8 string_type;
++ u8 id_length;
++ u8 id[SDR_MAX_ID_LENGTH];
++ /* retrieved from reading */
++ u8 reading;
++ u8 status;
++ u8 thresholds;
++ /* sensor's bmc */
++ struct ipmisensors_bmc_data *bmc;
++ /* sysfs entries */
++ struct ipmisensors_device_attribute attr;
++ char *attr_name;
++ struct ipmisensors_device_attribute attr_min;
++ char *attr_min_name;
++ struct ipmisensors_device_attribute attr_max;
++ char *attr_max_name;
++ struct ipmisensors_device_attribute attr_label;
++ char *attr_label_name;
++
++};
++
++/**
++ * &struct_ipmisensors_data stores the data for the ipmisensors driver.
++ */
++struct ipmisensors_data {
++ /* Driver struct */
++ char *driver_name;
++
++ /* Linked list of ipmisensors_bmc_data structs, one for each BMC */
++ struct list_head bmc_data;
++
++ /* Number of ipmi interfaces (and hence ipmisensors_data structs). */
++ int interfaces;
++
++ /* IPMI kernel interface - SMI watcher */
++ struct ipmi_smi_watcher smi_watcher;
++
++ /* IPMI kernel interface - user handlers */
++ struct ipmi_user_hndl ipmi_hndlrs;
++
++ /* Cache manager for sdrdata cache */
++ struct kmem_cache *sdrdata_cache;
++
++ /* Cache manager for ipmi_sensor_device_attribute cache */
++ struct kmem_cache *sysfsattr_cache;
++};
++
++/**
++ * &states: enumeration of state codes for a bmc specific ipmisensors
++ */
++enum states {
++ STATE_INIT,
++ STATE_RESERVE,
++ STATE_SDR,
++ STATE_SDRPARTIAL,
++ STATE_READING,
++ STATE_UNCANCEL,
++ STATE_SYSTABLE,
++ STATE_DONE
++};
++
++/**
++ * &struct_ipmisensors_bmc_data stores the data for a particular IPMI BMC.
++ */
++struct ipmisensors_bmc_data {
++ struct list_head list;
++
++ /* The IPMI interface number */
++ int interface_id;
++
++ /* The IPMI address */
++ struct ipmi_addr address;
++
++ /* List of sdrdata structs (sdrs) recieved from the BMC */
++ struct list_head sdrs;
++
++ /* Count of the number of sdrs stored in the sdr list */
++ int sdr_count;
++
++ /* next message id */
++ int msgid;
++
++ /* The ipmi interface 'user' used to access this particular bmc */
++ ipmi_user_t user;
++
++ /* BMC IPMI Version (major) */
++ unsigned char ipmi_version_major;
++
++ /* BMC IPMI Version (minor) */
++ unsigned char ipmi_version_minor;
++
++ /* The size of the SDR request message */
++ int ipmi_sdr_partial_size;
++
++ /* transmit message buffer */
++ struct kernel_ipmi_msg tx_message;
++
++ /* ipmi transmited data buffer */
++ unsigned char tx_msg_data[IPMI_MAX_MSG_LENGTH + 50]; /* why the +50 in bmcsensors? */
++
++ /* ipmi recieved data buffer */
++ unsigned char rx_msg_data[IPMI_MAX_MSG_LENGTH + 50];
++
++ /* current recieve buffer offset */
++ int rx_msg_data_offset;
++
++ /* The id of then next SDR record to read during update cycle */
++ u16 nextrecord;
++
++ /* BMC SDR Reservation ID */
++ u16 resid;
++
++ /* Alarm status */
++ u8 alarms;
++
++ /* The cumalative error count for this bmc */
++ int errorcount;
++
++ /* The current state of this bmc w.r.t. ipmisensors (see enum states) */
++ int state;
++
++ /* The current sdr for which a reading is pending */
++ struct sdrdata *current_sdr;
++
++ /* The BMC's device struct */
++ struct device *dev;
++
++ /* hwmon class device */
++ struct class_device *class_dev;
++
++ /* hwmon device name */
++ struct device_attribute name_attr;
++
++ /* alarms attribute */
++ struct ipmisensors_bmc_device_attribute alarms_attr;
++
++ /* update_period attribute */
++ struct ipmisensors_bmc_device_attribute update_attr;
++
++ /* lower bound on time between updates (in seconds) */
++ unsigned int update_period;
++
++ /* semaphore used to do a headcount of the SDR readings we are waiting
++ * on in a given bmc update */
++ struct semaphore update_semaphore;
++
++ /* bmc's work struct for updating sensors */
++ struct delayed_work update_work;
++
++ /* bmc's work struct for building the sysfs workqueue */
++ struct work_struct sysfs_work;
++};
+diff -rduNp linux-2.6.22.1.oorig2/include/linux/ipmi.h linux-2.6.22.1/include/linux/ipmi.h
+--- linux-2.6.22.1.oorig2/include/linux/ipmi.h 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/include/linux/ipmi.h 2007-07-24 14:22:26.000000000 +0200
+@@ -300,6 +300,9 @@ int ipmi_create_user(unsigned int
+ safe, too. */
+ int ipmi_destroy_user(ipmi_user_t user);
+
++/* Get the IPMI BMC's device struct */
++struct device *ipmi_get_bmcdevice(int ipmi_intf);
++
+ /* Get the IPMI version of the BMC we are talking to. */
+ void ipmi_get_version(ipmi_user_t user,
+ unsigned char *major,
+diff -rduNp linux-2.6.22.1.oorig2/include/linux/ipmi_msgdefs.h linux-2.6.22.1/include/linux/ipmi_msgdefs.h
+--- linux-2.6.22.1.oorig2/include/linux/ipmi_msgdefs.h 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/include/linux/ipmi_msgdefs.h 2007-07-24 14:22:26.000000000 +0200
+@@ -45,6 +45,7 @@
+
+ #define IPMI_NETFN_APP_REQUEST 0x06
+ #define IPMI_NETFN_APP_RESPONSE 0x07
++#define IPMI_GET_DEVICE_GUID_CMD 0x08
+ #define IPMI_GET_DEVICE_ID_CMD 0x01
+ #define IPMI_COLD_RESET_CMD 0x02
+ #define IPMI_WARM_RESET_CMD 0x03
+@@ -57,6 +58,11 @@
+ #define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
+ #define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
+ #define IPMI_GET_CHANNEL_INFO_CMD 0x42
++#define IPMI_RESERVE_SDR 0x22
++#define IPMI_GET_SDR 0x23
++#define IPMI_GET_SENSOR_STATE_READING 0x2D
++#define IPMI_SET_SENSOR_HYSTERESIS 0x24
++#define IPMI_SET_SENSOR_THRESHOLD 0x26
+
+ #define IPMI_NETFN_STORAGE_REQUEST 0x0a
+ #define IPMI_NETFN_STORAGE_RESPONSE 0x0b
+@@ -79,10 +85,13 @@
+ #define IPMI_NODE_BUSY_ERR 0xc0
+ #define IPMI_INVALID_COMMAND_ERR 0xc1
+ #define IPMI_TIMEOUT_ERR 0xc3
++#define IPMI_INVALID_RESERVATION_ID 0xc5
+ #define IPMI_ERR_MSG_TRUNCATED 0xc6
+ #define IPMI_REQ_LEN_INVALID_ERR 0xc7
+ #define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
+ #define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
++#define IPMI_ERR_RETURNING_REQ_BYTES 0xca
++#define IPMI_ERR_PROVIDING_RESPONSE 0xce
+ #define IPMI_LOST_ARBITRATION_ERR 0x81
+ #define IPMI_BUS_ERR 0x82
+ #define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-new.makefile b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-new.makefile
new file mode 100644
index 0000000000..7852c04bcc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-new.makefile
@@ -0,0 +1,91 @@
+#############################################################
+#
+# full kernel tarballs >= 2.6.19.1
+#
+#############################################################
+
+# new-style kernels?
+ifeq ($(LINUX_HEADERS_VERSION),)
+# parse linux version string
+LNXVER:=$(subst ., , $(strip $(DEFAULT_KERNEL_HEADERS)))
+VERSION:=$(word 1, $(LNXVER))
+PATCHLEVEL:=$(word 2, $(LNXVER))
+SUBLEVEL:=$(word 3, $(LNXVER))
+EXTRAVERSION:=$(word 4, $(LNXVER))
+LOCALVERSION:=
+
+# should contain prepended dot
+EXTRAVERSION:=$(if $(EXTRAVERSION),.$(EXTRAVERSION),)
+
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=$(BR2_KERNEL_MIRROR)/linux/kernel/v2.6/
+LINUX_HEADERS_SOURCE:=linux-$(LINUX_HEADERS_VERSION).tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_IS_KERNEL=y
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.22.1")
+LINUX_RT_VERSION:=rt9
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.21.5")
+LINUX_RT_VERSION:=rt20
+endif
+
+ifeq ($(LINUX_HEADERS_IS_KERNEL),y)
+# Need to redefine KERNEL_HEADERS_PATCH_DIR if you want
+# board specific kernel headers
+KERNEL_HEADERS_PATCH_DIR:=toolchain/kernel-headers/empty
+LINUX_HEADERS_DEPENDS:=
+
+ifeq ($(BR2_KERNEL_HEADERS_RT),y)
+LINUX_RT_SOURCE:=patch-$(LINUX_HEADERS_VERSION)-$(LINUX_RT_VERSION)
+LINUX_RT_SITE:=$(BR2_KERNEL_MIRROR)/linux/kernel/projects/rt/older/
+LINUX_HEADERS_DEPENDS+=$(DL_DIR)/$(LINUX_RT_SOURCE)
+$(DL_DIR)/$(LINUX_RT_SOURCE):
+ $(WGET) -P $(DL_DIR) $(LINUX_RT_SITE)/$(LINUX_RT_SOURCE)
+endif
+
+$(LINUX_HEADERS_UNPACK_DIR)/.unpacked: $(DL_DIR)/$(LINUX_HEADERS_SOURCE)
+ @echo "*** Using kernel-headers generated from kernel source"
+ rm -rf $(LINUX_HEADERS_DIR)
+ [ -d $(TOOL_BUILD_DIR) ] || $(INSTALL) -d $(TOOL_BUILD_DIR)
+ $(LINUX_HEADERS_CAT) $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ touch $@
+
+$(LINUX_HEADERS_UNPACK_DIR)/.patched: $(LINUX_HEADERS_UNPACK_DIR)/.unpacked $(LINUX_HEADERS_DEPENDS)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) toolchain/kernel-headers \
+ linux-$(LINUX_HEADERS_VERSION)-\*.patch{,.gz,.bz2}
+ifeq ($(BR2_KERNEL_HEADERS_IPMI),y)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) toolchain/kernel-headers/ipmi \
+ linux-$(LINUX_HEADERS_VERSION)-\*.patch{,.gz,.bz2}
+endif
+ifeq ($(BR2_KERNEL_HEADERS_LZMA),y)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) toolchain/kernel-headers/lzma \
+ linux-$(LINUX_HEADERS_VERSION)-\*.patch{,.gz,.bz2}
+endif
+ifeq ($(BR2_KERNEL_HEADERS_RT),y)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) $(DL_DIR) $(LINUX_RT_SOURCE)
+endif
+ifeq ($(BR2_KERNEL_HEADERS_PATCH_DIR),y)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) $(KERNEL_HEADERS_PATCH_DIR) \
+ \*.patch{,.gz,.bz2}
+endif
+ifeq ($(BR2_PACKAGE_OPENSWAN),y)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) package/openswan \
+ linux-$(LINUX_HEADERS_VERSION)-\*.patch{,.gz,.bz2}
+endif
+ touch $@
+
+$(LINUX_HEADERS_DIR)/.configured: $(LINUX_HEADERS_UNPACK_DIR)/.patched
+ (cd $(LINUX_HEADERS_UNPACK_DIR); \
+ $(MAKE) ARCH=$(KERNEL_ARCH) \
+ HOSTCC="$(HOSTCC)" HOSTCFLAGS="$(HOSTCFLAGS)" \
+ HOSTCXX="$(HOSTCXX)" \
+ INSTALL_HDR_PATH=$(LINUX_HEADERS_DIR) headers_install; \
+ )
+ touch $@
+
+endif
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old-versions.makefile b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old-versions.makefile
new file mode 100644
index 0000000000..01e530084f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old-versions.makefile
@@ -0,0 +1,103 @@
+#############################################################
+#
+# Setup the kernel headers. I include a generic package of
+# kernel headers here, so you shouldn't need to include your
+# own. Be aware these kernel headers _will_ get blown away
+# by a 'make clean' so don't put anything sacred in here...
+#
+#############################################################
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.4.25")
+VERSION:=2
+PATCHLEVEL:=4
+SUBLEVEL:=25
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://www.uclibc.org/downloads/toolchain
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.4.25.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.4.25
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.4.27")
+VERSION:=2
+PATCHLEVEL:=4
+SUBLEVEL:=27
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://www.uclibc.org/downloads/toolchain
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.4.27.tar.bz2
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.4.27
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.4.29")
+VERSION:=2
+PATCHLEVEL:=4
+SUBLEVEL:=29
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://www.uclibc.org/downloads/toolchain
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.4.29.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.4.29
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.4.31")
+VERSION:=2
+PATCHLEVEL:=4
+SUBLEVEL:=31
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://www.uclibc.org/downloads/toolchain
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.4.31.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.4.31
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.9")
+VERSION:=2
+PATCHLEVEL:=6
+SUBLEVEL:=9
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://ep09.pld-linux.org/~mmazur/linux-libc-headers/
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.6.9.1.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.6.9.1
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.10")
+VERSION:=2
+PATCHLEVEL:=6
+SUBLEVEL:=10
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://ep09.pld-linux.org/~mmazur/linux-libc-headers/
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.6.10.0.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.6.10.0
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.11")
+VERSION:=2
+PATCHLEVEL:=6
+SUBLEVEL:=11
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://ep09.pld-linux.org/~mmazur/linux-libc-headers/
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.6.11.0.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.6.11.0
+endif
+
+ifeq ("$(DEFAULT_KERNEL_HEADERS)","2.6.12")
+VERSION:=2
+PATCHLEVEL:=6
+SUBLEVEL:=12
+LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+LINUX_HEADERS_SITE:=http://ep09.pld-linux.org/~mmazur/linux-libc-headers/
+LINUX_HEADERS_SOURCE:=linux-libc-headers-2.6.12.0.tar.bz2
+LINUX_HEADERS_CAT:=$(BZCAT)
+LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-2.6.12.0
+endif
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old.makefile b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old.makefile
new file mode 100644
index 0000000000..52fa68e6f3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers-old.makefile
@@ -0,0 +1,87 @@
+#############################################################
+#
+# Setup the kernel headers. I include a generic package of
+# kernel headers here, so you shouldn't need to include your
+# own. Be aware these kernel headers _will_ get blown away
+# by a 'make clean' so don't put anything sacred in here...
+#
+#############################################################
+
+# the old sanitized kernel-headers
+ifeq ($(LINUX_HEADERS_IS_KERNEL),n)
+
+$(LINUX_HEADERS_UNPACK_DIR)/.unpacked: $(DL_DIR)/$(LINUX_HEADERS_SOURCE)
+ @echo "Using old sanitized kernel-headers"
+ rm -rf $(LINUX_HEADERS_DIR)
+ $(LINUX_HEADERS_CAT) $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ifneq ($(LINUX_HEADERS_UNPACK_DIR),$(LINUX_HEADERS_DIR))
+ ln -fs $(LINUX_HEADERS_UNPACK_DIR) $(LINUX_HEADERS_DIR)
+endif
+ touch $(LINUX_HEADERS_UNPACK_DIR)/.unpacked
+
+$(LINUX_HEADERS_DIR)/.patched: $(LINUX_HEADERS_UNPACK_DIR)/.unpacked
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_DIR) toolchain/kernel-headers \
+ linux-libc-headers-$(LINUX_HEADERS_VERSION)\*.patch
+ifeq ($(strip $(ARCH)),nios2)
+ toolchain/patch-kernel.sh $(LINUX_HEADERS_DIR) toolchain/kernel-headers \
+ linux-libc-headers-$(LINUX_HEADERS_VERSION)-nios2nommu.patch.conditional
+endif
+ touch $(LINUX_HEADERS_DIR)/.patched
+
+$(LINUX_HEADERS_DIR)/.configured: $(LINUX_HEADERS_DIR)/.patched
+ rm -f $(LINUX_HEADERS_DIR)/include/asm
+ @if [ ! -f $(LINUX_HEADERS_DIR)/Makefile ] ; then \
+ /bin/echo -e "VERSION = $(VERSION)\nPATCHLEVEL = $(PATCHLEVEL)\n" > \
+ $(LINUX_HEADERS_DIR)/Makefile; \
+ /bin/echo -e "SUBLEVEL = $(SUBLEVEL)\nEXTRAVERSION =\n" >> \
+ $(LINUX_HEADERS_DIR)/Makefile; \
+ /bin/echo -e "KERNELRELEASE=\$$(VERSION).\$$(PATCHLEVEL).\$$(SUBLEVEL)\$$(EXTRAVERSION)" >> \
+ $(LINUX_HEADERS_DIR)/Makefile; \
+ fi
+ @if [ "$(ARCH)" = "powerpc" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-ppc$(NOMMU) asm;) \
+ elif [ "$(ARCH)" = "mips" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-mips$(NOMMU) asm;) \
+ elif [ "$(ARCH)" = "mipsel" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-mips$(NOMMU) asm;) \
+ elif [ "$(ARCH)" = "nios2" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-nios2nommu asm;) \
+ elif [ "$(ARCH)" = "arm" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-arm$(NOMMU) asm; \
+ cd asm; \
+ if [ ! -L proc ] ; then \
+ ln -fs proc-armv proc; \
+ ln -fs arch-ebsa285 arch; fi); \
+ elif [ "$(ARCH)" = "armeb" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-arm$(NOMMU) asm; \
+ cd asm; \
+ if [ ! -L proc ] ; then \
+ ln -fs proc-armv proc; \
+ ln -fs arch-ebsa285 arch; fi); \
+ elif [ "$(ARCH)" = "cris" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-cris asm;) \
+ elif [ "$(ARCH)" = "sh3" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-sh asm; \
+ cd asm; \
+ ln -s cpu-sh3 cpu) \
+ elif [ "$(ARCH)" = "sh3eb" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-sh asm; \
+ cd asm; \
+ ln -s cpu-sh3 cpu) \
+ elif [ "$(ARCH)" = "sh4" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-sh asm; \
+ cd asm; \
+ ln -s cpu-sh4 cpu) \
+ elif [ "$(ARCH)" = "sh4eb" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-sh asm; \
+ cd asm; \
+ ln -s cpu-sh4 cpu) \
+ elif [ "$(ARCH)" = "i386" -o "$(ARCH)" = "i486" -o "$(ARCH)" = "i586" -o "$(ARCH)" = "i686" ];then \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-i386$(NOMMU) asm;) \
+ else \
+ (cd $(LINUX_HEADERS_DIR)/include; ln -fs asm-$(ARCH)$(NOMMU) asm;) \
+ fi
+ touch $(LINUX_HEADERS_DIR)/include/linux/autoconf.h
+ touch $(LINUX_HEADERS_DIR)/.configured
+
+endif
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers.mk b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers.mk
new file mode 100644
index 0000000000..fc8acda051
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/kernel-headers.mk
@@ -0,0 +1,48 @@
+#############################################################
+#
+# Setup the kernel headers. I include a generic package of
+# kernel headers here, so you shouldn't need to include your
+# own. Be aware these kernel headers _will_ get blown away
+# by a 'make clean' so don't put anything sacred in here...
+#
+#############################################################
+
+DEFAULT_KERNEL_HEADERS:=$(strip $(subst ",, $(BR2_DEFAULT_KERNEL_HEADERS)))
+#"))
+
+LINUX_HEADERS_SITE:=127.0.0.1
+LINUX_HEADERS_SOURCE:=unspecified-kernel-headers
+LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-libc-headers-null
+
+KERNEL_ARCH:=$(shell $(SHELL) -c "echo \"$(ARCH)\" | sed -e \"s/-.*//\" \
+ -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/s390x/s390/ -e s/parisc64/parisc/ \
+ -e s/powerpc64/powerpc/ \
+ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+ -e s/sh2.*/sh/ -e s/sh3.*/sh/ -e s/sh4.*/sh/ \
+ -e s/nios2.*/nios2nommu/")
+
+# assume old manually sanitized kernel-headers
+LINUX_HEADERS_IS_KERNEL=n
+
+# this needs to be included before kernel-headers-new to set old-style mode
+include toolchain/kernel-headers/kernel-headers-old-versions.makefile
+include toolchain/kernel-headers/kernel-headers-new.makefile
+include toolchain/kernel-headers/kernel-headers-old.makefile
+
+$(DL_DIR)/$(LINUX_HEADERS_SOURCE):
+ $(WGET) -P $(DL_DIR) $(LINUX_HEADERS_SITE)/$(LINUX_HEADERS_SOURCE)
+
+kernel-headers: $(LINUX_HEADERS_DIR)/.configured
+
+kernel-headers-source: $(DL_DIR)/$(LINUX_HEADERS_SOURCE)
+
+kernel-headers-clean: clean
+ rm -rf $(LINUX_HEADERS_DIR)
+
+kernel-headers-dirclean:
+ rm -rf $(LINUX_HEADERS_DIR)
+ rm -rf $(LINUX_HEADERS_UNPACK_DIR)
+
+.PHONY: kernel-headers
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.20.4-dwmw2-combined.01.diff b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.20.4-dwmw2-combined.01.diff
new file mode 100644
index 0000000000..d07dd33d2b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.20.4-dwmw2-combined.01.diff
@@ -0,0 +1,460 @@
+\\\\ dwmw2's --combine -fwhole-program patch for the kernel
+\\ original of this incarnation was here:
+\\ http://david.woodhou.se/linux-combine-build.patch
+diff -rduNp linux-2.6.20.4.orig/drivers/md/md.c linux-2.6.20.4/drivers/md/md.c
+--- linux-2.6.20.4.orig/drivers/md/md.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/drivers/md/md.c 2007-03-24 20:14:10.000000000 +0100
+@@ -2944,6 +2944,7 @@ static struct kobj_type md_ktype = {
+ };
+
+ int mdp_major = 0;
++__internal_export(mdp_major);
+
+ static struct kobject *md_probe(dev_t dev, int *part, void *data)
+ {
+@@ -5602,7 +5603,7 @@ void md_autodetect_dev(dev_t dev)
+ if (dev_cnt >= 0 && dev_cnt < 127)
+ detected_devices[dev_cnt++] = dev;
+ }
+-
++__internal_export(md_autodetect_dev);
+
+ static void autostart_arrays(int part)
+ {
+diff -rduNp linux-2.6.20.4.orig/drivers/video/fbcvt.c linux-2.6.20.4/drivers/video/fbcvt.c
+--- linux-2.6.20.4.orig/drivers/video/fbcvt.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/drivers/video/fbcvt.c 2007-03-24 20:14:10.000000000 +0100
+@@ -376,3 +376,4 @@ int fb_find_mode_cvt(struct fb_videomode
+
+ return 0;
+ }
++__internal_export(fb_find_mode_cvt);
+diff -rduNp linux-2.6.20.4.orig/fs/debugfs/inode.c linux-2.6.20.4/fs/debugfs/inode.c
+--- linux-2.6.20.4.orig/fs/debugfs/inode.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/debugfs/inode.c 2007-03-24 20:14:10.000000000 +0100
+@@ -29,7 +29,7 @@
+ #define DEBUGFS_MAGIC 0x64626720
+
+ /* declared over in file.c */
+-extern struct file_operations debugfs_file_operations;
++extern const struct file_operations debugfs_file_operations;
+
+ static struct vfsmount *debugfs_mount;
+ static int debugfs_mount_count;
+diff -rduNp linux-2.6.20.4.orig/fs/devpts/inode.c linux-2.6.20.4/fs/devpts/inode.c
+--- linux-2.6.20.4.orig/fs/devpts/inode.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/devpts/inode.c 2007-03-24 20:14:10.000000000 +0100
+@@ -185,6 +185,7 @@ int devpts_pty_new(struct tty_struct *tt
+
+ return 0;
+ }
++__internal_export(devpts_pty_new);
+
+ struct tty_struct *devpts_get_tty(int number)
+ {
+@@ -202,6 +203,7 @@ struct tty_struct *devpts_get_tty(int nu
+
+ return tty;
+ }
++__internal_export(devpts_get_tty);
+
+ void devpts_pty_kill(int number)
+ {
+@@ -218,6 +220,7 @@ void devpts_pty_kill(int number)
+ }
+ mutex_unlock(&devpts_root->d_inode->i_mutex);
+ }
++__internal_export(devpts_pty_kill);
+
+ static int __init init_devpts_fs(void)
+ {
+diff -rduNp linux-2.6.20.4.orig/fs/hfsplus/inode.c linux-2.6.20.4/fs/hfsplus/inode.c
+--- linux-2.6.20.4.orig/fs/hfsplus/inode.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/hfsplus/inode.c 2007-03-24 20:14:10.000000000 +0100
+@@ -269,7 +269,7 @@ static int hfsplus_file_release(struct i
+ }
+
+ extern struct inode_operations hfsplus_dir_inode_operations;
+-extern struct file_operations hfsplus_dir_operations;
++extern const struct file_operations hfsplus_dir_operations;
+
+ static struct inode_operations hfsplus_file_inode_operations = {
+ .lookup = hfsplus_file_lookup,
+diff -rduNp linux-2.6.20.4.orig/fs/hugetlbfs/inode.c linux-2.6.20.4/fs/hugetlbfs/inode.c
+--- linux-2.6.20.4.orig/fs/hugetlbfs/inode.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/hugetlbfs/inode.c 2007-03-24 20:14:10.000000000 +0100
+@@ -45,6 +45,7 @@ static struct backing_dev_info hugetlbfs
+ };
+
+ int sysctl_hugetlb_shm_group;
++__internal_export(sysctl_hugetlb_shm_group);
+
+ static void huge_pagevec_release(struct pagevec *pvec)
+ {
+@@ -562,6 +563,7 @@ const struct file_operations hugetlbfs_f
+ .fsync = simple_sync_file,
+ .get_unmapped_area = hugetlb_get_unmapped_area,
+ };
++__internal_export(hugetlbfs_file_operations);
+
+ static struct inode_operations hugetlbfs_dir_inode_operations = {
+ .create = hugetlbfs_create,
+@@ -701,6 +703,7 @@ int hugetlb_get_quota(struct address_spa
+
+ return ret;
+ }
++__internal_export(hugetlb_get_quota);
+
+ void hugetlb_put_quota(struct address_space *mapping)
+ {
+@@ -712,6 +715,7 @@ void hugetlb_put_quota(struct address_sp
+ spin_unlock(&sbinfo->stat_lock);
+ }
+ }
++__internal_export(hugetlb_put_quota);
+
+ static int hugetlbfs_get_sb(struct file_system_type *fs_type,
+ int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+@@ -794,6 +798,7 @@ out_shm_unlock:
+ user_shm_unlock(size, current->user);
+ return ERR_PTR(error);
+ }
++__internal_export(hugetlb_zero_setup);
+
+ static int __init init_hugetlbfs_fs(void)
+ {
+diff -rduNp linux-2.6.20.4.orig/fs/proc/base.c linux-2.6.20.4/fs/proc/base.c
+--- linux-2.6.20.4.orig/fs/proc/base.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/proc/base.c 2007-03-24 20:18:09.000000000 +0100
+@@ -71,6 +71,7 @@
+ #include <linux/cpuset.h>
+ #include <linux/audit.h>
+ #include <linux/poll.h>
++#include <linux/module.h>
+ #include <linux/nsproxy.h>
+ #include <linux/oom.h>
+ #include "internal.h"
+@@ -2030,6 +2031,7 @@ struct dentry *proc_pid_lookup(struct in
+ out:
+ return result;
+ }
++__internal_export(proc_flush_task);
+
+ /*
+ * Find the first task with tgid >= tgid
+diff -rduNp linux-2.6.20.4.orig/fs/proc/generic.c linux-2.6.20.4/fs/proc/generic.c
+--- linux-2.6.20.4.orig/fs/proc/generic.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/proc/generic.c 2007-03-24 20:14:10.000000000 +0100
+@@ -20,8 +20,8 @@
+ #include <linux/namei.h>
+ #include <linux/bitops.h>
+ #include <linux/spinlock.h>
++#include <linux/module.h>
+ #include <asm/uaccess.h>
+-
+ #include "internal.h"
+
+ static ssize_t proc_file_read(struct file *file, char __user *buf,
+@@ -38,6 +38,7 @@ int proc_match(int len, const char *name
+ return 0;
+ return !memcmp(name, de->name, len);
+ }
++__internal_export(proc_match);
+
+ static struct file_operations proc_file_operations = {
+ .llseek = proc_file_lseek,
+diff -rduNp linux-2.6.20.4.orig/fs/proc/kcore.c linux-2.6.20.4/fs/proc/kcore.c
+--- linux-2.6.20.4.orig/fs/proc/kcore.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/proc/kcore.c 2007-03-24 20:14:10.000000000 +0100
+@@ -19,6 +19,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/highmem.h>
+ #include <linux/init.h>
++#include <linux/module.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+
+@@ -66,6 +67,7 @@ kclist_add(struct kcore_list *new, void
+ kclist = new;
+ write_unlock(&kclist_lock);
+ }
++__internal_export(kclist_add);
+
+ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
+ {
+diff -rduNp linux-2.6.20.4.orig/fs/proc/proc_tty.c linux-2.6.20.4/fs/proc/proc_tty.c
+--- linux-2.6.20.4.orig/fs/proc/proc_tty.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/proc/proc_tty.c 2007-03-24 20:14:10.000000000 +0100
+@@ -201,6 +201,7 @@ void proc_tty_register_driver(struct tty
+
+ driver->proc_entry = ent;
+ }
++__internal_export(proc_tty_register_driver);
+
+ /*
+ * This function is called by tty_unregister_driver()
+@@ -217,6 +218,7 @@ void proc_tty_unregister_driver(struct t
+
+ driver->proc_entry = NULL;
+ }
++__internal_export(proc_tty_unregister_driver);
+
+ /*
+ * Called by proc_root_init() to initialize the /proc/tty subtree
+diff -rduNp linux-2.6.20.4.orig/fs/proc/root.c linux-2.6.20.4/fs/proc/root.c
+--- linux-2.6.20.4.orig/fs/proc/root.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/proc/root.c 2007-03-24 20:14:10.000000000 +0100
+@@ -21,7 +21,9 @@
+
+ #include "internal.h"
+
+-struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
++struct proc_dir_entry *proc_net;
++
++struct proc_dir_entry *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
+
+ #ifdef CONFIG_SYSCTL
+ struct proc_dir_entry *proc_sys_root;
+@@ -91,6 +93,7 @@ void __init proc_root_init(void)
+ #endif
+ proc_bus = proc_mkdir("bus", NULL);
+ }
++__internal_export(proc_root_init);
+
+ static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
+ )
+@@ -163,6 +166,7 @@ struct proc_dir_entry proc_root = {
+ .parent = &proc_root,
+ };
+
++__internal_export(proc_sys_root);
+ EXPORT_SYMBOL(proc_symlink);
+ EXPORT_SYMBOL(proc_mkdir);
+ EXPORT_SYMBOL(create_proc_entry);
+diff -rduNp linux-2.6.20.4.orig/fs/ramfs/inode.c linux-2.6.20.4/fs/ramfs/inode.c
+--- linux-2.6.20.4.orig/fs/ramfs/inode.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/ramfs/inode.c 2007-03-24 20:14:10.000000000 +0100
+@@ -225,5 +225,6 @@ int __init init_rootfs(void)
+ {
+ return register_filesystem(&rootfs_fs_type);
+ }
++__internal_export(init_rootfs);
+
+ MODULE_LICENSE("GPL");
+diff -rduNp linux-2.6.20.4.orig/fs/reiserfs/dir.c linux-2.6.20.4/fs/reiserfs/dir.c
+--- linux-2.6.20.4.orig/fs/reiserfs/dir.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/fs/reiserfs/dir.c 2007-03-24 20:14:10.000000000 +0100
+@@ -11,7 +11,7 @@
+ #include <linux/buffer_head.h>
+ #include <asm/uaccess.h>
+
+-extern struct reiserfs_key MIN_KEY;
++extern const struct reiserfs_key MIN_KEY;
+
+ static int reiserfs_readdir(struct file *, void *, filldir_t);
+ static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
+diff -rduNp linux-2.6.20.4.orig/include/linux/module.h linux-2.6.20.4/include/linux/module.h
+--- linux-2.6.20.4.orig/include/linux/module.h 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/include/linux/module.h 2007-03-24 20:14:10.000000000 +0100
+@@ -20,6 +20,15 @@
+
+ #include <asm/module.h>
+
++
++#ifdef CONFIG_COMBINED_COMPILE
++#define __externally_visible__ __attribute__((externally_visible,used))
++#define __internal_export(sym) extern typeof(sym) sym __externally_visible__
++#else
++#define __externally_visible__
++#define __internal_export(sym)
++#endif
++
+ /* Not Yet Implemented */
+ #define MODULE_SUPPORTED_DEVICE(name)
+
+@@ -188,7 +197,7 @@ void *__symbol_get_gpl(const char *symbo
+
+ /* For every exported symbol, place a struct in the __ksymtab section */
+ #define __EXPORT_SYMBOL(sym, sec) \
+- extern typeof(sym) sym; \
++ extern typeof(sym) sym __externally_visible__; \
+ __CRC_SYMBOL(sym, sec) \
+ static const char __kstrtab_##sym[] \
+ __attribute__((section("__ksymtab_strings"))) \
+@@ -212,8 +221,8 @@ void *__symbol_get_gpl(const char *symbo
+ #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
+ #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
+ #else
+-#define EXPORT_UNUSED_SYMBOL(sym)
+-#define EXPORT_UNUSED_SYMBOL_GPL(sym)
++#define EXPORT_UNUSED_SYMBOL(sym) __internal_export(sym)
++#define EXPORT_UNUSED_SYMBOL_GPL(sym) __internal_export(sym)
+ #endif
+
+ #endif
+@@ -471,11 +480,12 @@ void module_add_driver(struct module *,
+ void module_remove_driver(struct device_driver *);
+
+ #else /* !CONFIG_MODULES... */
+-#define EXPORT_SYMBOL(sym)
+-#define EXPORT_SYMBOL_GPL(sym)
+-#define EXPORT_SYMBOL_GPL_FUTURE(sym)
+-#define EXPORT_UNUSED_SYMBOL(sym)
+-#define EXPORT_UNUSED_SYMBOL_GPL(sym)
++
++#define EXPORT_SYMBOL(sym) __internal_export(sym)
++#define EXPORT_SYMBOL_GPL(sym) __internal_export(sym)
++#define EXPORT_SYMBOL_GPL_FUTURE(sym) __internal_export(sym)
++#define EXPORT_UNUSED_SYMBOL(sym) __internal_export(sym)
++#define EXPORT_UNUSED_SYMBOL_GPL(sym) __internal_export(sym)
+
+ /* Given an address, look for it in the exception tables. */
+ static inline const struct exception_table_entry *
+diff -rduNp linux-2.6.20.4.orig/init/do_mounts.c linux-2.6.20.4/init/do_mounts.c
+--- linux-2.6.20.4.orig/init/do_mounts.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/init/do_mounts.c 2007-03-24 20:14:10.000000000 +0100
+@@ -26,6 +26,10 @@ static char __initdata saved_root_name[6
+
+ dev_t ROOT_DEV;
+
++__internal_export(root_mountflags);
++__internal_export(rd_doload);
++__internal_export(ROOT_DEV);
++
+ static int __init load_ramdisk(char *str)
+ {
+ rd_doload = simple_strtol(str,NULL,0) & 3;
+@@ -205,6 +209,7 @@ fail:
+ res = 0;
+ goto done;
+ }
++__internal_export(name_to_dev_t);
+
+ static int __init root_dev_setup(char *line)
+ {
+@@ -446,4 +451,4 @@ out:
+ sys_chroot(".");
+ security_sb_post_mountroot();
+ }
+-
++__internal_export(prepare_namespace);
+diff -rduNp linux-2.6.20.4.orig/init/do_mounts_initrd.c linux-2.6.20.4/init/do_mounts_initrd.c
+--- linux-2.6.20.4.orig/init/do_mounts_initrd.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/init/do_mounts_initrd.c 2007-03-24 20:18:32.000000000 +0100
+@@ -6,6 +6,7 @@
+ #include <linux/romfs_fs.h>
+ #include <linux/initrd.h>
+ #include <linux/sched.h>
++#include <linux/module.h>
+ #include <linux/freezer.h>
+
+ #include "do_mounts.h"
+@@ -16,6 +17,11 @@ unsigned int real_root_dev; /* do_proc_d
+ static int __initdata old_fd, root_fd;
+ static int __initdata mount_initrd = 1;
+
++__internal_export(initrd_start);
++__internal_export(initrd_end);
++__internal_export(initrd_below_start_ok);
++__internal_export(real_root_dev);
++
+ static int __init no_initrd(char *str)
+ {
+ mount_initrd = 0;
+diff -rduNp linux-2.6.20.4.orig/init/do_mounts_rd.c linux-2.6.20.4/init/do_mounts_rd.c
+--- linux-2.6.20.4.orig/init/do_mounts_rd.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/init/do_mounts_rd.c 2007-03-24 20:14:10.000000000 +0100
+@@ -7,12 +7,14 @@
+ #include <linux/cramfs_fs.h>
+ #include <linux/initrd.h>
+ #include <linux/string.h>
++#include <linux/module.h>
+
+ #include "do_mounts.h"
+
+ #define BUILD_CRAMDISK
+
+ int __initdata rd_prompt = 1;/* 1 = prompt for RAM disk, 0 = don't prompt */
++__internal_export(rd_prompt);
+
+ static int __init prompt_ramdisk(char *str)
+ {
+@@ -22,6 +24,7 @@ static int __init prompt_ramdisk(char *s
+ __setup("prompt_ramdisk=", prompt_ramdisk);
+
+ int __initdata rd_image_start; /* starting block # of image */
++__internal_export(rd_image_start);
+
+ static int __init ramdisk_start_setup(char *str)
+ {
+diff -rduNp linux-2.6.20.4.orig/init/Kconfig linux-2.6.20.4/init/Kconfig
+--- linux-2.6.20.4.orig/init/Kconfig 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/init/Kconfig 2007-03-24 20:14:10.000000000 +0100
+@@ -526,6 +526,11 @@ config MODULE_FORCE_UNLOAD
+ rmmod). This is mainly for kernel developers and desperate users.
+ If unsure, say N.
+
++config COMBINED_COMPILE
++ bool "Use combined compilation (gcc --combine)"
++ help
++ fish
++
+ config MODVERSIONS
+ bool "Module versioning support"
+ depends on MODULES
+diff -rduNp linux-2.6.20.4.orig/net/netfilter/core.c linux-2.6.20.4/net/netfilter/core.c
+--- linux-2.6.20.4.orig/net/netfilter/core.c 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/net/netfilter/core.c 2007-03-24 20:14:10.000000000 +0100
+@@ -279,3 +279,5 @@ void __init netfilter_init(void)
+ if (netfilter_log_init() < 0)
+ panic("cannot initialize nf_log");
+ }
++__internal_export(netfilter_init);
++
+diff -rduNp linux-2.6.20.4.orig/scripts/Makefile.build linux-2.6.20.4/scripts/Makefile.build
+--- linux-2.6.20.4.orig/scripts/Makefile.build 2007-03-13 19:27:08.000000000 +0100
++++ linux-2.6.20.4/scripts/Makefile.build 2007-03-24 20:14:10.000000000 +0100
+@@ -128,6 +128,11 @@ $(multi-objs-y:.o=.i) : modname = $(mo
+ $(multi-objs-y:.o=.s) : modname = $(modname-multi)
+ $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
+
++ifdef CONFIG_COMBINED_COMPILE
++$(multi-used-m) : CFLAGS += -fwhole-program --combine $(sort $(addprefix $(srctree)/$(obj)/,$($(subst $(obj)/,,$(@:.o=-y)):.o=.c) $($(subst $(obj)/,,$(@:.o=-objs)):.o=.c)))
++$(multi-used-y) : CFLAGS += -fwhole-program --combine $(sort $(addprefix $(srctree)/$(obj)/,$($(subst $(obj)/,,$(@:.o=-y)):.o=.c) $($(subst $(obj)/,,$(@:.o=-objs)):.o=.c)))
++endif
++
+ quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
+ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
+
+@@ -284,6 +289,22 @@ $(lib-target): $(lib-y) FORCE
+ targets += $(lib-target)
+ endif
+
++ifdef CONFIG_COMBINED_COMPILE
++# We would rather have a list of rules like
++# foo.o: $(foo-objs)
++# but that's not so easy, so we rather make all composite objects depend
++# on the set of all their parts
++
++$(multi-used-y) : %.o: $(srctree)/dummy.c $(multi-objs-y:.o=.c) FORCE
++ $(call cmd,force_checksrc)
++ $(call if_changed_rule,cc_o_c)
++
++$(multi-used-m) : %.o: $(srctree)/dummy.c $(multi-objs-m:.o=.c) FORCE
++ $(call cmd,force_checksrc)
++ $(call if_changed_rule,cc_o_c)
++
++targets += $(multi-used-y) $(multi-used-m)
++else
+ #
+ # Rule to link composite objects
+ #
+@@ -314,7 +335,7 @@ $(multi-used-m) : %.o: $(multi-objs-m) F
+ @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
+
+ targets += $(multi-used-y) $(multi-used-m)
+-
++endif
+
+ # Descending
+ # ---------------------------------------------------------------------------
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-001-add-linkage-header.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-001-add-linkage-header.patch
new file mode 100644
index 0000000000..dd89d4a893
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-001-add-linkage-header.patch
@@ -0,0 +1,18 @@
+diff -ur linux-2.6.21.5/include/asm-arm/Kbuild linux-2.6.21.5-patched/include/asm-arm/Kbuild
+--- linux-2.6.21.5/include/asm-arm/Kbuild 2007-06-11 13:37:06.000000000 -0500
++++ linux-2.6.21.5-patched/include/asm-arm/Kbuild 2008-02-27 18:17:46.999128276 -0600
+@@ -1 +1,3 @@
+ include include/asm-generic/Kbuild.asm
++
++header-y += linkage.h
+diff -ur linux-2.6.21.5/include/linux/Kbuild linux-2.6.21.5-patched/include/linux/Kbuild
+--- linux-2.6.21.5/include/linux/Kbuild 2007-06-11 13:37:06.000000000 -0500
++++ linux-2.6.21.5-patched/include/linux/Kbuild 2008-02-27 18:15:05.921149678 -0600
+@@ -100,6 +100,7 @@
+ header-y += jffs2.h
+ header-y += keyctl.h
+ header-y += limits.h
++header-y += linkage.h
+ header-y += lock_dlm_plock.h
+ header-y += magic.h
+ header-y += major.h
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-006-wait-for-async-scanned-block-devices.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-006-wait-for-async-scanned-block-devices.patch
new file mode 100644
index 0000000000..910b43ad9b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.21.5-006-wait-for-async-scanned-block-devices.patch
@@ -0,0 +1,55 @@
+diff --git a/init/do_mounts.c b/init/do_mounts.c
+index 46fe407..efc134c 100644
+--- a/init/do_mounts.c
++++ b/init/do_mounts.c
+@@ -25,6 +25,7 @@ int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */
+ int root_mountflags = MS_RDONLY | MS_SILENT;
+ char * __initdata root_device_name;
+ static char __initdata saved_root_name[64];
++int __initdata root_wait;
+
+ dev_t ROOT_DEV;
+
+@@ -216,6 +217,14 @@ static int __init root_dev_setup(char *line)
+
+ __setup("root=", root_dev_setup);
+
++static int __init rootwait_setup(char *line)
++{
++ root_wait = simple_strtol(line,NULL,0);
++ return 1;
++}
++
++__setup("rootwait=", rootwait_setup);
++
+ static char * __initdata root_mount_data;
+ static int __init root_data_setup(char *str)
+ {
+@@ -438,11 +447,24 @@ void __init prepare_namespace(void)
+ root_device_name += 5;
+ }
+
+- is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+-
+ if (initrd_load())
+ goto out;
+
++ /* wait for any asynchronous scanning to complete */
++ if ((ROOT_DEV == 0) && root_wait) {
++ printk(KERN_INFO "Waiting for root device %s...\n",
++ saved_root_name);
++ do {
++ while (driver_probe_done() != 0)
++ msleep(100);
++ ROOT_DEV = name_to_dev_t(saved_root_name);
++ if (ROOT_DEV == 0)
++ msleep(100);
++ } while (ROOT_DEV == 0);
++ }
++
++ is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
++
+ if (is_floppy && rd_doload && rd_load_disk(0))
+ ROOT_DEV = Root_RAM0;
+
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.23-nios2nommu.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.23-nios2nommu.patch
new file mode 100644
index 0000000000..6e558fd66c
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.23-nios2nommu.patch
@@ -0,0 +1,26567 @@
+diff --git a/arch/nios2nommu/ChangeLog b/arch/nios2nommu/ChangeLog
+new file mode 100644
+index 0000000..039c010
+--- /dev/null
++++ b/arch/nios2nommu/ChangeLog
+@@ -0,0 +1,4 @@
++2004-06-15 Ken Hill <khill@microtronix.com>
++
++ * Kconfig: Add Microtronix uKit support.
++
+diff --git a/arch/nios2nommu/Kconfig b/arch/nios2nommu/Kconfig
+new file mode 100644
+index 0000000..525c77b
+--- /dev/null
++++ b/arch/nios2nommu/Kconfig
+@@ -0,0 +1,403 @@
++#
++# For a description of the syntax of this configuration file,
++# see the Configure script.
++#
++mainmenu 'uClinux/Nios2 (w/o MMU) Kernel Configuration'
++
++config MMU
++ bool
++ default n
++
++config FPU
++ bool
++ default n
++
++config ZONE_DMA
++ bool
++ default y
++
++config UID16
++ bool
++ default y
++
++config RWSEM_GENERIC_SPINLOCK
++ bool
++ default y
++
++config RWSEM_XCHGADD_ALGORITHM
++ bool
++ default n
++
++config GENERIC_FIND_NEXT_BIT
++ bool
++ default y
++
++config GENERIC_HWEIGHT
++ bool
++ default y
++
++config GENERIC_CALIBRATE_DELAY
++ bool
++ default y
++
++source "init/Kconfig"
++
++menu "Processor type and features"
++
++comment 'Platform dependant setup'
++
++choice
++ prompt "CPU"
++ default NIOS2
++
++config NIOS2
++ bool "NIOS2"
++ help
++ Altera Nios2 softcore processor.
++
++endchoice
++
++choice
++ prompt "Platform"
++ default ALTERA_STRATIX
++
++config MICROTRONIX_UKIT
++ bool "Microtronix uKit board support"
++ depends on NIOS2
++ help
++ Support for the Microtronix uKit development board. Includes support
++ for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY.
++
++config MICROTRONIX_STRATIX
++ bool "Microtronix Stratix board support"
++ depends on NIOS2
++ help
++ Support for the Microtronix Stratix board. Includes support
++ for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY, USB, LVDS
++ & analog/digital converters.
++
++config MICROTRONIX_CYCLONE
++ bool "Microtronix Cyclone board support"
++ depends on NIOS2
++ help
++ Support for the Microtronix Cyclone board. Includes support
++ for SDRAM, FLASH, soft ethernet MAC & PHY, USB,
++ & analog/digital converters.
++
++config MICROTRONIX_PSK
++ bool "Microtronix PSK (Product Starter Kit) support"
++ depends on NIOS2
++ help
++ Support for the Microtronix PSK (Product Starter Kit), which
++ features firefly module (EP1C4 or EP1C12). Includes support
++ for SDRAM, FLASH, and a variety of product expansion kits such
++ as USB, Ethernet etc.
++
++config ALTERA_STRATIX
++ bool "Altera Stratix Development board support"
++ depends on NIOS2
++ help
++ Support for the Altera Stratix Development board. Includes
++ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
++
++config ALTERA_STRATIX_PRO
++ bool "Altera Stratix Pro Development board support"
++ depends on NIOS2
++ help
++ Support for the Altera Stratix 1s40 Development board. Includes
++ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
++
++config ALTERA_STRATIX_II
++ bool "Altera Stratix II Development board support"
++ depends on NIOS2
++ help
++ Support for the Altera Stratix II Development board. Includes
++ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
++
++config ALTERA_CYCLONE
++ bool "Altera Cyclone Development board support"
++ depends on NIOS2
++ help
++ Support for the Altera Cyclone Development board. Includes
++ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
++
++config ALTERA_CYCLONE_1C12_EVAL
++ bool "Altera Cyclone 1C12 Evaluation board support"
++ depends on NIOS2
++ help
++ Support for the Altera Cyclone 1C12 Evaluation board (with the
++ embedded processor module).
++
++config ALTERA_DE2
++ bool "Altera DE2 Development board support"
++ depends on NIOS2
++ help
++ Support for the Altera Cyclone Development board. Includes
++ support for 10/100 ethernet, FLASH, SDRAM, VGA, I2C.
++
++endchoice
++
++choice
++ prompt "Nios II Hardware Multiply Support"
++ default NIOS2_HW_MULX
++ help
++ This option enables various assembler instructions based on your
++ selection. The choice depends on what target hardware you'll be
++ running your applications on. The default is
++ "Enable mulx instruction".
++
++ Here is an explanation of each option:
++ None = -mno-hw-mul -mno-hw-mulx
++ (no mul or mulx instructions used)
++ Enable mul instruction = -mhw-mul -mno-hw-mulx
++ (use mul instructions)
++ Enable mul and mulx instructions = -mhw-mul -mhw-mulx
++ (use mul and mulx instructions)
++
++ If you don't know what to choose, select "Enable mulx instruction".
++
++config NIOS2_HW_MUL_OFF
++ bool "None"
++
++config NIOS2_HW_MUL
++ bool "Enable mul instruction"
++
++config NIOS2_HW_MULX
++ bool "Enable mul and mulx instructions"
++
++endchoice
++
++comment 'Platform drivers Options'
++
++config AVALON_DMA
++ bool "Support of DMA controller with Avalon interface"
++ default y
++ help
++ This enables support of Altera's DMA controller with Avalon
++ interface, so that drivers of DMA-able device can use this
++ interface.
++
++config PIO_DEVICES
++ bool "Enable leds, seven segment display"
++ default y
++ depends on (ALTERA_STRATIX || ALTERA_STRATIX_PRO || ALTERA_CYCLONE)
++ help
++ This enables example code to support leds, and seven segment
++ display as PIO devices. Once enabled, the kernel will show a
++ counter (increas once a second) on these devices.
++
++source "arch/nios2nommu/drivers/Kconfig"
++
++comment 'Miscellaneous Options'
++
++config EXCALIBUR
++ bool
++ default y
++ depends on (NIOS2)
++
++config BREAK_ON_START
++ bool "Include breakpoint trap on kernel startup"
++ help
++ Configures the kernel to trap to the GDB client on startup
++ before the kernel starts initialization. This allows you to
++ debug the kernel startup.
++
++config LARGE_ALLOCS
++ bool "Allow allocating large blocks (> 1MB) of memory"
++ help
++ Allow the slab memory allocator to keep chains for very large
++ memory sizes - upto 32MB. You may need this if your system has
++ a lot of RAM, and you need to able to allocate very large
++ contiguous chunks. If unsure, say N.
++
++choice
++ prompt "Kernel executes from"
++ ---help---
++ Choose the memory type that the kernel will be running in.
++
++config RAMKERNEL
++ bool "RAM"
++ help
++ The kernel will be resident in RAM when running.
++
++#config ROMKERNEL
++# bool "ROM"
++# help
++# The kernel will be resident in FLASH/ROM when running.
++
++#config HIMEMKERNEL
++# bool "HIMEM"
++# help
++# The kernel will be resident in high memory when running.
++
++endchoice
++
++config PREEMPT
++ bool "Preemptible Kernel"
++ help
++ This option reduces the latency of the kernel when reacting to
++ real-time or interactive events by allowing a low priority process to
++ be preempted even if it is in kernel mode executing a system call.
++ This allows applications to run more reliably even when the system is
++ under load.
++
++ Say Y here if you are building a kernel for a desktop, embedded
++ or real-time system. Say N if you are unsure.
++
++config PREEMPT_TIMES
++ bool "Collect preemption latency times"
++ depends on PREEMPT
++ help
++ Allow collection for preemption latency times.
++
++config CMDLINE
++ string "Default kernel command string"
++ default "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
++ help
++ On some architectures, there is currently no way
++ for the boot loader to pass arguments to the kernel. For these
++ architectures, you should supply some command-line options at build
++ time by entering them here. As a minimum, you should specify the
++ memory size and the root device (e.g., mem=64M root=/dev/nfs).
++
++config PASS_CMDLINE
++ bool "Passed kernel command line from u-boot"
++ default n
++ help
++ Use bootargs env variable from u-boot for kernel command line.
++ will override "Default kernel command string".
++ Say N if you are unsure.
++
++source "mm/Kconfig"
++
++config BOOT_LINK_OFFSET
++ hex "Link address offset for booting"
++ default "0x00800000"
++ help
++ This option allows you to set the link address offset of the zImage.
++ This can be useful if you are on a board which has a small amount of
++ memory.
++
++endmenu
++
++menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
++
++config PCI
++ bool "PCI support"
++ help
++ Support for PCI bus.
++
++source "drivers/pci/Kconfig"
++
++config HOTPLUG
++ bool "Support for hot-pluggable device"
++ ---help---
++ Say Y here if you want to plug devices into your computer while
++ the system is running, and be able to use them quickly. In many
++ cases, the devices can likewise be unplugged at any time too.
++
++ One well known example of this is PCMCIA- or PC-cards, credit-card
++ size devices such as network cards, modems or hard drives which are
++ plugged into slots found on all modern laptop computers. Another
++ example, used on modern desktops as well as laptops, is USB.
++
++ Enable HOTPLUG and KMOD, and build a modular kernel. Get agent
++ software (at <http://linux-hotplug.sourceforge.net/>) and install it.
++ Then your kernel will automatically call out to a user mode "policy
++ agent" (/sbin/hotplug) to load modules and set up software needed
++ to use devices as you hotplug them.
++
++source "drivers/pcmcia/Kconfig"
++
++source "drivers/pci/hotplug/Kconfig"
++
++endmenu
++
++menu "Executable file formats"
++
++config KCORE_AOUT
++ bool
++ default y
++
++config KCORE_ELF
++ bool
++ default y
++
++source "fs/Kconfig.binfmt"
++
++endmenu
++
++menu "Power management options"
++
++config PM
++ bool "Power Management support"
++ help
++ Support processor power management modes
++
++endmenu
++
++
++source "net/Kconfig"
++
++source "drivers/Kconfig"
++
++source "fs/Kconfig"
++
++source "arch/nios2nommu/Kconfig.debug"
++
++menu "Kernel hacking"
++
++config FULLDEBUG
++ bool "Full Symbolic/Source Debugging support"
++ help
++ Enable debuging symbols on kernel build.
++
++config FRAME_POINTER
++ bool "Compile the kernel with frame pointers"
++ help
++ If you say Y here the resulting kernel image will be slightly larger
++ and slower, but it will give very useful debugging information.
++ If you don't debug the kernel, you can say N, but we may not be able
++ to solve problems without frame pointers.
++
++config MAGIC_SYSRQ
++ bool "Magic SysRq key"
++ help
++ Enables console device to interpret special characters as
++ commands to dump state information.
++
++config HIGHPROFILE
++ bool "Use fast second timer for profiling"
++ depends on COLDFIRE
++ help
++ Use a fast secondary clock to produce profiling information.
++
++config NO_KERNEL_MSG
++ bool "Suppress Kernel BUG Messages"
++ help
++ Do not output any debug BUG messages within the kernel.
++
++config LOG_BUF_SHIFT
++ int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
++ range 12 21
++ default 17 if ARCH_S390
++ default 16 if X86_NUMAQ || IA64
++ default 15 if SMP
++ default 14
++ help
++ Select kernel log buffer size as a power of 2.
++ Defaults and Examples:
++ 17 => 128 KB for S/390
++ 16 => 64 KB for x86 NUMAQ or IA-64
++ 15 => 32 KB for SMP
++ 14 => 16 KB for uniprocessor
++ 13 => 8 KB
++ 12 => 4 KB
++
++endmenu
++
++source "security/Kconfig"
++
++source "crypto/Kconfig"
++
++source "lib/Kconfig"
+diff --git a/arch/nios2nommu/Kconfig.debug b/arch/nios2nommu/Kconfig.debug
+new file mode 100644
+index 0000000..b188c4a
+--- /dev/null
++++ b/arch/nios2nommu/Kconfig.debug
+@@ -0,0 +1,35 @@
++menu "Kernel hacking"
++
++source "lib/Kconfig.debug"
++
++config FULLDEBUG
++ bool "Full Symbolic/Source Debugging support"
++ help
++ Enable debuging symbols on kernel build.
++
++config FRAME_POINTER
++ bool "Compile the kernel with frame pointers"
++ help
++ If you say Y here the resulting kernel image will be slightly larger
++ and slower, but it will give very useful debugging information.
++ If you don't debug the kernel, you can say N, but we may not be able
++ to solve problems without frame pointers.
++
++config MAGIC_SYSRQ
++ bool "Magic SysRq key"
++ help
++ Enables console device to interpret special characters as
++ commands to dump state information.
++
++config HIGHPROFILE
++ bool "Use fast second timer for profiling"
++ depends on COLDFIRE
++ help
++ Use a fast secondary clock to produce profiling information.
++
++config NO_KERNEL_MSG
++ bool "Suppress Kernel BUG Messages"
++ help
++ Do not output any debug BUG messages within the kernel.
++
++endmenu
+diff --git a/arch/nios2nommu/Makefile b/arch/nios2nommu/Makefile
+new file mode 100644
+index 0000000..ca139b6
+--- /dev/null
++++ b/arch/nios2nommu/Makefile
+@@ -0,0 +1,181 @@
++# arch/niosnommu/Makefile
++#
++# Makefile for the architecture dependent flags and dependencies on the
++# nios.
++#
++# Copyright (C) 2001 Vic Phillips (vic@microtronix.com)
++#
++# based on sparcnommu/Makefile:
++#
++# Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
++#
++KERNELLOAD = ${shell echo `grep "nasys_program_mem " include/asm/nios.h | sed 's/^.*\*)//' | sed 's/)//'`}
++
++HARDWARE_MK = arch/$(ARCH)/hardware.mk
++
++platform-$(CONFIG_NIOS) := NIOS2
++PLATFORM := $(platform-y)
++
++board-$(CONFIG_ALTERA_STRATIX) := altera_stratix
++board-$(CONFIG_ALTERA_STRATIX_PRO) := altera_stratix_pro
++board-$(CONFIG_ALTERA_STRATIX_II) := altera_stratix_ii
++board-$(CONFIG_ALTERA_CYCLONE) := altera_cyclone
++board-$(CONFIG_ALTERA_CYCLONE_1C12_EVAL) := altera_cyclone_1c12_eval
++board-$(CONFIG_MICROTRONIX_STRATIX) := microtronix_stratix
++board-$(CONFIG_MICROTRONIX_CYCLONE) := microtronix_cyclone
++board-$(CONFIG_MICROTRONIX_UKIT) := microtronix_ukit
++board-$(CONFIG_MICROTRONIX_PSK) := microtronix_psk
++BOARD := $(board-y)
++
++model-$(CONFIG_RAMKERNEL) := ram
++model-$(CONFIG_ROMKERNEL) := rom
++model-$(CONFIG_HIMEMKERNEL) := himem
++MODEL := $(model-y)
++
++export PLATFORM BOARD MODEL
++
++CFLAGS += -DNO_MM -pipe -D__linux__ -D__ELF__
++#CFLAGS += -DNO_MM -save-temps -D__linux__ -D__ELF__
++
++# Uncomment this if you are doing gdb source level
++# debugging of the kernel to get the proper debugging information.
++#
++#CFLAGS += -DDEBUG
++
++# Turn on/off various hardware multiply options
++cpu-cflags-$(CONFIG_NIOS2_HW_MUL_OFF) += -mno-hw-mul -mno-hw-mulx
++cpu-cflags-$(CONFIG_NIOS2_HW_MUL) += -mhw-mul -mno-hw-mulx
++cpu-cflags-$(CONFIG_NIOS2_HW_MULX) += -mhw-mul -mhw-mulx
++CFLAGS += $(cpu-cflags-y)
++
++# mulx flags currently cause older version of nios2-elf-gcc to fail
++# The following line ensures that all mulx flags are removed before
++# it is passed to the compiler.
++mulx_help_text:= $(shell $(CC) --target-help | grep mulx)
++ifeq "$(mulx_help_text)" ""
++CFLAGS := $(filter-out -mhw-mulx -mno-hw-mulx, $(CFLAGS))
++endif
++
++# Temporary workaround for nios2-elf-gcc bug
++# First noticed in v3.4.1 (Altera Nios II 1.1 b131)
++# To be removed at a later date when bug is resolved.
++CFLAGS += -fno-optimize-sibling-calls
++
++# This undefines the "__init" type used in defining initialization
++# procedures. When defined, the procedures are put into an 'init' data
++# section that GDB doesn't recognize as source.
++#
++CFLAGS += -DNO_TEXT_SECTIONS
++CFLAGS += -fno-builtin
++CFLAGS += -O2 -g -G 0
++CFLAGS += -DUTS_SYSNAME=\"uClinux\"
++
++CFLAGS_GCC_INC := $(shell $(CC) -print-file-name=include)
++CFLAGS += -I$(CFLAGS_GCC_INC)
++
++AFLAGS += -DNO_MM -g
++#AFLAGS += -DNO_MM -g -save-temps
++
++# vic - add this to get name of nios gcc library
++LIBGCC_CFLAGS = $(if $(CONFIG_NIOS2_HW_MUL_OFF),-mno-hw-mul)
++LIBGCC := `$(CC) --print-libgcc-file-name $(LIBGCC_CFLAGS)`
++
++# add this to avoid multiple '_stack' and '_vecbase' definition errors
++#
++ifdef niosgnu
++# Include the path to the lib directory where the ldscripts are found to fix
++# a problem with the cygwin/bash environment.
++
++#cygwhack: kenw - this following section could be a possible problem
++# due to the O= option on the command line.
++LDSCRIPTS:=$(shell nios2-elf-gcc -print-file-name=ldscripts)
++LDFLAGS += -mnios2elf -L $(LDSCRIPTS)/..
++else
++LDFLAGS += -mnios2elf
++LDLIBS := -L `$(CC) -print-file-name=m32` -l gcc
++endif
++
++head-y := arch/nios2nommu/kernel/head.o arch/nios2nommu/kernel/init_task.o
++
++CLEAN_FILES := include/asm-$(ARCH)/asm-offsets.h \
++ $(HARDWARE_MK) \
++ arch/$(ARCH)/kernel/asm-offsets.s \
++ linux.srec \
++ linux.flash \
++ linux.bin \
++ linux.bin.srec
++
++core-y += arch/nios2nommu/kernel/ \
++ arch/nios2nommu/mm/ \
++ arch/nios2nommu/drivers/
++
++libs-y += arch/nios2nommu/lib/
++
++libs-y += $(LIBGCC)
++####;dgt2;tmp;
++
++# force user to configure hardware before building kernel
++
++pardoned_targets = clean mrproper sgmldocs psdocs pdfdocs \
++ htmldocs mandocs headers_install
++
++-include $(HARDWARE_MK)
++build_targets = $(filter-out $(pardoned_targets), $(MAKECMDGOALS))
++ifneq '$(strip $(build_targets))' ''
++ ifndef SYSPTF
++ ifneq '$(firstword $(MAKECMDGOALS))' 'hwselect'
++ $(error Run "make hwselect SYSPTF=<system.ptf>" first)
++ endif
++ endif
++endif
++
++quiet_cmd_gen_mk = ' RUNNING $@'
++define cmd_gen_mk
++ mkdir -p $(dir $(objtree)/$(HARDWARE_MK)); \
++ perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
++ $(srctree)/arch/$(ARCH)/scripts/hwselect.pl $(SYSPTF) \
++ $(objtree)/$(HARDWARE_MK)
++endef
++
++.PHONY: hwselect
++hwselect:
++ @echo $($(quiet)cmd_gen_mk);
++ @$(cmd_gen_mk)
++
++prepare: include/nios2_system.h
++
++archclean:
++ $(call descend arch/$(ARCH)/boot, subdirclean)
++
++define filechk_nios2_system.h
++ # call perl script that will build nios2_system.h file
++ perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
++ $(TOPDIR)/arch/$(ARCH)/scripts/gen_nios2_system.h.pl $(CPU) $(EXEMEM) $(UPLMEM)
++endef
++
++include/nios2_system.h: $(SYSPTF) FORCE
++ $(call filechk,nios2_system.h)
++
++quiet_cmd_touch = ' TOUCH $@'
++ cmd_touch = touch $(TOPDIR)/$@
++
++arch/$(ARCH)/kernel/vmlinux.lds.S: FORCE
++ @echo $($(quiet)cmd_touch);
++ @$(cmd_touch)
++
++linuxsrec: linux
++ $(OBJCOPY) -O srec $(LINUX) linux.srec
++
++boot := arch/nios2nommu/boot
++
++zImage: vmlinux
++ $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
++
++compressed: zImage
++
++CLEAN_FILES += include/nios2_system.h
++
++archmrproper:
++
++archdep:
++
+diff --git a/arch/nios2nommu/boot/Makefile b/arch/nios2nommu/boot/Makefile
+new file mode 100644
+index 0000000..fd25b72
+--- /dev/null
++++ b/arch/nios2nommu/boot/Makefile
+@@ -0,0 +1,17 @@
++#
++# arch/nios2nommu/boot/Makefile
++#
++# This file is subject to the terms and conditions of the GNU General Public
++# License. See the file "COPYING" in the main directory of this archive
++# for more details.
++
++targets := zImage
++subdir- := compressed
++
++$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
++ $(call if_changed,objcopy)
++ @echo 'Kernel: $@ is ready'
++
++$(obj)/compressed/vmlinux: FORCE
++ $(Q)$(MAKE) $(build)=$(obj)/compressed $@
++
+diff --git a/arch/nios2nommu/boot/compressed/Makefile b/arch/nios2nommu/boot/compressed/Makefile
+new file mode 100644
+index 0000000..2002471
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/Makefile
+@@ -0,0 +1,36 @@
++#
++# linux/arch/sh/boot/compressed/Makefile
++#
++# create a compressed vmlinux image from the original vmlinux
++#
++
++targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o \
++ piggy.o vmlinux.lds
++EXTRA_AFLAGS :=
++
++OBJECTS = $(obj)/head.o $(obj)/misc.o
++
++#
++# IMAGE_OFFSET is the load offset of the compression loader
++#
++#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x2000])
++#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x00400000])
++
++LDFLAGS_vmlinux := -T
++
++$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
++ $(call if_changed,ld)
++ @:
++
++$(obj)/vmlinux.bin: vmlinux FORCE
++ $(call if_changed,objcopy)
++
++$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
++ $(call if_changed,gzip)
++
++LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T
++
++OBJCOPYFLAGS += -O binary
++
++$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
++ $(call if_changed,ld)
+diff --git a/arch/nios2nommu/boot/compressed/head.S b/arch/nios2nommu/boot/compressed/head.S
+new file mode 100644
+index 0000000..accadd0
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/head.S
+@@ -0,0 +1,100 @@
++/*
++ * linux/arch/nios2nommu/boot/compressed/head.S
++ *
++ */
++
++ .text
++ .set noat
++#include <asm/asm-offsets.h>
++#include <asm/asm-macros.h>
++
++ /*
++ * This code can be loaded anywhere, as long as output will not
++ * overlap it.
++ *
++ */
++
++ .global _start
++_start:
++ // disable interrupt
++ wrctl status, r0
++ // flush the instruction cache
++ movia r1,NIOS2_ICACHE_SIZE
++ movi r2,NIOS2_ICACHE_LINE_SIZE
++text_init:
++ initi r1
++ sub r1, r1, r2
++ bgt r1, zero, text_init
++ // then flush the pipeline
++ flushp
++ // flush the data cache
++ movia r1,NIOS2_DCACHE_SIZE
++ movi r2,NIOS2_DCACHE_LINE_SIZE
++data_init:
++ initd (r1)
++ sub r1, r1, r2
++ bgt r1, zero, data_init
++ //------------------------------------------------------
++ // Zero out the .bss segment (uninitialized common data)
++ //
++ movia r2,__bss_start // presume nothing is between
++ movia r1,_end // the .bss and _end.
++1:
++ stb r0,0(r2)
++ addi r2,r2,1
++ bne r1,r2,1b
++ // set up the stack pointer, some where higher than _end. The stack space must be greater than 32K for decompress.
++ movia sp, 0x10000
++ add sp,sp,r1
++ // save args passed from u-boot
++ addi sp,sp,-16
++ stw r4,0(sp)
++ stw r5,4(sp)
++ stw r6,8(sp)
++ stw r7,12(sp)
++/*
++ * decompress the kernel
++ */
++ call decompress_kernel
++
++flush_cache:
++ // flush all cache after loading
++ // flush the data cache
++ movia r1,NIOS2_DCACHE_SIZE
++ movi r2,NIOS2_DCACHE_LINE_SIZE
++data_flush:
++ flushd (r1)
++ sub r1, r1, r2
++ bgt r1, zero, data_flush
++ // flush the instruction cache
++ movia r1,NIOS2_ICACHE_SIZE
++ movi r2,NIOS2_ICACHE_LINE_SIZE
++text_flush:
++ flushi r1
++ sub r1, r1, r2
++ bgt r1, zero, text_flush
++ // then flush the pipeline
++ flushp
++ // pass saved args to kernel
++ ldw r4,0(sp)
++ ldw r5,4(sp)
++ ldw r6,8(sp)
++ ldw r7,12(sp)
++ movia r1,LINUX_SDRAM_START
++ jmp r1
++
++ .balign 512
++fake_headers_as_bzImage:
++ .short 0
++ .ascii "HdrS"
++ .short 0x0202
++ .short 0
++ .short 0
++ .byte 0x00, 0x10
++ .short 0
++ .byte 0
++ .byte 1
++ .byte 0x00, 0x80
++ .long 0
++ .long 0
++
+diff --git a/arch/nios2nommu/boot/compressed/install.sh b/arch/nios2nommu/boot/compressed/install.sh
+new file mode 100644
+index 0000000..6d72e9e
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/install.sh
+@@ -0,0 +1,57 @@
++#!/bin/sh
++#
++# arch/sh/boot/install.sh
++#
++# This file is subject to the terms and conditions of the GNU General Public
++# License. See the file "COPYING" in the main directory of this archive
++# for more details.
++#
++# Copyright (C) 1995 by Linus Torvalds
++#
++# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
++# Adapted from code in arch/i386/boot/install.sh by Russell King
++# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy
++# Adapted from code in arch/sh/boot/install.sh by Takeo Takahashi
++#
++# "make install" script for sh architecture
++#
++# Arguments:
++# $1 - kernel version
++# $2 - kernel image file
++# $3 - kernel map file
++# $4 - default install path (blank if root directory)
++#
++
++# User may have a custom install script
++
++if [ -x /sbin/installkernel ]; then
++ exec /sbin/installkernel "$@"
++fi
++
++if [ "$2" = "zImage" ]; then
++# Compressed install
++ echo "Installing compressed kernel"
++ if [ -f $4/vmlinuz-$1 ]; then
++ mv $4/vmlinuz-$1 $4/vmlinuz.old
++ fi
++
++ if [ -f $4/System.map-$1 ]; then
++ mv $4/System.map-$1 $4/System.old
++ fi
++
++ cat $2 > $4/vmlinuz-$1
++ cp $3 $4/System.map-$1
++else
++# Normal install
++ echo "Installing normal kernel"
++ if [ -f $4/vmlinux-$1 ]; then
++ mv $4/vmlinux-$1 $4/vmlinux.old
++ fi
++
++ if [ -f $4/System.map ]; then
++ mv $4/System.map $4/System.old
++ fi
++
++ cat $2 > $4/vmlinux-$1
++ cp $3 $4/System.map
++fi
+diff --git a/arch/nios2nommu/boot/compressed/misc.c b/arch/nios2nommu/boot/compressed/misc.c
+new file mode 100644
+index 0000000..c513e6e
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/misc.c
+@@ -0,0 +1,208 @@
++/*
++ * arch/nios2nommu/boot/compressed/misc.c
++ *
++ * This is a collection of several routines from gzip-1.0.3
++ * adapted for Linux.
++ *
++ * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
++ *
++ * Adapted for SH by Stuart Menefy, Aug 1999
++ *
++ * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
++ */
++
++#include <linux/string.h>
++
++/*
++ * gzip declarations
++ */
++
++#define OF(args) args
++#define STATIC static
++
++#undef memset
++#undef memcpy
++#define memzero(s, n) memset ((s), 0, (n))
++
++typedef unsigned char uch;
++typedef unsigned short ush;
++typedef unsigned long ulg;
++
++#define WSIZE 0x8000 /* Window size must be at least 32k, */
++ /* and a power of two */
++
++static uch *inbuf; /* input buffer */
++static uch window[WSIZE]; /* Sliding window buffer */
++
++static unsigned insize = 0; /* valid bytes in inbuf */
++static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
++static unsigned outcnt = 0; /* bytes in output buffer */
++
++/* gzip flag byte */
++#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
++#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
++#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
++#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
++#define COMMENT 0x10 /* bit 4 set: file comment present */
++#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
++#define RESERVED 0xC0 /* bit 6,7: reserved */
++
++#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
++
++/* Diagnostic functions */
++#ifdef DEBUG
++# define Assert(cond,msg) {if(!(cond)) error(msg);}
++# define Trace(x) fprintf x
++# define Tracev(x) {if (verbose) fprintf x ;}
++# define Tracevv(x) {if (verbose>1) fprintf x ;}
++# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
++# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
++#else
++# define Assert(cond,msg)
++# define Trace(x)
++# define Tracev(x)
++# define Tracevv(x)
++# define Tracec(c,x)
++# define Tracecv(c,x)
++#endif
++
++static int fill_inbuf(void);
++static void flush_window(void);
++static void error(char *m);
++static void gzip_mark(void **);
++static void gzip_release(void **);
++
++extern char input_data[];
++extern int input_len;
++
++static long bytes_out = 0;
++static uch *output_data;
++static unsigned long output_ptr = 0;
++
++#include "nios2_sio.c"
++
++static void *malloc(int size);
++static void free(void *where);
++static void error(char *m);
++static void gzip_mark(void **);
++static void gzip_release(void **);
++
++int puts(const char *);
++
++extern int _end;
++static unsigned long free_mem_ptr;
++static unsigned long free_mem_end_ptr;
++
++#define HEAP_SIZE 0x10000
++
++#include "../../../../lib/inflate.c"
++
++static void *malloc(int size)
++{
++ void *p;
++
++ if (size <0) error("Malloc error");
++ if (free_mem_ptr == 0) error("Memory error");
++
++ free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
++
++ p = (void *)free_mem_ptr;
++ free_mem_ptr += size;
++
++ if (free_mem_ptr >= free_mem_end_ptr)
++ error("Out of memory");
++
++ return p;
++}
++
++static void free(void *where)
++{ /* Don't care */
++}
++
++static void gzip_mark(void **ptr)
++{
++ *ptr = (void *) free_mem_ptr;
++}
++
++static void gzip_release(void **ptr)
++{
++ free_mem_ptr = (long) *ptr;
++}
++
++void* memset(void* s, int c, size_t n)
++{
++ int i;
++ char *ss = (char*)s;
++
++ for (i=0;i<n;i++) ss[i] = c;
++ return s;
++}
++
++void* memcpy(void* __dest, __const void* __src,
++ size_t __n)
++{
++ int i;
++ char *d = (char *)__dest, *s = (char *)__src;
++
++ for (i=0;i<__n;i++) d[i] = s[i];
++ return __dest;
++}
++
++/* ===========================================================================
++ * Fill the input buffer. This is called only when the buffer is empty
++ * and at least one byte is really needed.
++ */
++static int fill_inbuf(void)
++{
++ if (insize != 0) {
++ error("ran out of input data");
++ }
++
++ inbuf = input_data;
++ insize = input_len;
++ inptr = 1;
++ return inbuf[0];
++}
++
++/* ===========================================================================
++ * Write the output window window[0..outcnt-1] and update crc and bytes_out.
++ * (Used for the decompressed data only.)
++ */
++static void flush_window(void)
++{
++ ulg c = crc; /* temporary variable */
++ unsigned n;
++ uch *in, *out, ch;
++ in = window;
++ out = &output_data[output_ptr];
++ for (n = 0; n < outcnt; n++) {
++ ch = *out++ = *in++;
++ c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
++ }
++ crc = c;
++ bytes_out += (ulg)outcnt;
++ output_ptr += (ulg)outcnt;
++ outcnt = 0;
++}
++
++static void error(char *x)
++{
++ puts("\nERROR\n");
++ puts(x);
++ puts("\n\n -- System halted");
++
++ while(1); /* Halt */
++}
++
++void decompress_kernel(void)
++{
++ output_data = (void *)nasys_program_mem;
++ output_ptr = 0;
++ free_mem_ptr = (unsigned long)&_end;
++ free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
++
++ makecrc();
++ puts("Uncompressing Linux... ");
++ gunzip();
++ puts("Ok, booting the kernel.\n");
++}
+diff --git a/arch/nios2nommu/boot/compressed/nios2_sio.c b/arch/nios2nommu/boot/compressed/nios2_sio.c
+new file mode 100644
+index 0000000..8630c8f
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/nios2_sio.c
+@@ -0,0 +1,57 @@
++
++static int putchar(int ch);
++
++static int puts(const char *s)
++ {
++ while(*s)
++ putchar(*s++);
++ return 0;
++ }
++
++#include <asm/nios.h>
++#include <asm/io.h>
++
++#if defined(CONFIG_SERIAL_AJUART_CONSOLE)
++
++#define IORD_ALTERA_AVALON_JTAG_UART_DATA(base) inl(base)
++#define IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, data) outl(data, base)
++#define IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) inl(base+4)
++#define IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, data) outl(data, base+4)
++#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK (0xFFFF0000u)
++#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST (16)
++
++static void jtag_putc(int ch)
++{
++ unsigned base = na_jtag_uart;
++ while ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
++ IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, ch);
++}
++
++static int putchar(int ch)
++{
++ jtag_putc( ch );
++ return ch;
++}
++
++#elif defined(CONFIG_NIOS_SERIAL_CONSOLE)
++
++static void nr_txchar(int ch)
++{
++ while ((na_uart0->np_uartstatus & np_uartstatus_trdy_mask) == 0);
++ na_uart0->np_uarttxdata = ch;
++}
++
++static int putchar(int ch)
++{
++ nr_txchar( ch ); if (ch=='\n') nr_txchar( '\r' );
++ return ch;
++}
++
++#else
++
++static int putchar(int ch)
++{
++ return ch;
++}
++
++#endif
+diff --git a/arch/nios2nommu/boot/compressed/vmlinux.lds.S b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
+new file mode 100644
+index 0000000..08bb3e2
+--- /dev/null
++++ b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
+@@ -0,0 +1,34 @@
++#include <asm-generic/vmlinux.lds.h>
++#include <asm/nios.h>
++
++OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
++
++OUTPUT_ARCH(nios)
++ENTRY(_start) /* Defined in head.S */
++
++SECTIONS
++{
++ . =nasys_program_mem + CONFIG_BOOT_LINK_OFFSET;
++
++ _text = .;
++ .text : { *(.text) } = 0
++ .rodata : { *(.rodata) *(.rodata.*) }
++ _etext = .;
++
++ . = ALIGN(32 / 8);
++ .data : { *(.data) }
++ . = ALIGN(32 / 8);
++ _got = .;
++ .got : { *(.got) _egot = .; *(.got.*) }
++ _edata = .;
++
++ . = ALIGN(32 / 8);
++ __bss_start = .;
++ .bss : { *(.bss) *(.sbss) }
++ . = ALIGN(32 / 8);
++ _ebss = .;
++ end = . ;
++ _end = . ;
++
++ got_len = (_egot - _got);
++}
+diff --git a/arch/nios2nommu/defconfig b/arch/nios2nommu/defconfig
+new file mode 100644
+index 0000000..40629cb
+--- /dev/null
++++ b/arch/nios2nommu/defconfig
+@@ -0,0 +1,690 @@
++#
++# Automatically generated make config: don't edit
++# Linux kernel version: 2.6.19-uc1
++#
++# CONFIG_MMU is not set
++# CONFIG_FPU is not set
++CONFIG_UID16=y
++CONFIG_RWSEM_GENERIC_SPINLOCK=y
++# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
++CONFIG_GENERIC_FIND_NEXT_BIT=y
++CONFIG_GENERIC_HWEIGHT=y
++CONFIG_GENERIC_CALIBRATE_DELAY=y
++
++#
++# Code maturity level options
++#
++CONFIG_EXPERIMENTAL=y
++CONFIG_BROKEN_ON_SMP=y
++CONFIG_LOCK_KERNEL=y
++CONFIG_INIT_ENV_ARG_LIMIT=32
++
++#
++# General setup
++#
++CONFIG_LOCALVERSION=""
++CONFIG_LOCALVERSION_AUTO=y
++# CONFIG_SYSVIPC is not set
++# CONFIG_POSIX_MQUEUE is not set
++# CONFIG_BSD_PROCESS_ACCT is not set
++# CONFIG_TASKSTATS is not set
++# CONFIG_UTS_NS is not set
++# CONFIG_AUDIT is not set
++# CONFIG_IKCONFIG is not set
++# CONFIG_RELAY is not set
++CONFIG_INITRAMFS_SOURCE="../romfs ../vendors/Altera/nios2nommu/romfs_list"
++CONFIG_INITRAMFS_ROOT_UID=500
++CONFIG_INITRAMFS_ROOT_GID=500
++CONFIG_CC_OPTIMIZE_FOR_SIZE=y
++CONFIG_EMBEDDED=y
++# CONFIG_SYSCTL_SYSCALL is not set
++# CONFIG_KALLSYMS is not set
++# CONFIG_HOTPLUG is not set
++CONFIG_PRINTK=y
++CONFIG_BUG=y
++# CONFIG_ELF_CORE is not set
++CONFIG_BASE_FULL=y
++CONFIG_FUTEX=y
++# CONFIG_EPOLL is not set
++CONFIG_SLAB=y
++# CONFIG_VM_EVENT_COUNTERS is not set
++CONFIG_RT_MUTEXES=y
++CONFIG_TINY_SHMEM=y
++CONFIG_BASE_SMALL=0
++# CONFIG_SLOB is not set
++
++#
++# Loadable module support
++#
++# CONFIG_MODULES is not set
++
++#
++# Block layer
++#
++CONFIG_BLOCK=y
++# CONFIG_BLK_DEV_IO_TRACE is not set
++
++#
++# IO Schedulers
++#
++CONFIG_IOSCHED_NOOP=y
++# CONFIG_IOSCHED_AS is not set
++CONFIG_IOSCHED_DEADLINE=y
++# CONFIG_IOSCHED_CFQ is not set
++# CONFIG_DEFAULT_AS is not set
++CONFIG_DEFAULT_DEADLINE=y
++# CONFIG_DEFAULT_CFQ is not set
++# CONFIG_DEFAULT_NOOP is not set
++CONFIG_DEFAULT_IOSCHED="deadline"
++
++#
++# Processor type and features
++#
++
++#
++# Platform dependant setup
++#
++CONFIG_NIOS2=y
++# CONFIG_MICROTRONIX_UKIT is not set
++# CONFIG_MICROTRONIX_STRATIX is not set
++# CONFIG_MICROTRONIX_CYCLONE is not set
++# CONFIG_MICROTRONIX_PSK is not set
++CONFIG_ALTERA_STRATIX=y
++# CONFIG_ALTERA_STRATIX_PRO is not set
++# CONFIG_ALTERA_STRATIX_II is not set
++# CONFIG_ALTERA_CYCLONE is not set
++# CONFIG_ALTERA_CYCLONE_1C12_EVAL is not set
++# CONFIG_ALTERA_DE2 is not set
++# CONFIG_NIOS2_HW_MUL_OFF is not set
++CONFIG_NIOS2_HW_MUL=y
++# CONFIG_NIOS2_HW_MULX is not set
++
++#
++# Platform drivers Options
++#
++# CONFIG_AVALON_DMA is not set
++# CONFIG_PIO_DEVICES is not set
++# CONFIG_PCI is not set
++# CONFIG_FB_ALTERA is not set
++# CONFIG_SERIO_ALTPS2 is not set
++# CONFIG_I2C_GPIO is not set
++
++#
++# Miscellaneous Options
++#
++CONFIG_EXCALIBUR=y
++# CONFIG_BREAK_ON_START is not set
++CONFIG_LARGE_ALLOCS=y
++CONFIG_RAMKERNEL=y
++CONFIG_PREEMPT=y
++# CONFIG_PREEMPT_TIMES is not set
++CONFIG_CMDLINE=""
++# CONFIG_PASS_CMDLINE is not set
++CONFIG_SELECT_MEMORY_MODEL=y
++CONFIG_FLATMEM_MANUAL=y
++# CONFIG_DISCONTIGMEM_MANUAL is not set
++# CONFIG_SPARSEMEM_MANUAL is not set
++CONFIG_FLATMEM=y
++CONFIG_FLAT_NODE_MEM_MAP=y
++# CONFIG_SPARSEMEM_STATIC is not set
++CONFIG_SPLIT_PTLOCK_CPUS=4
++# CONFIG_RESOURCES_64BIT is not set
++CONFIG_BOOT_LINK_OFFSET=0x00500000
++
++#
++# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
++#
++
++#
++# PCCARD (PCMCIA/CardBus) support
++#
++
++#
++# PCI Hotplug Support
++#
++
++#
++# Executable file formats
++#
++CONFIG_KCORE_AOUT=y
++CONFIG_KCORE_ELF=y
++CONFIG_BINFMT_FLAT=y
++CONFIG_BINFMT_ZFLAT=y
++# CONFIG_BINFMT_SHARED_FLAT is not set
++# CONFIG_BINFMT_MISC is not set
++
++#
++# Power management options
++#
++# CONFIG_PM is not set
++
++#
++# Networking
++#
++CONFIG_NET=y
++
++#
++# Networking options
++#
++# CONFIG_NETDEBUG is not set
++CONFIG_PACKET=y
++# CONFIG_PACKET_MMAP is not set
++CONFIG_UNIX=y
++# CONFIG_NET_KEY is not set
++CONFIG_INET=y
++# CONFIG_IP_MULTICAST is not set
++# CONFIG_IP_ADVANCED_ROUTER is not set
++CONFIG_IP_FIB_HASH=y
++# CONFIG_IP_PNP is not set
++# CONFIG_NET_IPIP is not set
++# CONFIG_NET_IPGRE is not set
++# CONFIG_ARPD is not set
++# CONFIG_SYN_COOKIES is not set
++# CONFIG_INET_AH is not set
++# CONFIG_INET_ESP is not set
++# CONFIG_INET_IPCOMP is not set
++# CONFIG_INET_XFRM_TUNNEL is not set
++# CONFIG_INET_TUNNEL is not set
++# CONFIG_IPSEC_NAT_TRAVERSAL is not set
++# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
++# CONFIG_INET_XFRM_MODE_TUNNEL is not set
++# CONFIG_INET_XFRM_MODE_BEET is not set
++# CONFIG_INET_DIAG is not set
++# CONFIG_TCP_CONG_ADVANCED is not set
++CONFIG_TCP_CONG_CUBIC=y
++CONFIG_DEFAULT_TCP_CONG="cubic"
++# CONFIG_IPV6 is not set
++# CONFIG_INET6_XFRM_TUNNEL is not set
++# CONFIG_INET6_TUNNEL is not set
++# CONFIG_NETWORK_SECMARK is not set
++# CONFIG_NETFILTER is not set
++
++#
++# DCCP Configuration (EXPERIMENTAL)
++#
++# CONFIG_IP_DCCP is not set
++
++#
++# SCTP Configuration (EXPERIMENTAL)
++#
++# CONFIG_IP_SCTP is not set
++
++#
++# TIPC Configuration (EXPERIMENTAL)
++#
++# CONFIG_TIPC is not set
++# CONFIG_ATM is not set
++# CONFIG_BRIDGE is not set
++# CONFIG_VLAN_8021Q is not set
++# CONFIG_DECNET is not set
++# CONFIG_LLC2 is not set
++# CONFIG_IPX is not set
++# CONFIG_ATALK is not set
++# CONFIG_X25 is not set
++# CONFIG_LAPB is not set
++# CONFIG_ECONET is not set
++# CONFIG_WAN_ROUTER is not set
++
++#
++# QoS and/or fair queueing
++#
++# CONFIG_NET_SCHED is not set
++
++#
++# Network testing
++#
++# CONFIG_NET_PKTGEN is not set
++# CONFIG_HAMRADIO is not set
++# CONFIG_IRDA is not set
++# CONFIG_BT is not set
++# CONFIG_KLIPS is not set
++# CONFIG_IEEE80211 is not set
++
++#
++# Device Drivers
++#
++
++#
++# Generic Driver Options
++#
++CONFIG_STANDALONE=y
++CONFIG_PREVENT_FIRMWARE_BUILD=y
++# CONFIG_SYS_HYPERVISOR is not set
++
++#
++# Connector - unified userspace <-> kernelspace linker
++#
++# CONFIG_CONNECTOR is not set
++
++#
++# Memory Technology Devices (MTD)
++#
++# CONFIG_MTD is not set
++
++#
++# Parallel port support
++#
++# CONFIG_PARPORT is not set
++
++#
++# Plug and Play support
++#
++
++#
++# Block devices
++#
++# CONFIG_BLK_DEV_COW_COMMON is not set
++# CONFIG_BLK_DEV_LOOP is not set
++# CONFIG_BLK_DEV_NBD is not set
++# CONFIG_BLK_DEV_RAM is not set
++# CONFIG_BLK_DEV_INITRD is not set
++# CONFIG_CDROM_PKTCDVD is not set
++# CONFIG_ATA_OVER_ETH is not set
++
++#
++# Misc devices
++#
++# CONFIG_TIFM_CORE is not set
++
++#
++# ATA/ATAPI/MFM/RLL support
++#
++# CONFIG_IDE is not set
++
++#
++# SCSI device support
++#
++# CONFIG_RAID_ATTRS is not set
++# CONFIG_SCSI is not set
++# CONFIG_SCSI_NETLINK is not set
++
++#
++# Serial ATA (prod) and Parallel ATA (experimental) drivers
++#
++# CONFIG_ATA is not set
++
++#
++# Multi-device support (RAID and LVM)
++#
++# CONFIG_MD is not set
++
++#
++# Fusion MPT device support
++#
++# CONFIG_FUSION is not set
++
++#
++# IEEE 1394 (FireWire) support
++#
++
++#
++# I2O device support
++#
++
++#
++# Network device support
++#
++CONFIG_NETDEVICES=y
++# CONFIG_DUMMY is not set
++# CONFIG_BONDING is not set
++# CONFIG_EQUALIZER is not set
++# CONFIG_TUN is not set
++
++#
++# PHY device support
++#
++# CONFIG_PHYLIB is not set
++
++#
++# Ethernet (10 or 100Mbit)
++#
++CONFIG_NET_ETHERNET=y
++CONFIG_MII=y
++# CONFIG_NET_VENDOR_SMC is not set
++# CONFIG_OPEN_ETH is not set
++# CONFIG_MTIP1000_ETH is not set
++# CONFIG_NE2000 is not set
++# CONFIG_NET_PCI is not set
++
++#
++# Ethernet (1000 Mbit)
++#
++
++#
++# Ethernet (10000 Mbit)
++#
++
++#
++# Token Ring devices
++#
++
++#
++# Wireless LAN (non-hamradio)
++#
++# CONFIG_NET_RADIO is not set
++
++#
++# Wan interfaces
++#
++# CONFIG_WAN is not set
++# CONFIG_PPP is not set
++# CONFIG_SLIP is not set
++# CONFIG_SHAPER is not set
++# CONFIG_NETCONSOLE is not set
++# CONFIG_NETPOLL is not set
++# CONFIG_NET_POLL_CONTROLLER is not set
++
++#
++# ISDN subsystem
++#
++# CONFIG_ISDN is not set
++
++#
++# Telephony Support
++#
++# CONFIG_PHONE is not set
++
++#
++# Input device support
++#
++# CONFIG_INPUT is not set
++
++#
++# Hardware I/O ports
++#
++# CONFIG_SERIO is not set
++# CONFIG_GAMEPORT is not set
++
++#
++# Character devices
++#
++# CONFIG_VT is not set
++# CONFIG_SERIAL_NONSTANDARD is not set
++# CONFIG_NIOS_LCD_16207 is not set
++# CONFIG_NIOS_BUTTON is not set
++# CONFIG_LEDMAN is not set
++# CONFIG_SNAPDOG is not set
++# CONFIG_FAST_TIMER is not set
++# CONFIG_RESETSWITCH is not set
++
++#
++# Serial drivers
++#
++# CONFIG_SERIAL_8250 is not set
++
++#
++# Non-8250 serial port support
++#
++CONFIG_SERIAL_CORE=y
++CONFIG_SERIAL_CORE_CONSOLE=y
++# CONFIG_NIOS_SERIAL is not set
++CONFIG_SERIAL_AJUART=y
++CONFIG_SERIAL_AJUART_CONSOLE=y
++# CONFIG_UNIX98_PTYS is not set
++CONFIG_LEGACY_PTYS=y
++CONFIG_LEGACY_PTY_COUNT=10
++
++#
++# IPMI
++#
++# CONFIG_IPMI_HANDLER is not set
++
++#
++# Watchdog Cards
++#
++# CONFIG_WATCHDOG is not set
++# CONFIG_HW_RANDOM is not set
++# CONFIG_RTC is not set
++# CONFIG_GEN_RTC is not set
++# CONFIG_DTLK is not set
++# CONFIG_R3964 is not set
++
++#
++# Ftape, the floppy tape device driver
++#
++# CONFIG_RAW_DRIVER is not set
++
++#
++# TPM devices
++#
++# CONFIG_TCG_TPM is not set
++# CONFIG_M41T11M6 is not set
++
++#
++# I2C support
++#
++# CONFIG_I2C is not set
++
++#
++# SPI support
++#
++# CONFIG_SPI is not set
++# CONFIG_SPI_MASTER is not set
++
++#
++# Dallas's 1-wire bus
++#
++# CONFIG_W1 is not set
++
++#
++# Hardware Monitoring support
++#
++CONFIG_HWMON=y
++# CONFIG_HWMON_VID is not set
++# CONFIG_SENSORS_ABITUGURU is not set
++# CONFIG_SENSORS_F71805F is not set
++# CONFIG_SENSORS_VT1211 is not set
++# CONFIG_HWMON_DEBUG_CHIP is not set
++
++#
++# Multimedia devices
++#
++# CONFIG_VIDEO_DEV is not set
++
++#
++# Digital Video Broadcasting Devices
++#
++# CONFIG_DVB is not set
++
++#
++# Graphics support
++#
++# CONFIG_FIRMWARE_EDID is not set
++# CONFIG_FB is not set
++# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
++
++#
++# Sound
++#
++# CONFIG_SOUND is not set
++
++#
++# USB support
++#
++# CONFIG_USB_ARCH_HAS_HCD is not set
++# CONFIG_USB_ARCH_HAS_OHCI is not set
++# CONFIG_USB_ARCH_HAS_EHCI is not set
++
++#
++# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
++#
++
++#
++# USB Gadget Support
++#
++# CONFIG_USB_GADGET is not set
++
++#
++# MMC/SD Card support
++#
++# CONFIG_MMC is not set
++
++#
++# LED devices
++#
++# CONFIG_NEW_LEDS is not set
++
++#
++# LED drivers
++#
++
++#
++# LED Triggers
++#
++
++#
++# InfiniBand support
++#
++
++#
++# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
++#
++
++#
++# Real Time Clock
++#
++# CONFIG_RTC_CLASS is not set
++
++#
++# DMA Engine support
++#
++# CONFIG_DMA_ENGINE is not set
++
++#
++# DMA Clients
++#
++
++#
++# DMA Devices
++#
++
++#
++# File systems
++#
++# CONFIG_EXT2_FS is not set
++# CONFIG_EXT3_FS is not set
++# CONFIG_EXT4DEV_FS is not set
++# CONFIG_REISERFS_FS is not set
++# CONFIG_JFS_FS is not set
++# CONFIG_FS_POSIX_ACL is not set
++# CONFIG_XFS_FS is not set
++# CONFIG_GFS2_FS is not set
++# CONFIG_OCFS2_FS is not set
++# CONFIG_MINIX_FS is not set
++# CONFIG_ROMFS_FS is not set
++# CONFIG_INOTIFY is not set
++# CONFIG_QUOTA is not set
++# CONFIG_DNOTIFY is not set
++# CONFIG_AUTOFS_FS is not set
++# CONFIG_AUTOFS4_FS is not set
++# CONFIG_FUSE_FS is not set
++# CONFIG_DIRECTIO is not set
++
++#
++# CD-ROM/DVD Filesystems
++#
++# CONFIG_ISO9660_FS is not set
++# CONFIG_UDF_FS is not set
++
++#
++# DOS/FAT/NT Filesystems
++#
++# CONFIG_MSDOS_FS is not set
++# CONFIG_VFAT_FS is not set
++# CONFIG_NTFS_FS is not set
++
++#
++# Pseudo filesystems
++#
++CONFIG_PROC_FS=y
++# CONFIG_PROC_SYSCTL is not set
++CONFIG_SYSFS=y
++# CONFIG_TMPFS is not set
++# CONFIG_HUGETLB_PAGE is not set
++CONFIG_RAMFS=y
++# CONFIG_CONFIGFS_FS is not set
++
++#
++# Miscellaneous filesystems
++#
++# CONFIG_ADFS_FS is not set
++# CONFIG_AFFS_FS is not set
++# CONFIG_HFS_FS is not set
++# CONFIG_HFSPLUS_FS is not set
++# CONFIG_BEFS_FS is not set
++# CONFIG_BFS_FS is not set
++# CONFIG_EFS_FS is not set
++# CONFIG_CRAMFS is not set
++# CONFIG_SQUASHFS is not set
++# CONFIG_VXFS_FS is not set
++# CONFIG_HPFS_FS is not set
++# CONFIG_QNX4FS_FS is not set
++# CONFIG_SYSV_FS is not set
++# CONFIG_UFS_FS is not set
++
++#
++# Network File Systems
++#
++CONFIG_NFS_FS=y
++CONFIG_NFS_V3=y
++# CONFIG_NFS_V3_ACL is not set
++# CONFIG_NFS_V4 is not set
++# CONFIG_NFSD is not set
++CONFIG_LOCKD=y
++CONFIG_LOCKD_V4=y
++CONFIG_NFS_COMMON=y
++CONFIG_SUNRPC=y
++# CONFIG_RPCSEC_GSS_KRB5 is not set
++# CONFIG_RPCSEC_GSS_SPKM3 is not set
++# CONFIG_SMB_FS is not set
++# CONFIG_CIFS is not set
++# CONFIG_NCP_FS is not set
++# CONFIG_CODA_FS is not set
++# CONFIG_AFS_FS is not set
++# CONFIG_9P_FS is not set
++
++#
++# Partition Types
++#
++# CONFIG_PARTITION_ADVANCED is not set
++CONFIG_MSDOS_PARTITION=y
++
++#
++# Native Language Support
++#
++# CONFIG_NLS is not set
++
++#
++# Debug
++#
++# CONFIG_COREDUMP_PRINTK is not set
++
++#
++# Kernel hacking
++#
++# CONFIG_FULLDEBUG is not set
++# CONFIG_FRAME_POINTER is not set
++# CONFIG_MAGIC_SYSRQ is not set
++# CONFIG_NO_KERNEL_MSG is not set
++CONFIG_LOG_BUF_SHIFT=14
++
++#
++# Security options
++#
++# CONFIG_KEYS is not set
++# CONFIG_SECURITY is not set
++
++#
++# Cryptographic options
++#
++# CONFIG_CRYPTO is not set
++
++#
++# Library routines
++#
++# CONFIG_CRC_CCITT is not set
++# CONFIG_CRC16 is not set
++CONFIG_CRC32=y
++# CONFIG_LIBCRC32C is not set
++CONFIG_ZLIB_INFLATE=y
++CONFIG_PLIST=y
+diff --git a/arch/nios2nommu/drivers/Kconfig b/arch/nios2nommu/drivers/Kconfig
+new file mode 100644
+index 0000000..2fde3a8
+--- /dev/null
++++ b/arch/nios2nommu/drivers/Kconfig
+@@ -0,0 +1,45 @@
++# Platfrom drivers configuration
++
++source "arch/nios2nommu/drivers/pci/Kconfig"
++
++config FB_ALTERA
++ tristate "Avalon VGA controller support"
++ default N
++ select FB
++ select FB_CFB_FILLRECT
++ select FB_CFB_COPYAREA
++ select FB_CFB_IMAGEBLIT
++ help
++ This is the frame buffer device driver for the VGA controller
++ in SOPC Builder.
++
++config SERIO_ALTPS2
++ tristate "PS2 controller"
++ select VT
++ default N
++ select SERIO
++
++config I2C_NIOS2_GPIO
++ tristate "GPIO-Based I2C Interface"
++ default N
++ select I2C
++ select I2C_ALGOBIT
++ help
++ Say Y here if you use GPIO lines for an I2C bus.
++
++config BLK_DEV_ALTCF
++ tristate "Altera CF (IDE mode) interface (Avalon bus) support"
++ select IDE
++ select BLK_DEV_IDE
++ default N
++ help
++ This driver provides support for the Altera Compact flash core (with
++ Avalon interface) support. If you have an Altera or Microtronix
++ development board you can build support into the FPGA device for this.
++
++config NIOS_SPI
++ bool "Nios SPI device support"
++ depends on NIOS || NIOS2
++ help
++ This driver supports the Nios softcore SPI device.
++
+diff --git a/arch/nios2nommu/drivers/Makefile b/arch/nios2nommu/drivers/Makefile
+new file mode 100644
+index 0000000..f6a273e
+--- /dev/null
++++ b/arch/nios2nommu/drivers/Makefile
+@@ -0,0 +1,10 @@
++#
++# Makefile for the Linux nios2-specific device drivers.
++#
++
++obj-$(CONFIG_PCI) += pci/
++obj-$(CONFIG_FB_ALTERA) += altfb.o
++obj-$(CONFIG_SERIO_ALTPS2) += altps2.o
++obj-$(CONFIG_I2C_NIOS2_GPIO) += i2c-gpio.o
++obj-$(CONFIG_BLK_DEV_ALTCF) += altcf.o
++obj-$(CONFIG_NIOS_SPI) += spi.o
+diff --git a/arch/nios2nommu/drivers/altcf.c b/arch/nios2nommu/drivers/altcf.c
+new file mode 100644
+index 0000000..80275c6
+--- /dev/null
++++ b/arch/nios2nommu/drivers/altcf.c
+@@ -0,0 +1,266 @@
++/*
++ * linux/drivers/ide/altcf.c
++ * Support for Altera CompactFlash core with Avalon interface.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#include <linux/module.h>
++#include <linux/types.h>
++#include <linux/kernel.h>
++#include <linux/delay.h>
++#include <linux/timer.h>
++#include <linux/mm.h>
++#include <linux/ioport.h>
++#include <linux/blkdev.h>
++#include <linux/hdreg.h>
++#include <linux/ide.h>
++#include <linux/init.h>
++#include <asm/io.h>
++#include <asm/nios.h>
++
++MODULE_AUTHOR("Microtronix Datacom Ltd.");
++MODULE_DESCRIPTION("Driver of Altera CompactFlash core with Avalon interface");
++MODULE_LICENSE("GPL");
++
++#define PDEBUG printk
++/* Altera Avalon Compact Flash core registers */
++#define REG_CFCTL 0
++#define REG_IDECTL 4
++
++/* CFCTL bits */
++#define CFCTL_DET 1 /* detect status */
++#define CFCTL_PWR 2 /* Power */
++#define CFCTL_RST 4 /* Reset */
++#define CFCTL_IDET 8 /* Detect int enable*/
++
++/* IDECTL bits */
++#define IDECTL_IIDE 1 /* IDE int enable */
++
++struct cf_dev {
++ int base;
++ int irq;
++ int ide_base;
++ int ide_irq;
++ int configured;
++ ide_hwif_t *hwif;
++ struct delayed_work wcf;
++};
++
++static struct cf_dev cf_devices[MAX_HWIFS] = {
++#if MAX_HWIFS > 0
++ {na_ide_ctl, na_ide_ctl_irq, na_ide_ide, na_ide_ide_irq, 0, NULL},
++#endif
++#if MAX_HWIFS > 1
++ {na_ctl_base1, na_ctl_irq1, na_ide_base1, na_ide_irq1, 0, NULL},
++#endif
++#if MAX_HWIFS > 2
++ {na_ctl_base2, na_ctl_irq2, na_ide_base2, na_ide_irq2, 0, NULL},
++#endif
++#if MAX_HWIFS > 3
++ {na_ctl_base3, na_ctl_irq3, na_ide_base3, na_ide_irq3, 0, NULL},
++#endif
++};
++
++static inline void cf_init_hwif_ports(hw_regs_t *hw,
++ unsigned long io_addr,
++ unsigned long ctl_addr,
++ int *irq)
++{
++ unsigned int i;
++
++ for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
++ hw->io_ports[i] = io_addr + 4*(i-IDE_DATA_OFFSET);
++
++ hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr;
++
++ if (irq)
++ *irq = 0;
++
++ hw->io_ports[IDE_IRQ_OFFSET] = 0;
++
++}
++
++static int cf_release(struct cf_dev* dev)
++{
++ if (dev) {
++ if ((dev->configured) && (dev->hwif)) {
++ /* disable IDE interrupts */
++ outl(0, dev->base + REG_IDECTL);
++ /* power off the card */
++ //outl(0, dev->base + REG_CFCTL);
++
++ ide_unregister(dev->hwif->index);
++ dev->configured = 0;
++ dev->hwif = NULL;
++ PDEBUG("CF released\n");
++ return 0;
++ }
++ }
++ return -1;
++}
++
++static int cf_config(struct cf_dev* dev)
++{
++ hw_regs_t hw;
++ int index;
++ ide_hwif_t *hwif;
++
++ if (!dev)
++ return -1;
++
++ if (!dev->configured) {
++ int i;
++ for (i=1; i<=10; i++) {
++ cf_init_hwif_ports(&hw, dev->ide_base, 0, NULL);
++ hw.irq = dev->ide_irq;
++ hw.chipset = ide_generic;
++ outl(IDECTL_IIDE, dev->base + REG_IDECTL);
++ index = ide_register_hw(&hw, 1, &hwif);
++ if (index >=0) {
++ dev->configured = 1;
++ dev->hwif = hwif;
++ return index;
++ }
++
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout(HZ/10);
++ }
++ /* register fails */
++ PDEBUG("CF:fail to register\n");
++ /* disable IDE interrupt */
++ outl(0, dev->base + REG_IDECTL);
++ return -1;
++ }
++ return -2; /* already configured */
++}
++
++static irqreturn_t cf_intr(int irq, void *dev_id)
++{
++ unsigned int cfctl;
++ struct cf_dev* dev = (struct cf_dev *)dev_id;
++
++ if (!dev)
++ return IRQ_NONE;
++
++ cfctl=inl(dev->base + REG_CFCTL);
++ /* unpower the card */
++ outl((cfctl & ~(CFCTL_PWR)), dev->base + REG_CFCTL);
++
++ if ((cfctl & CFCTL_DET))
++ schedule_delayed_work(&dev->wcf, HZ/2);
++ else
++ schedule_work(&dev->wcf.work);
++ return IRQ_HANDLED;
++}
++
++static void cf_event(struct work_struct *work)
++{
++ struct cf_dev* dev = container_of(work, struct cf_dev, wcf.work);
++
++ if (dev) {
++ unsigned int cfctl;
++
++ cfctl=inl(dev->base + REG_CFCTL);
++ if ((cfctl & CFCTL_DET)) {
++ /* a CF card is inserted, power on the card */
++ outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), dev->base + REG_CFCTL);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout(HZ);
++ cf_config(dev);
++ }
++ else {
++ /* a CF card is removed */
++ cf_release(dev);
++ }
++ }
++}
++
++int __init altcf_init(void)
++{
++ unsigned int cfctl;
++ int i;
++ ide_hwif_t *hwif;
++ hw_regs_t hw;
++ extern ide_hwif_t ide_hwifs[];
++
++ for (i=0; i<MAX_HWIFS; i++) {
++ cfctl=inl(cf_devices[i].base + REG_CFCTL);
++ PDEBUG("CF: ctl=%d\n", cfctl);
++ if (cfctl & CFCTL_DET)
++ {
++ /* power off the card */
++ outl(CFCTL_RST, cf_devices[i].base + REG_CFCTL);
++ mdelay(500);
++ cfctl=inl(cf_devices[i].base + REG_CFCTL);
++
++ /* power on the card */
++ outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), cf_devices[i].base + REG_CFCTL);
++ mdelay(2000);
++ inl(cf_devices[i].base + REG_CFCTL);
++
++ /* check if card is in right mode */
++ outb(0xa0, cf_devices[i].ide_base+IDE_SELECT_OFFSET*4);
++ mdelay(50);
++ if (inb(cf_devices[i].ide_base+IDE_SELECT_OFFSET*4) == 0xa0) {
++ /* enable IDE interrupt */
++ outl(IDECTL_IIDE, cf_devices[i].base + REG_IDECTL);
++ ide_hwifs[i].chipset = ide_generic;
++ cf_devices[i].hwif = &ide_hwifs[i];
++
++ memset(&hw, 0, sizeof hw);
++ cf_init_hwif_ports(&hw, cf_devices[i].ide_base, 0, NULL);
++ hw.chipset = ide_generic;
++ hw.irq = cf_devices[i].ide_irq;
++ if (ide_register_hw(&hw, 1, &hwif)>=0) {
++ cf_devices[i].configured = 1;
++ cf_devices[i].hwif = hwif;
++ }
++ else
++ printk("CF register fails\n");
++ }
++ else printk("Unable to initialize compact flash card. Please re-insert\n");
++ }
++
++ /* register the detection interrupt */
++ if (request_irq(cf_devices[i].irq, cf_intr, IRQF_DISABLED, "cf", &cf_devices[i])) {
++ PDEBUG("CF: unable to get interrupt %d for detecting inf %d\n",
++ cf_devices[i].irq, i );
++ } else {
++ INIT_DELAYED_WORK(&cf_devices[i].wcf, cf_event);
++ /* enable the detection interrupt */
++ cfctl=inl(cf_devices[i].base + REG_CFCTL);
++ outl(cfctl | CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
++ }
++ }
++
++ return 0;
++}
++
++#ifdef MODULE
++static void __exit altcf_exit(void)
++{
++ unsigned int cfctl;
++ for (i=0; i<MAX_HWIFS; i++) {
++ /* disable detection irq */
++ cfctl=inl(cf_devices[i].base + REG_CFCTL);
++ outl(cfctl & ~CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
++
++ /* free the detection irq */
++ free_irq(cf_devices[i].irq, &cf_devices[i]);
++
++ /* release the device */
++ cf_release(&cf_devices[i]);
++ }
++}
++
++module_init(altcf_init);
++module_exit(altcf_exit);
++#endif
+diff --git a/arch/nios2nommu/drivers/altfb.c b/arch/nios2nommu/drivers/altfb.c
+new file mode 100644
+index 0000000..cebd659
+--- /dev/null
++++ b/arch/nios2nommu/drivers/altfb.c
+@@ -0,0 +1,234 @@
++/*
++ * Altera VGA controller
++ *
++ * linux/drivers/video/vfb.c -- Virtual frame buffer device
++ *
++ * Copyright (C) 2002 James Simmons
++ *
++ * Copyright (C) 1997 Geert Uytterhoeven
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file COPYING in the main directory of this archive for
++ * more details.
++ */
++
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/errno.h>
++#include <linux/string.h>
++#include <linux/mm.h>
++#include <linux/tty.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++#include <linux/delay.h>
++#include <linux/interrupt.h>
++#include <linux/dma-mapping.h>
++#include <linux/platform_device.h>
++
++#include <asm/uaccess.h>
++#include <linux/fb.h>
++#include <linux/init.h>
++
++#define vgabase na_vga_controller_0
++#define XRES 640
++#define YRES 480
++#define BPX 16
++
++ /*
++ * RAM we reserve for the frame buffer. This defines the maximum screen
++ * size
++ *
++ * The default can be overridden if the driver is compiled as a module
++ */
++
++#define VIDEOMEMSIZE (XRES * YRES * (BPX>>3))
++
++static void *videomemory;
++static u_long videomemorysize = VIDEOMEMSIZE;
++module_param(videomemorysize, ulong, 0);
++
++static struct fb_var_screeninfo altfb_default __initdata = {
++ .xres = XRES,
++ .yres = YRES,
++ .xres_virtual = XRES,
++ .yres_virtual = YRES,
++ .bits_per_pixel = BPX,
++#if (BPX == 16)
++ .red = { 11, 5, 0 },
++ .green = { 5, 6, 0 },
++ .blue = { 0, 5, 0 },
++#else // BPX == 24
++ .red = { 16, 8, 0 },
++ .green = { 8, 8, 0 },
++ .blue = { 0, 8, 0 },
++#endif
++ .activate = FB_ACTIVATE_NOW,
++ .height = -1,
++ .width = -1,
++ // timing useless ?
++ .pixclock = 20000,
++ .left_margin = 64,
++ .right_margin = 64,
++ .upper_margin = 32,
++ .lower_margin = 32,
++ .hsync_len = 64,
++ .vsync_len = 2,
++ .vmode = FB_VMODE_NONINTERLACED,
++};
++
++static struct fb_fix_screeninfo altfb_fix __initdata = {
++ .id = "Altera FB",
++ .type = FB_TYPE_PACKED_PIXELS,
++ .visual = FB_VISUAL_TRUECOLOR,
++ .line_length = (XRES * (BPX>>3)),
++ .xpanstep = 0,
++ .ypanstep = 0,
++ .ywrapstep = 0,
++ .accel = FB_ACCEL_NONE,
++};
++
++static int altfb_mmap(struct fb_info *info,
++ struct vm_area_struct *vma);
++
++static struct fb_ops altfb_ops = {
++ .fb_fillrect = cfb_fillrect,
++ .fb_copyarea = cfb_copyarea,
++ .fb_imageblit = cfb_imageblit,
++ .fb_mmap = altfb_mmap,
++};
++
++
++ /*
++ * Most drivers don't need their own mmap function
++ */
++
++static int altfb_mmap(struct fb_info *info,
++ struct vm_area_struct *vma)
++{
++ /* this is uClinux (no MMU) specific code */
++ vma->vm_flags |= (VM_RESERVED | VM_MAYSHARE);
++ vma->vm_start = (unsigned) videomemory;
++ return 0;
++}
++
++ /*
++ * Initialisation
++ */
++
++static void altfb_platform_release(struct device *device)
++{
++ // This is called when the reference count goes to zero.
++ dev_err(device, "This driver is broken, please bug the authors so they will fix it.\n");
++}
++
++static int __init altfb_probe(struct platform_device *dev)
++{
++ struct fb_info *info;
++ int retval = -ENOMEM;
++ dma_addr_t handle;
++
++ /*
++ * For real video cards we use ioremap.
++ */
++ if (!(videomemory = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(videomemorysize), &handle, GFP_KERNEL))) {
++ printk(KERN_ERR "altfb: unable to allocate screen memory\n");
++ return retval;
++ }
++ altfb_fix.smem_start = handle;
++ altfb_fix.smem_len = videomemorysize;
++
++ info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
++ if (!info)
++ goto err;
++
++ info->screen_base = (char __iomem *)videomemory;
++ info->fbops = &altfb_ops;
++ info->var = altfb_default;
++ info->fix = altfb_fix;
++ info->pseudo_palette = info->par;
++ info->par = NULL;
++ info->flags = FBINFO_FLAG_DEFAULT;
++
++ retval = fb_alloc_cmap(&info->cmap, 256, 0);
++ if (retval < 0)
++ goto err1;
++
++ retval = register_framebuffer(info);
++ if (retval < 0)
++ goto err2;
++ platform_set_drvdata(dev, info);
++
++ outl(0x0,vgabase+0); // Reset the VGA controller
++ outl(videomemory,vgabase+4); // Where our frame buffer starts
++ outl(videomemorysize,vgabase+8); // amount of memory needed
++ outl(0x1,vgabase+0); // Set the go bit
++
++ printk(KERN_INFO
++ "fb%d: Altera frame buffer device, using %ldK of video memory\n",
++ info->node, videomemorysize >> 10);
++ // printk("vga %08x, video %08x+%08x\n",vgabase,videomemory,videomemorysize);
++ return 0;
++err2:
++ fb_dealloc_cmap(&info->cmap);
++err1:
++ framebuffer_release(info);
++err:
++ dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, handle);
++ return retval;
++}
++
++static int altfb_remove(struct platform_device *dev)
++{
++ struct fb_info *info = platform_get_drvdata(dev);
++
++ if (info) {
++ unregister_framebuffer(info);
++ dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, altfb_fix.smem_start);
++ framebuffer_release(info);
++ }
++ return 0;
++}
++
++static struct platform_driver altfb_driver = {
++ .probe = altfb_probe,
++ .remove = altfb_remove,
++ .driver = {
++ .name = "altfb",
++ },
++};
++
++static struct platform_device altfb_device = {
++ .name = "altfb",
++ .id = 0,
++ .dev = {
++ .release = altfb_platform_release,
++ }
++};
++
++static int __init altfb_init(void)
++{
++ int ret = 0;
++
++ ret = platform_driver_register(&altfb_driver);
++
++ if (!ret) {
++ ret = platform_device_register(&altfb_device);
++ if (ret)
++ platform_driver_unregister(&altfb_driver);
++ }
++ return ret;
++}
++
++module_init(altfb_init);
++
++#ifdef MODULE
++static void __exit altfb_exit(void)
++{
++ platform_device_unregister(&altfb_device);
++ platform_driver_unregister(&altfb_driver);
++}
++
++module_exit(altfb_exit);
++
++MODULE_LICENSE("GPL");
++#endif /* MODULE */
+diff --git a/arch/nios2nommu/drivers/altps2.c b/arch/nios2nommu/drivers/altps2.c
+new file mode 100644
+index 0000000..4a6523c
+--- /dev/null
++++ b/arch/nios2nommu/drivers/altps2.c
+@@ -0,0 +1,193 @@
++/*
++ * altera DE2 PS/2
++ *
++ * linux/drivers/input/serio/sa1111ps2.c
++ *
++ * Copyright (C) 2002 Russell King
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License.
++ */
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/input.h>
++#include <linux/serio.h>
++#include <linux/errno.h>
++#include <linux/interrupt.h>
++#include <linux/ioport.h>
++#include <linux/delay.h>
++#include <linux/platform_device.h>
++#include <linux/slab.h>
++
++#include <asm/io.h>
++#include <asm/system.h>
++
++
++struct ps2if {
++ struct serio *io;
++ struct platform_device *dev;
++ unsigned base;
++ unsigned irq;
++};
++
++/*
++ * Read all bytes waiting in the PS2 port. There should be
++ * at the most one, but we loop for safety. If there was a
++ * framing error, we have to manually clear the status.
++ */
++static irqreturn_t ps2_rxint(int irq, void *dev_id)
++{
++ struct ps2if *ps2if = dev_id;
++ unsigned int status;
++ int handled = IRQ_NONE;
++
++ while ((status = inl(ps2if->base)) & 0xffff0000) {
++ serio_interrupt(ps2if->io, status & 0xff, 0);
++ handled = IRQ_HANDLED;
++ }
++ return handled;
++}
++
++/*
++ * Write a byte to the PS2 port. We have to wait for the
++ * port to indicate that the transmitter is empty.
++ */
++static int ps2_write(struct serio *io, unsigned char val)
++{
++ struct ps2if *ps2if = io->port_data;
++ outl(val,ps2if->base);
++ // should check command send error
++ if (inl(ps2if->base+4) & (1<<10))
++ {
++ // printk("ps2 write error %02x\n",val);
++ }
++ return 0;
++}
++
++static int ps2_open(struct serio *io)
++{
++ struct ps2if *ps2if = io->port_data;
++ int ret;
++
++ ret = request_irq(ps2if->irq, ps2_rxint, 0,
++ "altps2", ps2if);
++ if (ret) {
++ printk(KERN_ERR "altps2: could not allocate IRQ%d: %d\n",
++ ps2if->irq, ret);
++ return ret;
++ }
++ outl(1,ps2if->base+4); // enable rx irq
++ return 0;
++}
++
++static void ps2_close(struct serio *io)
++{
++ struct ps2if *ps2if = io->port_data;
++ outl(0,ps2if->base); // disable rx irq
++ free_irq(ps2if->irq, ps2if);
++}
++
++/*
++ * Add one device to this driver.
++ */
++static int ps2_probe(struct platform_device *dev)
++{
++ struct ps2if *ps2if;
++ struct serio *serio;
++ unsigned int status;
++ int ret;
++
++ ps2if = kmalloc(sizeof(struct ps2if), GFP_KERNEL);
++ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
++ if (!ps2if || !serio) {
++ ret = -ENOMEM;
++ goto free;
++ }
++
++ memset(ps2if, 0, sizeof(struct ps2if));
++ memset(serio, 0, sizeof(struct serio));
++
++ serio->id.type = SERIO_8042;
++ serio->write = ps2_write;
++ serio->open = ps2_open;
++ serio->close = ps2_close;
++ strlcpy(serio->name, dev->dev.bus_id, sizeof(serio->name));
++ strlcpy(serio->phys, dev->dev.bus_id, sizeof(serio->phys));
++ serio->port_data = ps2if;
++ serio->dev.parent = &dev->dev;
++ ps2if->io = serio;
++ ps2if->dev = dev;
++ platform_set_drvdata(dev, ps2if);
++
++ /*
++ * Request the physical region for this PS2 port.
++ */
++ if (dev->num_resources < 2) {
++ ret = -ENODEV;
++ goto out;
++ }
++ if (!request_mem_region(dev->resource[0].start,
++ 4,
++ "altps2")) {
++ ret = -EBUSY;
++ goto free;
++ }
++ ps2if->base = dev->resource[0].start;
++ ps2if->irq = dev->resource[1].start;
++ printk("altps2 : base %08x irq %d\n",ps2if->base,ps2if->irq);
++ // clear fifo
++ while ((status = inl(ps2if->base)) & 0xffff0000) {
++ }
++
++ serio_register_port(ps2if->io);
++ return 0;
++
++ out:
++ release_mem_region(dev->resource[0].start,4);
++ free:
++ platform_set_drvdata(dev, NULL);
++ kfree(ps2if);
++ kfree(serio);
++ return ret;
++}
++
++/*
++ * Remove one device from this driver.
++ */
++static int ps2_remove(struct platform_device *dev)
++{
++ struct ps2if *ps2if = platform_get_drvdata(dev);
++
++ platform_set_drvdata(dev, NULL);
++ serio_unregister_port(ps2if->io);
++ release_mem_region(dev->resource[0].start,4);
++
++ kfree(ps2if);
++
++ return 0;
++}
++
++/*
++ * Our device driver structure
++ */
++static struct platform_driver ps2_driver = {
++ .probe = ps2_probe,
++ .remove = ps2_remove,
++ .driver = {
++ .name = "altps2",
++ },
++};
++
++static int __init ps2_init(void)
++{
++ return platform_driver_register(&ps2_driver);
++}
++
++static void __exit ps2_exit(void)
++{
++ platform_driver_unregister(&ps2_driver);
++}
++
++module_init(ps2_init);
++module_exit(ps2_exit);
+diff --git a/arch/nios2nommu/drivers/i2c-gpio.c b/arch/nios2nommu/drivers/i2c-gpio.c
+new file mode 100644
+index 0000000..3f5e51a
+--- /dev/null
++++ b/arch/nios2nommu/drivers/i2c-gpio.c
+@@ -0,0 +1,166 @@
++/*
++ * drivers/i2c/busses/i2c-gpio.c for Nios2
++ *
++ * drivers/i2c/busses/i2c-ixp2000.c
++ *
++ * I2C adapter for IXP2000 systems using GPIOs for I2C bus
++ *
++ * Author: Deepak Saxena <dsaxena@plexity.net>
++ * Based on IXDP2400 code by: Naeem M. Afzal <naeem.m.afzal@intel.com>
++ * Made generic by: Jeff Daly <jeffrey.daly@intel.com>
++ *
++ * Copyright (c) 2003-2004 MontaVista Software Inc.
++ *
++ * This file is licensed under the terms of the GNU General Public
++ * License version 2. This program is licensed "as is" without any
++ * warranty of any kind, whether express or implied.
++ *
++ * From Jeff Daly:
++ *
++ * I2C adapter driver for Intel IXDP2xxx platforms. This should work for any
++ * IXP2000 platform if it uses the HW GPIO in the same manner. Basically,
++ * SDA and SCL GPIOs have external pullups. Setting the respective GPIO to
++ * an input will make the signal a '1' via the pullup. Setting them to
++ * outputs will pull them down.
++ *
++ * The GPIOs are open drain signals and are used as configuration strap inputs
++ * during power-up so there's generally a buffer on the board that needs to be
++ * 'enabled' to drive the GPIOs.
++ */
++
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/platform_device.h>
++#include <linux/module.h>
++#include <linux/i2c.h>
++#include <linux/i2c-algo-bit.h>
++#include <linux/i2c-id.h>
++
++#include <asm/io.h>
++#include <asm/gpio.h>
++
++static inline int gpio_scl_pin(void *data)
++{
++ return ((struct gpio_i2c_pins*)data)->scl_pin;
++}
++
++static inline int gpio_sda_pin(void *data)
++{
++ return ((struct gpio_i2c_pins*)data)->sda_pin;
++}
++
++
++static void gpio_bit_setscl(void *data, int val)
++{
++ int i = 5000;
++
++ if (val) {
++ outl(3,gpio_scl_pin(data));
++ while(!(inl(gpio_scl_pin(data)) & 1) && i--);
++ } else {
++ outl(2,gpio_scl_pin(data));
++ }
++}
++
++static void gpio_bit_setsda(void *data, int val)
++{
++ if (val) {
++ outl(1,gpio_sda_pin(data));
++ } else {
++ outl(0,gpio_sda_pin(data));
++ }
++}
++
++static int gpio_bit_getscl(void *data)
++{
++ return inl(gpio_scl_pin(data)) & 1;
++}
++
++static int gpio_bit_getsda(void *data)
++{
++ return inl(gpio_sda_pin(data)) & 1;
++}
++
++struct gpio_i2c_data {
++ struct gpio_i2c_pins *gpio_pins;
++ struct i2c_adapter adapter;
++ struct i2c_algo_bit_data algo_data;
++};
++
++static int gpio_i2c_remove(struct platform_device *plat_dev)
++{
++ struct gpio_i2c_data *drv_data = platform_get_drvdata(plat_dev);
++
++ platform_set_drvdata(plat_dev, NULL);
++
++ i2c_del_adapter(&drv_data->adapter);
++
++ kfree(drv_data);
++
++ return 0;
++}
++
++static int gpio_i2c_probe(struct platform_device *plat_dev)
++{
++ int err;
++ struct gpio_i2c_pins *gpio = plat_dev->dev.platform_data;
++ struct gpio_i2c_data *drv_data =
++ kzalloc(sizeof(struct gpio_i2c_data), GFP_KERNEL);
++
++ if (!drv_data)
++ return -ENOMEM;
++ drv_data->gpio_pins = gpio;
++
++ drv_data->algo_data.data = gpio;
++ drv_data->algo_data.setsda = gpio_bit_setsda;
++ drv_data->algo_data.setscl = gpio_bit_setscl;
++ drv_data->algo_data.getsda = gpio_bit_getsda;
++ drv_data->algo_data.getscl = gpio_bit_getscl;
++ drv_data->algo_data.udelay = 6;
++ drv_data->algo_data.timeout = 100;
++
++ drv_data->adapter.id = I2C_HW_B_IXP2000, // borrowed,
++ strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
++ I2C_NAME_SIZE);
++ drv_data->adapter.algo_data = &drv_data->algo_data,
++
++ drv_data->adapter.dev.parent = &plat_dev->dev;
++ drv_data->adapter.class = I2C_CLASS_ALL;
++
++ outl(1,gpio->sda_pin);
++ outl(1,gpio->scl_pin);
++
++ if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) {
++ dev_err(&plat_dev->dev, "Could not install, error %d\n", err);
++ kfree(drv_data);
++ return err;
++ }
++
++ platform_set_drvdata(plat_dev, drv_data);
++ printk("i2c-gpio driver at %08x\n",gpio->sda_pin);
++
++ return 0;
++}
++
++static struct platform_driver gpio_i2c_driver = {
++ .probe = gpio_i2c_probe,
++ .remove = gpio_i2c_remove,
++ .driver = {
++ .name = "GPIO-I2C",
++ .owner = THIS_MODULE,
++ },
++};
++
++static int __init gpio_i2c_init(void)
++{
++ return platform_driver_register(&gpio_i2c_driver);
++}
++
++static void __exit gpio_i2c_exit(void)
++{
++ platform_driver_unregister(&gpio_i2c_driver);
++}
++
++module_init(gpio_i2c_init);
++module_exit(gpio_i2c_exit);
++
+diff --git a/arch/nios2nommu/drivers/pci/Kconfig b/arch/nios2nommu/drivers/pci/Kconfig
+new file mode 100644
+index 0000000..6c3b175
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/Kconfig
+@@ -0,0 +1,4 @@
++config PCI_ALTPCI
++ bool "Altera PCI host bridge"
++ select PCI
++ default n
+diff --git a/arch/nios2nommu/drivers/pci/Makefile b/arch/nios2nommu/drivers/pci/Makefile
+new file mode 100644
+index 0000000..b027e1e
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/Makefile
+@@ -0,0 +1,6 @@
++#
++# Makefile for the PCI specific kernel interface routines under Linux.
++#
++
++obj-y += pci.o
++obj-$(CONFIG_PCI_ALTPCI) += altpci.o setup-irq.o pci-auto.o
+diff --git a/arch/nios2nommu/drivers/pci/altpci.c b/arch/nios2nommu/drivers/pci/altpci.c
+new file mode 100644
+index 0000000..85959ea
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/altpci.c
+@@ -0,0 +1,204 @@
++/* arch/sh/kernel/pci.c
++ * $Id: altpci.c,v 1.1 2006/07/05 06:23:17 gerg Exp $
++ *
++ * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
++ *
++ *
++ * These functions are collected here to reduce duplication of common
++ * code amongst the many platform-specific PCI support code files.
++ *
++ * These routines require the following board-specific routines:
++ * void pcibios_fixup_irqs();
++ *
++ * See include/asm-sh/pci.h for more information.
++ */
++
++#include <linux/kernel.h>
++#include <linux/pci.h>
++#include <linux/init.h>
++
++/*
++ * Direct access to PCI hardware...
++ */
++#define pcicfg_space (na_pci_compiler_0_PCI_Bus_Access) // avalon space
++#define pciio (pcicfg_space+0x100000) // pci io device base in avalon space
++#define pcimm (pcicfg_space+0x200000) // pci mem device base in avalon space
++ // idsel of ad11=dev0,ad12=dev1 , using type 0 config request
++#define pcicfg(dev,fun,reg) (pcicfg_space | ((dev)<<11) | ((fun)<<8) | (reg)) // cfg space
++
++// FIX ME for your board, dram device for external pci masters access
++static int __init alt_pci_init(void)
++{
++ unsigned dev,fun;
++ // setup dram bar
++ dev=0; fun=0;
++ outl(nasys_program_mem,pcicfg(dev,fun,0x10)); // mem space
++ outw(0x0006,pcicfg(dev,fun,0x04)); // enable master, mem space
++ return 0;
++}
++
++subsys_initcall(alt_pci_init);
++
++#define PCICFG(bus, devfn, where) (pcicfg_space | (bus->number << 16) | (devfn << 8) | (where & ~3))
++#define ALT_PCI_IO_BASE (pciio)
++#define ALT_PCI_IO_SIZE 0x100000
++#define ALT_PCI_MEMORY_BASE (pcimm)
++#define ALT_PCI_MEM_SIZE 0x100000
++
++/*
++ * Functions for accessing PCI configuration space with type 1 accesses
++ */
++
++// FIX ME for your board, number of pci bus, and number of devices
++static inline int pci_range_ck(struct pci_bus *bus, unsigned int devfn)
++{
++ if (bus->number > 0 || PCI_SLOT(devfn) == 0 || PCI_SLOT(devfn) > 2)
++ return -1;
++
++ return 0;
++}
++
++static int alt_pci_read(struct pci_bus *bus, unsigned int devfn,
++ int where, int size, u32 *val)
++{
++ u32 data;
++
++ if (pci_range_ck(bus, devfn))
++ return PCIBIOS_DEVICE_NOT_FOUND;
++
++ // local_irq_save(flags);
++ data = inl(PCICFG(bus, devfn, where));
++ // local_irq_restore(flags);
++
++ switch (size) {
++ case 1:
++ *val = (data >> ((where & 3) << 3)) & 0xff;
++ break;
++ case 2:
++ *val = (data >> ((where & 2) << 3)) & 0xffff;
++ break;
++ case 4:
++ *val = data;
++ break;
++ default:
++ return PCIBIOS_FUNC_NOT_SUPPORTED;
++ }
++
++ return PCIBIOS_SUCCESSFUL;
++}
++
++/*
++ * we'll do a read,
++ * mask,write operation.
++ * We'll allow an odd byte offset, though it should be illegal.
++ */
++static int alt_pci_write(struct pci_bus *bus, unsigned int devfn,
++ int where, int size, u32 val)
++{
++ int shift;
++ u32 data;
++
++ if (pci_range_ck(bus, devfn))
++ return PCIBIOS_DEVICE_NOT_FOUND;
++
++ // local_irq_save(flags);
++ data = inl(PCICFG(bus, devfn, where));
++ // local_irq_restore(flags);
++
++ switch (size) {
++ case 1:
++ shift = (where & 3) << 3;
++ data &= ~(0xff << shift);
++ data |= ((val & 0xff) << shift);
++ break;
++ case 2:
++ shift = (where & 2) << 3;
++ data &= ~(0xffff << shift);
++ data |= ((val & 0xffff) << shift);
++ break;
++ case 4:
++ data = val;
++ break;
++ default:
++ return PCIBIOS_FUNC_NOT_SUPPORTED;
++ }
++
++ outl(data, PCICFG(bus, devfn, where));
++
++ return PCIBIOS_SUCCESSFUL;
++}
++
++struct pci_ops alt_pci_ops = {
++ .read = alt_pci_read,
++ .write = alt_pci_write,
++};
++
++static struct resource alt_io_resource = {
++ .name = "ALTPCI IO",
++ .start = ALT_PCI_IO_BASE,
++ .end = ALT_PCI_IO_BASE + ALT_PCI_IO_SIZE - 1,
++ .flags = IORESOURCE_IO
++};
++
++static struct resource alt_mem_resource = {
++ .name = "ALTPCI mem",
++ .start = ALT_PCI_MEMORY_BASE,
++ .end = ALT_PCI_MEMORY_BASE + ALT_PCI_MEM_SIZE - 1,
++ .flags = IORESOURCE_MEM
++};
++
++extern struct pci_ops alt_pci_ops;
++
++struct pci_channel board_pci_channels[] = {
++ { &alt_pci_ops, &alt_io_resource, &alt_mem_resource, 0, 0xff },
++ { NULL, NULL, NULL, 0, 0 },
++};
++
++char *pcibios_setup(char *option)
++{
++ /* Nothing for us to handle. */
++ return(option);
++}
++
++void pcibios_fixup_bus(struct pci_bus *b)
++{
++}
++
++/*
++ * IRQ functions
++ */
++static u8 __init altpci_no_swizzle(struct pci_dev *dev, u8 *pin)
++{
++ /* no swizzling */
++ return PCI_SLOT(dev->devfn);
++}
++
++// FIX ME for your board, nios2 irqn mapping
++int __init pcibios_map_platform_irq(u8 slot, u8 pin)
++{
++ int irq = na_irqn_0_irq + ((slot-1)*4) + (pin-1);
++ // printk("map slot %d pin %d irq %d\n",slot,pin,irq);
++ return irq;
++}
++
++static int altpci_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
++{
++ int irq = -1;
++
++ /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
++ irq = pcibios_map_platform_irq(slot,pin);
++ if( irq < 0 ) {
++ // printk("PCI: Error mapping IRQ on device %s\n", pci_name(dev));
++ return irq;
++ }
++
++ // printk("Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
++
++ return irq;
++}
++
++void __init pcibios_fixup_irqs(void)
++{
++ pci_fixup_irqs(altpci_no_swizzle, altpci_pci_lookup_irq);
++}
++
+diff --git a/arch/nios2nommu/drivers/pci/pci-auto.c b/arch/nios2nommu/drivers/pci/pci-auto.c
+new file mode 100644
+index 0000000..e1cdfdc
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/pci-auto.c
+@@ -0,0 +1,559 @@
++/*
++ * PCI autoconfiguration library
++ *
++ * Author: Matt Porter <mporter@mvista.com>
++ *
++ * Copyright 2000, 2001 MontaVista Software Inc.
++ * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
++ * Copyright 2003 Paul Mundt <lethal@linux-sh.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License as published by the
++ * Free Software Foundation; either version 2 of the License, or (at your
++ * option) any later version.
++ */
++
++/*
++ * Modified for MIPS by Jun Sun, jsun@mvista.com
++ *
++ * . Simplify the interface between pci_auto and the rest: a single function.
++ * . Assign resources from low address to upper address.
++ * . change most int to u32.
++ *
++ * Further modified to include it as mips generic code, ppopov@mvista.com.
++ *
++ * 2001-10-26 Bradley D. LaRonde <brad@ltc.com>
++ * - Add a top_bus argument to the "early config" functions so that
++ * they can set a fake parent bus pointer to convince the underlying
++ * pci ops to use type 1 configuration for sub busses.
++ * - Set bridge base and limit registers correctly.
++ * - Align io and memory base properly before and after bridge setup.
++ * - Don't fall through to pci_setup_bars for bridge.
++ * - Reformat the debug output to look more like lspci's output.
++ *
++ * Cloned for SuperH by M. R. Brown, mrbrown@0xd6.org
++ *
++ * 2003-08-05 Paul Mundt <lethal@linux-sh.org>
++ * - Don't update the BAR values on systems that already have valid addresses
++ * and don't want these updated for whatever reason, by way of a new config
++ * option check. However, we still read in the old BAR values so that they
++ * can still be reported through the debug output.
++ */
++
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/types.h>
++#include <linux/pci.h>
++
++#undef DEBUG
++#define DEBUG // you can remove debug message here
++
++#ifdef DEBUG
++#define DBG(x...) printk(x)
++#else
++#define DBG(x...)
++#endif
++
++/*
++ * These functions are used early on before PCI scanning is done
++ * and all of the pci_dev and pci_bus structures have been created.
++ */
++static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
++ int top_bus, int busnr, int devfn)
++{
++ static struct pci_dev dev;
++ static struct pci_bus bus;
++
++ dev.bus = &bus;
++ dev.sysdata = hose;
++ dev.devfn = devfn;
++ bus.number = busnr;
++ bus.ops = hose->pci_ops;
++
++ if(busnr != top_bus)
++ /* Fake a parent bus structure. */
++ bus.parent = &bus;
++ else
++ bus.parent = NULL;
++
++ return &dev;
++}
++
++#define EARLY_PCI_OP(rw, size, type) \
++int early_##rw##_config_##size(struct pci_channel *hose, \
++ int top_bus, int bus, int devfn, int offset, type value) \
++{ \
++ return pci_##rw##_config_##size( \
++ fake_pci_dev(hose, top_bus, bus, devfn), \
++ offset, value); \
++}
++
++EARLY_PCI_OP(read, byte, u8 *)
++EARLY_PCI_OP(read, word, u16 *)
++EARLY_PCI_OP(read, dword, u32 *)
++EARLY_PCI_OP(write, byte, u8)
++EARLY_PCI_OP(write, word, u16)
++EARLY_PCI_OP(write, dword, u32)
++
++static struct resource *io_resource_inuse;
++static struct resource *mem_resource_inuse;
++
++static u32 pciauto_lower_iospc;
++static u32 pciauto_upper_iospc;
++
++static u32 pciauto_lower_memspc;
++static u32 pciauto_upper_memspc;
++
++static void __init
++pciauto_setup_bars(struct pci_channel *hose,
++ int top_bus,
++ int current_bus,
++ int pci_devfn,
++ int bar_limit)
++{
++ u32 bar_response, bar_size, bar_value;
++ u32 bar, addr_mask, bar_nr = 0;
++ u32 * upper_limit;
++ u32 * lower_limit;
++ int found_mem64 = 0;
++
++ for (bar = PCI_BASE_ADDRESS_0; bar <= bar_limit; bar+=4) {
++#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
++ u32 bar_addr;
++
++ /* Read the old BAR value */
++ early_read_config_dword(hose, top_bus,
++ current_bus,
++ pci_devfn,
++ bar,
++ &bar_addr);
++#endif
++
++ /* Tickle the BAR and get the response */
++ early_write_config_dword(hose, top_bus,
++ current_bus,
++ pci_devfn,
++ bar,
++ 0xffffffff);
++
++ early_read_config_dword(hose, top_bus,
++ current_bus,
++ pci_devfn,
++ bar,
++ &bar_response);
++
++#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
++ /*
++ * Write the old BAR value back out, only update the BAR
++ * if we implicitly want resources to be updated, which
++ * is done by the generic code further down. -- PFM.
++ */
++ early_write_config_dword(hose, top_bus,
++ current_bus,
++ pci_devfn,
++ bar,
++ bar_addr);
++#endif
++
++ /* If BAR is not implemented go to the next BAR */
++ if (!bar_response)
++ continue;
++
++ /*
++ * Workaround for a BAR that doesn't use its upper word,
++ * like the ALi 1535D+ PCI DC-97 Controller Modem (M5457).
++ * bdl <brad@ltc.com>
++ */
++ if (!(bar_response & 0xffff0000))
++ bar_response |= 0xffff0000;
++
++retry:
++ /* Check the BAR type and set our address mask */
++ if (bar_response & PCI_BASE_ADDRESS_SPACE) {
++ addr_mask = PCI_BASE_ADDRESS_IO_MASK;
++ upper_limit = &pciauto_upper_iospc;
++ lower_limit = &pciauto_lower_iospc;
++ DBG(" I/O");
++ } else {
++ if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
++ PCI_BASE_ADDRESS_MEM_TYPE_64)
++ found_mem64 = 1;
++
++ addr_mask = PCI_BASE_ADDRESS_MEM_MASK;
++ upper_limit = &pciauto_upper_memspc;
++ lower_limit = &pciauto_lower_memspc;
++ DBG(" Mem");
++ }
++
++
++ /* Calculate requested size */
++ bar_size = ~(bar_response & addr_mask) + 1;
++
++ /* Allocate a base address */
++ bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
++
++ if ((bar_value + bar_size) > *upper_limit) {
++ if (bar_response & PCI_BASE_ADDRESS_SPACE) {
++ if (io_resource_inuse->child) {
++ io_resource_inuse =
++ io_resource_inuse->child;
++ pciauto_lower_iospc =
++ io_resource_inuse->start;
++ pciauto_upper_iospc =
++ io_resource_inuse->end + 1;
++ goto retry;
++ }
++
++ } else {
++ if (mem_resource_inuse->child) {
++ mem_resource_inuse =
++ mem_resource_inuse->child;
++ pciauto_lower_memspc =
++ mem_resource_inuse->start;
++ pciauto_upper_memspc =
++ mem_resource_inuse->end + 1;
++ goto retry;
++ }
++ }
++ DBG(" unavailable -- skipping, value %x size %x\n",
++ bar_value, bar_size);
++ continue;
++ }
++
++#if 1
++ /* Write it out and update our limit */
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ bar, bar_value);
++#endif
++
++ *lower_limit = bar_value + bar_size;
++
++ /*
++ * If we are a 64-bit decoder then increment to the
++ * upper 32 bits of the bar and force it to locate
++ * in the lower 4GB of memory.
++ */
++ if (found_mem64) {
++ bar += 4;
++ early_write_config_dword(hose, top_bus,
++ current_bus,
++ pci_devfn,
++ bar,
++ 0x00000000);
++ }
++
++ DBG(" at 0x%.8x [size=0x%x]\n", bar_value, bar_size);
++
++ bar_nr++;
++ }
++
++}
++
++static void __init
++pciauto_prescan_setup_bridge(struct pci_channel *hose,
++ int top_bus,
++ int current_bus,
++ int pci_devfn,
++ int sub_bus)
++{
++ /* Configure bus number registers */
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_PRIMARY_BUS, current_bus);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SECONDARY_BUS, sub_bus + 1);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SUBORDINATE_BUS, 0xff);
++
++ /* Align memory and I/O to 1MB and 4KB boundaries. */
++ pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
++ & ~(0x100000 - 1);
++ pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
++ & ~(0x1000 - 1);
++
++ /* Set base (lower limit) of address range behind bridge. */
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_MEMORY_BASE, pciauto_lower_memspc >> 16);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_IO_BASE, (pciauto_lower_iospc & 0x0000f000) >> 8);
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_IO_BASE_UPPER16, pciauto_lower_iospc >> 16);
++
++ /* We don't support prefetchable memory for now, so disable */
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_PREF_MEMORY_BASE, 0);
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_PREF_MEMORY_LIMIT, 0);
++}
++
++static void __init
++pciauto_postscan_setup_bridge(struct pci_channel *hose,
++ int top_bus,
++ int current_bus,
++ int pci_devfn,
++ int sub_bus)
++{
++ u32 temp;
++
++ /*
++ * [jsun] we always bump up baselines a little, so that if there
++ * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
++ * spaces.
++ */
++ pciauto_lower_memspc += 1;
++ pciauto_lower_iospc += 1;
++
++ /* Configure bus number registers */
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SUBORDINATE_BUS, sub_bus);
++
++ /* Set upper limit of address range behind bridge. */
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_MEMORY_LIMIT, pciauto_lower_memspc >> 16);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_IO_LIMIT, (pciauto_lower_iospc & 0x0000f000) >> 8);
++ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_IO_LIMIT_UPPER16, pciauto_lower_iospc >> 16);
++
++ /* Align memory and I/O to 1MB and 4KB boundaries. */
++ pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
++ & ~(0x100000 - 1);
++ pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
++ & ~(0x1000 - 1);
++
++ /* Enable memory and I/O accesses, enable bus master */
++ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, &temp);
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
++ | PCI_COMMAND_MASTER);
++}
++
++static void __init
++pciauto_prescan_setup_cardbus_bridge(struct pci_channel *hose,
++ int top_bus,
++ int current_bus,
++ int pci_devfn,
++ int sub_bus)
++{
++ /* Configure bus number registers */
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_PRIMARY_BUS, current_bus);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SECONDARY_BUS, sub_bus + 1);
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SUBORDINATE_BUS, 0xff);
++
++ /* Align memory and I/O to 4KB and 4 byte boundaries. */
++ pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
++ & ~(0x1000 - 1);
++ pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
++ & ~(0x4 - 1);
++
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_CB_MEMORY_BASE_0, pciauto_lower_memspc);
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_CB_IO_BASE_0, pciauto_lower_iospc);
++}
++
++static void __init
++pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
++ int top_bus,
++ int current_bus,
++ int pci_devfn,
++ int sub_bus)
++{
++ u32 temp;
++
++#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
++ /*
++ * [jsun] we always bump up baselines a little, so that if there
++ * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
++ * spaces.
++ */
++ pciauto_lower_memspc += 1;
++ pciauto_lower_iospc += 1;
++#endif
++
++ /*
++ * Configure subordinate bus number. The PCI subsystem
++ * bus scan will renumber buses (reserving three additional
++ * for this PCI<->CardBus bridge for the case where a CardBus
++ * adapter contains a P2P or CB2CB bridge.
++ */
++
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_SUBORDINATE_BUS, sub_bus);
++
++ /*
++ * Reserve an additional 4MB for mem space and 16KB for
++ * I/O space. This should cover any additional space
++ * requirement of unusual CardBus devices with
++ * additional bridges that can consume more address space.
++ *
++ * Although pcmcia-cs currently will reprogram bridge
++ * windows, the goal is to add an option to leave them
++ * alone and use the bridge window ranges as the regions
++ * that are searched for free resources upon hot-insertion
++ * of a device. This will allow a PCI<->CardBus bridge
++ * configured by this routine to happily live behind a
++ * P2P bridge in a system.
++ */
++#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
++ pciauto_lower_memspc += 0x00400000;
++ pciauto_lower_iospc += 0x00004000;
++#endif
++
++ /* Align memory and I/O to 4KB and 4 byte boundaries. */
++ pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
++ & ~(0x1000 - 1);
++ pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
++ & ~(0x4 - 1);
++ /* Set up memory and I/O filter limits, assume 32-bit I/O space */
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_CB_MEMORY_LIMIT_0, pciauto_lower_memspc - 1);
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_CB_IO_LIMIT_0, pciauto_lower_iospc - 1);
++
++ /* Enable memory and I/O accesses, enable bus master */
++ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, &temp);
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
++ PCI_COMMAND_MASTER);
++}
++
++#define PCIAUTO_IDE_MODE_MASK 0x05
++
++static int __init
++pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
++{
++ int sub_bus;
++ u32 pci_devfn, pci_class, cmdstat, found_multi=0;
++ unsigned short vid, did;
++ unsigned char header_type;
++ int devfn_start = 0;
++ int devfn_stop = 0xff;
++
++ sub_bus = current_bus;
++
++ if (hose->first_devfn)
++ devfn_start = hose->first_devfn;
++ if (hose->last_devfn)
++ devfn_stop = hose->last_devfn;
++
++ for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
++
++ if (PCI_FUNC(pci_devfn) && !found_multi)
++ continue;
++
++ early_read_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_VENDOR_ID, &vid);
++
++ if (vid == 0xffff) continue;
++
++ early_read_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_HEADER_TYPE, &header_type);
++
++ if (!PCI_FUNC(pci_devfn))
++ found_multi = header_type & 0x80;
++
++ early_read_config_word(hose, top_bus, current_bus, pci_devfn,
++ PCI_DEVICE_ID, &did);
++
++ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_CLASS_REVISION, &pci_class);
++
++ if ((pci_class & 0xff000000)==0) continue; // devices before pci 2.0
++
++ DBG("%.2x:%.2x.%x Class %.4x: %.4x:%.4x",
++ current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn),
++ pci_class >> 16, vid, did);
++ if (pci_class & 0xff)
++ DBG(" (rev %.2x)", pci_class & 0xff);
++ DBG("\n");
++
++ if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
++ DBG(" Bridge: primary=%.2x, secondary=%.2x\n",
++ current_bus, sub_bus + 1);
++#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
++ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_1);
++#endif
++ pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
++ pci_devfn, sub_bus);
++ DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
++ sub_bus + 1,
++ pciauto_lower_iospc, pciauto_lower_memspc);
++ sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
++ DBG("Back to bus %.2x\n", current_bus);
++ pciauto_postscan_setup_bridge(hose, top_bus, current_bus,
++ pci_devfn, sub_bus);
++ continue;
++ } else if ((pci_class >> 16) == PCI_CLASS_BRIDGE_CARDBUS) {
++ DBG(" CARDBUS Bridge: primary=%.2x, secondary=%.2x\n",
++ current_bus, sub_bus + 1);
++ DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
++ /* Place CardBus Socket/ExCA registers */
++ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_0);
++
++ pciauto_prescan_setup_cardbus_bridge(hose, top_bus,
++ current_bus, pci_devfn, sub_bus);
++
++ DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
++ sub_bus + 1,
++ pciauto_lower_iospc, pciauto_lower_memspc);
++ sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
++ DBG("Back to bus %.2x, sub_bus is %x\n", current_bus, sub_bus);
++ pciauto_postscan_setup_cardbus_bridge(hose, top_bus,
++ current_bus, pci_devfn, sub_bus);
++ continue;
++ } else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
++
++ unsigned char prg_iface;
++
++ early_read_config_byte(hose, top_bus, current_bus,
++ pci_devfn, PCI_CLASS_PROG, &prg_iface);
++ if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
++ DBG("Skipping legacy mode IDE controller\n");
++ continue;
++ }
++ }
++
++ /*
++ * Found a peripheral, enable some standard
++ * settings
++ */
++ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, &cmdstat);
++ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
++ PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
++ PCI_COMMAND_MEMORY |
++ PCI_COMMAND_MASTER);
++#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
++ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
++ PCI_LATENCY_TIMER, 0x80);
++#endif
++
++ /* Allocate PCI I/O and/or memory space */
++ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_5);
++ }
++ return sub_bus;
++}
++
++int __init
++pciauto_assign_resources(int busno, struct pci_channel *hose)
++{
++ /* setup resource limits */
++ io_resource_inuse = hose->io_resource;
++ mem_resource_inuse = hose->mem_resource;
++
++ pciauto_lower_iospc = io_resource_inuse->start;
++ pciauto_upper_iospc = io_resource_inuse->end + 1;
++ pciauto_lower_memspc = mem_resource_inuse->start;
++ pciauto_upper_memspc = mem_resource_inuse->end + 1;
++ DBG("Autoconfig PCI channel 0x%p\n", hose);
++ DBG("Scanning bus %.2x, I/O 0x%.8x:0x%.8x, Mem 0x%.8x:0x%.8x\n",
++ busno, pciauto_lower_iospc, pciauto_upper_iospc,
++ pciauto_lower_memspc, pciauto_upper_memspc);
++
++ return pciauto_bus_scan(hose, busno, busno);
++}
+diff --git a/arch/nios2nommu/drivers/pci/pci.c b/arch/nios2nommu/drivers/pci/pci.c
+new file mode 100644
+index 0000000..83436df
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/pci.c
+@@ -0,0 +1,151 @@
++/* arch/sh/kernel/pci.c
++ * $Id: pci.c,v 1.2 2007/01/25 01:26:48 gerg Exp $
++ *
++ * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
++ *
++ *
++ * These functions are collected here to reduce duplication of common
++ * code amongst the many platform-specific PCI support code files.
++ *
++ * These routines require the following board-specific routines:
++ * void pcibios_fixup_irqs();
++ *
++ * See include/asm-sh/pci.h for more information.
++ */
++
++#include <linux/kernel.h>
++#include <linux/pci.h>
++#include <linux/init.h>
++
++static int __init pcibios_init(void)
++{
++ struct pci_channel *p;
++ struct pci_bus *bus;
++ int busno;
++
++#if 1
++ /* assign resources */
++ busno = 0;
++ for (p = board_pci_channels; p->pci_ops != NULL; p++) {
++ busno = pciauto_assign_resources(busno, p) + 1;
++ }
++#endif
++
++ /* scan the buses */
++ busno = 0;
++ for (p= board_pci_channels; p->pci_ops != NULL; p++) {
++ bus = pci_scan_bus(busno, p->pci_ops, p);
++ busno = bus->subordinate+1;
++ }
++
++ /* board-specific fixups */
++ pcibios_fixup_irqs();
++
++ return 0;
++}
++
++subsys_initcall(pcibios_init);
++
++void
++pcibios_update_resource(struct pci_dev *dev, struct resource *root,
++ struct resource *res, int resource)
++{
++ u32 new, check;
++ int reg;
++
++ new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
++ if (resource < 6) {
++ reg = PCI_BASE_ADDRESS_0 + 4*resource;
++ } else if (resource == PCI_ROM_RESOURCE) {
++ res->flags |= IORESOURCE_ROM_ENABLE;
++ new |= PCI_ROM_ADDRESS_ENABLE;
++ reg = dev->rom_base_reg;
++ } else {
++ /* Somebody might have asked allocation of a non-standard resource */
++ return;
++ }
++
++ pci_write_config_dword(dev, reg, new);
++ pci_read_config_dword(dev, reg, &check);
++ if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
++ printk(KERN_ERR "PCI: Error while updating region "
++ "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
++ new, check);
++ }
++}
++
++/*
++ * We need to avoid collisions with `mirrored' VGA ports
++ * and other strange ISA hardware, so we always want the
++ * addresses to be allocated in the 0x000-0x0ff region
++ * modulo 0x400.
++ */
++void pcibios_align_resource(void *data, struct resource *res,
++ resource_size_t size, resource_size_t align)
++{
++ if (res->flags & IORESOURCE_IO) {
++ unsigned long start = res->start;
++
++ if (start & 0x300) {
++ start = (start + 0x3ff) & ~0x3ff;
++ res->start = start;
++ }
++ }
++}
++
++int pcibios_enable_device(struct pci_dev *dev, int mask)
++{
++ u16 cmd, old_cmd;
++ int idx;
++ struct resource *r;
++
++ pci_read_config_word(dev, PCI_COMMAND, &cmd);
++ old_cmd = cmd;
++ for(idx=0; idx<6; idx++) {
++ if (!(mask & (1 << idx)))
++ continue;
++ r = &dev->resource[idx];
++ if (!r->start && r->end) {
++ printk(KERN_ERR "PCI: Device %s not available because "
++ "of resource collisions\n", pci_name(dev));
++ return -EINVAL;
++ }
++ if (r->flags & IORESOURCE_IO)
++ cmd |= PCI_COMMAND_IO;
++ if (r->flags & IORESOURCE_MEM)
++ cmd |= PCI_COMMAND_MEMORY;
++ }
++ if (dev->resource[PCI_ROM_RESOURCE].start)
++ cmd |= PCI_COMMAND_MEMORY;
++ if (cmd != old_cmd) {
++ printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n",
++ pci_name(dev), old_cmd, cmd);
++ pci_write_config_word(dev, PCI_COMMAND, cmd);
++ }
++ return 0;
++}
++
++/*
++ * If we set up a device for bus mastering, we need to check and set
++ * the latency timer as it may not be properly set.
++ */
++unsigned int pcibios_max_latency = 255;
++
++void pcibios_set_master(struct pci_dev *dev)
++{
++ u8 lat;
++ pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
++ if (lat < 16)
++ lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
++ else if (lat > pcibios_max_latency)
++ lat = pcibios_max_latency;
++ else
++ return;
++ printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
++ pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
++}
++
++void __init pcibios_update_irq(struct pci_dev *dev, int irq)
++{
++ pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
++}
+diff --git a/arch/nios2nommu/drivers/pci/setup-irq.c b/arch/nios2nommu/drivers/pci/setup-irq.c
+new file mode 100644
+index 0000000..0fa8f98
+--- /dev/null
++++ b/arch/nios2nommu/drivers/pci/setup-irq.c
+@@ -0,0 +1 @@
++#include "../../../../drivers/pci/setup-irq.c"
+diff --git a/arch/nios2nommu/drivers/spi.c b/arch/nios2nommu/drivers/spi.c
+new file mode 100644
+index 0000000..72a2519
+--- /dev/null
++++ b/arch/nios2nommu/drivers/spi.c
+@@ -0,0 +1,315 @@
++#ifdef MODULE
++#include <linux/module.h>
++#include <linux/version.h>
++#else
++#define MOD_INC_USE_COUNT
++#define MOD_DEC_USE_COUNT
++#endif
++
++#include <linux/types.h>
++#include <linux/errno.h>
++#include <linux/kernel.h>
++#include <linux/fs.h>
++#include <linux/major.h>
++#include <linux/sched.h>
++#include <linux/slab.h>
++#include <linux/ioport.h>
++#include <linux/fcntl.h>
++#include <linux/unistd.h>
++#include <linux/init.h>
++
++
++#include <asm/io.h>
++#include <asm/segment.h>
++#include <asm/system.h>
++#include <asm/spi.h>
++
++#if !defined(SEEK_SET)
++#define SEEK_SET 0
++#endif
++
++
++static unsigned int spi_major = 60; /* a local major, can be overwritten */
++static int openflag = 0;
++static np_spi * const spi_ptr = na_spi;
++
++ /*******************************/
++ /* SPI data transfer routines. */
++ /*******************************/
++
++#define SPI_XMIT_READY np_spistatus_trdy_mask
++#define SPI_RECV_READY np_spistatus_rrdy_mask
++
++#define SPI_BUSYPOLL_TIMEOUT 1000
++
++// returns -1 if there is no data present, otherwise returns
++// the value
++inline int SPI_Recv_Byte(char *pdata )
++{
++ if (spi_ptr->np_spistatus & SPI_RECV_READY){
++ *pdata = spi_ptr->np_spirxdata & 0xff;
++ return 0;
++ }
++ return -1;
++}
++
++
++// Sends the 16 bit address+data
++inline int SPI_Send_Byte( unsigned char address, char data )
++{
++ u16 value = ((address & 0xFF) << 8) | (data & 0xFF);
++
++ if ( spi_ptr->np_spistatus & SPI_XMIT_READY ) {
++ spi_ptr->np_spitxdata = value;
++ return 0;
++ }
++
++ return -1;
++}
++
++
++
++ /*************************/
++ /* SPI Driver functions. */
++ /*************************/
++
++int spi_reset( void )
++{
++ // Nothing to do: The Nios does _not_
++ // support burst xfers. Chip Enables
++ // (Selects) are inactive after each xfer.
++ return 0;
++}
++
++
++/***************************************************/
++/* The SPI Write routine. The first 16 bits are */
++/* the device register, and the rest of the buffer */
++/* is data. */
++/***************************************************/
++
++ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
++{
++ int i;
++ unsigned char addr;
++ int timeout;
++ char temp;
++
++ if ( count < 3 )
++ return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
++
++ addr = buf[0]; /* chip register address. */
++ spi_ptr->np_spistatus=0;
++
++ for ( i = sizeof(u16); i<count; i++ )
++ {
++ timeout=SPI_BUSYPOLL_TIMEOUT;
++ while (SPI_Send_Byte(addr, buf[i])==-1)
++ {
++ if (--timeout==0)
++ {
++ printk("spi_write time out\n");
++ return i; /* return the number of bytes sent */
++ }
++ }
++ /* read the data */
++ timeout=SPI_BUSYPOLL_TIMEOUT;
++ while (SPI_Recv_Byte(&temp)==-1)
++ {
++ if (--timeout==0)
++ break;
++ }
++ }
++ return i;
++// unsigned char *temp; /* Our pointer to the buffer */
++// int i;
++// int addr;
++//
++// if ( count < 3 )
++// return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
++//
++// temp = (char *)buf;
++// addr = (int)*((u16 *)temp); /* chip register address. */
++// temp += sizeof(u16);
++//
++// for ( i = count - sizeof(u16); i; i--, temp++ )
++// *temp = (unsigned char)SPI_Transfer( addr, (int)*temp );
++//
++//
++// return count; /* we can always send all data */
++}
++
++//int spi_read( struct inode *inode, struct file *file, char *buf, int count )
++ssize_t spi_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
++{
++ int i;
++ unsigned char addr;
++ int timeout;
++ char temp;
++
++ if ( count < 3 )
++ return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
++
++ addr = buf[0]; /* chip register address. */
++ spi_ptr->np_spistatus=0;
++
++ /* empty the np_spirxdata register */
++ SPI_Recv_Byte(&temp);
++
++ for ( i = sizeof(u16); i<count; i++ )
++ {
++ /* send the address */
++ timeout=SPI_BUSYPOLL_TIMEOUT;
++ while (SPI_Send_Byte(addr, 0)==-1)
++ {
++ if (--timeout==0)
++ {
++ printk("spi_read write address time out\n");
++ return i;
++ }
++ }
++
++ /* read the data */
++ timeout=SPI_BUSYPOLL_TIMEOUT;
++ while (SPI_Recv_Byte(&buf[i])==-1)
++ {
++ if (--timeout==0)
++ {
++ printk("spi_read read data time out\n");
++ return i;
++ }
++ }
++#if 0
++ printk("spi_read time left %d\n", timeout);
++#endif
++ }
++ return i;
++}
++
++loff_t spi_lseek(struct file *filp, loff_t offset, int origin)
++{
++#if 0
++ int bit_count, i;
++#endif
++
++ if ( origin != SEEK_SET || offset != (offset & 0xFFFF) )
++ {
++ errno = -EINVAL;
++ return -1;
++ }
++
++#if 0
++ /****************************************/
++ /* Nios SPI implementation safeguard: */
++ /* It is possible to have more than */
++ /* one CS active at a time. Check that */
++ /* the given address is a power of two. */
++ /****************************************/
++ bit_count = 0;
++ for ( i = 0; i < sizeof(u16); i++ )
++ {
++ if ( (1 << i) & offset )
++ {
++ if ( ++bit_count > 1 )
++ {
++ errno = -EINVAL;
++ return -1;
++ }
++ }
++ }
++#endif
++ spi_ptr->np_spislaveselect = offset;
++ return 0;
++}
++
++int spi_open(struct inode *inode, struct file *filp)
++{
++ preempt_disable();
++ if (openflag) {
++ preempt_enable();
++ return -EBUSY;
++ }
++
++ MOD_INC_USE_COUNT;
++ openflag = 1;
++ preempt_enable();
++
++ return 0;
++}
++
++int spi_release(struct inode *inode, struct file *filp)
++{
++ openflag = 0;
++ MOD_DEC_USE_COUNT;
++ return 0;
++}
++
++
++/* static struct file_operations spi_fops */
++
++static struct file_operations spi_fops = {
++ llseek: spi_lseek, /* Set chip-select line. The offset is used as an address. */
++ read: spi_read,
++ write: spi_write,
++ open: spi_open,
++ release: spi_release,
++};
++
++
++int register_NIOS_SPI( void )
++{
++ int result = register_chrdev( spi_major, "spi", &spi_fops );
++ if ( result < 0 )
++ {
++ printk( "SPI: unable to get major %d for SPI bus \n", spi_major );
++ return result;
++ }/*end-if*/
++
++ if ( spi_major == 0 )
++ spi_major = result; /* here we got our major dynamically */
++
++ /* reserve our port, but check first if free */
++ if ( check_region( (unsigned int)na_spi, sizeof(np_spi) ) )
++ {
++ printk( "SPI: port at adr 0x%08x already occupied\n", (unsigned int)na_spi );
++ unregister_chrdev( spi_major, "spi" );
++
++ return result;
++ }/*end-if*/
++
++ return 0;
++}
++
++void unregister_NIOS_SPI( void )
++{
++ if ( spi_major > 0 )
++ unregister_chrdev( spi_major, "spi" );
++
++ release_region( (unsigned int)na_spi, sizeof(np_spi) );
++}
++
++
++#ifdef MODULE
++void cleanup_module( void )
++{
++ unregister_NIOS_SPI();
++}
++
++
++
++int init_module( void )
++{
++ return register_NIOS_SPI();
++}
++#endif
++
++
++static int __init nios_spi_init(void)
++{
++ printk("SPI: Nios SPI bus device version 0.1\n");
++ return register_NIOS_SPI();
++// if ( register_NIOS_SPI() )
++// printk("*** Cannot initialize SPI device.\n");
++}
++
++__initcall(nios_spi_init);
+diff --git a/arch/nios2nommu/kernel/ChangeLog b/arch/nios2nommu/kernel/ChangeLog
+new file mode 100644
+index 0000000..7f1449d
+--- /dev/null
++++ b/arch/nios2nommu/kernel/ChangeLog
+@@ -0,0 +1,27 @@
++2004-06-17 Ken Hill <khill@microtronix.com>
++
++ * process.c (machine_restart): Add code to disable interrups and
++ jump to the cpu reset address.
++ (machine_halt): Add code to disable interrupts and spinlock.
++ (machine_power_off): Add code to disable interrupts and spinlock.
++
++2004-06-16 Ken Hill <khill@microtronix.com>
++
++ * nios2_ksyms.c: Remove hard_reset_now.
++
++2004-06-10 Ken Hill <khill@microtronix.com>
++
++ * nios2_ksyms.c: Add EXPORT_SYMBOL_NOVERS(__down) to solve insmod for
++ some modules.
++
++2004-06-02 Ken Hill <khill@microtronix.com>
++
++ * entry.S (software_exception): Add a safety catch for old applications that may
++ have been linked against an older library. This does not add any overhead to
++ system call processing.
++
++2004-04-15 Ken Hill <khill@microtronix.com>
++
++ * setup.c (setup_arch): Remove ROMFS message from debug printk kernel message.
++ Add copyright and GNU license notice.
++
+diff --git a/arch/nios2nommu/kernel/Makefile b/arch/nios2nommu/kernel/Makefile
+new file mode 100644
+index 0000000..a056ff1
+--- /dev/null
++++ b/arch/nios2nommu/kernel/Makefile
+@@ -0,0 +1,22 @@
++#
++# Makefile for the linux kernel.
++#
++# Note! Dependencies are done automagically by 'make dep', which also
++# removes any old dependencies. DON'T put your own dependencies here
++# unless it's something special (ie not a .c file).
++#
++# Note 2! The CFLAGS definitions are now in the main makefile...
++
++extra-y := head.o init_task.o vmlinux.lds
++
++obj-y := entry.o traps.o irq.o syscalltable.o \
++ process.o signal.o setup.o sys_nios2.o \
++ semaphore.o io.o usb.o\
++ time.o ptrace.o start.o nios2_ksyms.o
++
++obj-$(CONFIG_MODULES) += module.o
++obj-$(CONFIG_CONSOLE) += console.o
++obj-$(CONFIG_PIO_DEVICES) += pio.o
++obj-$(CONFIG_AVALON_DMA) += dma.o
++
++
+diff --git a/arch/nios2nommu/kernel/asm-offsets.c b/arch/nios2nommu/kernel/asm-offsets.c
+new file mode 100644
+index 0000000..4877eba
+--- /dev/null
++++ b/arch/nios2nommu/kernel/asm-offsets.c
+@@ -0,0 +1,201 @@
++/*
++ * This program is used to generate definitions needed by
++ * assembly language modules.
++ *
++ * We use the technique used in the OSF Mach kernel code:
++ * generate asm statements containing #defines,
++ * compile this file to assembler, and then extract the
++ * #defines from the assembly-language output.
++ */
++
++#include <linux/stddef.h>
++#include <linux/sched.h>
++#include <linux/kernel_stat.h>
++#include <linux/ptrace.h>
++#include <asm/bootinfo.h>
++#include <asm/irq.h>
++#include <asm/hardirq.h>
++#include <asm/nios.h>
++
++#define DEFINE(sym, val) \
++ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
++
++#define BLANK() asm volatile("\n->" : : )
++
++int main(void)
++{
++
++ /* offsets into the task struct */
++ DEFINE(TASK_STATE, offsetof(struct task_struct, state));
++ DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
++ DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
++ DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
++ DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
++ DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
++ DEFINE(TASK_MM, offsetof(struct task_struct, mm));
++ DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
++
++ /* offsets into the kernel_stat struct */
++ DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
++
++ /* offsets into the irq_cpustat_t struct */
++ DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
++
++ /* offsets into the irq_node struct */
++ DEFINE(IRQ_HANDLER, offsetof(struct irq_hand, handler));
++ DEFINE(IRQ_FLAGS, offsetof(struct irq_hand, flags));
++ DEFINE(IRQ_DEV_ID, offsetof(struct irq_hand, dev_id));
++ DEFINE(IRQ_DEVNAME, offsetof(struct irq_hand, devname));
++
++ /* offsets into the thread struct */
++ DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
++ DEFINE(THREAD_KPSR, offsetof(struct thread_struct, kpsr));
++ DEFINE(THREAD_KESR, offsetof(struct thread_struct, kesr));
++ DEFINE(THREAD_FLAGS, offsetof(struct thread_struct, flags));
++
++ /* offsets into the pt_regs */
++ DEFINE(PT_ORIG_R2, offsetof(struct pt_regs, orig_r2));
++ DEFINE(PT_R1, offsetof(struct pt_regs, r1));
++ DEFINE(PT_R2, offsetof(struct pt_regs, r2));
++ DEFINE(PT_R3, offsetof(struct pt_regs, r3));
++ DEFINE(PT_R4, offsetof(struct pt_regs, r4));
++ DEFINE(PT_R5, offsetof(struct pt_regs, r5));
++ DEFINE(PT_R6, offsetof(struct pt_regs, r6));
++ DEFINE(PT_R7, offsetof(struct pt_regs, r7));
++ DEFINE(PT_R8, offsetof(struct pt_regs, r8));
++ DEFINE(PT_R9, offsetof(struct pt_regs, r9));
++ DEFINE(PT_R10, offsetof(struct pt_regs, r10));
++ DEFINE(PT_R11, offsetof(struct pt_regs, r11));
++ DEFINE(PT_R12, offsetof(struct pt_regs, r12));
++ DEFINE(PT_R13, offsetof(struct pt_regs, r13));
++ DEFINE(PT_R14, offsetof(struct pt_regs, r14));
++ DEFINE(PT_R15, offsetof(struct pt_regs, r15));
++ DEFINE(PT_EA, offsetof(struct pt_regs, ea));
++ DEFINE(PT_RA, offsetof(struct pt_regs, ra));
++ DEFINE(PT_FP, offsetof(struct pt_regs, fp));
++ DEFINE(PT_SP, offsetof(struct pt_regs, sp));
++ DEFINE(PT_GP, offsetof(struct pt_regs, gp));
++ DEFINE(PT_ESTATUS, offsetof(struct pt_regs, estatus));
++ DEFINE(PT_STATUS_EXTENSION, offsetof(struct pt_regs, status_extension));
++ DEFINE(PT_REGS_SIZE, sizeof(struct pt_regs));
++
++ /* offsets into the switch_stack */
++ DEFINE(SW_R16, offsetof(struct switch_stack, r16));
++ DEFINE(SW_R17, offsetof(struct switch_stack, r17));
++ DEFINE(SW_R18, offsetof(struct switch_stack, r18));
++ DEFINE(SW_R19, offsetof(struct switch_stack, r19));
++ DEFINE(SW_R20, offsetof(struct switch_stack, r20));
++ DEFINE(SW_R21, offsetof(struct switch_stack, r21));
++ DEFINE(SW_R22, offsetof(struct switch_stack, r22));
++ DEFINE(SW_R23, offsetof(struct switch_stack, r23));
++ DEFINE(SW_FP, offsetof(struct switch_stack, fp));
++ DEFINE(SW_GP, offsetof(struct switch_stack, gp));
++ DEFINE(SW_RA, offsetof(struct switch_stack, ra));
++ DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack));
++
++ DEFINE(PS_S_ASM, PS_S);
++
++ DEFINE(NIOS2_STATUS_PIE_MSK_ASM, NIOS2_STATUS_PIE_MSK);
++ DEFINE(NIOS2_STATUS_PIE_OFST_ASM, NIOS2_STATUS_PIE_OFST);
++ DEFINE(NIOS2_STATUS_U_MSK_ASM, NIOS2_STATUS_U_MSK);
++ DEFINE(NIOS2_STATUS_U_OFST_ASM, NIOS2_STATUS_U_OFST);
++
++ /* offsets into the kernel_stat struct */
++ DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
++
++ /* Offsets in thread_info structure, used in assembly code */
++ DEFINE(TI_TASK, offsetof(struct thread_info, task));
++ DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
++ DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
++ DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
++ DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count));
++
++ DEFINE(PREEMPT_ACTIVE_ASM, PREEMPT_ACTIVE);
++
++ DEFINE(THREAD_SIZE_ASM, THREAD_SIZE);
++
++ DEFINE(TIF_SYSCALL_TRACE_ASM, TIF_SYSCALL_TRACE);
++ DEFINE(TIF_NOTIFY_RESUME_ASM, TIF_NOTIFY_RESUME);
++ DEFINE(TIF_SIGPENDING_ASM, TIF_SIGPENDING);
++ DEFINE(TIF_NEED_RESCHED_ASM, TIF_NEED_RESCHED);
++ DEFINE(TIF_POLLING_NRFLAG_ASM, TIF_POLLING_NRFLAG);
++
++ DEFINE(_TIF_SYSCALL_TRACE_ASM, _TIF_SYSCALL_TRACE);
++ DEFINE(_TIF_NOTIFY_RESUME_ASM, _TIF_NOTIFY_RESUME);
++ DEFINE(_TIF_SIGPENDING_ASM, _TIF_SIGPENDING);
++ DEFINE(_TIF_NEED_RESCHED_ASM, _TIF_NEED_RESCHED);
++ DEFINE(_TIF_POLLING_NRFLAG_ASM, _TIF_POLLING_NRFLAG);
++
++ DEFINE(_TIF_WORK_MASK_ASM, _TIF_WORK_MASK);
++
++#if defined(na_flash_kernel) && defined(na_flash_kernel_end)
++ /* the flash chip */
++ DEFINE(NIOS_FLASH_START, na_flash_kernel);
++ DEFINE(NIOS_FLASH_END, na_flash_kernel_end);
++
++ /* the kernel placement in the flash*/
++ DEFINE(KERNEL_FLASH_START, na_flash_kernel);
++ DEFINE(KERNEL_FLASH_LEN, 0x200000);
++
++ /* the romdisk placement in the flash */
++ DEFINE(LINUX_ROMFS_START, na_flash_kernel+0x200000);
++ DEFINE(LINUX_ROMFS_END, na_flash_kernel_end);
++#else
++#error Sorry,you dont have na_flash_kernel or na_flash_kernel_end defined in the core.
++#endif
++
++#if defined(nasys_program_mem) && defined(nasys_program_mem_end)
++ /* the sdram */
++ DEFINE(LINUX_SDRAM_START, nasys_program_mem);
++ DEFINE(LINUX_SDRAM_END, nasys_program_mem_end);
++#else
++#error Sorry,you dont have nasys_program_mem or nasys_program_mem_end defined in the core.
++#endif
++
++ DEFINE(NIOS2_ICACHE_SIZE, nasys_icache_size);
++ DEFINE(NIOS2_ICACHE_LINE_SIZE, nasys_icache_line_size);
++ DEFINE(NIOS2_DCACHE_SIZE, nasys_dcache_size);
++ DEFINE(NIOS2_DCACHE_LINE_SIZE, nasys_dcache_line_size);
++
++#if defined(na_enet)
++ DEFINE(NA_ENET_ASM, na_enet);
++#endif
++
++#if defined(na_enet_reset)
++ DEFINE(NA_ENET_RESET_ASM, na_enet_reset);
++#endif
++
++#if defined(na_enet_reset_n)
++ DEFINE(NA_ENET_RESET_N_ASM, na_enet_reset_n);
++#endif
++
++#if defined(na_ide_interface)
++ DEFINE(NA_IDE_INTERFACE_ASM, na_ide_interface);
++#endif
++
++#if defined(na_timer0)
++ DEFINE(NA_TIMER0_ASM, na_timer0);
++ DEFINE(NP_TIMERCONTROL_ASM, offsetof(np_timer, np_timercontrol));
++ DEFINE(NP_TIMERSTATUS_ASM, offsetof(np_timer, np_timerstatus));
++#endif
++
++#if defined(na_uart0)
++ DEFINE(NA_UART0_ASM, na_uart0);
++ DEFINE(NP_UARTCONTROL_ASM, offsetof(np_uart, np_uartcontrol));
++ DEFINE(NP_UARTSTATUS_ASM, offsetof(np_uart, np_uartstatus));
++#endif
++
++#if defined(na_uart1)
++ DEFINE(NA_UART1_ASM, na_uart1);
++#endif
++
++#if defined(na_uart2)
++ DEFINE(NA_UART2_ASM, na_uart2);
++#endif
++
++#if defined(na_uart3)
++ DEFINE(NA_UART3_ASM, na_uart3);
++#endif
++
++ return 0;
++}
+diff --git a/arch/nios2nommu/kernel/dma.c b/arch/nios2nommu/kernel/dma.c
+new file mode 100644
+index 0000000..f23323b
+--- /dev/null
++++ b/arch/nios2nommu/kernel/dma.c
+@@ -0,0 +1,342 @@
++/*
++ * arch/nios2nommu/kernel/dma.c
++ *
++ * Copyright (C) 2005 Microtronix Datacom Ltd
++ *
++ * PC like DMA API for Nios's DMAC.
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file "COPYING" in the main directory of this archive
++ * for more details.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#include <linux/init.h>
++#include <linux/irq.h>
++#include <linux/interrupt.h>
++#include <linux/module.h>
++#include <linux/fs.h>
++#include <linux/seq_file.h>
++#include <linux/proc_fs.h>
++#include <asm/io.h>
++#include <asm/dma.h>
++
++/* nios2 dma controller register map */
++#define REG_DMA_STATUS 0
++#define REG_DMA_READADDR 4
++#define REG_DMA_WRITEADDR 8
++#define REG_DMA_LENGTH 12
++#define REG_DMA_CONTROL 24
++
++/* status register bits definition */
++#define ST_DONE 0x01
++#define ST_BUSY 0x02
++#define ST_REOP 0x04
++#define ST_WROP 0x08
++#define ST_LEN 0x10
++
++/* control register bits definition */
++#define CT_BYTE 0x01
++#define CT_HW 0x02
++#define CT_WORD 0x04
++#define CT_GO 0x08
++#define CT_IEEN 0x10
++#define CT_REEN 0x20
++#define CT_WEEN 0x40
++#define CT_LEEN 0x80
++#define CT_RCON 0x100
++#define CT_WCON 0x200
++#define CT_DOUBLE 0x400
++#define CT_QUAD 0x800
++
++struct dma_channel {
++ unsigned int addr; /* control address */
++ unsigned int irq; /* interrupt number */
++ atomic_t idle;
++ unsigned int mode; /* dma mode: width, stream etc */
++ int (*handler)(void*, int );
++ void* user;
++
++ char id[16];
++ char dev_id[16];
++};
++static struct dma_channel dma_channels[]={
++#ifdef na_dma_0
++ {
++ .addr = na_dma_0,
++ .irq = na_dma_0_irq,
++ .idle = ATOMIC_INIT(1),
++ },
++#endif
++#ifdef na_dma_1
++ {
++ .addr = na_dma_1,
++ .irq = na_dma_1_irq,
++ .idle = ATOMIC_INIT(1),
++ },
++#endif
++};
++#define MAX_DMA_CHANNELS sizeof(dma_channels)/sizeof(struct dma_channel)
++
++void enable_dma(unsigned int dmanr)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ unsigned int ctl = dma_channels[dmanr].mode;
++ ctl |= CT_GO | CT_IEEN;
++ outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
++ }
++}
++
++void disable_dma(unsigned int dmanr)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ unsigned int ctl = dma_channels[dmanr].mode;
++ ctl &= ~(CT_GO | CT_IEEN);
++ outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
++ }
++}
++
++void set_dma_count(unsigned int dmanr, unsigned int count)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ dma_channels[dmanr].mode |= CT_LEEN;
++ outl(count, dma_channels[dmanr].addr+REG_DMA_LENGTH);
++ }
++}
++
++int get_dma_residue(unsigned int dmanr)
++{
++ int result =-1;
++ if (dmanr < MAX_DMA_CHANNELS) {
++ result = inl(dma_channels[dmanr].addr+REG_DMA_LENGTH);
++ }
++ return result;
++}
++
++int request_dma(unsigned int chan, const char *dev_id)
++{
++ struct dma_channel *channel;
++
++ if ( chan >= MAX_DMA_CHANNELS) {
++ return -EINVAL;
++ }
++
++ channel = &dma_channels[chan];
++
++ if (!atomic_dec_and_test(&channel->idle)) {
++ return -EBUSY;
++ }
++
++ strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id));
++ channel->handler=NULL;
++ channel->user=NULL;
++ channel->mode =0;
++
++ return 0;
++}
++
++void free_dma(unsigned int chan)
++{
++ if ( chan < MAX_DMA_CHANNELS) {
++ dma_channels[chan].handler=NULL;
++ dma_channels[chan].user=NULL;
++ atomic_set(&dma_channels[chan].idle, 1);
++ }
++}
++
++int nios2_request_dma(const char *dev_id)
++{
++ int chann;
++
++ for ( chann=0; chann < MAX_DMA_CHANNELS; chann++) {
++ if (request_dma(chann, dev_id)==0)
++ return chann;
++ }
++
++ return -EINVAL;
++}
++void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ dma_channels[dmanr].handler=handler;
++ dma_channels[dmanr].user=user;
++ }
++}
++#define NIOS2_DMA_WIDTH_MASK (CT_BYTE | CT_HW | CT_WORD | CT_DOUBLE | CT_QUAD)
++#define NIOS2_MODE_MASK (NIOS2_DMA_WIDTH_MASK | CT_REEN | CT_WEEN | CT_LEEN | CT_RCON | CT_WCON)
++void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ dma_channels[dmanr].mode &= ~NIOS2_DMA_WIDTH_MASK;
++ switch (width) {
++ case 1:
++ dma_channels[dmanr].mode |= CT_BYTE;
++ break;
++ case 2:
++ dma_channels[dmanr].mode |= CT_HW;
++ break;
++ case 8:
++ dma_channels[dmanr].mode |= CT_DOUBLE;
++ break;
++ case 16:
++ dma_channels[dmanr].mode |= CT_QUAD;
++ break;
++ case 4:
++ default:
++ dma_channels[dmanr].mode |= CT_WORD;
++ break;
++ }
++ }
++}
++
++void nios2_set_dma_rcon(unsigned int dmanr,unsigned int set)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ dma_channels[dmanr].mode &= ~(CT_REEN | CT_RCON);
++ if (set)
++ dma_channels[dmanr].mode |= (CT_REEN | CT_RCON);
++ }
++}
++void nios2_set_dma_wcon(unsigned int dmanr,unsigned int set)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ dma_channels[dmanr].mode &= ~(CT_WEEN | CT_WCON);
++ if (set)
++ dma_channels[dmanr].mode |= (CT_WEEN | CT_WCON);
++ }
++}
++void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ /* set_dma_mode is only allowed to change the bus width,
++ stream setting, etc.
++ */
++ mode &= NIOS2_MODE_MASK;
++ dma_channels[dmanr].mode &= ~NIOS2_MODE_MASK;
++ dma_channels[dmanr].mode |= mode;
++ }
++}
++
++void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ outl(a, dma_channels[dmanr].addr+REG_DMA_READADDR);
++ }
++}
++void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a)
++{
++ if (dmanr < MAX_DMA_CHANNELS) {
++ outl(a, dma_channels[dmanr].addr+REG_DMA_WRITEADDR);
++ }
++}
++
++
++static irqreturn_t dma_isr(int irq, void *dev_id)
++{
++ struct dma_channel *chann=(struct dma_channel*)dev_id;
++
++ if (chann) {
++ int status = inl(chann->addr+REG_DMA_STATUS);
++ /* ack the interrupt, and clear the DONE bit */
++ outl(0, chann->addr+REG_DMA_STATUS);
++ /* call the peripheral callback */
++ if (chann->handler)
++ chann->handler(chann->user, status);
++ }
++
++ return IRQ_HANDLED;
++}
++
++
++
++#ifdef CONFIG_PROC_FS
++static int proc_dma_show(struct seq_file *m, void *v)
++{
++ int i;
++
++ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
++ if (!atomic_read(&dma_channels[i].idle)) {
++ seq_printf(m, "%2d: %s\n", i,
++ dma_channels[i].dev_id);
++ }
++ }
++ return 0;
++}
++
++static int proc_dma_open(struct inode *inode, struct file *file)
++{
++ return single_open(file, proc_dma_show, NULL);
++}
++static struct file_operations proc_dma_operations = {
++ .open = proc_dma_open,
++ .read = seq_read,
++ .llseek = seq_lseek,
++ .release = single_release,
++};
++
++static int __init proc_dma_init(void)
++{
++ struct proc_dir_entry *e;
++
++ e = create_proc_entry("dma", 0, NULL);
++ if (e)
++ e->proc_fops = &proc_dma_operations;
++
++ return 0;
++}
++
++__initcall(proc_dma_init);
++
++#endif /* CONFIG_PROC_FS */
++
++int __init init_dma(void)
++{
++ int i;
++
++ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
++ sprintf(dma_channels[i].id, "dmac-%d", i);
++ /* disable the dmac channel */
++ disable_dma(i);
++ /* request irq*/
++ if (request_irq(dma_channels[i].irq, dma_isr, 0, dma_channels[i].id, (void*)&dma_channels[i])){
++ printk("DMA controller %d failed to get irq %d\n", i, dma_channels[i].irq);
++ atomic_set(&dma_channels[i].idle, 0);
++ }
++ }
++ return 0;
++}
++
++static void __exit exit_dma(void)
++{
++ int i;
++
++ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
++ /* disable the dmac channel */
++ disable_dma(i);
++ free_irq(dma_channels[i].irq, dma_channels[i].id);
++ }
++}
++
++module_init(init_dma);
++module_exit(exit_dma);
++
++MODULE_LICENSE("GPL");
++
++//EXPORT_SYMBOL(claim_dma_lock);
++//EXPORT_SYMBOL(release_dma_lock);
++EXPORT_SYMBOL(enable_dma);
++EXPORT_SYMBOL(disable_dma);
++EXPORT_SYMBOL(set_dma_count);
++EXPORT_SYMBOL(get_dma_residue);
++EXPORT_SYMBOL(request_dma);
++EXPORT_SYMBOL(free_dma);
++EXPORT_SYMBOL(nios2_request_dma);
++EXPORT_SYMBOL(nios2_set_dma_handler);
++EXPORT_SYMBOL(nios2_set_dma_data_width);
++EXPORT_SYMBOL(nios2_set_dma_rcon);
++EXPORT_SYMBOL(nios2_set_dma_wcon);
++EXPORT_SYMBOL(nios2_set_dma_mode);
++EXPORT_SYMBOL(nios2_set_dma_raddr);
++EXPORT_SYMBOL(nios2_set_dma_waddr);
++
+diff --git a/arch/nios2nommu/kernel/entry.S b/arch/nios2nommu/kernel/entry.S
+new file mode 100644
+index 0000000..7f71a01
+--- /dev/null
++++ b/arch/nios2nommu/kernel/entry.S
+@@ -0,0 +1,898 @@
++/*
++ * linux/arch/nios2nommu/kernel/entry.S
++ *
++ * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
++ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
++ * Kenneth Albanowski <kjahds@kjahds.com>,
++ * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * Based on:
++ *
++ * linux/arch/m68knommu/kernel/entry.S
++ *
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file README.legal in the main directory of this archive
++ * for more details.
++ *
++ * Linux/m68k support by Hamish Macdonald
++ *
++ * 68060 fixes by Jesper Skov
++ * ColdFire support by Greg Ungerer (gerg@snapgear.com)
++ * 5307 fixes by David W. Miller
++ * linux 2.4 support David McCullough <davidm@snapgear.com>
++ */
++
++#include <linux/sys.h>
++#include <linux/linkage.h>
++#include <asm/asm-offsets.h>
++#include <asm/asm-macros.h>
++#include <asm/thread_info.h>
++#include <asm/errno.h>
++#include <asm/setup.h>
++#include <asm/segment.h>
++#include <asm/entry.h>
++#include <asm/unistd.h>
++#include <asm/traps.h>
++#include <asm/processor.h>
++
++.text
++.set noat
++.set nobreak
++
++ENTRY(system_call)
++/* SAVE_ALL */
++ rdctl r10,status /* enable intrs again */
++ ori r10,r10,0x0001
++ wrctl status,r10
++
++ movi r2,-LENOSYS
++ stw r2,PT_R2(sp) /* default return value in r2 */
++ /* original r2 is in orig_r2 */
++
++ movui r1,NR_syscalls
++ bgtu r3,r1,ret_from_exception
++ slli r1,r3,2
++ movhi r11,%hiadj(sys_call_table)
++ add r1,r1,r11
++ ldw r1,%lo(sys_call_table)(r1)
++ beq r1,r0,ret_from_exception
++
++ movi r11,%lo(0xffffe000) /* Get thread info pointer */
++ and r11,sp,r11
++ ldw r11,TI_FLAGS(r11)
++ BTBNZ r11,r11,TIF_SYSCALL_TRACE_ASM,1f
++
++ callr r1
++ stw r2,PT_R2(sp) /* save the return value */
++ br ret_from_exception
++1:
++ SAVE_SWITCH_STACK
++ call syscall_trace
++ RESTORE_SWITCH_STACK
++ /* wentao: restore r4-9, since they are trashed by syscall_trace */
++ ldw r4,PT_R4(sp)
++ ldw r5,PT_R5(sp)
++ ldw r6,PT_R6(sp)
++ ldw r7,PT_R7(sp)
++ ldw r8,PT_R8(sp)
++ ldw r9,PT_R9(sp)
++ callr r1
++ stw r2,PT_R2(sp) /* save the return value */
++ SAVE_SWITCH_STACK
++ call syscall_trace
++ RESTORE_SWITCH_STACK
++
++ret_from_exception:
++ ldw r1,PT_STATUS_EXTENSION(sp) /* check if returning to kernel */
++ TSTBZ r1,r1,PS_S_ASM,Luser_return /* if so, skip resched, signals */
++
++restore_all:
++ rdctl r10,status /* disable intrs */
++ andi r10,r10,0xfffe
++ wrctl status, r10
++ RESTORE_ALL
++ eret
++
++Luser_return:
++ GET_THREAD_INFO r24 /* get thread_info pointer */
++ ldw r10,TI_FLAGS(r24) /* get thread_info->flags */
++ ANDI32 r11,r10,_TIF_WORK_MASK_ASM
++ beq r11,r0,restore_all /* Nothing to do */
++ BTBZ r1,r10,TIF_NEED_RESCHED_ASM,Lsignal_return
++
++Lwork_resched:
++ call schedule
++ br ret_from_exception
++
++Lsignal_return:
++ BTBZ r1,r10,TIF_SIGPENDING_ASM,restore_all
++ mov r5,sp /* pt_regs */
++ SAVE_SWITCH_STACK
++ CLR r4 /* oldset = 0 */
++ call do_signal
++ RESTORE_SWITCH_STACK
++ br restore_all
++
++/*
++ * Handle software exceptions. Put here so external interrupts
++ * can fall throught to ret_from_interrupt.
++ */
++
++software_exception:
++ ldw r24,-4(ea) // instruction that caused the exception
++ xorhi r24,r24,0x003b // upper half of trap opcode
++ xori r24,r24,0x683a // lower half of trap opcode
++ bne r24,r0,instruction_trap /* N - check for instruction trap */
++ cmpeqi r11,r2,TRAP_ID_SYSCALL /* ? Is this a syscall */
++ bne r11,r0,system_call /* Y - handle syscall */
++ cmpeqi r11,r2,TRAP_ID_APPDEBUG /* ? Is this an application debug */
++ bne r11,r0,app_debug /* Y - handle app_debug */
++ cmpeqi r11,r2,63 /* ? Is this the old syscall number */
++ bne r11,r0,system_call /* Y - handle syscall to catch older apps*/
++ br restore_all /* N - everything else is ignored for now */
++
++app_debug:
++ GET_THREAD_INFO r24 /* get thread_info */
++ ldw r1,TI_TASK(r24) /* get thread_info->task */
++ ldw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* get thread_info->task->thread.flags */
++ ORI32 r24, r24, NIOS2_FLAG_DEBUG /* set the debug flag */
++ stw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* save thread_info->task->thread.flags */
++ br restore_all
++
++/*
++ * This is the generic interrupt handler (for all hardware interrupt
++ * sources). It figures out the vector number and calls the appropriate
++ * interrupt service routine directly.
++ */
++ENTRY(inthandler)
++ SAVE_ALL
++ /*
++ * Test to see if the exception was a software exception or caused by an
++ * external interrupt, and vector accordingly.
++ */
++
++ rdctl r24,estatus
++ andi r24,r24,1
++ beq r24,r0,software_exception
++ rdctl r12,ipending
++ beq r12,r0,software_exception
++
++ movi r24,-1
++ stw r24,PT_ORIG_R2(sp)
++
++ /*
++ * Process an external hardware interrupt.
++ */
++
++ addi ea,ea,-4 /* re-issue the interrupted instruction */
++ stw ea,PT_EA(sp)
++ rdctl r9,ienable /* Isolate possible interrupts */
++ and r12,r12,r9
++ beq r12,r0,ret_from_interrupt /* No one to service done */
++ movi r4,%lo(-1) /* Start from bit position 0, highest priority */
++ /* This is the IRQ # for handler call */
++1: addi r4,r4,1
++ srl r10,r12,r4
++ andi r10,r10,1 /* Isolate bit we are interested in */
++ cmpeqi r11,r4,32 /* ? End of the register */
++ bne r11,r0,ret_from_interrupt /* Y - out of here */
++ beq r10,r0,1b
++ mov r5,sp /* Setup pt_regs pointer for handler call */
++ PUSH r4 /* Save state for return */
++ PUSH r12
++ call process_int
++ POP r12
++ POP r4
++ br 1b /* Check for other interrupts while here */
++
++ENTRY(ret_from_interrupt)
++ ldw r4,PT_STATUS_EXTENSION(sp)
++ TSTBZ r4,r4,PS_S_ASM,Luser_return // Returning to user
++
++#ifdef CONFIG_PREEMPT
++ GET_THREAD_INFO r1
++ ldw r4,TI_PREEMPT_COUNT(r1)
++ bne r4,r0,restore_all
++
++need_resched:
++ ldw r4,TI_FLAGS(r1) // ? Need resched set
++ BTBZ r10,r4,TIF_NEED_RESCHED_ASM,restore_all
++ ldw r4,PT_ESTATUS(sp) // ? Interrupts off
++ BTBZ r10,r4,NIOS2_STATUS_PIE_OFST_ASM,restore_all
++ movia r4,PREEMPT_ACTIVE_ASM
++ stw r4,TI_PREEMPT_COUNT(r1)
++ rdctl r10,status /* enable intrs again */
++ ori r10,r10,0x0001
++ wrctl status,r10
++ PUSH r1
++ call schedule
++ POP r1
++ mov r4,r0
++ stw r4,TI_PREEMPT_COUNT(r1)
++ rdctl r10,status /* disable intrs */
++ andi r10,r10,0xfffe
++ wrctl status, r10
++ br need_resched
++#else
++ br restore_all
++#endif
++
++
++/*
++ * Beware - when entering resume, prev (the current task) is
++ * in r4, next (the new task) is in r5, don't change these
++ * registers.
++ */
++ENTRY(resume)
++
++ rdctl r7,status /* save thread status reg */
++ stw r7,TASK_THREAD+THREAD_KPSR(r4)
++
++ andi r7,r7,0x0fffe /* disable interrupts */
++ wrctl status,r7
++
++ movia r8,status_extension /* save status extension */
++ ldw r7,0(r8)
++ stw r7,TASK_THREAD+THREAD_KESR(r4)
++
++ SAVE_SWITCH_STACK
++ stw sp,TASK_THREAD+THREAD_KSP(r4) /* save kernel stack pointer */
++ ldw sp,TASK_THREAD+THREAD_KSP(r5) /* restore new thread stack */
++ movia r24,_current_thread /* save thread */
++ GET_THREAD_INFO r1
++ stw r1,0(r24)
++ RESTORE_SWITCH_STACK
++
++ ldw r7,TASK_THREAD+THREAD_KESR(r5) /* restore extended status reg */
++ stw r7,0(r8)
++
++ ldw r7,TASK_THREAD+THREAD_KPSR(r5) /* restore thread status reg */
++ wrctl status,r7
++ ret
++
++ENTRY(ret_from_fork)
++ call schedule_tail
++ br ret_from_exception
++
++ENTRY(sys_fork)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call nios2_vfork
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_vfork)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call nios2_vfork
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_execve)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call nios2_execve
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_clone)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call nios2_clone
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_sigsuspend)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call do_sigsuspend
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_rt_sigsuspend)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call do_rt_sigsuspend
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_sigreturn)
++ mov r4,sp
++ SAVE_SWITCH_STACK
++ call do_sigreturn
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_sigaltstack)
++ ldw r4,PT_R4(sp)
++ ldw r5,PT_R5(sp)
++ ldw r6,PT_SP(sp)
++ SAVE_SWITCH_STACK
++ call do_sigaltstack
++ RESTORE_SWITCH_STACK
++ ret
++
++ENTRY(sys_rt_sigreturn)
++ SAVE_SWITCH_STACK
++ call do_rt_sigreturn
++ RESTORE_SWITCH_STACK
++ ret
++
++/******************************************************************************
++* *
++* License Agreement *
++* *
++* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
++* All rights reserved. *
++* *
++* Permission is hereby granted, free of charge, to any person obtaining a *
++* copy of this software and associated documentation files (the "Software"), *
++* to deal in the Software without restriction, including without limitation *
++* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
++* and/or sell copies of the Software, and to permit persons to whom the *
++* Software is furnished to do so, subject to the following conditions: *
++* *
++* The above copyright notice and this permission notice shall be included in *
++* all copies or substantial portions of the Software. *
++* *
++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
++* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
++* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
++* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
++* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
++* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
++* DEALINGS IN THE SOFTWARE. *
++* *
++* This agreement shall be governed in all respects by the laws of the State *
++* of California and by the laws of the United States of America. *
++* *
++******************************************************************************/
++
++ /*
++ * This is the software exception handler for Nios2.
++ */
++
++ /*
++ * Explicitly allow the use of r1 (the assembler temporary register)
++ * within this code. This register is normally reserved for the use of
++ * the compiler.
++ */
++
++ENTRY(instruction_trap)
++ RESTORE_ALL // Clean off our save & setup for emulation
++
++ /* INSTRUCTION EMULATION
++ * ---------------------
++ *
++ * Nios II processors generate exceptions for unimplemented instructions.
++ * The routines below emulate these instructions. Depending on the
++ * processor core, the only instructions that might need to be emulated
++ * are div, divu, mul, muli, mulxss, mulxsu, and mulxuu.
++ *
++ * The emulations match the instructions, except for the following
++ * limitations:
++ *
++ * 1) The emulation routines do not emulate the use of the exception
++ * temporary register (et) as a source operand because the exception
++ * handler already has modified it.
++ *
++ * 2) The routines do not emulate the use of the stack pointer (sp) or the
++ * exception return address register (ea) as a destination because
++ * modifying these registers crashes the exception handler or the
++ * interrupted routine.
++ *
++ * Detailed Design
++ * ---------------
++ *
++ * The emulation routines expect the contents of integer registers r0-r31
++ * to be on the stack at addresses sp, 4(sp), 8(sp), ... 124(sp). The
++ * routines retrieve source operands from the stack and modify the
++ * destination register's value on the stack prior to the end of the
++ * exception handler. Then all registers except the destination register
++ * are restored to their previous values.
++ *
++ * The instruction that causes the exception is found at address -4(ea).
++ * The instruction's OP and OPX fields identify the operation to be
++ * performed.
++ *
++ * One instruction, muli, is an I-type instruction that is identified by
++ * an OP field of 0x24.
++ *
++ * muli AAAAA,BBBBB,IIIIIIIIIIIIIIII,-0x24-
++ * 27 22 6 0 <-- LSB of field
++ *
++ * The remaining emulated instructions are R-type and have an OP field
++ * of 0x3a. Their OPX fields identify them.
++ *
++ * R-type AAAAA,BBBBB,CCCCC,XXXXXX,NNNNN,-0x3a-
++ * 27 22 17 11 6 0 <-- LSB of field
++ *
++ *
++ * Opcode Encoding. muli is identified by its OP value. Then OPX & 0x02
++ * is used to differentiate between the division opcodes and the remaining
++ * multiplication opcodes.
++ *
++ * Instruction OP OPX OPX & 0x02
++ * ----------- ---- ---- ----------
++ * muli 0x24
++ * divu 0x3a 0x24 0
++ * div 0x3a 0x25 0
++ * mul 0x3a 0x27 != 0
++ * mulxuu 0x3a 0x07 != 0
++ * mulxsu 0x3a 0x17 != 0
++ * mulxss 0x3a 0x1f != 0
++ */
++
++
++ /*
++ * Save everything on the stack to make it easy for the emulation routines
++ * to retrieve the source register operands.
++ */
++
++ addi sp, sp, -128
++ stw zero, 0(sp) // Save zero on stack to avoid special case for r0.
++ stw r1, 4(sp)
++ stw r2, 8(sp)
++ stw r3, 12(sp)
++ stw r4, 16(sp)
++ stw r5, 20(sp)
++ stw r6, 24(sp)
++ stw r7, 28(sp)
++ stw r8, 32(sp)
++ stw r9, 36(sp)
++ stw r10, 40(sp)
++ stw r11, 44(sp)
++ stw r12, 48(sp)
++ stw r13, 52(sp)
++ stw r14, 56(sp)
++ stw r15, 60(sp)
++ stw r16, 64(sp)
++ stw r17, 68(sp)
++ stw r18, 72(sp)
++ stw r19, 76(sp)
++ stw r20, 80(sp)
++ stw r21, 84(sp)
++ stw r22, 88(sp)
++ stw r23, 92(sp)
++ // Don't bother to save et. It's already been changed.
++ stw bt, 100(sp)
++ stw gp, 104(sp)
++ stw sp, 108(sp)
++ stw fp, 112(sp)
++ // Don't bother to save ea. It's already been changed.
++ stw ba, 120(sp)
++ stw ra, 124(sp)
++
++
++ /*
++ * Split the instruction into its fields. We need 4*A, 4*B, and 4*C as
++ * offsets to the stack pointer for access to the stored register values.
++ */
++ ldw r2,-4(ea) // r2 = AAAAA,BBBBB,IIIIIIIIIIIIIIII,PPPPPP
++ roli r3,r2,7 // r3 = BBB,IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BB
++ roli r4,r3,3 // r4 = IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB
++ roli r5,r4,2 // r5 = IIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB,II
++ srai r4,r4,16 // r4 = (sign-extended) IMM16
++ roli r6,r5,5 // r6 = XXXX,NNNNN,PPPPPP,AAAAA,BBBBB,CCCCC,XX
++ andi r2,r2,0x3f // r2 = 00000000000000000000000000,PPPPPP
++ andi r3,r3,0x7c // r3 = 0000000000000000000000000,AAAAA,00
++ andi r5,r5,0x7c // r5 = 0000000000000000000000000,BBBBB,00
++ andi r6,r6,0x7c // r6 = 0000000000000000000000000,CCCCC,00
++
++ /* Now
++ * r2 = OP
++ * r3 = 4*A
++ * r4 = IMM16 (sign extended)
++ * r5 = 4*B
++ * r6 = 4*C
++ */
++
++
++ /*
++ * Get the operands.
++ *
++ * It is necessary to check for muli because it uses an I-type instruction
++ * format, while the other instructions are have an R-type format.
++ *
++ * Prepare for either multiplication or division loop.
++ * They both loop 32 times.
++ */
++ movi r14,32
++
++ add r3,r3,sp // r3 = address of A-operand.
++ ldw r3,0(r3) // r3 = A-operand.
++ movi r7,0x24 // muli opcode (I-type instruction format)
++ beq r2,r7,mul_immed // muli doesn't use the B register as a source
++
++ add r5,r5,sp // r5 = address of B-operand.
++ ldw r5,0(r5) // r5 = B-operand.
++ // r4 = SSSSSSSSSSSSSSSS,-----IMM16------
++ // IMM16 not needed, align OPX portion
++ // r4 = SSSSSSSSSSSSSSSS,CCCCC,-OPX--,00000
++ srli r4,r4,5 // r4 = 00000,SSSSSSSSSSSSSSSS,CCCCC,-OPX--
++ andi r4,r4,0x3f // r4 = 00000000000000000000000000,-OPX--
++
++ /* Now
++ * r2 = OP
++ * r3 = src1
++ * r5 = src2
++ * r4 = OPX (no longer can be muli)
++ * r6 = 4*C
++ */
++
++
++
++ /*
++ * Multiply or Divide?
++ */
++ andi r7,r4,0x02 // For R-type multiply instructions, OPX & 0x02 != 0
++ bne r7,zero,multiply
++
++
++ /* DIVISION
++ *
++ * Divide an unsigned dividend by an unsigned divisor using
++ * a shift-and-subtract algorithm. The example below shows
++ * 43 div 7 = 6 for 8-bit integers. This classic algorithm uses a
++ * single register to store both the dividend and the quotient,
++ * allowing both values to be shifted with a single instruction.
++ *
++ * remainder dividend:quotient
++ * --------- -----------------
++ * initialize 00000000 00101011:
++ * shift 00000000 0101011:_
++ * remainder >= divisor? no 00000000 0101011:0
++ * shift 00000000 101011:0_
++ * remainder >= divisor? no 00000000 101011:00
++ * shift 00000001 01011:00_
++ * remainder >= divisor? no 00000001 01011:000
++ * shift 00000010 1011:000_
++ * remainder >= divisor? no 00000010 1011:0000
++ * shift 00000101 011:0000_
++ * remainder >= divisor? no 00000101 011:00000
++ * shift 00001010 11:00000_
++ * remainder >= divisor? yes 00001010 11:000001
++ * remainder -= divisor - 00000111
++ * ----------
++ * 00000011 11:000001
++ * shift 00000111 1:000001_
++ * remainder >= divisor? yes 00000111 1:0000011
++ * remainder -= divisor - 00000111
++ * ----------
++ * 00000000 1:0000011
++ * shift 00000001 :0000011_
++ * remainder >= divisor? no 00000001 :00000110
++ *
++ * The quotient is 00000110.
++ */
++
++divide:
++ /*
++ * Prepare for division by assuming the result
++ * is unsigned, and storing its "sign" as 0.
++ */
++ movi r17,0
++
++
++ // Which division opcode?
++ xori r7,r4,0x25 // OPX of div
++ bne r7,zero,unsigned_division
++
++
++ /*
++ * OPX is div. Determine and store the sign of the quotient.
++ * Then take the absolute value of both operands.
++ */
++ xor r17,r3,r5 // MSB contains sign of quotient
++ bge r3,zero,dividend_is_nonnegative
++ sub r3,zero,r3 // -r3
++dividend_is_nonnegative:
++ bge r5,zero,divisor_is_nonnegative
++ sub r5,zero,r5 // -r5
++divisor_is_nonnegative:
++
++
++unsigned_division:
++ // Initialize the unsigned-division loop.
++ movi r13,0 // remainder = 0
++
++ /* Now
++ * r3 = dividend : quotient
++ * r4 = 0x25 for div, 0x24 for divu
++ * r5 = divisor
++ * r13 = remainder
++ * r14 = loop counter (already initialized to 32)
++ * r17 = MSB contains sign of quotient
++ */
++
++
++ /*
++ * for (count = 32; count > 0; --count)
++ * {
++ */
++divide_loop:
++
++ /*
++ * Division:
++ *
++ * (remainder:dividend:quotient) <<= 1;
++ */
++ slli r13,r13,1
++ cmplt r7,r3,zero // r7 = MSB of r3
++ or r13,r13,r7
++ slli r3,r3,1
++
++
++ /*
++ * if (remainder >= divisor)
++ * {
++ * set LSB of quotient
++ * remainder -= divisor;
++ * }
++ */
++ bltu r13,r5,div_skip
++ ori r3,r3,1
++ sub r13,r13,r5
++div_skip:
++
++ /*
++ * }
++ */
++ subi r14,r14,1
++ bne r14,zero,divide_loop
++
++
++ /* Now
++ * r3 = quotient
++ * r4 = 0x25 for div, 0x24 for divu
++ * r6 = 4*C
++ * r17 = MSB contains sign of quotient
++ */
++
++
++ /*
++ * Conditionally negate signed quotient. If quotient is unsigned,
++ * the sign already is initialized to 0.
++ */
++ bge r17,zero,quotient_is_nonnegative
++ sub r3,zero,r3 // -r3
++quotient_is_nonnegative:
++
++
++ /*
++ * Final quotient is in r3.
++ */
++ add r6,r6,sp
++ stw r3,0(r6) // write quotient to stack
++ br restore_registers
++
++
++
++
++ /* MULTIPLICATION
++ *
++ * A "product" is the number that one gets by summing a "multiplicand"
++ * several times. The "multiplier" specifies the number of copies of the
++ * multiplicand that are summed.
++ *
++ * Actual multiplication algorithms don't use repeated addition, however.
++ * Shift-and-add algorithms get the same answer as repeated addition, and
++ * they are faster. To compute the lower half of a product (pppp below)
++ * one shifts the product left before adding in each of the partial products
++ * (a * mmmm) through (d * mmmm).
++ *
++ * To compute the upper half of a product (PPPP below), one adds in the
++ * partial products (d * mmmm) through (a * mmmm), each time following the
++ * add by a right shift of the product.
++ *
++ * mmmm
++ * * abcd
++ * ------
++ * #### = d * mmmm
++ * #### = c * mmmm
++ * #### = b * mmmm
++ * #### = a * mmmm
++ * --------
++ * PPPPpppp
++ *
++ * The example above shows 4 partial products. Computing actual Nios II
++ * products requires 32 partials.
++ *
++ * It is possible to compute the result of mulxsu from the result of mulxuu
++ * because the only difference between the results of these two opcodes is
++ * the value of the partial product associated with the sign bit of rA.
++ *
++ * mulxsu = mulxuu - (rA < 0) ? rB : 0;
++ *
++ * It is possible to compute the result of mulxss from the result of mulxsu
++ * because the only difference between the results of these two opcodes is
++ * the value of the partial product associated with the sign bit of rB.
++ *
++ * mulxss = mulxsu - (rB < 0) ? rA : 0;
++ *
++ */
++
++mul_immed:
++ // Opcode is muli. Change it into mul for remainder of algorithm.
++ mov r6,r5 // Field B is dest register, not field C.
++ mov r5,r4 // Field IMM16 is src2, not field B.
++ movi r4,0x27 // OPX of mul is 0x27
++
++multiply:
++ // Initialize the multiplication loop.
++ movi r9,0 // mul_product = 0
++ movi r10,0 // mulxuu_product = 0
++ mov r11,r5 // save original multiplier for mulxsu and mulxss
++ mov r12,r5 // mulxuu_multiplier (will be shifted)
++ movi r16,1 // used to create "rori B,A,1" from "ror B,A,r16"
++
++ /* Now
++ * r3 = multiplicand
++ * r5 = mul_multiplier
++ * r6 = 4 * dest_register (used later as offset to sp)
++ * r7 = temp
++ * r9 = mul_product
++ * r10 = mulxuu_product
++ * r11 = original multiplier
++ * r12 = mulxuu_multiplier
++ * r14 = loop counter (already initialized)
++ * r16 = 1
++ */
++
++
++ /*
++ * for (count = 32; count > 0; --count)
++ * {
++ */
++multiply_loop:
++
++ /*
++ * mul_product <<= 1;
++ * lsb = multiplier & 1;
++ */
++ slli r9,r9,1
++ andi r7,r12,1
++
++ /*
++ * if (lsb == 1)
++ * {
++ * mulxuu_product += multiplicand;
++ * }
++ */
++ beq r7,zero,mulx_skip
++ add r10,r10,r3
++ cmpltu r7,r10,r3 // Save the carry from the MSB of mulxuu_product.
++ ror r7,r7,r16 // r7 = 0x80000000 on carry, or else 0x00000000
++mulx_skip:
++
++ /*
++ * if (MSB of mul_multiplier == 1)
++ * {
++ * mul_product += multiplicand;
++ * }
++ */
++ bge r5,zero,mul_skip
++ add r9,r9,r3
++mul_skip:
++
++ /*
++ * mulxuu_product >>= 1; logical shift
++ * mul_multiplier <<= 1; done with MSB
++ * mulx_multiplier >>= 1; done with LSB
++ */
++ srli r10,r10,1
++ or r10,r10,r7 // OR in the saved carry bit.
++ slli r5,r5,1
++ srli r12,r12,1
++
++
++ /*
++ * }
++ */
++ subi r14,r14,1
++ bne r14,zero,multiply_loop
++
++
++ /*
++ * Multiply emulation loop done.
++ */
++
++ /* Now
++ * r3 = multiplicand
++ * r4 = OPX
++ * r6 = 4 * dest_register (used later as offset to sp)
++ * r7 = temp
++ * r9 = mul_product
++ * r10 = mulxuu_product
++ * r11 = original multiplier
++ */
++
++
++ // Calculate address for result from 4 * dest_register
++ add r6,r6,sp
++
++
++ /*
++ * Select/compute the result based on OPX.
++ */
++
++
++ // OPX == mul? Then store.
++ xori r7,r4,0x27
++ beq r7,zero,store_product
++
++ // It's one of the mulx.. opcodes. Move over the result.
++ mov r9,r10
++
++ // OPX == mulxuu? Then store.
++ xori r7,r4,0x07
++ beq r7,zero,store_product
++
++ // Compute mulxsu
++ //
++ // mulxsu = mulxuu - (rA < 0) ? rB : 0;
++ //
++ bge r3,zero,mulxsu_skip
++ sub r9,r9,r11
++mulxsu_skip:
++
++ // OPX == mulxsu? Then store.
++ xori r7,r4,0x17
++ beq r7,zero,store_product
++
++ // Compute mulxss
++ //
++ // mulxss = mulxsu - (rB < 0) ? rA : 0;
++ //
++ bge r11,zero,mulxss_skip
++ sub r9,r9,r3
++mulxss_skip:
++ // At this point, assume that OPX is mulxss, so store
++
++
++store_product:
++ stw r9,0(r6)
++
++
++restore_registers:
++ // No need to restore r0.
++ ldw r1, 4(sp)
++ ldw r2, 8(sp)
++ ldw r3, 12(sp)
++ ldw r4, 16(sp)
++ ldw r5, 20(sp)
++ ldw r6, 24(sp)
++ ldw r7, 28(sp)
++ ldw r8, 32(sp)
++ ldw r9, 36(sp)
++ ldw r10, 40(sp)
++ ldw r11, 44(sp)
++ ldw r12, 48(sp)
++ ldw r13, 52(sp)
++ ldw r14, 56(sp)
++ ldw r15, 60(sp)
++ ldw r16, 64(sp)
++ ldw r17, 68(sp)
++ ldw r18, 72(sp)
++ ldw r19, 76(sp)
++ ldw r20, 80(sp)
++ ldw r21, 84(sp)
++ ldw r22, 88(sp)
++ ldw r23, 92(sp)
++ ldw et, 96(sp)
++ ldw bt, 100(sp)
++ ldw gp, 104(sp)
++ // Don't corrupt sp.
++ ldw fp, 112(sp)
++ // Don't corrupt ea.
++ ldw ba, 120(sp)
++ ldw ra, 124(sp)
++ addi sp, sp, 128
++ eret
++
++.set at
++.set break
++
+diff --git a/arch/nios2nommu/kernel/head.S b/arch/nios2nommu/kernel/head.S
+new file mode 100644
+index 0000000..f1cba65
+--- /dev/null
++++ b/arch/nios2nommu/kernel/head.S
+@@ -0,0 +1,228 @@
++/*
++ * head.S for Altera's Excalibur development board with nios processor
++ *
++ * (c) Vic Phillips, Microtronix Datacom Ltd., 2001
++ * (C) Copyright 2004 Microtronix Datacom Ltd
++ *
++ * Based on the following from the Excalibur sdk distribution:
++ * NA_MemoryMap.s, NR_JumpToStart.s, NR_Setup.s, NR_CWPManager.s
++ *
++ * This program is free software; you can redistribute it and/or modify it under
++ * the terms of the GNU General Public License as published by the Free
++ * Software Foundation; either version 2 of the License, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, write to the Free Software Foundation, Inc., 675
++ * Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <asm/asm-offsets.h>
++#include <asm/asm-macros.h>
++
++
++#ifdef CONFIG_CRC_CHECK
++/**********************************************/
++/* Define where the CRC table lives in flash. */
++/* The __CRC_Sector_Size is the flash sector */
++/* size for the address range. */
++/**********************************************/
++
++ GEQU __CRC_Table_Begin,(na_flash)+0x4000 /* Second sector of main board flash */
++ GEQU __CRC_Sector_Size,0x2000
++#endif
++
++/*
++ * This global variable is used as an extension to the nios'
++ * STATUS register to emulate a user/supervisor mode.
++ */
++ .data
++ .align 2
++ .set noat
++ .global status_extension
++status_extension:
++ .long 0
++
++ .global _current_thread
++_current_thread:
++ .long 0
++/*
++ * Input(s): passed from u-boot
++ * r4 - Optional pointer to a board information structure.
++ * r5 - Optional pointer to the physical starting address of the init RAM
++ * disk.
++ * r6 - Optional pointer to the physical ending address of the init RAM
++ * disk.
++ * r7 - Optional pointer to the physical starting address of any kernel
++ * command-line parameters.
++ */
++
++/*
++ * First executable code - detected and jumped to by the ROM bootstrap
++ * if the code resides in flash (looks for "Nios" at offset 0x0c from
++ * the potential executable image).
++ */
++ .text
++ .global _start
++_start:
++ wrctl status,r0 /* Disable interrupts */
++
++ /* Flush all cache lines within the instruction cache */
++
++ movia r1,NIOS2_ICACHE_SIZE
++ movui r2,NIOS2_ICACHE_LINE_SIZE
++
++text_flush:
++ flushi r1
++ sub r1,r1,r2
++ bgt r1,r0,text_flush
++ br 1f
++
++ /* This is the default location for the exception
++ * handler. Code in jump to our handler
++ */
++
++ movia r24,inthandler
++ jmp r24
++1:
++ /*
++ * After flushing the instruction cache, we must flush the data
++ * cache.
++ */
++
++ movia r1,NIOS2_DCACHE_SIZE
++ movi r2,NIOS2_DCACHE_LINE_SIZE
++
++data_flush:
++ flushd 0(r1)
++ sub r1,r1,r2
++ bgt r1,r0,data_flush
++
++NR_MoveStart:
++#ifdef CONFIG_BREAK_ON_START
++ break
++#endif //CONFIG_BREAK_ON_START
++ nextpc r1 /* Find out where we are */
++chkadr:
++ movia r2,chkadr
++ beq r1,r2,finish_move /* We are running in RAM done */
++ addi r1,r1,(_start - chkadr) /* Source */
++ movia r2,_start /* Destination */
++ movia r3,__bss_start /* End of copy */
++
++loop_move: // r1: src, r2: dest, r3: last dest
++ ldw r8,0(r1) // load a word from [r1]
++ stw r8,0(r2) // stort a word to dest [r2]
++ flushd 0(r2) // Flush cache for safty
++ addi r1,r1,4 // inc the src addr
++ addi r2,r2,4 // inc the dest addr
++ blt r2,r3,loop_move
++
++ movia r1,finish_move // VMA(_start)->l1
++ jmp r1 // jmp to _start
++
++finish_move:
++
++ //------------------------------------
++ // Disable interrupts on known devices
++ //
++#ifdef NA_ENET_ASM
++#ifdef NA_ENET_RESET_ASM
++ movia r1,NA_ENET_RESET_ASM // ethernet reset address
++ stwio r0,0(r1) // reset
++#endif
++#ifdef NA_ENET_RESET_N_ASM
++ movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
++ stwio r0,0(r1) // reset
++#endif
++ nop // give it some time
++ nop //
++ nop //
++ nop //
++#endif
++#ifdef NA_TIMER0_ASM
++ movia r1,NA_TIMER0_ASM // get timer address
++ stwio r0,NP_TIMERCONTROL_ASM(r1) // clear interrupt enable
++ stwio r0,NP_TIMERSTATUS_ASM(r1) // clear interrupt condition
++#endif
++#ifdef NA_UART0_ASM
++ movia r1,NA_UART0_ASM
++ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
++ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
++#endif
++#ifdef NA_UART1_ASM
++ movia r1,NA_UART1_ASM
++ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
++ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
++#endif
++#ifdef NA_UART2_ASM
++ movia r1,NA_UART2_ASM
++ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
++ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
++#endif
++#ifdef NA_UART3_ASM
++ movia r1,NA_UART3_ASM
++ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
++ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
++#endif
++#ifdef NA_IDE_INTERFACE_ASM
++ movia r1,NA_IDE_INTERFACE_ASM // ATA reset
++ stwio r0,0(r1) // write to control register
++#endif
++#ifdef NA_ENET_ASM
++#ifdef NA_ENET_RESET_ASM
++ movia r1,NA_ENET_RESET_ASM // ethernet reset address
++ movui r2,1 // reset
++ stwio r2,0(r1) //
++#endif
++#ifdef NA_ENET_RESET_N_ASM
++ movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
++ movui r2,1 // reset
++ stwio r2,0(r1) //
++#endif
++#endif
++ wrctl ienable,r0 // Mask off all possible interrupts
++
++ //------------------------------------------------------
++ // Zero out the .bss segment (uninitialized common data)
++ //
++ movia r2,__bss_start // presume nothing is between
++ movia r1,_end // the .bss and _end.
++1:
++ stb r0,0(r2)
++ addi r2,r2,1
++ bne r1,r2,1b
++
++ //------------------------------------------------------
++ // Call main() with interrupts disabled
++ //
++ movia r1,status_extension // get the STATUS extension address
++ movi r2,PS_S_ASM // set initial mode = supervisor
++ stw r2,0(r1)
++
++ movia r1,init_thread_union // set stack at top of the task union
++ addi sp,r1,THREAD_SIZE_ASM
++ movia r2,_current_thread // Remember current thread
++ stw r1,0(r2)
++
++ movia r1,nios2_boot_init // save args r4-r7 passed from u-boot
++ callr r1
++
++ movia r1,main // call main as a subroutine
++ callr r1
++
++ //------------------------------------------------------------------
++ // If we return from main, break to the oci debugger and buggered we are
++ //
++ break
++
++ /* End of startup code */
++.set at
++
++
+diff --git a/arch/nios2nommu/kernel/init_task.c b/arch/nios2nommu/kernel/init_task.c
+new file mode 100644
+index 0000000..867e8fb
+--- /dev/null
++++ b/arch/nios2nommu/kernel/init_task.c
+@@ -0,0 +1,69 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/init_task.c
++ *
++ * Ported from arch/m68knommu/kernel/init_task.c
++ *
++ * Copyright (C) 2003, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <linux/mm.h>
++#include <linux/module.h>
++#include <linux/sched.h>
++#include <linux/init.h>
++#include <linux/init_task.h>
++#include <linux/fs.h>
++#include <linux/mqueue.h>
++
++#include <asm/uaccess.h>
++#include <asm/pgtable.h>
++
++static struct fs_struct init_fs = INIT_FS;
++static struct files_struct init_files = INIT_FILES;
++static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
++static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
++struct mm_struct init_mm = INIT_MM(init_mm);
++
++EXPORT_SYMBOL(init_mm);
++
++/*
++ * Initial task structure.
++ *
++ * All other task structs will be allocated on slabs in fork.c
++ */
++__asm__(".align 2");
++struct task_struct init_task = INIT_TASK(init_task);
++
++
++/*
++ * Initial thread structure.
++ *
++ * We need to make sure that this is 8192-byte aligned due to the
++ * way process stacks are handled. This is done by having a special
++ * "init_task" linker map entry..
++ */
++union thread_union init_thread_union
++ __attribute__((__section__(".data.init_task"))) =
++ { INIT_THREAD_INFO(init_task) };
++
+diff --git a/arch/nios2nommu/kernel/io.c b/arch/nios2nommu/kernel/io.c
+new file mode 100644
+index 0000000..e1b0b12
+--- /dev/null
++++ b/arch/nios2nommu/kernel/io.c
+@@ -0,0 +1,143 @@
++/*--------------------------------------------------------------------
++ *
++ * Optimized IO string functions.
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/io.h>
++
++void insl(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned long read32;
++
++ if ((unsigned long)dst & 2){
++ /* Unaligned destination pointer, need to do
++ * two 16 bit writes for each read.
++ */
++ unsigned short *p=(unsigned short*)dst;
++ while (count--){
++ read32 = inl(port);
++ *p++ = read32 & 0xFFFF;
++ *p++ = read32 >> 16;
++ }
++ }
++ else {
++ unsigned long *p=(unsigned long*)dst;
++ while (count--)
++ *p++ = inl(port);
++ }
++}
++
++void insw(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned long dst1=(unsigned long)dst;
++ if (count > 8) {
++ /* Long word align buffer ptr */
++ if (dst1 & 2) {
++ *(unsigned short*)dst1 = inw(port);
++ dst1 += sizeof(unsigned short);
++ count--;
++ }
++
++ /* Input pairs of short and store as longs */
++ while (count >= 8) {
++ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
++ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
++ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
++ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
++ count -= 8;
++ }
++ }
++
++ /* Input remaining shorts */
++ while (count--) {
++ *((unsigned short *)dst1) = inw(port);
++ dst1 += sizeof(unsigned short);
++ }
++}
++
++
++void outsl(unsigned long port, void *src, unsigned long count)
++{
++ unsigned long src1=(unsigned long)src;
++ unsigned long write32;
++
++ if (src1 & 2){
++ /* Unaligned source pointer, need to read
++ * two 16 bit shorts before writing to register.
++ */
++ while (count--){
++ write32 = *(unsigned short *)src1;
++ src1+=sizeof(unsigned short);
++ write32 |= *((unsigned short *)src1) << 16;
++ src1+=sizeof(unsigned short);
++ outl(write32,port);
++ }
++ }
++ else {
++ while (count--) {
++ outl(*(unsigned long *)src1,port);
++ src1+=sizeof(unsigned long);
++ }
++ }
++}
++
++void outsw(unsigned long port, void *src, unsigned long count)
++{
++ unsigned int lw;
++ unsigned long src1=(unsigned long)src;
++
++ if (count > 8) {
++ /* Long word align buffer ptr */
++ if (src1 & 2) {
++ outw( *(unsigned short *)src1, port );
++ count--;
++ src1 += sizeof(unsigned short);
++ }
++
++ /* Read long words and output as pairs of short */
++ while (count >= 8) {
++ lw = *(unsigned long *)src1;
++ src1+=sizeof(unsigned long);
++ outw(lw, port);
++ outw((lw >> 16), port);
++ lw = *(unsigned long *)src1;
++ src1+=sizeof(unsigned long);
++ outw(lw, port);
++ outw((lw >> 16), port);
++ lw = *(unsigned long *)src1;
++ src1+=sizeof(unsigned long);
++ outw(lw, port);
++ outw((lw >> 16), port);
++ lw = *(unsigned long *)src1;
++ src1+=sizeof(unsigned long);
++ outw(lw, port);
++ outw((lw >> 16), port);
++ count -= 8;
++ }
++ }
++
++ /* Output remaining shorts */
++ while (count--) {
++ outw( *(unsigned short *)src1, port );
++ src1 += sizeof(unsigned short);
++ }
++}
+diff --git a/arch/nios2nommu/kernel/irq.c b/arch/nios2nommu/kernel/irq.c
+new file mode 100644
+index 0000000..f1b2347
+--- /dev/null
++++ b/arch/nios2nommu/kernel/irq.c
+@@ -0,0 +1,245 @@
++/*
++ * linux/arch/$(ARCH)/irq.c -- general exception handling code
++ *
++ * Cloned from Linux/m68k.
++ *
++ * No original Copyright holder listed,
++ * Probabily original (C) Roman Zippel (assigned DJD, 1999)
++ *
++ * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file COPYING in the main directory of this archive
++ * for more details.
++ */
++
++#include <linux/types.h>
++#include <linux/module.h>
++#include <linux/sched.h>
++#include <linux/kernel_stat.h>
++#include <linux/errno.h>
++#include <linux/init.h>
++#include <linux/seq_file.h>
++
++#include <asm/system.h>
++#include <asm/irq.h>
++#include <asm/page.h>
++#include <asm/nios.h>
++#include <asm/hardirq.h>
++
++/* table for system interrupt handlers */
++irq_hand_t irq_list[NR_IRQS];
++
++/* The number of spurious interrupts */
++volatile unsigned int num_spurious;
++
++#define NUM_IRQ_NODES 16
++static irq_node_t nodes[NUM_IRQ_NODES];
++
++void __init init_irq_proc(void)
++{
++ /* Insert /proc/irq driver here */
++}
++
++static irqreturn_t default_irq_handler(int irq, void *ptr)
++{
++#if 1
++ printk(KERN_INFO "%s(%d): default irq handler vec=%d [0x%x]\n",
++ __FILE__, __LINE__, irq, irq);
++#endif
++ disable_irq(irq);
++ return(IRQ_NONE);
++}
++
++/*
++ * void init_IRQ(void)
++ *
++ * Parameters: None
++ *
++ * Returns: Nothing
++ *
++ * This function should be called during kernel startup to initialize
++ * the IRQ handling routines.
++ */
++
++void __init init_IRQ(void)
++{
++ int i;
++
++ for (i = 0; i < NR_IRQS; i++) {
++ irq_list[i].handler = default_irq_handler;
++ irq_list[i].flags = IRQ_FLG_STD;
++ irq_list[i].dev_id = NULL;
++ irq_list[i].devname = NULL;
++ }
++
++ for (i = 0; i < NUM_IRQ_NODES; i++)
++ nodes[i].handler = NULL;
++
++ /* turn off all interrupts */
++ clrimr(0);
++
++#ifdef DEBUG
++ printk("init_IRQ done\n");
++#endif
++}
++
++irq_node_t *new_irq_node(void)
++{
++ irq_node_t *node;
++ short i;
++
++ for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
++ if (!node->handler)
++ return node;
++
++ printk (KERN_INFO "new_irq_node: out of nodes\n");
++ return NULL;
++}
++
++int request_irq(unsigned int irq,
++ irq_handler_t handler,
++ unsigned long flags,
++ const char *devname,
++ void *dev_id)
++{
++ if (irq >= NR_IRQS) {
++ printk (KERN_ERR "%s: Unknown IRQ %d from %s\n", __FUNCTION__, irq, devname);
++ return -ENXIO;
++ }
++
++ if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
++ if (irq_list[irq].flags & IRQ_FLG_LOCK) {
++ printk(KERN_ERR "%s: IRQ %d from %s is not replaceable\n",
++ __FUNCTION__, irq, irq_list[irq].devname);
++ return -EBUSY;
++ }
++ if (flags & IRQ_FLG_REPLACE) {
++ printk(KERN_ERR "%s: %s can't replace IRQ %d from %s\n",
++ __FUNCTION__, devname, irq, irq_list[irq].devname);
++ return -EBUSY;
++ }
++ }
++ irq_list[irq].handler = handler;
++ irq_list[irq].flags = flags;
++ irq_list[irq].dev_id = dev_id;
++ irq_list[irq].devname = devname;
++
++ setimr(1<<irq);
++
++ return 0;
++}
++
++void free_irq(unsigned int irq, void *dev_id)
++{
++ if (irq >= NR_IRQS) {
++ printk (KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
++ return;
++ }
++
++ if (irq_list[irq].dev_id != dev_id)
++ printk(KERN_ERR "%s: Removing probably wrong IRQ %d from %s\n",
++ __FUNCTION__, irq, irq_list[irq].devname);
++
++ irq_list[irq].handler = default_irq_handler;
++ irq_list[irq].flags = IRQ_FLG_STD;
++ irq_list[irq].dev_id = NULL;
++ irq_list[irq].devname = NULL;
++
++ clrimr(~(1<<irq));
++}
++
++/* usually not useful in embedded systems */
++unsigned long probe_irq_on (void)
++{
++ return 0;
++}
++
++int probe_irq_off (unsigned long irqs)
++{
++ return 0;
++}
++
++void enable_irq(unsigned int irq)
++{
++ setimr(1<<irq);
++}
++
++void disable_irq(unsigned int irq)
++{
++ clrimr(~(1<<irq));
++}
++
++int show_interrupts(struct seq_file *p, void *v)
++{
++ int i = *(loff_t *) v;
++
++ if (i == 0) {
++ seq_printf(p, " : %10u spurious\n", num_spurious);
++ }
++
++ if ((i < NR_IRQS) && (!(irq_list[i].flags & IRQ_FLG_STD))) {
++ seq_printf(p, "%3d: %10u ", i, kstat_cpu(0).irqs[i]);
++ if (irq_list[i].flags & IRQ_FLG_LOCK)
++ seq_printf(p, "L ");
++ else
++ seq_printf(p, " ");
++ seq_printf(p, "%s\n", irq_list[i].devname);
++ }
++
++ return 0;
++}
++
++#ifdef CONFIG_PREEMPT_TIMES
++extern void latency_cause(int,int);
++#else
++#define latency_cause(a, b)
++#endif
++asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
++{
++
++ /* give the machine specific code a crack at it first */
++ irq_enter();
++ kstat_cpu(0).irqs[vec]++;
++ latency_cause(-99,~vec);
++
++ if (irq_list[vec].handler) {
++ if ((irq_list[vec].handler(vec, irq_list[vec].dev_id))==IRQ_NONE)
++ ;
++ } else
++#ifdef DEBUG
++ {
++ printk(KERN_ERR "No interrupt handler for level %ld\n", vec);
++//// asm("trap 5");
++ }
++#else
++ #if 1
++ printk(KERN_ERR "Ignoring interrupt %ld: no handler\n", vec);
++ #else
++ panic("No interrupt handler for level %ld\n", vec);
++ #endif
++#endif
++
++ irq_exit();
++}
++
++int get_irq_list(char *buf)
++{
++ int i, len = 0;
++
++ /* autovector interrupts */
++ for (i = 0; i < NR_IRQS; i++) {
++ if (irq_list[i].handler) {
++ len += sprintf(buf+len, "auto %2d: %10u ", i,
++ i ? kstat_cpu(0).irqs[i] : num_spurious);
++ if (irq_list[i].flags & IRQ_FLG_LOCK)
++ len += sprintf(buf+len, "L ");
++ else
++ len += sprintf(buf+len, " ");
++ len += sprintf(buf+len, "%s\n", irq_list[i].devname);
++ }
++ }
++ return len;
++}
++EXPORT_SYMBOL(request_irq);
++EXPORT_SYMBOL(free_irq);
+diff --git a/arch/nios2nommu/kernel/module.c b/arch/nios2nommu/kernel/module.c
+new file mode 100644
+index 0000000..99b270f
+--- /dev/null
++++ b/arch/nios2nommu/kernel/module.c
+@@ -0,0 +1,173 @@
++/* Kernel module help for Nios2.
++ Copyright (C) 2004 Microtronix Datacom Ltd.
++ Copyright (C) 2001,03 Rusty Russell
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++ Written by Wentao Xu <xuwentao@microtronix.com>
++*/
++#include <linux/moduleloader.h>
++#include <linux/elf.h>
++#include <linux/vmalloc.h>
++#include <linux/fs.h>
++#include <linux/string.h>
++#include <linux/kernel.h>
++
++#if 0
++#define DEBUGP printk
++#else
++#define DEBUGP(fmt , ...)
++#endif
++
++void *module_alloc(unsigned long size)
++{
++ if (size == 0)
++ return NULL;
++ return vmalloc(size);
++}
++
++
++/* Free memory returned from module_alloc */
++void module_free(struct module *mod, void *module_region)
++{
++ vfree(module_region);
++ /* FIXME: If module_region == mod->init_region, trim exception
++ table entries. */
++}
++
++/* We don't need anything special. */
++int module_frob_arch_sections(Elf_Ehdr *hdr,
++ Elf_Shdr *sechdrs,
++ char *secstrings,
++ struct module *mod)
++{
++ return 0;
++}
++
++int apply_relocate(Elf32_Shdr *sechdrs,
++ const char *strtab,
++ unsigned int symindex,
++ unsigned int relsec,
++ struct module *me)
++{
++ printk(KERN_ERR "module %s: NO-ADD RELOCATION unsupported\n",
++ me->name);
++ return -ENOEXEC;
++}
++
++
++int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab,
++ unsigned int symindex, unsigned int relsec,
++ struct module *mod)
++{
++ unsigned int i;
++ Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
++
++ DEBUGP ("Applying relocate section %u to %u\n", relsec,
++ sechdrs[relsec].sh_info);
++
++ for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {
++ /* This is where to make the change */
++ uint32_t word;
++ uint32_t *loc
++ = ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
++ + rela[i].r_offset);
++ /* This is the symbol it is referring to. Note that all
++ undefined symbols have been resolved. */
++ Elf32_Sym *sym
++ = ((Elf32_Sym *)sechdrs[symindex].sh_addr
++ + ELF32_R_SYM (rela[i].r_info));
++ uint32_t v = sym->st_value + rela[i].r_addend;
++
++ switch (ELF32_R_TYPE (rela[i].r_info)) {
++ case R_NIOS2_NONE:
++ break;
++
++ case R_NIOS2_BFD_RELOC_32:
++ *loc += v;
++ break;
++
++ case R_NIOS2_PCREL16:
++ v -= (uint32_t)loc + 4;
++ if ((int32_t)v > 0x7fff ||
++ (int32_t)v < -(int32_t)0x8000) {
++ printk(KERN_ERR
++ "module %s: relocation overflow\n",
++ mod->name);
++ return -ENOEXEC;
++ }
++ word = *loc;
++ *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) | (word & 0x3f);
++ break;
++
++ case R_NIOS2_CALL26:
++ if (v & 3) {
++ printk(KERN_ERR
++ "module %s: dangerous relocation\n",
++ mod->name);
++ return -ENOEXEC;
++ }
++ if ((v >> 28) != ((uint32_t)loc >> 28)) {
++ printk(KERN_ERR
++ "module %s: relocation overflow\n",
++ mod->name);
++ return -ENOEXEC;
++ }
++ *loc = (*loc & 0x3f) | ((v >> 2) << 6);
++ break;
++
++ case R_NIOS2_HI16:
++ word = *loc;
++ *loc = ((((word >> 22) << 16) | ((v >>16) & 0xffff)) << 6) |
++ (word & 0x3f);
++ break;
++
++ case R_NIOS2_LO16:
++ word = *loc;
++ *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
++ (word & 0x3f);
++ break;
++
++ case R_NIOS2_HIADJ16:
++ {
++ Elf32_Addr word2;
++
++ word = *loc;
++ word2 = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
++ *loc = ((((word >> 22) << 16) | word2) << 6) |
++ (word & 0x3f);
++ }
++ break;
++
++ default:
++ printk (KERN_ERR "module %s: Unknown reloc: %u\n",
++ mod->name, ELF32_R_TYPE (rela[i].r_info));
++ return -ENOEXEC;
++ }
++ }
++
++ return 0;
++}
++
++int module_finalize(const Elf_Ehdr *hdr,
++ const Elf_Shdr *sechdrs,
++ struct module *me)
++{
++ return 0;
++}
++
++void module_arch_cleanup(struct module *mod)
++{
++}
+diff --git a/arch/nios2nommu/kernel/nios2_ksyms.c b/arch/nios2nommu/kernel/nios2_ksyms.c
+new file mode 100644
+index 0000000..720f007
+--- /dev/null
++++ b/arch/nios2nommu/kernel/nios2_ksyms.c
+@@ -0,0 +1,113 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/nios_ksyms.c
++ *
++ * Derived from Nios1
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * vic - copied from v850
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++//;dgt2;tmp;
++
++#include <linux/module.h>
++#include <linux/linkage.h>
++#include <linux/sched.h>
++#include <linux/string.h>
++#include <linux/mm.h>
++#include <linux/user.h>
++#include <linux/elfcore.h>
++#include <linux/in6.h>
++#include <linux/interrupt.h>
++
++#include <asm/setup.h>
++#include <asm/pgalloc.h>
++#include <asm/irq.h>
++#include <asm/io.h>
++#include <asm/semaphore.h>
++#include <asm/checksum.h>
++#include <asm/hardirq.h>
++#include <asm/current.h>
++
++extern void dump_thread(struct pt_regs *, struct user *);
++/* platform dependent support */
++
++EXPORT_SYMBOL(__ioremap);
++EXPORT_SYMBOL(iounmap);
++EXPORT_SYMBOL(dump_fpu);
++EXPORT_SYMBOL(dump_thread);
++
++EXPORT_SYMBOL(kernel_thread);
++
++/* Networking helper routines. */
++EXPORT_SYMBOL(csum_partial_copy);
++
++EXPORT_SYMBOL(memcpy);
++EXPORT_SYMBOL(memset);
++EXPORT_SYMBOL(memmove);
++
++EXPORT_SYMBOL(__down);
++EXPORT_SYMBOL(__down_interruptible);
++EXPORT_SYMBOL(__down_trylock);
++EXPORT_SYMBOL(__up);
++
++EXPORT_SYMBOL(get_wchan);
++
++/*
++ * libgcc functions - functions that are used internally by the
++ * compiler... (prototypes are not correct though, but that
++ * doesn't really matter since they're not versioned).
++ */
++extern void __gcc_bcmp(void);
++extern void __ashldi3(void);
++extern void __ashrdi3(void);
++extern void __cmpdi2(void);
++extern void __divdi3(void);
++extern void __divsi3(void);
++extern void __lshrdi3(void);
++extern void __moddi3(void);
++extern void __modsi3(void);
++extern void __muldi3(void);
++extern void __mulsi3(void);
++extern void __negdi2(void);
++extern void __ucmpdi2(void);
++extern void __udivdi3(void);
++extern void __udivmoddi4(void);
++extern void __udivsi3(void);
++extern void __umoddi3(void);
++extern void __umodsi3(void);
++
++ /* gcc lib functions */
++EXPORT_SYMBOL(__gcc_bcmp);
++EXPORT_SYMBOL(__ashldi3);
++EXPORT_SYMBOL(__ashrdi3);
++EXPORT_SYMBOL(__cmpdi2);
++EXPORT_SYMBOL(__divdi3);
++EXPORT_SYMBOL(__divsi3);
++EXPORT_SYMBOL(__lshrdi3);
++EXPORT_SYMBOL(__moddi3);
++EXPORT_SYMBOL(__modsi3);
++EXPORT_SYMBOL(__muldi3);
++EXPORT_SYMBOL(__mulsi3);
++EXPORT_SYMBOL(__negdi2);
++EXPORT_SYMBOL(__ucmpdi2);
++EXPORT_SYMBOL(__udivdi3);
++EXPORT_SYMBOL(__udivmoddi4);
++EXPORT_SYMBOL(__udivsi3);
++EXPORT_SYMBOL(__umoddi3);
++EXPORT_SYMBOL(__umodsi3);
+diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.c b/arch/nios2nommu/kernel/nios_gdb_stub.c
+new file mode 100644
+index 0000000..103925b
+--- /dev/null
++++ b/arch/nios2nommu/kernel/nios_gdb_stub.c
+@@ -0,0 +1,1456 @@
++// Modified for uClinux - Vic - Apr 2002
++// From:
++
++// File: nios_gdb_stub.c
++// Date: 2000 June 20
++// Author dvb \ Altera Santa Cruz
++
++#ifndef __KERNEL__
++#include "nios.h"
++#else
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <asm/nios.h>
++#endif
++
++#include "nios_gdb_stub.h"
++
++#define na_debug_peripheral_irq 8
++
++enum
++{
++ na_BreakpointTrap = 3,
++ na_SingleStepTrap = 4,
++ na_StartGDBTrap = 5
++};
++
++
++#ifdef __KERNEL__
++
++extern int _etext;
++
++static void puts( unsigned char *s )
++{
++ while(*s) {
++ while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask));
++ nasys_printf_uart->np_uarttxdata = *s++;
++ }
++}
++
++#endif // __KERNEL__
++
++// --------------------------------
++// Local Prototypes
++
++#if GDB_DEBUG_PRINT
++
++static void StringFit(char *s,int w);
++
++// --------------------------------
++// Debugging The Debugger
++
++void GDB_RawMessage(char *s)
++ {
++ StringFit(s,32);
++ nr_pio_lcdwritescreen(s);
++ }
++#else
++ #define GDB_RawMessage(a,b,c) // define away to nothing
++#endif
++
++#if GDB_DEBUG_PRINT
++void GDB_Print2(char *s,int n1,int n2)
++ {
++ char st[1000];
++
++ sprintf(st,s,n1,n2);
++ GDB_RawMessage(st);
++ }
++#else
++ #define GDB_Print2(a,b,c) // define away to nothing
++#endif
++
++// If string is longer than w, cut out the middle.
++
++#if GDB_DEBUG_PRINT
++int StringLen(char *s)
++ {
++ int l = 0;
++
++ while(*s++)
++ l++;
++ return l;
++ }
++
++static void StringFit(char *s,int w)
++ {
++ if(StringLen(s) > w)
++ {
++ int i;
++
++
++ w = w / 2;
++
++ for(i = 0; i < w; i++)
++ {
++ s[i + w] = s[StringLen(s) - w + i];
++ }
++ s[w + w] = 0;
++ }
++ }
++#endif
++
++// ---------------------------------------------
++// Generic routines for dealing with
++// hex input, output, and parsing
++// (Adapted from other stubs.)
++
++NiosGDBGlobals gdb = {0}; // not static: the ISR uses it!
++
++static char dHexChars[16] = "0123456789abcdef";
++
++/*
++ * HexCharToValue -- convert a characters
++ * to its hex value, or -1 if not.
++ */
++char HexCharToValue(char c)
++{
++ char result=0;
++
++ if(c >= '0' && c <= '9')
++ result = c - '0';
++ else if(c >= 'a' && c <= 'f')
++ result = c - 'a' + 10;
++ else if(c >= 'A' && c <= 'F')
++ result = c - 'A' + 10;
++ else
++ result = -1;
++ return result;
++}
++
++/*
++ * HexStringToValue -- convert a 2*byte_width string of characters
++ * to its little endian hex value,
++ * or -1 if not.
++ * This routine is for strings of hex values
++ */
++unsigned long HexStringToValue(char *c, int byte_width)
++{
++ unsigned long result=0;
++ unsigned char a,b;
++ int i=0;
++
++ while (i < byte_width)
++ {
++ a = HexCharToValue(*c++);
++ if (a & 0x80) return a;
++ b = HexCharToValue(*c++);
++ if (b & 0x80) return b;
++ b = (a<<4) | (b&0x0f);
++ result |= b << (i*8);
++ i++;
++ }
++ return result;
++}
++
++/*
++ * Hex2Value -- convert a non-hex char delimited string
++ * to its big endian hex value.
++ * This routine is for address and byte count values
++ */
++
++char *Hex2Value(char *hexIn, int *valueOut)
++ {
++ char c;
++ int digitValue;
++ int value = 0;
++
++ while(1)
++ {
++ c = *hexIn;
++ digitValue = HexCharToValue(c);
++ if(digitValue < 0)
++ {
++ *valueOut = value;
++ return hexIn;
++ }
++ hexIn++;
++ value = (value << 4) + digitValue;
++ }
++ }
++
++/*
++ * HexToMem -- convert a string to a specified
++ * number of bytes in memory.
++ *
++ * JMB -- make this thing a bit smarter so
++ * that it selects the byte width to
++ * write based on the number of bytes
++ * and the destination address alignment.
++ * This is to support writes to non-byte enabled
++ * peripheral registers...I don't like it.
++ * Beware! there are cases where it wont work
++ */
++char *HexToMem(char *hexIn, char *memOut, int memByteCount)
++{
++ int i;
++ unsigned long x;
++ short *memOutS=0;
++ long *memOutL=0;
++ int byte_width;
++
++ //determine maximum byte width
++ if (((memByteCount%2) != 0) || (((unsigned int)memOut%2) != 0))
++ byte_width = 1;
++ else if (((memByteCount % 4) != 0) || (((unsigned int)memOut % 4) != 0))
++ {
++ byte_width = 2;
++ memOutS = (short *)memOut;
++ }
++ else
++ {
++ byte_width = 4;
++ memOutL = (long *)memOut;
++ }
++ for(i = 0; i < memByteCount; i+=byte_width)
++ {
++ x = HexStringToValue(hexIn,byte_width);
++ hexIn += byte_width*2;
++ switch (byte_width)
++ {
++ case 1:
++ *memOut++ = (unsigned char) 0x000000ff & x;
++ break;
++ case 2:
++ *memOutS++ = (unsigned short) 0x0000ffff & x;
++ break;
++ case 4:
++ *memOutL++ = x;
++ break;
++ default:
++ //How could this ever happen???
++ break;
++ }
++ }
++
++ return hexIn;
++}
++
++char *MemToHex(char *memIn, char *hexOut, int memByteCount)
++{
++ int i,j;
++ int byte_width;
++ unsigned long x=0;
++ unsigned short *memInS=0;
++ unsigned long *memInL=0;
++
++ //determine maximum byte width
++ if (((memByteCount % 2) != 0) || (((unsigned int)memIn % 2) != 0))
++ byte_width = 1;
++ else if (((memByteCount % 4) != 0) || (((unsigned int)memIn % 4) != 0))
++ {
++ byte_width = 2;
++ memInS = (short *)memIn;
++ }
++ else
++ {
++ byte_width = 4;
++ memInL = (long *)memIn;
++ }
++
++ for(i = 0; i < memByteCount; i+=byte_width)
++ {
++ switch (byte_width)
++ {
++ case 1:
++ x = *memIn++;
++ break;
++ case 2:
++ x = *memInS++;
++ break;
++ case 4:
++ x = *memInL++;
++ break;
++ default:
++ //How would we get here?
++ break;
++ }
++
++ for (j=0; j<byte_width; j++)
++ {
++ *hexOut++ = dHexChars[(x&0x000000f0)>>4];
++ *hexOut++ = dHexChars[x&0x0000000f];
++ x = x>>8;
++ }
++ }
++
++ *hexOut = 0;
++
++ return hexOut;
++}
++
++//Send just the + or - to indicate
++//ACK or NACK
++void GDBPutAck (char ack)
++{
++ if (gdb.comlink == ne_gdb_serial)
++ GDBPutChar (ack);
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ else
++ {
++ if (gdb.host_ip_address != 0)
++ nr_plugs_send_to (gdb.gdb_eth_plug, &ack, 1, 0,
++ gdb.host_ip_address,
++ gdb.host_port_number);
++ }
++#endif
++#endif
++}
++
++/*
++ * Once a $ comes in, use GetGDBPacket to
++ * retrieve a full gdb packet, and verify
++ * checksum, and reply + or -.
++ */
++int GetGDBPacket(char *aBuffer)
++{
++ int checksum=0;
++ int length=0;
++ char c;
++ int x=0;
++
++ if (gdb.comlink == ne_gdb_serial)
++ {
++ while ((c = GDBGetChar ()) != '$') ;
++
++startPacket:
++ length = 0;
++ checksum = 0;
++ while(((c = GDBGetChar()) != '#') && (length < kTextBufferSize))
++ {
++ if(c == '$')
++ goto startPacket;
++ checksum += c;
++ aBuffer[length++] = c;
++ aBuffer[length] = 0;
++ }
++
++ c = GDBGetChar();
++ x = HexCharToValue(c) << 4;
++ c = GDBGetChar();
++ x += HexCharToValue(c);
++
++
++ checksum &= 0xff;
++
++ GDB_Print2("GetPacket %d",length,0);
++ }
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ else
++ {
++ int srcidx;
++ // wait till beginning of packet
++ while (gdb.textBuffer[0] != '$') nr_plugs_idle();
++startEPacket:
++ length = 0;
++ checksum = 0;
++ srcidx = 1;
++
++ //loop until packet terminator
++ //leave enough room for the checksum at the end
++ while (((c = gdb.textBuffer[srcidx++]) != '#') && (srcidx < kTextBufferSize-2))
++ {
++ if (c == '$')
++ goto startEPacket;
++
++ checksum += c;
++ aBuffer[length++] = c;
++ }
++
++ c = gdb.textBuffer[srcidx++];
++ x = HexCharToValue(c) << 4;
++ c = gdb.textBuffer[srcidx++];
++ x += HexCharToValue (c);
++
++ aBuffer[length++] = 0;
++
++ checksum &= 0xff;
++
++ GDB_Print2("GetPacket %d",length,0);
++ }
++#endif
++#endif
++
++ if(checksum != x)
++ {
++ GDBPutAck('-');
++ length = 0;
++ }
++ else
++ {
++ GDBPutAck('+');
++ }
++ return length;
++}
++
++//Wait for acknowledgement
++//Should we have some way of timing out???
++//return TRUE if ACK
++//return FALSE if NACK
++int GDBGetACK (void)
++{
++ char c;
++ if (gdb.comlink == ne_gdb_serial)
++ {
++ while (1)
++ {
++ c = GDBGetChar ();
++ if (c == '+') return (1);
++ else if (c == '-') return (0);
++ }
++
++ }
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ else
++ {
++ gdb.ACKstatus = ne_gdb_ack_waiting;
++ while (1)
++ {
++ nr_plugs_idle ();
++ if (gdb.ACKstatus == ne_gdb_ack_acked)
++ {
++ gdb.ACKstatus = ne_gdb_ack_notwaiting;
++ return (1);
++ }
++ else if (gdb.ACKstatus == ne_gdb_ack_nacked)
++ {
++ gdb.ACKstatus = ne_gdb_ack_notwaiting;
++ return (0);
++ }
++ }
++ }
++#endif
++#endif
++ return(0);
++}
++
++/*
++ * Send a packet, preceded by $,
++ * and followed by #checksum.
++ */
++void PutGDBPacket(char *aBuffer)
++{
++ int checksum;
++ char c;
++ char *origPtr;
++ int cnt=0;
++
++ origPtr = aBuffer; // Remember in case we get a NACK
++ if (gdb.comlink == ne_gdb_serial)
++ {
++startPutSerial:
++ GDBPutChar('$');
++ checksum = 0;
++ while((c = *aBuffer++) != 0)
++ {
++ checksum += c;
++ GDBPutChar(c);
++ }
++ GDBPutChar('#');
++ GDBPutChar(dHexChars[(checksum >> 4) & 15]);
++ GDBPutChar(dHexChars[checksum & 15]);
++
++ if (!GDBGetACK ())
++ {
++ aBuffer = origPtr;
++ if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
++ }
++ }
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ else
++ {
++ if (gdb.host_ip_address != 0)
++ {
++ int i;
++ int result;
++ char c1;
++
++ i = 0;
++ c = aBuffer[i];
++ if (c==0) return; //there is no data in packet, so why bother sending
++ aBuffer[i++] = '$';
++ checksum = 0;
++ do
++ {
++ checksum += c;
++ c1 = aBuffer[i];
++ aBuffer[i++] = c;
++ c = c1;
++ } while (c != 0);
++
++ aBuffer[i++] = '#';
++ aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
++ aBuffer[i++] = dHexChars[checksum & 15];
++ aBuffer[i++] = 0;
++startPutEth:
++ result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
++ gdb.host_ip_address,
++ gdb.host_port_number);
++
++ if (!GDBGetACK ())
++ {
++ if (++cnt < GDB_RETRY_CNT) goto startPutEth;
++ }
++ aBuffer[0] = 0; //clear packet to
++ }
++ }
++#endif
++#endif
++}
++
++int PutTracePacket(char *aBuffer, int size)
++{
++ int checksum;
++#ifdef ethernet_exists
++ char c;
++#endif
++ int i;
++ int cnt=0;
++
++ if (gdb.comlink == ne_gdb_serial)
++ {
++startPutSerial:
++ GDBPutChar('$');
++ checksum = 0;
++ for (i=0; i<size; i++)
++ {
++ checksum += aBuffer[i];
++ GDBPutChar (aBuffer[i]);
++ }
++ GDBPutChar('#');
++ GDBPutChar(dHexChars[(checksum >> 4) & 15]);
++ GDBPutChar(dHexChars[checksum & 15]);
++
++ if (!GDBGetACK ())
++ {
++ if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
++ }
++ }
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ else
++ {
++ int result;
++ char c1;
++
++ checksum = 0;
++ c = '$';
++ for (i=0; i<size; i++)
++ {
++ checksum += aBuffer[i];
++ c1 = aBuffer[i];
++ aBuffer[i] = c;
++ c = c1;
++ }
++ aBuffer[i++] = c;
++
++ aBuffer[i++] = '#';
++ aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
++ aBuffer[i++] = dHexChars[checksum & 15];
++ aBuffer[i++] = 0;
++ethResend:
++ if (gdb.host_ip_address != 0)
++ {
++ result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
++ gdb.host_ip_address,
++ gdb.host_port_number);
++ }
++ if (!GDBGetACK ())
++ {
++ if (++cnt < GDB_RETRY_CNT) goto ethResend;
++ }
++ aBuffer[0]=0;
++ }
++#endif
++#endif
++ if (cnt < GDB_RETRY_CNT) return 1;
++ else return 0;
++}
++
++void PutGDBOKPacket(char *aBuffer)
++ {
++ aBuffer[0] = 'O';
++ aBuffer[1] = 'K';
++ aBuffer[2] = 0;
++ PutGDBPacket(aBuffer);
++ }
++
++#if nasys_debug_core
++
++//some defines used exclusively for TRACE data xfer
++//stepsize is the ascii hex step value i.e. twice the binary length
++#define stepsize (2*(2*sizeof(int) + sizeof (char)))
++#define MAX_TRACE_BYTES (((int)((2*MAX_DATA_SIZE-2)/stepsize))*stepsize)
++
++int Trace_Read_Intercept (char *aBuffer)
++{
++ int cnt=0;
++ unsigned int data;
++ unsigned char code;
++ int byteCount;
++ unsigned char *w;
++ unsigned short dataAccumulate;
++ int status;
++
++ w = aBuffer;
++ w++; //skip past the m
++ if (*w++ == 't') //see if this is a special "memory trace" packet
++ {
++ w = Hex2Value(w,&byteCount); //get the number of bytes to transfer
++
++ //turn byteCount to a multiple of stepsize
++ byteCount = ((int)(byteCount/stepsize))*stepsize;
++
++ //wait until fifo empties
++ nm_debug_get_reg(status, np_debug_write_status);
++ while (status&np_debug_write_status_writing_mask) nm_debug_get_reg(status,np_debug_write_status);
++
++ // loop through total size
++ while (byteCount > 0)
++ {
++ w=aBuffer; //reset w to beginning of buffer
++
++ //calculate the number of bytes in this packet
++ if (byteCount > MAX_TRACE_BYTES) dataAccumulate = MAX_TRACE_BYTES;
++ else dataAccumulate = byteCount;
++
++ //insert data size at beginning of packet
++ w = MemToHex((char *)&dataAccumulate, w, sizeof (dataAccumulate));
++
++ byteCount -= dataAccumulate; //decrement byteCount
++
++ // accumulate a full buffer
++ for (cnt=0; cnt<dataAccumulate; cnt+=stepsize)
++ {
++ int valid;
++ nm_debug_set_reg (1, np_debug_read_sample); //begin transaction
++
++ //wait until data is ready
++ nm_debug_get_reg (valid, np_debug_data_valid);
++ while (!valid) nm_debug_get_reg(valid,np_debug_data_valid) ;
++
++ nm_debug_get_reg (data, np_debug_trace_address);
++ w = MemToHex ((char *)&data, w, sizeof (int));
++
++ nm_debug_get_reg (data, np_debug_trace_data);
++ w = MemToHex ((char *)&data, w, sizeof (int));
++
++ nm_debug_get_reg (data, np_debug_trace_code);
++ w = MemToHex ((char *)&data, w, sizeof (char));
++ }
++
++ //if one of our data packets doesn't make it, stop sending them
++ //if (PutTracePacket (aBuffer,dataAccumulate+4) != 1) //+4 for size filed
++ // byteCount = 0;
++ /* kenw - My module can't handle the incoming data fast enough. So
++ * send this one packet, and wait for another mt command.
++ */
++ PutTracePacket (aBuffer,dataAccumulate+4);
++ byteCount = 0;
++ }
++ return 1;
++ }
++ return 0;
++}
++
++/*
++#undef stepsize
++#undef MAX_TRACE_BYTES
++*/
++
++#endif
++
++void DoGDBCommand_m(char *aBuffer)
++ {
++ char *w;
++ int startAddr,byteCount;
++
++#if nasys_debug_core
++ /* intercept some access to the dbg peripheral */
++ if (Trace_Read_Intercept (aBuffer)) return;
++#endif
++
++ w = aBuffer;
++ w++; // past 'm'
++ w = Hex2Value(w,&startAddr);
++ w++; // past ','
++ w = Hex2Value(w,&byteCount);
++
++ if (byteCount > MAX_DATA_SIZE) byteCount = MAX_DATA_SIZE;
++
++ // mA,L -- request memory
++ w = aBuffer;
++ w = MemToHex((char *)startAddr,w,byteCount);
++ PutGDBPacket(aBuffer);
++ }
++
++void DoGDBCommand_M(char *aBuffer)
++ {
++ char *w;
++ int startAddr,byteCount;
++
++ w = aBuffer;
++ w++; // past 'M'
++ w = Hex2Value(w,&startAddr);
++ w++; // past ','
++ w = Hex2Value(w,&byteCount);
++ w++; // past ':'
++
++ GDB_Print2("M from %x to %x",startAddr,byteCount);
++
++ // MA,L:values -- write to memory
++
++ w = HexToMem(w,(char *)startAddr,byteCount);
++
++ // Send "OK"
++ PutGDBOKPacket(aBuffer);
++ }
++
++int Debug_Read_Intercept (char *aBuffer)
++{
++ unsigned int data;
++ int index;
++ unsigned char *w;
++
++ w = aBuffer;
++ w++; //skip past the g
++ if (*w++ == 'g') //see if this is a special "register read" packet
++ {
++ w = Hex2Value(w,&index); //get the index of the register to be read
++
++ nm_debug_get_reg (data, index);
++
++ //assemble the output packet
++ w=aBuffer; //reset w to beginning of buffer
++ w = MemToHex((char *)&data, w, sizeof (data));
++ *w++ = 0;
++
++ //now send it
++ PutTracePacket (aBuffer,sizeof (data) * 2);
++
++ return 1;
++ }
++ return 0;
++}
++
++// Return the values of all the registers
++void DoGDBCommand_g(NiosGDBGlobals *g)
++ {
++ char *w;
++
++ if (Debug_Read_Intercept (g->textBuffer)) return;
++
++ w = g->textBuffer;
++
++ w = MemToHex((char *)(&g->registers),w,sizeof(g->registers));
++ PutGDBPacket(g->textBuffer);
++ GDB_Print2("Sent Registers",0,0);
++ }
++
++int Debug_Write_Intercept (char *aBuffer)
++{
++ unsigned int data;
++ int index;
++ unsigned char *w;
++
++ w = aBuffer;
++ w++; //skip past the g
++ if (*w++ == 'g') //see if this is a special "register read" packet
++ {
++ w = Hex2Value(w,&index); //get the index of the register to be written
++ w++; // past ','
++ w = Hex2Value(w,&data);
++
++ nm_debug_set_reg (data, index);
++
++ //now send it
++ // Send "OK"
++ PutGDBOKPacket(aBuffer);
++
++ return 1;
++ }
++ return 0;
++}
++
++void DoGDBCommand_G(NiosGDBGlobals *g)
++ {
++ char *w;
++
++ if (Debug_Write_Intercept (g->textBuffer)) return;
++
++ w = g->textBuffer;
++ w++; // skip past 'G'
++ w = HexToMem(w,(char *)(&g->registers), sizeof(g->registers) );
++
++ // Send "OK"
++ PutGDBOKPacket(g->textBuffer);
++
++ GDB_Print2("Received Registers",0,0);
++ }
++
++// Return last signal value
++void DoGDBCommand_qm(NiosGDBGlobals *g)
++ {
++ char *w;
++
++ w = g->textBuffer;
++
++ *w++ = 'S';
++ *w++ = '2';
++ *w++ = '3'; // make up a signal for now...
++ *w++ = 0;
++ PutGDBPacket(g->textBuffer);
++ }
++
++void DoGDBCommand_q(NiosGDBGlobals *g)
++{
++#ifdef na_ssram_detect_in
++ short int* ssram_exists;
++#endif
++ char *w;
++ w = g->textBuffer;
++
++ w++; /* skip past the q */
++ switch (*w) {
++ case ('A'):
++ w = g->textBuffer;
++
++ /* handle intialization information */
++ /* is nios_ocd available? */
++#ifdef nasys_debug_core
++ *w++ = nasys_debug_core + '0';
++#else
++ *w++ = '0';
++#endif
++ *w++ = ',';
++
++ /* determine if the SSRAM debugger board is
++ * physically present */
++#ifdef na_ssram_detect_in
++ ssram_exists = (short int*) na_ssram_detect_in;
++ *w++ = !(*ssram_exists) + '0';
++#else
++ *w++ = '0';
++#endif
++ *w++ = ',';
++
++ /* print out the max size of a trace packet */
++#if nasys_debug_core
++ sprintf (w, "%04x", MAX_TRACE_BYTES);
++#else
++ sprintf (w, "0000");
++#endif
++
++ break;
++ case ('B'):
++ w = g->textBuffer;
++
++ /* returns 1 if it was an OCD interrupt
++ * returns 0 if it was software breakpoint */
++ if (gdb.trapNumber == nasys_debug_core_irq) {
++ *w++ = '1';
++ } else {
++ *w++ = '0';
++ }
++
++ *w++ = 0;
++ break;
++ default:
++ w = g->textBuffer;
++
++ *w = 0;
++ break;
++ }
++
++ PutGDBPacket(g->textBuffer);
++}
++
++
++void GDBInsertBreakpoint(NiosGDBGlobals *g,short *address)
++ {
++ NiosGDBBreakpoint *b;
++
++ GDB_Print2("breakpoint 0x%x",(int)address,0);
++ if(g->breakpointCount < kMaximumBreakpoints)
++ {
++ b = &g->breakpoint[g->breakpointCount++];
++ b->address = address;
++ b->oldContents = *b->address;
++ *b->address = 0x7904;
++ }
++ }
++
++void GDBRemoveBreakpoints(NiosGDBGlobals *g)
++ {
++ NiosGDBBreakpoint *b;
++ int i;
++
++ for(i = 0; i < g->breakpointCount; i++)
++ {
++ b = &g->breakpoint[i];
++ *b->address = b->oldContents;
++ b->address = 0;
++ }
++
++ g->breakpointCount = 0;
++ }
++
++int NiosInstructionIsTrap5(unsigned short instruction)
++ {
++ return instruction == 0x7905;
++ }
++
++int NiosInstructionIsPrefix(unsigned short instruction)
++ {
++ return (instruction >> 11) == 0x13;
++ }
++
++int NiosInstructionIsSkip(unsigned short instruction)
++ {
++ int op6;
++ int op11;
++
++ op6 = (instruction >> 10);
++ op11 = (instruction >> 5);
++
++ return (op6 == 0x14 // SKP0
++ || op6 == 0x15 // SKP1
++ || op11 == 0x3f6 // SKPRz
++ || op11 == 0x3f7 // SKPS
++ || op11 == 0x3fa); // SKPRnz
++ }
++
++int NiosInstructionIsBranch(unsigned short instruction,short *pc,short **branchTargetOut)
++ {
++ int op4;
++ int op7;
++ int op10;
++ short *branchTarget = 0;
++ int result = 0;
++
++ op4 = (instruction >> 12);
++ op7 = (instruction >> 9);
++ op10 = (instruction >> 6);
++
++ if(op4 == 0x08) // BR, BSR
++ {
++ int offset;
++
++ result = 1;
++ offset = instruction & 0x07ff;
++ if(offset & 0x400) // sign extend
++ offset |= 0xffffF800;
++ branchTarget = pc + offset + 1; // short * gets x2 scaling automatically
++ }
++ else if(op10 == 0x1ff) // JMP, CALL
++ {
++ result = 1;
++ branchTarget = (short *)(gdb.registers.r[instruction & 31] * 2);
++ }
++ else if(op7 == 0x3d) // JMPC, CALLC
++ {
++ result = 1;
++ branchTarget = pc + 1 + (instruction & 0x0ffff);
++#ifdef __nios32__
++ branchTarget = (short *)((int)branchTarget & 0xffffFFFc); // align 32...
++#else
++ branchTarget = (short *)((int)branchTarget & 0xFFFe); // align 16...
++#endif
++ branchTarget = (short *)(*(int *)branchTarget);
++ }
++
++ if(branchTargetOut)
++ *branchTargetOut = branchTarget;
++
++ return result;
++ }
++
++// -------------------------
++// Step at address
++//
++// "stepping" involves inserting a
++// breakpoint at some reasonable
++// spot later than the current program
++// counter
++//
++// On the Nios processor, this is
++// nontrivial. For example, we should
++// not break up a PFX instruction.
++
++void DoGDBCommand_s(NiosGDBGlobals *g)
++ {
++ char *w;
++ int x;
++ short *pc;
++ short *branchTarget;
++ unsigned short instruction;
++ int stepType;
++
++ /*
++ * First, if there's an argument to the packet,
++ * set the new program-counter value
++ */
++
++ w = g->textBuffer;
++ w++;
++ if(HexCharToValue(*w) >= 0)
++ {
++ w = Hex2Value(w,&x);
++ g->registers.pc = x;
++ }
++
++ /*
++ * Scan forward to see what the
++ * most appropriate location(s) for
++ * a breakpoint will be.
++ *
++ * The rules are:
++ * 1. If *pc == PFX, break after modified instruction.
++ * 2. If *pc == BR,BSR,JMP,CALL, break at destination
++ * 3. If *pc == SKIP, break right after SKIP AND after optional instruction,
++ which might, of course, be prefixed.
++ * 4. Anything else, just drop in the breakpoint.
++ */
++
++ pc = (short *)(int)g->registers.pc;
++
++ instruction = *pc;
++ stepType = 0;
++
++ if(NiosInstructionIsPrefix(instruction))
++ {
++ /*
++ * PFX instruction: skip til after it
++ */
++ while(NiosInstructionIsPrefix(instruction))
++ {
++ pc++;
++ instruction = *pc;
++ }
++
++ GDBInsertBreakpoint(g,pc + 1);
++ stepType = 1;
++ }
++ else if(NiosInstructionIsBranch(instruction,pc,&branchTarget))
++ {
++ GDBInsertBreakpoint(g,branchTarget);
++ stepType = 2;
++ }
++ else if(NiosInstructionIsSkip(instruction))
++ {
++ short *pc2;
++ stepType = 3;
++
++ /*
++ * Skip gets to breaks: one after the skippable instruction,
++ * and the skippable instruction itself.
++ *
++ * Since Skips know how to skip over PFX's, we have to, too.
++ */
++ pc2 = pc; // the Skip instruction
++ do
++ {
++ pc2++;
++ } while(NiosInstructionIsPrefix(*pc2));
++ // pc2 now points to first non-PFX after Skip
++ GDBInsertBreakpoint(g,pc2+1);
++ GDBInsertBreakpoint(g,pc+1);
++ }
++ else
++ GDBInsertBreakpoint(g,pc+1); // the genericest case
++
++ GDB_Print2("Program Steppingat 0x%x (%d)",g->registers.pc,stepType);
++ }
++
++// -----------------------------
++// Continue at address
++
++void DoGDBCommand_c(NiosGDBGlobals *g)
++ {
++ char *w;
++ int x;
++ w = g->textBuffer;
++
++ w++; // past command
++
++ // Anything in the packet? if so,
++ // use it to set the PC value
++
++ if(HexCharToValue(*w) >= 0)
++ {
++ w = Hex2Value(w,&x);
++ g->registers.pc = x;
++ }
++
++ GDB_Print2("Program Running at 0x%x",g->registers.pc,0);
++ }
++
++// ----------------------
++// Kill
++
++void DoGDBCommand_k(NiosGDBGlobals *g)
++ {
++ return;
++ }
++
++
++/*
++ * If we've somehow skidded
++ * to a stop just after a PFX instruction
++ * back up the program counter by one.
++ *
++ * That way, we can't end up with an accidentally-unprefixed
++ * instruction.
++ *
++ * We do this just before we begin running
++ * again, so that when the host queries our
++ * registers, we report the place we actually
++ * stopped.
++ */
++
++void MaybeAdjustProgramCounter(NiosGDBGlobals *g)
++ {
++ short instruction;
++ if(g->registers.pc)
++ {
++ instruction = *(short *)(int)(g->registers.pc - 2);
++ if(NiosInstructionIsPrefix(instruction))
++ g->registers.pc -= 2;
++ else
++ {
++ // If the *current* instruction is Trap5, we must skip it!
++ instruction = *(short *)(int)(g->registers.pc);
++ if(NiosInstructionIsTrap5(instruction))
++ g->registers.pc += 2;
++ }
++ }
++ }
++
++/*
++ * GDBMainLoop - this is the main processing loop
++ * for the GDB stub.
++ */
++void GDBMainLoop (void)
++{
++ while(1)
++ {
++ if (GetGDBPacket(gdb.textBuffer) > 0)
++ {
++
++ GDB_Print2(gdb.textBuffer,0,0);
++ switch(gdb.textBuffer[0])
++ {
++ case 's':
++ DoGDBCommand_s(&gdb);
++ goto startRunning;
++ break;
++
++ case 'c': // continue
++ DoGDBCommand_c(&gdb);
++
++ // if the PC is something other than 0, it's
++ // probably ok to exit and go there
++
++ startRunning:
++ if(gdb.registers.pc)
++ {
++ MaybeAdjustProgramCounter(&gdb);
++ return;
++ }
++ break;
++
++ case 'm': // memory read
++ DoGDBCommand_m(gdb.textBuffer);
++ break;
++
++ case 'M': // memory set
++ DoGDBCommand_M(gdb.textBuffer);
++ break;
++
++ case 'g': // registers read
++ DoGDBCommand_g(&gdb);
++ break;
++
++ case 'G': //registers set
++ DoGDBCommand_G(&gdb);
++ break;
++
++ case 'k': //kill process
++ DoGDBCommand_k(&gdb);
++ break;
++
++ case '?': // last exception value
++ DoGDBCommand_qm(&gdb);
++ break;
++
++ case 'q':
++ DoGDBCommand_q(&gdb);
++ break;
++
++ default: // return empty packet, means "yeah yeah".
++ gdb.textBuffer[0] = 0;
++ PutGDBPacket(gdb.textBuffer);
++ break;
++ }
++ }
++ }
++
++}
++
++// ----------main------------
++void GDBMain(void)
++{
++ int i;
++
++ for(i = 0; i < kTextBufferSize; i++)
++ gdb.textBuffer[i] = i;
++
++ GDBRemoveBreakpoints(&gdb);
++
++#ifdef __KERNEL__
++/*
++ * Inform the user that they need to add the symbol file for the application
++ * that is just starting up. Display the .text .data .bss regions.
++ */
++ if (gdb.trapNumber == 5) {
++ extern struct task_struct *_current_task;
++ sprintf(gdb.textBuffer,
++ "\r\n\nGDB: trap 5 at 0x%08lX", gdb.registers.pc);
++ puts(gdb.textBuffer);
++ if (_current_task) {
++ if ( _current_task->mm->start_code > _etext )
++ sprintf(gdb.textBuffer,
++ "\r\nGDB: Enter the following command in the nios-elf-gdb Console Window:"
++ "\r\nGDB: add-symbol-file %s.abself 0x%08lX 0x%08lX 0x%08lX\r\n\n",
++ _current_task->comm,
++ (unsigned long)_current_task->mm->start_code,
++ (unsigned long)_current_task->mm->start_data,
++ (unsigned long)_current_task->mm->end_data );
++ else
++ sprintf(gdb.textBuffer,
++ ", kernel process: %s\r\n", _current_task->comm );
++ } else
++ sprintf(gdb.textBuffer,
++ ", kernel process unknown\r\n" );
++ puts(gdb.textBuffer);
++ }
++#endif
++
++ // Send trapnumber for breakpoint encountered. No other signals.
++
++ gdb.textBuffer[0] = 'S';
++ gdb.textBuffer[1] = '0';
++
++#if nasys_debug_core
++ if (gdb.trapNumber == nasys_debug_core_irq)
++ {
++ /* gdb.textBuffer[2] = '8'; */
++ gdb.textBuffer[2] = '5';
++ }
++ else
++ {
++ gdb.textBuffer[2] = '5';
++ }
++#else
++ gdb.textBuffer[2] = '5';
++#endif
++ gdb.textBuffer[3] = 0;
++ PutGDBPacket(gdb.textBuffer);
++
++ GDB_Print2("Trap %2d At 0x%x",
++ gdb.trapNumber,gdb.registers.pc);
++// printf ("Trap %d at 0x%x\n",gdb.trapNumber,gdb.registers.pc);
++// for (i=0;i<32;i++) printf (" register[%d] = 0x%x\n",i,gdb.registers.r[i]);
++
++ GDBMainLoop ();
++}
++
++// +----------------------------------
++// | gdb_eth_proc -- gets called for udp packets
++// | from the host bound for gdb stub
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++int gdb_eth_proc(int plug_handle,
++ void *context,
++ ns_plugs_packet *p,
++ void *payload,
++ int payload_length)
++{
++ int i;
++ char *buf = (char *)payload;
++ // if this is a stop request, set a flag to stop after nr_plugs_idle
++ // leave it up to the host to prevent stops from being sent while stub is running???
++
++ if (*buf == 3) gdb.stop = 1;
++
++ // if we're waiting for an ack, check that here
++ if (gdb.ACKstatus == ne_gdb_ack_waiting)
++ {
++ if (buf[0] == '+')
++ {
++ gdb.ACKstatus = ne_gdb_ack_acked;
++ return 0;
++ }
++ else if (buf[0] == '-')
++ {
++ gdb.ACKstatus = ne_gdb_ack_nacked;
++ return 0;
++ }
++ }
++ strcpy (gdb.textBuffer, buf); //all commands should be zero terminated strings
++
++ gdb.textBuffer[payload_length] = 0; //terminate string
++
++ gdb.host_ip_address=((ns_plugs_ip_packet *)(p[ne_plugs_ip].header))->source_ip_address;
++ gdb.host_port_number=((ns_plugs_udp_packet *)(p[ne_plugs_udp].header))->source_port;
++
++ return 0;
++}
++
++int nr_dbg_plugs_idle (void)
++{
++ int result;
++
++ result = nr_plugs_idle ();
++ if (gdb.stop)
++ {
++ gdb.stop = 0;
++//;dgt2;tmp; asm ("TRAP #5");
++ }
++ return result;
++}
++#endif
++#endif
++
++
++/*
++ * int main(void)
++ *
++ * All we really do here is install our trap # 3,
++ * and call it once, so that we're living down in
++ * the GDBMain, trap handler.
++ */
++
++extern int StubBreakpointHandler;
++extern int StubHarmlessHandler;
++#if nasys_debug_core
++extern int StubHWBreakpointHandler;
++#endif
++#ifdef nasys_debug_uart
++extern int StubUartHandler;
++#endif
++
++void gdb_local_install(int active)
++{
++ unsigned int *vectorTable;
++ unsigned int stubBreakpointHandler;
++ unsigned int stubHarmlessHandler;
++#if nasys_debug_core
++ unsigned int stubHWBreakpointHandler;
++#endif
++
++ gdb.breakpointCount = 0;
++ gdb.textBuffer[0] = 0;
++
++ vectorTable = (int *)nasys_vector_table;
++ stubBreakpointHandler = ( (unsigned int)(&StubBreakpointHandler) ) >> 1;
++ stubHarmlessHandler = ( (unsigned int)(&StubHarmlessHandler) ) >> 1;
++#if nasys_debug_core
++ stubHWBreakpointHandler = ( (unsigned int)(&StubHWBreakpointHandler) ) >> 1;
++#endif
++
++ /*
++ * Breakpoint & single step both go here
++ */
++ vectorTable[na_BreakpointTrap] = stubBreakpointHandler;
++ vectorTable[na_SingleStepTrap] = stubBreakpointHandler;
++ vectorTable[na_StartGDBTrap] = active ? stubBreakpointHandler : stubHarmlessHandler;
++ /*
++ * If it exists, Hardware Breakpoint has a different entry point
++ */
++#if nasys_debug_core
++ vectorTable[na_debug_peripheral_irq] = stubHWBreakpointHandler;
++#endif
++
++#ifndef __KERNEL__
++#ifdef nasys_debug_uart
++ if (gdb.comlink == ne_gdb_serial)
++ {
++ np_uart *uart = (np_uart *)nasys_debug_uart;
++ unsigned int stubUartHandler = ((unsigned int)(&StubUartHandler)) >> 1;
++
++ vectorTable[nasys_debug_uart_irq] = stubUartHandler; //set Uart int vector
++ uart->np_uartcontrol = np_uartcontrol_irrdy_mask; //enable Rx intr
++ }
++#endif
++#endif
++}
++
++void nios_gdb_install(int active)
++{
++ gdb.comlink = ne_gdb_serial;
++ gdb_local_install (active);
++}
++
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++void nios_gdb_install_ethernet (int active)
++{
++ int result;
++ host_16 host_port = GDB_ETH_PORT;
++
++ gdb.comlink = ne_gdb_ethernet;
++ gdb_local_install (active);
++
++ result = nr_plugs_create (&gdb.gdb_eth_plug, ne_plugs_udp, host_port, gdb_eth_proc, 0, 0);
++ //if unabled to open ethernet plug, switch back to default serial interface
++ if (result)
++ {
++ printf ("nr_plugs_create failed %d\n",result);
++ gdb.comlink = ne_gdb_serial;
++ return;
++ }
++ result = nr_plugs_connect (gdb.gdb_eth_plug, 0, -1, -1);
++ if (result)
++ {
++ printf ("nr_plugs_connect fialed %d\n",result);
++ gdb.comlink = ne_gdb_serial;
++ return;
++ }
++}
++#endif
++#endif
++
++#ifdef nios_gdb_breakpoint
++ #undef nios_gdb_breakpoint
++#endif
++
++void nios_gdb_breakpoint(void)
++ {
++ /*
++ * If you arrived here, you didn't include
++ * the file "nios_peripherals.h", which
++ * defines nios_gdb_breakpoint as a
++ * macro that expands to TRAP 5.
++ *
++ * (No problem, you can step out
++ * of this routine.)
++ */
++//;dgt2;tmp; asm("TRAP 5");
++ }
++
++// end of file
+diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.h b/arch/nios2nommu/kernel/nios_gdb_stub.h
+new file mode 100644
+index 0000000..3900109
+--- /dev/null
++++ b/arch/nios2nommu/kernel/nios_gdb_stub.h
+@@ -0,0 +1,105 @@
++// file: nios_gdb_stub.h
++// Author: Altera Santa Cruz \ 2000
++//
++// You can modify this header file to
++// enable some features useful for
++// debugging the debugger. They're
++// good features also to just show
++// signs of life on your Nios board.
++// But they consume valuable peripherals!
++//
++// The 'GDB_DEBUG_PRINT' option ties
++// up the LCD living on the 5v port,
++// showing useful internals of the stub.
++//
++// dvb@altera.com
++//
++
++#ifdef ETHER_DEBUG
++#ifdef na_enet
++#define ethernet_exists
++#endif
++#endif
++
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++#include "plugs.h"
++#endif
++#endif
++
++#define MAX_DATA_SIZE 650
++#define kTextBufferSize ((2*MAX_DATA_SIZE)+4)
++#define kMaximumBreakpoints 4
++#define GDB_ETH_PORT 7070
++#define GDB_WHOLE_PACKET 0
++#define GDB_SKIP_FIRST 1
++#define GDB_RETRY_CNT 3
++
++/*
++ * This register structure must match
++ * its counterpart in the GDB host, since
++ * it is blasted across in byte notation.
++ */
++typedef struct
++ {
++ int r[32];
++ long pc;
++ short ctl0;
++ short ctl1;
++ short ctl2;
++ short ctl3;
++ } NiosGDBRegisters;
++
++typedef struct
++ {
++ short *address;
++ short oldContents;
++ } NiosGDBBreakpoint;
++
++typedef struct
++ {
++ NiosGDBRegisters registers;
++ int trapNumber; // stashed by ISR, to distinguish types
++ char textBuffer[kTextBufferSize];
++ int breakpointCount; // breakpoints used for stepping
++ int comlink;
++ int stop;
++ int gdb_eth_plug;
++ NiosGDBBreakpoint breakpoint[kMaximumBreakpoints];
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++ volatile int ACKstatus;
++ net_32 host_ip_address;
++ net_16 host_port_number;
++#endif
++#endif
++ } NiosGDBGlobals;
++
++#ifdef ETHER_DEBUG
++#ifdef ethernet_exists
++enum
++{
++ ne_gdb_ack_notwaiting,
++ ne_gdb_ack_waiting,
++ ne_gdb_ack_acked,
++ ne_gdb_ack_nacked
++};
++#endif
++#endif
++
++enum
++{
++ ne_gdb_serial,
++ ne_gdb_ethernet
++};
++
++#ifndef GDB_DEBUG_PRINT
++ #define GDB_DEBUG_PRINT 0
++#endif
++
++void GDB_Main(void); // initialize gdb and begin.
++
++char GDBGetChar(void);
++void GDBPutChar(char c);
++void GDB_Print2(char *s,int v1,int v2);
++
+diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_io.c b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
+new file mode 100644
+index 0000000..e0d8f82
+--- /dev/null
++++ b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
+@@ -0,0 +1,39 @@
++// Modified for uClinux - Vic - Apr 2002
++// From:
++
++// file: nios_gdb_stub_IO.c
++//
++// Single character I/O for Nios GDB Stub
++
++#ifndef __KERNEL__
++#include "nios.h"
++#else
++#include <asm/nios.h>
++#endif
++
++#include "nios_gdb_stub.h"
++
++#ifdef nasys_debug_uart
++ #define GDB_UART nasys_debug_uart
++#endif
++
++char GDBGetChar(void)
++{
++ char c = 0;
++
++#ifdef GDB_UART
++ while( (c = (char)nr_uart_rxchar(GDB_UART)) < 0 )
++ ;
++#endif
++
++ return c;
++}
++
++void GDBPutChar(char c)
++{
++#ifdef GDB_UART
++ nr_uart_txchar(c, GDB_UART);
++#endif
++}
++
++// End of file
+diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_isr.S b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
+new file mode 100644
+index 0000000..c4af09a
+--- /dev/null
++++ b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
+@@ -0,0 +1,99 @@
++/*--------------------------------------------------------------------
++ *
++ * Assembly language portions of Nios GDB Stub
++ *
++ * arch\nios2nommu\kernel\switch.S
++ *
++ * Derived from Nios1
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Modified for uClinux - Vic - Apr 2002
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++//;dgt2;tmp;
++
++ .equ ethernet_exists, 1
++
++
++ .equ gdbRegistersGeneral,0
++ .equ gdbRegistersPC,32
++ .equ gdbRegistersCtl0Ctl1,33
++ .equ gdbRegistersCtl2Ctl3,34
++ .equ gdbTrapNumber,35 ; ISR can report trap number here
++
++
++ .text
++
++ .global StubBreakpointHandler
++ .global StubHarmlessHandler
++ .global StubButtonHandler
++ .global StubHWBreakpointHandler
++ .global GDBMain
++
++ .comm _gdb_stub_stack,1024,4 ; Local stack, statically allocated.
++ .equ gdbStubStacktop,_gdb_stub_stack+992
++
++
++StubHarmlessHandler:
++//;dgt2;tmp
++
++ .equ gdbBreakChar,0x3
++ .global StubUartHandler
++
++StubUartHandler:
++//;dgt2;tmp
++
++StubUartRx:
++//;dgt2;tmp
++
++StubHWBreakpointHandler:
++//;dgt2;tmp
++
++StubBreakpointHandler:
++//;dgt2;tmp
++
++#ifdef __KERNEL__
++;----------------------------------------
++; Name: nr_uart_rxchar
++; Description: Read character if available
++; Input: %o0: UART base to use
++; Output: %o0 = character 0-0xff, or -1 if none present
++; Side Effects: %g0 & %g1 altered
++; CWP Depth: 0
++;
++
++ .global nr_uart_rxchar
++nr_uart_rxchar:
++//;dgt2;tmp
++
++
++;----------------------------------------
++; Name: nr_uart_txchar
++; Description: Send a single byte out the UART
++; Input: %o0 = A character
++; %o1 = the UART to use, 0 for default
++; Output: none
++; Side Effects: %g0 & %g1 altered, CPU waits for UART
++; CWP Depth: 0
++;
++
++; nr_uart_txchar
++ .global nr_uart_txchar
++nr_uart_txchar:
++//;dgt2;tmp
++
++#endif
+diff --git a/arch/nios2nommu/kernel/pio.c b/arch/nios2nommu/kernel/pio.c
+new file mode 100644
+index 0000000..013a64b
+--- /dev/null
++++ b/arch/nios2nommu/kernel/pio.c
+@@ -0,0 +1,154 @@
++/*
++ * linux/arch/nios2nommu/kernel/pio.c
++ * "Example" drivers(LEDs and 7 seg displays) of the PIO interface
++ * on Nios Development Kit.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#include <linux/module.h>
++#include <linux/types.h>
++#include <linux/kernel.h>
++#include <linux/delay.h>
++#include <linux/timer.h>
++#include <linux/init.h>
++#include <linux/interrupt.h>
++#include <linux/ioport.h>
++#include <asm/io.h>
++
++MODULE_AUTHOR("Microtronix Datacom Ltd.");
++MODULE_DESCRIPTION("Drivers of PIO devices (LEDs and 7 seg) on Nios kit");
++MODULE_LICENSE("GPL");
++
++#undef CONFIG_PIO_SEG
++#ifdef na_seven_seg_pio
++#define CONFIG_PIO_SEG
++#define PIO_SEG_IO na_seven_seg_pio
++#endif
++
++#undef CONFIG_PIO_LED
++#ifdef na_led_pio
++#define CONFIG_PIO_LED
++#define PIO_LED_IO na_led_pio
++#endif
++
++#define PDEBUG printk
++
++/* routines for 7-segment hex display */
++#ifdef CONFIG_PIO_SEG
++static unsigned char _hex_digits_data[] = {
++ 0x01, 0x4f, 0x12, 0x06, 0x4c, /* 0-4 */
++ 0x24, 0x20, 0x0f, 0x00, 0x04, /* 5-9 */
++ 0x08, 0x60, 0x72, 0x42, 0x30, /* a-e */
++ 0x38 /* f */
++};
++
++void pio_seg_write(int value)
++{
++ int led_value;
++
++ /* Left Hand Digit, goes to PIO bits 8-14 */
++ led_value = _hex_digits_data[value & 0xF];
++ led_value |= (_hex_digits_data[(value >> 4) & 0xF]) << 8;
++
++ outl(led_value, &(PIO_SEG_IO->np_piodata));
++}
++
++static void __init pio_seg_init(void)
++{
++ pio_seg_write(0);
++}
++#endif
++
++
++/* routines for LED display */
++#ifdef CONFIG_PIO_LED
++void pio_led_write(int value)
++{
++ np_pio *pio=(np_pio *)(PIO_LED_IO);
++
++ //outl(-1, &pio->np_piodirection);
++ outl(value, &pio->np_piodata);
++}
++
++static void __init pio_led_init(void)
++{
++ np_pio *pio=(np_pio *)(PIO_LED_IO);
++
++ outl(-1, &pio->np_piodirection);
++ outl(0x0, &pio->np_piodata);
++}
++#endif
++
++/* timing routines */
++#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
++static struct timer_list display_timer;
++static int restart_timer=1;
++static int timer_counter=0;
++static void display_timeout(unsigned long unused)
++{
++#ifdef CONFIG_PIO_SEG
++ pio_seg_write(++timer_counter);
++#endif
++
++#ifdef CONFIG_PIO_LED
++ pio_led_write(timer_counter);
++#endif
++ if (restart_timer) {
++ display_timer.expires = jiffies + HZ; /* one second */
++ add_timer(&display_timer);
++ }
++}
++#endif
++
++int __init pio_init(void)
++{
++#ifdef CONFIG_PIO_SEG
++ request_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio), "pio_7seg");
++ pio_seg_init();
++#endif
++
++#ifdef CONFIG_PIO_LED
++ request_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio), "pio_led");
++ pio_led_init();
++#endif
++
++#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
++ /* init timer */
++ init_timer(&display_timer);
++ display_timer.function = display_timeout;
++ display_timer.data = 0;
++ display_timer.expires = jiffies + HZ * 10; /* 10 seconds */
++ add_timer(&display_timer);
++#endif
++
++ return 0;
++}
++
++static void __exit pio_exit(void)
++{
++#ifdef CONFIG_PIO_SEG
++ pio_seg_write(0);
++ release_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio));
++#endif
++
++#ifdef CONFIG_PIO_LED
++ pio_led_write(0);
++ release_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio));
++#endif
++
++#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
++ restart_timer=0;
++ del_timer_sync(&display_timer);
++#endif
++}
++module_init(pio_init);
++module_exit(pio_exit);
++
+diff --git a/arch/nios2nommu/kernel/process.c b/arch/nios2nommu/kernel/process.c
+new file mode 100644
+index 0000000..4cd353c
+--- /dev/null
++++ b/arch/nios2nommu/kernel/process.c
+@@ -0,0 +1,578 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/process.c
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 1995 Hamish Macdonald
++ * Copyright (C) 2000-2002, David McCullough <davidm@snapgear.com>
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * 68060 fixes by Jesper Skov
++ * Jan/20/2004 dgt NiosII
++ * rdusp() === (pt_regs *) regs->sp
++ * Monday:
++ * asm-nios2nommu\processor.h now bears
++ * inline thread_saved_pc
++ * (struct thread_struct *t)
++ * Friday: it's back here now
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file handles the architecture-dependent parts of process handling..
++ */
++
++#include <linux/module.h>
++#include <linux/errno.h>
++#include <linux/sched.h>
++#include <linux/kernel.h>
++#include <linux/mm.h>
++#include <linux/smp.h>
++#include <linux/smp_lock.h>
++#include <linux/stddef.h>
++#include <linux/unistd.h>
++#include <linux/ptrace.h>
++#include <linux/slab.h>
++#include <linux/user.h>
++#include <linux/a.out.h>
++#include <linux/interrupt.h>
++#include <linux/reboot.h>
++#include <linux/uaccess.h>
++#include <linux/fs.h>
++#include <linux/err.h>
++
++#include <asm/system.h>
++#include <asm/traps.h>
++#include <asm/setup.h>
++#include <asm/pgtable.h>
++#include <asm/cacheflush.h>
++
++asmlinkage void ret_from_fork(void);
++
++/*
++ * The following aren't currently used.
++ */
++void (*pm_idle)(void) = NULL;
++EXPORT_SYMBOL(pm_idle);
++
++void (*pm_power_off)(void) = NULL;
++EXPORT_SYMBOL(pm_power_off);
++
++void default_idle(void)
++{
++ local_irq_disable();
++ if (!need_resched()) {
++ local_irq_enable();
++ __asm__("nop"); // was asm sleep
++ } else
++ local_irq_enable();
++}
++
++void (*idle)(void) = default_idle;
++
++/*
++ * The idle thread. There's no useful work to be
++ * done, so just try to conserve power and have a
++ * low exit latency (ie sit in a loop waiting for
++ * somebody to say that they'd like to reschedule)
++ */
++void cpu_idle(void)
++{
++ while (1) {
++ while (!need_resched())
++ idle();
++ preempt_enable_no_resched();
++ schedule();
++ preempt_disable();
++ }
++}
++
++/*
++ * The development boards have no way to pull a board
++ * reset. Just jump to the cpu reset address and let
++ * the code in head.S take care of disabling peripherals.
++ */
++
++void machine_restart(char * __unused)
++{
++ local_irq_disable();
++ __asm__ __volatile__ (
++ "jmp %0\n\t"
++ :
++ : "r" (CPU_RESET_ADDRESS)
++ : "r4");
++}
++
++EXPORT_SYMBOL(machine_restart);
++
++void machine_halt(void)
++{
++ local_irq_disable();
++ for (;;);
++}
++
++EXPORT_SYMBOL(machine_halt);
++
++void exit_thread(void)
++{
++}
++
++void release_thread(struct task_struct *dead_task)
++{
++ /* nothing to do ... */
++}
++
++/*
++ * There is no way to power off the development
++ * boards. So just spin lock for now. If you have
++ * your own board with power down circuits add you
++ * specific code here.
++ */
++
++void machine_power_off(void)
++{
++ local_irq_disable();
++ for (;;);
++}
++
++EXPORT_SYMBOL(machine_power_off);
++
++void show_regs(struct pt_regs * regs)
++{
++ printk(KERN_NOTICE "\n");
++
++ printk(KERN_NOTICE "r1: %08lx r2: %08lx r3: %08lx r4: %08lx\n",
++ regs->r1, regs->r2, regs->r3, regs->r4);
++
++ printk(KERN_NOTICE "r5: %08lx r6: %08lx r7: %08lx r8: %08lx\n",
++ regs->r5, regs->r6, regs->r7, regs->r8);
++
++ printk(KERN_NOTICE "r9: %08lx r10: %08lx r11: %08lx r12: %08lx\n",
++ regs->r9, regs->r10, regs->r11, regs->r12);
++
++ printk(KERN_NOTICE "r13: %08lx r14: %08lx r15: %08lx\n",
++ regs->r13, regs->r14, regs->r15);
++
++ printk(KERN_NOTICE "ra: %08lx fp: %08lx sp: %08lx gp: %08lx\n",
++ regs->ra, regs->fp, regs->sp, regs->gp);
++
++ printk(KERN_NOTICE "ea: %08lx estatus: %08lx statusx: %08lx\n",
++ regs->ea, regs->estatus, regs->status_extension);
++}
++
++/*
++ * Create a kernel thread
++ */
++int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
++{
++ long retval;
++ long clone_arg = flags | CLONE_VM;
++ mm_segment_t fs;
++
++ fs = get_fs();
++ set_fs(KERNEL_DS);
++
++ __asm__ __volatile(
++
++ " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
++ " movi r3, %1\n\t" /* __NR_clone */
++ " mov r4, %5\n\t" /* (clone_arg */
++ /* (flags | CLONE_VM)) */
++ " movia r5, -1\n\t" /* usp: -1 */
++ " trap\n\t" /* sys_clone */
++ "\n\t"
++ " cmpeq r4, r3, zero\n\t"/*2nd return valu in r3 */
++ " bne r4, zero, 1f\n\t"/* 0: parent, just return. */
++ /* See copy_thread, called */
++ /* by do_fork, called by */
++ /* nios2_clone, called by */
++ /* sys_clone, called by */
++ /* syscall trap handler. */
++
++ " mov r4, %4\n\t" /* fn's parameter (arg) */
++ "\n\t"
++ "\n\t"
++ " callr %3\n\t" /* Call function (fn) */
++ "\n\t"
++ " mov r4, r2\n\t" /* fn's rtn code//;dgt2;tmp;*/
++ " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
++ " movi r3, %2\n\t" /* __NR_exit */
++ " trap\n\t" /* sys_exit() */
++
++ /* Not reached by child. */
++ "1:\n\t"
++ " mov %0, r2\n\t" /* error rtn code (retval) */
++
++ : "=r" (retval) /* %0 */
++
++ : "i" (__NR_clone) /* %1 */
++ , "i" (__NR_exit) /* %2 */
++ , "r" (fn) /* %3 */
++ , "r" (arg) /* %4 */
++ , "r" (clone_arg) /* %5 (flags | CLONE_VM) */
++ , "i" (TRAP_ID_SYSCALL) /* %6 */
++
++ : "r2" /* Clobbered */
++ , "r3" /* Clobbered */
++ , "r4" /* Clobbered */
++ , "r5" /* Clobbered */
++ , "ra" /* Clobbered //;mex1 */
++ );
++
++ set_fs(fs);
++ return retval;
++}
++
++void flush_thread(void)
++{
++ /* Now, this task is no longer a kernel thread. */
++ current->thread.flags &= ~NIOS2_FLAG_KTHREAD;
++
++#ifdef CONFIG_FPU
++ unsigned long zero = 0;
++#endif
++ set_fs(USER_DS);
++#ifdef CONFIG_FPU
++ if (!FPU_IS_EMU)
++...;dgt2;
++ asm volatile (".chip 68k/68881\n\t"
++ "frestore %0@\n\t"
++ ".chip 68k" : : "a" (&zero));
++#endif
++}
++
++/*
++ * "nios2_fork()".. By the time we get here, the
++ * non-volatile registers have also been saved on the
++ * stack. We do some ugly pointer stuff here.. (see
++ * also copy_thread)
++ */
++
++asmlinkage int nios2_fork(struct pt_regs *regs)
++{
++ /* fork almost works, enough to trick you into looking elsewhere :-( */
++ return(-EINVAL);
++}
++
++/*
++ * nios2_execve() executes a new program.
++ */
++asmlinkage int nios2_execve(struct pt_regs *regs)
++{
++ int error;
++ char * filename;
++
++ lock_kernel();
++ filename = getname((char *) regs->r4);
++ error = PTR_ERR(filename);
++ if (IS_ERR(filename))
++ goto out;
++ error = do_execve(filename,
++ (char **) regs->r5,
++ (char **) regs->r6,
++ regs);
++ putname(filename);
++out:
++ unlock_kernel();
++ return error;
++}
++
++asmlinkage int nios2_vfork(struct pt_regs *regs)
++{
++ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, NULL, NULL);
++}
++
++asmlinkage int nios2_clone(struct pt_regs *regs)
++{
++ /* r4: clone_flags, r5: child_stack (usp) */
++
++ unsigned long clone_flags;
++ unsigned long newsp;
++
++ clone_flags = regs->r4;
++ newsp = regs->r5;
++ if (!newsp)
++ newsp = regs->sp;
++ return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
++}
++
++int copy_thread(int nr, unsigned long clone_flags,
++ unsigned long usp, unsigned long topstk,
++ struct task_struct * p, struct pt_regs * regs)
++{
++ struct pt_regs * childregs;
++ struct switch_stack * childstack, *stack;
++ unsigned long stack_offset, *retp;
++
++ stack_offset = THREAD_SIZE - sizeof(struct pt_regs);
++ childregs = (struct pt_regs *) ((unsigned long) p->stack + stack_offset);
++ p->thread.kregs = childregs;
++
++ *childregs = *regs;
++ childregs->r2 = 0; //;dgt2;...redundant?...see "rtnvals" below
++
++ retp = ((unsigned long *) regs);
++ stack = ((struct switch_stack *) retp) - 1;
++
++ childstack = ((struct switch_stack *) childregs) - 1;
++ *childstack = *stack;
++ childstack->ra = (unsigned long)ret_from_fork;
++
++ if (usp == -1)
++ p->thread.kregs->sp = (unsigned long) childstack;
++ else
++ p->thread.kregs->sp = usp;
++
++ p->thread.ksp = (unsigned long)childstack;
++
++#ifdef CONFIG_FPU
++ if (!FPU_IS_EMU) {
++ /* Copy the current fpu state */
++...;dgt2;
++ asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0]) : "memory");
++
++ if (p->thread.fpstate[0])
++ asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
++ "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
++ : : "m" (p->thread.fp[0]), "m" (p->thread.fpcntl[0])
++ : "memory");
++ /* Restore the state in case the fpu was busy */
++ asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
++ }
++#endif
++
++ /* Set the return value for the child. */
++ childregs->r2 = 0; //;dgt2;...redundant?...see childregs->r2 above
++ childregs->r3 = 1; //;dgt2;...eg: kernel_thread parent test
++
++ /* Set the return value for the parent. */
++ regs->r2 = p->pid; // Return child pid to parent
++ regs->r3 = 0; //;dgt2;...eg: kernel_thread parent test
++
++ return 0;
++}
++
++/* Fill in the fpu structure for a core dump. */
++
++int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu)
++{
++#ifdef CONFIG_FPU
++ char fpustate[216];
++
++ if (FPU_IS_EMU) {
++ int i;
++
++ memcpy(fpu->fpcntl, current->thread.fpcntl, 12);
++ memcpy(fpu->fpregs, current->thread.fp, 96);
++ /* Convert internal fpu reg representation
++ * into long double format
++ */
++ for (i = 0; i < 24; i += 3)
++ fpu->fpregs[i] = ((fpu->fpregs[i] & 0xffff0000) << 15) |
++ ((fpu->fpregs[i] & 0x0000ffff) << 16);
++ return 1;
++ }
++
++ /* First dump the fpu context to avoid protocol violation. */
++...;dgt2;tmp;
++ asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
++ if (!fpustate[0])
++ return 0;
++
++ asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
++ :: "m" (fpu->fpcntl[0])
++ : "memory");
++ asm volatile ("fmovemx %/fp0-%/fp7,%0"
++ :: "m" (fpu->fpregs[0])
++ : "memory");
++#endif
++ return 1;
++}
++
++/*
++ * fill in the user structure for a core dump..
++ */
++void dump_thread(struct pt_regs * regs, struct user * dump)
++{
++ struct switch_stack *sw;
++
++ /* changed the size calculations - should hopefully work better. lbt */
++ dump->magic = CMAGIC;
++ dump->start_code = 0;
++ dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
++ dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
++ dump->u_dsize = ((unsigned long) (current->mm->brk +
++ (PAGE_SIZE-1))) >> PAGE_SHIFT;
++ dump->u_dsize -= dump->u_tsize;
++ dump->u_ssize = 0;
++
++ if (dump->start_stack < TASK_SIZE)
++ dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
++
++ dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
++ sw = ((struct switch_stack *)regs) - 1;
++ dump->regs.r1 = regs->r1;
++ dump->regs.r2 = regs->r2;
++ dump->regs.r3 = regs->r3;
++ dump->regs.r4 = regs->r4;
++ dump->regs.r5 = regs->r5;
++ dump->regs.r6 = regs->r6;
++ dump->regs.r7 = regs->r7;
++ dump->regs.r8 = regs->r8;
++ dump->regs.r9 = regs->r9;
++ dump->regs.r10 = regs->r10;
++ dump->regs.r11 = regs->r11;
++ dump->regs.r12 = regs->r12;
++ dump->regs.r13 = regs->r13;
++ dump->regs.r14 = regs->r14;
++ dump->regs.r15 = regs->r15;
++ dump->regs.r16 = sw->r16;
++ dump->regs.r17 = sw->r17;
++ dump->regs.r18 = sw->r18;
++ dump->regs.r19 = sw->r19;
++ dump->regs.r20 = sw->r20;
++ dump->regs.r21 = sw->r21;
++ dump->regs.r22 = sw->r22;
++ dump->regs.r23 = sw->r23;
++ dump->regs.ra = sw->ra;
++ dump->regs.fp = sw->fp;
++ dump->regs.gp = sw->gp;
++ dump->regs.sp = regs->sp;
++ dump->regs.orig_r2 = regs->orig_r2;
++ dump->regs.estatus = regs->estatus;
++ dump->regs.ea = regs->ea;
++ /* dump floating point stuff */
++ // dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
++}
++
++/*
++ * Generic dumping code. Used for panic and debug.
++ */
++void dump(struct pt_regs *fp)
++{
++ unsigned long *sp;
++ unsigned char *tp;
++ int i;
++
++ printk(KERN_EMERG "\nCURRENT PROCESS:\n\n");
++ printk(KERN_EMERG "COMM=%s PID=%d\n", current->comm, current->pid);
++
++ if (current->mm) {
++ printk(KERN_EMERG "TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
++ (int) current->mm->start_code,
++ (int) current->mm->end_code,
++ (int) current->mm->start_data,
++ (int) current->mm->end_data,
++ (int) current->mm->end_data,
++ (int) current->mm->brk);
++ printk(KERN_EMERG "USER-STACK=%08x KERNEL-STACK=%08x\n\n",
++ (int) current->mm->start_stack,
++ (int)(((unsigned long) current) + THREAD_SIZE));
++ }
++
++ printk(KERN_EMERG "PC: %08lx\n", fp->ea);
++ printk(KERN_EMERG "SR: %08lx SP: %08lx\n", (long) fp->estatus, (long) fp);
++ printk(KERN_EMERG "r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
++ fp->r4, fp->r5, fp->r6, fp->r7);
++ printk(KERN_EMERG "r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
++ fp->r8, fp->r9, fp->r10, fp->r11);
++ printk(KERN_EMERG "\nUSP: %08x TRAPFRAME: %08x\n", (unsigned int) fp->sp,
++ (unsigned int) fp);
++
++ printk(KERN_EMERG "\nCODE:");
++ tp = ((unsigned char *) fp->ea) - 0x20;
++ for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
++ if ((i % 0x10) == 0)
++ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
++ printk(KERN_EMERG "%08x ", (int) *sp++);
++ }
++ printk(KERN_EMERG "\n");
++
++ printk(KERN_EMERG "\nKERNEL STACK:");
++ tp = ((unsigned char *) fp) - 0x40;
++ for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
++ if ((i % 0x10) == 0)
++ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
++ printk(KERN_EMERG "%08x ", (int) *sp++);
++ }
++ printk(KERN_EMERG "\n");
++ printk(KERN_EMERG "\n");
++
++ printk(KERN_EMERG "\nUSER STACK:");
++ tp = (unsigned char *) (fp->sp - 0x10);
++ for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
++ if ((i % 0x10) == 0)
++ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
++ printk(KERN_EMERG "%08x ", (int) *sp++);
++ }
++ printk(KERN_EMERG "\n\n");
++}
++
++/*
++ * These bracket the sleeping functions..
++ */
++extern void scheduling_functions_start_here(void);
++extern void scheduling_functions_end_here(void);
++#define first_sched ((unsigned long) scheduling_functions_start_here)
++#define last_sched ((unsigned long) scheduling_functions_end_here)
++
++unsigned long get_wchan(struct task_struct *p)
++{
++ unsigned long fp, pc;
++ unsigned long stack_page;
++ int count = 0;
++ if (!p || p == current || p->state == TASK_RUNNING)
++ return 0;
++
++ stack_page = (unsigned long)p;
++ fp = ((struct switch_stack *)p->thread.ksp)->fp; //;dgt2
++ do {
++ if (fp < stack_page+sizeof(struct task_struct) ||
++ fp >= 8184+stack_page) //;dgt2;tmp
++ return 0;
++ pc = ((unsigned long *)fp)[1];
++ if (!in_sched_functions(pc))
++ return pc;
++ fp = *(unsigned long *) fp;
++ } while (count++ < 16); //;dgt2;tmp
++ return 0;
++}
++
++/* Return saved PC of a blocked thread. */
++unsigned long thread_saved_pc(struct task_struct *t)
++{
++ return (t->thread.kregs->ea);
++}
++
++/*
++ * Do necessary setup to start up a newly executed thread.
++ * Will statup in user mode (status_extension = 0).
++ */
++void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
++{
++ memset((void *) regs, 0, sizeof(struct pt_regs));
++ regs->estatus = NIOS2_STATUS_PIE_MSK; // No user mode setting, at least not for now
++ regs->ea = pc;
++ regs->sp = sp;
++
++ /* check if debug flag is set */
++ if (current->thread.flags & NIOS2_FLAG_DEBUG ) {
++ if ( *(u32*)pc == NIOS2_OP_NOP ) {
++ *(u32*)pc = NIOS2_OP_BREAK;
++ flush_icache_range(pc, pc+4);
++ }
++ }
++}
+diff --git a/arch/nios2nommu/kernel/ptrace.c b/arch/nios2nommu/kernel/ptrace.c
+new file mode 100644
+index 0000000..e6ff3b3
+--- /dev/null
++++ b/arch/nios2nommu/kernel/ptrace.c
+@@ -0,0 +1,352 @@
++/*
++ * linux/arch/m68knommu/kernel/ptrace.c
++ *
++ * Copyright (C) 1994 by Hamish Macdonald
++ * Taken from linux/kernel/ptrace.c and modified for M680x0.
++ * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License. See the file COPYING in the main directory of
++ * this archive for more details.
++ */
++
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <linux/smp.h>
++#include <linux/smp_lock.h>
++#include <linux/errno.h>
++#include <linux/ptrace.h>
++#include <linux/user.h>
++
++#include <asm/uaccess.h>
++#include <asm/page.h>
++#include <asm/pgtable.h>
++#include <asm/system.h>
++#include <asm/processor.h>
++
++/*
++ * does not yet catch signals sent when the child dies.
++ * in exit.c or in signal.c.
++ */
++
++/* determines which bits in the SR the user has access to. */
++/* 1 = access 0 = no access */
++#define SR_MASK 0x00000000
++
++/* Find the stack offset for a register, relative to thread.ksp. */
++#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
++#define SW_REG(reg) ((long)&((struct switch_stack *)0)->reg \
++ - sizeof(struct switch_stack))
++/* Mapping from PT_xxx to the stack offset at which the register is
++ saved. Notice that usp has no stack-slot and needs to be treated
++ specially (see get_reg/put_reg below). */
++static int regoff[] = {
++ -1, PT_REG(r1), PT_REG(r2), PT_REG(r3), PT_REG(r4),
++ PT_REG(r5), PT_REG(r6), PT_REG(r7), PT_REG(r8),
++ PT_REG(r9), PT_REG(r10), PT_REG(r11), PT_REG(r12),
++ PT_REG(r13), PT_REG(r14), PT_REG(r15), SW_REG(r16),
++ SW_REG(r17), SW_REG(r18), SW_REG(r19), SW_REG(r20),
++ SW_REG(r21), SW_REG(r22), SW_REG(r23), -1, -1,
++ PT_REG(gp), PT_REG(sp), -1, -1, PT_REG(ra), -1,
++ PT_REG(estatus), -1, -1, -1
++};
++
++/*
++ * Get contents of register REGNO in task TASK.
++ */
++static inline long get_reg(struct task_struct *task, int regno)
++{
++ unsigned long *addr;
++
++ if (regno == PTR_R0)
++ return 0;
++ else if (regno == PTR_BA)
++ return 0;
++ else if (regno == PTR_STATUS)
++ return 0;
++ else if (regno == PTR_IENABLE)
++ return 0;
++ else if (regno == PTR_IPENDING)
++ return 0;
++ else if (regno < sizeof(regoff)/sizeof(regoff[0]))
++ addr = (unsigned long *)(task->thread.kregs + regoff[regno]);
++ else
++ return 0;
++ return *addr;
++}
++
++/*
++ * Write contents of register REGNO in task TASK.
++ */
++static inline int put_reg(struct task_struct *task, int regno,
++ unsigned long data)
++{
++ unsigned long *addr;
++
++ if (regno == PTR_R0)
++ return -1;
++ else if (regno == PTR_BA)
++ return -1;
++ else if (regno == PTR_STATUS)
++ return -1;
++ else if (regno == PTR_IENABLE)
++ return -1;
++ else if (regno == PTR_IPENDING)
++ return -1;
++ else if (regno < sizeof(regoff)/sizeof(regoff[0]))
++ addr = (unsigned long *) (task->thread.kregs + regoff[regno]);
++ else
++ return -1;
++ *addr = data;
++ return 0;
++}
++
++/*
++ * Called by kernel/ptrace.c when detaching..
++ *
++ * Nothing special to do here, no processor debug support.
++ */
++void ptrace_disable(struct task_struct *child)
++{
++}
++
++long arch_ptrace(struct task_struct *child, long request, long addr, long data)
++{
++ int ret;
++
++ switch (request) {
++ /* when I and D space are separate, these will need to be fixed. */
++ case PTRACE_PEEKTEXT: /* read word at location addr. */
++ case PTRACE_PEEKDATA: {
++ unsigned long tmp;
++ int copied;
++
++ copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
++ ret = -EIO;
++ if (copied != sizeof(tmp))
++ break;
++ ret = put_user(tmp,(unsigned long *) data);
++ break;
++ }
++
++ /* read the word at location addr in the USER area. */
++ case PTRACE_PEEKUSR: {
++ unsigned long tmp;
++
++ ret = -EIO;
++ if ((addr & 3) || addr < 0 ||
++ addr > sizeof(struct user) - 3)
++ break;
++
++ tmp = 0; /* Default return condition */
++ addr = addr >> 2; /* temporary hack. */
++ ret = -EIO;
++ if (addr < 19) {
++ tmp = get_reg(child, addr);
++#if 0 // No FPU stuff
++ } else if (addr >= 21 && addr < 49) {
++ tmp = child->thread.fp[addr - 21];
++#ifdef CONFIG_M68KFPU_EMU
++ /* Convert internal fpu reg representation
++ * into long double format
++ */
++ if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
++ tmp = ((tmp & 0xffff0000) << 15) |
++ ((tmp & 0x0000ffff) << 16);
++#endif
++#endif
++ } else if (addr == 49) {
++ tmp = child->mm->start_code;
++ } else if (addr == 50) {
++ tmp = child->mm->start_data;
++ } else if (addr == 51) {
++ tmp = child->mm->end_code;
++ } else
++ break;
++ ret = put_user(tmp,(unsigned long *) data);
++ break;
++ }
++
++ /* when I and D space are separate, this will have to be fixed. */
++ case PTRACE_POKETEXT: /* write the word at location addr. */
++ case PTRACE_POKEDATA:
++ ret = 0;
++ if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
++ break;
++ ret = -EIO;
++ break;
++
++ case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
++ ret = -EIO;
++ if ((addr & 3) || addr < 0 ||
++ addr > sizeof(struct user) - 3)
++ break;
++
++ addr = addr >> 2; /* temporary hack. */
++
++ if (addr == PTR_ESTATUS) {
++ data &= SR_MASK;
++ data |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
++ }
++ if (addr < 19) {
++ if (put_reg(child, addr, data))
++ break;
++ ret = 0;
++ break;
++ }
++#if 0 // No FPU stuff
++ if (addr >= 21 && addr < 48)
++ {
++#ifdef CONFIG_M68KFPU_EMU
++ /* Convert long double format
++ * into internal fpu reg representation
++ */
++ if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
++ data = (unsigned long)data << 15;
++ data = (data & 0xffff0000) |
++ ((data & 0x0000ffff) >> 1);
++ }
++#endif
++ child->thread.fp[addr - 21] = data;
++ ret = 0;
++ }
++#endif
++ break;
++
++ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
++ case PTRACE_CONT: { /* restart after signal. */
++
++ ret = -EIO;
++ if ((unsigned long) data > _NSIG)
++ break;
++ if (request == PTRACE_SYSCALL)
++ set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
++ else
++ clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
++ child->exit_code = data;
++ wake_up_process(child);
++ ret = 0;
++ break;
++ }
++
++ /*
++ * make the child exit. Best I can do is send it a sigkill.
++ * perhaps it should be put in the status that it wants to
++ * exit.
++ */
++ case PTRACE_KILL: {
++
++ ret = 0;
++ if (child->state == EXIT_ZOMBIE) /* already dead */
++ break;
++ child->exit_code = SIGKILL;
++ wake_up_process(child);
++ break;
++ }
++
++ /*
++ * Single stepping requires placing break instructions in
++ * the code to break back. If you are stepping through a
++ * conditional branch you need to decode the test and put
++ * the break in the correct location.
++ */
++ case PTRACE_SINGLESTEP: { /* set the trap flag. */
++
++ ret = -EIO;
++ if ((unsigned long) data > _NSIG)
++ break;
++ clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
++
++ child->exit_code = data;
++ /* give it a chance to run. */
++ wake_up_process(child);
++ ret = 0;
++ break;
++ }
++
++ case PTRACE_DETACH: /* detach a process that was attached. */
++ ret = ptrace_detach(child, data);
++ break;
++
++ case PTRACE_GETREGS: { /* Get all gp regs from the child. */
++ int i;
++ unsigned long tmp;
++ for (i = 0; i < 19; i++) {
++ tmp = get_reg(child, i);
++ if (put_user(tmp, (unsigned long *) data)) {
++ ret = -EFAULT;
++ break;
++ }
++ data += sizeof(long);
++ }
++ ret = 0;
++ break;
++ }
++
++ case PTRACE_SETREGS: { /* Set all gp regs in the child. */
++ int i;
++ unsigned long tmp;
++ for (i = 0; i < 19; i++) {
++ if (get_user(tmp, (unsigned long *) data)) {
++ ret = -EFAULT;
++ break;
++ }
++ if (i == PTR_ESTATUS) {
++ tmp &= SR_MASK;
++ tmp |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
++ }
++ put_reg(child, i, tmp);
++ data += sizeof(long);
++ }
++ ret = 0;
++ break;
++ }
++
++#ifdef PTRACE_GETFPREGS
++ case PTRACE_GETFPREGS: { /* Get the child FPU state. */
++ ret = 0;
++ if (copy_to_user((void *)data, &child->thread.fp,
++ sizeof(struct user_m68kfp_struct)))
++ ret = -EFAULT;
++ break;
++ }
++#endif
++
++#ifdef PTRACE_SETFPREGS
++ case PTRACE_SETFPREGS: { /* Set the child FPU state. */
++ ret = 0;
++ if (copy_from_user(&child->thread.fp, (void *)data,
++ sizeof(struct user_m68kfp_struct)))
++ ret = -EFAULT;
++ break;
++ }
++#endif
++
++ default:
++ ret = -EIO;
++ break;
++ }
++ return ret;
++}
++
++asmlinkage void syscall_trace(void)
++{
++ if (!test_thread_flag(TIF_SYSCALL_TRACE))
++ return;
++ if (!(current->ptrace & PT_PTRACED))
++ return;
++ current->exit_code = SIGTRAP;
++ current->state = TASK_STOPPED;
++ ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
++ ? 0x80 : 0));
++ /*
++ * this isn't the same as continuing with a signal, but it will do
++ * for normal use. strace only continues with a signal if the
++ * stopping signal is not SIGTRAP. -brl
++ */
++ if (current->exit_code) {
++ send_sig(current->exit_code, current, 1);
++ current->exit_code = 0;
++ }
++}
+diff --git a/arch/nios2nommu/kernel/semaphore.c b/arch/nios2nommu/kernel/semaphore.c
+new file mode 100644
+index 0000000..0c7d11b
+--- /dev/null
++++ b/arch/nios2nommu/kernel/semaphore.c
+@@ -0,0 +1,155 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/semaphore.c
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++/*
++ * Generic semaphore code. Buyer beware. Do your own
++ * specific changes in <asm/semaphore-helper.h>
++ */
++
++#include <linux/sched.h>
++#include <linux/err.h>
++#include <asm/semaphore-helper.h>
++
++#ifndef CONFIG_RMW_INSNS
++spinlock_t semaphore_wake_lock;
++#endif
++
++/*
++ * Semaphores are implemented using a two-way counter:
++ * The "count" variable is decremented for each process
++ * that tries to sleep, while the "waking" variable is
++ * incremented when the "up()" code goes to wake up waiting
++ * processes.
++ *
++ * Notably, the inline "up()" and "down()" functions can
++ * efficiently test if they need to do any extra work (up
++ * needs to do something only if count was negative before
++ * the increment operation.
++ *
++ * waking_non_zero() (from asm/semaphore.h) must execute
++ * atomically.
++ *
++ * When __up() is called, the count was negative before
++ * incrementing it, and we need to wake up somebody.
++ *
++ * This routine adds one to the count of processes that need to
++ * wake up and exit. ALL waiting processes actually wake up but
++ * only the one that gets to the "waking" field first will gate
++ * through and acquire the semaphore. The others will go back
++ * to sleep.
++ *
++ * Note that these functions are only called when there is
++ * contention on the lock, and as such all this is the
++ * "non-critical" part of the whole semaphore business. The
++ * critical part is the inline stuff in <asm/semaphore.h>
++ * where we want to avoid any extra jumps and calls.
++ */
++asmlinkage void __up(struct semaphore *sem)
++{
++ wake_one_more(sem);
++ wake_up(&sem->wait);
++}
++
++/*
++ * Perform the "down" function. Return zero for semaphore acquired,
++ * return negative for signalled out of the function.
++ *
++ * If called from __down, the return is ignored and the wait loop is
++ * not interruptible. This means that a task waiting on a semaphore
++ * using "down()" cannot be killed until someone does an "up()" on
++ * the semaphore.
++ *
++ * If called from __down_interruptible, the return value gets checked
++ * upon return. If the return value is negative then the task continues
++ * with the negative value in the return register (it can be tested by
++ * the caller).
++ *
++ * Either form may be used in conjunction with "up()".
++ *
++ */
++
++
++#define DOWN_HEAD(task_state) \
++ \
++ \
++ current->state = (task_state); \
++ add_wait_queue(&sem->wait, &wait); \
++ \
++ /* \
++ * Ok, we're set up. sem->count is known to be less than zero \
++ * so we must wait. \
++ * \
++ * We can let go the lock for purposes of waiting. \
++ * We re-acquire it after awaking so as to protect \
++ * all semaphore operations. \
++ * \
++ * If "up()" is called before we call waking_non_zero() then \
++ * we will catch it right away. If it is called later then \
++ * we will have to go through a wakeup cycle to catch it. \
++ * \
++ * Multiple waiters contend for the semaphore lock to see \
++ * who gets to gate through and who has to wait some more. \
++ */ \
++ for (;;) {
++
++#define DOWN_TAIL(task_state) \
++ current->state = (task_state); \
++ } \
++ current->state = TASK_RUNNING; \
++ remove_wait_queue(&sem->wait, &wait);
++
++void __sched __down(struct semaphore * sem)
++{
++ DECLARE_WAITQUEUE(wait, current);
++
++ DOWN_HEAD(TASK_UNINTERRUPTIBLE)
++ if (waking_non_zero(sem))
++ break;
++ schedule();
++ DOWN_TAIL(TASK_UNINTERRUPTIBLE)
++}
++
++int __sched __down_interruptible(struct semaphore * sem)
++{
++ DECLARE_WAITQUEUE(wait, current);
++ int ret = 0;
++
++ DOWN_HEAD(TASK_INTERRUPTIBLE)
++
++ ret = waking_non_zero_interruptible(sem, current);
++ if (ret)
++ {
++ if (ret == 1)
++ /* ret != 0 only if we get interrupted -arca */
++ ret = 0;
++ break;
++ }
++ schedule();
++ DOWN_TAIL(TASK_INTERRUPTIBLE)
++ return ret;
++}
++
++int __down_trylock(struct semaphore * sem)
++{
++ return waking_non_zero_trylock(sem);
++}
+diff --git a/arch/nios2nommu/kernel/setup.c b/arch/nios2nommu/kernel/setup.c
+new file mode 100644
+index 0000000..1f1627b
+--- /dev/null
++++ b/arch/nios2nommu/kernel/setup.c
+@@ -0,0 +1,663 @@
++/*
++ 21Mar2001 1.1 dgt/microtronix: Altera Excalibur/Nios32 port
++ 30Jun2003 kenw/microtronix: Remove cmdline check in flash
++*/
++
++/*
++ * linux/arch/niosnommu/kernel/setup.c
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2001 Vic Phillips {vic@microtronix.com}
++ * Copyleft (C) 2000 James D. Schettine {james@telos-systems.com}
++ * Copyright (C) 1999 Greg Ungerer (gerg@moreton.com.au)
++ * Copyright (C) 1998,2000 D. Jeff Dionne <jeff@lineo.ca>
++ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
++ * Copyright (C) 1995 Hamish Macdonald
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++/*
++ * This file handles the architecture-dependent parts of system setup
++ */
++
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <linux/platform_device.h>
++#include <linux/delay.h>
++#include <linux/interrupt.h>
++#include <linux/fs.h>
++#include <linux/fb.h>
++#include <linux/module.h>
++#include <linux/console.h>
++#include <linux/genhd.h>
++#include <linux/errno.h>
++#include <linux/string.h>
++#include <linux/major.h>
++#include <linux/bootmem.h>
++#include <linux/initrd.h>
++#include <linux/seq_file.h>
++
++#include <asm/irq.h>
++#include <asm/byteorder.h>
++#include <asm/asm-offsets.h>
++#include <asm/pgtable.h>
++
++#ifdef CONFIG_BLK_DEV_INITRD
++#include <linux/blk.h>
++#endif
++
++#ifdef CONFIG_NIOS_SPI
++#include <asm/spi.h>
++extern ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos);
++extern ssize_t spi_read (struct file *filp, char *buf, size_t count, loff_t *ppos);
++extern loff_t spi_lseek (struct file *filp, loff_t offset, int origin);
++extern int spi_open (struct inode *inode, struct file *filp);
++extern int spi_release (struct inode *inode, struct file *filp);
++#endif
++
++#ifdef CONFIG_CONSOLE
++extern struct consw *conswitchp;
++#endif
++
++unsigned long rom_length;
++unsigned long memory_start;
++unsigned long memory_end;
++
++EXPORT_SYMBOL(memory_start);
++EXPORT_SYMBOL(memory_end);
++
++#ifndef CONFIG_CMDLINE
++#define CONFIG_CMDLINE "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
++#endif
++
++#ifndef CONFIG_PASS_CMDLINE
++static char default_command_line[] = CONFIG_CMDLINE;
++#endif
++static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };
++
++
++/* r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11*/
++/* r12 r13 r14 r15 or2 ra fp sp gp es ste ea*/
++static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
++ 0, 0, 0, 0, 0, (unsigned long)cpu_idle, 0, 0, 0, 0, 0, 0};
++
++#define CPU "NIOS2"
++
++#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
++ #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
++ #include <../drivers/net/mtip1000.h> //;dgt3;
++ #endif //;dgt3;
++
++ unsigned char *excalibur_enet_hwaddr;
++ unsigned char excalibur_enet_hwaddr_array[6];
++#endif
++
++// save args passed from u-boot, called from head.S
++void nios2_boot_init(unsigned r4,unsigned r5,unsigned r6,unsigned r7)
++{
++#if defined(CONFIG_PASS_CMDLINE)
++ if (r4 == 0x534f494e) // r4 is magic NIOS, to become board info check in the future
++ {
++#if defined(CONFIG_BLK_DEV_INITRD)
++ /*
++ * If the init RAM disk has been configured in, and there's a valid
++ * starting address for it, set it up.
++ */
++ if (r5) {
++ initrd_start = r5;
++ initrd_end = r6;
++ }
++#endif /* CONFIG_BLK_DEV_INITRD */
++ if (r7)
++ strncpy(command_line, (char *)r7, COMMAND_LINE_SIZE);
++ }
++#endif
++}
++
++inline void flash_command(int base, int offset, short data)
++{
++ volatile unsigned short * ptr=(unsigned short*) (base);
++
++ ptr[0x555]=0xaa;
++ ptr[0x2aa]=0x55;
++ ptr[offset]=data;
++}
++
++inline void exit_se_flash(int base)
++{
++ flash_command(base, 0x555, 0x90);
++ *(unsigned short*)base=0;
++}
++
++void __init setup_arch(char **cmdline_p)
++{
++ int bootmap_size;
++ extern int _stext, _etext;
++ extern int _edata, _end;
++#ifdef DEBUG
++ extern int _sdata, _sbss, _ebss;
++#ifdef CONFIG_BLK_DEV_BLKMEM
++ extern int *romarray;
++#endif
++#endif
++#if 0 // krh
++ unsigned char *psrc=(unsigned char *)((NIOS_FLASH_START + NIOS_FLASH_END)>>1);
++ int i=0;
++#endif // krh
++
++ memory_start = PAGE_ALIGN((unsigned long)&_end);
++ memory_end = (unsigned long) nasys_program_mem_end;
++
++#if 0 //;kenw;
++ /* copy the command line from booting paramter region */
++ #if defined (nasys_am29lv065d_flash_0) //;dgt;
++ { //;dgt;
++ // ...TBA... //;dgt;
++ } //;dgt;
++ #else //;dgt;
++ flash_command((int)psrc, 0x555, 0x88);
++ while ((*psrc!=0xFF) && (i<sizeof(command_line))) {
++ command_line[i++]=*psrc++;
++ }
++ command_line[i]=0;
++ exit_se_flash(((NIOS_FLASH_START + NIOS_FLASH_END)>>1) );
++ if (command_line[0]==0)
++ #endif //;dgt;
++#endif //;kenw;
++#ifndef CONFIG_PASS_CMDLINE
++ memcpy(command_line, default_command_line, sizeof(default_command_line));
++#endif
++
++ printk("\x0F\r\n\nuClinux/Nios II\n");
++ printk("Altera Nios II support (C) 2004 Microtronix Datacom Ltd.\n");
++
++#ifdef DEBUG
++ printk("KERNEL -> TEXT=0x%08x-0x%08x DATA=0x%08x-0x%08x "
++ "BSS=0x%08x-0x%08x\n", (int) &_stext, (int) &_etext,
++ (int) &_sdata, (int) &_edata,
++ (int) &_sbss, (int) &_ebss);
++ printk("KERNEL -> MEM=0x%06x-0x%06x STACK=0x%06x-0x%06x\n",
++ (int) memory_start, (int) memory_end,
++ (int) memory_end, (int) nasys_program_mem_end);
++#endif
++
++ init_mm.start_code = (unsigned long) &_stext;
++ init_mm.end_code = (unsigned long) &_etext;
++ init_mm.end_data = (unsigned long) &_edata;
++ init_mm.brk = (unsigned long) 0;
++ init_task.thread.kregs = &fake_regs;
++
++#if 0
++ ROOT_DEV = MKDEV(BLKMEM_MAJOR,0);
++#endif
++
++ /* Keep a copy of command line */
++ *cmdline_p = &command_line[0];
++
++ memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
++ saved_command_line[COMMAND_LINE_SIZE-1] = 0;
++
++#ifdef DEBUG
++ if (strlen(*cmdline_p))
++ printk("Command line: '%s'\n", *cmdline_p);
++ else
++ printk("No Command line passed\n");
++#endif
++
++
++#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
++
++ #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
++ (*((np_mtip_mac *) //;dgt3;
++ (na_mtip_mac_control_port))). //;dgt3;
++ COMMAND_CONFIG = 0; //;dgt3;
++ #endif //;dgt3;
++
++ /* now read the hwaddr of the ethernet --wentao*/
++
++ #if 1 //;dgt2;
++// #if defined (nasys_am29lv065d_flash_0) //;dgt;
++ { //;dgt;
++ unsigned char *flashptr = //;dgt;
++ ((unsigned char *) //;dgt;
++ (( //;dgt;
++ #if defined (na_flash_kernel_end) //;dgt2;
++ na_flash_kernel_end //;dgt2;
++ #else //;dgt2;
++ #if defined (na_flash_kernel_base) //;dgt2;
++ na_flash_kernel_base + //;dgt;
++ #else //;dgt2;
++ na_flash_kernel + //;dgt2;
++ #endif //;dgt2;
++ na_flash_kernel_size //;dgt2;
++ #endif //;dgt2;
++ - 0x00010000))); //;dgt;
++ // last 64K of Altera stratix/cyclone flash //;dgt;
++ //;dgt;
++ if((*((unsigned long *) flashptr)) == 0x00005AFE) //;dgt;
++ { //;dgt;
++ memcpy(excalibur_enet_hwaddr_array, //;dgt;
++ ((void*) (flashptr+4)),6); //;dgt;
++ } //;dgt;
++ else //;dgt;
++ { //;dgt;
++ printk("\nsetup_arch: No persistant network" //;dgt;
++ " settings signature at %08lX\n", //;dgt;
++ ((unsigned long) flashptr)); //;dgt;
++ *((unsigned long *) //;dgt;
++ (&(excalibur_enet_hwaddr_array[0]))) = //;dgt;
++ 0x00ED0700; //;dgt2;
++ /* 0x00-07-ED: Altera Corporation. //;dgt; */
++ *((unsigned short *) //;dgt;
++ (&(excalibur_enet_hwaddr_array[4]))) = //;dgt;
++ 0x0000; //;dgt;
++ /* Should be: 0x-00-07-ED-0A-03-(Random# 0-256) //;dgt2; */
++ /* 0x-00-07-ED-0A-xx-yy Vermont boards //;dgt2; */
++ /* 0x-00-07-ED-0B-xx-yy Rhode Island boards //;dgt2; */
++ /* 0x-00-07-ED-0C-xx-yy Delaware boards //;dgt2; */
++ /* 00 Internal Altera //;dgt2; */
++ /* 01 Beta, pre-production//;dgt2; */
++ /* 02 Beta, pre-production//;dgt2; */
++ /* 03 Customer use //;dgt2; */
++ } //;dgt;
++ } //;dgt;
++ #else //;dgt;
++ flash_command(NIOS_FLASH_START, 0x555, 0x88);
++ memcpy(excalibur_enet_hwaddr_array,(void*)NIOS_FLASH_START,6);
++ exit_se_flash(NIOS_FLASH_START);;
++ #endif //;dgt;
++
++ /* now do the checking, make sure we got a valid addr */
++ if (excalibur_enet_hwaddr_array[0] & (unsigned char)1)
++ {
++ printk("Ethernet hardware address:Clearing invalid bit #0\n");
++ excalibur_enet_hwaddr_array[0] ^= (unsigned char)1;
++ }
++ excalibur_enet_hwaddr=excalibur_enet_hwaddr_array;
++#ifdef DEBUG
++ printk("Setup the hardware addr for ethernet\n\t %02x %02x %02x %02x %02x %02x\n",
++ excalibur_enet_hwaddr[0],excalibur_enet_hwaddr[1],
++ excalibur_enet_hwaddr[2],excalibur_enet_hwaddr[3],
++ excalibur_enet_hwaddr[4],excalibur_enet_hwaddr[5]);
++#endif
++#endif
++
++
++ /*
++ * give all the memory to the bootmap allocator, tell it to put the
++ * boot mem_map at the start of memory
++ */
++ bootmap_size = init_bootmem_node(
++ NODE_DATA(0),
++ memory_start >> PAGE_SHIFT, /* map goes here */
++ PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
++ memory_end >> PAGE_SHIFT);
++ /*
++ * free the usable memory, we have to make sure we do not free
++ * the bootmem bitmap so we then reserve it after freeing it :-)
++ */
++ free_bootmem(memory_start, memory_end - memory_start);
++ reserve_bootmem(memory_start, bootmap_size);
++#ifdef CONFIG_BLK_DEV_INITRD
++ if (initrd_start) reserve_bootmem(virt_to_phys((void *)initrd_start), initrd_end - initrd_start);
++#endif /* CONFIG_BLK_DEV_INITRD */
++ /*
++ * get kmalloc into gear
++ */
++ paging_init();
++#ifdef CONFIG_VT
++#if defined(CONFIG_DUMMY_CONSOLE)
++ conswitchp = &dummy_con;
++#endif
++#endif
++
++#ifdef DEBUG
++ printk("Done setup_arch\n");
++#endif
++
++}
++
++int get_cpuinfo(char * buffer)
++{
++ char *cpu, *mmu, *fpu;
++ u_long clockfreq;
++
++ cpu = CPU;
++ mmu = "none";
++ fpu = "none";
++
++ clockfreq = nasys_clock_freq;
++
++ return(sprintf(buffer, "CPU:\t\t%s\n"
++ "MMU:\t\t%s\n"
++ "FPU:\t\t%s\n"
++ "Clocking:\t%lu.%1luMHz\n"
++ "BogoMips:\t%lu.%02lu\n"
++ "Calibration:\t%lu loops\n",
++ cpu, mmu, fpu,
++ clockfreq/1000000,(clockfreq/100000)%10,
++ (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
++ (loops_per_jiffy*HZ)));
++
++}
++
++/*
++ * Get CPU information for use by the procfs.
++ */
++
++static int show_cpuinfo(struct seq_file *m, void *v)
++{
++ char *cpu, *mmu, *fpu;
++ u_long clockfreq;
++
++ cpu = CPU;
++ mmu = "none";
++ fpu = "none";
++
++ clockfreq = nasys_clock_freq;
++
++ seq_printf(m, "CPU:\t\t%s\n"
++ "MMU:\t\t%s\n"
++ "FPU:\t\t%s\n"
++ "Clocking:\t%lu.%1luMHz\n"
++ "BogoMips:\t%lu.%02lu\n"
++ "Calibration:\t%lu loops\n",
++ cpu, mmu, fpu,
++ clockfreq/1000000,(clockfreq/100000)%10,
++ (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
++ (loops_per_jiffy*HZ));
++
++ return 0;
++}
++
++#ifdef CONFIG_NIOS_SPI
++
++static int bcd2char( int x )
++{
++ if ( (x & 0xF) > 0x90 || (x & 0x0F) > 0x09 )
++ return 99;
++
++ return (((x & 0xF0) >> 4) * 10) + (x & 0x0F);
++}
++
++#endif // CONFIG_NIOS_SPI
++
++
++void arch_gettod(int *year, int *month, int *date, int *hour, int *min, int *sec)
++{
++#ifdef CONFIG_NIOS_SPI
++ /********************************************************************/
++ /* Read the CMOS clock on the Microtronix Datacom O/S Support card. */
++ /* Use the SPI driver code, but circumvent the file system by using */
++ /* its internal functions. */
++ /********************************************************************/
++ int hr;
++
++ struct /*********************************/
++ { /* The SPI payload. Warning: the */
++ unsigned short register_addr; /* sizeof() operator will return */
++ unsigned char value; /* a length of 4 instead of 3! */
++ } spi_data; /*********************************/
++
++
++ if ( spi_open( NULL, NULL ) )
++ {
++ printk( "Cannot open SPI driver to read system CMOS clock.\n" );
++ *year = *month = *date = *hour = *min = *sec = 0;
++ return;
++ }
++
++ spi_lseek( NULL, clockCS, 0 /* == SEEK_SET */ );
++
++ spi_data.register_addr = clock_write_control;
++ spi_data.value = 0x40; // Write protect
++ spi_write( NULL, (const char *)&spi_data, 3, NULL );
++
++ spi_data.register_addr = clock_read_sec;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ *sec = (int)bcd2char( spi_data.value );
++
++ spi_data.register_addr = clock_read_min;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ *min = (int)bcd2char( spi_data.value );
++
++ spi_data.register_addr = clock_read_hour;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ hr = (int)bcd2char( spi_data.value );
++ if ( hr & 0x40 ) // Check 24-hr bit
++ hr = (hr & 0x3F) + 12; // Convert to 24-hr
++
++ *hour = hr;
++
++
++
++ spi_data.register_addr = clock_read_date;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ *date = (int)bcd2char( spi_data.value );
++
++ spi_data.register_addr = clock_read_month;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ *month = (int)bcd2char( spi_data.value );
++
++ spi_data.register_addr = clock_read_year;
++ spi_data.value = 0;
++ spi_read( NULL, (char *)&spi_data, 3, NULL );
++ *year = (int)bcd2char( spi_data.value );
++
++
++ spi_release( NULL, NULL );
++#else
++ *year = *month = *date = *hour = *min = *sec = 0;
++
++#endif
++}
++
++static void *cpuinfo_start (struct seq_file *m, loff_t *pos)
++{
++ return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
++}
++
++static void *cpuinfo_next (struct seq_file *m, void *v, loff_t *pos)
++{
++ ++*pos;
++ return cpuinfo_start (m, pos);
++}
++
++static void cpuinfo_stop (struct seq_file *m, void *v)
++{
++}
++
++struct seq_operations cpuinfo_op = {
++ start: cpuinfo_start,
++ next: cpuinfo_next,
++ stop: cpuinfo_stop,
++ show: show_cpuinfo
++};
++
++
++// adapted from linux/arch/arm/mach-versatile/core.c and mach-bast
++// note, hardware MAC address is still undefined
++
++#if defined(CONFIG_SMC91X) && defined(na_enet)
++
++#ifndef LAN91C111_REGISTERS_OFFSET
++#define LAN91C111_REGISTERS_OFFSET 0x300
++#endif
++
++static struct resource smc91x_resources[] = {
++ [0] = {
++ .start = na_enet + LAN91C111_REGISTERS_OFFSET,
++ .end = na_enet + LAN91C111_REGISTERS_OFFSET + 0x100 - 1, // 32bits,64k, LAN91C111_REGISTERS_OFFSET 0x0300 ?
++ .flags = IORESOURCE_MEM,
++ },
++ [1] = {
++ .start = na_enet_irq,
++ .end = na_enet_irq,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++static struct platform_device smc91x_device = {
++ .name = "smc91x",
++ .id = 0,
++ .num_resources = ARRAY_SIZE(smc91x_resources),
++ .resource = smc91x_resources,
++};
++static int __init smc91x_device_init(void)
++{
++ /* customizes platform devices, or adds new ones */
++ platform_device_register(&smc91x_device);
++ return 0;
++}
++arch_initcall(smc91x_device_init);
++#endif // CONFIG_SMC91X
++
++
++#if defined(na_DM9000A) && !defined(na_dm9000) // defs for DE2
++#define na_dm9000 na_DM9000A
++#define na_dm9000_irq na_DM9000A_irq
++#endif
++
++#if defined(CONFIG_DM9000) && defined(na_dm9000)
++#include <linux/dm9000.h>
++static struct resource dm9k_resource[] = {
++ [0] = {
++ .start = na_dm9000,
++ .end = na_dm9000 + 3,
++ .flags = IORESOURCE_MEM,
++ },
++ [1] = {
++ .start = na_dm9000 + 4,
++ .end = na_dm9000 + 4 + 3,
++ .flags = IORESOURCE_MEM,
++ },
++ [2] = {
++ .start = na_dm9000_irq,
++ .end = na_dm9000_irq,
++ .flags = IORESOURCE_IRQ,
++ }
++
++};
++static struct dm9000_plat_data dm9k_platdata = {
++ .flags = DM9000_PLATF_16BITONLY,
++};
++static struct platform_device dm9k_device = {
++ .name = "dm9000",
++ .id = 0,
++ .num_resources = ARRAY_SIZE(dm9k_resource),
++ .resource = dm9k_resource,
++ .dev = {
++ .platform_data = &dm9k_platdata,
++ }
++};
++static int __init dm9k_device_init(void)
++{
++ /* customizes platform devices, or adds new ones */
++ platform_device_register(&dm9k_device);
++ return 0;
++}
++arch_initcall(dm9k_device_init);
++#endif // CONFIG_DM9000
++
++
++#if defined(CONFIG_SERIO_ALTPS2) && defined(na_ps2_0)
++
++static struct resource altps2_0_resources[] = {
++ [0] = {
++ .start = na_ps2_0,
++ .end = na_ps2_0 + 0x8 - 1,
++ .flags = IORESOURCE_MEM,
++ },
++ [1] = {
++ .start = na_ps2_0_irq,
++ .end = na_ps2_0_irq,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++static struct platform_device altps2_0_device = {
++ .name = "altps2",
++ .id = 0,
++ .num_resources = ARRAY_SIZE(altps2_0_resources),
++ .resource = altps2_0_resources,
++};
++
++#if defined(na_ps2_1)
++static struct resource altps2_1_resources[] = {
++ [0] = {
++ .start = na_ps2_1,
++ .end = na_ps2_1 + 0x8 - 1,
++ .flags = IORESOURCE_MEM,
++ },
++ [1] = {
++ .start = na_ps2_1_irq,
++ .end = na_ps2_1_irq,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++static struct platform_device altps2_1_device = {
++ .name = "altps2",
++ .id = 0,
++ .num_resources = ARRAY_SIZE(altps2_1_resources),
++ .resource = altps2_1_resources,
++};
++#endif // na_ps2_1
++
++static int __init altps2_device_init(void)
++{
++ /* customizes platform devices, or adds new ones */
++ platform_device_register(&altps2_0_device);
++#if defined(na_ps2_1)
++ platform_device_register(&altps2_1_device);
++#endif // na_ps2_1
++ return 0;
++}
++arch_initcall(altps2_device_init);
++#endif // CONFIG_SERIO_ALTPS2
++
++#if defined(CONFIG_I2C_NIOS2_GPIO) && defined(na_gpio_0)
++#include <asm/gpio.h>
++
++static struct gpio_i2c_pins i2c_gpio_0_pins = {
++ .sda_pin = (na_gpio_0+(0<<2)),
++ .scl_pin = (na_gpio_0+(1<<2)),
++};
++
++static struct platform_device i2c_gpio_0_controller = {
++ .name = "GPIO-I2C",
++ .id = 0,
++ .dev = {
++ .platform_data = &i2c_gpio_0_pins,
++ },
++ .num_resources = 0
++};
++
++static int __init i2c_gpio_device_init(void)
++{
++ /* customizes platform devices, or adds new ones */
++ platform_device_register(&i2c_gpio_0_controller);
++ return 0;
++}
++arch_initcall(i2c_gpio_device_init);
++
++#endif // CONFIG_I2C_NIOS2_GPIO
+diff --git a/arch/nios2nommu/kernel/signal.c b/arch/nios2nommu/kernel/signal.c
+new file mode 100644
+index 0000000..d8c30dc
+--- /dev/null
++++ b/arch/nios2nommu/kernel/signal.c
+@@ -0,0 +1,738 @@
++/*
++ * linux/arch/nios2nommu/kernel/signal.c
++ *
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file COPYING in the main directory of this archive
++ * for more details.
++ *
++ * Linux/m68k support by Hamish Macdonald
++ *
++ * 68060 fixes by Jesper Skov
++ *
++ * 1997-12-01 Modified for POSIX.1b signals by Andreas Schwab
++ *
++ * mathemu support by Roman Zippel
++ * (Note: fpstate in the signal context is completely ignored for the emulator
++ * and the internal floating point format is put on stack)
++ *
++ * ++roman (07/09/96): implemented signal stacks (specially for tosemu on
++ * Atari :-) Current limitation: Only one sigstack can be active at one time.
++ * If a second signal with SA_ONSTACK set arrives while working on a sigstack,
++ * SA_ONSTACK is ignored. This behaviour avoids lots of trouble with nested
++ * signal handlers!
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ */
++
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <linux/kernel.h>
++#include <linux/signal.h>
++#include <linux/errno.h>
++#include <linux/wait.h>
++#include <linux/ptrace.h>
++#include <linux/unistd.h>
++#include <linux/stddef.h>
++#include <linux/highuid.h>
++#include <linux/tty.h>
++#include <linux/personality.h>
++#include <linux/binfmts.h>
++
++#include <asm/setup.h>
++#include <asm/uaccess.h>
++#include <asm/pgtable.h>
++#include <asm/traps.h>
++#include <asm/ucontext.h>
++
++#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
++
++asmlinkage long sys_wait4(pid_t pid, unsigned int * stat_addr, int options,
++ struct rusage * ru);
++asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
++
++/*
++ * Atomically swap in the new signal mask, and wait for a signal.
++ */
++asmlinkage int do_sigsuspend(struct pt_regs *regs)
++{
++ old_sigset_t mask = regs->r4; // Verify correct syscall reg
++ sigset_t saveset;
++
++ mask &= _BLOCKABLE;
++ spin_lock_irq(&current->sighand->siglock);
++ saveset = current->blocked;
++ siginitset(&current->blocked, mask);
++ recalc_sigpending();
++ spin_unlock_irq(&current->sighand->siglock);
++
++ regs->r2 = -EINTR;
++ while (1) {
++ current->state = TASK_INTERRUPTIBLE;
++ schedule();
++ if (do_signal(&saveset, regs))
++ return -EINTR;
++ }
++}
++
++asmlinkage int
++do_rt_sigsuspend(struct pt_regs *regs)
++{
++ sigset_t *unewset = (sigset_t *)regs->r4;
++ size_t sigsetsize = (size_t)regs->r5;
++ sigset_t saveset, newset;
++
++ /* XXX: Don't preclude handling different sized sigset_t's. */
++ if (sigsetsize != sizeof(sigset_t))
++ return -EINVAL;
++
++ if (copy_from_user(&newset, unewset, sizeof(newset)))
++ return -EFAULT;
++ sigdelsetmask(&newset, ~_BLOCKABLE);
++
++ spin_lock_irq(&current->sighand->siglock);
++ saveset = current->blocked;
++ current->blocked = newset;
++ recalc_sigpending();
++ spin_unlock_irq(&current->sighand->siglock);
++
++ regs->r2 = -EINTR;
++ while (1) {
++ current->state = TASK_INTERRUPTIBLE;
++ schedule();
++ if (do_signal(&saveset, regs))
++ return -EINTR;
++ }
++}
++
++asmlinkage int
++sys_sigaction(int sig, const struct old_sigaction *act,
++ struct old_sigaction *oact)
++{
++ struct k_sigaction new_ka, old_ka;
++ int ret;
++
++ if (act) {
++ old_sigset_t mask;
++ if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
++ __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
++ __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
++ return -EFAULT;
++ __get_user(new_ka.sa.sa_flags, &act->sa_flags);
++ __get_user(mask, &act->sa_mask);
++ siginitset(&new_ka.sa.sa_mask, mask);
++ }
++
++ ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
++
++ if (!ret && oact) {
++ if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
++ __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
++ __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
++ return -EFAULT;
++ __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
++ __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
++ }
++
++ return ret;
++}
++
++/*
++ * Do a signal return; undo the signal stack.
++ *
++ * Keep the return code on the stack quadword aligned!
++ * That makes the cache flush below easier.
++ */
++
++
++struct sigframe
++{
++ char retcode[12];
++ unsigned long extramask[_NSIG_WORDS-1];
++ struct sigcontext sc;
++};
++
++struct rt_sigframe
++{
++ char retcode[12];
++ struct siginfo info;
++ struct ucontext uc;
++};
++
++#ifdef CONFIG_FPU
++
++static unsigned char fpu_version = 0; /* version number of fpu, set by setup_frame */
++
++static inline int restore_fpu_state(struct sigcontext *sc)
++{
++ int err = 1;
++
++ if (FPU_IS_EMU) {
++ /* restore registers */
++ memcpy(current->thread.fpcntl, sc->sc_fpcntl, 12);
++ memcpy(current->thread.fp, sc->sc_fpregs, 24);
++ return 0;
++ }
++
++ if (sc->sc_fpstate[0]) {
++ /* Verify the frame format. */
++ if (sc->sc_fpstate[0] != fpu_version)
++ goto out;
++
++ __asm__ volatile ("Nios II FPU"
++ : /* no outputs */
++ : );
++ }
++ __asm__ volatile ("Nios II FPU"
++ : : );
++ err = 0;
++
++out:
++ return err;
++}
++
++#define FPCONTEXT_SIZE 216
++#define uc_fpstate uc_filler[0]
++#define uc_formatvec uc_filler[FPCONTEXT_SIZE/4]
++#define uc_extra uc_filler[FPCONTEXT_SIZE/4+1]
++
++static inline int rt_restore_fpu_state(struct ucontext *uc)
++{
++ unsigned char fpstate[FPCONTEXT_SIZE];
++ int context_size = 0;
++ fpregset_t fpregs;
++ int err = 1;
++
++ if (FPU_IS_EMU) {
++ /* restore fpu control register */
++ if (__copy_from_user(current->thread.fpcntl,
++ &uc->uc_mcontext.fpregs.f_pcr, 12))
++ goto out;
++ /* restore all other fpu register */
++ if (__copy_from_user(current->thread.fp,
++ uc->uc_mcontext.fpregs.f_fpregs, 96))
++ goto out;
++ return 0;
++ }
++
++ if (__get_user(*(long *)fpstate, (long *)&uc->uc_fpstate))
++ goto out;
++ if (fpstate[0]) {
++ context_size = fpstate[1];
++
++ /* Verify the frame format. */
++ if (fpstate[0] != fpu_version)
++ goto out;
++ if (__copy_from_user(&fpregs, &uc->uc_mcontext.fpregs,
++ sizeof(fpregs)))
++ goto out;
++ __asm__ volatile ("Nios II FPU"
++ : /* no outputs */
++ : );
++ }
++ if (context_size &&
++ __copy_from_user(fpstate + 4, (long *)&uc->uc_fpstate + 1,
++ context_size))
++ goto out;
++ __asm__ volatile ("Nios II FPU"
++ : : );
++ err = 0;
++
++out:
++ return err;
++}
++
++#endif
++
++static inline int
++restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
++ int *pr2)
++{
++ int err = 0;
++ int estatus;
++
++ estatus = regs->estatus;
++
++ /* get previous pt_regs */
++ if (copy_from_user(regs, &usc->regs, sizeof(*regs)))
++ goto badframe;
++
++ /* Prevent user from being able to change
++ * certain processor status bits. Currently nothing.
++ */
++ regs->estatus = (estatus & 0xffffffff) | (regs->estatus & 0);
++
++ *pr2 = regs->r2;
++ regs->orig_r2 = -1; /* disable syscall checks */
++
++#ifdef CONFIG_FPU
++ err |= restore_fpu_state(&context);
++#endif
++
++ return err;
++
++badframe:
++ return 1;
++}
++
++static inline int
++rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw,
++ struct ucontext *uc, int *pr2)
++{
++ int temp;
++ greg_t *gregs = uc->uc_mcontext.gregs;
++ unsigned long usp;
++ int err;
++
++ err = __get_user(temp, &uc->uc_mcontext.version);
++ if (temp != MCONTEXT_VERSION)
++ goto badframe;
++ /* restore passed registers */
++ err |= __get_user(regs->r1, &gregs[0]);
++ err |= __get_user(regs->r2, &gregs[1]);
++ err |= __get_user(regs->r3, &gregs[2]);
++ err |= __get_user(regs->r4, &gregs[3]);
++ err |= __get_user(regs->r5, &gregs[4]);
++ err |= __get_user(regs->r6, &gregs[5]);
++ err |= __get_user(regs->r7, &gregs[6]);
++ err |= __get_user(regs->r8, &gregs[7]);
++ err |= __get_user(regs->r9, &gregs[8]);
++ err |= __get_user(regs->r10, &gregs[9]);
++ err |= __get_user(regs->r11, &gregs[10]);
++ err |= __get_user(regs->r12, &gregs[11]);
++ err |= __get_user(regs->r13, &gregs[12]);
++ err |= __get_user(regs->r14, &gregs[13]);
++ err |= __get_user(regs->r15, &gregs[14]);
++ err |= __get_user(sw->r16, &gregs[15]);
++ err |= __get_user(sw->r17, &gregs[16]);
++ err |= __get_user(sw->r18, &gregs[17]);
++ err |= __get_user(sw->r19, &gregs[18]);
++ err |= __get_user(sw->r20, &gregs[19]);
++ err |= __get_user(sw->r21, &gregs[20]);
++ err |= __get_user(sw->r22, &gregs[21]);
++ err |= __get_user(sw->r23, &gregs[22]);
++ err |= __get_user(usp, &gregs[23]);
++ err |= __get_user(sw->fp, &gregs[24]); // Verify, should this be settable
++ err |= __get_user(sw->gp, &gregs[25]); // Verify, should this be settable
++
++ err |= __get_user(temp, &gregs[26]); // Not really necessary no user settable bits
++ regs->estatus = (regs->estatus & 0xffffffff) | (temp & 0x0);
++ err |= __get_user(regs->status_extension,
++ &uc->uc_mcontext.status_extension);
++ regs->orig_r2 = -1; /* disable syscall checks */
++
++ if (do_sigaltstack(&uc->uc_stack, NULL, usp) == -EFAULT)
++ goto badframe;
++
++ *pr2 = regs->r2;
++ return err;
++
++badframe:
++ return 1;
++}
++
++asmlinkage int do_sigreturn(struct pt_regs *regs)
++{
++ struct sigframe *frame = (struct sigframe *) regs->sp;
++ sigset_t set;
++ int rval;
++
++ if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
++ goto badframe;
++ if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
++ (_NSIG_WORDS > 1 &&
++ __copy_from_user(&set.sig[1], &frame->extramask,
++ sizeof(frame->extramask))))
++ goto badframe;
++
++ sigdelsetmask(&set, ~_BLOCKABLE);
++ spin_lock_irq(&current->sighand->siglock);
++ current->blocked = set;
++ recalc_sigpending();
++ spin_unlock_irq(&current->sighand->siglock);
++
++ if (restore_sigcontext(regs, &frame->sc, frame + 1, &rval))
++ goto badframe;
++ return rval;
++
++badframe:
++ force_sig(SIGSEGV, current);
++ return 0;
++}
++
++asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
++{
++ struct pt_regs *regs = (struct pt_regs *) sw + 1;
++ struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; // Verify, can we follow the stack back
++ sigset_t set;
++ int rval;
++
++ if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
++ goto badframe;
++ if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
++ goto badframe;
++
++ sigdelsetmask(&set, ~_BLOCKABLE);
++ spin_lock_irq(&current->sighand->siglock);
++ current->blocked = set;
++ recalc_sigpending();
++ spin_unlock_irq(&current->sighand->siglock);
++
++ if (rt_restore_ucontext(regs, sw, &frame->uc, &rval))
++ goto badframe;
++ return rval;
++
++badframe:
++ force_sig(SIGSEGV, current);
++ return 0;
++}
++
++#ifdef CONFIG_FPU
++/*
++ * Set up a signal frame.
++ *
++ * Not converted, no FPU support at moment.
++ */
++
++static inline int save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)
++{
++ int err = 0;
++
++ if (FPU_IS_EMU) {
++ /* save registers */
++ err |= copy_to_user(&sc->sc_fpcntl, current->thread.fpcntl, 12);
++ err |= copy_to_user(&sc->sc_fpregs, current->thread.fp, 24);
++ return err;
++ }
++
++ __asm__ volatile ("Nios II FPUt"
++ : : );
++
++ if (sc->sc_fpstate[0]) {
++ fpu_version = sc->sc_fpstate[0];
++ __asm__ volatile ("Nios II FPU"
++ : /* no outputs */
++ :
++ : );
++ }
++ return err;
++}
++
++static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
++{
++ unsigned char fpstate[FPCONTEXT_SIZE];
++ int context_size = 0;
++ int err = 0;
++
++ if (FPU_IS_EMU) {
++ /* save fpu control register */
++ err |= copy_to_user(&uc->uc_mcontext.fpregs.f_pcr,
++ current->thread.fpcntl, 12);
++ /* save all other fpu register */
++ err |= copy_to_user(uc->uc_mcontext.fpregs.f_fpregs,
++ current->thread.fp, 96);
++ return err;
++ }
++
++ __asm__ volatile ("Nios II FPU"
++ : : : );
++
++ err |= __put_user(*(long *)fpstate, (long *)&uc->uc_fpstate);
++ if (fpstate[0]) {
++ fpregset_t fpregs;
++ context_size = fpstate[1];
++ fpu_version = fpstate[0];
++ __asm__ volatile ("Nios II FPU"
++ : /* no outputs */
++ :
++ : );
++ err |= copy_to_user(&uc->uc_mcontext.fpregs, &fpregs,
++ sizeof(fpregs));
++ }
++ if (context_size)
++ err |= copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4,
++ context_size);
++ return err;
++}
++
++#endif
++
++static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
++ unsigned long mask)
++{
++ int err = 0;
++
++ err |= __put_user(mask, &sc->sc_mask);
++ err |= copy_to_user(&sc->regs, regs, sizeof(*regs));
++#ifdef CONFIG_FPU
++ err |= save_fpu_state(sc, regs);
++#endif
++ return err;
++}
++
++static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
++{
++ struct switch_stack *sw = (struct switch_stack *)regs - 1;
++ greg_t *gregs = uc->uc_mcontext.gregs;
++ int err = 0;
++
++ err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
++ err |= __put_user(regs->status_extension,
++ &uc->uc_mcontext.status_extension);
++ err |= __put_user(regs->r1, &gregs[0]);
++ err |= __put_user(regs->r2, &gregs[1]);
++ err |= __put_user(regs->r3, &gregs[2]);
++ err |= __put_user(regs->r4, &gregs[3]);
++ err |= __put_user(regs->r5, &gregs[4]);
++ err |= __put_user(regs->r6, &gregs[5]);
++ err |= __put_user(regs->r7, &gregs[6]);
++ err |= __put_user(regs->r8, &gregs[7]);
++ err |= __put_user(regs->r9, &gregs[8]);
++ err |= __put_user(regs->r10, &gregs[9]);
++ err |= __put_user(regs->r11, &gregs[10]);
++ err |= __put_user(regs->r12, &gregs[11]);
++ err |= __put_user(regs->r13, &gregs[12]);
++ err |= __put_user(regs->r14, &gregs[13]);
++ err |= __put_user(regs->r15, &gregs[14]);
++ err |= __put_user(sw->r16, &gregs[15]);
++ err |= __put_user(sw->r17, &gregs[16]);
++ err |= __put_user(sw->r18, &gregs[17]);
++ err |= __put_user(sw->r19, &gregs[18]);
++ err |= __put_user(sw->r20, &gregs[19]);
++ err |= __put_user(sw->r21, &gregs[20]);
++ err |= __put_user(sw->r22, &gregs[21]);
++ err |= __put_user(sw->r23, &gregs[22]);
++ err |= __put_user(regs->sp, &gregs[23]);
++ err |= __put_user(sw->fp, &gregs[24]);
++ err |= __put_user(sw->gp, &gregs[25]);
++#ifdef CONFIG_FPU
++ err |= rt_save_fpu_state(uc, regs);
++#endif
++ return err;
++}
++
++extern void cache_push_v (unsigned long vaddr, int len);
++
++static inline void push_cache (unsigned long vaddr)
++{
++ cache_push_v(vaddr,12);
++}
++
++static inline void *
++get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
++{
++ unsigned long usp;
++
++ /* Default to using normal stack. */
++ usp = regs->sp;
++
++ /* This is the X/Open sanctioned signal stack switching. */
++ if (ka->sa.sa_flags & SA_ONSTACK) {
++ if (!on_sig_stack(usp))
++ usp = current->sas_ss_sp + current->sas_ss_size;
++ }
++ return (void *)((usp - frame_size) & -8UL); // Verify, is it 32 or 64 bit aligned
++}
++
++static void setup_frame (int sig, struct k_sigaction *ka,
++ sigset_t *set, struct pt_regs *regs)
++{
++ struct sigframe *frame;
++ int err = 0;
++
++ frame = get_sigframe(ka, regs, sizeof(*frame));
++
++ if (_NSIG_WORDS > 1)
++ err |= copy_to_user(frame->extramask, &set->sig[1],
++ sizeof(frame->extramask));
++
++ err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
++
++ /* Set up to return from userspace. */
++ regs->ra = (unsigned long) &frame->retcode[0];
++ /* movi r3,__NR_sigreturn */
++ err |= __put_user(0x00c00004 + (__NR_sigreturn << 6), (long *)(frame->retcode));
++ /* mov r2,r0 */
++ err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
++ /* trap */
++ err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
++
++ if (err)
++ goto give_sigsegv;
++
++ push_cache ((unsigned long) &frame->retcode);
++
++ /* Set up registers for signal handler */
++ regs->sp = (unsigned long) frame;
++ regs->r4 = (unsigned long) (current_thread_info()->exec_domain
++ && current_thread_info()->exec_domain->signal_invmap
++ && sig < 32
++ ? current_thread_info()->exec_domain->signal_invmap[sig]
++ : sig);
++ regs->ea = (unsigned long) ka->sa.sa_handler;
++ return;
++
++give_sigsegv:
++ if (sig == SIGSEGV)
++ ka->sa.sa_handler = SIG_DFL;
++ force_sig(SIGSEGV, current);
++}
++
++static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
++ sigset_t *set, struct pt_regs *regs)
++{
++ struct rt_sigframe *frame;
++ int err = 0;
++
++ frame = get_sigframe(ka, regs, sizeof(*frame));
++
++ err |= copy_siginfo_to_user(&frame->info, info);
++
++ /* Create the ucontext. */
++ err |= __put_user(0, &frame->uc.uc_flags);
++ err |= __put_user(0, &frame->uc.uc_link);
++ err |= __put_user((void *)current->sas_ss_sp,
++ &frame->uc.uc_stack.ss_sp);
++ err |= __put_user(sas_ss_flags(regs->sp),
++ &frame->uc.uc_stack.ss_flags);
++ err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
++ err |= rt_setup_ucontext(&frame->uc, regs);
++ err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
++
++ /* Set up to return from userspace. */
++ regs->ra = (unsigned long) &frame->retcode[0];
++ /* movi r3,__NR_rt_sigreturn */
++ err |= __put_user(0x00c00004 + (__NR_rt_sigreturn << 6), (long *)(frame->retcode));
++ /* mov r2,r0 */
++ err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
++ /* trap */
++ err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
++
++ if (err)
++ goto give_sigsegv;
++
++ push_cache ((unsigned long) &frame->retcode);
++
++ /* Set up registers for signal handler */
++ regs->sp = (unsigned long) frame;
++ regs->r4 = (unsigned long) (current_thread_info()->exec_domain
++ && current_thread_info()->exec_domain->signal_invmap
++ && sig < 32
++ ? current_thread_info()->exec_domain->signal_invmap[sig]
++ : sig);
++ regs->r5 = (unsigned long) &frame->info;
++ regs->r6 = (unsigned long) &frame->uc;
++ regs->ea = (unsigned long) ka->sa.sa_handler;
++ return;
++
++give_sigsegv:
++ if (sig == SIGSEGV)
++ ka->sa.sa_handler = SIG_DFL;
++ force_sig(SIGSEGV, current);
++}
++
++static inline void
++handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
++{
++ switch (regs->r2) {
++ case -ERESTARTNOHAND:
++ if (!has_handler)
++ goto do_restart;
++ regs->r2 = -EINTR;
++ break;
++
++ case -ERESTARTSYS:
++ if (has_handler && !(ka->sa.sa_flags & SA_RESTART)) {
++ regs->r2 = -EINTR;
++ break;
++ }
++ /* fallthrough */
++ case -ERESTARTNOINTR:
++ do_restart:
++ regs->r2 = regs->orig_r2;
++ regs->ea -= 4;
++ break;
++ }
++}
++
++/*
++ * OK, we're invoking a handler
++ */
++static void
++handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
++ sigset_t *oldset, struct pt_regs *regs)
++{
++ /* are we from a system call? */
++ if (regs->orig_r2 >= 0)
++ /* If so, check system call restarting.. */
++ handle_restart(regs, ka, 1);
++
++ /* set up the stack frame */
++ if (ka->sa.sa_flags & SA_SIGINFO)
++ setup_rt_frame(sig, ka, info, oldset, regs);
++ else
++ setup_frame(sig, ka, oldset, regs);
++
++ if (ka->sa.sa_flags & SA_ONESHOT)
++ ka->sa.sa_handler = SIG_DFL;
++
++ if (!(ka->sa.sa_flags & SA_NODEFER)) {
++ spin_lock_irq(&current->sighand->siglock);
++ sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
++ sigaddset(&current->blocked,sig);
++ recalc_sigpending();
++ spin_unlock_irq(&current->sighand->siglock);
++ }
++}
++
++/*
++ * Note that 'init' is a special process: it doesn't get signals it doesn't
++ * want to handle. Thus you cannot kill init even with a SIGKILL even by
++ * mistake.
++ */
++asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
++{
++ struct k_sigaction ka;
++ siginfo_t info;
++ int signr;
++
++ /*
++ * We want the common case to go fast, which
++ * is why we may in certain cases get here from
++ * kernel mode. Just return without doing anything
++ * if so.
++ */
++ if (!user_mode(regs))
++ return 1;
++
++ /* FIXME - Do we still need to do this ? */
++ current->thread.kregs = regs;
++
++ if (!oldset)
++ oldset = &current->blocked;
++
++ signr = get_signal_to_deliver(&info, &ka, regs, NULL);
++ if (signr > 0) {
++ /* Whee! Actually deliver the signal. */
++ handle_signal(signr, &ka, &info, oldset, regs);
++ return 1;
++ }
++
++ /* Did we come from a system call? */
++ if (regs->orig_r2 >= 0){
++ /* Restart the system call - no handlers present */
++ if (regs->r2 == -ERESTARTNOHAND
++ || regs->r2 == -ERESTARTSYS
++ || regs->r2 == -ERESTARTNOINTR) {
++ regs->r2 = regs->orig_r2;
++ regs->ea -= 4;
++ } else if (regs->r2 == -ERESTART_RESTARTBLOCK) {
++ regs->r2 = __NR_restart_syscall;
++ regs->ea -= 4;
++ }
++ }
++ return 0;
++}
+diff --git a/arch/nios2nommu/kernel/start.c b/arch/nios2nommu/kernel/start.c
+new file mode 100644
+index 0000000..bca81fc
+--- /dev/null
++++ b/arch/nios2nommu/kernel/start.c
+@@ -0,0 +1,502 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/start.c
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ * May/20/2005 dgt Altera NiosII Custom shift instr(s)
++ * possibly assumed by memcpy, etc; ensure
++ * "correct" core loaded therefore if so.
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/system.h>
++#include <asm/nios.h>
++#include <linux/kernel.h>
++#include <linux/ctype.h>
++#include <linux/string.h>
++#include <linux/time.h>
++#include <linux/start_kernel.h>
++
++ #ifdef CONFIG_SERIAL_AJUART //;dgt;20may05;
++ #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
++
++ #include <linux/console.h> //;dgt;20may05;
++ #include <asm/altera_juart.h> //;dgt;20may05;
++
++ extern struct console juart_console; //;dgt;20may05;
++
++ #endif // CONFIG_SERIAL_AJUART //;dgt;20may05;
++ #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
++
++//;dgt;20may05; #ifdef CONFIG_CRC_CHECK
++
++// #if defined(CONFIG_NIOS_SERIAL) //;dgt;20may05;
++// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
++ #if defined(nasys_printf_uart) //;dgt;20may05;
++ static void putsNoNewLine( unsigned char *s )
++ {
++ while(*s) {
++ while (!(nasys_printf_uart->np_uartstatus &
++ np_uartstatus_trdy_mask));
++ nasys_printf_uart->np_uarttxdata = *s++;
++ }
++ }
++
++ #define NL "\r\n"
++ static void puts(unsigned char *s)
++ {
++ putsNoNewLine( s );
++ putsNoNewLine( NL );
++ }
++ #endif // nasys_printf_uart //;dgt;20may05;
++// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
++// #endif // CONFIG_NIOS_SERIAL) //;dgt;20may05;
++
++#ifdef CONFIG_CRC_CHECK //;dgt;20may05;
++
++#if 1
++#define outchar(X) { \
++ while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask)); \
++ nasys_printf_uart->np_uarttxdata = (X); }
++#else
++#define outchar(X) putchar(X)
++#endif
++#define outhex(X,Y) { \
++ unsigned long __w; \
++ __w = ((X) >> (Y)) & 0xf; \
++ __w = __w > 0x9 ? 'A' + __w - 0xa : '0' + __w; \
++ outchar(__w); }
++#define outhex8(X) { \
++ outhex(X,4); \
++ outhex(X,0); }
++#define outhex16(X) { \
++ outhex(X,12); \
++ outhex(X,8); \
++ outhex(X,4); \
++ outhex(X,0); }
++#define outhex32(X) { \
++ outhex(X,28); \
++ outhex(X,24); \
++ outhex(X,20); \
++ outhex(X,16); \
++ outhex(X,12); \
++ outhex(X,8); \
++ outhex(X,4); \
++ outhex(X,0); }
++#endif
++
++#if 0
++static unsigned long testvar = 0xdeadbeef;
++#endif
++
++#ifdef CONFIG_CRC_CHECK
++
++
++/******************************************************/
++
++
++extern unsigned long __CRC_Table_Begin;
++
++typedef unsigned char U8;
++typedef unsigned long U32;
++
++/* Table of CRC-32's of all single byte values */
++const U32 crc_32_tab[] = {
++ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
++ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
++ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
++ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
++ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
++ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
++ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
++ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
++ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
++ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
++ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
++ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
++ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
++ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
++ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
++ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
++ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
++ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
++ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
++ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
++ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
++ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
++ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
++ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
++ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
++ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
++ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
++ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
++ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
++ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
++ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
++ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
++ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
++ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
++ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
++ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
++ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
++ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
++ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
++ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
++ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
++ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
++ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
++ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
++ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
++ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
++ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
++ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
++ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
++ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
++ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
++ 0x2d02ef8dL
++};
++
++U32 Calc_CRC( const U8 *p, U32 len )
++{
++ U32 crc = (U32)~0L;
++ while (len--)
++ crc = crc_32_tab[0xFF & (crc ^ *p++)] ^ (crc >> 8);
++
++ return crc ^ (U32)~0L;
++}
++
++
++
++/******************************************************/
++
++
++/* hjz: Following time stuff is hacked and modified from uC-libc (various files), which in turn was... */
++/* This is adapted from glibc */
++/* Copyright (C) 1991, 1993 Free Software Foundation, Inc */
++
++#define SECS_PER_HOUR 3600L
++#define SECS_PER_DAY 86400L
++typedef unsigned long time_t;
++
++
++static const unsigned short int __mon_lengths[2][12] = {
++ /* Normal years. */
++ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
++ /* Leap years. */
++ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
++};
++/* This global is exported to the wide world in keeping
++ * with the interface in time.h */
++long int timezone = 0;
++
++static const char *dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
++static const char *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
++ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
++
++/* Nonzero if YEAR is a leap year (every 4 years,
++ except every 100th isn't, and every 400th is). */
++# define __isleap(year) ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
++
++struct tm
++{
++ int tm_sec; /* Seconds. [0-60] (1 leap second) */
++ int tm_min; /* Minutes. [0-59] */
++ int tm_hour; /* Hours. [0-23] */
++ int tm_mday; /* Day. [1-31] */
++ int tm_mon; /* Month. [0-11] */
++ int tm_year; /* Year - 1900. */
++ int tm_wday; /* Day of week. [0-6] */
++ int tm_yday; /* Days in year.[0-365] */
++ int tm_isdst; /* DST. [-1/0/1]*/
++
++# ifdef __USE_BSD
++ long int tm_gmtoff; /* Seconds east of UTC. */
++ __const char *tm_zone; /* Timezone abbreviation. */
++# else
++ long int __tm_gmtoff; /* Seconds east of UTC. */
++ __const char *__tm_zone; /* Timezone abbreviation. */
++# endif
++};
++
++void __tm_conv(struct tm *tmbuf, time_t *t, time_t offset)
++{
++ long days, rem;
++ register int y;
++ register const unsigned short int *ip;
++
++ timezone = -offset;
++
++ days = *t / SECS_PER_DAY;
++ rem = *t % SECS_PER_DAY;
++ rem += offset;
++ while (rem < 0)
++ {
++ rem += SECS_PER_DAY;
++ days--;
++ }
++ while (rem >= SECS_PER_DAY)
++ {
++ rem -= SECS_PER_DAY;
++ days++;
++ }
++
++ tmbuf->tm_hour = rem / SECS_PER_HOUR;
++ rem %= SECS_PER_HOUR;
++ tmbuf->tm_min = rem / 60;
++ tmbuf->tm_sec = rem % 60;
++
++ /* January 1, 1970 was a Thursday. */
++ tmbuf->tm_wday = (4 + days) % 7;
++ if (tmbuf->tm_wday < 0)
++ tmbuf->tm_wday += 7;
++
++ y = 1970;
++ while (days >= (rem = __isleap(y) ? 366 : 365))
++ {
++ y++;
++ days -= rem;
++ }
++
++ while (days < 0)
++ {
++ y--;
++ days += __isleap(y) ? 366 : 365;
++ }
++
++ tmbuf->tm_year = y - 1900;
++ tmbuf->tm_yday = days;
++
++ ip = __mon_lengths[__isleap(y)];
++ for (y = 0; days >= ip[y]; ++y)
++ days -= ip[y];
++
++ tmbuf->tm_mon = y;
++ tmbuf->tm_mday = days + 1;
++ tmbuf->tm_isdst = -1;
++}
++
++
++
++/* hjz: NOT your traditional ctime: This one includes timezone */
++/* (UTC) and excludes the traditional trailing newline. */
++char *CTime( time_t *t )
++{
++ static char theTime[29];
++ struct tm tm;
++
++ __tm_conv( &tm, t, 0 );
++ sprintf( theTime, "%s %s %02d %02d:%02d:%02d UTC %04d",
++ dayOfWeek[tm.tm_wday], month[tm.tm_mon], tm.tm_mday,
++ tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900 );
++
++ return theTime;
++}
++
++/******************************************************/
++
++
++/* hjz: polled-I/O: Get a char if one is ready, or return -1 */
++int getc( void )
++{
++ if ( nasys_printf_uart->np_uartstatus & np_uartstatus_rrdy_mask )
++ return nasys_printf_uart->np_uartrxdata;
++ else
++ return -1;
++}
++
++
++typedef unsigned long off_t;
++typedef struct
++{
++ U8 *startAddr;
++ U8 *endAddr;
++ U32 CRC;
++ time_t mtime;
++ off_t size; // File size
++ char id[44]; // Filename. If path exceeds available size, name is "..." + last 40 chars of given filename
++ char host[32]; // hostname. If name exceeds available size name is first 28 chars of hostname + "..."
++} FLASH_REGION_DESC;
++
++
++int Test_Flash_Regions(void)
++{
++ FLASH_REGION_DESC *pRegion = (FLASH_REGION_DESC *)&__CRC_Table_Begin;
++ U32 crc;
++ char cBuff[256];
++ int nrFailedRegions = 0;
++ int regionStatus;
++ int i;
++ unsigned int startAddr = (int) pRegion->startAddr;
++ unsigned int endAddr = (int) pRegion->endAddr;
++
++ puts( "***Checking flash CRC's" );
++ if ( (startAddr == -1) || (startAddr >= endAddr)
++ || !( ((startAddr >= (int) NIOS_FLASH_START) && (endAddr < (int) NIOS_FLASH_END))
++ || ((startAddr >= (int) na_flash) && (endAddr < (int) na_flash_end)) ) )
++ {
++ puts( " No Flash regions defined." );
++ return -1;
++ }
++
++
++ for ( i = 0; pRegion->startAddr && pRegion->startAddr != (U8 *)~0L; pRegion++, i++ )
++ {
++ crc = Calc_CRC( pRegion->startAddr, pRegion->endAddr - pRegion->startAddr );
++ if ( crc != pRegion->CRC )
++ {
++ regionStatus = 1;
++ nrFailedRegions++;
++ }
++ else
++ regionStatus = 0;
++
++ sprintf( cBuff, " Region %d: 0x%08lX - 0x%08lX, CRC = 0x%08lX --> %s" NL
++ " From file `%s' on host `%s'" NL
++ " Dated %s, size = %lu bytes",
++ i, (U32)pRegion->startAddr, (U32)pRegion->endAddr, pRegion->CRC,
++ regionStatus ? "***Failed" : "Passed",
++ pRegion->id, pRegion->host, CTime( &pRegion->mtime ), pRegion->size
++ );
++ puts( cBuff );
++ }
++
++ return nrFailedRegions;
++}
++#endif /* CONFIG_CRC_CHECK */
++
++
++int main(void) {
++
++#ifdef DEBUG
++ puts("MAIN: starting c\n");
++#endif
++
++#ifdef CONFIG_KGDB /* builtin GDB stub */
++
++/* Set up GDB stub, and make the first trap into it */
++ nios_gdb_install(1);
++#ifdef CONFIG_BREAK_ON_START
++ puts( "MAIN: trapping to debugger - make sure nios-elf-gdb is running on host." );
++ nios_gdb_breakpoint();
++ nop();
++#endif
++
++#endif /* CONFIG_KGDB */
++
++#ifdef CONFIG_CRC_CHECK
++ #ifdef CONFIG_PROMPT_ON_MISSING_CRC_TABLES
++ if ( Test_Flash_Regions() )
++ #else
++ if ( Test_Flash_Regions() > 0 )
++ #endif
++ {
++ int c;
++ char tmp[3];
++ while ( getc() != -1 ) // flush input
++ ;
++
++ putsNoNewLine( " Do you wish to continue (Y/N) ? " );
++ while ( 1 )
++ {
++ c = getc();
++ if ( c == -1 )
++ continue;
++
++ if ( !isprint( c ) )
++ c = '?';
++
++ sprintf( tmp, "\b%c", c );
++ putsNoNewLine( tmp );
++ c = toupper( c );
++ if ( c == 'Y' )
++ {
++ puts( "" );
++ break;
++ }
++
++ if ( c == 'N' )
++ {
++ puts( NL "***Trapping to monitor..." );
++ return -1;
++ }
++ }
++ }
++ puts( "***Starting kernel..." );
++
++#endif
++
++ // Altera NiosII Custom shift instr(s) possibly //;dgt;
++ // assumed by memcpy, etc; ensure "correct" core //;dgt;
++ // loaded therefore if so. //;dgt;
++
++ #if defined(ALT_CI_ALIGN_32_N) //;dgt;
++ if(ALT_CI_ALIGN_32(1, 0xA9876543, //;dgt;
++ 0xB210FEDC) != 0x10FEDCA9) //;dgt;
++ { //;dgt;
++ goto badshiftci_label; //;dgt;
++ } //;dgt;
++ if(ALT_CI_ALIGN_32(2, 0xA9876543, //;dgt;
++ 0xB210FEDC) != 0xFEDCA987) //;dgt;
++ { //;dgt;
++ goto badshiftci_label; //;dgt;
++ } //;dgt;
++ if(ALT_CI_ALIGN_32(3, 0xA9876543, //;dgt;
++ 0xB210FEDC) != 0xDCA98765) //;dgt;
++ { //;dgt;
++ goto badshiftci_label; //;dgt;
++ } //;dgt;
++ #endif //;dgt;
++ goto gudshiftci_label; //;dgt;
++badshiftci_label: //;dgt;
++ { //;dgt;
++ unsigned char BadCImsg[] = //;dgt;
++ "?...ALT_CI_ALIGNn_321() NOT expected" //;dgt;
++ " NiosII custom instruction\n"; //;dgt;
++ unsigned char CIabortMsg[] = //;dgt;
++ " ...aborting uClinux startup..."; //;dgt;
++
++ #ifdef CONFIG_SERIAL_AJUART //;dgt;
++ #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
++ juart_console.index = 0; //;dgt;
++ jtaguart_console_write(&(juart_console), //;dgt;
++ BadCImsg, //;dgt;
++ strlen(BadCImsg)); //;dgt;
++ jtaguart_console_write(&(juart_console), //;dgt;
++ CIabortMsg, //;dgt;
++ strlen(CIabortMsg)); //;dgt;
++ #endif // CONFIG_SERIAL_AJUART //;dgt;
++ #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
++
++// #if defined(CONFIG_NIOS_SERIAL) //;dgt;
++// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
++ #if defined(nasys_printf_uart) //;dgt;
++ puts(BadCImsg); //;dgt;
++ puts(CIabortMsg); //;dgt;
++ #endif // nasys_printf_uart //;dgt;
++// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
++// #endif // CONFIG_NIOS_SERIAL) //;dgt;
++
++ panic(" ...wrong fpga core?..."); //;dgt;
++ } //;dgt;
++
++gudshiftci_label: //;dgt;
++
++ start_kernel();
++ return 0;
++}
+diff --git a/arch/nios2nommu/kernel/sys_nios2.c b/arch/nios2nommu/kernel/sys_nios2.c
+new file mode 100644
+index 0000000..8018fb0
+--- /dev/null
++++ b/arch/nios2nommu/kernel/sys_nios2.c
+@@ -0,0 +1,248 @@
++/*
++ * linux/arch/nios2nommu/kernel/sys_nios2.c
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * This file contains various random system calls that
++ * have a non-standard calling sequence on the Linux/nios2nommu
++ * platform.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++*/
++
++#include <linux/errno.h>
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <linux/smp.h>
++#include <linux/smp_lock.h>
++#include <linux/sem.h>
++#include <linux/msg.h>
++#include <linux/shm.h>
++#include <linux/stat.h>
++#include <linux/syscalls.h>
++#include <linux/mman.h>
++#include <linux/file.h>
++#include <linux/utsname.h>
++#include <linux/fs.h>
++#include <linux/uaccess.h>
++#include <linux/ipc.h>
++#include <linux/unistd.h>
++
++#include <asm/setup.h>
++#include <asm/cachectl.h>
++#include <asm/traps.h>
++#include <asm/ipc.h>
++#include <asm/cacheflush.h>
++
++/*
++ * sys_pipe() is the normal C calling standard for creating
++ * a pipe. It's not the way unix traditionally does this, though.
++ */
++asmlinkage int sys_pipe(unsigned long * fildes)
++{
++ int fd[2];
++ int error;
++
++ error = do_pipe(fd);
++ if (!error) {
++ if (copy_to_user(fildes, fd, 2*sizeof(int)))
++ error = -EFAULT;
++ }
++ return error;
++}
++
++/* common code for old and new mmaps */
++static inline long do_mmap2(
++ unsigned long addr, unsigned long len,
++ unsigned long prot, unsigned long flags,
++ unsigned long fd, unsigned long pgoff)
++{
++ int error = -EBADF;
++ struct file * file = NULL;
++
++ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
++ if (!(flags & MAP_ANONYMOUS)) {
++ file = fget(fd);
++ if (!file)
++ goto out;
++ }
++
++ down_write(&current->mm->mmap_sem);
++ error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
++ up_write(&current->mm->mmap_sem);
++
++ if (file)
++ fput(file);
++out:
++ return error;
++}
++
++asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
++ unsigned long prot, unsigned long flags,
++ unsigned long fd, unsigned long pgoff)
++{
++ return do_mmap2(addr, len, prot, flags, fd, pgoff);
++}
++
++/*
++ * Perform the select(nd, in, out, ex, tv) and mmap() system
++ * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
++ * handle more than 4 system call parameters, so these system calls
++ * used a memory block for parameter passing..
++ */
++
++struct mmap_arg_struct {
++ unsigned long addr;
++ unsigned long len;
++ unsigned long prot;
++ unsigned long flags;
++ unsigned long fd;
++ unsigned long offset;
++};
++
++asmlinkage int old_mmap(struct mmap_arg_struct *arg)
++{
++ struct mmap_arg_struct a;
++ int error = -EFAULT;
++
++ if (copy_from_user(&a, arg, sizeof(a)))
++ goto out;
++
++ error = -EINVAL;
++ if (a.offset & ~PAGE_MASK)
++ goto out;
++
++ a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
++
++ error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
++out:
++ return error;
++}
++
++struct sel_arg_struct {
++ unsigned long n;
++ fd_set *inp, *outp, *exp;
++ struct timeval *tvp;
++};
++
++asmlinkage int old_select(struct sel_arg_struct *arg)
++{
++ struct sel_arg_struct a;
++
++ if (copy_from_user(&a, arg, sizeof(a)))
++ return -EFAULT;
++ /* sys_select() does the appropriate kernel locking */
++ return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
++}
++
++/*
++ * sys_ipc() is the de-multiplexer for the SysV IPC calls..
++ *
++ * This is really horribly ugly.
++ */
++asmlinkage int sys_ipc (uint call, int first, int second,
++ int third, void *ptr, long fifth)
++{
++ int version;
++
++ version = call >> 16; /* hack for backward compatibility */
++ call &= 0xffff;
++
++ if (call <= SEMCTL)
++ switch (call) {
++ case SEMOP:
++ return sys_semop (first, (struct sembuf *)ptr, second);
++ case SEMGET:
++ return sys_semget (first, second, third);
++ case SEMCTL: {
++ union semun fourth;
++ if (!ptr)
++ return -EINVAL;
++ if (get_user(fourth.__pad, (void **) ptr))
++ return -EFAULT;
++ return sys_semctl (first, second, third, fourth);
++ }
++ default:
++ return -EINVAL;
++ }
++ if (call <= MSGCTL)
++ switch (call) {
++ case MSGSND:
++ return sys_msgsnd (first, (struct msgbuf *) ptr,
++ second, third);
++ case MSGRCV:
++ switch (version) {
++ case 0: {
++ struct ipc_kludge tmp;
++ if (!ptr)
++ return -EINVAL;
++ if (copy_from_user (&tmp,
++ (struct ipc_kludge *)ptr,
++ sizeof (tmp)))
++ return -EFAULT;
++ return sys_msgrcv (first, tmp.msgp, second,
++ tmp.msgtyp, third);
++ }
++ default:
++ return sys_msgrcv (first,
++ (struct msgbuf *) ptr,
++ second, fifth, third);
++ }
++ case MSGGET:
++ return sys_msgget ((key_t) first, second);
++ case MSGCTL:
++ return sys_msgctl (first, second,
++ (struct msqid_ds *) ptr);
++ default:
++ return -EINVAL;
++ }
++
++ return -EINVAL;
++}
++
++/* sys_cacheflush -- flush the processor cache. */
++asmlinkage int
++sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
++{
++ flush_cache_all();
++ return(0);
++}
++
++asmlinkage int sys_getpagesize(void)
++{
++ return PAGE_SIZE;
++}
++
++/*
++ * Do a system call from kernel instead of calling sys_execve so we
++ * end up with proper pt_regs.
++ */
++int kernel_execve(const char *filename, char *const argv[], char *const envp[])
++{
++ register long __res __asm__ ("r2") = TRAP_ID_SYSCALL;
++ register long __sc __asm__ ("r3") = __NR_execve;
++ register long __a __asm__ ("r4") = (long) filename;
++ register long __b __asm__ ("r5") = (long) argv;
++ register long __c __asm__ ("r6") = (long) envp;
++ __asm__ __volatile__ ("trap" : "=r" (__res)
++ : "0" (__res), "r" (__sc), "r" (__a), "r" (__b), "r" (__c)
++ : "memory");
++
++ return __res;
++}
+diff --git a/arch/nios2nommu/kernel/syscalltable.S b/arch/nios2nommu/kernel/syscalltable.S
+new file mode 100644
+index 0000000..3507e24
+--- /dev/null
++++ b/arch/nios2nommu/kernel/syscalltable.S
+@@ -0,0 +1,362 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/syscalltable.S
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
++ * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
++ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
++ * Kenneth Albanowski <kjahds@kjahds.com>,
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <linux/sys.h>
++#include <linux/linkage.h>
++#include <asm/unistd.h>
++#include <asm/asm-macros.h>
++
++.text
++ALIGN
++ENTRY(sys_call_table)
++ .long sys_ni_syscall /* 0 - old "setup()" system call*/
++ .long sys_exit
++ .long sys_fork
++ .long sys_read
++ .long sys_write
++ .long sys_open /* 5 */
++ .long sys_close
++ .long sys_waitpid
++ .long sys_creat
++ .long sys_link
++ .long sys_unlink /* 10 */
++ .long sys_execve
++ .long sys_chdir
++ .long sys_time
++ .long sys_mknod
++ .long sys_chmod /* 15 */
++ .long sys_chown16
++ .long sys_ni_syscall /* old break syscall holder */
++ .long sys_stat
++ .long sys_lseek
++ .long sys_getpid /* 20 */
++ .long sys_mount
++ .long sys_oldumount
++ .long sys_setuid16
++ .long sys_getuid16
++ .long sys_stime /* 25 */
++ .long sys_ptrace
++ .long sys_alarm
++ .long sys_fstat
++ .long sys_pause
++ .long sys_utime /* 30 */
++ .long sys_ni_syscall /* old stty syscall holder */
++ .long sys_ni_syscall /* old gtty syscall holder */
++ .long sys_access
++ .long sys_nice
++ .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
++ .long sys_sync
++ .long sys_kill
++ .long sys_rename
++ .long sys_mkdir
++ .long sys_rmdir /* 40 */
++ .long sys_dup
++ .long sys_pipe
++ .long sys_times
++ .long sys_ni_syscall /* old prof syscall holder */
++ .long sys_brk /* 45 */
++ .long sys_setgid16
++ .long sys_getgid16
++ .long sys_signal
++ .long sys_geteuid16
++ .long sys_getegid16 /* 50 */
++ .long sys_acct
++ .long sys_umount /* recycled never used phys() */
++ .long sys_ni_syscall /* old lock syscall holder */
++ .long sys_ioctl
++ .long sys_fcntl /* 55 */
++ .long sys_ni_syscall /* old mpx syscall holder */
++ .long sys_setpgid
++ .long sys_ni_syscall /* old ulimit syscall holder */
++ .long sys_ni_syscall
++ .long sys_umask /* 60 */
++ .long sys_chroot
++ .long sys_ustat
++ .long sys_dup2
++ .long sys_getppid
++ .long sys_getpgrp /* 65 */
++ .long sys_setsid
++ .long sys_sigaction
++ .long sys_sgetmask
++ .long sys_ssetmask
++ .long sys_setreuid16 /* 70 */
++ .long sys_setregid16
++ .long sys_sigsuspend
++ .long sys_sigpending
++ .long sys_sethostname
++ .long sys_setrlimit /* 75 */
++ .long sys_old_getrlimit
++ .long sys_getrusage
++ .long sys_gettimeofday
++ .long sys_settimeofday
++ .long sys_getgroups16 /* 80 */
++ .long sys_setgroups16
++ .long old_select
++ .long sys_symlink
++ .long sys_lstat
++ .long sys_readlink /* 85 */
++ .long sys_uselib
++ .long sys_ni_syscall /* sys_swapon */
++ .long sys_reboot
++ .long old_readdir
++ .long old_mmap /* 90 */
++ .long sys_munmap
++ .long sys_truncate
++ .long sys_ftruncate
++ .long sys_fchmod
++ .long sys_fchown16 /* 95 */
++ .long sys_getpriority
++ .long sys_setpriority
++ .long sys_ni_syscall /* old profil syscall holder */
++ .long sys_statfs
++ .long sys_fstatfs /* 100 */
++ .long sys_ni_syscall /* was ioperm */
++ .long sys_socketcall
++ .long sys_syslog
++ .long sys_setitimer
++ .long sys_getitimer /* 105 */
++ .long sys_newstat
++ .long sys_newlstat
++ .long sys_newfstat
++ .long sys_ni_syscall
++ .long sys_ni_syscall /* iopl for i386 */ /* 110 */
++ .long sys_vhangup
++ .long sys_ni_syscall /* obsolete idle() syscall */
++ .long sys_ni_syscall /* vm86old for i386 */
++ .long sys_wait4
++ .long sys_ni_syscall /* 115 */ /* sys_swapoff */
++ .long sys_sysinfo
++ .long sys_ipc
++ .long sys_fsync
++ .long sys_sigreturn
++ .long sys_clone /* 120 */
++ .long sys_setdomainname
++ .long sys_newuname
++ .long sys_cacheflush /* modify_ldt for i386 */
++ .long sys_adjtimex
++ .long sys_ni_syscall /* 125 */ /* sys_mprotect */
++ .long sys_sigprocmask
++ .long sys_ni_syscall /* old "creat_module" */
++ .long sys_init_module
++ .long sys_delete_module
++ .long sys_ni_syscall /* 130: old "get_kernel_syms" */
++ .long sys_quotactl
++ .long sys_getpgid
++ .long sys_fchdir
++ .long sys_bdflush
++ .long sys_sysfs /* 135 */
++ .long sys_personality
++ .long sys_ni_syscall /* for afs_syscall */
++ .long sys_setfsuid16
++ .long sys_setfsgid16
++ .long sys_llseek /* 140 */
++ .long sys_getdents
++ .long sys_select
++ .long sys_flock
++ .long sys_ni_syscall /* sys_msync */
++ .long sys_readv /* 145 */
++ .long sys_writev
++ .long sys_getsid
++ .long sys_fdatasync
++ .long sys_sysctl
++ .long sys_ni_syscall /* 150 */ /* sys_mlock */
++ .long sys_ni_syscall /* sys_munlock */
++ .long sys_ni_syscall /* sys_mlockall */
++ .long sys_ni_syscall /* sys_munlockall */
++ .long sys_sched_setparam
++ .long sys_sched_getparam /* 155 */
++ .long sys_sched_setscheduler
++ .long sys_sched_getscheduler
++ .long sys_sched_yield
++ .long sys_sched_get_priority_max
++ .long sys_sched_get_priority_min /* 160 */
++ .long sys_sched_rr_get_interval
++ .long sys_nanosleep
++ .long sys_ni_syscall /* sys_mremap */
++ .long sys_setresuid16
++ .long sys_getresuid16 /* 165 */
++ .long sys_getpagesize /* sys_getpagesize */
++ .long sys_ni_syscall /* old "query_module" */
++ .long sys_poll
++ .long sys_ni_syscall /* sys_nfsservctl */
++ .long sys_setresgid16 /* 170 */
++ .long sys_getresgid16
++ .long sys_prctl
++ .long sys_rt_sigreturn
++ .long sys_rt_sigaction
++ .long sys_rt_sigprocmask /* 175 */
++ .long sys_rt_sigpending
++ .long sys_rt_sigtimedwait
++ .long sys_rt_sigqueueinfo
++ .long sys_rt_sigsuspend
++ .long sys_pread64 /* 180 */
++ .long sys_pwrite64
++ .long sys_lchown16
++ .long sys_getcwd
++ .long sys_capget
++ .long sys_capset /* 185 */
++ .long sys_sigaltstack
++ .long sys_sendfile
++ .long sys_ni_syscall /* streams1 */
++ .long sys_ni_syscall /* streams2 */
++ .long sys_vfork /* 190 */
++ .long sys_getrlimit
++ .long sys_mmap2
++ .long sys_truncate64
++ .long sys_ftruncate64
++ .long sys_stat64 /* 195 */
++ .long sys_lstat64
++ .long sys_fstat64
++ .long sys_chown
++ .long sys_getuid
++ .long sys_getgid /* 200 */
++ .long sys_geteuid
++ .long sys_getegid
++ .long sys_setreuid
++ .long sys_setregid
++ .long sys_getgroups /* 205 */
++ .long sys_setgroups
++ .long sys_fchown
++ .long sys_setresuid
++ .long sys_getresuid
++ .long sys_setresgid /* 210 */
++ .long sys_getresgid
++ .long sys_lchown
++ .long sys_setuid
++ .long sys_setgid
++ .long sys_setfsuid /* 215 */
++ .long sys_setfsgid
++ .long sys_pivot_root
++ .long sys_ni_syscall
++ .long sys_ni_syscall
++ .long sys_getdents64 /* 220 */
++ .long sys_gettid
++ .long sys_tkill
++ .long sys_setxattr
++ .long sys_lsetxattr
++ .long sys_fsetxattr /* 225 */
++ .long sys_getxattr
++ .long sys_lgetxattr
++ .long sys_fgetxattr
++ .long sys_listxattr
++ .long sys_llistxattr /* 230 */
++ .long sys_flistxattr
++ .long sys_removexattr
++ .long sys_lremovexattr
++ .long sys_fremovexattr
++ .long sys_futex /* 235 */
++ .long sys_sendfile64
++ .long sys_ni_syscall /* sys_mincore */
++ .long sys_ni_syscall /* sys_madvise */
++ .long sys_fcntl64
++ .long sys_readahead /* 240 */
++ .long sys_io_setup
++ .long sys_io_destroy
++ .long sys_io_getevents
++ .long sys_io_submit
++ .long sys_io_cancel /* 245 */
++ .long sys_fadvise64
++ .long sys_exit_group
++ .long sys_lookup_dcookie
++ .long sys_epoll_create
++ .long sys_epoll_ctl /* 250 */
++ .long sys_epoll_wait
++ .long sys_ni_syscall /* sys_remap_file_pages */
++ .long sys_set_tid_address
++ .long sys_timer_create
++ .long sys_timer_settime /* 255 */
++ .long sys_timer_gettime
++ .long sys_timer_getoverrun
++ .long sys_timer_delete
++ .long sys_clock_settime
++ .long sys_clock_gettime /* 260 */
++ .long sys_clock_getres
++ .long sys_clock_nanosleep
++ .long sys_statfs64
++ .long sys_fstatfs64
++ .long sys_tgkill /* 265 */
++ .long sys_utimes
++ .long sys_fadvise64_64
++ .long sys_mbind
++ .long sys_get_mempolicy
++ .long sys_set_mempolicy /* 270 */
++ .long sys_mq_open
++ .long sys_mq_unlink
++ .long sys_mq_timedsend
++ .long sys_mq_timedreceive
++ .long sys_mq_notify /* 275 */
++ .long sys_mq_getsetattr
++ .long sys_waitid
++ .long sys_ni_syscall /* sys_setaltroot */
++ .long sys_ni_syscall /* sys_add_key */
++ .long sys_ni_syscall /* 280 */ /* sys_request_key */
++ .long sys_ni_syscall /* sys_keyctl */
++ .long sys_ioprio_set
++ .long sys_ioprio_get
++ .long sys_inotify_init
++ .long sys_inotify_add_watch /* 285 */
++ .long sys_inotify_rm_watch
++ .long sys_migrate_pages
++ .long sys_openat
++ .long sys_mkdirat
++ .long sys_mknodat /* 290 */
++ .long sys_fchownat
++ .long sys_futimesat
++ .long sys_fstatat64
++ .long sys_unlinkat
++ .long sys_renameat /* 295 */
++ .long sys_linkat
++ .long sys_symlinkat
++ .long sys_readlinkat
++ .long sys_fchmodat
++ .long sys_faccessat /* 300 */
++ .long sys_ni_syscall /* Reserved for pselect6 */
++ .long sys_ni_syscall /* Reserved for ppoll */
++ .long sys_unshare
++ .long sys_set_robust_list
++ .long sys_get_robust_list /* 305 */
++ .long sys_splice
++ .long sys_sync_file_range
++ .long sys_tee
++ .long sys_vmsplice
++ .long sys_move_pages /* 310 */
++ .long sys_sched_setaffinity
++ .long sys_sched_getaffinity
++ .long sys_kexec_load
++ .long sys_getcpu
++ .long sys_epoll_pwait /* 315 */
++ .long sys_utimensat
++ .long sys_signalfd
++ .long sys_timerfd
++ .long sys_eventfd
++ .long sys_pread64
++ .long sys_pwrite64 /* 321 */
++
++ .rept NR_syscalls - 322
++ .long sys_ni_syscall
++ .endr
++
+diff --git a/arch/nios2nommu/kernel/time.c b/arch/nios2nommu/kernel/time.c
+new file mode 100644
+index 0000000..3b536fe
+--- /dev/null
++++ b/arch/nios2nommu/kernel/time.c
+@@ -0,0 +1,219 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/kernel/time.c
++ *
++ * Architecture specific time handling details.
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Most of the stuff is located in the machine specific files.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ * Copyright (C) 1998-2000 D. Jeff Dionne <jeff@lineo.ca>,
++ * Kenneth Albanowski <kjahds@kjahds.com>,
++ * Copyright (C) 1991, 1992, 1995 Linus Torvalds
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/errno.h>
++#include <linux/sched.h>
++#include <linux/kernel.h>
++#include <linux/param.h>
++#include <linux/string.h>
++#include <linux/mm.h>
++#include <linux/interrupt.h>
++#include <linux/time.h>
++#include <linux/timex.h>
++#include <linux/profile.h>
++#include <linux/module.h>
++#include <linux/irq.h>
++
++#include <asm/segment.h>
++#include <asm/io.h>
++#include <asm/nios.h>
++
++#define TICK_SIZE (tick_nsec / 1000)
++
++unsigned long cpu_khz;
++static inline int set_rtc_mmss(unsigned long nowtime)
++{
++ return 0;
++}
++
++/* Timer timeout status */
++#define nios2_timer_TO (inw(&na_timer0->np_timerstatus) & np_timerstatus_to_mask)
++
++/* Timer snapshot */
++static inline unsigned long nios2_read_timercount(void)
++{
++ unsigned long count;
++
++ outw(0, &na_timer0->np_timersnapl);
++ count = inw(&na_timer0->np_timersnaph) << 16 | inw(&na_timer0->np_timersnapl);
++
++ return count;
++}
++
++/*
++ * Should return useconds since last timer tick
++ */
++static unsigned long gettimeoffset(void)
++{
++ unsigned long offset;
++ unsigned long count;
++
++ count = nios2_read_timercount();
++ offset = ((nasys_clock_freq/HZ)-1 - nios2_read_timercount()) \
++ / (nasys_clock_freq / USEC_PER_SEC);
++
++ /* Check if we just wrapped the counters and maybe missed a tick */
++ if (nios2_timer_TO && (offset < (100000 / HZ / 2)))
++ offset += (USEC_PER_SEC / HZ);
++
++ return offset;
++}
++
++/*
++ * timer_interrupt() needs to keep up the real-time clock,
++ * as well as call the "do_timer()" routine every clocktick
++ */
++irqreturn_t timer_interrupt(int irq, void *dummy)
++{
++ /* last time the cmos clock got updated */
++ static long last_rtc_update=0;
++
++ write_seqlock(&xtime_lock);
++ na_timer0->np_timerstatus = 0; /* Clear the interrupt condition */
++
++ do_timer(1);
++#ifndef CONFIG_SMP
++ update_process_times(user_mode(get_irq_regs()));
++#endif
++ profile_tick(CPU_PROFILING);
++ /*
++ * If we have an externally synchronized Linux clock, then update
++ * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
++ * called as close as possible to 500 ms before the new second starts.
++ */
++ if (ntp_synced() &&
++ xtime.tv_sec > last_rtc_update + 660 &&
++ (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
++ (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
++ if (set_rtc_mmss(xtime.tv_sec) == 0)
++ last_rtc_update = xtime.tv_sec;
++ else
++ last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
++ }
++
++ write_sequnlock(&xtime_lock);
++ return(IRQ_HANDLED);
++}
++
++void __init time_init(void)
++{
++ unsigned int year, mon, day, hour, min, sec;
++ int err;
++
++ extern void arch_gettod(int *year, int *mon, int *day, int *hour,
++ int *min, int *sec);
++
++ cpu_khz=nasys_clock_freq_1000;
++ arch_gettod(&year, &mon, &day, &hour, &min, &sec);
++
++ if ((year += 1900) < 1970)
++ year += 100;
++ xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
++ xtime.tv_nsec = 0;
++ wall_to_monotonic.tv_sec = -xtime.tv_sec;
++
++ err = request_irq(na_timer0_irq, timer_interrupt, IRQ_FLG_LOCK, "timer", NULL);
++ if(err)
++ printk(KERN_ERR "%s() failed - errno = %d\n", __FUNCTION__, -err);
++ na_timer0->np_timerperiodl = (nasys_clock_freq/HZ)-1;
++ na_timer0->np_timerperiodh = ((nasys_clock_freq/HZ)-1) >> 16;
++
++ /* interrupt enable + continuous + start */
++ na_timer0->np_timercontrol = np_timercontrol_start_mask
++ + np_timercontrol_cont_mask
++ + np_timercontrol_ito_mask;
++}
++
++/*
++ * This version of gettimeofday has near microsecond resolution.
++ */
++void do_gettimeofday(struct timeval *tv)
++{
++ unsigned long flags;
++ unsigned long seq;
++ unsigned long usec, sec;
++
++ do {
++ seq = read_seqbegin_irqsave(&xtime_lock, flags);
++ usec = gettimeoffset();
++ sec = xtime.tv_sec;
++ usec += (xtime.tv_nsec / 1000);
++ } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
++
++ while (usec >= 1000000) {
++ usec -= 1000000;
++ sec++;
++ }
++
++ tv->tv_sec = sec;
++ tv->tv_usec = usec;
++}
++EXPORT_SYMBOL(do_gettimeofday);
++
++int do_settimeofday(struct timespec *tv)
++{
++ time_t wtm_sec, sec = tv->tv_sec;
++ long wtm_nsec, nsec = tv->tv_nsec;
++
++ if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
++ return -EINVAL;
++
++ write_seqlock_irq(&xtime_lock);
++ /*
++ * This is revolting. We need to set "xtime" correctly. However, the
++ * value in this location is the value at the last tick.
++ * Discover what correction gettimeofday() would have
++ * made, and then undo it!
++ */
++ nsec -= gettimeoffset() * NSEC_PER_USEC;
++
++ wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
++ wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
++
++ set_normalized_timespec(&xtime, sec, nsec);
++ set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
++
++ ntp_clear();
++
++ write_sequnlock_irq(&xtime_lock);
++ clock_was_set();
++
++ return 0;
++}
++EXPORT_SYMBOL(do_settimeofday);
++
++/*
++ * Scheduler clock - returns current time in nanosec units.
++ */
++unsigned long long sched_clock(void)
++{
++ return (unsigned long long)jiffies * (1000000000 / HZ);
++}
+diff --git a/arch/nios2nommu/kernel/traps.c b/arch/nios2nommu/kernel/traps.c
+new file mode 100644
+index 0000000..14b7e4c
+--- /dev/null
++++ b/arch/nios2nommu/kernel/traps.c
+@@ -0,0 +1,178 @@
++/*
++ * arch/niosnommu/kernel/traps.c
++ *
++ * Copyright 2004 Microtronix Datacom Ltd.
++ * Copyright 2001 Vic Phillips
++ * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * hacked from:
++ *
++ * arch/sparcnommu/kernel/traps.c
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/sched.h> /* for jiffies */
++#include <linux/kernel.h>
++#include <linux/signal.h>
++#include <linux/module.h>
++
++#include <asm/delay.h>
++#include <asm/system.h>
++#include <asm/ptrace.h>
++#include <asm/page.h>
++#include <asm/pgtable.h>
++#include <asm/unistd.h>
++
++#include <asm/nios.h>
++
++/* #define TRAP_DEBUG */
++
++#if 0
++void dumpit(unsigned long l1, unsigned long l2)
++{
++ printk("0x%08x l1 0x%08x l2\n");
++ while(1);
++}
++
++struct trap_trace_entry {
++ unsigned long pc;
++ unsigned long type;
++};
++
++int trap_curbuf = 0;
++struct trap_trace_entry trapbuf[1024];
++
++void syscall_trace_entry(struct pt_regs *regs)
++{
++ printk("%s[%d]: ", current->comm, current->pid);
++ printk("scall<%d> (could be %d)\n", (int) regs->r3,
++ (int) regs->r4);
++}
++
++void syscall_trace_exit(struct pt_regs *regs)
++{
++}
++#endif
++
++/*
++ * The architecture-independent backtrace generator
++ */
++void dump_stack(void)
++{
++ unsigned long stack;
++
++ show_stack(current, &stack);
++}
++
++EXPORT_SYMBOL(dump_stack);
++
++/*
++ * The show_stack is an external API which we do not use ourselves.
++ * The oops is printed in die_if_kernel.
++ */
++
++int kstack_depth_to_print = 48;
++
++void show_stack(struct task_struct *task, unsigned long *stack)
++{
++ unsigned long *endstack, addr;
++ extern char _start, _etext;
++ int i;
++
++ if (!stack) {
++ if (task)
++ stack = (unsigned long *)task->thread.ksp;
++ else
++ stack = (unsigned long *)&stack;
++ }
++
++ addr = (unsigned long) stack;
++ endstack = (unsigned long *) PAGE_ALIGN(addr);
++
++ printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
++ for (i = 0; i < kstack_depth_to_print; i++) {
++ if (stack + 1 > endstack)
++ break;
++ if (i % 8 == 0)
++ printk(KERN_EMERG "\n ");
++ printk(KERN_EMERG " %08lx", *stack++);
++ }
++
++ printk(KERN_EMERG "\nCall Trace:");
++ i = 0;
++ while (stack + 1 <= endstack) {
++ addr = *stack++;
++ /*
++ * If the address is either in the text segment of the
++ * kernel, or in the region which contains vmalloc'ed
++ * memory, it *may* be the address of a calling
++ * routine; if so, print it so that someone tracing
++ * down the cause of the crash will be able to figure
++ * out the call path that was taken.
++ */
++ if (((addr >= (unsigned long) &_start) &&
++ (addr <= (unsigned long) &_etext))) {
++ if (i % 4 == 0)
++ printk(KERN_EMERG "\n ");
++ printk(KERN_EMERG " [<%08lx>]", addr);
++ i++;
++ }
++ }
++ printk(KERN_EMERG "\n");
++}
++
++void die_if_kernel(char *str, struct pt_regs *pregs)
++{
++ unsigned long pc;
++
++ pc = pregs->ra;
++ printk("0x%08lx\n trapped to die_if_kernel\n",pregs->ra);
++ show_regs(pregs);
++ if(pregs->status_extension & PS_S)
++ do_exit(SIGKILL);
++ do_exit(SIGSEGV);
++}
++
++void do_hw_interrupt(unsigned long type, unsigned long psr, unsigned long pc)
++{
++ if(type < 0x10) {
++ printk("Unimplemented Nios2 TRAP, type = %02lx\n", type);
++ die_if_kernel("Whee... Hello Mr. Penguin", current->thread.kregs);
++ }
++}
++
++#if 0
++void handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long psr)
++{
++#ifdef TRAP_DEBUG
++ printk("Watchpoint detected at PC %08lx PSR %08lx\n", pc, psr);
++#endif
++ if(psr & PSR_SUPERVISOR)
++ panic("Tell me what a watchpoint trap is, and I'll then deal "
++ "with such a beast...");
++}
++#endif
++
++void trap_init(void)
++{
++#ifdef DEBUG
++ printk("trap_init reached\n");
++#endif
++}
+diff --git a/arch/nios2nommu/kernel/usb.c b/arch/nios2nommu/kernel/usb.c
+new file mode 100644
+index 0000000..65655b6
+--- /dev/null
++++ b/arch/nios2nommu/kernel/usb.c
+@@ -0,0 +1,341 @@
++/*
++ * arch/nios2nommu/kernel/usb.c -- platform level USB initialization
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++
++#undef DEBUG
++
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/types.h>
++#include <linux/errno.h>
++#include <linux/init.h>
++#include <linux/platform_device.h>
++#include <linux/delay.h>
++
++#include <asm/io.h>
++#include <asm/irq.h>
++#include <asm/system.h>
++#include <asm/nios.h>
++
++#if defined(CONFIG_USB_SL811_HCD) || defined (CONFIG_USB_SL811_HCD_MODULE)
++#if defined(CONFIG_MICROTRONIX_STRATIX) || defined (CONFIG_MICROTRONIX_CYCLONE)
++
++#include <linux/usb/sl811.h>
++#define SL811_ADDR ((unsigned int)na_usb)
++#define SL811_IRQ na_usb_irq
++
++static void sl811_port_power(struct device *dev, int is_on)
++{
++}
++
++static void sl811_port_reset(struct device *dev)
++{
++ writeb(0xA, (SL811_ADDR+8));
++ mdelay(10);
++ writeb(4, (SL811_ADDR+8));
++}
++
++static struct resource sl811hs_resources[] = {
++ {
++ .start = (SL811_ADDR),
++ .end = (SL811_ADDR + 3),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = (SL811_ADDR + 4),
++ .end = (SL811_ADDR + 7),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = SL811_IRQ,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++
++static struct sl811_platform_data sl811_data = {
++ .can_wakeup = 0,
++ .potpg = 0,
++ .power = 250,
++ .port_power = sl811_port_power,
++ .reset = sl811_port_reset,
++};
++
++static struct platform_device sl811hs_device = {
++ .name = "sl811-hcd",
++ .id = -1,
++ .dev = {
++ //.release = usb_release,
++ //.dma_mask = &ohci_dmamask,
++ .coherent_dma_mask = 0x0fffffff,
++ .platform_data = &sl811_data,
++ },
++ .num_resources = ARRAY_SIZE(sl811hs_resources),
++ .resource = sl811hs_resources,
++};
++
++
++static int __init mtx_kit_usb_init(void)
++{
++ int status;
++
++ status = platform_device_register(&sl811hs_device);
++ if (status) {
++ pr_debug("can't register sl811hs device, %d\n", status);
++ return -1;
++ }
++
++ writeb(4, (SL811_ADDR+8));
++ return 0;
++}
++
++subsys_initcall(mtx_kit_usb_init);
++#endif /* (CONFIG_MICROTRONIX_STRATIX) || (CONFIG_MICROTRONIX_CYCLONE)*/
++#endif /*(CONFIG_USB_SL811_HCD) ||(CONFIG_USB_SL811_HCD_MODULE) */
++
++#if defined(CONFIG_USB_ISP116X_HCD) || defined (CONFIG_USB_ISP116X_HCD_MODULE)
++
++#include <linux/usb/isp116x.h>
++
++#define ISP116X_HCD_ADDR ((unsigned int)na_usb)
++#define ISP116X_HCD_IRQ na_usb_irq
++
++static void isp116x_delay(struct device *dev, int delay)
++{
++ ndelay(delay);
++}
++
++static struct resource isp116x_hcd_resources[] = {
++ {
++ .start = (ISP116X_HCD_ADDR),
++ .end = (ISP116X_HCD_ADDR + 3),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = (ISP116X_HCD_ADDR + 4),
++ .end = (ISP116X_HCD_ADDR + 7),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = ISP116X_HCD_IRQ,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++
++static struct isp116x_platform_data isp116x_data = {
++ // Enable internal resistors on downstream ports
++ .sel15Kres = 1,
++ // On-chip overcurrent protection
++ .oc_enable = 1,
++ // INT output polarity
++ .int_act_high = 0,
++ // INT edge or level triggered
++ .int_edge_triggered = 0,
++ // Wakeup by devices on usb bus enabled
++ .remote_wakeup_enable = 0,
++ .delay = isp116x_delay,
++};
++
++static struct platform_device isp116x_hcd = {
++ .name = "isp116x-hcd",
++ .id = -1,
++ .dev = {
++ //.release = usb_release,
++ //.dma_mask = &ohci_dmamask,
++ .coherent_dma_mask = 0x0fffffff,
++ .platform_data = &isp116x_data,
++ },
++ .num_resources = ARRAY_SIZE(isp116x_hcd_resources),
++ .resource = isp116x_hcd_resources,
++};
++
++static int __init usb_hcd_init(void)
++{
++ int status;
++
++ status = platform_device_register(&isp116x_hcd);
++ if (status) {
++ pr_debug("can't register isp116x host controller, %d\n", status);
++ return -1;
++ }
++
++ return 0;
++}
++subsys_initcall(usb_hcd_init);
++#endif /*(CONFIG_USB_ISP116X_HCD) ||(CONFIG_USB_ISP116X_HCD_MODULE) */
++
++#if defined(CONFIG_USB_ISP1161X) || defined(CONFIG_USB_ISP1161X_MODULE)
++#include <linux/usb_isp116x_dc.h>
++
++#define ISP116X_UDC_ADDR ((unsigned int)na_usb+8)
++#define ISP116X_UDC_IRQ na_int2_usb_irq
++
++static struct resource isp116x_udc_resources[] = {
++ {
++ .start = (ISP116X_UDC_ADDR),
++ .end = (ISP116X_UDC_ADDR + 3),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = (ISP116X_UDC_ADDR + 4),
++ .end = (ISP116X_UDC_ADDR + 7),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = ISP116X_UDC_IRQ,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++static void isp116x_udc_delay()
++{
++ __asm__ __volatile__(
++ "1: \n\t"
++ " beq %0,zero,2f\n\t"
++ " addi %0, %0, -1\n\t"
++ " br 1b\n\t"
++ "2: \n\t"
++ :
++ : "r" (nasys_clock_freq_1000 * 180 / 2000000)
++ );
++
++}
++struct isp116x_dc_platform_data isp116x_udc_data = {
++ .ext_pullup_enable =0,
++ .no_lazy =1,
++ .eot_act_high =0,
++ .remote_wakeup_enable=1,
++ .power_off_enable =1,
++ .int_edge_triggered =0,
++ .int_act_high =0,
++ .clkout_freq =12,
++ .delay = isp116x_udc_delay
++};
++
++static struct platform_device isp116x_udc = {
++ .name = "isp1161a_udc",
++ .id = -1,
++ .dev = {
++ //.release = usb_release,
++ //.dma_mask = &ohci_dmamask,
++ .coherent_dma_mask = 0x0fffffff,
++ .platform_data = &isp116x_udc_data,
++ },
++ .num_resources = ARRAY_SIZE(isp116x_udc_resources),
++ .resource = isp116x_udc_resources,
++};
++
++static int __init usb_udc_init(void)
++{
++ int status;
++ np_pio* pio;
++
++ status = platform_device_register(&isp116x_udc);
++ if (status) {
++ pr_debug("can't register isp116x device controller, %d\n", status);
++ return -1;
++ }
++
++ /* enable interrupts */
++ pio = (np_pio*)na_int2_usb;
++ //outw(0, &pio->np_piodata);
++ //outw(0, &pio->np_pioedgecapture);
++ outw(1, &pio->np_piointerruptmask);
++
++ return 0;
++}
++subsys_initcall(usb_udc_init);
++#endif
++
++#if defined(na_ISP1362_avalonS) // for DE2 dev board, FIX ME otehrwise
++#define na_usb na_ISP1362_avalonS
++#define na_usb_irq na_ISP1362_avalonS_irq
++#endif
++
++#if defined(na_ISP1362_avalon_slave_0) // for DE2 dev board, FIX ME otehrwise
++#define na_usb na_ISP1362_avalon_slave_0
++#define na_usb_irq na_ISP1362_avalon_slave_0_irq
++#endif
++
++#if defined(CONFIG_USB_ISP1362_HCD) && defined(na_usb)
++
++#include <linux/usb_isp1362.h>
++#define ISP1362_HCD_ADDR ((unsigned int)na_usb)
++#define ISP1362_HCD_IRQ na_usb_irq
++
++static struct resource isp1362_hcd_resources[] = {
++ {
++ .start = (ISP1362_HCD_ADDR),
++ .end = (ISP1362_HCD_ADDR + 3),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = (ISP1362_HCD_ADDR + 4),
++ .end = (ISP1362_HCD_ADDR + 7),
++ .flags = IORESOURCE_MEM,
++ },
++ {
++ .start = ISP1362_HCD_IRQ,
++ .flags = IORESOURCE_IRQ,
++ },
++};
++
++static struct isp1362_platform_data isp1362_data = {
++ // Enable internal resistors on downstream ports
++ .sel15Kres = 1,
++ // Clock cannot be stopped
++ .clknotstop = 0,
++ // On-chip overcurrent protection
++ .oc_enable = 0,
++ // INT output polarity
++ .int_act_high = 0,
++ // INT edge or level triggered
++ .int_edge_triggered = 0,
++ // WAKEUP pin connected
++ .remote_wakeup_connected = 0,
++ // Switch or not to switch (keep always powered)
++ .no_power_switching = 1,
++ // Ganged port power switching (0) or individual port power switching (1)
++ .power_switching_mode = 0,
++};
++
++static struct platform_device isp1362_hcd = {
++ .name = "isp1362-hcd",
++ .id = -1,
++ .dev = {
++ //.release = usb_release,
++ //.dma_mask = &ohci_dmamask,
++ .coherent_dma_mask = 0x0fffffff,
++ .platform_data = &isp1362_data,
++ },
++ .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
++ .resource = isp1362_hcd_resources,
++};
++
++static int __init usb_hcd_init(void)
++{
++ int status;
++
++ status = platform_device_register(&isp1362_hcd);
++ if (status) {
++ pr_debug("can't register isp1362 host controller, %d\n", status);
++ return -1;
++ }
++
++ return 0;
++}
++subsys_initcall(usb_hcd_init);
++#endif
++
+diff --git a/arch/nios2nommu/kernel/vmlinux.lds.S b/arch/nios2nommu/kernel/vmlinux.lds.S
+new file mode 100644
+index 0000000..491901c
+--- /dev/null
++++ b/arch/nios2nommu/kernel/vmlinux.lds.S
+@@ -0,0 +1,141 @@
++#include <asm-generic/vmlinux.lds.h>
++#include <asm/nios.h>
++
++OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
++
++OUTPUT_ARCH(nios)
++ENTRY(_start) /* Defined in head.S */
++
++jiffies = jiffies_64;
++
++SECTIONS
++{
++ . = nasys_program_mem;
++ /* read-only */
++ _stext = . ;
++ _text = .; /* Text and read-only data */
++ .text : {
++ TEXT_TEXT
++ SCHED_TEXT
++ LOCK_TEXT
++ *(.fixup)
++ *(.gnu.warning)
++ } =0
++
++ . = ALIGN(4) ;
++ _etext = .; /* End of text section */
++
++ . = ALIGN(32); /* Exception table */
++ __start___ex_table = .;
++ __ex_table : { *(__ex_table) }
++ __stop___ex_table = .;
++
++ RODATA
++
++ /* writeable */
++ .data : { /* Data */
++ /*
++ * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
++ * limits the maximum alignment to at most 32kB and results in the following
++ * warning:
++ *
++ * CC arch/mips/kernel/init_task.o
++ * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’
++ * is greater than maximum object file alignment. Using 32768
++ */
++ . = ALIGN(4096);
++ *(.data.init_task)
++
++ *(.data)
++
++ CONSTRUCTORS
++ }
++
++ .lit8 : { *(.lit8) }
++ .lit4 : { *(.lit4) }
++ /* We want the small data sections together, so single-instruction offsets
++ can access them all, and initialized data all before uninitialized, so
++ we can shorten the on-disk segment size. */
++ .sdata : { *(.sdata) }
++
++ . = ALIGN(4096);
++ __nosave_begin = .;
++ .data_nosave : { *(.data.nosave) }
++ . = ALIGN(4096);
++ __nosave_end = .;
++
++ . = ALIGN(32);
++ .data.cacheline_aligned : { *(.data.cacheline_aligned) }
++
++ _edata = .; /* End of data section */
++
++ /* will be freed after init */
++ . = ALIGN(4096); /* Init code and data */
++ __init_begin = .;
++ .init.text : {
++ _sinittext = .;
++ *(.init.text)
++ _einittext = .;
++ }
++ .init.data : { *(.init.data) }
++ . = ALIGN(16);
++ __setup_start = .;
++ .init.setup : { *(.init.setup) }
++ __setup_end = .;
++
++ __initcall_start = .;
++ .initcall.init : {
++ INITCALLS
++ }
++ __initcall_end = .;
++
++ __con_initcall_start = .;
++ .con_initcall.init : { *(.con_initcall.init) }
++ __con_initcall_end = .;
++ SECURITY_INIT
++ /* .exit.text is discarded at runtime, not link time, to deal with
++ references from .rodata */
++ .exit.text : { *(.exit.text) }
++ .exit.data : { *(.exit.data) }
++ . = ALIGN(4096);
++ __initramfs_start = .;
++ .init.ramfs : { *(.init.ramfs) }
++ __initramfs_end = .;
++ . = ALIGN(32);
++ __per_cpu_start = .;
++ .data.percpu : { *(.data.percpu) }
++ __per_cpu_end = .;
++ . = ALIGN(4096);
++ __init_end = .;
++ /* freed after init ends here */
++
++ __bss_start = .; /* BSS */
++ .sbss : {
++ *(.sbss)
++ *(.scommon)
++ }
++ .bss : {
++ *(.bss)
++ *(COMMON)
++ }
++ __bss_stop = .;
++
++ _end = . ;
++
++ /* Sections to be discarded */
++ /DISCARD/ : {
++ *(.exit.text)
++ *(.exit.data)
++ *(.exitcall.exit)
++ }
++
++
++ STABS_DEBUG
++
++ DWARF_DEBUG
++
++ /* These must appear regardless of . */
++ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
++ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
++ .note : { *(.note) }
++}
+diff --git a/arch/nios2nommu/lib/Makefile b/arch/nios2nommu/lib/Makefile
+new file mode 100644
+index 0000000..1315c57
+--- /dev/null
++++ b/arch/nios2nommu/lib/Makefile
+@@ -0,0 +1,17 @@
++#
++# Copyright (C) 2005 Microtronix Datacom Ltd
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++
++####CSRC := $(wildcard *.c)
++####lib-y =$(patsubst %.c,%.o, $(CSRC))
++####wapos!
++lib-y =checksum.o string.o memcpy.o
+diff --git a/arch/nios2nommu/lib/checksum.c b/arch/nios2nommu/lib/checksum.c
+new file mode 100644
+index 0000000..475f1a3
+--- /dev/null
++++ b/arch/nios2nommu/lib/checksum.c
+@@ -0,0 +1,73 @@
++/*--------------------------------------------------------------------
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <net/checksum.h>
++#include <asm/checksum.h>
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * computes the checksum of a memory block at buff, length len,
++ * and adds in "sum" (32-bit)
++ *
++ * returns a 32-bit number suitable for feeding into itself
++ * or csum_tcpudp_magic
++ *
++ * this function must be called with even lengths, except
++ * for the last fragment, which may be odd
++ *
++ * it's best to have buff aligned on a 32-bit boundary
++ */
++
++unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
++{
++#if 0
++ __asm__ __volatile__ ...//;dgt2;tmp;not (yet) available...
++ ...//;dgt2;tmp;NiosI didn't offer either...
++#else
++ unsigned int result = do_csum(buff, len);
++
++ /* add in old sum, and carry.. */
++ result += sum;
++ if (sum > result)
++ result += 1;
++ return result;
++#endif
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/*
++ * the same as csum_partial, but copies from fs:src while it
++ * checksums
++ *
++ * here even more important to align src and dst on a 32-bit (or even
++ * better 64-bit) boundary
++ */
++
++unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum)
++{
++ memcpy(dst, src, len);
++ return csum_partial(dst, len, sum);
++
++}
+diff --git a/arch/nios2nommu/lib/memcpy.c b/arch/nios2nommu/lib/memcpy.c
+new file mode 100644
+index 0000000..6586b99
+--- /dev/null
++++ b/arch/nios2nommu/lib/memcpy.c
+@@ -0,0 +1,62 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/lib/memcpy.c
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jun/09/2004 dgt Split out separate source file from string.c
++ *
++ ---------------------------------------------------------------------*/
++
++#include <linux/types.h>
++#include <linux/autoconf.h>
++#include <asm/nios.h>
++#include <asm/string.h>
++
++#ifdef __HAVE_ARCH_MEMCPY
++ void * memcpy(void * d, const void * s, size_t count)
++ {
++ unsigned long dst, src;
++ dst = (unsigned long) d;
++ src = (unsigned long) s;
++
++ if ((count < 8) || ((dst ^ src) & 3))
++ goto restup;
++
++ if (dst & 1) {
++ *(char*)dst++=*(char*)src++;
++ count--;
++ }
++ if (dst & 2) {
++ *(short*)dst=*(short*)src;
++ src += 2;
++ dst += 2;
++ count -= 2;
++ }
++ while (count > 3) {
++ *(long*)dst=*(long*)src;
++ src += 4;
++ dst += 4;
++ count -= 4;
++ }
++
++ restup:
++ while (count--)
++ *(char*)dst++=*(char*)src++;
++
++ return d;
++ }
++#endif
+diff --git a/arch/nios2nommu/lib/string.c b/arch/nios2nommu/lib/string.c
+new file mode 100644
+index 0000000..b87c195
+--- /dev/null
++++ b/arch/nios2nommu/lib/string.c
+@@ -0,0 +1,180 @@
++/*--------------------------------------------------------------------
++ *
++ * arch/nios2nommu/lib/string.c
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ * Jun/09/2004 dgt Split out memcpy into separate source file
++ *
++ ---------------------------------------------------------------------*/
++
++#include <linux/types.h>
++#include <linux/autoconf.h>
++#include <asm/nios.h>
++#include <asm/string.h>
++
++#ifdef __HAVE_ARCH_MEMSET
++void * memset(void * s,int c,size_t count)
++{
++
++ if (count > 8) {
++ int destptr, charcnt, dwordcnt, fill8reg, wrkrega;
++ __asm__ __volatile__ (
++ // fill8 %3, %5 (c & 0xff)\n\t"
++ //
++ " slli %4, %5, 8\n\t"
++ " or %4, %4, %5\n\t"
++ " slli %3, %4, 16\n\t"
++ " or %3, %3, %4\n\t"
++ //
++ // Word-align %0 (s) if necessary
++ //
++ " andi %4, %0, 0x01\n\t"
++ " beq %4, zero, 1f\n\t"
++ " addi %1, %1, -1\n\t"
++ " stb %3, 0(%0)\n\t"
++ " addi %0, %0, 1\n\t"
++ "1: \n\t"
++ " mov %2, %1\n\t"
++ //
++ // Dword-align %0 (s) if necessary
++ //
++ " andi %4, %0, 0x02\n\t"
++ " beq %4, zero, 2f\n\t"
++ " addi %1, %1, -2\n\t"
++ " sth %3, 0(%0)\n\t"
++ " addi %0, %0, 2\n\t"
++ " mov %2, %1\n\t"
++ "2: \n\t"
++ // %1 and %2 are how many more bytes to set
++ //
++ " srli %2, %2, 2\n\t"
++ //
++ // %2 is how many dwords to set
++ //
++ "3: ;\n\t"
++ " stw %3, 0(%0)\n\t"
++ " addi %0, %0, 4\n\t"
++ " addi %2, %2, -1\n\t"
++ " bne %2, zero, 3b\n\t"
++ //
++ // store residual word and/or byte if necessary
++ //
++ " andi %4, %1, 0x02\n\t"
++ " beq %4, zero, 4f\n\t"
++ " sth %3, 0(%0)\n\t"
++ " addi %0, %0, 2\n\t"
++ "4: \n\t"
++ // store residual byte if necessary
++ //
++ " andi %4, %1, 0x01\n\t"
++ " beq %4, zero, 5f\n\t"
++ " stb %3, 0(%0)\n\t"
++ "5: \n\t"
++
++ : "=r" (destptr), /* %0 Output */
++ "=r" (charcnt), /* %1 Output */
++ "=r" (dwordcnt), /* %2 Output */
++ "=r" (fill8reg), /* %3 Output */
++ "=r" (wrkrega) /* %4 Output */
++
++ : "r" (c & 0xff), /* %5 Input */
++ "0" (s), /* %0 Input/Output */
++ "1" (count) /* %1 Input/Output */
++
++ : "memory" /* clobbered */
++ );
++ }
++ else {
++ char* xs=(char*)s;
++ while (count--)
++ *xs++ = c;
++ }
++ return s;
++}
++#endif
++
++#ifdef __HAVE_ARCH_MEMMOVE
++void * memmove(void * d, const void * s, size_t count)
++{
++ unsigned long dst, src;
++
++ if (d < s) {
++ dst = (unsigned long) d;
++ src = (unsigned long) s;
++
++ if ((count < 8) || ((dst ^ src) & 3))
++ goto restup;
++
++ if (dst & 1) {
++ *(char*)dst++=*(char*)src++;
++ count--;
++ }
++ if (dst & 2) {
++ *(short*)dst=*(short*)src;
++ src += 2;
++ dst += 2;
++ count -= 2;
++ }
++ while (count > 3) {
++ *(long*)dst=*(long*)src;
++ src += 4;
++ dst += 4;
++ count -= 4;
++ }
++
++ restup:
++ while (count--)
++ *(char*)dst++=*(char*)src++;
++ } else {
++ dst = (unsigned long) d + count;
++ src = (unsigned long) s + count;
++
++ if ((count < 8) || ((dst ^ src) & 3))
++ goto restdown;
++
++ if (dst & 1) {
++ src--;
++ dst--;
++ count--;
++ *(char*)dst=*(char*)src;
++ }
++ if (dst & 2) {
++ src -= 2;
++ dst -= 2;
++ count -= 2;
++ *(short*)dst=*(short*)src;
++ }
++ while (count > 3) {
++ src -= 4;
++ dst -= 4;
++ count -= 4;
++ *(long*)dst=*(long*)src;
++ }
++
++ restdown:
++ while (count--) {
++ src--;
++ dst--;
++ *(char*)dst=*(char*)src;
++ }
++ }
++
++ return d;
++
++}
++#endif
+diff --git a/arch/nios2nommu/mm/Makefile b/arch/nios2nommu/mm/Makefile
+new file mode 100644
+index 0000000..b007a11
+--- /dev/null
++++ b/arch/nios2nommu/mm/Makefile
+@@ -0,0 +1,12 @@
++# $Id: Makefile,v 1.1 2006/07/05 06:23:18 gerg Exp $
++# Makefile for the linux Sparc-specific parts of the memory manager.
++#
++# Note! Dependencies are done automagically by 'make dep', which also
++# removes any old dependencies. DON'T put your own dependencies here
++# unless it's something special (ie not a .c file).
++#
++# Note 2! The CFLAGS definition is now in the main makefile...
++
++obj-y := init.o ioremap.o extable.o memory.o
++obj-y += dma-noncoherent.o
++
+diff --git a/arch/nios2nommu/mm/dma-noncoherent.c b/arch/nios2nommu/mm/dma-noncoherent.c
+new file mode 100644
+index 0000000..5649940
+--- /dev/null
++++ b/arch/nios2nommu/mm/dma-noncoherent.c
+@@ -0,0 +1,373 @@
++/*
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file "COPYING" in the main directory of this archive
++ * for more details.
++ *
++ * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
++ * Copyright (C) 2000, 2001 Ralf Baechle <ralf@gnu.org>
++ * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
++ */
++#include <linux/types.h>
++#include <linux/mm.h>
++#include <linux/module.h>
++#include <linux/string.h>
++#include <linux/dma-mapping.h>
++
++#include <asm/cache.h>
++#include <asm/cacheflush.h>
++#include <asm/io.h>
++
++#define UNCAC_ADDR(addr) ((void *)((unsigned long)(addr) | 0x80000000))
++#define CAC_ADDR(addr) ((void *)((unsigned long)(addr) & ~0x80000000))
++
++/*
++ * Warning on the terminology - Linux calls an uncached area coherent;
++ * MIPS terminology calls memory areas with hardware maintained coherency
++ * coherent.
++ */
++
++void *dma_alloc_noncoherent(struct device *dev, size_t size,
++ dma_addr_t * dma_handle, gfp_t gfp)
++{
++ void *ret;
++ /* ignore region specifiers */
++ gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
++
++ if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
++ gfp |= GFP_DMA;
++ ret = (void *) __get_free_pages(gfp, get_order(size));
++
++ if (ret != NULL) {
++ memset(ret, 0, size);
++ *dma_handle = virt_to_phys(ret);
++ }
++
++ return ret;
++}
++
++EXPORT_SYMBOL(dma_alloc_noncoherent);
++
++void *dma_alloc_coherent(struct device *dev, size_t size,
++ dma_addr_t * dma_handle, gfp_t gfp)
++{
++ void *ret;
++
++ ret = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
++ if (ret) {
++ dma_cache_wback_inv((unsigned long) ret, size);
++ ret = UNCAC_ADDR(ret);
++ }
++
++ return ret;
++}
++
++EXPORT_SYMBOL(dma_alloc_coherent);
++
++void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
++ dma_addr_t dma_handle)
++{
++ free_pages((unsigned long) vaddr, get_order(size));
++}
++
++EXPORT_SYMBOL(dma_free_noncoherent);
++
++void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
++ dma_addr_t dma_handle)
++{
++ unsigned long addr = (unsigned long) vaddr;
++
++ addr = (unsigned long) CAC_ADDR(addr);
++ free_pages(addr, get_order(size));
++}
++
++EXPORT_SYMBOL(dma_free_coherent);
++
++static inline void __dma_sync(unsigned long addr, size_t size,
++ enum dma_data_direction direction)
++{
++ switch (direction) {
++ case DMA_TO_DEVICE:
++ dma_cache_wback(addr, size);
++ break;
++
++ case DMA_FROM_DEVICE:
++ dma_cache_inv(addr, size);
++ break;
++
++ case DMA_BIDIRECTIONAL:
++ dma_cache_wback_inv(addr, size);
++ break;
++
++ default:
++ BUG();
++ }
++}
++
++dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
++ enum dma_data_direction direction)
++{
++ unsigned long addr = (unsigned long) ptr;
++
++ __dma_sync(addr, size, direction);
++
++ return virt_to_phys(ptr);
++}
++
++EXPORT_SYMBOL(dma_map_single);
++
++void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ unsigned long addr;
++ addr = dma_addr + PAGE_OFFSET;
++
++ //__dma_sync(addr, size, direction);
++}
++
++EXPORT_SYMBOL(dma_unmap_single);
++
++int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction)
++{
++ int i;
++
++ BUG_ON(direction == DMA_NONE);
++
++ for (i = 0; i < nents; i++, sg++) {
++ unsigned long addr;
++
++ addr = (unsigned long) page_address(sg->page);
++ if (addr) {
++ __dma_sync(addr + sg->offset, sg->length, direction);
++ sg->dma_address = (dma_addr_t)page_to_phys(sg->page)
++ + sg->offset;
++ }
++ }
++
++ return nents;
++}
++
++EXPORT_SYMBOL(dma_map_sg);
++
++dma_addr_t dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size, enum dma_data_direction direction)
++{
++ unsigned long addr;
++
++ BUG_ON(direction == DMA_NONE);
++
++ addr = (unsigned long) page_address(page) + offset;
++ dma_cache_wback_inv(addr, size);
++
++ return page_to_phys(page) + offset;
++}
++
++EXPORT_SYMBOL(dma_map_page);
++
++void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(direction == DMA_NONE);
++
++ if (direction != DMA_TO_DEVICE) {
++ unsigned long addr;
++
++ addr = dma_address + PAGE_OFFSET;
++ dma_cache_wback_inv(addr, size);
++ }
++}
++
++EXPORT_SYMBOL(dma_unmap_page);
++
++void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
++ enum dma_data_direction direction)
++{
++ unsigned long addr;
++ int i;
++
++ BUG_ON(direction == DMA_NONE);
++
++ if (direction == DMA_TO_DEVICE)
++ return;
++
++ for (i = 0; i < nhwentries; i++, sg++) {
++ addr = (unsigned long) page_address(sg->page);
++ if (addr)
++ __dma_sync(addr + sg->offset, sg->length, direction);
++ }
++}
++
++EXPORT_SYMBOL(dma_unmap_sg);
++
++void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
++ size_t size, enum dma_data_direction direction)
++{
++ unsigned long addr;
++
++ BUG_ON(direction == DMA_NONE);
++
++ addr = dma_handle + PAGE_OFFSET;
++ __dma_sync(addr, size, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_single_for_cpu);
++
++void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
++ size_t size, enum dma_data_direction direction)
++{
++ unsigned long addr;
++
++ BUG_ON(direction == DMA_NONE);
++
++ addr = dma_handle + PAGE_OFFSET;
++ __dma_sync(addr, size, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_single_for_device);
++
++void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size, enum dma_data_direction direction)
++{
++ unsigned long addr;
++
++ BUG_ON(direction == DMA_NONE);
++
++ addr = dma_handle + offset + PAGE_OFFSET;
++ __dma_sync(addr, size, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
++
++void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size, enum dma_data_direction direction)
++{
++ unsigned long addr;
++
++ BUG_ON(direction == DMA_NONE);
++
++ addr = dma_handle + offset + PAGE_OFFSET;
++ __dma_sync(addr, size, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_single_range_for_device);
++
++void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ int i;
++
++ BUG_ON(direction == DMA_NONE);
++
++ /* Make sure that gcc doesn't leave the empty loop body. */
++ for (i = 0; i < nelems; i++, sg++)
++ __dma_sync((unsigned long)page_address(sg->page),
++ sg->length, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_sg_for_cpu);
++
++void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ int i;
++
++ BUG_ON(direction == DMA_NONE);
++
++ /* Make sure that gcc doesn't leave the empty loop body. */
++ for (i = 0; i < nelems; i++, sg++)
++ __dma_sync((unsigned long)page_address(sg->page),
++ sg->length, direction);
++}
++
++EXPORT_SYMBOL(dma_sync_sg_for_device);
++
++int dma_mapping_error(dma_addr_t dma_addr)
++{
++ return 0;
++}
++
++EXPORT_SYMBOL(dma_mapping_error);
++
++int dma_supported(struct device *dev, u64 mask)
++{
++ /*
++ * we fall back to GFP_DMA when the mask isn't all 1s,
++ * so we can't guarantee allocations that must be
++ * within a tighter range than GFP_DMA..
++ */
++ if (mask < 0x00ffffff)
++ return 0;
++
++ return 1;
++}
++
++EXPORT_SYMBOL(dma_supported);
++
++int dma_is_consistent(dma_addr_t dma_addr)
++{
++ return 1;
++}
++
++EXPORT_SYMBOL(dma_is_consistent);
++
++void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction)
++{
++ if (direction == DMA_NONE)
++ return;
++
++ dma_cache_wback_inv((unsigned long)vaddr, size);
++}
++
++EXPORT_SYMBOL(dma_cache_sync);
++
++/* The DAC routines are a PCIism.. */
++
++#ifdef CONFIG_PCI
++
++#include <linux/pci.h>
++
++dma64_addr_t pci_dac_page_to_dma(struct pci_dev *pdev,
++ struct page *page, unsigned long offset, int direction)
++{
++ return (dma64_addr_t)page_to_phys(page) + offset;
++}
++
++EXPORT_SYMBOL(pci_dac_page_to_dma);
++
++struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
++ dma64_addr_t dma_addr)
++{
++ return mem_map + (dma_addr >> PAGE_SHIFT);
++}
++
++EXPORT_SYMBOL(pci_dac_dma_to_page);
++
++unsigned long pci_dac_dma_to_offset(struct pci_dev *pdev,
++ dma64_addr_t dma_addr)
++{
++ return dma_addr & ~PAGE_MASK;
++}
++
++EXPORT_SYMBOL(pci_dac_dma_to_offset);
++
++void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev,
++ dma64_addr_t dma_addr, size_t len, int direction)
++{
++ BUG_ON(direction == PCI_DMA_NONE);
++
++ dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
++}
++
++EXPORT_SYMBOL(pci_dac_dma_sync_single_for_cpu);
++
++void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev,
++ dma64_addr_t dma_addr, size_t len, int direction)
++{
++ BUG_ON(direction == PCI_DMA_NONE);
++
++ dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
++}
++
++EXPORT_SYMBOL(pci_dac_dma_sync_single_for_device);
++
++#endif /* CONFIG_PCI */
+diff --git a/arch/nios2nommu/mm/extable.c b/arch/nios2nommu/mm/extable.c
+new file mode 100644
+index 0000000..e23778f
+--- /dev/null
++++ b/arch/nios2nommu/mm/extable.c
+@@ -0,0 +1,29 @@
++/*
++ * linux/arch/niosnommu/mm/extable.c
++ */
++
++#include <linux/module.h>
++#include <linux/spinlock.h>
++#include <asm/uaccess.h>
++
++/* Simple binary search */
++const struct exception_table_entry *
++search_extable(const struct exception_table_entry *first,
++ const struct exception_table_entry *last,
++ unsigned long value)
++{
++ while (first <= last) {
++ const struct exception_table_entry *mid;
++ long diff;
++
++ mid = (last - first) / 2 + first;
++ diff = mid->insn - value;
++ if (diff == 0)
++ return mid;
++ else if (diff < 0)
++ first = mid+1;
++ else
++ last = mid-1;
++ }
++ return NULL;
++}
+diff --git a/arch/nios2nommu/mm/init.c b/arch/nios2nommu/mm/init.c
+new file mode 100644
+index 0000000..21fe61b
+--- /dev/null
++++ b/arch/nios2nommu/mm/init.c
+@@ -0,0 +1,231 @@
++/*
++ * linux/arch/nios2nommu/mm/init.c
++ *
++ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
++ * Kenneth Albanowski <kjahds@kjahds.com>,
++ * Copyright (C) 2000 Lineo, Inc. (www.lineo.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * Based on:
++ *
++ * linux/arch/m68k/mm/init.c
++ *
++ * Copyright (C) 1995 Hamish Macdonald
++ *
++ * JAN/1999 -- hacked to support ColdFire (gerg@snapgear.com)
++ * DEC/2000 -- linux 2.4 support <davidm@snapgear.com>
++ * Jan/20/2004 dgt NiosII
++ *
++ */
++
++#include <linux/signal.h>
++#include <linux/sched.h>
++#include <linux/kernel.h>
++#include <linux/errno.h>
++#include <linux/string.h>
++#include <linux/types.h>
++#include <linux/ptrace.h>
++#include <linux/mman.h>
++#include <linux/mm.h>
++#include <linux/swap.h>
++#include <linux/init.h>
++#include <linux/highmem.h>
++#include <linux/pagemap.h>
++#include <linux/bootmem.h>
++#include <linux/slab.h>
++
++#include <asm/setup.h>
++#include <asm/segment.h>
++#include <asm/page.h>
++#include <asm/pgtable.h>
++#include <asm/system.h>
++//;dgt2;#include <asm/machdep.h>
++//;dgt2;#include <asm/shglcore.h>
++
++#undef DEBUG
++
++extern void die_if_kernel(char *,struct pt_regs *,long);
++extern void free_initmem(void);
++
++/*
++ * BAD_PAGE is the page that is used for page faults when linux
++ * is out-of-memory. Older versions of linux just did a
++ * do_exit(), but using this instead means there is less risk
++ * for a process dying in kernel mode, possibly leaving a inode
++ * unused etc..
++ *
++ * BAD_PAGETABLE is the accompanying page-table: it is initialized
++ * to point to BAD_PAGE entries.
++ *
++ * ZERO_PAGE is a special page that is used for zero-initialized
++ * data and COW.
++ */
++static unsigned long empty_bad_page_table;
++
++static unsigned long empty_bad_page;
++
++unsigned long empty_zero_page;
++
++extern unsigned long rom_length;
++
++void show_mem(void)
++{
++ unsigned long i;
++ int free = 0, total = 0, reserved = 0, shared = 0;
++ int cached = 0;
++
++ printk(KERN_INFO "\nMem-info:\n");
++ show_free_areas();
++ i = max_mapnr;
++ while (i-- > 0) {
++ total++;
++ if (PageReserved(mem_map+i))
++ reserved++;
++ else if (PageSwapCache(mem_map+i))
++ cached++;
++ else if (!page_count(mem_map+i))
++ free++;
++ else
++ shared += page_count(mem_map+i) - 1;
++ }
++ printk(KERN_INFO "%d pages of RAM\n",total);
++ printk(KERN_INFO "%d free pages\n",free);
++ printk(KERN_INFO "%d reserved pages\n",reserved);
++ printk(KERN_INFO "%d pages shared\n",shared);
++ printk(KERN_INFO "%d pages swap cached\n",cached);
++}
++
++extern unsigned long memory_start;
++extern unsigned long memory_end;
++
++/*
++ * paging_init() continues the virtual memory environment setup which
++ * was begun by the code in arch/head.S.
++ * The parameters are pointers to where to stick the starting and ending
++ * addresses of available kernel virtual memory.
++ */
++void __init paging_init(void)
++{
++ /*
++ * Make sure start_mem is page aligned, otherwise bootmem and
++ * page_alloc get different views of the world.
++ */
++#ifdef DEBUG
++ unsigned long start_mem = PAGE_ALIGN(memory_start);
++#endif
++ unsigned long end_mem = memory_end & PAGE_MASK;
++
++#ifdef DEBUG
++ printk (KERN_DEBUG "start_mem is %#lx\nvirtual_end is %#lx\n",
++ start_mem, end_mem);
++#endif
++
++ /*
++ * Initialize the bad page table and bad page to point
++ * to a couple of allocated pages.
++ */
++ empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
++ empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
++ empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
++ memset((void *)empty_zero_page, 0, PAGE_SIZE);
++
++ /*
++ * Set up SFC/DFC registers (user data space).
++ */
++ set_fs (USER_DS);
++
++#ifdef DEBUG
++ printk (KERN_DEBUG "before free_area_init\n");
++
++ printk (KERN_DEBUG "free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
++ start_mem, end_mem);
++#endif
++
++ {
++ unsigned long zones_size[MAX_NR_ZONES] = {0, };
++
++ zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
++ zones_size[ZONE_NORMAL] = 0;
++#ifdef CONFIG_HIGHMEM
++ zones_size[ZONE_HIGHMEM] = 0;
++#endif
++ free_area_init(zones_size);
++ }
++}
++
++void __init mem_init(void)
++{
++ int codek = 0, datak = 0, initk = 0;
++ unsigned long tmp;
++ extern char _etext, _stext, __init_begin, __init_end, _end;
++ unsigned long start_mem = memory_start; /* DAVIDM - these must start at end of kernel */
++ unsigned long end_mem = memory_end; /* DAVIDM - this must not include kernel stack at top */
++
++#ifdef DEBUG
++ printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
++#endif
++
++ end_mem &= PAGE_MASK;
++ high_memory = (void *) end_mem;
++
++ start_mem = PAGE_ALIGN(start_mem);
++ max_mapnr = num_physpages = MAP_NR(high_memory);
++
++ /* this will put all memory onto the freelists */
++ totalram_pages = free_all_bootmem();
++
++ codek = (&_etext - &_stext) >> 10;
++ datak = (&_end - &_etext) >> 10;
++ initk = (&__init_begin - &__init_end) >> 10;
++
++ tmp = nr_free_pages() << PAGE_SHIFT;
++ printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
++ tmp >> 10,
++ (&_end - &_stext) >> 10,
++ (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
++ rom_length >> 10,
++ codek,
++ datak
++ );
++}
++
++
++#ifdef CONFIG_BLK_DEV_INITRD
++void __init free_initrd_mem(unsigned long start, unsigned long end)
++{
++ int pages = 0;
++ for (; start < end; start += PAGE_SIZE) {
++ ClearPageReserved(virt_to_page(start));
++ init_page_count(virt_to_page(start));
++ free_page(start);
++ totalram_pages++;
++ pages++;
++ }
++ printk (KERN_NOTICE "Freeing initrd memory: %dk freed\n", pages);
++}
++#endif
++
++void free_initmem(void)
++{
++#ifdef CONFIG_RAMKERNEL
++ unsigned long addr;
++ extern char __init_begin, __init_end;
++ /*
++ * The following code should be cool even if these sections
++ * are not page aligned.
++ */
++ addr = PAGE_ALIGN((unsigned long)(&__init_begin));
++ /* next to check that the page we free is not a partial page */
++ for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
++ ClearPageReserved(virt_to_page(addr));
++ init_page_count(virt_to_page(addr));
++ free_page(addr);
++ totalram_pages++;
++ }
++ printk(KERN_NOTICE "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
++ (addr - PAGE_ALIGN((long) &__init_begin)) >> 10,
++ (int)(PAGE_ALIGN((unsigned long)(&__init_begin))),
++ (int)(addr - PAGE_SIZE));
++#endif
++}
++
+diff --git a/arch/nios2nommu/mm/ioremap.c b/arch/nios2nommu/mm/ioremap.c
+new file mode 100644
+index 0000000..1c8b172
+--- /dev/null
++++ b/arch/nios2nommu/mm/ioremap.c
+@@ -0,0 +1,65 @@
++/* linux/arch/nios2nommu/mm/ioremap.c, based on:
++ *
++ * linux/arch/m68knommu/mm/kmap.c
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2000 Lineo, <davidm@lineo.com>
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/mm.h>
++#include <linux/kernel.h>
++#include <linux/string.h>
++#include <linux/types.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++
++#include <asm/setup.h>
++#include <asm/segment.h>
++#include <asm/page.h>
++#include <asm/pgalloc.h>
++#include <asm/io.h>
++#include <asm/system.h>
++
++/*
++ * Map some physical address range into the kernel address space.
++ */
++
++void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
++{
++ return (void *)physaddr;
++}
++
++/*
++ * Unmap a ioremap()ed region again
++ */
++void iounmap(void *addr)
++{
++}
++
++/*
++ * __iounmap unmaps nearly everything, so be careful
++ * it doesn't free currently pointer/page tables anymore but it
++ * wans't used anyway and might be added later.
++ */
++void __iounmap(void *addr, unsigned long size)
++{
++}
++
+diff --git a/arch/nios2nommu/mm/memory.c b/arch/nios2nommu/mm/memory.c
+new file mode 100644
+index 0000000..76d60d9
+--- /dev/null
++++ b/arch/nios2nommu/mm/memory.c
+@@ -0,0 +1,212 @@
++/*
++ * linux/arch/nio2nommu/mm/memory.c
++ *
++ * Copyright (C) 1995 Hamish Macdonald
++ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
++ * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * Based on:
++ *
++ * linux/arch/m68k/mm/memory.c
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/mm.h>
++#include <linux/kernel.h>
++#include <linux/string.h>
++#include <linux/types.h>
++#include <linux/slab.h>
++
++#include <asm/setup.h>
++#include <asm/segment.h>
++#include <asm/page.h>
++#include <asm/pgtable.h>
++#include <asm/system.h>
++#include <asm/traps.h>
++#include <asm/io.h>
++
++/*
++ * cache_clear() semantics: Clear any cache entries for the area in question,
++ * without writing back dirty entries first. This is useful if the data will
++ * be overwritten anyway, e.g. by DMA to memory. The range is defined by a
++ * _physical_ address.
++ */
++
++void cache_clear (unsigned long paddr, int len)
++{
++}
++
++
++/*
++ * Define cache invalidate functions. The instruction and data cache
++ * will need to be flushed. Write back the dirty data cache and invalidate
++ * the instruction cache for the range.
++ *
++ */
++
++static __inline__ void cache_invalidate_inst(unsigned long paddr, int len)
++{
++ unsigned long sset, eset;
++
++ sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
++ eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
++
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushi %0\n\t"
++ "add %0,%0,%2\n\t"
++ "blt %0,%1,1b\n\t"
++ "flushp\n\t"
++ : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
++
++}
++
++static __inline__ void cache_invalidate_data(unsigned long paddr, int len)
++{
++ unsigned long sset, eset;
++
++ sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
++ eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
++
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushd 0(%0)\n\t"
++ "add %0,%0,%2\n\t"
++ "blt %0,%1,1b\n\t"
++ : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
++
++}
++
++static __inline__ void cache_invalidate_lines(unsigned long paddr, int len)
++{
++ unsigned long sset, eset;
++
++ sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
++ eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
++
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushd 0(%0)\n\t"
++ "add %0,%0,%2\n\t"
++ "blt %0,%1,1b\n\t"
++ : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
++
++ sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
++ eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
++
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushi %0\n\t"
++ "add %0,%0,%2\n\t"
++ "blt %0,%1,1b\n\t"
++ "flushp\n\t"
++ : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
++
++}
++
++/*
++ * cache_push() semantics: Write back any dirty cache data in the given area,
++ * and invalidate the range in the instruction cache. It needs not (but may)
++ * invalidate those entries also in the data cache. The range is defined by a
++ * _physical_ address.
++ */
++
++void cache_push (unsigned long paddr, int len)
++{
++ cache_invalidate_lines(paddr, len);
++}
++
++
++/*
++ * cache_push_v() semantics: Write back any dirty cache data in the given
++ * area, and invalidate those entries at least in the instruction cache. This
++ * is intended to be used after data has been written that can be executed as
++ * code later. The range is defined by a _user_mode_ _virtual_ address.
++ */
++
++void cache_push_v (unsigned long vaddr, int len)
++{
++ cache_invalidate_lines(vaddr, len);
++}
++
++/*
++ * cache_push_all() semantics: Invalidate instruction cache and write back
++ * dirty data cache & invalidate.
++ */
++void cache_push_all (void)
++{
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushd 0(%0)\n\t"
++ "sub %0,%0,%1\n\t"
++ "bgt %0,r0,1b\n\t"
++ : : "r" (nasys_dcache_size), "r" (nasys_dcache_line_size));
++
++ __asm__ __volatile__ (
++ "1:\n\t"
++ "flushi %0\n\t"
++ "sub %0,%0,%1\n\t"
++ "bgt %0,r0,1b\n\t"
++ "flushp\n\t"
++ : : "r" (nasys_icache_size), "r" (nasys_icache_line_size));
++
++}
++
++/*
++ * dcache_push() semantics: Write back and dirty data cache and invalidate
++ * the range.
++ */
++void dcache_push (unsigned long vaddr, int len)
++{
++ cache_invalidate_data(vaddr, len);
++}
++
++/*
++ * icache_push() semantics: Invalidate instruction cache in the range.
++ */
++void icache_push (unsigned long vaddr, int len)
++{
++ cache_invalidate_inst(vaddr, len);
++}
++
++/* Map some physical address range into the kernel address space. The
++ * code is copied and adapted from map_chunk().
++ */
++
++unsigned long kernel_map(unsigned long paddr, unsigned long size,
++ int nocacheflag, unsigned long *memavailp )
++{
++ return paddr;
++}
++
++
++int is_in_rom(unsigned long addr)
++{
++ /* Default case, not in ROM */
++ return(0);
++}
++
++int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
++ unsigned long address, int write_access)
++{
++ BUG();
++ return VM_FAULT_OOM;
++}
+diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.pm b/arch/nios2nommu/scripts/PTF/PTFParser.pm
+new file mode 100644
+index 0000000..c243c7b
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/PTFParser.pm
+@@ -0,0 +1,873 @@
++####################################################################
++#
++# This file was generated using Parse::Yapp version 1.05.
++#
++# Don't edit this file, use source file instead.
++#
++# ANY CHANGE MADE HERE WILL BE LOST !
++#
++####################################################################
++package PTFParser;
++use vars qw ( @ISA );
++use strict;
++
++@ISA= qw ( Parse::Yapp::Driver );
++#Included Parse/Yapp/Driver.pm file----------------------------------------
++{
++#
++# Module Parse::Yapp::Driver
++#
++# This module is part of the Parse::Yapp package available on your
++# nearest CPAN
++#
++# Any use of this module in a standalone parser make the included
++# text under the same copyright as the Parse::Yapp module itself.
++#
++# This notice should remain unchanged.
++#
++# (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
++# (see the pod text in Parse::Yapp module for use and distribution rights)
++#
++
++package Parse::Yapp::Driver;
++
++require 5.004;
++
++use strict;
++
++use vars qw ( $VERSION $COMPATIBLE $FILENAME );
++
++$VERSION = '1.05';
++$COMPATIBLE = '0.07';
++$FILENAME=__FILE__;
++
++use Carp;
++
++#Known parameters, all starting with YY (leading YY will be discarded)
++my(%params)=(YYLEX => 'CODE', 'YYERROR' => 'CODE', YYVERSION => '',
++ YYRULES => 'ARRAY', YYSTATES => 'ARRAY', YYDEBUG => '');
++#Mandatory parameters
++my(@params)=('LEX','RULES','STATES');
++
++sub new {
++ my($class)=shift;
++ my($errst,$nberr,$token,$value,$check,$dotpos);
++ my($self)={ ERROR => \&_Error,
++ ERRST => \$errst,
++ NBERR => \$nberr,
++ TOKEN => \$token,
++ VALUE => \$value,
++ DOTPOS => \$dotpos,
++ STACK => [],
++ DEBUG => 0,
++ CHECK => \$check };
++
++ _CheckParams( [], \%params, \@_, $self );
++
++ exists($$self{VERSION})
++ and $$self{VERSION} < $COMPATIBLE
++ and croak "Yapp driver version $VERSION ".
++ "incompatible with version $$self{VERSION}:\n".
++ "Please recompile parser module.";
++
++ ref($class)
++ and $class=ref($class);
++
++ bless($self,$class);
++}
++
++sub YYParse {
++ my($self)=shift;
++ my($retval);
++
++ _CheckParams( \@params, \%params, \@_, $self );
++
++ if($$self{DEBUG}) {
++ _DBLoad();
++ $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
++ $@ and die $@;
++ }
++ else {
++ $retval = $self->_Parse();
++ }
++ $retval
++}
++
++sub YYData {
++ my($self)=shift;
++
++ exists($$self{USER})
++ or $$self{USER}={};
++
++ $$self{USER};
++
++}
++
++sub YYErrok {
++ my($self)=shift;
++
++ ${$$self{ERRST}}=0;
++ undef;
++}
++
++sub YYNberr {
++ my($self)=shift;
++
++ ${$$self{NBERR}};
++}
++
++sub YYRecovering {
++ my($self)=shift;
++
++ ${$$self{ERRST}} != 0;
++}
++
++sub YYAbort {
++ my($self)=shift;
++
++ ${$$self{CHECK}}='ABORT';
++ undef;
++}
++
++sub YYAccept {
++ my($self)=shift;
++
++ ${$$self{CHECK}}='ACCEPT';
++ undef;
++}
++
++sub YYError {
++ my($self)=shift;
++
++ ${$$self{CHECK}}='ERROR';
++ undef;
++}
++
++sub YYSemval {
++ my($self)=shift;
++ my($index)= $_[0] - ${$$self{DOTPOS}} - 1;
++
++ $index < 0
++ and -$index <= @{$$self{STACK}}
++ and return $$self{STACK}[$index][1];
++
++ undef; #Invalid index
++}
++
++sub YYCurtok {
++ my($self)=shift;
++
++ @_
++ and ${$$self{TOKEN}}=$_[0];
++ ${$$self{TOKEN}};
++}
++
++sub YYCurval {
++ my($self)=shift;
++
++ @_
++ and ${$$self{VALUE}}=$_[0];
++ ${$$self{VALUE}};
++}
++
++sub YYExpect {
++ my($self)=shift;
++
++ keys %{$self->{STATES}[$self->{STACK}[-1][0]]{ACTIONS}}
++}
++
++sub YYLexer {
++ my($self)=shift;
++
++ $$self{LEX};
++}
++
++
++#################
++# Private stuff #
++#################
++
++
++sub _CheckParams {
++ my($mandatory,$checklist,$inarray,$outhash)=@_;
++ my($prm,$value);
++ my($prmlst)={};
++
++ while(($prm,$value)=splice(@$inarray,0,2)) {
++ $prm=uc($prm);
++ exists($$checklist{$prm})
++ or croak("Unknow parameter '$prm'");
++ ref($value) eq $$checklist{$prm}
++ or croak("Invalid value for parameter '$prm'");
++ $prm=unpack('@2A*',$prm);
++ $$outhash{$prm}=$value;
++ }
++ for (@$mandatory) {
++ exists($$outhash{$_})
++ or croak("Missing mandatory parameter '".lc($_)."'");
++ }
++}
++
++sub _Error {
++ print "Parse error.\n";
++}
++
++sub _DBLoad {
++ {
++ no strict 'refs';
++
++ exists(${__PACKAGE__.'::'}{_DBParse})#Already loaded ?
++ and return;
++ }
++ my($fname)=__FILE__;
++ my(@drv);
++ open(DRV,"<$fname") or die "Report this as a BUG: Cannot open $fname";
++ while(<DRV>) {
++ /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
++ and do {
++ s/^#DBG>//;
++ push(@drv,$_);
++ }
++ }
++ close(DRV);
++
++ $drv[0]=~s/_P/_DBP/;
++ eval join('',@drv);
++}
++
++#Note that for loading debugging version of the driver,
++#this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
++#So, DO NOT remove comment at end of sub !!!
++sub _Parse {
++ my($self)=shift;
++
++ my($rules,$states,$lex,$error)
++ = @$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
++ my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
++ = @$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
++
++#DBG> my($debug)=$$self{DEBUG};
++#DBG> my($dbgerror)=0;
++
++#DBG> my($ShowCurToken) = sub {
++#DBG> my($tok)='>';
++#DBG> for (split('',$$token)) {
++#DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
++#DBG> ? sprintf('<%02X>',ord($_))
++#DBG> : $_;
++#DBG> }
++#DBG> $tok.='<';
++#DBG> };
++
++ $$errstatus=0;
++ $$nberror=0;
++ ($$token,$$value)=(undef,undef);
++ @$stack=( [ 0, undef ] );
++ $$check='';
++
++ while(1) {
++ my($actions,$act,$stateno);
++
++ $stateno=$$stack[-1][0];
++ $actions=$$states[$stateno];
++
++#DBG> print STDERR ('-' x 40),"\n";
++#DBG> $debug & 0x2
++#DBG> and print STDERR "In state $stateno:\n";
++#DBG> $debug & 0x08
++#DBG> and print STDERR "Stack:[".
++#DBG> join(',',map { $$_[0] } @$stack).
++#DBG> "]\n";
++
++
++ if (exists($$actions{ACTIONS})) {
++
++ defined($$token)
++ or do {
++ ($$token,$$value)=&$lex($self);
++#DBG> $debug & 0x01
++#DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
++ };
++
++ $act= exists($$actions{ACTIONS}{$$token})
++ ? $$actions{ACTIONS}{$$token}
++ : exists($$actions{DEFAULT})
++ ? $$actions{DEFAULT}
++ : undef;
++ }
++ else {
++ $act=$$actions{DEFAULT};
++#DBG> $debug & 0x01
++#DBG> and print STDERR "Don't need token.\n";
++ }
++
++ defined($act)
++ and do {
++
++ $act > 0
++ and do { #shift
++
++#DBG> $debug & 0x04
++#DBG> and print STDERR "Shift and go to state $act.\n";
++
++ $$errstatus
++ and do {
++ --$$errstatus;
++
++#DBG> $debug & 0x10
++#DBG> and $dbgerror
++#DBG> and $$errstatus == 0
++#DBG> and do {
++#DBG> print STDERR "**End of Error recovery.\n";
++#DBG> $dbgerror=0;
++#DBG> };
++ };
++
++
++ push(@$stack,[ $act, $$value ]);
++
++ $$token ne '' #Don't eat the eof
++ and $$token=$$value=undef;
++ next;
++ };
++
++ #reduce
++ my($lhs,$len,$code,@sempar,$semval);
++ ($lhs,$len,$code)=@{$$rules[-$act]};
++
++#DBG> $debug & 0x04
++#DBG> and $act
++#DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
++
++ $act
++ or $self->YYAccept();
++
++ $$dotpos=$len;
++
++ unpack('A1',$lhs) eq '@' #In line rule
++ and do {
++ $lhs =~ /^\@[0-9]+\-([0-9]+)$/
++ or die "In line rule name '$lhs' ill formed: ".
++ "report it as a BUG.\n";
++ $$dotpos = $1;
++ };
++
++ @sempar = $$dotpos
++ ? map { $$_[1] } @$stack[ -$$dotpos .. -1 ]
++ : ();
++
++ $semval = $code ? &$code( $self, @sempar )
++ : @sempar ? $sempar[0] : undef;
++
++ splice(@$stack,-$len,$len);
++
++ $$check eq 'ACCEPT'
++ and do {
++
++#DBG> $debug & 0x04
++#DBG> and print STDERR "Accept.\n";
++
++ return($semval);
++ };
++
++ $$check eq 'ABORT'
++ and do {
++
++#DBG> $debug & 0x04
++#DBG> and print STDERR "Abort.\n";
++
++ return(undef);
++
++ };
++
++#DBG> $debug & 0x04
++#DBG> and print STDERR "Back to state $$stack[-1][0], then ";
++
++ $$check eq 'ERROR'
++ or do {
++#DBG> $debug & 0x04
++#DBG> and print STDERR
++#DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
++
++#DBG> $debug & 0x10
++#DBG> and $dbgerror
++#DBG> and $$errstatus == 0
++#DBG> and do {
++#DBG> print STDERR "**End of Error recovery.\n";
++#DBG> $dbgerror=0;
++#DBG> };
++
++ push(@$stack,
++ [ $$states[$$stack[-1][0]]{GOTOS}{$lhs}, $semval ]);
++ $$check='';
++ next;
++ };
++
++#DBG> $debug & 0x04
++#DBG> and print STDERR "Forced Error recovery.\n";
++
++ $$check='';
++
++ };
++
++ #Error
++ $$errstatus
++ or do {
++
++ $$errstatus = 1;
++ &$error($self);
++ $$errstatus # if 0, then YYErrok has been called
++ or next; # so continue parsing
++
++#DBG> $debug & 0x10
++#DBG> and do {
++#DBG> print STDERR "**Entering Error recovery.\n";
++#DBG> ++$dbgerror;
++#DBG> };
++
++ ++$$nberror;
++
++ };
++
++ $$errstatus == 3 #The next token is not valid: discard it
++ and do {
++ $$token eq '' # End of input: no hope
++ and do {
++#DBG> $debug & 0x10
++#DBG> and print STDERR "**At eof: aborting.\n";
++ return(undef);
++ };
++
++#DBG> $debug & 0x10
++#DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
++
++ $$token=$$value=undef;
++ };
++
++ $$errstatus=3;
++
++ while( @$stack
++ and ( not exists($$states[$$stack[-1][0]]{ACTIONS})
++ or not exists($$states[$$stack[-1][0]]{ACTIONS}{error})
++ or $$states[$$stack[-1][0]]{ACTIONS}{error} <= 0)) {
++
++#DBG> $debug & 0x10
++#DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
++
++ pop(@$stack);
++ }
++
++ @$stack
++ or do {
++
++#DBG> $debug & 0x10
++#DBG> and print STDERR "**No state left on stack: aborting.\n";
++
++ return(undef);
++ };
++
++ #shift the error token
++
++#DBG> $debug & 0x10
++#DBG> and print STDERR "**Shift \$error token and go to state ".
++#DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
++#DBG> ".\n";
++
++ push(@$stack, [ $$states[$$stack[-1][0]]{ACTIONS}{error}, undef ]);
++
++ }
++
++ #never reached
++ croak("Error in driver logic. Please, report it as a BUG");
++
++}#_Parse
++#DO NOT remove comment
++
++1;
++
++}
++#End of include--------------------------------------------------
++
++
++#line 1 "PTFParser.yp"
++#
++# Altera PTF file parser
++#
++# Copyright (c) 2004 Microtronix Datacom Ltd.
++#
++
++package PTFParser;
++
++use PTF::PTFSection;
++
++#global variables should go here.
++
++#my $line = 0; # for error messages
++#my @sectionStack = (); # used to keep track of ptf sections
++#my $root;
++
++my $fh;
++
++sub new {
++ my($class)=shift;
++ ref($class)
++ and $class=ref($class);
++
++ my($self)=$class->SUPER::new( yyversion => '1.05',
++ yystates =>
++[
++ {#State 0
++ ACTIONS => {
++ 'IDENTIFIER' => 1
++ },
++ GOTOS => {
++ 'section' => 2,
++ 'section_title' => 3
++ }
++ },
++ {#State 1
++ ACTIONS => {
++ 'IDENTIFIER' => 4,
++ 'STRING_LITERAL' => 6,
++ 'NUMBER' => 7
++ },
++ DEFAULT => -3,
++ GOTOS => {
++ 'section_name' => 5
++ }
++ },
++ {#State 2
++ ACTIONS => {
++ '' => 8
++ }
++ },
++ {#State 3
++ ACTIONS => {
++ "{" => 9
++ }
++ },
++ {#State 4
++ DEFAULT => -4
++ },
++ {#State 5
++ DEFAULT => -2
++ },
++ {#State 6
++ DEFAULT => -6
++ },
++ {#State 7
++ DEFAULT => -5
++ },
++ {#State 8
++ DEFAULT => 0
++ },
++ {#State 9
++ ACTIONS => {
++ 'IDENTIFIER' => 11,
++ 'HIERARCHICAL_NAME' => 13
++ },
++ DEFAULT => -7,
++ GOTOS => {
++ 'assignment_name' => 10,
++ 'assignment' => 12,
++ 'section_element' => 14,
++ 'section' => 15,
++ 'section_title' => 3
++ }
++ },
++ {#State 10
++ ACTIONS => {
++ "=" => 16
++ }
++ },
++ {#State 11
++ ACTIONS => {
++ 'IDENTIFIER' => 4,
++ 'STRING_LITERAL' => 6,
++ 'NUMBER' => 7,
++ "=" => -11
++ },
++ DEFAULT => -3,
++ GOTOS => {
++ 'section_name' => 5
++ }
++ },
++ {#State 12
++ ACTIONS => {
++ 'IDENTIFIER' => 11,
++ 'HIERARCHICAL_NAME' => 13
++ },
++ DEFAULT => -7,
++ GOTOS => {
++ 'assignment_name' => 10,
++ 'assignment' => 12,
++ 'section_element' => 17,
++ 'section' => 15,
++ 'section_title' => 3
++ }
++ },
++ {#State 13
++ DEFAULT => -12
++ },
++ {#State 14
++ ACTIONS => {
++ "}" => 18
++ }
++ },
++ {#State 15
++ ACTIONS => {
++ 'IDENTIFIER' => 11,
++ 'HIERARCHICAL_NAME' => 13
++ },
++ DEFAULT => -7,
++ GOTOS => {
++ 'assignment_name' => 10,
++ 'assignment' => 12,
++ 'section_element' => 19,
++ 'section' => 15,
++ 'section_title' => 3
++ }
++ },
++ {#State 16
++ ACTIONS => {
++ 'STRING_LITERAL' => 20,
++ 'NUMBER' => 22
++ },
++ GOTOS => {
++ 'assignment_value' => 21
++ }
++ },
++ {#State 17
++ DEFAULT => -8
++ },
++ {#State 18
++ DEFAULT => -1
++ },
++ {#State 19
++ DEFAULT => -9
++ },
++ {#State 20
++ DEFAULT => -13
++ },
++ {#State 21
++ ACTIONS => {
++ ";" => 23
++ }
++ },
++ {#State 22
++ DEFAULT => -14
++ },
++ {#State 23
++ DEFAULT => -10
++ }
++],
++ yyrules =>
++[
++ [#Rule 0
++ '$start', 2, undef
++ ],
++ [#Rule 1
++ 'section', 4,
++sub
++#line 20 "PTFParser.yp"
++{
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++ pop @{$sectionStack};
++ }
++ ],
++ [#Rule 2
++ 'section_title', 2,
++sub
++#line 26 "PTFParser.yp"
++{
++ my $section = PTFSection->new (type => $_[1], name => $_[2]);
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++
++ if (scalar(@{$sectionStack}) == 0) {
++ $_[0]->YYData->{root} = $section;
++ } else {
++ my $parent = $sectionStack->[$#{$sectionStack}];
++ $parent->addSection ($section);
++ }
++
++ push @{$sectionStack}, $section;
++ }
++ ],
++ [#Rule 3
++ 'section_name', 0, undef
++ ],
++ [#Rule 4
++ 'section_name', 1, undef
++ ],
++ [#Rule 5
++ 'section_name', 1, undef
++ ],
++ [#Rule 6
++ 'section_name', 1, undef
++ ],
++ [#Rule 7
++ 'section_element', 0, undef
++ ],
++ [#Rule 8
++ 'section_element', 2, undef
++ ],
++ [#Rule 9
++ 'section_element', 2, undef
++ ],
++ [#Rule 10
++ 'assignment', 4,
++sub
++#line 52 "PTFParser.yp"
++{
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++ my $parent= $sectionStack->[$#{$sectionStack}];
++ $parent->addAssignment ($_[1], $_[3]);
++ }
++ ],
++ [#Rule 11
++ 'assignment_name', 1, undef
++ ],
++ [#Rule 12
++ 'assignment_name', 1, undef
++ ],
++ [#Rule 13
++ 'assignment_value', 1, undef
++ ],
++ [#Rule 14
++ 'assignment_value', 1, undef
++ ]
++],
++ @_);
++ bless($self,$class);
++}
++
++#line 67 "PTFParser.yp"
++
++
++sub _Error {
++# TODO: update this error function to be more useful
++ exists $_[0]->YYData->{ERRMSG}
++ and do {
++ print $_[0]->YYData->{ERRMSG};
++ delete $_[0]->YYData->{ERRMSG};
++ return;
++ };
++ print "Syntax error on line $_[0]->YYData->{line}.\n";
++}
++
++sub _Lexer {
++ my($parser)=shift;
++
++ if (! $parser->YYData->{INPUT}) {
++ if ($parser->YYData->{INPUT} = <$fh>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ }
++
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++
++ while (1) {
++
++ # skip blank lines
++ if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
++ if ($parser->YYData->{INPUT} = <$fh>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # Skip comments
++ if ($parser->YYData->{INPUT} =~ s/^#.*//) {
++ if ($parser->YYData->{INPUT} = <$fh>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # Don't continue if the line length is 0;
++ if (length $parser->YYData->{INPUT} == 0) {
++ if ($parser->YYData->{INPUT} = <$fh>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # tokenize input
++ $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
++ and return('IDENTIFIER',$1);
++ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
++ and return('STRING_LITERAL',$1);
++ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
++ and do {
++ my $literal = $1;
++
++ do {
++ if ($parser->YYData->{INPUT} = <$fh>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++
++ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
++ and do {
++ $literal .= $1;
++ return ('STRING_LITERAL', $literal);
++ };
++
++ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
++ and $literal .= $1;
++ } while (1);
++ };
++ $parser->YYData->{INPUT} =~ s/^([0-9]+)//
++ and return('NUMBER',$1);
++ $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
++ and return('HIERARCHICAL_NAME',$1);
++ $parser->YYData->{INPUT} =~ s/^(.)//
++ and return($1,$1);
++ }
++}
++
++sub readPTF {
++ my $self = shift;
++ my $filename = shift;
++
++ # store information for later use
++ $self->YYData->{line} = 0;
++ $self->YYData->{sectionStack} = [];
++ undef $self->YYData->{root};
++
++ if (-e $filename) {
++ open (PTFFILE, $filename);
++ $fh = \*PTFFILE;
++ } else {
++ $fh = \*STDIN;
++ }
++
++ $self->YYParse (
++ yylex => \&_Lexer,
++ yyerror => \&_Error,
++ );
++
++ if (-e $filename) {
++ close PTFFILE;
++ }
++
++ return $self->YYData->{root};
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.yp b/arch/nios2nommu/scripts/PTF/PTFParser.yp
+new file mode 100644
+index 0000000..e105e6a
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/PTFParser.yp
+@@ -0,0 +1,178 @@
++%{#
++# Altera PTF file parser
++#
++# Copyright (c) 2004 Microtronix Datacom Ltd.
++#
++
++package PTFParser;
++
++use PTF::PTFSection;
++
++%}
++
++%%
++section: section_title '{' section_element '}' {
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++ pop @{$sectionStack};
++ }
++;
++
++section_title: IDENTIFIER section_name {
++ my $section = PTFSection->new (type => $_[1], name => $_[2]);
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++
++ if (scalar(@{$sectionStack}) == 0) {
++ $_[0]->YYData->{root} = $section;
++ } else {
++ my $parent = $sectionStack->[$#{$sectionStack}];
++ $parent->addSection ($section);
++ }
++
++ push @{$sectionStack}, $section;
++ }
++;
++
++section_name: # empty string
++ | IDENTIFIER
++ | NUMBER
++ | STRING_LITERAL
++;
++
++section_element: # empty element
++ | assignment section_element
++ | section section_element
++;
++
++assignment: assignment_name '=' assignment_value ';' {
++ my $sectionStack = $_[0]->YYData->{sectionStack};
++ my $parent= $sectionStack->[$#{$sectionStack}];
++ $parent->addAssignment ($_[1], $_[3]);
++ }
++;
++
++assignment_name: IDENTIFIER
++ | HIERARCHICAL_NAME
++;
++
++assignment_value: STRING_LITERAL
++ | NUMBER
++;
++
++%%
++
++sub _Error {
++# TODO: update this error function to be more useful
++ exists $_[0]->YYData->{ERRMSG}
++ and do {
++ print $_[0]->YYData->{ERRMSG};
++ delete $_[0]->YYData->{ERRMSG};
++ return;
++ };
++ print "Syntax error on line $_[0]->YYData->{line}.\n";
++}
++
++sub _Lexer {
++ my($parser)=shift;
++
++ if (! $parser->YYData->{INPUT}) {
++ if ($parser->YYData->{INPUT} = <PTFFILE>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ }
++
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++
++ while (1) {
++
++ # skip blank lines
++ if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
++ if ($parser->YYData->{INPUT} = <PTFFILE>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # Skip comments
++ if ($parser->YYData->{INPUT} =~ s/^#.*//) {
++ if ($parser->YYData->{INPUT} = <PTFFILE>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # Don't continue if the line length is 0;
++ if (length $parser->YYData->{INPUT} == 0) {
++ if ($parser->YYData->{INPUT} = <PTFFILE>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++ $parser->YYData->{INPUT} and
++ $parser->YYData->{INPUT} =~ s/^\s*//;
++ next;
++ }
++
++ # tokenize input
++ $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
++ and return('IDENTIFIER',$1);
++ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
++ and return('STRING_LITERAL',$1);
++ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
++ and do {
++ my $literal = $1;
++
++ do {
++ if ($parser->YYData->{INPUT} = <PTFFILE>) {
++ $parser->YYData->{line} += 1;
++ } else {
++ return ('', undef);
++ }
++
++ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
++ and do {
++ $literal .= $1;
++ return ('STRING_LITERAL', $literal);
++ };
++
++ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
++ and $literal .= $1;
++ } while (1);
++ };
++ $parser->YYData->{INPUT} =~ s/^([0-9]+)//
++ and return('NUMBER',$1);
++ $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
++ and return('HIERARCHICAL_NAME',$1);
++ $parser->YYData->{INPUT} =~ s/^(.)//
++ and return($1,$1);
++ }
++}
++
++sub readPTF {
++ my $self = shift;
++ my $filename = shift;
++
++ # store information for later use
++ $self->YYData->{line} = 0;
++ $self->YYData->{sectionStack} = [];
++ undef $self->YYData->{root};
++
++ open (PTFFILE, $filename) or return undef;
++ $self->YYParse (
++ yylex => \&_Lexer,
++ yyerror => \&_Error,
++ );
++ close PTFFILE;
++
++ return $self->YYData->{root};
++}
+diff --git a/arch/nios2nommu/scripts/PTF/PTFSection.pm b/arch/nios2nommu/scripts/PTF/PTFSection.pm
+new file mode 100644
+index 0000000..a88d340
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/PTFSection.pm
+@@ -0,0 +1,81 @@
++package PTFSection;
++
++use strict;
++
++# Fields:
++# type = type of PTF Section
++# name = name of PTF Section (can be blank)
++# sections = array of section references
++# assignments = hash of assignments
++
++sub new {
++ my $invocant = shift;
++ my $class = ref($invocant) || $invocant;
++ my $self = {
++ @_,
++ sections => [],
++ assignments => {},
++ };
++ bless ($self, $class);
++ return $self;
++}
++
++sub addSection {
++ my ($self, $section) = @_;
++ push @{$self->{sections}}, $section;
++}
++
++sub getSections {
++ my ($self, $type) = @_;
++
++ if (! $type) {
++ return @{$self->{sections}};
++ }
++
++ my @matchedSections;
++ foreach my $section (@{$self->{sections}}) {
++ if ($section->type eq $type) {
++ push @matchedSections, $section;
++ }
++ }
++
++ return @matchedSections;
++}
++
++sub getSection {
++ my ($self, $type, $name) = @_;
++
++ if (! $name) {
++ $name = "";
++ }
++
++ foreach my $section (@{$self->{sections}}) {
++ if ($section->type eq $type and $section->name eq $name) {
++ return $section;
++ }
++ }
++
++}
++
++sub addAssignment {
++ my ($self, $name, $value) = @_;
++ $self->{assignments}{$name} = $value;
++}
++
++sub getAssignment {
++ my ($self, $name) = @_;
++ return $self->{assignments}{$name};
++}
++
++sub type {
++ my $self = shift;
++ return $self->{type};
++}
++
++sub name {
++ my $self = shift;
++ return $self->{name};
++}
++
++
++1;
+diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF.pm b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
+new file mode 100644
+index 0000000..9f44cfe
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
+@@ -0,0 +1,149 @@
++package SystemPTF;
++
++use strict;
++
++use PTF::PTFParser;
++use PTF::PTFSection;
++use PTF::SystemPTF::CPU;
++use PTF::SystemPTF::Board;
++use PTF::SystemPTF::Module;
++
++# Fields:
++
++my %module_order;
++
++sub new {
++ my $invocant = shift;
++ my $class = ref($invocant) || $invocant;
++ my $self = {
++ filename => "",
++ @_,
++ };
++
++ my $parser = PTFParser->new;
++ $self->{root} = $parser->readPTF($self->{filename});
++
++ # if the specified PTF file could not be read properly, return undef;
++ $self->{root} or return;
++
++ # if the specified PTF file is not a SYSTEM, return undef.
++ if ($self->{root}->type ne 'SYSTEM') {
++ return;
++ }
++
++ # initialize the modulemap
++ my @modules = $self->{root}->getSections ("MODULE");
++ my $index = 0;
++ foreach my $module (@modules) {
++ # if the module is not enabled then do not add
++ my $SBI = $module->getSection ('SYSTEM_BUILDER_INFO', '');
++ if ($SBI->getAssignment ('Is_Enabled') eq "1") {
++ $self->{modules}->{$module->name} = $module;
++ $module_order{$module->name} = $index;
++ $index += 1;
++ }
++ }
++
++ bless ($self, $class);
++ return $self;
++}
++
++sub getName {
++ my ($self) = @_;
++ return $self->{root}->name;
++}
++
++sub getCPUList {
++ my ($self, @classes) = @_;
++ my @cpulist = ();
++
++ foreach my $module_name (keys (%{$self->{modules}})) {
++ my $module = $self->{modules}->{$module_name};
++ my $module_class = $module->getAssignment ('class');
++ foreach my $class (@classes) {
++ if ($module_class eq $class) {
++ push @cpulist, $module->name;
++ }
++ }
++ }
++
++ return @cpulist;
++}
++
++sub getCPU {
++ my ($self, $name) = @_;
++
++ my $cpu = CPU->new (ptf => $self->{modules}->{$name});
++}
++
++sub getModule {
++ my ($self, $name) = @_;
++
++ my $module = Module->new (ptf => $self->{modules}->{$name});
++}
++
++sub getSlaveModules {
++ my ($self, $master, $type) = @_;
++
++ # create %connected set with just the master
++ # value of hash key is inconsequential
++ my %connected;
++ $connected{$master} = ( );
++
++ # create %pool set with all modules
++ # value of hash key is inconsequential
++ my %pool;
++ @pool{keys (%{$self->{modules}})} = ( );
++
++ my $dirty = 1;
++ while ($dirty) {
++ # %pool = difference (%pool, %connected)
++ delete @pool{ keys %connected };
++
++ $dirty = 0;
++
++ foreach my $name (keys %pool) {
++ my $mod = $self->getModule ($name);
++ my %mod_masters;
++ @mod_masters{ $mod->getMasters ($type) } = ( );
++
++ # if intersection (%masters, %connected) is not empty
++ delete @mod_masters{
++ grep ( ! exists $connected{ $_ },
++ keys %mod_masters) };
++
++ if (scalar(keys(%mod_masters)) > 0) {
++ $connected{$name} = ( );
++ $dirty = 1;
++ }
++ }
++ }
++
++ delete $connected{$master};
++
++ return sort module_comparison keys (%connected);
++}
++
++sub getClockFreq () {
++ my ($self) = @_;
++
++ my $wsa = $self->{root}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
++ $wsa or return;
++
++ my $result = $wsa->getAssignment ('clock_freq');
++ return $result;
++}
++
++# This is not really a class method... more of a helper function really...
++sub module_comparison {
++ if ($module_order{$a} > $module_order{$b}) {
++ return 1;
++ } elsif ($module_order{$a} < $module_order{$b}) {
++ return -1;
++ } else {
++ return 0;
++ }
++}
++
++
++1;
+diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
+new file mode 100644
+index 0000000..fe2bbc8
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
+@@ -0,0 +1,2 @@
++1;
++
+diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
+new file mode 100644
+index 0000000..ea10598
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
+@@ -0,0 +1,89 @@
++package CPU;
++
++use PTF::PTFSection;
++
++sub new {
++ my $invocant = shift;
++ my $class = ref($invocant) || $invocant;
++ my $self = {
++ @_,
++ };
++
++ # if no ptf section was passed in, then return undef
++ $self->{ptf} or return;
++
++ bless ($self, $class);
++ return $self;
++}
++
++sub getClass {
++ my ($self) = @_;
++
++ return $self->{ptf}->getAssignment ('class');
++}
++
++sub getVersion {
++ my ($self) = @_;
++
++ return $self->{ptf}->getAssignment ('class_version');
++}
++
++sub getConstant {
++ my ($self, $name) = @_;
++
++ # get WSA
++ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
++ $wsa or return;
++
++ # get constants section
++ $constants = $wsa->getSection('CONSTANTS', '');
++ $constants or return;
++
++ # get section for specific constant
++ $constant = $constants->getSection ('CONSTANT', $name);
++ $constant or return;
++
++ # get value of constant
++ $value = $constant->getAssignment ('value');
++ return $value;
++}
++
++sub getWSAAssignment {
++ my ($self, $name) = @_;
++
++ # get WSA
++ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
++ $wsa or return;
++
++ # get value of WSA Assignment
++ $value = $wsa->getAssignment ($name);
++ return $value;
++}
++
++sub getResetLocationOffset {
++ my ($self) = @_;
++
++ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
++ $wsa or return;
++
++ my $location = $wsa->getAssignment ('reset_slave');
++ my $offset = $wsa->getAssignment ('reset_offset');
++
++ return ($location, $offset);
++}
++
++sub isEnabled {
++ my ($self) = @_;
++
++ $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
++ $sbi or return;
++
++ my $enabled = $sbi->getAssignment ('Is_Enabled');
++ if ($enabled eq "1") {
++ return 1;
++ } else {
++ return 0;
++ }
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
+new file mode 100644
+index 0000000..48d246b
+--- /dev/null
++++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
+@@ -0,0 +1,267 @@
++package Module;
++
++use PTF::PTFSection;
++
++sub new {
++ my $invocant = shift;
++ my $class = ref($invocant) || $invocant;
++ my $self = {
++ @_,
++ };
++
++ # if no ptf section was passed in, then return undef
++ $self->{ptf} or return;
++
++ bless ($self, $class);
++ return $self;
++}
++
++sub getClass {
++ my ($self) = @_;
++
++ return $self->{ptf}->getAssignment ('class');
++}
++
++sub getPorts {
++ my ($self) = @_;
++
++ my @port_names;
++
++ my @ports = $self->{ptf}->getSections ('SLAVE');
++ foreach $port (@ports) {
++ push @port_names, $port->name;
++ }
++
++ return @port_names;
++}
++
++sub getPort {
++ my ($self, $port_name) = @_;
++
++ my $port;
++
++ if (! $port_name) {
++ # use first port found
++ my @port_names = $self->getPorts ();
++ $port = $self->{ptf}->getSection ('SLAVE', $port_names[0]);
++ } else {
++ $port = $self->{ptf}->getSection ('SLAVE', $port_name);
++ if (! $port) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++ }
++
++ return $port;
++}
++
++sub getWSAAssignment {
++ my ($self, $assignment) = @_;
++
++ my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
++ if (! $WSA) {
++ # return undef if the WSA section doesn't exist.
++ return;
++ }
++
++ my $result = $WSA->getAssignment ($assignment);
++
++ return $result;
++
++}
++
++sub getWSAConstant {
++ my ($self, $name) = @_;
++
++ my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
++ if (! $WSA) {
++ # return undef if the WSA section doesn't exist.
++ return;
++ }
++
++ my $constants = $WSA->getSection ('CONSTANTS', '');
++ if (! $constants) {
++ # return undef if the CONSTANTS section doesn't exist.
++ return;
++ }
++
++ my $constant = $constants->getSection ('CONSTANT', $name);
++ if (! $constant) {
++ # return undef if the CONSTANT $name section doesn't exist.
++ return;
++ }
++
++ my $result = $constant->getAssignment ('value');
++ return $result;
++
++}
++
++sub isMemoryDevice {
++ my ($self, $port_name) = @_;
++
++ my $port = $self->getPort ($port_name);
++ if (! $port) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
++ if (! $SBI) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $result = $SBI->getAssignment('Is_Memory_Device');
++
++ return $result;
++}
++
++sub isCustomInstruction {
++ my ($self, $port_name) = @_;
++
++ my $port = $self->getPort ($port_name);
++ if (! $port) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
++ if (! $SBI) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $result = $SBI->getAssignment('Is_Custom_Instruction');
++
++ return $result;
++}
++
++sub getBaseAddress {
++ my ($self, $port_name) = @_;
++
++ my $port = $self->getPort ($port_name);
++ if (! $port) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
++ if (! $SBI) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $result = $SBI->getAssignment('Base_Address');
++ if ($result eq 'N/A') {
++ return;
++ }
++ return $result;
++}
++
++sub getSize {
++ my ($self, $port_name) = @_;
++
++ my $port = $self->getPort ($port_name);
++ $port or return; #return undef if the ptf section doesn't exist
++
++ my $SBI = $port->getSection ('SYSTEM_BUILDER_INFO', '');
++ my $data_width = $SBI->getAssignment ('Data_Width');
++ my $addr_width = $SBI->getAssignment ('Address_Width');
++
++ if ($data_width == 8) {
++ $size = 1 << $addr_width;
++ } elsif ($data_width == 16) {
++ $size = 1 << ($addr_width + 1);
++ } elsif ($data_width == 32) {
++ $size = 1 << ($addr_width + 2);
++ } elsif ($data_width == 64) {
++ $size = 1 << ($addr_width + 3);
++ } elsif ($data_width == 128) {
++ $size = 1 << ($addr_width + 4);
++ } else {
++ return;
++ }
++
++ $size_text = sprintf ("%#010x", $size);
++ return $size_text;
++}
++
++sub getIRQ {
++ my ($self, $port_name) = @_;
++
++ my $port = $self->getPort ($port_name);
++ if (! $port) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
++ if (! $SBI) {
++ # return undef if the PTF section doesn't exist
++ return;
++ }
++
++ my $result = $SBI->getAssignment('Has_IRQ');
++ if ($result ne "1") {
++ # this device has no associated IRQ
++ return;
++ }
++
++ my @irq_masters = $SBI->getSections('IRQ_MASTER');
++ return $irq_masters[0]->getAssignment('IRQ_Number');
++}
++
++sub getMasters {
++ my ($self, $type) = @_;
++ my %masters = ();
++
++ # get list of all slave for device
++ my @slaves = $self->{ptf}->getSections ('SLAVE');
++
++ # get list of masters of relevant type for all slaves
++ foreach my $slave (@slaves) {
++ # get SBI for slave
++ my $SBI = $slave->getSection ('SYSTEM_BUILDER_INFO', '');
++
++ # get list of all MASTERED_BY and IRQ_MASTER sections
++ my @mastered_bys = $SBI->getSections ('MASTERED_BY');
++ my @irq_masters = $SBI->getSections ('IRQ_MASTER');
++
++ # start adding masters to the list
++ foreach my $master (@mastered_bys, @irq_masters) {
++ my $section_name = $master->name;
++ $section_name =~ /(.*)\/(.*)/;
++ my $master_name = $1;
++ my $master_type = $2;
++
++ if (! $type) {
++ $masters{$master_name} = ();
++ } else {
++ if ($master_type eq $type) {
++ $masters{$master_name} = ();
++ }
++ }
++
++ }
++
++ }
++
++ return keys (%masters);
++}
++
++sub isEnabled {
++ my ($self) = @_;
++
++ $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
++ $sbi or return;
++
++ my $enabled = $sbi->getAssignment ('Is_Enabled');
++ if ($enabled eq "1") {
++ return 1;
++ } else {
++ return 0;
++ }
++}
++
++1;
++
+diff --git a/arch/nios2nommu/scripts/gen_nios2_system.h.pl b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
+new file mode 100644
+index 0000000..b7bcff5
+--- /dev/null
++++ b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
+@@ -0,0 +1,314 @@
++# This script generates an appropriate hardware.h file for Nios II Linux based
++# on information within the target hardware's system.ptf file. This script
++# outputs everything to stdout.
++#
++# usage:
++#
++# [SOPC Builder]$ perl gen_hardware.h.pl <target cpu> <exec location> \
++# <upload location>
++#
++
++use PTF::SystemPTF;
++use strict;
++use integer;
++
++my $target_cpu;
++my $exec_location;
++my $upload_location;
++
++if (scalar (@ARGV) != 3) {
++ print STDERR "ERROR: Invalid number of parameters.\n";
++ print ("#error Invalid number of parameters.\n");
++ exit;
++} else {
++ $target_cpu = $ARGV[0];
++ $exec_location = $ARGV[1];
++ $upload_location = $ARGV[2];
++}
++
++#
++# startup the parser.
++#
++my $system = SystemPTF->new;
++if (!$system) {
++ print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
++ print ("#error Specified file is not a SYSTEM ptf file.\n");
++ exit;
++}
++
++#
++# print header for nios2_system.h
++#
++print <<ENDOFHEADER;
++#ifndef __NIOS2_SYSTEM_H__
++#define __NIOS2_SYSTEM_H__
++
++/*
++ * This file contains hardware information about the target platform.
++ * The nios2_system.h file is being phased out and will be removed in a
++ * later release.
++ *
++ * All base addresses for non memory devices have their high bit turned on to
++ * bypass the cache.
++ *
++ * This file is automatically generated. Do not modify.
++ */
++
++ENDOFHEADER
++
++#
++# generate contents for nios2_system.h
++#
++my $result; # dummy variable
++my $cpu = $system->getCPU ($target_cpu);
++if (! $cpu) {
++ print STDERR "ERROR: $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
++ print "#error $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
++ exit 1;
++}
++
++my $exec_module = $system->getModule ($exec_location);
++if (! $exec_module) {
++ print STDERR "ERROR: $exec_location is not a valid module in the system: " . $system->getName() . ".\n";
++ print "#error $exec_location is not a valid module in system: " . $system->getName () . ".\n";
++ exit 1;
++}
++
++my $upload_module = $system->getModule ($upload_location);
++if (! $upload_module) {
++ print STDERR "ERROR: $upload_location is not a valid module in the system: " . $system->getName() . ".\n";
++ print "#error $upload_location is not a valid module in system: " . $system->getName () . ".\n";
++ exit 1;
++}
++
++my %found_classes;
++my @found_classes_order;
++
++# the SYSPTF environment variable is set by kernel build process.
++if ($ENV{SYSPTF} ne "") {
++ print "/* Input System: " . $ENV{SYSPTF} . ":" . $system->getName () . " */\n";
++} else {
++ print "/* Input System: " . $system->getName () . " */\n";
++}
++print "/* Target CPU: " . $target_cpu . " */\n";
++
++print "\n";
++
++print <<ENDOFCONSTANTS;
++/* Nios II Constants */
++#define NIOS2_STATUS_PIE_MSK 0x1
++#define NIOS2_STATUS_PIE_OFST 0
++#define NIOS2_STATUS_U_MSK 0x2
++#define NIOS2_STATUS_U_OFST 1
++ENDOFCONSTANTS
++
++print "\n";
++
++print "/*\n";
++print " * Outputting basic values from system.ptf.\n";
++print " */\n\n";
++
++#
++# Start outputing information about each module.
++#
++my @module_names = $system->getSlaveModules ($target_cpu);
++foreach my $module_name (@module_names) {
++ my $module = $system->getModule ($module_name);
++ my $module_class = $module->getClass ();
++ my @module_ports = $module->getPorts ();
++ my $mask = 0;
++ my $text_printed = 0;
++ my $output = "";
++
++ # $output .= "/* $module_name (of type $module_class) */\n";
++
++ if (! exists $found_classes{$module_class}) {
++ push @found_classes_order, $module_class;
++ }
++ push @{$found_classes{$module_class}}, $module_name;
++
++ if (! $module->isMemoryDevice () && ! $module->isCustomInstruction ()) {
++ # turn on high bit for base address
++ $mask = 0x80000000;
++ }
++
++ if (scalar (@module_ports) == 1) {
++ my $base_address;
++ my $mem_size;
++ my $mem_end;
++
++ # base address information
++ $base_address = $module->getBaseAddress ();
++ if ($base_address) {
++ $output .= sprintf ("#define na_%-50s %#010x\n",
++ ($module_name, hex ($base_address) | $mask));
++ $text_printed = 1;
++ }
++ if ($module->isMemoryDevice()) {
++ # output size and end address
++ $mem_size = $module->getSize();
++ $output .= sprintf ("#define na_%-50s %#010x\n",
++ ($module_name . "_size", hex ($mem_size)));
++ $mem_end = hex ($mem_size) + hex($base_address);
++ $output .= sprintf ("#define na_%-50s %#010x\n",
++ ($module_name . "_end", $mem_end));
++
++ $text_printed = 1;
++ }
++
++ # irq information
++ $result = $module->getIRQ ();
++ if (defined ($result)) {
++ $output .= sprintf ("#define na_%-30s %30s\n",
++ ($module_name . "_irq", $result));
++ $text_printed = 1;
++ }
++
++ } else {
++ # if device has multiple ports
++ foreach my $port_name (@module_ports) {
++ # base address information
++ $result = $module->getBaseAddress ($port_name);
++ if ($result) {
++ $output .= sprintf ("#define na_%-50s %#010x\n",
++ ($module_name . "_" . $port_name, hex ($result) | $mask));
++ $text_printed = 1;
++ }
++
++ # irq information
++ $result = $module->getIRQ ($port_name);
++ if (defined ($result)) {
++ $output .= sprintf ("#define na_%-30s %30s\n",
++ ($module_name . "_" . $port_name . "_irq", $result));
++ $text_printed = 1;
++ }
++ }
++ }
++
++ if ($text_printed == 1) {
++ # $output .= "\n";
++ print $output;
++ }
++}
++
++print "\n";
++
++#
++# Handle special cases through customized perl scripts
++#
++foreach my $class_name (@found_classes_order) {
++ my $code = "";
++
++ foreach my $dir (@INC) {
++ if (-e "$dir/nios2_system.h/$class_name.pm") {
++ print "/* Executing ...scripts/nios2_system.h/$class_name.pm */\n";
++ $code .= "require \"$dir/nios2_system.h/BasicModule.pm\";";
++ $code .= "require \"$dir/nios2_system.h/$class_name.pm\";";
++ $code .= $class_name . "::run(\$system, \@{\$found_classes{\$class_name}});";
++ eval $code;
++ if ($@) {
++ print "#warning Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
++ print "#warning Error message is stored in nios2_system.h:\n";
++ print "/*\n";
++ print "$@";
++ print "*/\n";
++ print STDERR "Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
++ print STDERR "Error message follows:\n";
++ print STDERR "$@";
++ }
++ last;
++ }
++ }
++}
++
++#
++# Write out system information
++#
++print "/*\n";
++print " * Basic System Information\n";
++print " */\n";
++
++$result = $cpu->getWSAAssignment ('cache_icache_size');
++printf ("#define %-53s %10d\n", ("nasys_icache_size", $result));
++
++$result = $cpu->getConstant ('nasys_icache_line_size');
++printf ("#define %-53s %10d\n", ("nasys_icache_line_size", $result));
++
++$result = $cpu->getWSAAssignment ('cache_dcache_size');
++printf ("#define %-53s %10d\n", ("nasys_dcache_size", $result));
++
++$result = $cpu->getConstant ('nasys_dcache_line_size');
++printf ("#define %-53s %10d\n", ("nasys_dcache_line_size", $result));
++
++print "\n";
++
++printf ("#define %-33s %30s\n",
++ ("nasys_program_mem", "na_${exec_location}"));
++printf ("#define %-33s %30s\n",
++ ("nasys_program_mem_size", "na_${exec_location}_size"));
++printf ("#define %-33s %30s\n",
++ ("nasys_program_mem_end", "na_${exec_location}_end"));
++
++print "\n";
++
++if ($upload_location eq "flash_kernel") {
++ # nothing to do
++ print ("/* Redefinition of CFI flash memory unecessary */\n");
++} else {
++ my $module = $system->getModule ("flash_kernel");
++ if ($module) {
++ # there is a conflicting module in the system, error.
++ print STDERR "Error, a SOPC module named flash_kernel already exists but is not the upload location.\n";
++ print "#error The module name \"flash_kernel\" already exists but isn't the upload location.\n";
++ print "#error This will break the kernel.\n";
++ print "#error Please rename the module to something else in SOPC Builder.\n\n";
++ exit 1;
++ } else {
++ print ("/*\n");
++ print (" * Redefining upload location ($upload_location) to flash_kernel.\n");
++ print (" */\n\n");
++ # undefine the original module names and re-define them here.
++ print ("#undef na_${upload_location}\n");
++ print ("#undef na_${upload_location}_size\n");
++ print ("#undef na_${upload_location}_end\n");
++
++ my $base_address = $upload_module->getBaseAddress ();
++ printf ("#define %-33s %30s\n",
++ ("na_flash_kernel", $base_address));
++
++ my $mem_size = $upload_module->getSize();
++ printf ("#define %-33s %30s\n",
++ ("na_flash_kernel_size", $mem_size));
++
++ my $mem_end = hex ($base_address) + hex ($mem_size);
++ printf ("#define %-53s %#010x\n",
++ ("na_flash_kernel_end", $mem_end));
++ }
++}
++
++print "\n";
++
++printf ("#define %-33s %30s\n",
++ ("nasys_clock_freq", $system->getClockFreq()));
++printf ("#define %-33s %30s\n",
++ ("nasys_clock_freq_1000", int ($system->getClockFreq()) / 1000));
++
++{
++ my ($reset_location, $reset_offset) = $cpu->getResetLocationOffset();
++ my ($reset_module_name, $reset_port_name) = ($reset_location =~ /(.*)\/(.*)/);
++ my $reset_module = $system->getModule ($reset_module_name);
++ my $reset_address = $reset_module->getBaseAddress ($reset_port_name);
++
++ $reset_address = hex ($reset_address) + hex ($reset_offset);
++ printf ("#define %-53s %#010x\n",
++ ("CPU_RESET_ADDRESS", $reset_address));
++}
++
++print "\n";
++
++#
++# print footer for nios2_system.h
++#
++print <<ENDOFFOOTER;
++#endif /* __NIOS2_SYSTEM_H__ */
++ENDOFFOOTER
+diff --git a/arch/nios2nommu/scripts/hwselect.pl b/arch/nios2nommu/scripts/hwselect.pl
+new file mode 100644
+index 0000000..8181bee
+--- /dev/null
++++ b/arch/nios2nommu/scripts/hwselect.pl
+@@ -0,0 +1,166 @@
++# This script generates arch/nios2nommu/hardware.mk based on user input
++
++# usage:
++#
++# [SOPC Builder]$ perl hwselect.pl <ptf file path> <target file path>
++#
++
++use PTF::SystemPTF;
++use strict;
++use integer;
++
++my $ptf_filename;
++my $target_filename;
++my $index;
++my $system;
++
++#
++# Subroutine: Prompt user for an answer
++#
++
++sub request_answer {
++ my ($min, $max) = @_;
++ my $answer;
++
++ do {
++ print "Selection: ";
++ $answer = <STDIN>;
++ if (! ($answer >= $min && $answer <= $max)) {
++ print "Invalid response, please try again.\n";
++ }
++ } until $answer >= $min && $answer <= $max;
++
++ return $answer;
++}
++
++#
++# Check for correct number of args
++#
++
++if (scalar (@ARGV) != 2) {
++ print STDERR "ERROR: Invalid number of parameters.\n";
++ exit;
++} else {
++ $ptf_filename = $ARGV[0];
++ $target_filename = $ARGV[1];
++}
++
++#
++# Check to see if the specified file exists
++#
++
++if (! -e $ptf_filename) {
++ print STDERR "ERROR: Could not open SYSTEM ptf file.\n";
++ exit;
++}
++
++#
++# startup the parser.
++#
++$system = SystemPTF->new (filename => $ptf_filename);
++if (!$system) {
++ print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
++ exit;
++}
++
++#
++# Grab listing of Nios II processors and force user to select one:
++#
++
++print "\n--- Please select which CPU you wish to build the kernel against:\n\n";
++
++my @cpulist = $system->getCPUList ('altera_nios2');
++my %cpuinfo;
++
++$index = 1;
++foreach my $cpu (@cpulist) {
++ my $cpu_module = $system->getCPU ($cpu);
++ if ($cpu_module->isEnabled ()) {
++ my $class = $cpu_module->getClass();
++ my $type = $cpu_module->getWSAAssignment('cpu_selection');
++ my $version = $cpu_module->getVersion();
++
++ print "($index) $cpu - Class: $class Type: $type Version: $version\n";
++ }
++ $index += 1;
++}
++
++print "\n";
++
++my $cpu_selection = $cpulist[request_answer (1, $index - 1) - 1];
++
++#
++# Grab list of memory devices that $cpu_selection is hooked up to:
++#
++my @modulelist = $system->getSlaveModules ($cpu_selection);
++my %cfiinfo;
++my %meminfo;
++foreach my $module_name (@modulelist) {
++ my $module = $system->getModule ($module_name);
++ my $class = $module->getClass ();
++
++ if ($module->isEnabled ()) {
++ if ($class eq 'altera_avalon_cfi_flash') {
++ $cfiinfo{$module_name}{class} = $class;
++ $cfiinfo{$module_name}{size} = $module->getSize();
++ }
++
++ if ($module->isMemoryDevice()) {
++ $meminfo{$module_name}{class} = $class;
++ $meminfo{$module_name}{size} = $module->getSize();
++ }
++ }
++}
++
++#
++# Select an upload device:
++#
++print "\n--- Please select a device to upload the kernel to:\n\n";
++
++$index = 1;
++foreach my $name (keys (%cfiinfo)) {
++ my $size = hex ($cfiinfo{$name}{size});
++ print "($index) $name\n\tClass: $cfiinfo{$name}{class}\n\tSize: $size bytes\n\n";
++ $index += 1;
++}
++
++my @cfilist = keys (%cfiinfo);
++my $cfi_selected = $cfilist[request_answer (1, $index - 1) - 1];
++
++delete $meminfo{$cfi_selected};
++
++#
++# Select program memory to execute kernel from:
++#
++print "\n--- Please select a device to execute kernel from:\n\n";
++
++$index = 1;
++foreach my $name (keys (%meminfo)) {
++ my $size = hex ($meminfo{$name}{size});
++ print "($index) $name\n\tClass: $meminfo{$name}{class}\n\tSize: $size bytes\n\n";
++ $index += 1;
++}
++
++my @memlist = keys (%meminfo);
++my $mem_selected = $memlist[request_answer (1, $index - 1) - 1];
++
++print "\n--- Summary using\n\n";
++print "PTF: $ptf_filename\n";
++print "CPU: $cpu_selection\n";
++print "Device to upload to: $cfi_selected\n";
++print "Program memory to execute from: $mem_selected\n";
++
++#
++# Write settings out to Makefile fragment
++#
++open (HWMK, ">$target_filename") ||
++ die "Could not write to $target_filename";
++
++print HWMK "SYSPTF = $ptf_filename\n";
++print HWMK "CPU = $cpu_selection\n";
++print HWMK "UPLMEM = $cfi_selected\n";
++print HWMK "EXEMEM = $mem_selected\n";
++
++close (HWMK);
++
++print "\n--- Settings written to $target_filename\n\n";
+\ No newline at end of file
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
+new file mode 100644
+index 0000000..e15c26b
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
+@@ -0,0 +1,267 @@
++package BasicModule;
++
++require PTF::SystemPTF;
++require PTF::SystemPTF::Module;
++use strict;
++
++# Description: Prints an error message to stdout. This should prefix each line
++# with "#error " so that it can be properly read by the C
++# pre-processor.
++# Args: $module_name: name of module that was is required by driver
++# $class_name: name of device class that module belongs to.
++sub print_error_name_used {
++ my ($class, $module_name, $class_name) = @_;
++
++ print "#error The kernel requires that the $class->required_class_name device be named as $module_name.\n";
++ print "#error The current hardware has $module_name defined as a(n) $class_name device.\n";
++ print "#error This will cause the kernel to fail.\n";
++ print "#error Please rename the current $module_name device to something else in SOPC Builder.\n";
++}
++
++# Description: This casts the base address to a specific data type
++# By default, it does not cast the base address to
++# anything.
++sub base_address_cast {
++ my ($class, $port_name) = @_;
++ return;
++}
++
++# Description: This sub-routine prints out a prefix that is shown only once
++# before any translations take place.
++sub print_prefix {
++ my ($class, $system) = @_;
++ printf ("\n");
++}
++
++# Description: Prints a set of lines to stdout that re-defines all symbols
++# related to $module_name to the symbols required by the driver.
++# Typically starts off with "#undefine ..." statements followed
++# by one or more "#define statements".
++# Args: $required_module_name: the module name that's expected by the kernel.
++# $module_name: the name of the module that was found in the PTF file.
++sub translate {
++ my ($class, $system, $required_module_name, $module_name) = @_;
++
++ # get the necessary info about the module
++ my $module = $system->getModule ($module_name);
++ my @port_names = $module->getPorts ();
++
++ my $boolean_base_address_cast = 0;
++ if (scalar (@port_names) > 1) {
++ foreach my $port_name (@port_names) {
++ my $cast = $class->base_address_cast ($port_name);
++ if (defined ($cast)) {
++ $boolean_base_address_cast = 1;
++ last;
++ }
++ }
++ } else {
++ my $cast = $class->base_address_cast;
++ if (defined ($cast)) {
++ $boolean_base_address_cast = 1;
++ }
++ }
++
++ if ($module_name eq $required_module_name &&
++ !$boolean_base_address_cast) {
++ printf ("/* No translation necessary for $module_name */\n\n");
++ return;
++ }
++
++ # undefine the original entries
++ print "/* Redefining $module_name -> $required_module_name */\n";
++ if (scalar (@port_names) == 1) {
++ my $irq = $module->getIRQ ();
++ print "#undef na_" . $module_name . "\n";
++ if (defined ($irq)) {
++ print "#undef na_" . $module_name . "_irq\n";
++ }
++ print "\n";
++ } else {
++ foreach my $port_name (@port_names) {
++ print "#undef na_" . $module_name . "_" .
++ $port_name . "\n";
++ my $irq = $module->getIRQ ($port_name);
++ if (defined ($irq)) {
++ print "#undef na_" . $module_name . "_" .
++ $port_name . "_irq\n";
++ }
++ print "\n";
++ }
++ }
++
++ if (scalar (@port_names) == 1) {
++ # set up a string to pass to printf that will output the correct
++ # #define base address statement.
++
++ # turn on the high bit for the base address to bypass cache.
++ my $base_address = $module->getBaseAddress ();
++ $base_address = hex ($base_address) | 0x80000000;
++
++ my $cast = $class->base_address_cast;
++ $class->print_define_line ($required_module_name,
++ undef, "addr", $cast, $base_address);
++
++ # print out an IRQ define statement if necessary
++ my $irq = $module->getIRQ ();
++ if (defined ($irq)) {
++ $class->print_define_line ($required_module_name,
++ undef, "irq", undef, $irq);
++ }
++ printf ("\n");
++ } else {
++ foreach my $port_name (@port_names) {
++ my $cast = $class->base_address_cast ($port_name);
++ my $base_address = $module->getBaseAddress ($port_name);
++ $base_address = hex ($base_address) | 0x80000000;
++ $class->print_define_line ($required_module_name,
++ $port_name, "addr", $cast, $base_address);
++
++ my $irq = $module->getIRQ ($port_name);
++ if (defined ($irq)) {
++ $class->print_define_line (
++ $required_module_name, $port_name,
++ "irq", undef, $irq);
++ }
++
++ print "\n";
++ }
++ }
++}
++
++# Description: The following sub-routine prints out "undef" or "define"
++# statements based on the arguments received.
++# Args: $name: "define" or "undef"
++# $port: name of port (if applicable)
++# $type: "addr" or "irq"
++# $cast: data type to cast base address to (if applicable)
++# $value: value of symbol to be defined (if applicable)
++sub print_define_line {
++ my ($class, $name, $port, $type, $cast, $value) = @_;
++
++ # construct the symbol that is being used
++ my $symbol .= "na_";
++ $symbol .= $name;
++
++ $symbol .= defined ($port) ? "_" . $port : "";
++ $symbol .= $type eq "irq" ? "_irq" : "";
++
++ my $string_value;
++ if ($type eq "addr") {
++ $string_value = sprintf ("%#010x", $value);
++ if (defined $cast) {
++ $string_value = "(($cast*) $string_value)";
++ }
++ } else {
++ $string_value = $value;
++ }
++ printf ("%-41s %30s\n", "#define $symbol", $string_value);
++}
++
++# Description: This sub-routine prints out a prefix that is shown only once
++# after any translations take place.
++sub print_suffix {
++ my ($class, $system) = @_;
++ # intentionally left empty
++}
++
++# Description: The following function allows the class to further determine if
++# the module is valid. For instance, the timer class requires
++# that the selected module does not have a fixed period.
++# This function returns true by default which basically means
++# that all modules belonging to class are valid.
++sub is_module_valid {
++ my ($class, $system, $module_name) = @_;
++ return 1;
++}
++
++# Description: This sub-routine is required. It is executed by the
++# "../gen_nios2_system_h.pl" script whenever any devices of type
++# $class->required_class_name are found in the PTF file.
++#
++# It looks for any conflicting module names first. If any are
++# found, "print_error_name_used" is called and this perl module
++# exits.
++#
++# It then goes through the list of module names found in the PTF
++# file that are of type $class->required_class_name and maps them to the
++# list of unused names in $class->required_module_names.
++#
++# Finally, it will call the "translate" sub-routine to output the
++# symbols required by the driver.
++# Args: $system: a variable containing a reference to the system.ptf file that
++# provides full access to any information in the file.
++# @found_module_names: a list of module names that are of type
++# $class->required_class_name
++sub run2 {
++ my ($class, $system, @found_module_names) = @_;
++
++ # initialize a mapping of required module names to actual module names
++ my %module_map;
++ foreach my $module_name ($class->required_module_names) {
++ $module_map{$module_name} = "";
++ }
++
++ # if the required module name is already in use in the PTF file for a
++ # different device class, flag it as an error.
++ my $error_found = 0;
++ foreach my $module_name ($class->required_module_names) {
++ my $module = $system->getModule ($module_name);
++
++ if (!defined ($module)) {
++ next;
++ }
++
++ my $class_name = $module->getClass ();
++ if ($class_name ne $class->required_class_name) {
++ $class->print_error_name_used ($class, $module_name, $class_name);
++ $error_found = 1;
++ }
++ }
++
++ # if errors were found, then there's no point in continuing.
++ if ($error_found == 1) {
++ return;
++ }
++
++ # Run through list of modules that belong to the class and start
++ # mapping each module name to the first unused required module name
++ # as defined above
++ FOUND_MOD_LOOP: foreach my $module_name (@found_module_names) {
++
++ # If the module name has already been used, then continue
++ # to the next one.
++ foreach my $required_module_name ($class->required_module_names) {
++ if ($module_map{$required_module_name} eq $module_name) {
++ next FOUND_MOD_LOOP;
++ }
++ }
++
++ # assertion: $module_name is not mapped yet.
++ foreach my $required_module_name ($class->required_module_names) {
++ if ($module_map{$required_module_name} ne "") {
++ next;
++ }
++
++ if ($class->is_module_valid ($system, $module_name)) {
++ $module_map{$required_module_name} = $module_name;
++ }
++ last;
++ }
++ }
++
++ $class->print_prefix ($system);
++
++ # Now that everything's been mapped (or as close as we're going to get
++ # to it being mapped), start printing out the literal translation.
++ foreach my $required_module_name ($class->required_module_names) {
++ my $module_name = $module_map{$required_module_name};
++ if (length ($module_name) > 0) {
++ $class->translate ($system, $required_module_name, $module_name);
++ }
++ }
++
++ $class->print_suffix ($system);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
+new file mode 100644
+index 0000000..dada452
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
+@@ -0,0 +1,18 @@
++package altera_avalon_cf;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "ide"
++}
++
++sub required_class_name {
++ "altera_avalon_cf"
++}
++
++sub run {
++ altera_avalon_cf->run2(@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
+new file mode 100644
+index 0000000..22bb9c9
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
+@@ -0,0 +1,18 @@
++package altera_avalon_jtag_uart;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ ("jtag_uart")
++}
++
++sub required_class_name {
++ "altera_avalon_jtag_uart";
++}
++
++sub run {
++ altera_avalon_jtag_uart->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
+new file mode 100644
+index 0000000..5a29b7e
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
+@@ -0,0 +1,38 @@
++package altera_avalon_lan91c111;
++
++require PTF::SystemPTF;
++require PTF::SystemPTF::Module;
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "enet"
++}
++
++sub required_class_name {
++ "altera_avalon_lan91c111"
++}
++
++sub translate {
++ my $class = shift;
++ my ($system, $required_module_name, $module_name) = @_;
++ $class->SUPER::translate (@_);
++
++ my $module = $system->getModule ($module_name);
++
++ my $offset_keyword = "LAN91C111_REGISTERS_OFFSET";
++ my $offset = $module->getWSAConstant ($offset_keyword);
++ printf ("%-41s %30s\n", "#define $offset_keyword", $offset);
++
++ my $width_keyword = "LAN91C111_DATA_BUS_WIDTH";
++ my $width = $module->getWSAConstant ($width_keyword);
++ printf ("%-41s %30s\n", "#define $width_keyword", $width);
++
++ print "\n";
++}
++
++sub run {
++ altera_avalon_lan91c111->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
+new file mode 100644
+index 0000000..afdbcae
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
+@@ -0,0 +1,46 @@
++package altera_avalon_pio;
++
++require PTF::SystemPTF;
++require PTF::SystemPTF::Module;
++use strict;
++
++sub run {
++ my ($system, @pio_names) = @_;
++
++ print "#ifndef __ASSEMBLY__\n";
++ print "#include <asm/pio_struct.h>\n";
++ print "#endif\n\n";
++
++ foreach my $pio_name (@pio_names) {
++ my $module = $system->getModule ($pio_name);
++
++ # get all the relevant information
++ my $base_address = $module->getBaseAddress ();
++ $base_address = hex ($base_address) | 0x80000000;
++ my $irq = $module->getIRQ ();
++
++ print "/* Casting base addresses to the appropriate structure */\n";
++
++ # undefine all the old symbols first
++ print "#undef na_${pio_name}\n";
++ if (defined ($irq)) {
++ print "#undef na_${pio_name}_irq\n";
++ print "\n";
++ }
++
++ # define base address
++ $base_address = sprintf ("%#010x", $base_address);
++ printf ("%-41s %30s\n", "#define na_${pio_name}",
++ "((np_pio*) ${base_address})");
++
++ # define irq
++ if (defined ($irq)) {
++ printf ("%-41s %30s\n", "#define na_${pio_name}_irq",
++ $irq);
++ }
++
++ print "\n";
++ }
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
+new file mode 100644
+index 0000000..719a22c
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
+@@ -0,0 +1,30 @@
++package altera_avalon_spi;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "spi"
++}
++
++sub required_class_name {
++ "altera_avalon_spi"
++}
++
++sub base_address_cast {
++ "np_spi"
++}
++
++sub print_prefix {
++ my ($class, $system) = @_;
++
++ print "#ifndef __ASSEMBLY__\n";
++ print "#include <asm/spi_struct.h>\n";
++ print "#endif\n\n";
++}
++
++sub run {
++ altera_avalon_spi->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
+new file mode 100644
+index 0000000..deb9826
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
+@@ -0,0 +1,18 @@
++package altera_avalon_sysid;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_class_name {
++ "altera_avalon_sysid"
++}
++
++sub required_module_names {
++ "sysid"
++}
++
++sub run {
++ altera_avalon_sysid->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
+new file mode 100644
+index 0000000..495ccdc
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
+@@ -0,0 +1,46 @@
++package altera_avalon_timer;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_class_name {
++ "altera_avalon_timer";
++}
++
++sub required_module_names {
++ "timer0"
++}
++
++sub print_prefix {
++ my ($class, $system) = @_;
++
++ print "\n";
++ print "#ifndef __ASSEMBLY__\n";
++ print "#include <asm/timer_struct.h>\n";
++ print "#endif\n";
++ print "\n";
++}
++
++sub base_address_cast {
++ "np_timer"
++}
++
++# only timers with a non-fixed-period are valid
++sub is_module_valid {
++ my ($class, $system, $module_name) = @_;
++
++ my $module = $system->getModule ($module_name);
++ my $fixed_period = $module->getWSAAssignment ('fixed_period');
++
++ if ($fixed_period eq '0') {
++ return 1;
++ } else {
++ return 0;
++ }
++}
++
++sub run {
++ altera_avalon_timer->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
+new file mode 100644
+index 0000000..abf48d7
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
+@@ -0,0 +1,44 @@
++package altera_avalon_uart;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ ("uart0", "uart1", "uart2", "uart3")
++}
++
++sub required_class_name {
++ "altera_avalon_uart";
++}
++
++sub base_address_cast {
++ "np_uart"
++}
++
++sub print_prefix {
++ my ($class, $system) = @_;
++
++ print "#ifndef __ASSEMBLY__\n";
++ print "#include <asm/uart_struct.h>\n";
++ print "#endif\n\n";
++}
++
++sub translate {
++ my $class = shift;
++ my ($system, $required_module_name, $module_name) = @_;
++
++ $class->SUPER::translate (@_);
++
++ if (!defined ($altera_avalon_uart::default_uart)) {
++ print "/* The default uart is always the first one found in the PTF file */\n";
++ print "#define nasys_printf_uart na_$required_module_name\n\n";
++ $altera_avalon_uart::default_uart = $required_module_name;
++ }
++
++}
++
++sub run {
++ altera_avalon_uart->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
+new file mode 100644
+index 0000000..fdd727b
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
+@@ -0,0 +1,18 @@
++package mtip_avalon_10_100_mac;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_class_name {
++ "mtip_avalon_10_100_mac";
++}
++
++sub required_module_names {
++ "mtip_mac"
++}
++
++sub run {
++ mtip_avalon_10_100_mac->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
+new file mode 100644
+index 0000000..5985c2f
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
+@@ -0,0 +1,18 @@
++package mtx_avalon_dm9000;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "dm9000"
++}
++
++sub required_class_name {
++ "mtx_avalon_dm9000"
++}
++
++sub run {
++ mtx_avalon_dm9000->run2(@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
+new file mode 100644
+index 0000000..e70ffa3
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
+@@ -0,0 +1,18 @@
++package mtx_avalon_isp1161a1;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "usb"
++}
++
++sub required_class_name {
++ "mtx_avalon_isp1161a1";
++}
++
++sub run {
++ mtx_avalon_isp1161a1->run2(@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
+new file mode 100644
+index 0000000..7b580b5
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
+@@ -0,0 +1,18 @@
++package opencores_ethernet_mac;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ "igor_mac"
++}
++
++sub required_class_name {
++ "opencores_ethernet_mac"
++}
++
++sub run {
++ opencores_ethernet_mac->run2 (@_);
++}
++
++1;
+diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
+new file mode 100644
+index 0000000..512d12c
+--- /dev/null
++++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
+@@ -0,0 +1,18 @@
++package opencores_i2c;
++
++use base qw(BasicModule);
++use strict;
++
++sub required_module_names {
++ ("i2c_0", "i2c_1")
++}
++
++sub required_class_name {
++ "opencores_i2c";
++}
++
++sub run {
++ opencores_i2c->run2 (@_);
++}
++
++1;
+diff --git a/include/asm-nios2nommu/ChangeLog b/include/asm-nios2nommu/ChangeLog
+new file mode 100644
+index 0000000..94aaa27
+--- /dev/null
++++ b/include/asm-nios2nommu/ChangeLog
+@@ -0,0 +1,14 @@
++2004-06-29 Ken Hill <khill@microtronix.com>
++
++ * bitops.h (find_next_zero_bit): Fix problem with with masking for found_first
++ handling. The masking of the upper bits for size < 32 bits would set all
++ the bits to 1. Removing any zero's there may have been.
++
++2004-06-02 Ken Hill <khill@microtronix.com>
++
++ * processor.h (TASK_SIZE): Change na_sdram_end to nasys_program_mem_end to remove
++ dependancy on quartus memory component name.
++
++ * page.h (PAGE_OFFSET): Change na_sdram to nasys_program_mem to remove
++ dependancy on quartus memory component name.
++
+diff --git a/include/asm-nios2nommu/Kbuild b/include/asm-nios2nommu/Kbuild
+new file mode 100644
+index 0000000..abf0368
+--- /dev/null
++++ b/include/asm-nios2nommu/Kbuild
+@@ -0,0 +1,4 @@
++include include/asm-generic/Kbuild.asm
++
++header-y += traps.h
++header-y += io.h
+diff --git a/include/asm-nios2nommu/a.out.h b/include/asm-nios2nommu/a.out.h
+new file mode 100644
+index 0000000..8297687
+--- /dev/null
++++ b/include/asm-nios2nommu/a.out.h
+@@ -0,0 +1,85 @@
++/* $Id: a.out.h,v 1.1 2006/07/05 06:20:25 gerg Exp $ */
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2NOMMU_A_OUT_H__
++#define __NIOS2NOMMU_A_OUT_H__
++
++#define SPARC_PGSIZE 0x1000 /* Thanks to the sun4 architecture... */
++#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
++
++struct exec {
++ unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
++ unsigned char a_toolversion:7;
++ unsigned char a_machtype;
++ unsigned short a_info;
++ unsigned long a_text; /* length of text, in bytes */
++ unsigned long a_data; /* length of data, in bytes */
++ unsigned long a_bss; /* length of bss, in bytes */
++ unsigned long a_syms; /* length of symbol table, in bytes */
++ unsigned long a_entry; /* where program begins */
++ unsigned long a_trsize;
++ unsigned long a_drsize;
++};
++
++#define INIT_EXEC { \
++ .a_dynamic = 0, \
++ .a_toolversion = 0, \
++ .a_machtype = 0, \
++ .a_info = 0, \
++ .a_text = 0, \
++ .a_data = 0, \
++ .a_bss = 0, \
++ .a_syms = 0, \
++ .a_entry = 0, \
++ .a_trsize = 0, \
++ .a_drsize = 0, \
++}
++
++/* Where in the file does the text information begin? */
++#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
++
++/* Where do the Symbols start? */
++#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
++ (x).a_data + (x).a_trsize + \
++ (x).a_drsize)
++
++/* Where does text segment go in memory after being loaded? */
++#define N_TXTADDR(x) (((N_MAGIC(x) == ZMAGIC) && \
++ ((x).a_entry < SPARC_PGSIZE)) ? \
++ 0 : SPARC_PGSIZE)
++
++/* And same for the data segment.. */
++#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
++ (N_TXTADDR(x) + (x).a_text) \
++ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
++
++#define N_TRSIZE(a) ((a).a_trsize)
++#define N_DRSIZE(a) ((a).a_drsize)
++#define N_SYMSIZE(a) ((a).a_syms)
++
++#ifdef __KERNEL__
++
++#define STACK_TOP TASK_SIZE
++
++#endif
++
++#endif /* __NIOS2NOMMU_A_OUT_H__ */
+diff --git a/include/asm-nios2nommu/altera_juart.h b/include/asm-nios2nommu/altera_juart.h
+new file mode 100644
+index 0000000..da6320d
+--- /dev/null
++++ b/include/asm-nios2nommu/altera_juart.h
+@@ -0,0 +1,36 @@
++/*------------------------------------------------------------------------
++ *
++ * linux/drivers/serial/altera_juart.h
++ *
++ * Driver for Altera JTAG UART core with Avalon interface
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * History:
++ * Jun/20/2005 DGT Microtronix Datacom NiosII
++ *
++ -----------------------------------------------------------------------*/
++
++#ifndef _ALTERA_JUART_H_
++ #define _ALTERA_JUART_H_
++
++ /* jtag uart details needed outside of the driver itself: */
++ /* by: arch/kernel/start.c - boot time error message(s) */
++
++ void jtaguart_console_write
++ ( struct console *co,
++ const char *s,
++ unsigned int count);
++
++#endif /* _ALTERA_JUART_H_ */
+diff --git a/include/asm-nios2nommu/asm-macros.h b/include/asm-nios2nommu/asm-macros.h
+new file mode 100644
+index 0000000..9dda7cd
+--- /dev/null
++++ b/include/asm-nios2nommu/asm-macros.h
+@@ -0,0 +1,331 @@
++/*
++ * Macro used to simplify coding multi-line assembler.
++ * Some of the bit test macro can simplify down to one line
++ * depending on the mask value.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++/*
++ * ANDs reg2 with mask and places the result in reg1.
++ *
++ * You cannnot use the same register for reg1 & reg2.
++ */
++
++.macro ANDI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ movhi \reg1,%hi(\mask)
++ movui \reg1,%lo(\mask)
++ and \reg1,\reg1,\reg2
++ .else
++ andi \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ andhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * ORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro ORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ orhi \reg1,\reg2,%hi(\mask)
++ ori \reg1,\reg2,%lo(\mask)
++ .else
++ ori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ orhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * XORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro XORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ xorhi \reg1,\reg2,%hi(\mask)
++ xori \reg1,\reg1,%lo(\mask)
++ .else
++ xori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ xorhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * This is a support macro for BTBZ & BTBNZ. It checks
++ * the bit to make sure it is valid 32 value.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BT reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is non-zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBNZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTC reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ xori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ xorhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTS reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ ori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ orhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTR reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ andi \reg2,\reg2,%lo(~(1 << \bit))
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ andhi \reg2,\reg2,%lo(~(1 << (\bit - 16)))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBNZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBNZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBNZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the all the bits in the mask are zero it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the any of the bits in the mask are 1 it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBNZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Pushes reg onto the stack.
++ */
++
++.macro PUSH reg
++ addi sp,sp,-4
++ stw \reg,0(sp)
++.endm
++
++/*
++ * Pops the top of the stack into reg.
++ */
++
++.macro POP reg
++ ldw \reg,0(sp)
++ addi sp,sp,4
++.endm
++
++/*
++ * Clears reg
++ */
++
++.macro CLR reg
++ mov \reg,r0
++.endm
++
++/*
++ * The preprocessor macro does not work for
++ * the nios2 compiler. Undefine ENTRY and define
++ * a real assembler macro.
++ */
++#undef ENTRY
++#define ENTRY(name) ASM_ENTRY name
++
++.macro ASM_ENTRY name
++.globl \name
++__ALIGN
++ \name:
++.endm
+diff --git a/include/asm-nios2nommu/atomic.h b/include/asm-nios2nommu/atomic.h
+new file mode 100644
+index 0000000..fb627de
+--- /dev/null
++++ b/include/asm-nios2nommu/atomic.h
+@@ -0,0 +1,146 @@
++#ifndef __ASM_SH_ATOMIC_H
++#define __ASM_SH_ATOMIC_H
++
++/*
++ * Atomic operations that C can't guarantee us. Useful for
++ * resource counting etc..
++ *
++ */
++
++typedef struct { volatile int counter; } atomic_t;
++
++#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
++
++#define atomic_read(v) ((v)->counter)
++#define atomic_set(v,i) ((v)->counter = (i))
++
++#include <asm/system.h>
++
++/*
++ * To get proper branch prediction for the main line, we must branch
++ * forward to code at the end of this object's .text section, then
++ * branch back to restart the operation.
++ */
++
++static __inline__ void atomic_add(int i, atomic_t * v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ *(long *)v += i;
++ local_irq_restore(flags);
++}
++
++static __inline__ void atomic_sub(int i, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ *(long *)v -= i;
++ local_irq_restore(flags);
++}
++
++static __inline__ int atomic_add_return(int i, atomic_t * v)
++{
++ unsigned long temp, flags;
++
++ local_irq_save(flags);
++ temp = *(long *)v;
++ temp += i;
++ *(long *)v = temp;
++ local_irq_restore(flags);
++
++ return temp;
++}
++
++#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
++
++static __inline__ int atomic_sub_return(int i, atomic_t * v)
++{
++ unsigned long temp, flags;
++
++ local_irq_save(flags);
++ temp = *(long *)v;
++ temp -= i;
++ *(long *)v = temp;
++ local_irq_restore(flags);
++
++ return temp;
++}
++
++#define atomic_dec_return(v) atomic_sub_return(1,(v))
++#define atomic_inc_return(v) atomic_add_return(1,(v))
++
++/*
++ * atomic_inc_and_test - increment and test
++ * @v: pointer of type atomic_t
++ *
++ * Atomically increments @v by 1
++ * and returns true if the result is zero, or false for all
++ * other cases.
++ */
++#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
++
++#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
++#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
++
++#define atomic_inc(v) atomic_add(1,(v))
++#define atomic_dec(v) atomic_sub(1,(v))
++
++static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
++{
++ int ret;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ ret = v->counter;
++ if (likely(ret == old))
++ v->counter = new;
++ local_irq_restore(flags);
++
++ return ret;
++}
++
++#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
++
++static inline int atomic_add_unless(atomic_t *v, int a, int u)
++{
++ int ret;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ ret = v->counter;
++ if (ret != u)
++ v->counter += a;
++ local_irq_restore(flags);
++
++ return ret != u;
++}
++#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
++
++static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ *(long *)v &= ~mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ *(long *)v |= mask;
++ local_irq_restore(flags);
++}
++
++/* Atomic operations are already serializing on SH */
++#define smp_mb__before_atomic_dec() barrier()
++#define smp_mb__after_atomic_dec() barrier()
++#define smp_mb__before_atomic_inc() barrier()
++#define smp_mb__after_atomic_inc() barrier()
++
++#include <asm-generic/atomic.h>
++#endif /* __ASM_SH_ATOMIC_H */
+diff --git a/include/asm-nios2nommu/auxvec.h b/include/asm-nios2nommu/auxvec.h
+new file mode 100644
+index 0000000..fc21e4d
+--- /dev/null
++++ b/include/asm-nios2nommu/auxvec.h
+@@ -0,0 +1,4 @@
++#ifndef __ASM_SH_AUXVEC_H
++#define __ASM_SH_AUXVEC_H
++
++#endif /* __ASM_SH_AUXVEC_H */
+diff --git a/include/asm-nios2nommu/bitops.h b/include/asm-nios2nommu/bitops.h
+new file mode 100644
+index 0000000..7bf1862
+--- /dev/null
++++ b/include/asm-nios2nommu/bitops.h
+@@ -0,0 +1,11 @@
++#ifndef __ASM_NIOS2NOMMU_BITOPS_H
++#define __ASM_NIOS2NOMMU_BITOPS_H
++
++#ifdef __KERNEL__
++#include <asm/system.h>
++#include <asm-generic/bitops.h>
++#define smp_mb__before_clear_bit() barrier()
++#define smp_mb__after_clear_bit() barrier()
++#endif /* __KERNEL__ */
++
++#endif /* __ASM_NIOS2NOMMU_BITOPS_H */
+diff --git a/include/asm-nios2nommu/bootinfo.h b/include/asm-nios2nommu/bootinfo.h
+new file mode 100644
+index 0000000..ee8c39e
+--- /dev/null
++++ b/include/asm-nios2nommu/bootinfo.h
+@@ -0,0 +1,2 @@
++
++/* Nothing for nios2nommu */
+diff --git a/include/asm-nios2nommu/bug.h b/include/asm-nios2nommu/bug.h
+new file mode 100644
+index 0000000..d99ab08
+--- /dev/null
++++ b/include/asm-nios2nommu/bug.h
+@@ -0,0 +1,4 @@
++#ifndef _MNIOS2NOMMU_BUG_H
++#define _MNIOS2NOMMU_BUG_H
++#include <asm-generic/bug.h>
++#endif
+diff --git a/include/asm-nios2nommu/bugs.h b/include/asm-nios2nommu/bugs.h
+new file mode 100644
+index 0000000..a0753eb
+--- /dev/null
++++ b/include/asm-nios2nommu/bugs.h
+@@ -0,0 +1,40 @@
++#ifndef __ASM_NIOS_BUGS_H
++#define __ASM_NIOS_BUGS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bugs.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1994 Linus Torvalds
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This is included by init/main.c to check for architecture-dependent bugs.
++ *
++ * Needs:
++ * void check_bugs(void);
++ */
++
++static void check_bugs(void)
++{
++}
++
++#endif
+diff --git a/include/asm-nios2nommu/byteorder.h b/include/asm-nios2nommu/byteorder.h
+new file mode 100644
+index 0000000..960b6d3
+--- /dev/null
++++ b/include/asm-nios2nommu/byteorder.h
+@@ -0,0 +1,38 @@
++#ifndef __ASM_NIOS_BYTEORDER_H
++#define __ASM_NIOS_BYTEORDER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/byteorder.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/types.h>
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
++# define __BYTEORDER_HAS_U64__
++# define __SWAB_64_THRU_32__
++#endif
++
++#include <linux/byteorder/little_endian.h>
++
++#endif
++
+diff --git a/include/asm-nios2nommu/cache.h b/include/asm-nios2nommu/cache.h
+new file mode 100644
+index 0000000..82bbd14
+--- /dev/null
++++ b/include/asm-nios2nommu/cache.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __ARCH_NIOS2NOMMU_CACHE_H
++#define __ARCH_NIOS2NOMMU_CACHE_H
++
++#include <asm/nios.h>
++
++/* bytes per L1 cache line */
++#define L1_CACHE_BYTES nasys_icache_line_size /* 32, this need to be at least 1 */
++#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
++#define L1_CACHE_SHIFT 5
++
++
++#define __cacheline_aligned
++#define ____cacheline_aligned
++
++#endif
+diff --git a/include/asm-nios2nommu/cachectl.h b/include/asm-nios2nommu/cachectl.h
+new file mode 100644
+index 0000000..39d7d9d
+--- /dev/null
++++ b/include/asm-nios2nommu/cachectl.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_CACHECTL_H
++#define _NIOS2NOMMU_CACHECTL_H
++
++/* Definitions for the cacheflush system call. */
++
++#define FLUSH_SCOPE_LINE 1 /* Flush a cache line */
++#define FLUSH_SCOPE_PAGE 2 /* Flush a page */
++#define FLUSH_SCOPE_ALL 3 /* Flush the whole cache -- superuser only */
++
++#define FLUSH_CACHE_DATA 1 /* Writeback and flush data cache */
++#define FLUSH_CACHE_INSN 2 /* Flush instruction cache */
++#define FLUSH_CACHE_BOTH 3 /* Flush both caches */
++
++#endif /* _NIOS2NOMMU_CACHECTL_H */
+diff --git a/include/asm-nios2nommu/cacheflush.h b/include/asm-nios2nommu/cacheflush.h
+new file mode 100644
+index 0000000..4543201
+--- /dev/null
++++ b/include/asm-nios2nommu/cacheflush.h
+@@ -0,0 +1,59 @@
++#ifndef _NIOS2NOMMU_CACHEFLUSH_H
++#define _NIOS2NOMMU_CACHEFLUSH_H
++
++/*
++ * Ported from m68knommu.
++ *
++ * (C) Copyright 2003, Microtronix Datacom Ltd.
++ * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com>
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#include <linux/mm.h>
++
++extern void cache_push (unsigned long vaddr, int len);
++extern void dcache_push (unsigned long vaddr, int len);
++extern void icache_push (unsigned long vaddr, int len);
++extern void cache_push_all (void);
++extern void cache_clear (unsigned long paddr, int len);
++
++#define flush_cache_all() __flush_cache_all()
++#define flush_cache_mm(mm) do { } while (0)
++#define flush_cache_range(vma, start, end) cache_push(start, end - start)
++#define flush_cache_page(vma, vmaddr) do { } while (0)
++#define flush_dcache_range(start,end) dcache_push(start, end - start)
++#define flush_dcache_page(page) do { } while (0)
++#define flush_dcache_mmap_lock(mapping) do { } while (0)
++#define flush_dcache_mmap_unlock(mapping) do { } while (0)
++#define flush_icache_range(start,end) cache_push(start, end - start)
++#define flush_icache_page(vma,pg) do { } while (0)
++#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
++
++#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++
++
++extern inline void __flush_cache_all(void)
++{
++ cache_push_all();
++}
++
++#endif /* _NIOS2NOMMU_CACHEFLUSH_H */
+diff --git a/include/asm-nios2nommu/checksum.h b/include/asm-nios2nommu/checksum.h
+new file mode 100644
+index 0000000..1f6879e
+--- /dev/null
++++ b/include/asm-nios2nommu/checksum.h
+@@ -0,0 +1,320 @@
++#ifndef __NIOS2_CHECKSUM_H
++#define __NIOS2_CHECKSUM_H
++
++/* checksum.h: IP/UDP/TCP checksum routines on the NIOS.
++ *
++ * Copyright(C) 1995 Linus Torvalds
++ * Copyright(C) 1995 Miguel de Icaza
++ * Copyright(C) 1996 David S. Miller
++ * Copyright(C) 2001 Ken Hill
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * derived from:
++ * Alpha checksum c-code
++ * ix86 inline assembly
++ * Spar nommu
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * computes the checksum of the TCP/UDP pseudo-header
++ * returns a 16-bit checksum, already complemented
++ */
++
++extern inline unsigned short csum_tcpudp_magic(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++" add %0, %3, %0\n"
++" bgeu %0, %3, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %4, %0\n"
++" bgeu %0, %4, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %5, %0\n"
++" bgeu %0, %5, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++/*
++ We need the carry from the addition of 16-bit
++ significant addition, so we zap out the low bits
++ in one half, zap out the high bits in another,
++ shift them both up to the top 16-bits of a word
++ and do the carry producing addition, finally
++ shift the result back down to the low 16-bits.
++
++ Actually, we can further optimize away two shifts
++ because we know the low bits of the original
++ value will be added to zero-only bits so cannot
++ affect the addition result nor the final carry
++ bit.
++*/
++" slli %1,%0, 16\n" /* Need a copy to fold with */
++ /* Bring the LOW 16 bits up */
++" add %0, %1, %0\n" /* add and set carry, neat eh? */
++" cmpltu r15, %0, %1\n" /* get remaining carry bit */
++" srli %0, %0, 16\n" /* shift back down the result */
++" add %0, %0, r15\n"
++" nor %0, %0, %0\n" /* negate */
++ : "=&r" (sum), "=&r" (saddr)
++ : "0" (sum), "1" (saddr), "r" (ntohl(len+proto)), "r" (daddr)
++ : "r15");
++ return ((unsigned short) sum);
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++ extern inline unsigned short from32to16(unsigned long x)
++ {
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r15, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r15\n"
++ : "=r" (x)
++ : "r" (x << 16), "0" (x)
++ : "r15");
++ return x;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern inline unsigned long do_csum(const unsigned char * buff, int len)
++{
++ int odd, count;
++ unsigned long result = 0;
++
++ barrier();
++ if (len <= 0)
++ goto out;
++ odd = 1 & (unsigned long) buff;
++ if (odd) {
++////result = *buff; // dgt: Big endian
++ result = *buff << 8; // dgt: Little endian
++
++ len--;
++ buff++;
++ }
++ count = len >> 1; /* nr of 16-bit words.. */
++ if (count) {
++ if (2 & (unsigned long) buff) {
++ result += *(unsigned short *) buff;
++ count--;
++ len -= 2;
++ buff += 2;
++ }
++ count >>= 1; /* nr of 32-bit words.. */
++ if (count) {
++ unsigned long carry = 0;
++ do {
++ unsigned long w = *(unsigned long *) buff;
++ count--;
++ buff += 4;
++ result += carry;
++ result += w;
++ carry = (w > result);
++ } while (count);
++ result += carry;
++ result = (result & 0xffff) + (result >> 16);
++ }
++ if (len & 2) {
++ result += *(unsigned short *) buff;
++ buff += 2;
++ }
++ }
++ if (len & 1)
++ result += *buff; /* This is little machine, byte is right */
++ result = from32to16(result);
++ if (odd)
++ result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
++out:
++ return result;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/* ihl is always 5 or greater, almost always is 5, iph is always word
++ * aligned but can fail to be dword aligned very often.
++ */
++
++ extern inline unsigned short ip_fast_csum(const unsigned char *iph, unsigned int ihl)
++ {
++ unsigned int sum;
++
++ barrier();
++ __asm__ __volatile__(
++" andi r8, %1, 2\n" /* Remember original alignment */
++" ldw %0, (%1)\n" /* 16 or 32 bit boundary */
++" beq r8, r0, 1f\n" /* Aligned on 32 bit boundary, go */
++" srli %0, %0, 16\n" /* Get correct 16 bits */
++" addi %2, %2, -1\n" /* Take off for 4 bytes, pickup last 2 at end */
++" addi %1, %1, 2\n" /* Adjust pointer to 32 bit boundary */
++" br 2f\n"
++"1:\n"
++" addi %2, %2, -1\n"
++" addi %1, %1, 4\n" /* Bump ptr a long word */
++"2:\n"
++" ldw r9, (%1)\n"
++"1:\n"
++" add %0, r9, %0\n"
++" bgeu %0, r9, 2f\n"
++" addi %0, %0, 1\n"
++"2:\n"
++" addi %1, %1, 4\n"
++" addi %2, %2, -1\n"
++" ldw r9, (%1)\n"
++" bne %2, r0, 1b\n"
++" beq r8, r0, 1f\n" /* 32 bit boundary time to leave */
++" srli r9, r9, 16\n" /* 16 bit boundary, get correct 16 bits */
++" add %0, r9, %0\n"
++" bgeu %0, r9, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++" slli %2, %0, 16\n"
++" add %0, %2, %0\n"
++" cmpltu r8, %0, %2\n"
++" srli %0, %0, 16\n"
++" add %0, %0, r8\n"
++" nor %0, %0, %0\n"
++ : "=&r" (sum), "=&r" (iph), "=&r" (ihl)
++ : "1" (iph), "2" (ihl)
++ : "r8", "r9");
++ return sum;
++ barrier();
++ }
++
++/*these 2 functions are now in checksum.c */
++unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
++unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * the same as csum_partial_copy, but copies from user space.
++ *
++ * here even more important to align src and dst on a 32-bit (or even
++ * better 64-bit) boundary
++ */
++extern inline unsigned int
++csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err)
++{
++ barrier();
++ if (csum_err) *csum_err = 0;
++ memcpy(dst, src, len);
++ return csum_partial(dst, len, sum);
++ barrier();
++}
++
++#define csum_partial_copy_nocheck(src, dst, len, sum) \
++ csum_partial_copy ((src), (dst), (len), (sum))
++
++
++/*
++ * this routine is used for miscellaneous IP-like checksums, mainly
++ * in icmp.c
++ */
++
++extern inline unsigned short ip_compute_csum(unsigned char * buff, int len)
++{
++ barrier();
++ return ~from32to16(do_csum(buff,len));
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++#define csum_partial_copy_fromuser(s, d, l, w) \
++ csum_partial_copy((char *) (s), (d), (l), (w))
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/*
++ * Fold a partial checksum without adding pseudo headers
++ */
++extern __inline__ unsigned int csum_fold(unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r8\n"
++ "nor %0, %0, %0\n"
++ : "=r" (sum)
++ : "r" (sum << 16), "0" (sum)
++ : "r8");
++ return sum;
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %2, %0\n"
++ "cmpltu r8, %0, %2\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %3, %0\n"
++ "cmpltu r8, %0, %3\n"
++ "add %0, %0, r8\n" /* add carry */
++ : "=r" (sum), "=r" (saddr)
++ : "r" (daddr), "r" ( (ntohs(len)<<16) + (proto*256) ),
++ "0" (sum),
++ "1" (saddr)
++ : "r8");
++
++ return sum;
++ barrier();
++}
++
++
++#endif /* (__NIOS2_CHECKSUM_H) */
+diff --git a/include/asm-nios2nommu/cprefix.h b/include/asm-nios2nommu/cprefix.h
+new file mode 100644
+index 0000000..4983211
+--- /dev/null
++++ b/include/asm-nios2nommu/cprefix.h
+@@ -0,0 +1,38 @@
++/* cprefix.h: This file is included by assembly source which needs
++ * to know what the c-label prefixes are. The newer versions
++ * of cpp that come with gcc predefine such things to help
++ * us out. The reason this stuff is needed is to make
++ * solaris compiles of the kernel work.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_CPREFIX_H
++#define __NIOS2_CPREFIX_H
++
++#define C_LABEL_PREFIX
++
++#define CONCAT(a, b) CONCAT2(a, b)
++#define CONCAT2(a, b) a##b
++
++#define C_LABEL(name) CONCAT(C_LABEL_PREFIX, name)
++
++#endif /* !(__NIOS2_CPREFIX_H) */
+diff --git a/include/asm-nios2nommu/cpumask.h b/include/asm-nios2nommu/cpumask.h
+new file mode 100644
+index 0000000..86fb365
+--- /dev/null
++++ b/include/asm-nios2nommu/cpumask.h
+@@ -0,0 +1,28 @@
++/*
++ * All rights reserved.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_CPUMASK_H
++#define _ASM_NIOS2NOMMU_CPUMASK_H
++
++#include <asm-generic/cpumask.h>
++
++#endif /* _ASM_NIOS2NOMMU_CPUMASK_H */
+diff --git a/include/asm-nios2nommu/cputime.h b/include/asm-nios2nommu/cputime.h
+new file mode 100644
+index 0000000..370e4f2
+--- /dev/null
++++ b/include/asm-nios2nommu/cputime.h
+@@ -0,0 +1,31 @@
++/*
++ * cputime.h
++ * (C) Copyright 2004, Microtronix Datacom Ltd.
++ *
++ * Taken from m68knommu
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_CPUTIME_H
++#define __NIOS2NOMMU_CPUTIME_H
++
++#include <asm-generic/cputime.h>
++
++#endif /* __NIOS@NOMMU_CPUTIME_H */
+diff --git a/include/asm-nios2nommu/current.h b/include/asm-nios2nommu/current.h
+new file mode 100644
+index 0000000..5ac1dbc
+--- /dev/null
++++ b/include/asm-nios2nommu/current.h
+@@ -0,0 +1,39 @@
++#ifndef _NIOS2NOMMU_CURRENT_H
++#define _NIOS2NOMMU_CURRENT_H
++/*
++ * current.h
++ * (C) Copyright 2000, Lineo, David McCullough <davidm@uclinux.org>
++ * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
++ * (C) Copyright 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/thread_info.h>
++
++struct task_struct;
++
++static inline struct task_struct *get_current(void)
++{
++ return(current_thread_info()->task);
++}
++
++#define current get_current()
++
++#endif /* _NIOS2NOMMU_CURRENT_H */
+diff --git a/include/asm-nios2nommu/delay.h b/include/asm-nios2nommu/delay.h
+new file mode 100644
+index 0000000..da0a184
+--- /dev/null
++++ b/include/asm-nios2nommu/delay.h
+@@ -0,0 +1,96 @@
++#ifndef _NIOS_DELAY_H
++#define _NIOS_DELAY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/delay.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/param.h>
++
++extern __inline__ void __delay(unsigned long loops)
++{
++ int dummy;
++
++ __asm__ __volatile__(
++ "1: \n\t"
++ " beq %0,zero,2f\n\t"
++ " addi %0, %0, -1\n\t"
++ " br 1b\n\t"
++ "2: \n\t"
++
++ : "=r" (dummy) /* Need output for optimizer */
++
++ : "0" (loops) /* %0 Input */
++ );
++}
++
++/*
++ * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
++ * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
++ *
++ * The mul instruction gives us loops = (a * b) / 2^32.
++ * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
++ * because this lets us support a wide range of HZ and
++ * loops_per_jiffy values without either a or b overflowing 2^32.
++ * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
++ * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
++ * (which corresponds to ~3800 bogomips at HZ = 100).
++ * -- paulus
++ */
++#define __MAX_UDELAY (226050910UL/HZ) /* maximum udelay argument */
++#define __MAX_NDELAY (4294967295UL/HZ) /* maximum ndelay argument */
++
++extern unsigned long loops_per_jiffy;
++
++extern __inline__ void __udelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 226));
++ __delay(loops);
++}
++
++extern __inline__ void __ndelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 5));
++ __delay(loops);
++}
++
++extern void __bad_udelay(void); /* deliberately undefined */
++extern void __bad_ndelay(void); /* deliberately undefined */
++
++#define udelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
++ __udelay((n) * (19 * HZ)))
++
++#define ndelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
++ __ndelay((n) * HZ))
++
++#define muldiv(a, b, c) (((a)*(b))/(c))
++
++#endif /* defined(_NIOS_DELAY_H) */
+diff --git a/include/asm-nios2nommu/device.h b/include/asm-nios2nommu/device.h
+new file mode 100644
+index 0000000..d8f9872
+--- /dev/null
++++ b/include/asm-nios2nommu/device.h
+@@ -0,0 +1,7 @@
++/*
++ * Arch specific extensions to struct device
++ *
++ * This file is released under the GPLv2
++ */
++#include <asm-generic/device.h>
++
+diff --git a/include/asm-nios2nommu/div64.h b/include/asm-nios2nommu/div64.h
+new file mode 100644
+index 0000000..68d72e4
+--- /dev/null
++++ b/include/asm-nios2nommu/div64.h
+@@ -0,0 +1,31 @@
++#ifndef __ASMNIOS_DIV64_H
++#define __ASMNIOS_DIV64_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/div64.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/div64.h>
++
++#endif
++
+diff --git a/include/asm-nios2nommu/dma-mapping.h b/include/asm-nios2nommu/dma-mapping.h
+new file mode 100644
+index 0000000..6289370
+--- /dev/null
++++ b/include/asm-nios2nommu/dma-mapping.h
+@@ -0,0 +1,79 @@
++#ifndef _ASM_DMA_MAPPING_H
++#define _ASM_DMA_MAPPING_H
++
++#include <asm/scatterlist.h>
++#include <asm/cache.h>
++
++void *dma_alloc_noncoherent(struct device *dev, size_t size,
++ dma_addr_t *dma_handle, gfp_t flag);
++
++void dma_free_noncoherent(struct device *dev, size_t size,
++ void *vaddr, dma_addr_t dma_handle);
++
++void *dma_alloc_coherent(struct device *dev, size_t size,
++ dma_addr_t *dma_handle, gfp_t flag);
++
++void dma_free_coherent(struct device *dev, size_t size,
++ void *vaddr, dma_addr_t dma_handle);
++
++extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
++ enum dma_data_direction direction);
++extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
++ size_t size, enum dma_data_direction direction);
++extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction);
++extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size, enum dma_data_direction direction);
++extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
++ size_t size, enum dma_data_direction direction);
++extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
++ int nhwentries, enum dma_data_direction direction);
++extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
++ size_t size, enum dma_data_direction direction);
++extern void dma_sync_single_for_device(struct device *dev,
++ dma_addr_t dma_handle, size_t size, enum dma_data_direction direction);
++extern void dma_sync_single_range_for_cpu(struct device *dev,
++ dma_addr_t dma_handle, unsigned long offset, size_t size,
++ enum dma_data_direction direction);
++extern void dma_sync_single_range_for_device(struct device *dev,
++ dma_addr_t dma_handle, unsigned long offset, size_t size,
++ enum dma_data_direction direction);
++extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
++ int nelems, enum dma_data_direction direction);
++extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
++ int nelems, enum dma_data_direction direction);
++extern int dma_mapping_error(dma_addr_t dma_addr);
++extern int dma_supported(struct device *dev, u64 mask);
++
++static inline int
++dma_set_mask(struct device *dev, u64 mask)
++{
++ if(!dev->dma_mask || !dma_supported(dev, mask))
++ return -EIO;
++
++ *dev->dma_mask = mask;
++
++ return 0;
++}
++
++static inline int
++dma_get_cache_alignment(void)
++{
++ /* XXX Largest on any MIPS */
++ return 128;
++}
++
++extern int dma_is_consistent(dma_addr_t dma_addr);
++
++extern void dma_cache_sync(void *vaddr, size_t size,
++ enum dma_data_direction direction);
++
++// #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
++//
++// extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
++// dma_addr_t device_addr, size_t size, int flags);
++// extern void dma_release_declared_memory(struct device *dev);
++// extern void * dma_mark_declared_memory_occupied(struct device *dev,
++// dma_addr_t device_addr, size_t size);
++
++#endif /* _ASM_DMA_MAPPING_H */
+diff --git a/include/asm-nios2nommu/dma.h b/include/asm-nios2nommu/dma.h
+new file mode 100644
+index 0000000..ea098d5
+--- /dev/null
++++ b/include/asm-nios2nommu/dma.h
+@@ -0,0 +1,63 @@
++/* $Id: dma.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
++ *
++ * Copyright 2004 (C) Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2_DMA_H
++#define _ASM_NIOS2_DMA_H
++
++#include <linux/kernel.h>
++#include <asm/asm-offsets.h>
++
++#define MAX_DMA_ADDRESS (LINUX_SDRAM_END)
++
++int request_dma(unsigned int, const char *);
++void free_dma(unsigned int);
++void enable_dma(unsigned int dmanr);
++void disable_dma(unsigned int dmanr);
++void set_dma_count(unsigned int dmanr, unsigned int count);
++int get_dma_residue(unsigned int dmanr);
++void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width);
++
++void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user);
++int nios2_request_dma(const char *);
++
++void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode);
++void nios2_set_dma_rcon(unsigned int dmanr, unsigned int set);
++void nios2_set_dma_wcon(unsigned int dmanr, unsigned int set);
++void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a);
++void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a);
++
++static inline unsigned long claim_dma_lock(void)
++{
++}
++
++static inline void release_dma_lock(unsigned long flags)
++{
++}
++
++#ifdef CONFIG_PCI
++extern int isa_dma_bridge_buggy;
++#else
++#define isa_dma_bridge_buggy (0)
++#endif
++
++#endif /* !(_ASM_NIOS2_DMA_H) */
+diff --git a/include/asm-nios2nommu/elf.h b/include/asm-nios2nommu/elf.h
+new file mode 100644
+index 0000000..94b2ac0
+--- /dev/null
++++ b/include/asm-nios2nommu/elf.h
+@@ -0,0 +1,140 @@
++#ifndef __NIOS2_ELF_H
++#define __NIOS2_ELF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/elf.h
++ *
++ * Nio2 ELF relocation types
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ * Mar/18/2004 xwt NiosII relocation types added
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm/ptrace.h>
++#include <asm/user.h>
++
++#define R_NIOS2_NONE 0
++#define R_NIOS2_S16 1
++#define R_NIOS2_U16 2
++#define R_NIOS2_PCREL16 3
++#define R_NIOS2_CALL26 4
++#define R_NIOS2_IMM5 5
++#define R_NIOS2_CACHE_OPX 6
++#define R_NIOS2_IMM6 7
++#define R_NIOS2_IMM8 8
++#define R_NIOS2_HI16 9
++#define R_NIOS2_LO16 10
++#define R_NIOS2_HIADJ16 11
++#define R_NIOS2_BFD_RELOC_32 12
++#define R_NIOS2_BFD_RELOC_16 13
++#define R_NIOS2_BFD_RELOC_8 14
++#define R_NIOS2_GPREL 15
++#define R_NIOS2_GNU_VTINHERIT 16
++#define R_NIOS2_GNU_VTENTRY 17
++#define R_NIOS2_UJMP 18
++#define R_NIOS2_CJMP 19
++#define R_NIOS2_CALLR 20
++#define R_NIOS2_ALIGN 21
++/* Keep this the last entry. */
++#define R_NIOS2_NUM 22
++
++typedef unsigned long elf_greg_t;
++
++#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
++typedef elf_greg_t elf_gregset_t[ELF_NGREG];
++
++typedef unsigned long elf_fpregset_t;
++
++/*
++ * This is used to ensure we don't load something for the wrong architecture.
++ */
++#define elf_check_arch(x) \
++ ((x)->e_machine == EM_ALTERA_NIOS2)
++
++/*
++ * These are used to set parameters in the core dumps.
++ */
++#define ELF_CLASS ELFCLASS32
++#define ELF_DATA ELFDATA2LSB
++#define ELF_ARCH EM_ALTERA_NIOS2
++
++#define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0
++
++#define USE_ELF_CORE_DUMP
++#define ELF_EXEC_PAGESIZE 4096
++
++/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
++ use of this is to invoke "./ld.so someprog" to test out a new version of
++ the loader. We need to make sure that it is out of the way of the program
++ that it will "exec", and that there is sufficient room for the brk. */
++
++#define ELF_ET_DYN_BASE 0xD0000000UL
++
++/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
++ now struct_user_regs, they are different) */
++
++#define ELF_CORE_COPY_REGS(pr_reg, regs) \
++ /* Bleech. */ \
++ pr_reg[0] = regs->r1; \
++ pr_reg[1] = regs->r2; \
++ pr_reg[2] = regs->r3; \
++ pr_reg[3] = regs->r4; \
++ pr_reg[4] = regs->r5; \
++ pr_reg[5] = regs->r6; \
++ pr_reg[6] = regs->r7; \
++ pr_reg[7] = regs->r8; \
++ pr_reg[8] = regs->r9; \
++ pr_reg[9] = regs->r10; \
++ pr_reg[10] = regs->r11; \
++ pr_reg[11] = regs->r12; \
++ pr_reg[12] = regs->r13; \
++ pr_reg[13] = regs->r14; \
++ pr_reg[14] = regs->r15; \
++ pr_reg[23] = regs->sp; \
++ pr_reg[26] = regs->estatus; \
++ { \
++ struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
++ pr_reg[15] = sw->r16; \
++ pr_reg[16] = sw->r17; \
++ pr_reg[17] = sw->r18; \
++ pr_reg[18] = sw->r19; \
++ pr_reg[19] = sw->r20; \
++ pr_reg[20] = sw->r21; \
++ pr_reg[21] = sw->r22; \
++ pr_reg[22] = sw->r23; \
++ pr_reg[24] = sw->fp; \
++ pr_reg[25] = sw->gp; \
++ }
++
++/* This yields a mask that user programs can use to figure out what
++ instruction set this cpu supports. */
++
++#define ELF_HWCAP (0)
++
++/* This yields a string that ld.so will use to load implementation
++ specific libraries for optimization. This is more specific in
++ intent than poking at uname or /proc/cpuinfo. */
++
++#define ELF_PLATFORM (NULL)
++
++#ifdef __KERNEL__
++#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
++#endif
++
++#endif
+diff --git a/include/asm-nios2nommu/emergency-restart.h b/include/asm-nios2nommu/emergency-restart.h
+new file mode 100644
+index 0000000..108d8c4
+--- /dev/null
++++ b/include/asm-nios2nommu/emergency-restart.h
+@@ -0,0 +1,6 @@
++#ifndef _ASM_EMERGENCY_RESTART_H
++#define _ASM_EMERGENCY_RESTART_H
++
++#include <asm-generic/emergency-restart.h>
++
++#endif /* _ASM_EMERGENCY_RESTART_H */
+diff --git a/include/asm-nios2nommu/entry.h b/include/asm-nios2nommu/entry.h
+new file mode 100644
+index 0000000..4b1773f
+--- /dev/null
++++ b/include/asm-nios2nommu/entry.h
+@@ -0,0 +1,187 @@
++/*
++ * Hacked from m68knommu port.
++ *
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_ENTRY_H
++#define __NIOS2NOMMU_ENTRY_H
++
++#ifdef __ASSEMBLY__
++
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/asm-offsets.h>
++
++/*
++ * Stack layout in 'ret_from_exception':
++ *
++ * This allows access to the syscall arguments in registers r4-r8
++ *
++ * 0(sp) - r8
++ * 4(sp) - r9
++ * 8(sp) - r10
++ * C(sp) - r11
++ * 10(sp) - r12
++ * 14(sp) - r13
++ * 18(sp) - r14
++ * 1C(sp) - r15
++ * 20(sp) - r1
++ * 24(sp) - r2
++ * 28(sp) - r3
++ * 2C(sp) - r4
++ * 30(sp) - r5
++ * 34(sp) - r6
++ * 38(sp) - r7
++ * 3C(sp) - orig_r2
++ * 40(sp) - ra
++ * 44(sp) - fp
++ * 48(sp) - sp
++ * 4C(sp) - gp
++ * 50(sp) - estatus
++ * 54(sp) - status_extension
++ * 58(sp) - ea
++ *
++ */
++
++/* process bits for task_struct.flags */
++PF_TRACESYS_OFF = 3
++PF_TRACESYS_BIT = 5
++PF_PTRACED_OFF = 3
++PF_PTRACED_BIT = 4
++PF_DTRACE_OFF = 1
++PF_DTRACE_BIT = 5
++
++LENOSYS = 38
++
++/*
++ * This defines the normal kernel pt-regs layout.
++ *
++ */
++
++/*
++ * Standard Nios2 interrupt entry and exit macros.
++ * Must be called with interrupts disabled.
++ */
++.macro SAVE_ALL
++ movia r24,status_extension // Read status extension
++ ldw r24,0(r24)
++ andi r24,r24,PS_S_ASM
++ bne r24,r0,1f // In supervisor mode, already on kernel stack
++ movia r24,_current_thread // Switch to current kernel stack
++ ldw r24,0(r24) // using the thread_info
++ addi r24,r24,THREAD_SIZE_ASM-PT_REGS_SIZE
++ stw sp,PT_SP(r24) // Save user stack before changing
++ mov sp,r24
++ br 2f
++
++1: mov r24,sp
++ addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
++ stw r24,PT_SP(sp)
++2: stw r1,PT_R1(sp)
++ stw r2,PT_R2(sp)
++ stw r3,PT_R3(sp)
++ stw r4,PT_R4(sp)
++ stw r5,PT_R5(sp)
++ stw r6,PT_R6(sp)
++ stw r7,PT_R7(sp)
++ stw r8,PT_R8(sp)
++ stw r9,PT_R9(sp)
++ stw r10,PT_R10(sp)
++ stw r11,PT_R11(sp)
++ stw r12,PT_R12(sp)
++ stw r13,PT_R13(sp)
++ stw r14,PT_R14(sp)
++ stw r15,PT_R15(sp)
++ stw r2,PT_ORIG_R2(sp)
++ stw ra,PT_RA(sp)
++ stw fp,PT_FP(sp)
++ stw gp,PT_GP(sp)
++ rdctl r24,estatus
++ stw r24,PT_ESTATUS(sp)
++ movia r24,status_extension // Read status extension
++ ldw r1,0(r24)
++ stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
++ ORI32 r1,r1,PS_S_ASM // Set supervisor mode
++ stw r1,0(r24)
++ stw ea,PT_EA(sp)
++.endm
++
++.macro RESTORE_ALL
++ ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
++ movia r24,status_extension
++ stw r1,0(r24)
++ ldw r1,PT_R1(sp) // Restore registers
++ ldw r2,PT_R2(sp)
++ ldw r3,PT_R3(sp)
++ ldw r4,PT_R4(sp)
++ ldw r5,PT_R5(sp)
++ ldw r6,PT_R6(sp)
++ ldw r7,PT_R7(sp)
++ ldw r8,PT_R8(sp)
++ ldw r9,PT_R9(sp)
++ ldw r10,PT_R10(sp)
++ ldw r11,PT_R11(sp)
++ ldw r12,PT_R12(sp)
++ ldw r13,PT_R13(sp)
++ ldw r14,PT_R14(sp)
++ ldw r15,PT_R15(sp)
++ ldw ra,PT_RA(sp)
++ ldw fp,PT_FP(sp)
++ ldw gp,PT_GP(sp)
++ ldw r24,PT_ESTATUS(sp)
++ wrctl estatus,r24
++ ldw ea,PT_EA(sp)
++ ldw sp,PT_SP(sp) // Restore sp last
++.endm
++
++.macro SAVE_SWITCH_STACK
++ addi sp,sp,-SWITCH_STACK_SIZE
++ stw r16,SW_R16(sp)
++ stw r17,SW_R17(sp)
++ stw r18,SW_R18(sp)
++ stw r19,SW_R19(sp)
++ stw r20,SW_R20(sp)
++ stw r21,SW_R21(sp)
++ stw r22,SW_R22(sp)
++ stw r23,SW_R23(sp)
++ stw fp,SW_FP(sp)
++ stw gp,SW_GP(sp)
++ stw ra,SW_RA(sp)
++.endm
++
++.macro RESTORE_SWITCH_STACK
++ ldw r16,SW_R16(sp)
++ ldw r17,SW_R17(sp)
++ ldw r18,SW_R18(sp)
++ ldw r19,SW_R19(sp)
++ ldw r20,SW_R20(sp)
++ ldw r21,SW_R21(sp)
++ ldw r22,SW_R22(sp)
++ ldw r23,SW_R23(sp)
++ ldw fp,SW_FP(sp)
++ ldw gp,SW_GP(sp)
++ ldw ra,SW_RA(sp)
++ addi sp,sp,SWITCH_STACK_SIZE
++.endm
++
++#endif /* __ASSEMBLY__ */
++#endif /* __NIOS2NOMMU_ENTRY_H */
+diff --git a/include/asm-nios2nommu/errno.h b/include/asm-nios2nommu/errno.h
+new file mode 100644
+index 0000000..c2caf21
+--- /dev/null
++++ b/include/asm-nios2nommu/errno.h
+@@ -0,0 +1,6 @@
++#ifndef _NIOS2NOMMU_ERRNO_H
++#define _NIOS2NOMMU_ERRNO_H
++
++#include <asm-generic/errno.h>
++
++#endif /* _NIOS2NOMMU_ERRNO_H */
+diff --git a/include/asm-nios2nommu/fcntl.h b/include/asm-nios2nommu/fcntl.h
+new file mode 100644
+index 0000000..9d98af2
+--- /dev/null
++++ b/include/asm-nios2nommu/fcntl.h
+@@ -0,0 +1,11 @@
++#ifndef _NIOS2_FCNTL_H
++#define _NIOS2_FCNTL_H
++
++#define O_DIRECTORY 040000 /* must be a directory */
++#define O_NOFOLLOW 0100000 /* don't follow links */
++#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
++#define O_LARGEFILE 0400000
++
++#include <asm-generic/fcntl.h>
++
++#endif /* _NIOS2_FCNTL_H */
+diff --git a/include/asm-nios2nommu/flat.h b/include/asm-nios2nommu/flat.h
+new file mode 100644
+index 0000000..681329a
+--- /dev/null
++++ b/include/asm-nios2nommu/flat.h
+@@ -0,0 +1,129 @@
++/*
++ * include/asm-nios2nommu/flat.h -- uClinux bFLT relocations
++ *
++ * Copyright (C) 2004,05 Microtronix Datacom Ltd
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License. See the file COPYING in the main directory of this
++ * archive for more details.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#ifndef __NIOS2_FLAT_H__
++#define __NIOS2_FLAT_H__
++
++#define flat_reloc_valid(reloc, size) ((reloc) <= (size + 0x8000))
++
++/* The stack is 64-bit aligned for Nios II, so (sp - 1) shall
++ * be 64-bit aligned, where -1 is for argc
++ */
++#define flat_stack_align(sp) (sp = (unsigned long *)(((unsigned long)sp - 1) & (-8)))
++
++/* The uClibc port for Nios II expects the argc is followed by argv and envp */
++#define flat_argvp_envp_on_stack() 1
++
++#define flat_old_ram_flag(flags) (flags)
++
++/* We store the type of relocation in the top 4 bits of the `relval.' */
++
++/* Convert a relocation entry into an address. */
++static inline unsigned long
++flat_get_relocate_addr (unsigned long relval)
++{
++ return relval & 0x0fffffff; /* Mask out top 4-bits */
++}
++
++#define FLAT_NIOS2_RELOC_TYPE(relval) ((relval) >> 28)
++
++#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
++#define FLAT_NIOS2_R_HI_LO 1 /* High 16-bits + low 16-bits field */
++#define FLAT_NIOS2_R_HIADJ_LO 2 /* High 16-bits adjust + low 16-bits field */
++#define FLAT_NIOS2_R_CALL26 4 /* Call imm26 */
++
++#define flat_set_persistent(relval, p) 0
++
++/* Extract the address to be relocated from the symbol reference at rp;
++ * relval is the raw relocation-table entry from which RP is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
++ unsigned long relval,
++ unsigned long flags,
++ unsigned long *persistent)
++{
++ switch (FLAT_NIOS2_RELOC_TYPE(relval))
++ {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. The loader expect it in bigger endian */
++ return htonl(*rp);
++
++ case FLAT_NIOS2_R_HI_LO:
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ return htonl ((((rp[0] >> 6) & 0xFFFF) << 16 ) |
++ ((rp[1] >> 6) & 0xFFFF));
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ unsigned int low, high;
++ high = (rp[0] >> 6) & 0xFFFF;
++ low = (rp[1] >> 6) & 0xFFFF;
++
++ if ((low >> 15) & 1) high--;
++
++ return htonl ((high << 16 ) | low );
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the 26-bit immediate value is actually 28-bit */
++ return htonl(((*rp) >> 6) << 2);
++
++ default:
++ return ~0; /* bogus value */
++ }
++}
++
++/* Insert the address addr into the symbol reference at rp;
++ * relval is the raw relocation-table entry from which rp is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline void flat_put_addr_at_rp (unsigned long *rp, unsigned long addr,
++ unsigned long relval)
++{
++ unsigned long exist_val;
++ switch (FLAT_NIOS2_RELOC_TYPE (relval)) {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. */
++ *rp = addr;
++ break;
++
++ case FLAT_NIOS2_R_HI_LO:
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | (addr >> 16)) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ unsigned int high = (addr >> 16);
++ if ((addr >> 15) & 1)
++ high = (high + 1) & 0xFFFF;
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | high) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the opcode of CALL is 0, so just store the value */
++ *rp = ((addr >> 2) << 6);
++ break;
++ }
++}
++
++#endif /* __NIOS2_FLAT_H__ */
+diff --git a/include/asm-nios2nommu/futex.h b/include/asm-nios2nommu/futex.h
+new file mode 100644
+index 0000000..6a332a9
+--- /dev/null
++++ b/include/asm-nios2nommu/futex.h
+@@ -0,0 +1,6 @@
++#ifndef _ASM_FUTEX_H
++#define _ASM_FUTEX_H
++
++#include <asm-generic/futex.h>
++
++#endif
+diff --git a/include/asm-nios2nommu/gpio.h b/include/asm-nios2nommu/gpio.h
+new file mode 100644
+index 0000000..b91937b
+--- /dev/null
++++ b/include/asm-nios2nommu/gpio.h
+@@ -0,0 +1,11 @@
++#ifndef _ASM_GPIO_H_
++#define _ASM_GPIO_H_ 1
++
++
++struct gpio_i2c_pins {
++ unsigned sda_pin;
++ unsigned scl_pin;
++};
++
++#endif /*_ASM_GPIO_*/
++
+diff --git a/include/asm-nios2nommu/hardirq.h b/include/asm-nios2nommu/hardirq.h
+new file mode 100644
+index 0000000..0041f51
+--- /dev/null
++++ b/include/asm-nios2nommu/hardirq.h
+@@ -0,0 +1,43 @@
++/*
++ * Ported from m68knommu
++ *
++ * Copyright (C) 2003, Microtronix Datacom Ltd.
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_HARDIRQ_H
++#define __NIOS2_HARDIRQ_H
++
++#include <linux/cache.h>
++#include <linux/threads.h>
++
++typedef struct {
++ unsigned int __softirq_pending;
++} ____cacheline_aligned irq_cpustat_t;
++
++#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
++
++#define HARDIRQ_BITS 8
++
++#ifdef CONFIG_SMP
++# error nios2nommu SMP is not available
++#endif /* CONFIG_SMP */
++
++#endif /* __NIOS2_HARDIRQ_H */
+diff --git a/include/asm-nios2nommu/hdreg.h b/include/asm-nios2nommu/hdreg.h
+new file mode 100644
+index 0000000..b4d910a
+--- /dev/null
++++ b/include/asm-nios2nommu/hdreg.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2002 Wentau Xu (www.microtronix.com)
++ * copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_HDREG_H
++#define __NIOS2_HDREG_H
++
++typedef unsigned long ide_ioreg_t;
++
++#endif /* __NIOS2_HDREG_H */
+diff --git a/include/asm-nios2nommu/hw_irq.h b/include/asm-nios2nommu/hw_irq.h
+new file mode 100644
+index 0000000..d2fd3be
+--- /dev/null
++++ b/include/asm-nios2nommu/hw_irq.h
+@@ -0,0 +1,16 @@
++#ifndef _ASM_HW_IRQ_H
++#define _ASM_HW_IRQ_H
++
++/*
++ * linux/include/asm/hw_irq.h
++ *
++ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
++ *
++ * moved some of the old arch/i386/kernel/irq.h to here. VY
++ *
++ * IRQ/IPI changes taken from work by Thomas Radke
++ * <tomsoft@informatik.tu-chemnitz.de>
++ */
++
++
++#endif /* _ASM_HW_IRQ_H */
+diff --git a/include/asm-nios2nommu/ide.h b/include/asm-nios2nommu/ide.h
+new file mode 100644
+index 0000000..f8ef9ad
+--- /dev/null
++++ b/include/asm-nios2nommu/ide.h
+@@ -0,0 +1,40 @@
++/*
++ * linux/include/asm-niosnommu2/ide.h
++ *
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASMNIOS2_IDE_H
++#define __ASMNIOS2_IDE_H
++
++#ifdef __KERNEL__
++#undef MAX_HWIFS /* we're going to force it */
++
++#ifndef MAX_HWIFS
++#define MAX_HWIFS 1
++#endif
++
++#include <asm-generic/ide_iops.h>
++
++#endif /* __KERNEL__ */
++
++#endif /* __ASMNIOS2_IDE_H */
+diff --git a/include/asm-nios2nommu/init.h b/include/asm-nios2nommu/init.h
+new file mode 100644
+index 0000000..8641f4f
+--- /dev/null
++++ b/include/asm-nios2nommu/init.h
+@@ -0,0 +1,22 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+diff --git a/include/asm-nios2nommu/io.h b/include/asm-nios2nommu/io.h
+new file mode 100644
+index 0000000..d0e3741
+--- /dev/null
++++ b/include/asm-nios2nommu/io.h
+@@ -0,0 +1,277 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_IO_H
++#define __NIOS2_IO_H
++
++#ifdef __KERNEL__
++
++#include <linux/kernel.h>
++
++#include <asm/page.h> /* IO address mapping routines need this */
++#include <asm/system.h>
++#include <asm/unaligned.h>
++
++extern void insw(unsigned long port, void *dst, unsigned long count);
++extern void outsw(unsigned long port, void *src, unsigned long count);
++extern void insl(unsigned long port, void *dst, unsigned long count);
++extern void outsl(unsigned long port, void *src, unsigned long count);
++
++#define readsb(p,d,l) insb(p,d,l)
++#define readsw(p,d,l) insw(p,d,l)
++#define readsl(p,d,l) insl(p,d,l)
++#define writesb(p,d,l) outsb(p,d,l)
++#define writesw(p,d,l) outsw(p,d,l)
++#define writesl(p,d,l) outsl(p,d,l)
++#ifndef irq_canonicalize
++#define irq_canonicalize(i) (i)
++#endif
++
++#endif /* __KERNEL__ */
++/* IO macros are needed by userspace programs */
++
++/*
++ * readX/writeX() are used to access memory mapped devices. On some
++ * architectures the memory mapped IO stuff needs to be accessed
++ * differently. On the Nios architecture, we just read/write the
++ * memory location directly.
++ */
++
++#define readb(addr) \
++({ \
++ unsigned char __res;\
++ __asm__ __volatile__( \
++ "ldbuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readw(addr) \
++({ \
++ unsigned short __res;\
++ __asm__ __volatile__( \
++ "ldhuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readl(addr) \
++({ \
++ unsigned int __res;\
++ __asm__ __volatile__( \
++ "ldwio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define writeb(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stbio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writew(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "sthio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writel(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stwio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define __raw_readb readb
++#define __raw_readw readw
++#define __raw_readl readl
++#define __raw_writeb writeb
++#define __raw_writew writew
++#define __raw_writel writel
++
++#define mmiowb()
++
++/*
++ * make the short names macros so specific devices
++ * can override them as required
++ */
++
++#define memset_io(addr,c,len) memset((void *)(((unsigned int)(addr)) | 0x80000000),(c),(len))
++#define memcpy_fromio(to,from,len) memcpy((to),(void *)(((unsigned int)(from)) | 0x80000000),(len))
++#define memcpy_toio(to,from,len) memcpy((void *)(((unsigned int)(to)) | 0x80000000),(from),(len))
++
++#define inb(addr) readb(addr)
++#define inw(addr) readw(addr)
++#define inl(addr) readl(addr)
++
++#define outb(x,addr) ((void) writeb(x,addr))
++#define outw(x,addr) ((void) writew(x,addr))
++#define outl(x,addr) ((void) writel(x,addr))
++
++#define inb_p(addr) inb(addr)
++#define inw_p(addr) inw(addr)
++#define inl_p(addr) inl(addr)
++
++#define outb_p(x,addr) outb(x,addr)
++#define outw_p(x,addr) outw(x,addr)
++#define outl_p(x,addr) outl(x,addr)
++
++/* IO macros are needed by userspace programs */
++#ifdef __KERNEL__
++
++extern inline void insb(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)dst;
++ while (count--)
++ *p++ = inb(port);
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _insw(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)dst;
++ while (count--)
++ *p++ = inw(port);
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned destination pointer */
++extern inline void _insl(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)dst;
++ while (count--)
++ *p++ = inl(port);
++}
++
++extern inline void outsb(unsigned long port, void *src, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)src;
++ while (count--)
++ outb( *p++, port );
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _outsw(unsigned long port, void *src, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)src;
++ while (count--)
++ outw( *p++, port );
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned source pointer */
++extern inline void _outsl(unsigned long port, void *src, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)src;
++ while (count--)
++ outl( *p++, port );
++}
++
++
++
++extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr,
++ int bus, int rdonly)
++{
++ return;
++}
++
++//vic - copied from m68knommu
++
++/* Values for nocacheflag and cmode */
++#define IOMAP_FULL_CACHING 0
++#define IOMAP_NOCACHE_SER 1
++#define IOMAP_NOCACHE_NONSER 2
++#define IOMAP_WRITETHROUGH 3
++
++extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
++extern void __iounmap(void *addr, unsigned long size);
++
++extern inline void *ioremap(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
++}
++extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
++}
++
++extern void iounmap(void *addr);
++
++
++#define IO_SPACE_LIMIT 0xffffffff
++
++#define dma_cache_inv(_start,_size) dcache_push(_start,_size)
++#define dma_cache_wback(_start,_size) dcache_push(_start,_size)
++#define dma_cache_wback_inv(_start,_size) dcache_push(_start,_size)
++
++/* Pages to physical address... */
++#define page_to_phys(page) page_to_virt(page)
++#define page_to_bus(page) page_to_virt(page)
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#define ioport_map(port, nr) ioremap(port, nr)
++#define ioport_unmap(port) iounmap(port)
++
++/*
++ * Convert a physical pointer to a virtual kernel pointer for /dev/mem
++ * access
++ */
++#define xlate_dev_mem_ptr(p) __va(p)
++
++/*
++ * Convert a virtual cached pointer to an uncached pointer
++ */
++#define xlate_dev_kmem_ptr(p) p
++
++#define readsb(p,d,l) insb(p,d,l)
++#define readsw(p,d,l) insw(p,d,l)
++#define readsl(p,d,l) insl(p,d,l)
++#define writesb(p,d,l) outsb(p,d,l)
++#define writesw(p,d,l) outsw(p,d,l)
++#define writesl(p,d,l) outsl(p,d,l)
++#ifndef irq_canonicalize
++#define irq_canonicalize(i) (i)
++#endif
++
++#endif /* __KERNEL__ */
++
++#endif /* !(__NIOS2_IO_H) */
++
+diff --git a/include/asm-nios2nommu/ioctl.h b/include/asm-nios2nommu/ioctl.h
+new file mode 100644
+index 0000000..c02a36a
+--- /dev/null
++++ b/include/asm-nios2nommu/ioctl.h
+@@ -0,0 +1,100 @@
++/* $Id: ioctl.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
++ *
++ * linux/ioctl.h for Linux by H.H. Bergman.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_IOCTL_H
++#define _NIOS2_IOCTL_H
++
++/* ioctl command encoding: 32 bits total, command in lower 16 bits,
++ * size of the parameter structure in the lower 14 bits of the
++ * upper 16 bits.
++ * Encoding the size of the parameter structure in the ioctl request
++ * is useful for catching programs compiled with old versions
++ * and to avoid overwriting user space outside the user buffer area.
++ * The highest 2 bits are reserved for indicating the ``access mode''.
++ * NOTE: This limits the max parameter size to 16kB -1 !
++ */
++
++/*
++ * I don't really have any idea about what this should look like, so
++ * for the time being, this is heavily based on the PC definitions.
++ */
++
++/*
++ * The following is for compatibility across the various Linux
++ * platforms. The i386 ioctl numbering scheme doesn't really enforce
++ * a type field. De facto, however, the top 8 bits of the lower 16
++ * bits are indeed used as a type field, so we might just as well make
++ * this explicit here. Please be sure to use the decoding macros
++ * below from now on.
++ */
++#define _IOC_NRBITS 8
++#define _IOC_TYPEBITS 8
++#define _IOC_SIZEBITS 14
++#define _IOC_DIRBITS 2
++
++#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
++#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
++#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
++#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
++
++#define _IOC_NRSHIFT 0
++#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
++#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
++#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
++
++/*
++ * Direction bits.
++ */
++#define _IOC_NONE 0U
++#define _IOC_WRITE 1U
++#define _IOC_READ 2U
++
++#define _IOC(dir,type,nr,size) \
++ (((dir) << _IOC_DIRSHIFT) | \
++ ((type) << _IOC_TYPESHIFT) | \
++ ((nr) << _IOC_NRSHIFT) | \
++ ((size) << _IOC_SIZESHIFT))
++
++/* used to create numbers */
++#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
++#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
++#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
++#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
++
++/* used to decode ioctl numbers.. */
++#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
++#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
++#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
++#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
++
++/* ...and for the drivers/sound files... */
++
++#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
++#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
++#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
++#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
++#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
++
++#endif /* _NIOS2_IOCTL_H */
+diff --git a/include/asm-nios2nommu/ioctls.h b/include/asm-nios2nommu/ioctls.h
+new file mode 100644
+index 0000000..288025c
+--- /dev/null
++++ b/include/asm-nios2nommu/ioctls.h
+@@ -0,0 +1,103 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ARCH_NIOS2_IOCTLS_H__
++#define __ARCH_NIOS2_IOCTLS_H__
++
++#include <asm/ioctl.h>
++
++/* 0x54 is just a magic number to make these relatively unique ('T') */
++
++#define TCGETS 0x5401
++#define TCSETS 0x5402
++#define TCSETSW 0x5403
++#define TCSETSF 0x5404
++#define TCGETA 0x5405
++#define TCSETA 0x5406
++#define TCSETAW 0x5407
++#define TCSETAF 0x5408
++#define TCSBRK 0x5409
++#define TCXONC 0x540A
++#define TCFLSH 0x540B
++#define TIOCEXCL 0x540C
++#define TIOCNXCL 0x540D
++#define TIOCSCTTY 0x540E
++#define TIOCGPGRP 0x540F
++#define TIOCSPGRP 0x5410
++#define TIOCOUTQ 0x5411
++#define TIOCSTI 0x5412
++#define TIOCGWINSZ 0x5413
++#define TIOCSWINSZ 0x5414
++#define TIOCMGET 0x5415
++#define TIOCMBIS 0x5416
++#define TIOCMBIC 0x5417
++#define TIOCMSET 0x5418
++#define TIOCGSOFTCAR 0x5419
++#define TIOCSSOFTCAR 0x541A
++#define FIONREAD 0x541B
++#define TIOCINQ FIONREAD
++#define TIOCLINUX 0x541C
++#define TIOCCONS 0x541D
++#define TIOCGSERIAL 0x541E
++#define TIOCSSERIAL 0x541F
++#define TIOCPKT 0x5420
++#define FIONBIO 0x5421
++#define TIOCNOTTY 0x5422
++#define TIOCSETD 0x5423
++#define TIOCGETD 0x5424
++#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
++#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
++#define TIOCSBRK 0x5427 /* BSD compatibility */
++#define TIOCCBRK 0x5428 /* BSD compatibility */
++#define TIOCGSID 0x5429 /* Return the session ID of FD */
++#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
++#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
++
++#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
++#define FIOCLEX 0x5451
++#define FIOASYNC 0x5452
++#define TIOCSERCONFIG 0x5453
++#define TIOCSERGWILD 0x5454
++#define TIOCSERSWILD 0x5455
++#define TIOCGLCKTRMIOS 0x5456
++#define TIOCSLCKTRMIOS 0x5457
++#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
++#define TIOCSERGETLSR 0x5459 /* Get line status register */
++#define TIOCSERGETMULTI 0x545A /* Get multiport config */
++#define TIOCSERSETMULTI 0x545B /* Set multiport config */
++
++#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
++#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
++#define FIOQSIZE 0x545E
++
++/* Used for packet mode */
++#define TIOCPKT_DATA 0
++#define TIOCPKT_FLUSHREAD 1
++#define TIOCPKT_FLUSHWRITE 2
++#define TIOCPKT_STOP 4
++#define TIOCPKT_START 8
++#define TIOCPKT_NOSTOP 16
++#define TIOCPKT_DOSTOP 32
++
++#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
++
++#endif /* __ARCH_NIOS2_IOCTLS_H__ */
+diff --git a/include/asm-nios2nommu/ipc.h b/include/asm-nios2nommu/ipc.h
+new file mode 100644
+index 0000000..cb86a31
+--- /dev/null
++++ b/include/asm-nios2nommu/ipc.h
+@@ -0,0 +1,51 @@
++#ifndef __NIOS2_IPC_H__
++#define __NIOS2_IPC_H__
++
++/* Copied from sparc version
++ * These are used to wrap system calls on the Nios.
++ *
++ * See arch/niosnommu/kernel/sys_nios.c for ugly details..
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++struct ipc_kludge {
++ struct msgbuf *msgp;
++ long msgtyp;
++};
++
++#define SEMOP 1
++#define SEMGET 2
++#define SEMCTL 3
++#define MSGSND 11
++#define MSGRCV 12
++#define MSGGET 13
++#define MSGCTL 14
++#define SHMAT 21
++#define SHMDT 22
++#define SHMGET 23
++#define SHMCTL 24
++
++/* Used by the DIPC package, try and avoid reusing it */
++#define DIPC 25
++
++#define IPCCALL(version,op) ((version)<<16 | (op))
++
++#endif
+diff --git a/include/asm-nios2nommu/ipcbuf.h b/include/asm-nios2nommu/ipcbuf.h
+new file mode 100644
+index 0000000..ef59533
+--- /dev/null
++++ b/include/asm-nios2nommu/ipcbuf.h
+@@ -0,0 +1,49 @@
++#ifndef __NIOS2_IPCBUF_H__
++#define __NIOS2_IPCBUF_H__
++
++/* Copied from asm-m68k/ipcbuf.h
++ * The user_ipc_perm structure for Nios architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 32-bit mode_t and seq
++ * - 2 miscellaneous 32-bit values
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++struct ipc64_perm
++{
++ __kernel_key_t key;
++ __kernel_uid32_t uid;
++ __kernel_gid32_t gid;
++ __kernel_uid32_t cuid;
++ __kernel_gid32_t cgid;
++ __kernel_mode_t mode;
++ unsigned short __pad1;
++ unsigned short seq;
++ unsigned short __pad2;
++ unsigned long __unused1;
++ unsigned long __unused2;
++};
++
++#endif /* __NIOS2_IPCBUF_H__ */
+diff --git a/include/asm-nios2nommu/irq.h b/include/asm-nios2nommu/irq.h
+new file mode 100644
+index 0000000..f0e37a2
+--- /dev/null
++++ b/include/asm-nios2nommu/irq.h
+@@ -0,0 +1,181 @@
++/*
++ * 21Mar2001 1.1 dgt/microtronix
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++#ifndef _NIOS2NOMMU_IRQ_H_
++#define _NIOS2NOMMU_IRQ_H_
++
++extern void disable_irq(unsigned int);
++extern void enable_irq(unsigned int);
++
++#include <linux/interrupt.h>
++
++#define SYS_IRQS 32
++#define NR_IRQS SYS_IRQS
++
++/*
++ * Interrupt source definitions
++ * General interrupt sources are the level 1-7.
++ * Adding an interrupt service routine for one of these sources
++ * results in the addition of that routine to a chain of routines.
++ * Each one is called in succession. Each individual interrupt
++ * service routine should determine if the device associated with
++ * that routine requires service.
++ */
++
++#define IRQ01 (1) /* level 1 interrupt */
++#define IRQ02 (2) /* level 2 interrupt */
++#define IRQ03 (3) /* level 3 interrupt */
++#define IRQ04 (4) /* level 4 interrupt */
++#define IRQ05 (5) /* level 5 interrupt */
++#define IRQ06 (6) /* level 6 interrupt */
++#define IRQ07 (7) /* level 7 interrupt */
++#define IRQ08 (8) /* level 8 interrupt */
++#define IRQ09 (9) /* level 9 interrupt */
++#define IRQ0A (10) /* level 10 interrupt */
++#define IRQ0B (11) /* level 11 interrupt */
++#define IRQ0C (12) /* level 12 interrupt */
++#define IRQ0D (13) /* level 13 interrupt */
++#define IRQ0E (14) /* level 14 interrupt */
++#define IRQ0F (15) /* level 15 interrupt */
++#define IRQ10 (16) /* level 16 interrupt */
++#define IRQ12 (17) /* level 17 interrupt */
++#define IRQ13 (18) /* level 18 interrupt */
++#define IRQ14 (19) /* level 19 interrupt */
++#define IRQ15 (20) /* level 20 interrupt */
++#define IRQ16 (21) /* level 21 interrupt */
++#define IRQ17 (22) /* level 22 interrupt */
++#define IRQ18 (23) /* level 23 interrupt */
++#define IRQ19 (24) /* level 24 interrupt */
++#define IRQ1A (25) /* level 25 interrupt */
++#define IRQ1B (26) /* level 26 interrupt */
++#define IRQ1C (27) /* level 27 interrupt */
++#define IRQ1D (28) /* level 28 interrupt */
++#define IRQ1E (29) /* level 29 interrupt */
++#define IRQ1F (30) /* level 30 interrupt */
++#define IRQ20 (31) /* level 31 interrupt */
++#define IRQ21 (32) /* level 32 interrupt */
++
++#define IRQMAX IRQ21
++
++/*
++ * "Generic" interrupt sources
++ */
++
++/*
++ * Machine specific interrupt sources.
++ *
++ * Adding an interrupt service routine for a source with this bit
++ * set indicates a special machine specific interrupt source.
++ * The machine specific files define these sources.
++ *
++ * Removed, they are not used by any one.
++ */
++
++/*
++ * various flags for request_irq()
++ */
++#define IRQ_FLG_LOCK (0x0001) /* handler is not replaceable */
++#define IRQ_FLG_REPLACE (0x0002) /* replace existing handler */
++#define IRQ_FLG_FAST (0x0004)
++#define IRQ_FLG_SLOW (0x0008)
++#define IRQ_FLG_STD (0x8000) /* internally used */
++
++/*
++ * Functions to set and clear the interrupt mask.
++ */
++
++/*
++ * Use a zero to clean the bit.
++ */
++static inline void clrimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "and r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * Use a one to set the bit.
++ */
++static inline void setimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "or r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * This structure is used to chain together the ISRs for a particular
++ * interrupt source (if it supports chaining).
++ */
++typedef struct irq_node {
++ irq_handler_t handler;
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++ struct irq_node *next;
++} irq_node_t;
++
++/*
++ * This function returns a new irq_node_t
++ */
++extern irq_node_t *new_irq_node(void);
++
++/*
++ * This structure has only 4 elements for speed reasons
++ */
++typedef struct irq_hand {
++ irq_handler_t handler;
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++} irq_hand_t;
++
++/* count of spurious interrupts */
++extern volatile unsigned int num_spurious;
++
++#define disable_irq_nosync(i) disable_irq(i)
++
++#ifndef irq_canonicalize
++#define irq_canonicalize(i) (i)
++#endif
++
++#endif /* _NIOS2NOMMU_IRQ_H_ */
+diff --git a/include/asm-nios2nommu/irq_node.h b/include/asm-nios2nommu/irq_node.h
+new file mode 100644
+index 0000000..24f9763
+--- /dev/null
++++ b/include/asm-nios2nommu/irq_node.h
+@@ -0,0 +1,36 @@
++#ifndef _NIOS2NOMMU_IRQNODE_H_
++#define _NIOS2NOMMU_IRQNODE_H_
++
++#include <linux/interrupt.h>
++
++/*
++ * This structure is used to chain together the ISRs for a particular
++ * interrupt source (if it supports chaining).
++ */
++typedef struct irq_node {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++ struct irq_node *next;
++} irq_node_t;
++
++/*
++ * This structure has only 4 elements for speed reasons
++ */
++typedef struct irq_handler {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++} irq_handler_t;
++
++/* count of spurious interrupts */
++extern volatile unsigned int num_spurious;
++
++/*
++ * This function returns a new irq_node_t
++ */
++extern irq_node_t *new_irq_node(void);
++
++#endif /* _NIOS2NOMMU_IRQNODE_H_ */
+diff --git a/include/asm-nios2nommu/irq_regs.h b/include/asm-nios2nommu/irq_regs.h
+new file mode 100644
+index 0000000..3dd9c0b
+--- /dev/null
++++ b/include/asm-nios2nommu/irq_regs.h
+@@ -0,0 +1 @@
++#include <asm-generic/irq_regs.h>
+diff --git a/include/asm-nios2nommu/kdebug.h b/include/asm-nios2nommu/kdebug.h
+new file mode 100644
+index 0000000..6ece1b0
+--- /dev/null
++++ b/include/asm-nios2nommu/kdebug.h
+@@ -0,0 +1 @@
++#include <asm-generic/kdebug.h>
+diff --git a/include/asm-nios2nommu/kmap_types.h b/include/asm-nios2nommu/kmap_types.h
+new file mode 100644
+index 0000000..a26b91d
+--- /dev/null
++++ b/include/asm-nios2nommu/kmap_types.h
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_KMAP_TYPES_H
++#define _ASM_KMAP_TYPES_H
++
++enum km_type {
++ KM_BOUNCE_READ,
++ KM_SKB_SUNRPC_DATA,
++ KM_SKB_DATA_SOFTIRQ,
++ KM_USER0,
++ KM_USER1,
++ KM_BIO_SRC_IRQ,
++ KM_BIO_DST_IRQ,
++ KM_PTE0,
++ KM_PTE1,
++ KM_IRQ0,
++ KM_IRQ1,
++ KM_SOFTIRQ0,
++ KM_SOFTIRQ1,
++ KM_TYPE_NR
++};
++
++#endif
+diff --git a/include/asm-nios2nommu/linkage.h b/include/asm-nios2nommu/linkage.h
+new file mode 100644
+index 0000000..db79297
+--- /dev/null
++++ b/include/asm-nios2nommu/linkage.h
+@@ -0,0 +1,29 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASM_LINKAGE_H
++#define __ASM_LINKAGE_H
++
++#define __ALIGN .align 3
++#define __ALIGN_STR ".align 3"
++
++#endif
+diff --git a/include/asm-nios2nommu/linux_logo.h b/include/asm-nios2nommu/linux_logo.h
+new file mode 100644
+index 0000000..f9d38e7
+--- /dev/null
++++ b/include/asm-nios2nommu/linux_logo.h
+@@ -0,0 +1,953 @@
++/* $Id: linux_logo.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
++ * include/asm-nios/linux_logo.h: This is a linux logo
++ * to be displayed on boot.
++ *
++ * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
++ * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
++ * Copyright (C) 2004 Micrtronix Datacom Ltd.
++ *
++ * You can put anything here, but:
++ * LINUX_LOGO_COLORS has to be less than 224
++ * image size has to be 80x80
++ * values have to start from 0x20
++ * (i.e. RGB(linux_logo_red[0],
++ * linux_logo_green[0],
++ * linux_logo_blue[0]) is color 0x20)
++ * BW image has to be 80x80 as well, with MS bit
++ * on the left
++ * Serial_console ascii image can be any size,
++ * but should contain %s to display the version
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/init.h>
++#include <linux/version.h>
++
++#define linux_logo_banner "Linux/NIOS2 version " UTS_RELEASE
++
++#define __HAVE_ARCH_LINUX_LOGO
++#define __HAVE_ARCH_LINUX_LOGO16
++
++#define LINUX_LOGO_COLORS 221
++
++#ifdef INCLUDE_LINUX_LOGO_DATA
++
++unsigned char linux_logo_red[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x65, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x76, 0x79,
++ 0x62, 0x36, 0x9a, 0xe2, 0xec, 0xe1, 0xb8, 0xd7,
++ 0xaf, 0x25, 0xbc, 0xc0, 0xef, 0xea, 0xe8, 0xe8,
++ 0xf5, 0xf1, 0xda, 0xd3, 0x79, 0xdb, 0xf4, 0xf6,
++ 0xf6, 0xf6, 0xe2, 0x3d, 0xb4, 0xce, 0xe6, 0xee,
++ 0xf6, 0x68, 0xd8, 0xec, 0xf5, 0xc6, 0xc8, 0x9c,
++ 0x89, 0xd2, 0xee, 0xcb, 0xb9, 0xd2, 0x66, 0x5e,
++ 0x8b, 0xbe, 0xa8, 0xd5, 0xca, 0xb6, 0xae, 0x9c,
++ 0xc5, 0xbe, 0xbe, 0xca, 0x90, 0xb2, 0x9a, 0xa8,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfe,
++ 0xf6, 0xec, 0xfe, 0xd2, 0xea, 0xf5, 0xf2, 0xf2,
++ 0xe9, 0xee, 0xf6, 0xf2, 0xee, 0xf6, 0xda, 0xd4,
++ 0xfa, 0xca, 0xf2, 0xf6, 0xfe, 0xf2, 0xda, 0xe4,
++ 0xf6, 0xdd, 0xf2, 0xee, 0xfa, 0xf0, 0x12, 0x4a,
++ 0xd6, 0xf2, 0x8e, 0xf2, 0xf6, 0xf6, 0xb5, 0xf1,
++ 0x26, 0x9a, 0xea, 0xf6, 0xe0, 0xd2, 0x16, 0x9a,
++ 0x2e, 0xd2, 0x70, 0xd6, 0x46, 0x7c, 0xb4, 0x62,
++ 0xda, 0xee, 0xd6, 0xa3, 0x74, 0xa7, 0xa2, 0xe0,
++ 0xae, 0xbe, 0xce, 0xe2, 0xa3, 0x8e, 0x6d, 0x8e,
++ 0x32, 0xaf, 0x50, 0x9e, 0x5b, 0x8a, 0x98, 0x82,
++ 0x7a, 0x82, 0x56, 0x7c, 0x8a, 0x56, 0x5e, 0x86,
++ 0x6a, 0x52, 0x59, 0x64, 0x5e,
++};
++
++unsigned char linux_logo_green[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x62, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x62, 0x5c,
++ 0x4e, 0x26, 0x72, 0xaa, 0xba, 0xaf, 0x90, 0xae,
++ 0x92, 0x1a, 0xa4, 0x85, 0xb6, 0xbe, 0xc3, 0xc8,
++ 0xcf, 0xd0, 0xc2, 0xce, 0x57, 0xa2, 0xd6, 0xda,
++ 0xda, 0xd7, 0xb8, 0x2a, 0x7b, 0x91, 0xae, 0xca,
++ 0xda, 0x45, 0x9e, 0xb2, 0xd7, 0x9b, 0x90, 0x76,
++ 0x5c, 0xa2, 0xbe, 0xa6, 0x85, 0x96, 0x4e, 0x46,
++ 0x66, 0x92, 0x7a, 0x9a, 0x96, 0x9d, 0x9a, 0x6b,
++ 0x8a, 0x8e, 0xb2, 0xca, 0x90, 0xa6, 0x79, 0x7c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfa,
++ 0xea, 0xd7, 0xf6, 0xbc, 0xda, 0xde, 0xda, 0xe6,
++ 0xca, 0xd8, 0xea, 0xe0, 0xcc, 0xf2, 0xce, 0xb2,
++ 0xee, 0xa2, 0xd6, 0xe6, 0xf6, 0xd7, 0xc5, 0xb8,
++ 0xc6, 0xb9, 0xce, 0xde, 0xce, 0xc6, 0x0e, 0x36,
++ 0xae, 0xbe, 0x86, 0xba, 0xbe, 0xe6, 0x8e, 0xc4,
++ 0x1e, 0x8e, 0xae, 0xba, 0xb2, 0xa6, 0x12, 0x7a,
++ 0x20, 0xc6, 0x64, 0xaa, 0x2f, 0x70, 0x85, 0x46,
++ 0xce, 0xd6, 0xa6, 0x6e, 0x51, 0x72, 0x92, 0xa6,
++ 0x87, 0x96, 0xa2, 0xd6, 0x85, 0x7a, 0x6a, 0x6e,
++ 0x22, 0x76, 0x36, 0x76, 0x3c, 0x6e, 0x63, 0x53,
++ 0x66, 0x62, 0x42, 0x50, 0x56, 0x42, 0x56, 0x56,
++ 0x56, 0x3e, 0x51, 0x52, 0x56,
++};
++
++unsigned char linux_logo_blue[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x01, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x06, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x59, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x2e, 0x08,
++ 0x0a, 0x06, 0x0a, 0x0b, 0x0b, 0x0f, 0x0c, 0x0f,
++ 0x3d, 0x09, 0x73, 0x09, 0x0d, 0x0a, 0x10, 0x1e,
++ 0x2d, 0x13, 0x86, 0xba, 0x19, 0x0a, 0x36, 0x3c,
++ 0x26, 0x14, 0x0d, 0x06, 0x07, 0x0a, 0x0b, 0x0f,
++ 0x4a, 0x06, 0x0a, 0x0c, 0x2b, 0x0a, 0x0b, 0x0a,
++ 0x06, 0x0a, 0x0a, 0x11, 0x0b, 0x0a, 0x0a, 0x1e,
++ 0x0f, 0x0d, 0x0a, 0x0b, 0x22, 0x6a, 0x72, 0x0b,
++ 0x0b, 0x22, 0x90, 0xca, 0x90, 0x92, 0x3c, 0x2c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xea,
++ 0xb6, 0x7c, 0xda, 0x8e, 0xa6, 0x87, 0x66, 0xb6,
++ 0x81, 0x6a, 0xc6, 0x9a, 0x5b, 0xd2, 0xb6, 0x6a,
++ 0xca, 0x45, 0x92, 0xb2, 0xca, 0x52, 0x8a, 0x3e,
++ 0x2e, 0x66, 0x66, 0xae, 0x3e, 0x47, 0x06, 0x0e,
++ 0x52, 0x36, 0x6a, 0x0e, 0x0e, 0xbe, 0x2c, 0x0e,
++ 0x0a, 0x5a, 0x0d, 0x0e, 0x3e, 0x0a, 0x06, 0x2e,
++ 0x06, 0x9e, 0x4e, 0x36, 0x06, 0x58, 0x24, 0x06,
++ 0x9e, 0xae, 0x3a, 0x08, 0x08, 0x07, 0x5e, 0x0a,
++ 0x32, 0x2e, 0x2a, 0xb2, 0x43, 0x48, 0x5f, 0x2e,
++ 0x06, 0x06, 0x07, 0x24, 0x06, 0x32, 0x06, 0x06,
++ 0x46, 0x2e, 0x22, 0x06, 0x06, 0x1e, 0x4c, 0x06,
++ 0x3a, 0x22, 0x42, 0x34, 0x42,
++};
++
++unsigned char linux_logo[] __initdata = {
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22,
++ 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
++ 0x26, 0x26, 0x25, 0x28, 0x23, 0x22, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x25, 0x2a, 0x2b, 0x2c, 0x2d, 0x2d,
++ 0x2d, 0x2e, 0x2c, 0x2b, 0x2a, 0x25, 0x28, 0x22,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x24, 0x2a, 0x2c, 0x2f, 0x2c, 0x30, 0x30, 0x24,
++ 0x25, 0x27, 0x2b, 0x2c, 0x2f, 0x31, 0x32, 0x25,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x33, 0x34, 0x35, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x2b, 0x2f, 0x2c,
++ 0x30, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x2d, 0x27, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x31,
++ 0x2d, 0x32, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x28, 0x2a, 0x34,
++ 0x25, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x23, 0x32, 0x27, 0x21, 0x36,
++ 0x2a, 0x2d, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x26, 0x2c, 0x35,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2f, 0x37, 0x32, 0x22,
++ 0x36, 0x35, 0x31, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x22,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x26, 0x38, 0x38, 0x35, 0x25,
++ 0x36, 0x21, 0x2d, 0x2b, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x39, 0x39, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2b, 0x30, 0x28, 0x22,
++ 0x36, 0x36, 0x27, 0x34, 0x30, 0x23, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x26, 0x2d, 0x26, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x22, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2d, 0x33, 0x28, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2b, 0x2c, 0x25, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x36, 0x36,
++ 0x36, 0x21, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x21, 0x23, 0x22, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x28, 0x34, 0x27, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x21, 0x21, 0x24, 0x27, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x27, 0x22, 0x33, 0x24, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x2f, 0x2a, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x30, 0x3a, 0x38, 0x24, 0x24, 0x36, 0x36, 0x36,
++ 0x23, 0x2f, 0x3b, 0x3c, 0x3d, 0x30, 0x25, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x32, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x23,
++ 0x3e, 0x3f, 0x40, 0x3a, 0x22, 0x36, 0x36, 0x21,
++ 0x41, 0x42, 0x43, 0x44, 0x45, 0x3e, 0x23, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x33, 0x28, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x2b,
++ 0x44, 0x40, 0x46, 0x47, 0x35, 0x36, 0x36, 0x26,
++ 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x2e, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x34, 0x36, 0x4d,
++ 0x4e, 0x25, 0x2f, 0x46, 0x4a, 0x22, 0x23, 0x32,
++ 0x4f, 0x50, 0x21, 0x31, 0x51, 0x52, 0x53, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x21, 0x3a,
++ 0x4d, 0x21, 0x31, 0x54, 0x55, 0x28, 0x30, 0x2b,
++ 0x4b, 0x4d, 0x36, 0x23, 0x32, 0x50, 0x3f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x38, 0x23, 0x37,
++ 0x55, 0x36, 0x28, 0x3a, 0x56, 0x57, 0x57, 0x58,
++ 0x3c, 0x4d, 0x36, 0x36, 0x36, 0x40, 0x40, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x29, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x51, 0x23, 0x35,
++ 0x43, 0x25, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
++ 0x5f, 0x60, 0x61, 0x36, 0x31, 0x47, 0x3b, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x2c, 0x25, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x22,
++ 0x40, 0x62, 0x63, 0x5d, 0x64, 0x65, 0x66, 0x67,
++ 0x68, 0x69, 0x66, 0x5e, 0x6a, 0x6b, 0x2a, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x2e, 0x26, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2f, 0x23, 0x36,
++ 0x6c, 0x63, 0x6d, 0x64, 0x5c, 0x66, 0x69, 0x6e,
++ 0x6f, 0x70, 0x71, 0x69, 0x69, 0x72, 0x6c, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x34, 0x27, 0x22,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x34, 0x26, 0x73,
++ 0x74, 0x75, 0x76, 0x64, 0x65, 0x77, 0x69, 0x78,
++ 0x70, 0x71, 0x71, 0x71, 0x72, 0x5f, 0x5e, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x25, 0x38, 0x2a, 0x23,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x33, 0x79,
++ 0x63, 0x7a, 0x7b, 0x5c, 0x66, 0x69, 0x6e, 0x7c,
++ 0x71, 0x71, 0x69, 0x7d, 0x7e, 0x7a, 0x7f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x51, 0x2b, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x32, 0x24,
++ 0x80, 0x81, 0x64, 0x82, 0x77, 0x69, 0x71, 0x71,
++ 0x69, 0x83, 0x84, 0x85, 0x7a, 0x85, 0x86, 0x36,
++ 0x21, 0x2b, 0x23, 0x36, 0x36, 0x39, 0x2e, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2d, 0x33, 0x21,
++ 0x87, 0x88, 0x89, 0x72, 0x67, 0x66, 0x5f, 0x89,
++ 0x8a, 0x63, 0x85, 0x8b, 0x8c, 0x8d, 0x41, 0x36,
++ 0x36, 0x2d, 0x3a, 0x35, 0x36, 0x24, 0x51, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x33, 0x21,
++ 0x55, 0x8e, 0x8f, 0x8a, 0x7d, 0x5e, 0x90, 0x7e,
++ 0x75, 0x75, 0x90, 0x62, 0x40, 0x3f, 0x49, 0x23,
++ 0x36, 0x24, 0x3a, 0x3a, 0x24, 0x36, 0x2e, 0x31,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x33, 0x37, 0x25, 0x22,
++ 0x3b, 0x50, 0x8e, 0x8f, 0x90, 0x7e, 0x90, 0x63,
++ 0x74, 0x91, 0x92, 0x42, 0x93, 0x4b, 0x45, 0x2c,
++ 0x36, 0x36, 0x33, 0x39, 0x21, 0x36, 0x22, 0x51,
++ 0x33, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x27, 0x2e, 0x2e, 0x36, 0x21,
++ 0x94, 0x3f, 0x50, 0x95, 0x96, 0x8f, 0x8f, 0x97,
++ 0x8e, 0x42, 0x50, 0x43, 0x47, 0x48, 0x48, 0x98,
++ 0x21, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39,
++ 0x2e, 0x27, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x24, 0x2b, 0x38, 0x28, 0x36, 0x32,
++ 0x4c, 0x4b, 0x50, 0x50, 0x50, 0x42, 0x42, 0x50,
++ 0x50, 0x40, 0x45, 0x99, 0x48, 0x48, 0x48, 0x48,
++ 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x23,
++ 0x2f, 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x32, 0x51, 0x32, 0x28, 0x21, 0x98,
++ 0x48, 0x47, 0x9a, 0x50, 0x50, 0x50, 0x50, 0x50,
++ 0x9a, 0x4f, 0x9b, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x93, 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2f, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x23, 0x30, 0x2e, 0x2c, 0x36, 0x21, 0x51, 0x9b,
++ 0x48, 0x48, 0x52, 0x3f, 0x50, 0x50, 0x40, 0x4b,
++ 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2d, 0x31, 0x27, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x2c, 0x2d, 0x21, 0x36, 0x28, 0x44, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x46, 0x4f, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x9c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x28, 0x51, 0x39, 0x26, 0x22, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x35, 0x51, 0x28, 0x36, 0x36, 0x9d, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x9b, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4f, 0x28, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x38, 0x2b, 0x25, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x51, 0x25, 0x36, 0x36, 0x23, 0x40, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x9b, 0x99, 0x2b, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x2f, 0x33, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x23, 0x30, 0x34,
++ 0x27, 0x36, 0x36, 0x36, 0x2a, 0x40, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x99, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x47, 0x52,
++ 0x46, 0x4f, 0x37, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x30, 0x34, 0x2a, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x25, 0x39, 0x2c,
++ 0x36, 0x36, 0x36, 0x21, 0x31, 0x4e, 0x9a, 0x4c,
++ 0x47, 0x9b, 0x9b, 0x52, 0x46, 0x4f, 0x52, 0x9b,
++ 0x9b, 0x9b, 0x47, 0x4f, 0x45, 0x9a, 0x93, 0x93,
++ 0x3f, 0x93, 0x98, 0x28, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x28,
++ 0x36, 0x36, 0x36, 0x22, 0x38, 0x98, 0x44, 0x99,
++ 0x9b, 0x48, 0x48, 0x9b, 0x4c, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x52, 0x46, 0x43, 0x93,
++ 0x40, 0x40, 0x43, 0x53, 0x21, 0x23, 0x33, 0x23,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x2f, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x2b, 0x31, 0x36,
++ 0x36, 0x22, 0x36, 0x24, 0x9e, 0x4f, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x9f, 0x52, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x47,
++ 0x4f, 0x9a, 0x3f, 0x46, 0x38, 0x36, 0x21, 0x30,
++ 0x26, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c,
++ 0x25, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2e, 0x33, 0x36,
++ 0x25, 0x25, 0x36, 0x4d, 0x52, 0x48, 0x48, 0x48,
++ 0x47, 0x9f, 0x48, 0x48, 0x48, 0xa0, 0xa1, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x47, 0x44, 0x93, 0x43, 0x23, 0x36, 0x36,
++ 0x26, 0x24, 0x36, 0x36, 0x36, 0x36, 0x28, 0x2f,
++ 0x2a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x51, 0x24, 0x36,
++ 0x2a, 0x36, 0x28, 0x44, 0x48, 0x48, 0x48, 0x48,
++ 0xa3, 0xa4, 0x48, 0x48, 0x9f, 0xa5, 0xa6, 0x9f,
++ 0x48, 0x48, 0x48, 0xa2, 0xa7, 0x47, 0x48, 0x48,
++ 0x48, 0x48, 0x9b, 0x4b, 0x44, 0x37, 0x36, 0x23,
++ 0x28, 0x30, 0x22, 0x36, 0x36, 0x36, 0x36, 0x2d,
++ 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x2b, 0x34, 0x36, 0x25,
++ 0x24, 0x36, 0x4a, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0xa8, 0xa1, 0x48, 0x48, 0x9f, 0xa9, 0xa6, 0x9f,
++ 0x48, 0x48, 0xaa, 0xa1, 0xa5, 0x9f, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x52, 0x3f, 0x21, 0x30,
++ 0x35, 0x25, 0x30, 0x36, 0x36, 0x36, 0x36, 0x32,
++ 0x2d, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x26, 0x2e, 0x35, 0x36, 0x2a,
++ 0x36, 0x24, 0x4f, 0x48, 0x52, 0x52, 0x48, 0x48,
++ 0xab, 0xac, 0xa0, 0x48, 0xad, 0xa6, 0xa6, 0x9f,
++ 0x48, 0xa2, 0xa9, 0xa6, 0xa2, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x47, 0x32, 0x30,
++ 0x2a, 0x23, 0x30, 0x23, 0x36, 0x36, 0x36, 0x21,
++ 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x2a, 0x51, 0x28, 0x28, 0x25,
++ 0x36, 0x3a, 0x48, 0x48, 0xae, 0xaf, 0x48, 0x48,
++ 0xad, 0xac, 0xa1, 0x9f, 0xa2, 0xa9, 0xa9, 0xa2,
++ 0x48, 0xab, 0x78, 0xa7, 0x48, 0x48, 0x48, 0x48,
++ 0x9f, 0x48, 0x48, 0x48, 0x48, 0x48, 0x38, 0x21,
++ 0x36, 0x36, 0x22, 0x27, 0x36, 0x36, 0x36, 0x36,
++ 0x2e, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x25, 0x2c, 0x34, 0x36, 0x30, 0x21,
++ 0x23, 0x43, 0x48, 0x48, 0xb0, 0xb1, 0xb2, 0x9f,
++ 0x48, 0xb3, 0xa5, 0xb3, 0xab, 0xa9, 0xa9, 0xb3,
++ 0xb4, 0xa9, 0xb5, 0xb0, 0x48, 0x48, 0xa0, 0xa5,
++ 0xa1, 0xad, 0x48, 0x48, 0x48, 0x48, 0x94, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2e, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x2a, 0x51, 0x25, 0x21, 0x2a, 0x36,
++ 0x2e, 0x9b, 0x48, 0x48, 0x48, 0xb6, 0xb7, 0xa4,
++ 0xa2, 0xa7, 0xb5, 0x78, 0x6f, 0x6f, 0x6e, 0x6f,
++ 0xa9, 0xb5, 0xab, 0x48, 0x9f, 0xab, 0xa9, 0xa1,
++ 0xaa, 0x48, 0x48, 0x48, 0x48, 0x48, 0x98, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x22, 0x2f, 0x30, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x22, 0x25, 0x2c, 0x34, 0x36, 0x24, 0x28, 0x36,
++ 0x54, 0x48, 0x48, 0x48, 0x48, 0xa2, 0xa8, 0xa1,
++ 0xa5, 0xa6, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x6f, 0x78, 0xa5, 0xa0, 0xa0, 0x78, 0xa6, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x36, 0x36, 0x36, 0x36,
++ 0x21, 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x32, 0x2f, 0x28, 0x36, 0x27, 0x22, 0x21,
++ 0x43, 0x48, 0x4b, 0xa2, 0x9f, 0x48, 0xa2, 0xa1,
++ 0xb8, 0x6e, 0x6e, 0xb5, 0x78, 0x6f, 0x78, 0x78,
++ 0x6e, 0x6f, 0x78, 0xb5, 0xa6, 0xa1, 0xa0, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4b, 0x21,
++ 0x36, 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x25, 0x2c, 0x39, 0x36, 0x36, 0x30, 0x22, 0x25,
++ 0x52, 0x48, 0xa3, 0xb1, 0xb6, 0xb3, 0xaa, 0xac,
++ 0x68, 0x68, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x78, 0x6f, 0x6f, 0xb5, 0xa6, 0xb4, 0x48, 0x9f,
++ 0xb4, 0xb4, 0xa2, 0x9f, 0x48, 0x48, 0x4f, 0x21,
++ 0x36, 0x36, 0x22, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x30, 0x2d, 0x21, 0x36, 0x36, 0x32, 0x23, 0x2a,
++ 0x47, 0x48, 0xa2, 0xb6, 0xaf, 0xb9, 0xba, 0x68,
++ 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x78,
++ 0x6f, 0x6f, 0xa6, 0x6f, 0xb5, 0xa0, 0xaa, 0xa6,
++ 0xa6, 0xa9, 0xb2, 0xb3, 0x48, 0x48, 0x4c, 0x22,
++ 0x36, 0x36, 0x24, 0x23, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0x2e, 0x36, 0x36, 0x23, 0x31, 0x27, 0x39,
++ 0x9b, 0x48, 0x48, 0x48, 0xb0, 0xb0, 0xba, 0xb8,
++ 0x68, 0x68, 0x69, 0x78, 0x6f, 0xb5, 0x6f, 0xb5,
++ 0x78, 0x78, 0x78, 0x78, 0x78, 0xa5, 0xbb, 0xa9,
++ 0xa5, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4c, 0x23,
++ 0x36, 0x36, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x2b, 0x39, 0x36, 0x36, 0x36, 0x26, 0x32, 0x31,
++ 0x9b, 0x48, 0x48, 0x48, 0x48, 0x9f, 0xac, 0x68,
++ 0xbc, 0x6e, 0x6e, 0x6e, 0xb5, 0x6f, 0x6e, 0x6f,
++ 0x6f, 0x78, 0x78, 0xb5, 0xb5, 0xa5, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x46, 0x22,
++ 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x39, 0x36, 0x36, 0x36, 0x36, 0x26, 0x2d,
++ 0x9b, 0x48, 0x48, 0xb0, 0xaa, 0xb3, 0xbd, 0xb8,
++ 0xb8, 0x68, 0x6e, 0x6e, 0xb5, 0x6f, 0x78, 0x6e,
++ 0x78, 0x6f, 0x78, 0x78, 0xb5, 0xa9, 0xa2, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x24, 0x27, 0xbe, 0x24, 0x25, 0x28, 0x21, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x25,
++ 0x39, 0x4d, 0xbf, 0x84, 0x81, 0x57, 0x21, 0x39,
++ 0x52, 0x48, 0x48, 0x62, 0xb1, 0xc0, 0xc1, 0xc1,
++ 0xb8, 0xb8, 0x68, 0xbc, 0x6e, 0x6e, 0x6e, 0x78,
++ 0x78, 0x78, 0x78, 0x6e, 0x78, 0xa9, 0xa0, 0xab,
++ 0xb3, 0xa2, 0x48, 0x48, 0x48, 0x48, 0x53, 0x28,
++ 0x23, 0x36, 0x36, 0x36, 0x21, 0x28, 0x2c, 0x30,
++ 0x21, 0x38, 0x33, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x22, 0x22, 0x28, 0x30,
++ 0x2d, 0xc2, 0x7a, 0xc3, 0xc4, 0xc4, 0x7f, 0x22,
++ 0x51, 0x52, 0x48, 0x48, 0xb0, 0xaa, 0xa8, 0xbd,
++ 0x68, 0xb8, 0xb8, 0x68, 0x68, 0x6e, 0x6e, 0x6f,
++ 0x6e, 0x6e, 0xb5, 0x6e, 0x78, 0xab, 0xab, 0xb5,
++ 0x78, 0xa6, 0xb3, 0xc5, 0xac, 0xac, 0xc6, 0x61,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x30, 0x32,
++ 0x25, 0x4d, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x24, 0x26, 0x30, 0x33, 0x31,
++ 0x4d, 0x91, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0x5a,
++ 0x21, 0x2e, 0x46, 0x48, 0x48, 0x48, 0xb0, 0x64,
++ 0xc1, 0xb8, 0xb8, 0xb8, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6f, 0x71, 0x6f, 0x6f, 0xa6, 0xa0, 0x9f, 0xb4,
++ 0xb4, 0xa0, 0xa1, 0xb7, 0xc7, 0x69, 0x66, 0xc8,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x26, 0x25,
++ 0x83, 0xc9, 0x2c, 0x25, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x30, 0x35, 0x2d, 0x2f, 0x37, 0x4a,
++ 0x60, 0x85, 0xca, 0xcb, 0xc4, 0xc4, 0xc4, 0x82,
++ 0x86, 0x36, 0x32, 0x3f, 0xa2, 0xa4, 0xa8, 0xa9,
++ 0xb8, 0xb8, 0xb8, 0xb8, 0x68, 0x6e, 0x6e, 0x6e,
++ 0x6e, 0x71, 0x6f, 0x71, 0xa6, 0xb4, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0xcc, 0xc3, 0xc7, 0xcd, 0xce,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x57,
++ 0x77, 0x66, 0x34, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x23, 0x30, 0x31, 0xcf, 0x91, 0x7e, 0x90, 0x90,
++ 0x8b, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0x5d, 0xd0, 0x36, 0x24, 0xd1, 0xb1, 0xaf, 0xaa,
++ 0xba, 0xb8, 0x68, 0x68, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6e, 0x6f, 0x6e, 0x78, 0xa1, 0xa9, 0xa1, 0xb0,
++ 0x9f, 0x9b, 0x99, 0xcc, 0x64, 0x5c, 0x8b, 0xd0,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x73, 0x5d,
++ 0x82, 0x5c, 0xd2, 0x2a, 0x23, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x24, 0x2b, 0xcf, 0x8b, 0x5b, 0x76, 0x5b, 0x5b,
++ 0x7b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc7, 0x5e, 0x22, 0x36, 0x21, 0x3a, 0x99, 0x48,
++ 0xa2, 0xa8, 0xb7, 0xc1, 0xb8, 0x68, 0x68, 0xbc,
++ 0x68, 0x6e, 0xb5, 0xb4, 0xb4, 0xab, 0xb5, 0xa1,
++ 0xb0, 0x4f, 0x3f, 0xd3, 0x7b, 0x7b, 0x85, 0x80,
++ 0xbe, 0x36, 0x36, 0x36, 0x21, 0xd4, 0x7e, 0x7b,
++ 0x64, 0x64, 0xd5, 0x35, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x31, 0xd6, 0x5b, 0x64, 0xc3, 0xc3, 0xcb,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x66, 0xd7, 0x36, 0x36, 0x36, 0x2c, 0x4b,
++ 0xd8, 0xd9, 0xb3, 0xa8, 0xbd, 0xbd, 0xbd, 0xbd,
++ 0xa9, 0xab, 0xb3, 0xa5, 0xa2, 0x9f, 0xa2, 0xa1,
++ 0x6a, 0x9a, 0x3f, 0xda, 0x76, 0x76, 0x7a, 0x63,
++ 0xdb, 0xdc, 0x86, 0xdc, 0xdd, 0x90, 0x5b, 0x64,
++ 0xc3, 0xc3, 0xde, 0x2d, 0x27, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x26, 0x2d, 0x91, 0x5b, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc7, 0x83, 0xce, 0x36, 0x36, 0x36, 0x30,
++ 0xb1, 0xd9, 0x48, 0xa1, 0xb2, 0xb0, 0xb0, 0xb3,
++ 0xa2, 0x48, 0xa7, 0xbd, 0xa9, 0xa2, 0x48, 0x9f,
++ 0xaa, 0x9a, 0x3f, 0xb1, 0x5b, 0x7b, 0xdf, 0x85,
++ 0x7e, 0x90, 0x63, 0x90, 0x85, 0x5b, 0xc3, 0xc4,
++ 0xc4, 0xcb, 0x5d, 0xd5, 0x39, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe0, 0xdf, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x88, 0x36, 0x36, 0x36, 0x36,
++ 0x2d, 0x9b, 0x48, 0xb9, 0xaf, 0xa2, 0xa2, 0xb9,
++ 0xa8, 0x9f, 0x48, 0xa7, 0xb7, 0xd9, 0x48, 0x48,
++ 0x9b, 0x45, 0x3f, 0xe1, 0x6d, 0x7b, 0xca, 0xdf,
++ 0x7a, 0x8b, 0x8b, 0x7a, 0x5b, 0x64, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc3, 0xe2, 0x37, 0x35, 0x26, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2e, 0xe0, 0x7a, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x72, 0x73, 0x36, 0x36, 0x36,
++ 0x24, 0x52, 0x48, 0xa3, 0xaf, 0x9f, 0x48, 0xb6,
++ 0xaf, 0xa2, 0x48, 0x9f, 0xe3, 0xd8, 0x48, 0x48,
++ 0x48, 0x46, 0x42, 0xd6, 0x7a, 0x7b, 0x64, 0x7b,
++ 0x76, 0x5b, 0x5b, 0x76, 0x7b, 0xc3, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0x64, 0xe2, 0x4d, 0x2c, 0x27,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x8b, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc7, 0x89, 0xbe, 0x36, 0x36,
++ 0x32, 0x47, 0x48, 0x4f, 0xa0, 0x48, 0x48, 0xe3,
++ 0x92, 0x9f, 0x48, 0x9f, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4b, 0x2f, 0x8f, 0x7a, 0x7b, 0xc3, 0xcb,
++ 0xc3, 0x64, 0x64, 0xc3, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x5d, 0xe5, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x85, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x57, 0x27, 0x4d,
++ 0x4b, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x99, 0x34, 0xbe, 0xdb, 0x7a, 0x7b, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xe4,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe4, 0x85, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc7, 0x5f, 0x92, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x44,
++ 0x35, 0x36, 0xce, 0xdd, 0x7a, 0x7b, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0xc3, 0xe1,
++ 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x30, 0x2f, 0xd6, 0x8b, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x89, 0x45,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x4e, 0x25,
++ 0x36, 0x36, 0x61, 0xdb, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0xdf, 0xe5,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xe6, 0x63, 0xdf, 0xc3, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x72, 0x81, 0xe7,
++ 0x46, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x3f, 0x2c, 0x36, 0x36,
++ 0x36, 0x36, 0xe8, 0x8f, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc3, 0xca, 0x8b, 0xcf, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x96, 0x75, 0xca, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0x81, 0xdb,
++ 0x73, 0x3b, 0x44, 0x9b, 0x48, 0x48, 0x48, 0x9b,
++ 0x99, 0x43, 0x94, 0x2c, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x73, 0xdb, 0x7a, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x64, 0x76, 0x7a, 0x91, 0xd5, 0x31, 0x30,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x39, 0x97, 0x75, 0xdf, 0x7b, 0x64, 0xc3, 0xc3,
++ 0xcb, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x7b, 0x7a, 0xe9,
++ 0xea, 0x36, 0x21, 0x26, 0x2b, 0x39, 0x33, 0x30,
++ 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xdd, 0x8b, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x64, 0x64,
++ 0x76, 0x85, 0xe0, 0xd5, 0x34, 0x2b, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xeb, 0x63, 0x7e, 0x7a, 0x6d, 0xdf, 0x5b,
++ 0x76, 0x7b, 0x64, 0x64, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x76, 0x85, 0xdb,
++ 0x79, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xec, 0xdd, 0x75, 0x76, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0xc3, 0x64, 0x76, 0xdf, 0x8b,
++ 0xd6, 0xd5, 0x2f, 0x35, 0x30, 0x24, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x31, 0xed, 0xeb, 0xdd, 0x74, 0x63, 0x90,
++ 0x7e, 0x75, 0x8b, 0x6d, 0xdf, 0x76, 0x64, 0xc3,
++ 0xcb, 0xcb, 0xcb, 0xcb, 0x64, 0x7a, 0x84, 0xee,
++ 0x79, 0xbe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xee, 0x63, 0x6d, 0x7b, 0x64,
++ 0xcb, 0xc3, 0x64, 0x7b, 0xdf, 0x75, 0x63, 0x96,
++ 0x38, 0x39, 0x2a, 0x24, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x27, 0x35, 0x2d, 0x41, 0xd5, 0xe7, 0x8f,
++ 0xdb, 0xdd, 0xe9, 0x74, 0x84, 0x90, 0x85, 0x6d,
++ 0x5b, 0x7b, 0x7b, 0xca, 0x6d, 0x90, 0xdb, 0xef,
++ 0xec, 0x22, 0x36, 0x36, 0x28, 0x30, 0x30, 0x30,
++ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x25, 0x36,
++ 0x36, 0x21, 0xd4, 0x80, 0xe9, 0x7e, 0x6d, 0x76,
++ 0xca, 0x76, 0x6d, 0x85, 0x63, 0xdb, 0xd5, 0x34,
++ 0x33, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x24, 0x27, 0x2a, 0x35, 0x2e, 0x2f,
++ 0x41, 0xf0, 0xf1, 0x6c, 0x80, 0xee, 0xdb, 0x74,
++ 0x84, 0x90, 0x75, 0x7e, 0x74, 0x8f, 0xef, 0x79,
++ 0xe8, 0x2b, 0x9d, 0x41, 0x2f, 0x34, 0x2d, 0x2d,
++ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x34, 0x2f, 0x38,
++ 0x4d, 0x37, 0xf2, 0xf3, 0x8f, 0x74, 0x63, 0x7e,
++ 0x75, 0x7e, 0x63, 0xe9, 0x88, 0xe6, 0x31, 0x2a,
++ 0x24, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x30,
++ 0x33, 0x39, 0x2e, 0x51, 0x41, 0xd2, 0x6c, 0xf3,
++ 0x80, 0xee, 0xee, 0xee, 0xf4, 0xf3, 0xd7, 0xf5,
++ 0x41, 0x34, 0x35, 0x32, 0x30, 0x27, 0x27, 0x27,
++ 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x30, 0x2a,
++ 0x2b, 0x34, 0xf6, 0xec, 0xf7, 0x8f, 0xdd, 0xe9,
++ 0xe9, 0xdd, 0xee, 0x6c, 0x41, 0x39, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22,
++ 0x28, 0x24, 0x26, 0x2a, 0x33, 0x2c, 0x2f, 0x41,
++ 0xf8, 0xd7, 0x79, 0x79, 0x79, 0xec, 0xf9, 0x51,
++ 0x39, 0x30, 0x24, 0x23, 0x22, 0x22, 0x22, 0x22,
++ 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23,
++ 0x24, 0x2a, 0x31, 0xfa, 0xea, 0x79, 0xf3, 0x80,
++ 0xf7, 0xdc, 0xfb, 0x2f, 0x35, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x28, 0x25, 0x30, 0x2b,
++ 0x31, 0x2f, 0xf6, 0xfa, 0xfa, 0x2f, 0x2e, 0x33,
++ 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x27, 0x35, 0x34, 0xfa, 0xfa, 0xfa,
++ 0xfc, 0xf6, 0x2e, 0x33, 0x25, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x23, 0x28,
++ 0x26, 0x30, 0x32, 0x2b, 0x33, 0x2a, 0x26, 0x28,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x25, 0x30, 0x33, 0x35, 0x35,
++ 0x2b, 0x2a, 0x26, 0x28, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x21, 0x22, 0x23, 0x28, 0x28, 0x23, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x23, 0x28, 0x24, 0x24,
++ 0x28, 0x23, 0x22, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++};
++
++unsigned char linux_logo16[1];
++
++#endif /* INCLUDE_LINUX_LOGO_DATA */
++
++#include <linux/linux_logo.h>
++
+diff --git a/include/asm-nios2nommu/local.h b/include/asm-nios2nommu/local.h
+new file mode 100644
+index 0000000..5ed7d1c
+--- /dev/null
++++ b/include/asm-nios2nommu/local.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_LOCAL_H
++#define __NIOS2NOMMU_LOCAL_H
++
++#include <asm-generic/local.h>
++
++#endif /* __NIOS2NOMMU_LOCAL_H */
+diff --git a/include/asm-nios2nommu/mc146818rtc.h b/include/asm-nios2nommu/mc146818rtc.h
+new file mode 100644
+index 0000000..3492fc0
+--- /dev/null
++++ b/include/asm-nios2nommu/mc146818rtc.h
+@@ -0,0 +1,29 @@
++/*
++ * Machine dependent access functions for RTC registers.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_MC146818RTC_H
++#define _NIOS2_MC146818RTC_H
++
++/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
++
++#endif /* _NIOS2_MC146818RTC_H */
+diff --git a/include/asm-nios2nommu/mman.h b/include/asm-nios2nommu/mman.h
+new file mode 100644
+index 0000000..516ab26
+--- /dev/null
++++ b/include/asm-nios2nommu/mman.h
+@@ -0,0 +1,68 @@
++/*
++ * Copied from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_MMAN_H__
++#define __NIOS2_MMAN_H__
++
++#define PROT_READ 0x1 /* page can be read */
++#define PROT_WRITE 0x2 /* page can be written */
++#define PROT_EXEC 0x4 /* page can be executed */
++#define PROT_SEM 0x8 /* page may be used for atomic ops */
++#define PROT_NONE 0x0 /* page can not be accessed */
++#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
++#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
++
++#define MAP_SHARED 0x01 /* Share changes */
++#define MAP_PRIVATE 0x02 /* Changes are private */
++#define MAP_TYPE 0x0f /* Mask for type of mapping */
++#define MAP_FIXED 0x10 /* Interpret addr exactly */
++#define MAP_ANONYMOUS 0x20 /* don't use a file */
++
++#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
++#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
++#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
++#define MAP_LOCKED 0x2000 /* pages are locked */
++#define MAP_NORESERVE 0x4000 /* don't check for reservations */
++#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
++#define MAP_NONBLOCK 0x10000 /* do not block on IO */
++
++#define MS_ASYNC 1 /* sync memory asynchronously */
++#define MS_INVALIDATE 2 /* invalidate the caches */
++#define MS_SYNC 4 /* synchronous memory sync */
++
++#define MCL_CURRENT 1 /* lock all current mappings */
++#define MCL_FUTURE 2 /* lock all future mappings */
++
++#define MADV_NORMAL 0x0 /* default page-in behavior */
++#define MADV_RANDOM 0x1 /* page-in minimum required */
++#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
++#define MADV_WILLNEED 0x3 /* pre-fault pages */
++#define MADV_DONTNEED 0x4 /* discard these pages */
++
++/* compatibility flags */
++#define MAP_ANON MAP_ANONYMOUS
++#define MAP_FILE 0
++
++#endif /* __NIOS2_MMAN_H__ */
++
+diff --git a/include/asm-nios2nommu/mmu.h b/include/asm-nios2nommu/mmu.h
+new file mode 100644
+index 0000000..b6e579d
+--- /dev/null
++++ b/include/asm-nios2nommu/mmu.h
+@@ -0,0 +1,36 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_H
++#define __NIOS2NOMMU_MMU_H
++
++/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
++
++typedef struct {
++ struct vm_list_struct *vmlist;
++ unsigned long end_brk;
++} mm_context_t;
++
++#endif /* __NIOS2NOMMU_MMU_H */
+diff --git a/include/asm-nios2nommu/mmu_context.h b/include/asm-nios2nommu/mmu_context.h
+new file mode 100644
+index 0000000..795cd09
+--- /dev/null
++++ b/include/asm-nios2nommu/mmu_context.h
+@@ -0,0 +1,57 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_CONTEXT_H
++#define __NIOS2NOMMU_MMU_CONTEXT_H
++
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/pgalloc.h>
++
++static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
++{
++}
++
++extern inline int
++init_new_context(struct task_struct *tsk, struct mm_struct *mm)
++{
++ // mm->context = virt_to_phys(mm->pgd);
++ return(0);
++}
++
++#define destroy_context(mm) do { } while(0)
++
++static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
++{
++}
++
++#define deactivate_mm(tsk,mm) do { } while (0)
++
++extern inline void activate_mm(struct mm_struct *prev_mm,
++ struct mm_struct *next_mm)
++{
++}
++
++#endif
+diff --git a/include/asm-nios2nommu/module.h b/include/asm-nios2nommu/module.h
+new file mode 100644
+index 0000000..864f335
+--- /dev/null
++++ b/include/asm-nios2nommu/module.h
+@@ -0,0 +1,36 @@
++#ifndef _NIOS2_MODULE_H
++#define _NIOS2_MODULE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/module.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct mod_arch_specific
++{
++};
++
++#define Elf_Shdr Elf32_Shdr
++#define Elf_Sym Elf32_Sym
++#define Elf_Ehdr Elf32_Ehdr
++
++#endif /* _NIOS_MODULE_H */
+diff --git a/include/asm-nios2nommu/msgbuf.h b/include/asm-nios2nommu/msgbuf.h
+new file mode 100644
+index 0000000..4d090f7
+--- /dev/null
++++ b/include/asm-nios2nommu/msgbuf.h
+@@ -0,0 +1,56 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_MSGBUF_H
++#define _NIOS2_MSGBUF_H
++
++/*
++ * The msqid64_ds structure for nios2 architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct msqid64_ds {
++ struct ipc64_perm msg_perm;
++ __kernel_time_t msg_stime; /* last msgsnd time */
++ unsigned long __unused1;
++ __kernel_time_t msg_rtime; /* last msgrcv time */
++ unsigned long __unused2;
++ __kernel_time_t msg_ctime; /* last change time */
++ unsigned long __unused3;
++ unsigned long msg_cbytes; /* current number of bytes on queue */
++ unsigned long msg_qnum; /* number of messages in queue */
++ unsigned long msg_qbytes; /* max number of bytes on queue */
++ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
++ __kernel_pid_t msg_lrpid; /* last receive pid */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++#endif /* _NIOS2_MSGBUF_H */
++
+diff --git a/include/asm-nios2nommu/mutex.h b/include/asm-nios2nommu/mutex.h
+new file mode 100644
+index 0000000..458c1f7
+--- /dev/null
++++ b/include/asm-nios2nommu/mutex.h
+@@ -0,0 +1,9 @@
++/*
++ * Pull in the generic implementation for the mutex fastpath.
++ *
++ * TODO: implement optimized primitives instead, or leave the generic
++ * implementation in place, or pick the atomic_xchg() based generic
++ * implementation. (see asm-generic/mutex-xchg.h for details)
++ */
++
++#include <asm-generic/mutex-dec.h>
+diff --git a/include/asm-nios2nommu/namei.h b/include/asm-nios2nommu/namei.h
+new file mode 100644
+index 0000000..d925c4e
+--- /dev/null
++++ b/include/asm-nios2nommu/namei.h
+@@ -0,0 +1,36 @@
++/*
++ * linux/include/asm-nios/namei.h
++ * Moved from m68k version
++ * Included from linux/fs/namei.c
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_NAMEI_H
++#define __NIOS2_NAMEI_H
++
++/* This dummy routine maybe changed to something useful
++ * for /usr/gnemul/ emulation stuff.
++ * Look at asm-sparc/namei.h for details.
++ */
++
++#define __emul_prefix() NULL
++
++#endif
+diff --git a/include/asm-nios2nommu/ndma.h b/include/asm-nios2nommu/ndma.h
+new file mode 100644
+index 0000000..6b4604d
+--- /dev/null
++++ b/include/asm-nios2nommu/ndma.h
+@@ -0,0 +1,64 @@
++#ifndef __NDMA_H__
++ #define __NDMA_H__
++
++ #ifndef __ASSEMBLY__
++
++// DMA Registers
++typedef volatile struct
++{
++ int np_dmastatus; // status register
++ int np_dmareadaddress; // read address
++ int np_dmawriteaddress; // write address
++ int np_dmalength; // length in bytes
++ int np_dmareserved1; // reserved
++ int np_dmareserved2; // reserved
++ int np_dmacontrol; // control register
++ int np_dmareserved3; // control register alternate
++} np_dma;
++
++// DMA Register Bits
++enum
++{
++ np_dmacontrol_byte_bit = 0, // Byte transaction
++ np_dmacontrol_hw_bit = 1, // Half-word transaction
++ np_dmacontrol_word_bit = 2, // Word transaction
++ np_dmacontrol_go_bit = 3, // enable execution
++ np_dmacontrol_i_en_bit = 4, // enable interrupt
++ np_dmacontrol_reen_bit = 5, // Enable read end-of-packet
++ np_dmacontrol_ween_bit = 6, // Enable write end-of-packet
++ np_dmacontrol_leen_bit = 7, // Enable length=0 transaction end
++ np_dmacontrol_rcon_bit = 8, // Read from a fixed address
++ np_dmacontrol_wcon_bit = 9, // Write to a fixed address
++ np_dmacontrol_doubleword_bit = 10, // Double-word transaction
++ np_dmacontrol_quadword_bit = 11, // Quad-word transaction
++
++ np_dmastatus_done_bit = 0, // 1 when done. Status write clears.
++ np_dmastatus_busy_bit = 1, // 1 when busy.
++ np_dmastatus_reop_bit = 2, // read-eop received
++ np_dmastatus_weop_bit = 3, // write-eop received
++ np_dmastatus_len_bit = 4, // requested length transacted
++
++ np_dmacontrol_byte_mask = (1 << 0), // Byte transaction
++ np_dmacontrol_hw_mask = (1 << 1), // Half-word transaction
++ np_dmacontrol_word_mask = (1 << 2), // Word transaction
++ np_dmacontrol_go_mask = (1 << 3), // enable execution
++ np_dmacontrol_i_en_mask = (1 << 4), // enable interrupt
++ np_dmacontrol_reen_mask = (1 << 5), // Enable read end-of-packet
++ np_dmacontrol_ween_mask = (1 << 6), // Enable write end-of-packet
++ np_dmacontrol_leen_mask = (1 << 7), // Enable length=0 transaction end
++ np_dmacontrol_rcon_mask = (1 << 8), // Read from a fixed address
++ np_dmacontrol_wcon_mask = (1 << 9), // Write to a fixed address
++ np_dmacontrol_doubleword_mask = (1 << 10), // Double-word transaction
++ np_dmacontrol_quadword_mask = (1 << 11), // Quad-word transaction
++
++ np_dmastatus_done_mask = (1 << 0), // 1 when done. Status write clears.
++ np_dmastatus_busy_mask = (1 << 1), // 1 when busy.
++ np_dmastatus_reop_mask = (1 << 2), // read-eop received
++ np_dmastatus_weop_mask = (1 << 3), // write-eop received
++ np_dmastatus_len_mask = (1 << 4), // requested length transacted
++};
++
++ #endif /* __ASSEMBLY__ */
++
++#endif
++/* End of File */
+diff --git a/include/asm-nios2nommu/nios.h b/include/asm-nios2nommu/nios.h
+new file mode 100644
+index 0000000..df17672
+--- /dev/null
++++ b/include/asm-nios2nommu/nios.h
+@@ -0,0 +1,7 @@
++#ifndef __NIOS_H__
++#define __NIOS_H__
++
++#include <nios2_system.h>
++
++#endif
++
+diff --git a/include/asm-nios2nommu/page.h b/include/asm-nios2nommu/page.h
+new file mode 100644
+index 0000000..764e73c
+--- /dev/null
++++ b/include/asm-nios2nommu/page.h
+@@ -0,0 +1,124 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_PAGE_H
++#define _NIOS2_PAGE_H
++
++/* copied from m68knommu arch */
++
++/* PAGE_SHIFT determines the page size */
++
++#define PAGE_SHIFT (12)
++#define PAGE_SIZE (1UL << PAGE_SHIFT)
++#define PAGE_MASK (~(PAGE_SIZE-1))
++
++#ifdef __KERNEL__
++
++#include <asm/setup.h>
++
++#if PAGE_SHIFT < 13
++#define THREAD_SIZE (8192)
++#else
++#define THREAD_SIZE PAGE_SIZE
++#endif
++
++#ifndef __ASSEMBLY__
++
++#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
++#define free_user_page(page, addr) free_page(addr)
++
++#define clear_page(page) memset((page), 0, PAGE_SIZE)
++#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
++
++#define clear_user_page(page, vaddr, pg) clear_page(page)
++#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
++
++/*
++ * These are used to make use of C type-checking..
++ */
++typedef struct { unsigned long pte; } pte_t;
++typedef struct { unsigned long pmd[16]; } pmd_t;
++typedef struct { unsigned long pgd; } pgd_t;
++typedef struct { unsigned long pgprot; } pgprot_t;
++
++#define pte_val(x) ((x).pte)
++#define pmd_val(x) ((&x)->pmd[0])
++#define pgd_val(x) ((x).pgd)
++#define pgprot_val(x) ((x).pgprot)
++
++#define __pte(x) ((pte_t) { (x) } )
++#define __pmd(x) ((pmd_t) { (x) } )
++#define __pgd(x) ((pgd_t) { (x) } )
++#define __pgprot(x) ((pgprot_t) { (x) } )
++
++/* to align the pointer to the (next) page boundary */
++#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
++
++extern unsigned long memory_start;
++extern unsigned long memory_end;
++
++#endif /* !__ASSEMBLY__ */
++#include <asm/nios.h>
++#define PAGE_OFFSET ((int)(nasys_program_mem))
++
++#ifndef __ASSEMBLY__
++
++#define __pa(vaddr) virt_to_phys((void *)(vaddr))
++#define __va(paddr) phys_to_virt((unsigned long)(paddr))
++
++#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
++
++#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
++#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
++
++#define virt_to_page(addr) ((void*) addr < (void*) memory_end ? mem_map + \
++ (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) : 0UL)
++#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
++#define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
++
++#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
++#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
++#define pfn_valid(pfn) ((pfn) < max_mapnr)
++
++#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
++ ((void *)(kaddr) < (void *)memory_end))
++
++#ifdef CONFIG_NO_KERNEL_MSG
++#define BUG_PRINT()
++#else
++#define BUG_PRINT() printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__)
++#endif
++
++#ifdef na_cpu_oci_core
++#define BUG_PANIC() asm volatile ("break") /* drop to debugger */
++#else
++// #define BUG_PANIC() while(1)
++#define BUG_PANIC() panic("BUG!")
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++#include <asm-generic/page.h>
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_PAGE_H */
+diff --git a/include/asm-nios2nommu/param.h b/include/asm-nios2nommu/param.h
+new file mode 100644
+index 0000000..e75a355
+--- /dev/null
++++ b/include/asm-nios2nommu/param.h
+@@ -0,0 +1,49 @@
++#ifndef _NIOS_PARAM_H
++#define _NIOS_PARAM_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/param.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifndef HZ
++#define HZ 100
++#endif
++
++#ifdef __KERNEL__
++#define USER_HZ HZ
++#define CLOCKS_PER_SEC (USER_HZ)
++#endif
++
++#define EXEC_PAGESIZE 4096
++
++#ifndef NGROUPS
++#define NGROUPS 32
++#endif
++
++#ifndef NOGROUP
++#define NOGROUP (-1)
++#endif
++
++#define MAXHOSTNAMELEN 64 /* max length of hostname */
++
++#endif
+diff --git a/include/asm-nios2nommu/pci.h b/include/asm-nios2nommu/pci.h
+new file mode 100644
+index 0000000..be3b3b2
+--- /dev/null
++++ b/include/asm-nios2nommu/pci.h
+@@ -0,0 +1,126 @@
++#ifndef __ASM_SH_PCI_H
++#define __ASM_SH_PCI_H
++
++#ifdef __KERNEL__
++
++#include <linux/dma-mapping.h>
++
++/* Can be used to override the logic in pci_scan_bus for skipping
++ already-configured bus numbers - to be used for buggy BIOSes
++ or architectures with incomplete PCI setup by the loader */
++
++#define pcibios_assign_all_busses() 1
++#define pcibios_scan_all_fns(a, b) 0
++
++/*
++ * A board can define one or more PCI channels that represent built-in (or
++ * external) PCI controllers.
++ */
++struct pci_channel {
++ struct pci_ops *pci_ops;
++ struct resource *io_resource;
++ struct resource *mem_resource;
++ int first_devfn;
++ int last_devfn;
++};
++
++/*
++ * Each board initializes this array and terminates it with a NULL entry.
++ */
++extern struct pci_channel board_pci_channels[];
++
++#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start
++#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start
++
++struct pci_dev;
++
++extern void pcibios_set_master(struct pci_dev *dev);
++
++static inline void pcibios_penalize_isa_irq(int irq, int active)
++{
++ /* We don't do dynamic PCI IRQ allocation */
++}
++
++/* Dynamic DMA mapping stuff.
++ * SuperH has everything mapped statically like x86.
++ */
++
++/* The PCI address space does equal the physical memory
++ * address space. The networking and block device layers use
++ * this boolean for bounce buffer decisions.
++ */
++#define PCI_DMA_BUS_IS_PHYS (1)
++
++#include <linux/types.h>
++#include <linux/slab.h>
++#include <asm/scatterlist.h>
++#include <linux/string.h>
++#include <asm/io.h>
++
++/* pci_unmap_{single,page} being a nop depends upon the
++ * configuration.
++ */
++#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
++#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
++ dma_addr_t ADDR_NAME;
++#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
++ __u32 LEN_NAME;
++#define pci_unmap_addr(PTR, ADDR_NAME) \
++ ((PTR)->ADDR_NAME)
++#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
++ (((PTR)->ADDR_NAME) = (VAL))
++#define pci_unmap_len(PTR, LEN_NAME) \
++ ((PTR)->LEN_NAME)
++#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
++ (((PTR)->LEN_NAME) = (VAL))
++#else
++#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
++#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
++#define pci_unmap_addr(PTR, ADDR_NAME) (0)
++#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
++#define pci_unmap_len(PTR, LEN_NAME) (0)
++#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
++#endif
++
++/* Not supporting more than 32-bit PCI bus addresses now, but
++ * must satisfy references to this function. Change if needed.
++ */
++#define pci_dac_dma_supported(pci_dev, mask) (0)
++
++/* These macros should be used after a pci_map_sg call has been done
++ * to get bus addresses of each of the SG entries and their lengths.
++ * You should only work with the number of sg entries pci_map_sg
++ * returns, or alternatively stop on the first sg_dma_len(sg) which
++ * is 0.
++ */
++#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address))
++#define sg_dma_len(sg) ((sg)->length)
++
++#ifdef CONFIG_PCI
++static inline void pci_dma_burst_advice(struct pci_dev *pdev,
++ enum pci_dma_burst_strategy *strat,
++ unsigned long *strategy_parameter)
++{
++ *strat = PCI_DMA_BURST_INFINITY;
++ *strategy_parameter = ~0UL;
++}
++#endif
++
++/* Board-specific fixup routines. */
++extern void pcibios_fixup(void);
++extern void pcibios_fixup_irqs(void);
++
++#ifdef CONFIG_PCI_AUTO
++extern int pciauto_assign_resources(int busno, struct pci_channel *hose);
++#endif
++
++#endif /* __KERNEL__ */
++
++/* generic pci stuff */
++#include <asm-generic/pci.h>
++
++/* generic DMA-mapping stuff */
++#include <asm-generic/pci-dma-compat.h>
++
++#endif /* __ASM_SH_PCI_H */
++
+diff --git a/include/asm-nios2nommu/percpu.h b/include/asm-nios2nommu/percpu.h
+new file mode 100644
+index 0000000..cd6d4a3
+--- /dev/null
++++ b/include/asm-nios2nommu/percpu.h
+@@ -0,0 +1,30 @@
++#ifndef __ARCH_NIOS2NOMMU_PERCPU__
++#define __ARCH_NIOS2NOMMU_PERCPU__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/percpu.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/percpu.h>
++
++#endif /* __ARCH_NIOS2NOMMU_PERCPU__ */
+diff --git a/include/asm-nios2nommu/pgalloc.h b/include/asm-nios2nommu/pgalloc.h
+new file mode 100644
+index 0000000..a997ada
+--- /dev/null
++++ b/include/asm-nios2nommu/pgalloc.h
+@@ -0,0 +1,32 @@
++#ifndef _NIOS2NOMMU_PGALLOC_H
++#define _NIOS2NOMMU_PGALLOC_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgalloc.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/setup.h>
++
++#define check_pgt_cache() do { } while (0)
++
++#endif /* _NIOS2NOMMU_PGALLOC_H */
+diff --git a/include/asm-nios2nommu/pgtable.h b/include/asm-nios2nommu/pgtable.h
+new file mode 100644
+index 0000000..4124a33
+--- /dev/null
++++ b/include/asm-nios2nommu/pgtable.h
+@@ -0,0 +1,112 @@
++#ifndef _NIOS_PGTABLE_H
++#define _NIOS_PGTABLE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgtable.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm-generic/4level-fixup.h>
++
++//vic - this bit copied from m68knommu version
++#include <asm/setup.h>
++#include <asm/io.h>
++#include <linux/sched.h>
++
++typedef pte_t *pte_addr_t;
++
++#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
++#define pgd_none(pgd) (0)
++#define pgd_bad(pgd) (0)
++#define pgd_clear(pgdp)
++#define kern_addr_valid(addr) (1)
++#define pmd_offset(a, b) ((void *)0)
++
++#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
++//vic - this bit copied from m68knommu version
++
++extern void paging_init(void);
++#define swapper_pg_dir ((pgd_t *) 0)
++
++#define __swp_type(x) (0)
++#define __swp_offset(x) (0)
++#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
++#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
++#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
++
++static inline int pte_file(pte_t pte) { return 0; }
++
++/*
++ * ZERO_PAGE is a global shared page that is always zero: used
++ * for zero-mapped memory areas etc..
++ */
++#define ZERO_PAGE(vaddr) (virt_to_page(0))
++
++extern unsigned int kobjsize(const void *objp);
++extern int is_in_rom(unsigned long);
++
++/*
++ * No page table caches to initialise
++ */
++#define pgtable_cache_init() do { } while (0)
++
++#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
++ remap_pfn_range(vma, vaddr, pfn, size, prot)
++
++extern inline void flush_cache_mm(struct mm_struct *mm)
++{
++}
++
++extern inline void flush_cache_range(struct mm_struct *mm,
++ unsigned long start,
++ unsigned long end)
++{
++}
++
++/* Push the page at kernel virtual address and clear the icache */
++extern inline void flush_page_to_ram (unsigned long address)
++{
++}
++
++/* Push n pages at kernel virtual address and clear the icache */
++extern inline void flush_pages_to_ram (unsigned long address, int n)
++{
++}
++
++/*
++ * All 32bit addresses are effectively valid for vmalloc...
++ * Sort of meaningless for non-VM targets.
++ */
++#define VMALLOC_START 0
++#define VMALLOC_END 0xffffffff
++
++#define arch_enter_lazy_mmu_mode() do {} while (0)
++#define arch_leave_lazy_mmu_mode() do {} while (0)
++#define arch_flush_lazy_mmu_mode() do {} while (0)
++#define arch_enter_lazy_cpu_mode() do {} while (0)
++#define arch_leave_lazy_cpu_mode() do {} while (0)
++#define arch_flush_lazy_cpu_mode() do {} while (0)
++
++#endif /* _NIOS_PGTABLE_H */
+diff --git a/include/asm-nios2nommu/pio_struct.h b/include/asm-nios2nommu/pio_struct.h
+new file mode 100644
+index 0000000..8ce5176
+--- /dev/null
++++ b/include/asm-nios2nommu/pio_struct.h
+@@ -0,0 +1,14 @@
++// PIO Peripheral
++
++// PIO Registers
++typedef volatile struct
++ {
++ int np_piodata; // read/write, up to 32 bits
++ int np_piodirection; // write/readable, up to 32 bits, 1->output bit
++ int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
++ int np_pioedgecapture; // read, up to 32 bits, cleared by any write
++ } np_pio;
++
++// PIO Routines
++void nr_pio_showhex(int value); // shows low byte on pio named na_seven_seg_pio
++
+diff --git a/include/asm-nios2nommu/poll.h b/include/asm-nios2nommu/poll.h
+new file mode 100644
+index 0000000..f6b9ab8
+--- /dev/null
++++ b/include/asm-nios2nommu/poll.h
+@@ -0,0 +1,48 @@
++#ifndef __NIOS2_POLL_H
++#define __NIOS2_POLL_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/poll.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define POLLIN 1
++#define POLLPRI 2
++#define POLLOUT 4
++#define POLLERR 8
++#define POLLHUP 16
++#define POLLNVAL 32
++#define POLLRDNORM 64
++#define POLLWRNORM POLLOUT
++#define POLLRDBAND 128
++#define POLLWRBAND 256
++#define POLLMSG 0x0400
++#define POLLREMOVE 0x1000
++#define POLLRDHUP 0x2000
++
++struct pollfd {
++ int fd;
++ short events;
++ short revents;
++};
++
++#endif
+diff --git a/include/asm-nios2nommu/posix_types.h b/include/asm-nios2nommu/posix_types.h
+new file mode 100644
+index 0000000..0b019b5
+--- /dev/null
++++ b/include/asm-nios2nommu/posix_types.h
+@@ -0,0 +1,89 @@
++#ifndef __ARCH_NIOS2_POSIX_TYPES_H
++#define __ARCH_NIOS2_POSIX_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/posix_types.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is generally used by user-level software, so you need to
++ * be a little careful about namespace pollution etc. Also, we cannot
++ * assume GCC is being used.
++ */
++
++typedef unsigned long __kernel_ino_t;
++typedef unsigned short __kernel_mode_t;
++typedef unsigned short __kernel_nlink_t;
++typedef long __kernel_off_t;
++typedef int __kernel_pid_t;
++typedef unsigned short __kernel_ipc_pid_t;
++typedef unsigned short __kernel_uid_t;
++typedef unsigned short __kernel_gid_t;
++typedef unsigned int __kernel_size_t;
++typedef int __kernel_ssize_t;
++typedef int __kernel_ptrdiff_t;
++typedef long __kernel_time_t;
++typedef long __kernel_suseconds_t;
++typedef long __kernel_clock_t;
++typedef int __kernel_timer_t;
++typedef int __kernel_clockid_t;
++typedef int __kernel_daddr_t;
++typedef char * __kernel_caddr_t;
++typedef unsigned short __kernel_uid16_t;
++typedef unsigned short __kernel_gid16_t;
++typedef unsigned int __kernel_uid32_t;
++typedef unsigned int __kernel_gid32_t;
++
++typedef unsigned short __kernel_old_uid_t;
++typedef unsigned short __kernel_old_gid_t;
++typedef unsigned short __kernel_old_dev_t;
++
++#ifdef __GNUC__
++typedef long long __kernel_loff_t;
++#endif
++
++typedef struct {
++#if defined(__KERNEL__) || defined(__USE_ALL)
++ int val[2];
++#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++ int __val[2];
++#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++} __kernel_fsid_t;
++
++#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
++
++#undef __FD_SET
++#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
++
++#undef __FD_CLR
++#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
++
++#undef __FD_ISSET
++#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
++
++#undef __FD_ZERO
++#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
++
++#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
++
++#endif
+diff --git a/include/asm-nios2nommu/preem_latency.h b/include/asm-nios2nommu/preem_latency.h
+new file mode 100644
+index 0000000..6defb5c
+--- /dev/null
++++ b/include/asm-nios2nommu/preem_latency.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_PREEM_LATENCY_H
++#define _ASM_PREEM_LATENCY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/preem_latency.h
++ *
++ * timing support for preempt-stats patch
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++#define readclock(low) \
++do {\
++ *(volatile unsigned long *)na_Counter_64_bit=1; \
++ low=*(volatile unsigned long *)na_Counter_64_bit; \
++} while (0)
++#define readclock_init()
++
++#endif /* _ASM_PREEM_LATENCY_H */
+diff --git a/include/asm-nios2nommu/processor.h b/include/asm-nios2nommu/processor.h
+new file mode 100644
+index 0000000..5332f94
+--- /dev/null
++++ b/include/asm-nios2nommu/processor.h
+@@ -0,0 +1,148 @@
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/processor.h
++ *
++ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
++ * Vic Phillips (vic@microtronix.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * hacked from:
++ * include/asm-sparc/processor.h
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ * Nov/02/2003 dgt Fix task_size
++ *
++ ---------------------------------------------------------------------*/
++
++#ifndef __ASM_NIOS_PROCESSOR_H
++#define __ASM_NIOS_PROCESSOR_H
++
++#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
++#define NIOS2_FLAG_COPROC 0x00000002 /* Thread used coprocess */
++#define NIOS2_FLAG_DEBUG 0x00000004 /* task is being debugged */
++
++#define NIOS2_OP_NOP 0x1883a
++#define NIOS2_OP_BREAK 0x3da03a
++
++#ifndef __ASSEMBLY__
++
++/*
++ * Default implementation of macro that returns current
++ * instruction pointer ("program counter").
++ */
++#define current_text_addr() ({ __label__ _l; _l: &&_l;})
++
++#include <linux/a.out.h>
++#include <linux/string.h>
++
++#include <asm/ptrace.h>
++#include <asm/signal.h>
++#include <asm/segment.h>
++#include <asm/current.h>
++#include <asm/system.h> /* for get_hi_limit */
++
++/*
++ * Bus types
++ */
++#define EISA_bus 0
++#define EISA_bus__is_a_macro /* for versions in ksyms.c */
++#define MCA_bus 0
++#define MCA_bus__is_a_macro /* for versions in ksyms.c */
++
++/*
++ * The nios has no problems with write protection
++ */
++#define wp_works_ok 1
++#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
++
++/* Whee, this is STACK_TOP and the lowest kernel address too... */
++#if 0
++#define KERNBASE 0x00000000 /* First address the kernel will eventually be */
++#define TASK_SIZE (KERNBASE)
++#define MAX_USER_ADDR TASK_SIZE
++#define MMAP_SEARCH_START (TASK_SIZE/3)
++#endif
++
++#define TASK_SIZE ((unsigned int) nasys_program_mem_end) //...this is better...
++
++/*
++ * This decides where the kernel will search for a free chunk of vm
++ * space during mmap's. We won't be using it
++ */
++#define TASK_UNMAPPED_BASE 0
++
++/* The Nios processor specific thread struct. */
++struct thread_struct {
++ struct pt_regs *kregs;
++
++ /* For signal handling */
++ unsigned long sig_address;
++ unsigned long sig_desc;
++
++ /* Context switch saved kernel state. */
++ unsigned long ksp;
++ unsigned long kpsr;
++ unsigned long kesr;
++
++ /* Flags are defined below */
++
++ unsigned long flags;
++ int current_ds;
++ struct exec core_exec; /* just what it says. */
++};
++
++#define INIT_MMAP { &init_mm, (0), (0), \
++ __pgprot(0x0) , VM_READ | VM_WRITE | VM_EXEC }
++
++#define INIT_THREAD { \
++ .kregs = 0, \
++ .sig_address = 0, \
++ .sig_desc = 0, \
++ .ksp = 0, \
++ .kpsr = 0, \
++ .kesr = PS_S, \
++ .flags = NIOS2_FLAG_KTHREAD, \
++ .current_ds = __KERNEL_DS, \
++ .core_exec = INIT_EXEC \
++}
++
++/* Free all resources held by a thread. */
++extern void release_thread(struct task_struct *);
++
++extern unsigned long thread_saved_pc(struct task_struct *t);
++
++extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
++
++/* Prepare to copy thread state - unlazy all lazy status */
++#define prepare_to_copy(tsk) do { } while (0)
++
++extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
++
++unsigned long get_wchan(struct task_struct *p);
++
++#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
++#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
++
++#ifdef __KERNEL__
++/* Allocation and freeing of basic task resources. */
++
++//;dgt2;#define alloc_task_struct() ((struct task_struct *) xx..see..linux..fork..xx __get_free_pages(GFP_KERNEL,1))
++//;dgt2;#define get_task_struct(tsk) xx..see..linux..sched.h...atomic_inc(&mem_map[MAP_NR(tsk)].count)
++
++#endif
++
++#define cpu_relax() do { } while (0)
++#endif /* __ASSEMBLY__ */
++#endif /* __ASM_NIOS_PROCESSOR_H */
+diff --git a/include/asm-nios2nommu/ptrace.h b/include/asm-nios2nommu/ptrace.h
+new file mode 100644
+index 0000000..d669e08
+--- /dev/null
++++ b/include/asm-nios2nommu/ptrace.h
+@@ -0,0 +1,140 @@
++/*
++ * Taken from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2NOMMU_PTRACE_H
++#define _NIOS2NOMMU_PTRACE_H
++
++#ifndef __ASSEMBLY__
++
++#define PTR_R0 0
++#define PTR_R1 1
++#define PTR_R2 2
++#define PTR_R3 3
++#define PTR_R4 4
++#define PTR_R5 5
++#define PTR_R6 6
++#define PTR_R7 7
++#define PTR_R8 8
++#define PTR_R9 9
++#define PTR_R10 10
++#define PTR_R11 11
++#define PTR_R12 12
++#define PTR_R13 13
++#define PTR_R14 14
++#define PTR_R15 15
++#define PTR_R16 16
++#define PTR_R17 17
++#define PTR_R18 18
++#define PTR_R19 19
++#define PTR_R20 20
++#define PTR_R21 21
++#define PTR_R22 22
++#define PTR_R23 23
++#define PTR_R24 24
++#define PTR_R25 25
++#define PTR_GP 26
++#define PTR_SP 27
++#define PTR_FP 28
++#define PTR_EA 29
++#define PTR_BA 30
++#define PTR_RA 31
++#define PTR_STATUS 32
++#define PTR_ESTATUS 33
++#define PTR_BSTATUS 34
++#define PTR_IENABLE 35
++#define PTR_IPENDING 36
++
++/* this struct defines the way the registers are stored on the
++ stack during a system call.
++
++ There is a fake_regs in setup.c that has to match pt_regs.*/
++
++struct pt_regs {
++ unsigned long r8;
++ unsigned long r9;
++ unsigned long r10;
++ unsigned long r11;
++ unsigned long r12;
++ unsigned long r13;
++ unsigned long r14;
++ unsigned long r15;
++ unsigned long r1;
++ unsigned long r2;
++ unsigned long r3;
++ unsigned long r4;
++ unsigned long r5;
++ unsigned long r6;
++ unsigned long r7;
++ unsigned long orig_r2;
++ unsigned long ra;
++ unsigned long fp;
++ unsigned long sp;
++ unsigned long gp;
++ unsigned long estatus;
++ unsigned long status_extension;
++ unsigned long ea;
++};
++
++
++/*
++ * This is the extended stack used by signal handlers and the context
++ * switcher: it's pushed after the normal "struct pt_regs".
++ */
++struct switch_stack {
++ unsigned long r16;
++ unsigned long r17;
++ unsigned long r18;
++ unsigned long r19;
++ unsigned long r20;
++ unsigned long r21;
++ unsigned long r22;
++ unsigned long r23;
++ unsigned long fp;
++ unsigned long gp;
++ unsigned long ra;
++};
++
++#ifdef __KERNEL__
++/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
++#define PTRACE_GETREGS 12
++#define PTRACE_SETREGS 13
++#ifdef CONFIG_FPU
++#define PTRACE_GETFPREGS 14
++#define PTRACE_SETFPREGS 15
++#endif
++
++#ifndef PS_S
++#define PS_S (0x00000001)
++#endif
++#ifndef PS_T
++#define PS_T (0x00000002)
++#endif
++
++#define user_mode(regs) (!((regs)->status_extension & PS_S))
++#define instruction_pointer(regs) ((regs)->ra)
++#define profile_pc(regs) instruction_pointer(regs)
++extern void show_regs(struct pt_regs *);
++
++#endif /* __KERNEL__ */
++#endif /* __ASSEMBLY__ */
++#endif /* _NIOS2NOMMU_PTRACE_H */
+diff --git a/include/asm-nios2nommu/resource.h b/include/asm-nios2nommu/resource.h
+new file mode 100644
+index 0000000..9c2499a
+--- /dev/null
++++ b/include/asm-nios2nommu/resource.h
+@@ -0,0 +1,6 @@
++#ifndef __ASM_SH_RESOURCE_H
++#define __ASM_SH_RESOURCE_H
++
++#include <asm-generic/resource.h>
++
++#endif /* __ASM_SH_RESOURCE_H */
+diff --git a/include/asm-nios2nommu/rmap.h b/include/asm-nios2nommu/rmap.h
+new file mode 100644
+index 0000000..b3664cc
+--- /dev/null
++++ b/include/asm-nios2nommu/rmap.h
+@@ -0,0 +1,2 @@
++/* Do not need anything here */
++
+diff --git a/include/asm-nios2nommu/scatterlist.h b/include/asm-nios2nommu/scatterlist.h
+new file mode 100644
+index 0000000..20898e2
+--- /dev/null
++++ b/include/asm-nios2nommu/scatterlist.h
+@@ -0,0 +1,13 @@
++#ifndef __ASM_SH_SCATTERLIST_H
++#define __ASM_SH_SCATTERLIST_H
++
++struct scatterlist {
++ struct page * page; /* Location for highmem page, if any */
++ unsigned int offset;/* for highmem, page offset */
++ dma_addr_t dma_address;
++ unsigned int length;
++};
++
++#define ISA_DMA_THRESHOLD (0xffffffff)
++
++#endif /* !(__ASM_SH_SCATTERLIST_H) */
+diff --git a/include/asm-nios2nommu/sections.h b/include/asm-nios2nommu/sections.h
+new file mode 100644
+index 0000000..61b3f71
+--- /dev/null
++++ b/include/asm-nios2nommu/sections.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_SECTIONS_H
++#define _NIOS2NOMMU_SECTIONS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sections.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/sections.h>
++
++#endif /* _NIOS2NOMMU_SECTIONS_H */
+diff --git a/include/asm-nios2nommu/segment.h b/include/asm-nios2nommu/segment.h
+new file mode 100644
+index 0000000..25871b3
+--- /dev/null
++++ b/include/asm-nios2nommu/segment.h
+@@ -0,0 +1,75 @@
++#ifndef _NIOS2NOMMU_SEGMENT_H
++#define _NIOS2NOMMU_SEGMENT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/segment.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* define constants */
++/* Address spaces (FC0-FC2) */
++#define USER_DATA (1)
++#ifndef __USER_DS
++#define __USER_DS (USER_DATA)
++#endif
++#define USER_PROGRAM (2)
++#define SUPER_DATA (5)
++#ifndef __KERNEL_DS
++#define __KERNEL_DS (SUPER_DATA)
++#endif
++#define SUPER_PROGRAM (6)
++#define CPU_SPACE (7)
++
++#ifndef __ASSEMBLY__
++
++typedef struct {
++ unsigned long seg;
++} mm_segment_t;
++
++#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
++#define USER_DS MAKE_MM_SEG(__USER_DS)
++#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
++
++/*
++ * Get/set the SFC/DFC registers for MOVES instructions
++ */
++
++static inline mm_segment_t get_fs(void)
++{
++ return USER_DS;
++}
++
++static inline mm_segment_t get_ds(void)
++{
++ /* return the supervisor data space code */
++ return KERNEL_DS;
++}
++
++static inline void set_fs(mm_segment_t val)
++{
++}
++
++#define segment_eq(a,b) ((a).seg == (b).seg)
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* _NIOS2NOMMU_SEGMENT_H */
+diff --git a/include/asm-nios2nommu/semaphore-helper.h b/include/asm-nios2nommu/semaphore-helper.h
+new file mode 100644
+index 0000000..a8905d1
+--- /dev/null
++++ b/include/asm-nios2nommu/semaphore-helper.h
+@@ -0,0 +1,99 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_HELPER_H
++#define _NIOS2NOMMU_SEMAPHORE_HELPER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * SMP- and interrupt-safe semaphores helper functions.
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++/*
++ * These two _must_ execute atomically wrt each other.
++ */
++static inline void wake_one_more(struct semaphore * sem)
++{
++ atomic_inc(&sem->waking);
++}
++
++static inline int waking_non_zero(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_interruptible:
++ * 1 got the lock
++ * 0 go to sleep
++ * -EINTR interrupted
++ */
++static inline int waking_non_zero_interruptible(struct semaphore *sem,
++ struct task_struct *tsk)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ } else if (signal_pending(tsk)) {
++ atomic_inc(&sem->count);
++ ret = -EINTR;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_trylock:
++ * 1 failed to lock
++ * 0 got the lock
++ */
++static inline int waking_non_zero_trylock(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 1;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 0;
++ } else
++ atomic_inc(&sem->count);
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++#endif
+diff --git a/include/asm-nios2nommu/semaphore.h b/include/asm-nios2nommu/semaphore.h
+new file mode 100644
+index 0000000..8d66c77
+--- /dev/null
++++ b/include/asm-nios2nommu/semaphore.h
+@@ -0,0 +1,152 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_H
++#define _NIOS2NOMMU_SEMAPHORE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * Interrupt-safe semaphores..
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define RW_LOCK_BIAS 0x01000000
++
++#ifndef __ASSEMBLY__
++
++#include <linux/linkage.h>
++#include <linux/wait.h>
++#include <linux/spinlock.h>
++#include <linux/rwsem.h>
++
++#include <asm/system.h>
++#include <asm/atomic.h>
++
++struct semaphore {
++ atomic_t count;
++ atomic_t waking;
++ wait_queue_head_t wait;
++};
++
++#define __SEMAPHORE_INITIALIZER(name, n) \
++{ \
++ .count = ATOMIC_INIT(n), \
++ .waking = ATOMIC_INIT(0), \
++ .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
++}
++
++#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
++ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
++
++#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
++#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
++
++static inline void sema_init (struct semaphore *sem, int val)
++{
++ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
++}
++
++static inline void init_MUTEX (struct semaphore *sem)
++{
++ sema_init(sem, 1);
++}
++
++static inline void init_MUTEX_LOCKED (struct semaphore *sem)
++{
++ sema_init(sem, 0);
++}
++
++asmlinkage void __down_failed(void /* special register calling convention */);
++asmlinkage int __down_failed_interruptible(void /* params in registers */);
++asmlinkage int __down_failed_trylock(void /* params in registers */);
++asmlinkage void __up_wakeup(void /* special register calling convention */);
++
++asmlinkage void __down(struct semaphore * sem);
++asmlinkage int __down_interruptible(struct semaphore * sem);
++asmlinkage int __down_trylock(struct semaphore * sem);
++asmlinkage void __up(struct semaphore * sem);
++
++extern spinlock_t semaphore_wake_lock;
++
++/*
++ * This is ugly, but we want the default case to fall through.
++ * "down_failed" is a special asm handler that calls the C
++ * routine that actually waits.
++ */
++static inline void down(struct semaphore * sem)
++{
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if (atomic_dec_return(&sem->count) < 0)
++ __down(sem);
++ #endif
++}
++
++static inline int down_interruptible(struct semaphore * sem)
++{
++ int ret = 0;
++
++
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if(atomic_dec_return(&sem->count) < 0)
++ ret = __down_interruptible(sem);
++ return ret;
++ #endif
++}
++
++static inline int down_trylock(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ int ret = 0;
++
++ if (atomic_dec_return (&sem->count) < 0)
++ ret = __down_trylock(sem);
++ return ret;
++ #endif
++}
++
++/*
++ * Note! This is subtle. We jump to wake people up only if
++ * the semaphore was negative (== somebody was waiting on it).
++ * The default case (no contention) will result in NO
++ * jumps for both down() and up().
++ */
++static inline void up(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "increment memory"....
++ #else
++ if (atomic_inc_return(&sem->count) <= 0)
++ __up(sem);
++ #endif
++}
++
++#endif /* __ASSEMBLY__ */
++
++#endif
+diff --git a/include/asm-nios2nommu/sembuf.h b/include/asm-nios2nommu/sembuf.h
+new file mode 100644
+index 0000000..e530cab
+--- /dev/null
++++ b/include/asm-nios2nommu/sembuf.h
+@@ -0,0 +1,48 @@
++#ifndef _NIOS_SEMBUF_H
++#define _NIOS_SEMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sembuf.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct semid64_ds {
++ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
++ __kernel_time_t sem_otime; /* last semop time */
++ unsigned long __unused1;
++ __kernel_time_t sem_ctime; /* last change time */
++ unsigned long __unused2;
++ unsigned long sem_nsems; /* no. of semaphores in array */
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SEMBUF_H */
+diff --git a/include/asm-nios2nommu/setup.h b/include/asm-nios2nommu/setup.h
+new file mode 100644
+index 0000000..c5a655a
+--- /dev/null
++++ b/include/asm-nios2nommu/setup.h
+@@ -0,0 +1,31 @@
++/* Copied from i386 port.
++ * Just a place holder. We don't want to have to test x86 before
++ * we include stuff
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SETUP_H
++#define _NIOS2_SETUP_H
++
++#define COMMAND_LINE_SIZE 512
++
++#endif /* _NIOS2_SETUP_H */
+diff --git a/include/asm-nios2nommu/shmbuf.h b/include/asm-nios2nommu/shmbuf.h
+new file mode 100644
+index 0000000..f6e6e7d
+--- /dev/null
++++ b/include/asm-nios2nommu/shmbuf.h
+@@ -0,0 +1,64 @@
++#ifndef _NIOS_SHMBUF_H
++#define _NIOS_SHMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmbuf.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct shmid64_ds {
++ struct ipc64_perm shm_perm; /* operation perms */
++ size_t shm_segsz; /* size of segment (bytes) */
++ __kernel_time_t shm_atime; /* last attach time */
++ unsigned long __unused1;
++ __kernel_time_t shm_dtime; /* last detach time */
++ unsigned long __unused2;
++ __kernel_time_t shm_ctime; /* last change time */
++ unsigned long __unused3;
++ __kernel_pid_t shm_cpid; /* pid of creator */
++ __kernel_pid_t shm_lpid; /* pid of last operator */
++ unsigned long shm_nattch; /* no. of current attaches */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++struct shminfo64 {
++ unsigned long shmmax;
++ unsigned long shmmin;
++ unsigned long shmmni;
++ unsigned long shmseg;
++ unsigned long shmall;
++ unsigned long __unused1;
++ unsigned long __unused2;
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SHMBUF_H */
+diff --git a/include/asm-nios2nommu/shmparam.h b/include/asm-nios2nommu/shmparam.h
+new file mode 100644
+index 0000000..94efe2d
+--- /dev/null
++++ b/include/asm-nios2nommu/shmparam.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS2NOMMU_SHMPARAM_H__
++#define __NIOS2NOMMU_SHMPARAM_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmparam.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
++
++#endif /* __NIOS2NOMMU_SHMPARAM_H__ */
+diff --git a/include/asm-nios2nommu/sigcontext.h b/include/asm-nios2nommu/sigcontext.h
+new file mode 100644
+index 0000000..7321e7d
+--- /dev/null
++++ b/include/asm-nios2nommu/sigcontext.h
+@@ -0,0 +1,35 @@
++/*
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_SIGCONTEXT_H
++#define _ASM_NIOS2NOMMU_SIGCONTEXT_H
++
++#include <asm/ptrace.h>
++
++struct sigcontext {
++ struct pt_regs regs;
++ unsigned long sc_mask; /* old sigmask */
++};
++
++#endif
+diff --git a/include/asm-nios2nommu/siginfo.h b/include/asm-nios2nommu/siginfo.h
+new file mode 100644
+index 0000000..c047c0b
+--- /dev/null
++++ b/include/asm-nios2nommu/siginfo.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SIGINFO_H
++#define _NIOS2NOMMU_SIGINFO_H
++
++#include <asm-generic/siginfo.h>
++
++#endif
+diff --git a/include/asm-nios2nommu/signal.h b/include/asm-nios2nommu/signal.h
+new file mode 100644
+index 0000000..c86a20c
+--- /dev/null
++++ b/include/asm-nios2nommu/signal.h
+@@ -0,0 +1,181 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SIGNAL_H
++#define _NIOS2_SIGNAL_H
++
++#include <linux/types.h>
++
++/* Avoid too many header ordering problems. */
++struct siginfo;
++
++#ifdef __KERNEL__
++/* Most things should be clean enough to redefine this at will, if care
++ is taken to make libc match. */
++
++#define _NSIG 64
++#define _NSIG_BPW 32
++#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
++
++typedef unsigned long old_sigset_t; /* at least 32 bits */
++
++typedef struct {
++ unsigned long sig[_NSIG_WORDS];
++} sigset_t;
++
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++#define NSIG 32
++typedef unsigned long sigset_t;
++
++#endif /* __KERNEL__ */
++
++#define SIGHUP 1
++#define SIGINT 2
++#define SIGQUIT 3
++#define SIGILL 4
++#define SIGTRAP 5
++#define SIGABRT 6
++#define SIGIOT 6
++#define SIGBUS 7
++#define SIGFPE 8
++#define SIGKILL 9
++#define SIGUSR1 10
++#define SIGSEGV 11
++#define SIGUSR2 12
++#define SIGPIPE 13
++#define SIGALRM 14
++#define SIGTERM 15
++#define SIGSTKFLT 16
++#define SIGCHLD 17
++#define SIGCONT 18
++#define SIGSTOP 19
++#define SIGTSTP 20
++#define SIGTTIN 21
++#define SIGTTOU 22
++#define SIGURG 23
++#define SIGXCPU 24
++#define SIGXFSZ 25
++#define SIGVTALRM 26
++#define SIGPROF 27
++#define SIGWINCH 28
++#define SIGIO 29
++#define SIGPOLL SIGIO
++/*
++#define SIGLOST 29
++*/
++#define SIGPWR 30
++#define SIGSYS 31
++#define SIGUNUSED 31
++
++/* These should not be considered constants from userland. */
++#define SIGRTMIN 32
++#define SIGRTMAX _NSIG
++
++/*
++ * SA_FLAGS values:
++ *
++ * SA_ONSTACK indicates that a registered stack_t will be used.
++ * SA_RESTART flag to get restarting signals (which were the default long ago)
++ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
++ * SA_RESETHAND clears the handler when the signal is delivered.
++ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
++ * SA_NODEFER prevents the current signal from being masked in the handler.
++ *
++ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
++ * Unix names RESETHAND and NODEFER respectively.
++ */
++#define SA_NOCLDSTOP 0x00000001
++#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
++#define SA_SIGINFO 0x00000004
++#define SA_ONSTACK 0x08000000
++#define SA_RESTART 0x10000000
++#define SA_NODEFER 0x40000000
++#define SA_RESETHAND 0x80000000
++
++#define SA_NOMASK SA_NODEFER
++#define SA_ONESHOT SA_RESETHAND
++
++/*
++ * sigaltstack controls
++ */
++#define SS_ONSTACK 1
++#define SS_DISABLE 2
++
++#define MINSIGSTKSZ 2048
++#define SIGSTKSZ 8192
++
++#include <asm-generic/signal.h>
++
++#ifdef __KERNEL__
++struct old_sigaction {
++ __sighandler_t sa_handler;
++ old_sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++struct sigaction {
++ __sighandler_t sa_handler;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++ sigset_t sa_mask; /* mask last for extensibility */
++};
++
++struct k_sigaction {
++ struct sigaction sa;
++};
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++struct sigaction {
++ union {
++ __sighandler_t _sa_handler;
++ void (*_sa_sigaction)(int, struct siginfo *, void *);
++ } _u;
++ sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++#define sa_handler _u._sa_handler
++#define sa_sigaction _u._sa_sigaction
++
++#endif /* __KERNEL__ */
++
++typedef struct sigaltstack {
++ void *ss_sp;
++ int ss_flags;
++ size_t ss_size;
++} stack_t;
++
++#ifdef __KERNEL__
++
++#include <asm/sigcontext.h>
++#undef __HAVE_ARCH_SIG_BITOPS
++
++#define ptrace_signal_deliver(regs, cookie) do { } while (0)
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_SIGNAL_H */
+diff --git a/include/asm-nios2nommu/smp.h b/include/asm-nios2nommu/smp.h
+new file mode 100644
+index 0000000..fb23307
+--- /dev/null
++++ b/include/asm-nios2nommu/smp.h
+@@ -0,0 +1,32 @@
++#ifndef __ASM_SMP_H
++#define __ASM_SMP_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/smp.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef CONFIG_SMP
++#error SMP not supported
++#endif
++
++#endif
+diff --git a/include/asm-nios2nommu/socket.h b/include/asm-nios2nommu/socket.h
+new file mode 100644
+index 0000000..5452e2b
+--- /dev/null
++++ b/include/asm-nios2nommu/socket.h
+@@ -0,0 +1,79 @@
++#ifndef _ASM_SOCKET_H
++#define _ASM_SOCKET_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/socket.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/sockios.h>
++
++/* For setsockopt(2) */
++#define SOL_SOCKET 1
++
++#define SO_DEBUG 1
++#define SO_REUSEADDR 2
++#define SO_TYPE 3
++#define SO_ERROR 4
++#define SO_DONTROUTE 5
++#define SO_BROADCAST 6
++#define SO_SNDBUF 7
++#define SO_RCVBUF 8
++#define SO_SNDBUFFORCE 32
++#define SO_RCVBUFFORCE 33
++#define SO_KEEPALIVE 9
++#define SO_OOBINLINE 10
++#define SO_NO_CHECK 11
++#define SO_PRIORITY 12
++#define SO_LINGER 13
++#define SO_BSDCOMPAT 14
++/* To add :#define SO_REUSEPORT 15 */
++#define SO_PASSCRED 16
++#define SO_PEERCRED 17
++#define SO_RCVLOWAT 18
++#define SO_SNDLOWAT 19
++#define SO_RCVTIMEO 20
++#define SO_SNDTIMEO 21
++
++/* Security levels - as per NRL IPv6 - don't actually do anything */
++#define SO_SECURITY_AUTHENTICATION 22
++#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
++#define SO_SECURITY_ENCRYPTION_NETWORK 24
++
++#define SO_BINDTODEVICE 25
++
++/* Socket filtering */
++#define SO_ATTACH_FILTER 26
++#define SO_DETACH_FILTER 27
++
++#define SO_PEERNAME 28
++#define SO_TIMESTAMP 29
++#define SCM_TIMESTAMP SO_TIMESTAMP
++
++#define SO_ACCEPTCONN 30
++
++#define SO_PEERSEC 31 /* ;dgt2;tmp; */
++#define SO_PASSSEC 34
++#define SO_TIMESTAMPNS 35
++#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
++
++#endif /* _ASM_SOCKET_H */
+diff --git a/include/asm-nios2nommu/sockios.h b/include/asm-nios2nommu/sockios.h
+new file mode 100644
+index 0000000..c604aa7
+--- /dev/null
++++ b/include/asm-nios2nommu/sockios.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_NIOS_SOCKIOS_H
++#define _ASM_NIOS_SOCKIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sockios.h
++ *
++ * Socket-level I/O control calls.
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define FIOSETOWN 0x8901
++#define SIOCSPGRP 0x8902
++#define FIOGETOWN 0x8903
++#define SIOCGPGRP 0x8904
++#define SIOCATMARK 0x8905
++#define SIOCGSTAMP 0x8906 /* Get stamp */
++#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
++
++#endif /* !(_ASM_NIOS_SOCKIOS_H) */
++
+diff --git a/include/asm-nios2nommu/spi.h b/include/asm-nios2nommu/spi.h
+new file mode 100644
+index 0000000..6efb82c
+--- /dev/null
++++ b/include/asm-nios2nommu/spi.h
+@@ -0,0 +1,92 @@
++#ifndef _ASM_SPI_H_
++#define _ASM_SPI_H_ 1
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spi.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++int register_NIOS_SPI( void );
++void unregister_NIOS_SPI( void );
++
++#if defined(MODULE)
++void cleanup_module( void );
++int init_module( void );
++#endif
++
++#if defined(__KERNEL__)
++int spi_reset ( void );
++#endif
++
++
++#define clockCS 0x01
++#define temperatureCS 0x02
++
++#define clock_read_base 0x00
++#define clock_write_base 0x80
++#define clock_read_control 0x0F
++#define clock_read_trickle 0x11
++
++#define clock_read_sec 0x00
++#define clock_read_min 0x01
++#define clock_read_hour 0x02
++#define clock_read_day 0x03
++#define clock_read_date 0x04
++#define clock_read_month 0x05
++#define clock_read_year 0x06
++
++#define clock_write_control 0x8F
++#define clock_write_trickle 0x91
++#define clock_write_sec 0x80
++#define clock_write_min 0x81
++#define clock_write_hour 0x82
++#define clock_write_day 0x83
++#define clock_write_date 0x84
++#define clock_write_month 0x85
++#define clock_write_year 0x86
++
++#define clock_write_ram_start 0xA0
++#define clock_write_ram_end 0x100
++#define clock_read_ram_start 0x20
++#define clock_read_ram_end 0x80
++
++
++#define clock_sec_def 0x11
++#define clock_min_def 0x59
++#define clock_hour_def 0x71
++#define clock_day_def 0x00
++#define clock_date_def 0x20
++#define clock_month_def 0x12
++#define clock_year_def 0x34
++
++#define temp_read_base 0x00
++#define temp_write_base 0x80
++#define temp_read_control 0x00
++#define temp_write_control 0x80
++#define temp_read_msb 0x02
++#define temp_read_lsb 0x01
++
++#define MAX_TEMP_VAR 10
++
++#endif /*_ASM_SPI_H_*/
+diff --git a/include/asm-nios2nommu/spi_struct.h b/include/asm-nios2nommu/spi_struct.h
+new file mode 100644
+index 0000000..c7b2faf
+--- /dev/null
++++ b/include/asm-nios2nommu/spi_struct.h
+@@ -0,0 +1,57 @@
++// SPI Registers
++typedef volatile struct
++ {
++ int np_spirxdata; // Read-only, 1-16 bit
++ int np_spitxdata; // Write-only, same width as rxdata
++ int np_spistatus; // Read-only, 9-bit
++ int np_spicontrol; // Read/Write, 9-bit
++ int np_spireserved; // reserved
++ int np_spislaveselect; // Read/Write, 1-16 bit, master only
++ int np_spiendofpacket; // Read/write, same width as txdata, rxdata.
++ } np_spi;
++
++// SPI Status Register Bits
++enum
++ {
++ np_spistatus_eop_bit = 9,
++ np_spistatus_e_bit = 8,
++ np_spistatus_rrdy_bit = 7,
++ np_spistatus_trdy_bit = 6,
++ np_spistatus_tmt_bit = 5,
++ np_spistatus_toe_bit = 4,
++ np_spistatus_roe_bit = 3,
++
++ np_spistatus_eop_mask = (1 << 9),
++ np_spistatus_e_mask = (1 << 8),
++ np_spistatus_rrdy_mask = (1 << 7),
++ np_spistatus_trdy_mask = (1 << 6),
++ np_spistatus_tmt_mask = (1 << 5),
++ np_spistatus_toe_mask = (1 << 4),
++ np_spistatus_roe_mask = (1 << 3),
++ };
++
++// SPI Control Register Bits
++enum
++ {
++ np_spicontrol_sso_bit = 10,
++ np_spicontrol_ieop_bit = 9,
++ np_spicontrol_ie_bit = 8,
++ np_spicontrol_irrdy_bit = 7,
++ np_spicontrol_itrdy_bit = 6,
++ np_spicontrol_itoe_bit = 4,
++ np_spicontrol_iroe_bit = 3,
++
++ np_spicontrol_sso_mask = (1 << 10),
++ np_spicontrol_ieop_mask = (1 << 9),
++ np_spicontrol_ie_mask = (1 << 8),
++ np_spicontrol_irrdy_mask = (1 << 7),
++ np_spicontrol_itrdy_mask = (1 << 6),
++ np_spicontrol_itoe_mask = (1 << 4),
++ np_spicontrol_iroe_mask = (1 << 3),
++ };
++
++// SPI Routines.
++int nr_spi_rxchar(np_spi *spiBase);
++int nr_spi_txchar(int i, np_spi *spiBase);
++
++
+diff --git a/include/asm-nios2nommu/spinlock.h b/include/asm-nios2nommu/spinlock.h
+new file mode 100644
+index 0000000..f518755
+--- /dev/null
++++ b/include/asm-nios2nommu/spinlock.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS_SPINLOCK_H
++#define __NIOS_SPINLOCK_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spinlock.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#error "Nios doesn't do SMP yet"
++
++#endif
+diff --git a/include/asm-nios2nommu/stat.h b/include/asm-nios2nommu/stat.h
+new file mode 100644
+index 0000000..bd27a97
+--- /dev/null
++++ b/include/asm-nios2nommu/stat.h
+@@ -0,0 +1,102 @@
++#ifndef _ASMNIOS2NOMMU_STAT_H
++#define _ASMNIOS2NOMMU_STAT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/stat.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct __old_kernel_stat {
++ unsigned short st_dev;
++ unsigned short st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned long st_size;
++ unsigned long st_atime;
++ unsigned long st_mtime;
++ unsigned long st_ctime;
++};
++
++struct stat {
++ unsigned short st_dev;
++ unsigned short __pad1;
++ unsigned long st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned short __pad2;
++ unsigned long st_size;
++ unsigned long st_blksize;
++ unsigned long st_blocks;
++ unsigned long st_atime;
++ unsigned long __unused1;
++ unsigned long st_mtime;
++ unsigned long __unused2;
++ unsigned long st_ctime;
++ unsigned long __unused3;
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++/* This matches struct stat64 in glibc2.1, hence the absolutely
++ * insane amounts of padding around dev_t's.
++ */
++struct stat64 {
++ unsigned long long st_dev;
++ unsigned char __pad1[4];
++
++#define STAT64_HAS_BROKEN_ST_INO 1
++ unsigned long __st_ino;
++
++ unsigned int st_mode;
++ unsigned int st_nlink;
++
++ unsigned long st_uid;
++ unsigned long st_gid;
++
++ unsigned long long st_rdev;
++ unsigned char __pad3[4];
++
++ long long st_size;
++ unsigned long st_blksize;
++
++ unsigned long __pad4; /* future possible st_blocks high bits */
++ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
++
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++
++ unsigned long long st_ino;
++};
++
++#endif
+diff --git a/include/asm-nios2nommu/statfs.h b/include/asm-nios2nommu/statfs.h
+new file mode 100644
+index 0000000..c4637f6
+--- /dev/null
++++ b/include/asm-nios2nommu/statfs.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_STATFS_H
++#define _NIOS2NOMMU_STATFS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/statfs.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/statfs.h>
++
++#endif /* _NIOS2NOMMU_STATFS_H */
+diff --git a/include/asm-nios2nommu/string.h b/include/asm-nios2nommu/string.h
+new file mode 100644
+index 0000000..7e39479
+--- /dev/null
++++ b/include/asm-nios2nommu/string.h
+@@ -0,0 +1,45 @@
++#ifndef __NIOS_STRING_H__
++#define __NIOS_STRING_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/string.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef __KERNEL__ /* only set these up for kernel code */
++
++#define __HAVE_ARCH_MEMMOVE
++void * memmove(void * d, const void * s, size_t count);
++#define __HAVE_ARCH_MEMCPY
++extern void * memcpy(void *d, const void *s, size_t count);
++#define __HAVE_ARCH_MEMSET
++extern void * memset(void * s,int c,size_t count);
++
++#if 0
++#define __HAVE_ARCH_BCOPY
++#define __HAVE_ARCH_STRLEN
++#endif
++
++#endif /* KERNEL */
++
++#endif /* !(__NIOS_STRING_H__) */
+diff --git a/include/asm-nios2nommu/system.h b/include/asm-nios2nommu/system.h
+new file mode 100644
+index 0000000..7c35af0
+--- /dev/null
++++ b/include/asm-nios2nommu/system.h
+@@ -0,0 +1,172 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SYSTEM_H
++#define _NIOS2NOMMU_SYSTEM_H
++
++#include <linux/linkage.h>
++#include <linux/compiler.h>
++#include <asm/segment.h>
++#include <asm/entry.h>
++#include <asm/nios.h>
++
++/*
++ * switch_to(n) should switch tasks to task ptr, first checking that
++ * ptr isn't the current task, in which case it does nothing. This
++ * also clears the TS-flag if the task we switched to has used the
++ * math co-processor latest.
++ */
++
++/*
++ */
++asmlinkage void resume(void);
++#define switch_to(prev,next,last) \
++{ \
++ void *_last; \
++ __asm__ __volatile__( \
++ "mov r4, %1\n" \
++ "mov r5, %2\n" \
++ "call resume\n" \
++ "mov %0,r4\n" \
++ : "=r" (_last) \
++ : "r" (prev), "r" (next) \
++ : "r4","r5","r7","r8","ra"); \
++ (last) = _last; \
++}
++
++#define local_irq_enable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "ori r8, r8, 1\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_irq_disable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "andi r8, r8, 0xfffe\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_save_flags(x) __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "mov %0, r8\n" \
++ :"=r" (x) : : "r8", "memory")
++
++#define local_irq_restore(x) __asm__ __volatile__ ( \
++ "mov r8, %0\n" \
++ "wrctl status, r8\n" \
++ : :"r" (x) : "memory")
++
++/* For spinlocks etc */
++#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
++
++#define irqs_disabled() \
++({ \
++ unsigned long flags; \
++ local_save_flags(flags); \
++ ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
++})
++
++#define iret() __asm__ __volatile__ ("eret": : :"memory", "ea")
++
++/*
++ * Force strict CPU ordering.
++ * Not really required on m68k...
++ */
++#define nop() asm volatile ("nop"::)
++#define mb() asm volatile ("" : : :"memory")
++#define rmb() asm volatile ("" : : :"memory")
++#define wmb() asm volatile ("" : : :"memory")
++#define set_rmb(var, value) do { xchg(&var, value); } while (0)
++#define set_mb(var, value) set_rmb(var, value)
++#define set_wmb(var, value) do { var = value; wmb(); } while (0)
++
++#ifdef CONFIG_SMP
++#define smp_mb() mb()
++#define smp_rmb() rmb()
++#define smp_wmb() wmb()
++#define smp_read_barrier_depends() read_barrier_depends()
++#else
++#define smp_mb() barrier()
++#define smp_rmb() barrier()
++#define smp_wmb() barrier()
++#define smp_read_barrier_depends() do { } while(0)
++#endif
++
++#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
++#define tas(ptr) (xchg((ptr),1))
++
++struct __xchg_dummy { unsigned long a[100]; };
++#define __xg(x) ((volatile struct __xchg_dummy *)(x))
++
++static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
++{
++ unsigned long tmp, flags;
++
++ local_irq_save(flags);
++
++ switch (size) {
++ case 1:
++ __asm__ __volatile__( \
++ "ldb %0, %2\n" \
++ "stb %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 2:
++ __asm__ __volatile__( \
++ "ldh %0, %2\n" \
++ "sth %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 4:
++ __asm__ __volatile__( \
++ "ldw %0, %2\n" \
++ "stw %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ }
++ local_irq_restore(flags);
++ return tmp;
++}
++
++/*
++ * Atomic compare and exchange. Compare OLD with MEM, if identical,
++ * store NEW in MEM. Return the initial value in MEM. Success is
++ * indicated by comparing RETURN with OLD.
++ */
++#define __HAVE_ARCH_CMPXCHG 1
++
++static __inline__ unsigned long
++cmpxchg(volatile int *p, int old, int new)
++{
++ unsigned long flags;
++ int prev;
++
++ local_irq_save(flags);
++ if ((prev = *p) == old)
++ *p = new;
++ local_irq_restore(flags);
++ return(prev);
++}
++
++#endif /* _NIOS2NOMMU_SYSTEM_H */
+diff --git a/include/asm-nios2nommu/termbits.h b/include/asm-nios2nommu/termbits.h
+new file mode 100644
+index 0000000..74ef61d
+--- /dev/null
++++ b/include/asm-nios2nommu/termbits.h
+@@ -0,0 +1,210 @@
++#ifndef __ARCH_NIOS_TERMBITS_H__
++#define __ARCH_NIOS_TERMBITS_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termbits.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/posix_types.h>
++
++typedef unsigned char cc_t;
++typedef unsigned int speed_t;
++typedef unsigned int tcflag_t;
++
++#define NCCS 19
++struct termios {
++ tcflag_t c_iflag; /* input mode flags */
++ tcflag_t c_oflag; /* output mode flags */
++ tcflag_t c_cflag; /* control mode flags */
++ tcflag_t c_lflag; /* local mode flags */
++ cc_t c_line; /* line discipline */
++ cc_t c_cc[NCCS]; /* control characters */
++};
++
++struct ktermios {
++ tcflag_t c_iflag; /* input mode flags */
++ tcflag_t c_oflag; /* output mode flags */
++ tcflag_t c_cflag; /* control mode flags */
++ tcflag_t c_lflag; /* local mode flags */
++ cc_t c_line; /* line discipline */
++ cc_t c_cc[NCCS]; /* control characters */
++ speed_t c_ispeed; /* input speed */
++ speed_t c_ospeed; /* output speed */
++};
++
++/* c_cc characters */
++#define VINTR 0
++#define VQUIT 1
++#define VERASE 2
++#define VKILL 3
++#define VEOF 4
++#define VTIME 5
++#define VMIN 6
++#define VSWTC 7
++#define VSTART 8
++#define VSTOP 9
++#define VSUSP 10
++#define VEOL 11
++#define VREPRINT 12
++#define VDISCARD 13
++#define VWERASE 14
++#define VLNEXT 15
++#define VEOL2 16
++
++
++/* c_iflag bits */
++#define IGNBRK 0000001
++#define BRKINT 0000002
++#define IGNPAR 0000004
++#define PARMRK 0000010
++#define INPCK 0000020
++#define ISTRIP 0000040
++#define INLCR 0000100
++#define IGNCR 0000200
++#define ICRNL 0000400
++#define IUCLC 0001000
++#define IXON 0002000
++#define IXANY 0004000
++#define IXOFF 0010000
++#define IMAXBEL 0020000
++#define IUTF8 0040000
++
++/* c_oflag bits */
++#define OPOST 0000001
++#define OLCUC 0000002
++#define ONLCR 0000004
++#define OCRNL 0000010
++#define ONOCR 0000020
++#define ONLRET 0000040
++#define OFILL 0000100
++#define OFDEL 0000200
++#define NLDLY 0000400
++#define NL0 0000000
++#define NL1 0000400
++#define CRDLY 0003000
++#define CR0 0000000
++#define CR1 0001000
++#define CR2 0002000
++#define CR3 0003000
++#define TABDLY 0014000
++#define TAB0 0000000
++#define TAB1 0004000
++#define TAB2 0010000
++#define TAB3 0014000
++#define XTABS 0014000
++#define BSDLY 0020000
++#define BS0 0000000
++#define BS1 0020000
++#define VTDLY 0040000
++#define VT0 0000000
++#define VT1 0040000
++#define FFDLY 0100000
++#define FF0 0000000
++#define FF1 0100000
++
++/* c_cflag bit meaning */
++#define CBAUD 0010017
++#define B0 0000000 /* hang up */
++#define B50 0000001
++#define B75 0000002
++#define B110 0000003
++#define B134 0000004
++#define B150 0000005
++#define B200 0000006
++#define B300 0000007
++#define B600 0000010
++#define B1200 0000011
++#define B1800 0000012
++#define B2400 0000013
++#define B4800 0000014
++#define B9600 0000015
++#define B19200 0000016
++#define B38400 0000017
++#define EXTA B19200
++#define EXTB B38400
++#define CSIZE 0000060
++#define CS5 0000000
++#define CS6 0000020
++#define CS7 0000040
++#define CS8 0000060
++#define CSTOPB 0000100
++#define CREAD 0000200
++#define PARENB 0000400
++#define PARODD 0001000
++#define HUPCL 0002000
++#define CLOCAL 0004000
++#define CBAUDEX 0010000
++#define B57600 0010001
++#define B115200 0010002
++#define B230400 0010003
++#define B460800 0010004
++#define B500000 0010005
++#define B576000 0010006
++#define B921600 0010007
++#define B1000000 0010010
++#define B1152000 0010011
++#define B1500000 0010012
++#define B2000000 0010013
++#define B2500000 0010014
++#define B3000000 0010015
++#define B3500000 0010016
++#define B4000000 0010017
++#define CIBAUD 002003600000 /* input baud rate (not used) */
++#define CMSPAR 010000000000 /* mark or space (stick) parity */
++#define CRTSCTS 020000000000 /* flow control */
++
++/* c_lflag bits */
++#define ISIG 0000001
++#define ICANON 0000002
++#define XCASE 0000004
++#define ECHO 0000010
++#define ECHOE 0000020
++#define ECHOK 0000040
++#define ECHONL 0000100
++#define NOFLSH 0000200
++#define TOSTOP 0000400
++#define ECHOCTL 0001000
++#define ECHOPRT 0002000
++#define ECHOKE 0004000
++#define FLUSHO 0010000
++#define PENDIN 0040000
++#define IEXTEN 0100000
++
++
++/* tcflow() and TCXONC use these */
++#define TCOOFF 0
++#define TCOON 1
++#define TCIOFF 2
++#define TCION 3
++
++/* tcflush() and TCFLSH use these */
++#define TCIFLUSH 0
++#define TCOFLUSH 1
++#define TCIOFLUSH 2
++
++/* tcsetattr uses these */
++#define TCSANOW 0
++#define TCSADRAIN 1
++#define TCSAFLUSH 2
++
++#endif /* __ARCH_NIOS_TERMBITS_H__ */
+diff --git a/include/asm-nios2nommu/termios.h b/include/asm-nios2nommu/termios.h
+new file mode 100644
+index 0000000..db0dddf
+--- /dev/null
++++ b/include/asm-nios2nommu/termios.h
+@@ -0,0 +1,132 @@
++#ifndef _NIOS_TERMIOS_H
++#define _NIOS_TERMIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termios.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/termbits.h>
++#include <asm/ioctls.h>
++
++struct winsize {
++ unsigned short ws_row;
++ unsigned short ws_col;
++ unsigned short ws_xpixel;
++ unsigned short ws_ypixel;
++};
++
++#define NCC 8
++struct termio {
++ unsigned short c_iflag; /* input mode flags */
++ unsigned short c_oflag; /* output mode flags */
++ unsigned short c_cflag; /* control mode flags */
++ unsigned short c_lflag; /* local mode flags */
++ unsigned char c_line; /* line discipline */
++ unsigned char c_cc[NCC]; /* control characters */
++};
++
++#ifdef __KERNEL__
++/* intr=^C quit=^| erase=del kill=^U
++ eof=^D vtime=\0 vmin=\1 sxtc=\0
++ start=^Q stop=^S susp=^Z eol=\0
++ reprint=^R discard=^U werase=^W lnext=^V
++ eol2=\0
++*/
++#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
++#endif
++
++/* modem lines */
++#define TIOCM_LE 0x001
++#define TIOCM_DTR 0x002
++#define TIOCM_RTS 0x004
++#define TIOCM_ST 0x008
++#define TIOCM_SR 0x010
++#define TIOCM_CTS 0x020
++#define TIOCM_CAR 0x040
++#define TIOCM_RNG 0x080
++#define TIOCM_DSR 0x100
++#define TIOCM_CD TIOCM_CAR
++#define TIOCM_RI TIOCM_RNG
++#define TIOCM_OUT1 0x2000
++#define TIOCM_OUT2 0x4000
++#define TIOCM_LOOP 0x8000
++
++/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
++
++/* line disciplines */
++#define N_TTY 0
++#define N_SLIP 1
++#define N_MOUSE 2
++#define N_PPP 3
++#define N_STRIP 4
++#define N_AX25 5
++#define N_X25 6 /* X.25 async */
++#define N_6PACK 7
++#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
++#define N_R3964 9 /* Reserved for Simatic R3964 module */
++#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
++#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
++#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
++#define N_HDLC 13 /* synchronous HDLC */
++#define N_SYNC_PPP 14
++#define N_HCI 15 /* Bluetooth HCI UART */
++
++#ifdef __KERNEL__
++
++/*
++ * Translate a "termio" structure into a "termios". Ugh.
++ */
++#define user_termio_to_kernel_termios(termios, termio) \
++({ \
++ unsigned short tmp; \
++ get_user(tmp, &(termio)->c_iflag); \
++ (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
++ get_user(tmp, &(termio)->c_oflag); \
++ (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
++ get_user(tmp, &(termio)->c_cflag); \
++ (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
++ get_user(tmp, &(termio)->c_lflag); \
++ (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
++ get_user((termios)->c_line, &(termio)->c_line); \
++ copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
++})
++
++/*
++ * Translate a "termios" structure into a "termio". Ugh.
++ */
++#define kernel_termios_to_user_termio(termio, termios) \
++({ \
++ put_user((termios)->c_iflag, &(termio)->c_iflag); \
++ put_user((termios)->c_oflag, &(termio)->c_oflag); \
++ put_user((termios)->c_cflag, &(termio)->c_cflag); \
++ put_user((termios)->c_lflag, &(termio)->c_lflag); \
++ put_user((termios)->c_line, &(termio)->c_line); \
++ copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
++})
++
++#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
++#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TERMIOS_H */
+diff --git a/include/asm-nios2nommu/thread_info.h b/include/asm-nios2nommu/thread_info.h
+new file mode 100644
+index 0000000..6d51e0c
+--- /dev/null
++++ b/include/asm-nios2nommu/thread_info.h
+@@ -0,0 +1,127 @@
++/* thread_info.h: niosnommu low-level thread information
++ * adapted from the m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2002 Microtronix Datacom
++ *
++ * - Incorporating suggestions made by Linus Torvalds and Dave Miller
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_THREAD_INFO_H
++#define _ASM_THREAD_INFO_H
++
++#include <asm/page.h>
++
++#ifdef __KERNEL__
++
++#ifndef __ASSEMBLY__
++
++/*
++ * low level task data.
++ */
++struct thread_info {
++ struct task_struct *task; /* main task structure */
++ struct exec_domain *exec_domain; /* execution domain */
++ unsigned long flags; /* low level flags */
++ int cpu; /* cpu we're on */
++ int preempt_count; /* 0 => preemptable, <0 => BUG*/
++ struct restart_block restart_block;
++};
++
++/*
++ * macros/functions for gaining access to the thread information structure
++ */
++#define INIT_THREAD_INFO(tsk) \
++{ \
++ .task = &tsk, \
++ .exec_domain = &default_exec_domain, \
++ .flags = 0, \
++ .cpu = 0, \
++ .preempt_count = 1, \
++ .restart_block = { \
++ .fn = do_no_restart_syscall, \
++ }, \
++}
++
++#define init_thread_info (init_thread_union.thread_info)
++#define init_stack (init_thread_union.stack)
++
++
++/* how to get the thread information struct from C
++ usable only in supervisor mode */
++static inline struct thread_info *current_thread_info(void)
++{
++ struct thread_info *ti;
++ __asm__ __volatile__(
++ "mov %0, sp\n"
++ "and %0, %0, %1\n"
++ : "=&r"(ti)
++ : "r" (~(THREAD_SIZE-1))
++ );
++ return ti;
++}
++
++/* thread information allocation */
++#define alloc_thread_info(tsk) ((struct thread_info *) \
++ __get_free_pages(GFP_KERNEL, 1))
++#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
++#define put_thread_info(ti) put_task_struct((ti)->task)
++
++#define PREEMPT_ACTIVE 0x4000000
++
++/*
++ * thread information flag bit numbers
++ */
++#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
++#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
++#define TIF_SIGPENDING 2 /* signal pending */
++#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
++#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
++ TIF_NEED_RESCHED */
++#define TIF_MEMDIE 5
++
++/* as above, but as bit values */
++#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
++#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
++#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
++#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
++#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
++
++#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
++
++#else /* __ASSEMBLY__ */
++
++/* how to get the thread information struct from ASM
++ usable only in supervisor mode */
++.macro GET_THREAD_INFO reg
++.if THREAD_SIZE & 0xffff0000
++ andhi \reg, sp, %hi(~(THREAD_SIZE-1))
++.else
++ addi \reg, r0, %lo(~(THREAD_SIZE-1))
++ and \reg, \reg, sp
++.endif
++.endm
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_THREAD_INFO_H */
+diff --git a/include/asm-nios2nommu/timer_struct.h b/include/asm-nios2nommu/timer_struct.h
+new file mode 100644
+index 0000000..d811a37
+--- /dev/null
++++ b/include/asm-nios2nommu/timer_struct.h
+@@ -0,0 +1,38 @@
++
++// ----------------------------------------------
++// Timer Peripheral
++
++// Timer Registers
++typedef volatile struct
++ {
++ int np_timerstatus; // read only, 2 bits (any write to clear TO)
++ int np_timercontrol; // write/readable, 4 bits
++ int np_timerperiodl; // write/readable, 16 bits
++ int np_timerperiodh; // write/readable, 16 bits
++ int np_timersnapl; // read only, 16 bits
++ int np_timersnaph; // read only, 16 bits
++ } np_timer;
++
++// Timer Register Bits
++enum
++ {
++ np_timerstatus_run_bit = 1, // timer is running
++ np_timerstatus_to_bit = 0, // timer has timed out
++
++ np_timercontrol_stop_bit = 3, // stop the timer
++ np_timercontrol_start_bit = 2, // start the timer
++ np_timercontrol_cont_bit = 1, // continous mode
++ np_timercontrol_ito_bit = 0, // enable time out interrupt
++
++ np_timerstatus_run_mask = (1<<1), // timer is running
++ np_timerstatus_to_mask = (1<<0), // timer has timed out
++
++ np_timercontrol_stop_mask = (1<<3), // stop the timer
++ np_timercontrol_start_mask = (1<<2), // start the timer
++ np_timercontrol_cont_mask = (1<<1), // continous mode
++ np_timercontrol_ito_mask = (1<<0) // enable time out interrupt
++ };
++
++// Timer Routines
++int nr_timer_milliseconds(void); // Starts on first call, hogs timer1.
++
+diff --git a/include/asm-nios2nommu/timex.h b/include/asm-nios2nommu/timex.h
+new file mode 100644
+index 0000000..abd48cc
+--- /dev/null
++++ b/include/asm-nios2nommu/timex.h
+@@ -0,0 +1,48 @@
++#ifndef _ASMNIOS2NOMMU_TIMEX_H
++#define _ASMNIOS2NOMMU_TIMEX_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/timex.h
++ *
++ * timex specifications
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++
++#define CLOCK_TICK_RATE nasys_clock_freq /* Underlying HZ */
++
++#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
++
++#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
++ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
++ << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
++
++typedef unsigned long cycles_t;
++
++static inline cycles_t get_cycles(void)
++{
++ return 0;
++}
++
++#endif
+diff --git a/include/asm-nios2nommu/tlb.h b/include/asm-nios2nommu/tlb.h
+new file mode 100644
+index 0000000..c597b25
+--- /dev/null
++++ b/include/asm-nios2nommu/tlb.h
+@@ -0,0 +1,35 @@
++#ifndef __NIOS_TLB_H__
++#define __NIOS_TLB_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlb.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd
++ * Copyright (C) 2002 NEC Corporation
++ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Written by Miles Bader <miles@gnu.org>
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define tlb_flush(tlb) ((void)0)
++
++#include <asm-generic/tlb.h>
++
++#endif /* __NIOS_TLB_H__ */
++
+diff --git a/include/asm-nios2nommu/tlbflush.h b/include/asm-nios2nommu/tlbflush.h
+new file mode 100644
+index 0000000..63cbe52
+--- /dev/null
++++ b/include/asm-nios2nommu/tlbflush.h
+@@ -0,0 +1,86 @@
++#ifndef _NIOS2NOMMU_TLBFLUSH_H
++#define _NIOS2NOMMU_TLBFLUSH_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlbflush.h
++ *
++ * Ported from m68knommu.
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm/setup.h>
++
++/*
++ * flush all user-space atc entries.
++ */
++static inline void __flush_tlb(void)
++{
++ BUG();
++}
++
++static inline void __flush_tlb_one(unsigned long addr)
++{
++ BUG();
++}
++
++#define flush_tlb() __flush_tlb()
++
++/*
++ * flush all atc entries (both kernel and user-space entries).
++ */
++static inline void flush_tlb_all(void)
++{
++ BUG();
++}
++
++static inline void flush_tlb_mm(struct mm_struct *mm)
++{
++ BUG();
++}
++
++static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
++{
++ BUG();
++}
++
++static inline void flush_tlb_range(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_kernel_page(unsigned long addr)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_pgtables(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++#endif /* _NIOS2NOMMU_TLBFLUSH_H */
+diff --git a/include/asm-nios2nommu/topology.h b/include/asm-nios2nommu/topology.h
+new file mode 100644
+index 0000000..cfe1054
+--- /dev/null
++++ b/include/asm-nios2nommu/topology.h
+@@ -0,0 +1,30 @@
++#ifndef _ASM_NIOS2NOMMU_TOPOLOGY_H
++#define _ASM_NIOS2NOMMU_TOPOLOGY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/topology.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/topology.h>
++
++#endif /* _ASM_NIOS2NOMMU_TOPOLOGY_H */
+diff --git a/include/asm-nios2nommu/traps.h b/include/asm-nios2nommu/traps.h
+new file mode 100644
+index 0000000..e03ef7f
+--- /dev/null
++++ b/include/asm-nios2nommu/traps.h
+@@ -0,0 +1,27 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_TRAPS_H
++#define _NIOS2_TRAPS_H
++
++#define TRAP_ID_SYSCALL 0
++#define TRAP_ID_APPDEBUG 1
++#endif /* !(_NIOS2_TRAPS_H) */
+diff --git a/include/asm-nios2nommu/types.h b/include/asm-nios2nommu/types.h
+new file mode 100644
+index 0000000..dd7a48e
+--- /dev/null
++++ b/include/asm-nios2nommu/types.h
+@@ -0,0 +1,91 @@
++#ifndef _NIOS_TYPES_H
++#define _NIOS_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/types.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is never included by application software unless
++ * explicitly requested (e.g., via linux/types.h) in which case the
++ * application is Linux specific so (user-) name space pollution is
++ * not a major issue. However, for interoperability, libraries still
++ * need to be careful to avoid a name clashes.
++ */
++
++#ifndef __ASSEMBLY__
++
++typedef unsigned short umode_t;
++
++/*
++ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
++ * header files exported to user space
++ */
++
++typedef __signed__ char __s8;
++typedef unsigned char __u8;
++
++typedef __signed__ short __s16;
++typedef unsigned short __u16;
++
++typedef __signed__ int __s32;
++typedef unsigned int __u32;
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
++typedef __signed__ long long __s64;
++typedef unsigned long long __u64;
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++/*
++ * These aren't exported outside the kernel to avoid name space clashes
++ */
++#ifdef __KERNEL__
++
++#define BITS_PER_LONG 32
++
++#ifndef __ASSEMBLY__
++
++typedef signed char s8;
++typedef unsigned char u8;
++
++typedef signed short s16;
++typedef unsigned short u16;
++
++typedef signed int s32;
++typedef unsigned int u32;
++
++typedef signed long long s64;
++typedef unsigned long long u64;
++
++/* DMA addresses are always 32-bits wide */
++
++typedef u32 dma_addr_t;
++typedef u32 dma64_addr_t;
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TYPES_H */
+diff --git a/include/asm-nios2nommu/uaccess.h b/include/asm-nios2nommu/uaccess.h
+new file mode 100644
+index 0000000..e7ea20a
+--- /dev/null
++++ b/include/asm-nios2nommu/uaccess.h
+@@ -0,0 +1,184 @@
++#ifndef __NIOS2NOMMU_UACCESS_H
++#define __NIOS2NOMMU_UACCESS_H
++
++/*--------------------------------------------------------------------
++ *
++ * asm-nios2nommu/uaccess.h
++ *
++ * User space memory access functions
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Ported from asm-m68knommu/uaccess.h --wentao
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <asm/segment.h>
++#include <asm/nios.h>
++
++#define VERIFY_READ 0
++#define VERIFY_WRITE 1
++
++#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size))
++
++static inline int _access_ok(unsigned long addr, unsigned long size)
++{
++ return (((unsigned long)addr < (unsigned long)nasys_program_mem_end) &&
++ (((unsigned long)addr >= (unsigned long)nasys_program_mem)));
++}
++
++extern inline int verify_area(int type, const void * addr, unsigned long size)
++{
++ return access_ok(type,addr,size)?0:-EFAULT;
++}
++
++/*
++ * The exception table consists of pairs of addresses: the first is the
++ * address of an instruction that is allowed to fault, and the second is
++ * the address at which the program should continue. No registers are
++ * modified, so it is entirely up to the continuation code to figure out
++ * what to do.
++ *
++ * All the routines below use bits of fixup code that are out of line
++ * with the main instruction path. This means when everything is well,
++ * we don't even have to jump over them. Further, they do not intrude
++ * on our cache or tlb entries.
++ */
++
++#define ARCH_HAS_SEARCH_EXTABLE
++//;dgt2;tmp;
++
++struct exception_table_entry
++{
++ unsigned long insn, fixup;
++};
++
++/* Returns 0 if exception not found and fixup otherwise. */
++extern unsigned long search_exception_table(unsigned long);
++
++
++/*
++ * These are the main single-value transfer routines. They automatically
++ * use the right size if we just have the right pointer type.
++ */
++
++#define put_user(x, ptr) \
++({ \
++ int __pu_err = 0; \
++ typeof(*(ptr)) __pu_val = (x); \
++ switch (sizeof (*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __pu_err = __put_user_bad(); \
++ break; \
++ } \
++ __pu_err; \
++})
++#define __put_user(x, ptr) put_user(x, ptr)
++
++extern int __put_user_bad(void);
++
++/*
++ * Tell gcc we read from memory instead of writing: this is because
++ * we do not write to any memory gcc knows about, so there are no
++ * aliasing issues.
++ */
++
++#define __ptr(x) ((unsigned long *)(x))
++
++#define get_user(x, ptr) \
++({ \
++ int __gu_err = 0; \
++ typeof(*(ptr)) __gu_val = 0; \
++ switch (sizeof(*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(&__gu_val, ptr, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __gu_val = 0; \
++ __gu_err = __get_user_bad(); \
++ break; \
++ } \
++ (x) = __gu_val; \
++ __gu_err; \
++})
++#define __get_user(x, ptr) get_user(x, ptr)
++
++extern int __get_user_bad(void);
++
++#define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
++#define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
++
++#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
++#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
++#define __copy_to_user_inatomic __copy_to_user
++#define __copy_from_user_inatomic __copy_from_user
++
++#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
++
++#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
++
++/*
++ * Copy a null terminated string from userspace.
++ */
++
++static inline long
++strncpy_from_user(char *dst, const char *src, long count)
++{
++ char *tmp;
++ strncpy(dst, src, count);
++ for (tmp = dst; *tmp && count > 0; tmp++, count--)
++ ;
++ return(tmp - dst); /* DAVIDM should we count a NUL ? check getname */
++}
++
++/*
++ * Return the size of a string (including the ending 0)
++ *
++ * Return 0 on exception, a value greater than N if too long
++ */
++static inline long strnlen_user(const char *src, long n)
++{
++ return(strlen(src) + 1); /* DAVIDM make safer */
++}
++
++#define strlen_user(str) strnlen_user(str, 32767)
++
++/*
++ * Zero Userspace
++ */
++
++static inline unsigned long __clear_user(void *to, unsigned long n)
++{
++ memset(to, 0, n);
++ return(0);
++}
++
++#define clear_user(to, n) __clear_user(to, n)
++
++#endif /* _NIOS2NOMMU_UACCESS_H */
+diff --git a/include/asm-nios2nommu/uart_struct.h b/include/asm-nios2nommu/uart_struct.h
+new file mode 100644
+index 0000000..d955192
+--- /dev/null
++++ b/include/asm-nios2nommu/uart_struct.h
+@@ -0,0 +1,83 @@
++
++// UART Registers
++typedef volatile struct
++ {
++ int np_uartrxdata; // Read-only, 8-bit
++ int np_uarttxdata; // Write-only, 8-bit
++ int np_uartstatus; // Read-only, 8-bit
++ int np_uartcontrol; // Read/Write, 9-bit
++ int np_uartdivisor; // Read/Write, 16-bit, optional
++ int np_uartendofpacket; // Read/Write, end-of-packet character
++ } np_uart;
++
++// UART Status Register Bits
++enum
++ {
++ np_uartstatus_eop_bit = 12,
++ np_uartstatus_cts_bit = 11,
++ np_uartstatus_dcts_bit = 10,
++ np_uartstatus_e_bit = 8,
++ np_uartstatus_rrdy_bit = 7,
++ np_uartstatus_trdy_bit = 6,
++ np_uartstatus_tmt_bit = 5,
++ np_uartstatus_toe_bit = 4,
++ np_uartstatus_roe_bit = 3,
++ np_uartstatus_brk_bit = 2,
++ np_uartstatus_fe_bit = 1,
++ np_uartstatus_pe_bit = 0,
++
++ np_uartstatus_eop_mask = (1<<12),
++ np_uartstatus_cts_mask = (1<<11),
++ np_uartstatus_dcts_mask = (1<<10),
++ np_uartstatus_e_mask = (1<<8),
++ np_uartstatus_rrdy_mask = (1<<7),
++ np_uartstatus_trdy_mask = (1<<6),
++ np_uartstatus_tmt_mask = (1<<5),
++ np_uartstatus_toe_mask = (1<<4),
++ np_uartstatus_roe_mask = (1<<3),
++ np_uartstatus_brk_mask = (1<<2),
++ np_uartstatus_fe_mask = (1<<1),
++ np_uartstatus_pe_mask = (1<<0)
++ };
++
++// UART Control Register Bits
++enum
++ {
++ np_uartcontrol_ieop_bit = 12,
++ np_uartcontrol_rts_bit = 11,
++ np_uartcontrol_idcts_bit = 10,
++ np_uartcontrol_tbrk_bit = 9,
++ np_uartcontrol_ie_bit = 8,
++ np_uartcontrol_irrdy_bit = 7,
++ np_uartcontrol_itrdy_bit = 6,
++ np_uartcontrol_itmt_bit = 5,
++ np_uartcontrol_itoe_bit = 4,
++ np_uartcontrol_iroe_bit = 3,
++ np_uartcontrol_ibrk_bit = 2,
++ np_uartcontrol_ife_bit = 1,
++ np_uartcontrol_ipe_bit = 0,
++
++ np_uartcontrol_ieop_mask = (1<<12),
++ np_uartcontrol_rts_mask = (1<<11),
++ np_uartcontrol_idcts_mask = (1<<10),
++ np_uartcontrol_tbrk_mask = (1<<9),
++ np_uartcontrol_ie_mask = (1<<8),
++ np_uartcontrol_irrdy_mask = (1<<7),
++ np_uartcontrol_itrdy_mask = (1<<6),
++ np_uartcontrol_itmt_mask = (1<<5),
++ np_uartcontrol_itoe_mask = (1<<4),
++ np_uartcontrol_iroe_mask = (1<<3),
++ np_uartcontrol_ibrk_mask = (1<<2),
++ np_uartcontrol_ife_mask = (1<<1),
++ np_uartcontrol_ipe_mask = (1<<0)
++ };
++
++// UART Routines
++int nr_uart_rxchar(np_uart *uartBase); // 0 for default UART
++void nr_uart_txcr(void);
++void nr_uart_txchar(int c,np_uart *uartBase); // 0 for default UART
++void nr_uart_txhex(int x); // 16 or 32 bits
++void nr_uart_txhex16(short x);
++void nr_uart_txhex32(long x);
++void nr_uart_txstring(char *s);
++
+diff --git a/include/asm-nios2nommu/ucontext.h b/include/asm-nios2nommu/ucontext.h
+new file mode 100644
+index 0000000..f2e7ce2
+--- /dev/null
++++ b/include/asm-nios2nommu/ucontext.h
+@@ -0,0 +1,63 @@
++#ifndef _NIOSKNOMMU_UCONTEXT_H
++#define _NIOSKNOMMU_UCONTEXT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/ucontext.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++typedef int greg_t;
++#define NGREG 32
++typedef greg_t gregset_t[NGREG];
++
++#ifdef CONFIG_FPU
++typedef struct fpregset {
++ int f_pcr;
++ int f_psr;
++ int f_fpiaddr;
++ int f_fpregs[8][3];
++} fpregset_t;
++#endif
++
++struct mcontext {
++ int version;
++ int status_extension;
++ gregset_t gregs;
++#ifdef CONFIG_FPU
++ fpregset_t fpregs;
++#endif
++};
++
++#define MCONTEXT_VERSION 2
++
++struct ucontext {
++ unsigned long uc_flags;
++ struct ucontext *uc_link;
++ stack_t uc_stack;
++ struct mcontext uc_mcontext;
++#ifdef CONFIG_FPU
++ unsigned long uc_filler[80];
++#endif
++ sigset_t uc_sigmask; /* mask last for extensibility */
++};
++
++#endif
+diff --git a/include/asm-nios2nommu/unaligned.h b/include/asm-nios2nommu/unaligned.h
+new file mode 100644
+index 0000000..4876185
+--- /dev/null
++++ b/include/asm-nios2nommu/unaligned.h
+@@ -0,0 +1,6 @@
++#ifndef __NIOS2_UNALIGNED_H
++#define __NIOS2_UNALIGNED_H
++
++#include <asm-generic/unaligned.h>
++
++#endif /* __NIOS2_UNALIGNED_H */
+diff --git a/include/asm-nios2nommu/unistd.h b/include/asm-nios2nommu/unistd.h
+new file mode 100644
+index 0000000..43cd165
+--- /dev/null
++++ b/include/asm-nios2nommu/unistd.h
+@@ -0,0 +1,395 @@
++#ifndef _ASM_NIOS_UNISTD_H_
++#define _ASM_NIOS_UNISTD_H_
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/unistd.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * //vic - kernel_thread moved to process.c
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/traps.h>
++
++/* TRAP isr expects the trap# (syscall=#TRAP_ID_SYSCALL) in r2,
++ * the syscall # in r3, and arguments in r4, r5, ...
++ * Return argument expected in r2.
++ */
++
++#define __NR_restart_syscall 0
++#define __NR_exit 1
++#define __NR_fork 2
++#define __NR_read 3
++#define __NR_write 4
++#define __NR_open 5
++#define __NR_close 6
++#define __NR_waitpid 7
++#define __NR_creat 8
++#define __NR_link 9
++#define __NR_unlink 10
++#define __NR_execve 11
++#define __NR_chdir 12
++#define __NR_time 13
++#define __NR_mknod 14
++#define __NR_chmod 15
++#define __NR_chown 16
++#define __NR_break 17
++#define __NR_oldstat 18
++#define __NR_lseek 19
++#define __NR_getpid 20
++#define __NR_mount 21
++#define __NR_umount 22
++#define __NR_setuid 23
++#define __NR_getuid 24
++#define __NR_stime 25
++#define __NR_ptrace 26
++#define __NR_alarm 27
++#define __NR_oldfstat 28
++#define __NR_pause 29
++#define __NR_utime 30
++#define __NR_stty 31
++#define __NR_gtty 32
++#define __NR_access 33
++#define __NR_nice 34
++#define __NR_ftime 35
++#define __NR_sync 36
++#define __NR_kill 37
++#define __NR_rename 38
++#define __NR_mkdir 39
++#define __NR_rmdir 40
++#define __NR_dup 41
++#define __NR_pipe 42
++#define __NR_times 43
++#define __NR_prof 44
++#define __NR_brk 45
++#define __NR_setgid 46
++#define __NR_getgid 47
++#define __NR_signal 48
++#define __NR_geteuid 49
++#define __NR_getegid 50
++#define __NR_acct 51
++#define __NR_umount2 52 //vic #define __NR_phys 52
++#define __NR_lock 53
++#define __NR_ioctl 54
++#define __NR_fcntl 55
++#define __NR_mpx 56
++#define __NR_setpgid 57
++#define __NR_ulimit 58
++#define __NR_oldolduname 59
++#define __NR_umask 60
++#define __NR_chroot 61
++#define __NR_ustat 62
++#define __NR_dup2 63
++#define __NR_getppid 64
++#define __NR_getpgrp 65
++#define __NR_setsid 66
++#define __NR_sigaction 67
++#define __NR_sgetmask 68
++#define __NR_ssetmask 69
++#define __NR_setreuid 70
++#define __NR_setregid 71
++#define __NR_sigsuspend 72
++#define __NR_sigpending 73
++#define __NR_sethostname 74
++#define __NR_setrlimit 75
++#define __NR_getrlimit 76
++#define __NR_getrusage 77
++#define __NR_gettimeofday 78
++#define __NR_settimeofday 79
++#define __NR_getgroups 80
++#define __NR_setgroups 81
++#define __NR_select 82
++#define __NR_symlink 83
++#define __NR_oldlstat 84
++#define __NR_readlink 85
++#define __NR_uselib 86
++#define __NR_swapon 87
++#define __NR_reboot 88
++#define __NR_readdir 89
++#define __NR_mmap 90
++#define __NR_munmap 91
++#define __NR_truncate 92
++#define __NR_ftruncate 93
++#define __NR_fchmod 94
++#define __NR_fchown 95
++#define __NR_getpriority 96
++#define __NR_setpriority 97
++#define __NR_profil 98
++#define __NR_statfs 99
++#define __NR_fstatfs 100
++#define __NR_ioperm 101
++#define __NR_socketcall 102
++#define __NR_syslog 103
++#define __NR_setitimer 104
++#define __NR_getitimer 105
++#define __NR_stat 106
++#define __NR_lstat 107
++#define __NR_fstat 108
++#define __NR_olduname 109
++#define __NR_iopl /* 110 */ not supported
++#define __NR_vhangup 111
++#define __NR_idle /* 112 */ Obsolete
++#define __NR_vm86 /* 113 */ not supported
++#define __NR_wait4 114
++#define __NR_swapoff 115
++#define __NR_sysinfo 116
++#define __NR_ipc 117
++#define __NR_fsync 118
++#define __NR_sigreturn 119
++#define __NR_clone 120
++#define __NR_setdomainname 121
++#define __NR_uname 122
++#define __NR_cacheflush 123
++#define __NR_adjtimex 124
++#define __NR_mprotect 125
++#define __NR_sigprocmask 126
++#define __NR_create_module 127
++#define __NR_init_module 128
++#define __NR_delete_module 129
++#define __NR_get_kernel_syms 130
++#define __NR_quotactl 131
++#define __NR_getpgid 132
++#define __NR_fchdir 133
++#define __NR_bdflush 134
++#define __NR_sysfs 135
++#define __NR_personality 136
++#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
++#define __NR_setfsuid 138
++#define __NR_setfsgid 139
++#define __NR__llseek 140
++#define __NR_getdents 141
++#define __NR__newselect 142
++#define __NR_flock 143
++ /* 144 __NR_msync obsolete */
++#define __NR_readv 145
++#define __NR_writev 146
++#define __NR_getsid 147
++#define __NR_fdatasync 148
++#define __NR__sysctl 149
++#define __NR_mlock 150
++#define __NR_munlock 151
++#define __NR_mlockall 152
++#define __NR_munlockall 153
++#define __NR_sched_setparam 154
++#define __NR_sched_getparam 155
++#define __NR_sched_setscheduler 156
++#define __NR_sched_getscheduler 157
++#define __NR_sched_yield 158
++#define __NR_sched_get_priority_max 159
++#define __NR_sched_get_priority_min 160
++#define __NR_sched_rr_get_interval 161
++#define __NR_nanosleep 162
++#define __NR_mremap 163
++#define __NR_setresuid 164
++#define __NR_getresuid 165
++#define __NR_getpagesize 166
++#define __NR_query_module 167
++#define __NR_poll 168
++#define __NR_nfsservctl 169
++#define __NR_setresgid 170
++#define __NR_getresgid 171
++#define __NR_prctl 172
++#define __NR_rt_sigreturn 173
++#define __NR_rt_sigaction 174
++#define __NR_rt_sigprocmask 175
++#define __NR_rt_sigpending 176
++#define __NR_rt_sigtimedwait 177
++#define __NR_rt_sigqueueinfo 178
++#define __NR_rt_sigsuspend 179
++#define __NR_pread 180
++#define __NR_pwrite 181
++#define __NR_lchown 182
++#define __NR_getcwd 183
++#define __NR_capget 184
++#define __NR_capset 185
++#define __NR_sigaltstack 186
++#define __NR_sendfile 187
++#define __NR_getpmsg 188 /* some people actually want streams */
++#define __NR_putpmsg 189 /* some people actually want streams */
++#define __NR_vfork 190
++#define __NR_ugetrlimit 191
++#define __NR_mmap2 192
++#define __NR_truncate64 193
++#define __NR_ftruncate64 194
++#define __NR_stat64 195
++#define __NR_lstat64 196
++#define __NR_fstat64 197
++#define __NR_chown32 198
++#define __NR_getuid32 199
++#define __NR_getgid32 200
++#define __NR_geteuid32 201
++#define __NR_getegid32 202
++#define __NR_setreuid32 203
++#define __NR_setregid32 204
++#define __NR_getgroups32 205
++#define __NR_setgroups32 206
++#define __NR_fchown32 207
++#define __NR_setresuid32 208
++#define __NR_getresuid32 209
++#define __NR_setresgid32 210
++#define __NR_getresgid32 211
++#define __NR_lchown32 212
++#define __NR_setuid32 213
++#define __NR_setgid32 214
++#define __NR_setfsuid32 215
++#define __NR_setfsgid32 216
++#define __NR_pivot_root 217
++/* 218 unused */
++/* 219 unused */
++#define __NR_getdents64 220
++#define __NR_gettid 221
++#define __NR_tkill 222
++#define __NR_setxattr 223
++#define __NR_lsetxattr 224
++#define __NR_fsetxattr 225
++#define __NR_getxattr 226
++#define __NR_lgetxattr 227
++#define __NR_fgetxattr 228
++#define __NR_listxattr 229
++#define __NR_llistxattr 230
++#define __NR_flistxattr 231
++#define __NR_removexattr 232
++#define __NR_lremovexattr 233
++#define __NR_fremovexattr 234
++#define __NR_futex 235
++#define __NR_sendfile64 236
++#define __NR_mincore 237
++#define __NR_madvise 238
++#define __NR_fcntl64 239
++#define __NR_readahead 240
++#define __NR_io_setup 241
++#define __NR_io_destroy 242
++#define __NR_io_getevents 243
++#define __NR_io_submit 244
++#define __NR_io_cancel 245
++#define __NR_fadvise64 246
++#define __NR_exit_group 247
++#define __NR_lookup_dcookie 248
++#define __NR_epoll_create 249
++#define __NR_epoll_ctl 250
++#define __NR_epoll_wait 251
++#define __NR_remap_file_pages 252
++#define __NR_set_tid_address 253
++#define __NR_timer_create 254
++#define __NR_timer_settime 255
++#define __NR_timer_gettime 256
++#define __NR_timer_getoverrun 257
++#define __NR_timer_delete 258
++#define __NR_clock_settime 259
++#define __NR_clock_gettime 260
++#define __NR_clock_getres 261
++#define __NR_clock_nanosleep 262
++#define __NR_statfs64 263
++#define __NR_fstatfs64 264
++#define __NR_tgkill 265
++#define __NR_utimes 266
++#define __NR_fadvise64_64 267
++#define __NR_mbind 268
++#define __NR_get_mempolicy 269
++#define __NR_set_mempolicy 270
++#define __NR_mq_open 271
++#define __NR_mq_unlink 272
++#define __NR_mq_timedsend 273
++#define __NR_mq_timedreceive 274
++#define __NR_mq_notify 275
++#define __NR_mq_getsetattr 276
++#define __NR_waitid 277
++#define __NR_sys_setaltroot 278
++#define __NR_add_key 279
++#define __NR_request_key 280
++#define __NR_keyctl 281
++#define __NR_ioprio_set 282
++#define __NR_ioprio_get 283
++#define __NR_inotify_init 284
++#define __NR_inotify_add_watch 285
++#define __NR_inotify_rm_watch 286
++#define __NR_migrate_pages 287
++#define __NR_openat 288
++#define __NR_mkdirat 289
++#define __NR_mknodat 290
++#define __NR_fchownat 291
++#define __NR_futimesat 292
++#define __NR_fstatat64 293
++#define __NR_unlinkat 294
++#define __NR_renameat 295
++#define __NR_linkat 296
++#define __NR_symlinkat 297
++#define __NR_readlinkat 298
++#define __NR_fchmodat 299
++#define __NR_faccessat 300
++#define __NR_pselect6 301
++#define __NR_ppoll 302
++#define __NR_unshare 303
++#define __NR_set_robust_list 304
++#define __NR_get_robust_list 305
++#define __NR_splice 306
++#define __NR_sync_file_range 307
++#define __NR_tee 308
++#define __NR_vmsplice 309
++#define __NR_move_pages 310
++#define __NR_sched_setaffinity 311
++#define __NR_sched_getaffinity 312
++#define __NR_kexec_load 313
++#define __NR_getcpu 314
++#define __NR_epoll_pwait 315
++#define __NR_utimensat 316
++#define __NR_signalfd 317
++#define __NR_timerfd 318
++#define __NR_eventfd 319
++#define __NR_pread64 320
++#define __NR_pwrite64 321
++
++#ifdef __KERNEL__
++#define NR_syscalls 322
++
++#define __ARCH_WANT_IPC_PARSE_VERSION
++#define __ARCH_WANT_OLD_READDIR
++#define __ARCH_WANT_OLD_STAT
++#define __ARCH_WANT_STAT64
++#define __ARCH_WANT_SYS_ALARM
++#define __ARCH_WANT_SYS_GETHOSTNAME
++#define __ARCH_WANT_SYS_PAUSE
++#define __ARCH_WANT_SYS_SGETMASK
++#define __ARCH_WANT_SYS_SIGNAL
++#define __ARCH_WANT_SYS_TIME
++#define __ARCH_WANT_SYS_UTIME
++#define __ARCH_WANT_SYS_WAITPID
++#define __ARCH_WANT_SYS_SOCKETCALL
++#define __ARCH_WANT_SYS_FADVISE64
++#define __ARCH_WANT_SYS_GETPGRP
++#define __ARCH_WANT_SYS_LLSEEK
++#define __ARCH_WANT_SYS_NICE
++#define __ARCH_WANT_SYS_OLD_GETRLIMIT
++#define __ARCH_WANT_SYS_OLDUMOUNT
++#define __ARCH_WANT_SYS_SIGPENDING
++#define __ARCH_WANT_SYS_SIGPROCMASK
++#define __ARCH_WANT_SYS_RT_SIGACTION
++
++/*
++ * "Conditional" syscalls
++ *
++ * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
++ * but it doesn't work on all toolchains, so we just do it by hand
++ */
++#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_NIOS_UNISTD_H_ */
+diff --git a/include/asm-nios2nommu/user.h b/include/asm-nios2nommu/user.h
+new file mode 100644
+index 0000000..3cdc2ba
+--- /dev/null
++++ b/include/asm-nios2nommu/user.h
+@@ -0,0 +1,112 @@
++#ifndef _NIOS2NOMMU_USER_H
++#define _NIOS2NOMMU_USER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/user.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/page.h>
++
++/* Core file format: The core file is written in such a way that gdb
++ can understand it and provide useful information to the user (under
++ linux we use the 'trad-core' bfd). There are quite a number of
++ obstacles to being able to view the contents of the floating point
++ registers, and until these are solved you will not be able to view the
++ contents of them. Actually, you can read in the core file and look at
++ the contents of the user struct to find out what the floating point
++ registers contain.
++ The actual file contents are as follows:
++ UPAGE: 1 page consisting of a user struct that tells gdb what is present
++ in the file. Directly after this is a copy of the task_struct, which
++ is currently not used by gdb, but it may come in useful at some point.
++ All of the registers are stored as part of the upage. The upage should
++ always be only one page.
++ DATA: The data area is stored. We use current->end_text to
++ current->brk to pick up all of the user variables, plus any memory
++ that may have been malloced. No attempt is made to determine if a page
++ is demand-zero or if a page is totally unused, we just cover the entire
++ range. All of the addresses are rounded in such a way that an integral
++ number of pages is written.
++ STACK: We need the stack information in order to get a meaningful
++ backtrace. We need to write the data from (esp) to
++ current->start_stack, so we round each of these off in order to be able
++ to write an integer number of pages.
++ The minimum core file size is 3 pages, or 12288 bytes.
++*/
++
++struct user_m68kfp_struct {
++ unsigned long fpregs[8*3]; /* fp0-fp7 registers */
++ unsigned long fpcntl[3]; /* fp control regs */
++};
++
++/* This is needs more work, probably should look like gdb useage */
++struct user_regs_struct {
++ long r1,r2,r3,r4,r5,r6,r7,r8;
++ long r9,r10,r11,r12,r13,r14,r15;
++ long r16,r17,r18,r19,r20,r21,r22,r23;
++ long gp;
++ long sp;
++ long ra;
++ long fp;
++ long orig_r2;
++ long estatus;
++ long status_extension;
++ long ea;
++};
++
++
++/* When the kernel dumps core, it starts by dumping the user struct -
++ this will be used by gdb to figure out where the data and stack segments
++ are within the file, and what virtual addresses to use. */
++struct user{
++/* We start with the registers, to mimic the way that "memory" is returned
++ from the ptrace(3,...) function. */
++ struct user_regs_struct regs; /* Where the registers are actually stored */
++/* ptrace does not yet supply these. Someday.... */
++ int u_fpvalid; /* True if math co-processor being used. */
++ /* for this mess. Not yet used. */
++ struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
++/* The rest of this junk is to help gdb figure out what goes where */
++ unsigned long int u_tsize; /* Text segment size (pages). */
++ unsigned long int u_dsize; /* Data segment size (pages). */
++ unsigned long int u_ssize; /* Stack segment size (pages). */
++ unsigned long start_code; /* Starting virtual address of text. */
++ unsigned long start_stack; /* Starting virtual address of stack area.
++ This is actually the bottom of the stack,
++ the top of the stack is always found in the
++ esp register. */
++ long int signal; /* Signal that caused the core dump. */
++ int reserved; /* No longer used */
++ struct user_regs_struct *u_ar0;
++ /* Used by gdb to help find the values for */
++ /* the registers. */
++ struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
++ unsigned long magic; /* To uniquely identify a core file */
++ char u_comm[32]; /* User command that was responsible */
++};
++#define NBPG PAGE_SIZE
++#define UPAGES 1
++#define HOST_TEXT_START_ADDR (u.start_code)
++#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
++
++#endif
+diff --git a/include/asm-nios2nommu/virtconvert.h b/include/asm-nios2nommu/virtconvert.h
+new file mode 100644
+index 0000000..89bf899
+--- /dev/null
++++ b/include/asm-nios2nommu/virtconvert.h
+@@ -0,0 +1,46 @@
++#ifndef __NIOS_VIRT_CONVERT__
++#define __NIOS_VIRT_CONVERT__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/virtconvert.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Macros used for converting between virtual and physical mappings.
++ */
++
++#ifdef __KERNEL__
++
++#include <asm/setup.h>
++#include <asm/page.h>
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#endif /*__KERNEL__ */
++#endif /*__NIOS_VIRT_CONVERT__*/
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.25.9-export-linux-aout.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.25.9-export-linux-aout.patch
new file mode 100644
index 0000000000..972fa76b06
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-2.6.25.9-export-linux-aout.patch
@@ -0,0 +1,24 @@
+[PATCH] export linux/a.out.h
+
+Export linux/a.out.h like we do for asm/a.out.h. One minor complication is
+that the interesting stuff is protected by an CONFIG_ARCH_SUPPORTS_AOUT ifdef,
+so make sure this gets defined for unifdef.
+
+Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
+---
+ include/linux/Kbuild | 2 ++
+ 1 file changed, 2 insertions(+)
+
+Index: linux-2.6.25.6/include/linux/Kbuild
+===================================================================
+--- linux-2.6.25.6.orig/include/linux/Kbuild
++++ linux-2.6.25.6/include/linux/Kbuild
+@@ -159,6 +159,8 @@
+ header-y += videotext.h
+ header-y += x25.h
+
++UNIFDEF += -DCONFIG_ARCH_SUPPORTS_AOUT
++unifdef-y += a.out.h
+ unifdef-y += acct.h
+ unifdef-y += adb.h
+ unifdef-y += adfs_fs.h
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11-nios2nommu.patch.conditional b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11-nios2nommu.patch.conditional
new file mode 100644
index 0000000000..b8c3fff8f0
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11-nios2nommu.patch.conditional
@@ -0,0 +1,13527 @@
+--- linux/include/asm-generic/4level-fixup.h
++++ linux/include/asm-generic/4level-fixup.h
+@@ -0,0 +1,34 @@
++#ifndef _4LEVEL_FIXUP_H
++#define _4LEVEL_FIXUP_H
++
++#define __ARCH_HAS_4LEVEL_HACK
++
++#define PUD_SIZE PGDIR_SIZE
++#define PUD_MASK PGDIR_MASK
++#define PTRS_PER_PUD 1
++
++#define pud_t pgd_t
++
++#define pmd_alloc(mm, pud, address) \
++({ pmd_t *ret; \
++ if (pgd_none(*pud)) \
++ ret = __pmd_alloc(mm, pud, address); \
++ else \
++ ret = pmd_offset(pud, address); \
++ ret; \
++})
++
++#define pud_alloc(mm, pgd, address) (pgd)
++#define pud_offset(pgd, start) (pgd)
++#define pud_none(pud) 0
++#define pud_bad(pud) 0
++#define pud_present(pud) 1
++#define pud_ERROR(pud) do { } while (0)
++#define pud_clear(pud) pgd_clear(pud)
++
++#undef pud_free_tlb
++#define pud_free_tlb(tlb, x) do { } while (0)
++#define pud_free(x) do { } while (0)
++#define __pud_free_tlb(tlb, x) do { } while (0)
++
++#endif
+--- linux/include/asm-generic/bitops.h
++++ linux/include/asm-generic/bitops.h
+@@ -0,0 +1,81 @@
++#ifndef _ASM_GENERIC_BITOPS_H_
++#define _ASM_GENERIC_BITOPS_H_
++
++/*
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents. You should
++ * recode these in the native assembly language, if at all possible.
++ * To guarantee atomicity, these routines call cli() and sti() to
++ * disable interrupts while they operate. (You have to provide inline
++ * routines to cli() and sti().)
++ *
++ * Also note, these routines assume that you have 32 bit longs.
++ * You will have to change this if you are trying to port Linux to the
++ * Alpha architecture or to a Cray. :-)
++ *
++ * C language equivalents written by Theodore Ts'o, 9/26/92
++ */
++
++extern __inline__ int set_bit(int nr,long * addr)
++{
++ int mask, retval;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ cli();
++ retval = (mask & *addr) != 0;
++ *addr |= mask;
++ sti();
++ return retval;
++}
++
++extern __inline__ int clear_bit(int nr, long * addr)
++{
++ int mask, retval;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ cli();
++ retval = (mask & *addr) != 0;
++ *addr &= ~mask;
++ sti();
++ return retval;
++}
++
++extern __inline__ int test_bit(int nr, const unsigned long * addr)
++{
++ int mask;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ return ((mask & *addr) != 0);
++}
++
++/*
++ * fls: find last bit set.
++ */
++
++#define fls(x) generic_fls(x)
++
++#ifdef __KERNEL__
++
++/*
++ * ffs: find first bit set. This is defined the same way as
++ * the libc and compiler builtin ffs routines, therefore
++ * differs in spirit from the above ffz (man ffs).
++ */
++
++#define ffs(x) generic_ffs(x)
++
++/*
++ * hweightN: returns the hamming weight (i.e. the number
++ * of bits set) of a N-bit word
++ */
++
++#define hweight32(x) generic_hweight32(x)
++#define hweight16(x) generic_hweight16(x)
++#define hweight8(x) generic_hweight8(x)
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_GENERIC_BITOPS_H */
+--- linux/include/asm-generic/bug.h
++++ linux/include/asm-generic/bug.h
+@@ -0,0 +1,34 @@
++#ifndef _ASM_GENERIC_BUG_H
++#define _ASM_GENERIC_BUG_H
++
++#include <linux/compiler.h>
++// #include <linux/config.h>
++
++#ifndef HAVE_ARCH_BUG
++#define BUG() do { \
++ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
++ panic("BUG!"); \
++} while (0)
++#endif
++
++#ifndef HAVE_ARCH_PAGE_BUG
++#define PAGE_BUG(page) do { \
++ printk("page BUG for page at %p\n", page); \
++ BUG(); \
++} while (0)
++#endif
++
++#ifndef HAVE_ARCH_BUG_ON
++#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
++#endif
++
++#ifndef HAVE_ARCH_WARN_ON
++#define WARN_ON(condition) do { \
++ if (unlikely((condition)!=0)) { \
++ printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
++ dump_stack(); \
++ } \
++} while (0)
++#endif
++
++#endif
+--- linux/include/asm-generic/cpumask_arith.h
++++ linux/include/asm-generic/cpumask_arith.h
+@@ -0,0 +1,49 @@
++#ifndef __ASM_GENERIC_CPUMASK_ARITH_H
++#define __ASM_GENERIC_CPUMASK_ARITH_H
++
++/*
++ * Arithmetic type -based cpu bitmaps. A single unsigned long is used
++ * to contain the whole cpu bitmap.
++ */
++
++#define cpu_set(cpu, map) set_bit(cpu, &(map))
++#define cpu_clear(cpu, map) clear_bit(cpu, &(map))
++#define cpu_isset(cpu, map) test_bit(cpu, &(map))
++#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, &(map))
++
++#define cpus_and(dst,src1,src2) do { dst = (src1) & (src2); } while (0)
++#define cpus_or(dst,src1,src2) do { dst = (src1) | (src2); } while (0)
++#define cpus_clear(map) do { map = 0; } while (0)
++#define cpus_complement(map) do { map = ~(map); } while (0)
++#define cpus_equal(map1, map2) ((map1) == (map2))
++#define cpus_empty(map) ((map) == 0)
++#define cpus_addr(map) (&(map))
++
++#if BITS_PER_LONG == 32
++#define cpus_weight(map) hweight32(map)
++#elif BITS_PER_LONG == 64
++#define cpus_weight(map) hweight64(map)
++#endif
++
++#define cpus_shift_right(dst, src, n) do { dst = (src) >> (n); } while (0)
++#define cpus_shift_left(dst, src, n) do { dst = (src) << (n); } while (0)
++
++#define any_online_cpu(map) \
++({ \
++ cpumask_t __tmp__; \
++ cpus_and(__tmp__, map, cpu_online_map); \
++ __tmp__ ? first_cpu(__tmp__) : NR_CPUS; \
++})
++
++#define CPU_MASK_ALL (~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS))
++#define CPU_MASK_NONE ((cpumask_t)0)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce(map) ((unsigned long)(map))
++#define cpus_promote(map) ({ map; })
++#define cpumask_of_cpu(cpu) ({ ((cpumask_t)1) << (cpu); })
++
++#define first_cpu(map) __ffs(map)
++#define next_cpu(cpu, map) find_next_bit(&(map), NR_CPUS, cpu + 1)
++
++#endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
+--- linux/include/asm-generic/cpumask_array.h
++++ linux/include/asm-generic/cpumask_array.h
+@@ -0,0 +1,54 @@
++#ifndef __ASM_GENERIC_CPUMASK_ARRAY_H
++#define __ASM_GENERIC_CPUMASK_ARRAY_H
++
++/*
++ * Array-based cpu bitmaps. An array of unsigned longs is used to contain
++ * the bitmap, and then contained in a structure so it may be passed by
++ * value.
++ */
++
++#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
++
++#define cpu_set(cpu, map) set_bit(cpu, (map).mask)
++#define cpu_clear(cpu, map) clear_bit(cpu, (map).mask)
++#define cpu_isset(cpu, map) test_bit(cpu, (map).mask)
++#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, (map).mask)
++
++#define cpus_and(dst,src1,src2) bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)
++#define cpus_or(dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
++#define cpus_clear(map) bitmap_clear((map).mask, NR_CPUS)
++#define cpus_complement(map) bitmap_complement((map).mask, NR_CPUS)
++#define cpus_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, NR_CPUS)
++#define cpus_empty(map) bitmap_empty(map.mask, NR_CPUS)
++#define cpus_addr(map) ((map).mask)
++#define cpus_weight(map) bitmap_weight((map).mask, NR_CPUS)
++#define cpus_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, NR_CPUS)
++#define cpus_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, NR_CPUS)
++#define first_cpu(map) find_first_bit((map).mask, NR_CPUS)
++#define next_cpu(cpu, map) find_next_bit((map).mask, NR_CPUS, cpu + 1)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce(map) ((map).mask[0])
++#define cpus_promote(map) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
++ __cpu_mask.mask[0] = map; \
++ __cpu_mask; \
++ })
++#define cpumask_of_cpu(cpu) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
++ cpu_set(cpu, __cpu_mask); \
++ __cpu_mask; \
++ })
++#define any_online_cpu(map) \
++({ \
++ cpumask_t __tmp__; \
++ cpus_and(__tmp__, map, cpu_online_map); \
++ find_first_bit(__tmp__.mask, NR_CPUS); \
++})
++
++
++/*
++ * um, these need to be usable as static initializers
++ */
++#define CPU_MASK_ALL { {[0 ... CPU_ARRAY_SIZE-1] = ~0UL} }
++#define CPU_MASK_NONE { {[0 ... CPU_ARRAY_SIZE-1] = 0UL} }
++
++#endif /* __ASM_GENERIC_CPUMASK_ARRAY_H */
+--- linux/include/asm-generic/cpumask_const_reference.h
++++ linux/include/asm-generic/cpumask_const_reference.h
+@@ -0,0 +1,29 @@
++#ifndef __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
++#define __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
++
++struct cpumask_ref {
++ const cpumask_t *val;
++};
++
++typedef const struct cpumask_ref cpumask_const_t;
++
++#define mk_cpumask_const(map) ((cpumask_const_t){ &(map) })
++#define cpu_isset_const(cpu, map) cpu_isset(cpu, *(map).val)
++
++#define cpus_and_const(dst,src1,src2) cpus_and(dst,*(src1).val,*(src2).val)
++#define cpus_or_const(dst,src1,src2) cpus_or(dst,*(src1).val,*(src2).val)
++
++#define cpus_equal_const(map1, map2) cpus_equal(*(map1).val, *(map2).val)
++
++#define cpus_copy_const(map1, map2) bitmap_copy((map1).mask, (map2).val->mask, NR_CPUS)
++
++#define cpus_empty_const(map) cpus_empty(*(map).val)
++#define cpus_weight_const(map) cpus_weight(*(map).val)
++#define first_cpu_const(map) first_cpu(*(map).val)
++#define next_cpu_const(cpu, map) next_cpu(cpu, *(map).val)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce_const(map) cpus_coerce(*(map).val)
++#define any_online_cpu_const(map) any_online_cpu(*(map).val)
++
++#endif /* __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H */
+--- linux/include/asm-generic/cpumask_const_value.h
++++ linux/include/asm-generic/cpumask_const_value.h
+@@ -0,0 +1,21 @@
++#ifndef __ASM_GENERIC_CPUMASK_CONST_VALUE_H
++#define __ASM_GENERIC_CPUMASK_CONST_VALUE_H
++
++typedef const cpumask_t cpumask_const_t;
++
++#define mk_cpumask_const(map) (map)
++#define cpu_isset_const(cpu, map) cpu_isset(cpu, map)
++#define cpus_and_const(dst,src1,src2) cpus_and(dst, src1, src2)
++#define cpus_or_const(dst,src1,src2) cpus_or(dst, src1, src2)
++#define cpus_equal_const(map1, map2) cpus_equal(map1, map2)
++#define cpus_empty_const(map) cpus_empty(map)
++#define cpus_copy_const(map1, map2) do { map1 = (cpumask_t)map2; } while (0)
++#define cpus_weight_const(map) cpus_weight(map)
++#define first_cpu_const(map) first_cpu(map)
++#define next_cpu_const(cpu, map) next_cpu(cpu, map)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce_const(map) cpus_coerce(map)
++#define any_online_cpu_const(map) any_online_cpu(map)
++
++#endif /* __ASM_GENERIC_CPUMASK_CONST_VALUE_H */
+--- linux/include/asm-generic/cpumask.h
++++ linux/include/asm-generic/cpumask.h
+@@ -0,0 +1,40 @@
++#ifndef __ASM_GENERIC_CPUMASK_H
++#define __ASM_GENERIC_CPUMASK_H
++
++// #include <linux/config.h>
++#include <linux/kernel.h>
++#include <linux/threads.h>
++#include <linux/types.h>
++#include <linux/bitmap.h>
++
++#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1
++#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
++
++struct cpumask
++{
++ unsigned long mask[CPU_ARRAY_SIZE];
++};
++
++typedef struct cpumask cpumask_t;
++
++#else
++typedef unsigned long cpumask_t;
++#endif
++
++#ifdef CONFIG_SMP
++#if NR_CPUS > BITS_PER_LONG
++#include <asm-generic/cpumask_array.h>
++#else
++#include <asm-generic/cpumask_arith.h>
++#endif
++#else
++#include <asm-generic/cpumask_up.h>
++#endif
++
++#if NR_CPUS <= 4*BITS_PER_LONG
++#include <asm-generic/cpumask_const_value.h>
++#else
++#include <asm-generic/cpumask_const_reference.h>
++#endif
++
++#endif /* __ASM_GENERIC_CPUMASK_H */
+--- linux/include/asm-generic/cpumask_up.h
++++ linux/include/asm-generic/cpumask_up.h
+@@ -0,0 +1,59 @@
++#ifndef __ASM_GENERIC_CPUMASK_UP_H
++#define __ASM_GENERIC_CPUMASK_UP_H
++
++#define cpus_coerce(map) (map)
++
++#define cpu_set(cpu, map) do { (void)(cpu); cpus_coerce(map) = 1UL; } while (0)
++#define cpu_clear(cpu, map) do { (void)(cpu); cpus_coerce(map) = 0UL; } while (0)
++#define cpu_isset(cpu, map) ((void)(cpu), cpus_coerce(map) != 0UL)
++#define cpu_test_and_set(cpu, map) ((void)(cpu), test_and_set_bit(0, &(map)))
++
++#define cpus_and(dst, src1, src2) \
++ do { \
++ if (cpus_coerce(src1) && cpus_coerce(src2)) \
++ cpus_coerce(dst) = 1UL; \
++ else \
++ cpus_coerce(dst) = 0UL; \
++ } while (0)
++
++#define cpus_or(dst, src1, src2) \
++ do { \
++ if (cpus_coerce(src1) || cpus_coerce(src2)) \
++ cpus_coerce(dst) = 1UL; \
++ else \
++ cpus_coerce(dst) = 0UL; \
++ } while (0)
++
++#define cpus_clear(map) do { cpus_coerce(map) = 0UL; } while (0)
++
++#define cpus_complement(map) \
++ do { \
++ cpus_coerce(map) = !cpus_coerce(map); \
++ } while (0)
++
++#define cpus_equal(map1, map2) (cpus_coerce(map1) == cpus_coerce(map2))
++#define cpus_empty(map) (cpus_coerce(map) == 0UL)
++#define cpus_addr(map) (&(map))
++#define cpus_weight(map) (cpus_coerce(map) ? 1UL : 0UL)
++#define cpus_shift_right(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
++#define cpus_shift_left(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
++#define first_cpu(map) (cpus_coerce(map) ? 0 : 1)
++#define next_cpu(cpu, map) 1
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_promote(map) \
++ ({ \
++ cpumask_t __tmp__; \
++ cpus_coerce(__tmp__) = map; \
++ __tmp__; \
++ })
++#define cpumask_of_cpu(cpu) ((void)(cpu), cpus_promote(1))
++#define any_online_cpu(map) (cpus_coerce(map) ? 0 : 1)
++
++/*
++ * um, these need to be usable as static initializers
++ */
++#define CPU_MASK_ALL 1UL
++#define CPU_MASK_NONE 0UL
++
++#endif /* __ASM_GENERIC_CPUMASK_UP_H */
+--- linux/include/asm-generic/cputime.h
++++ linux/include/asm-generic/cputime.h
+@@ -0,0 +1,64 @@
++#ifndef _ASM_GENERIC_CPUTIME_H
++#define _ASM_GENERIC_CPUTIME_H
++
++#include <linux/time.h>
++#include <linux/jiffies.h>
++
++typedef unsigned long cputime_t;
++
++#define cputime_zero (0UL)
++#define cputime_max ((~0UL >> 1) - 1)
++#define cputime_add(__a, __b) ((__a) + (__b))
++#define cputime_sub(__a, __b) ((__a) - (__b))
++#define cputime_eq(__a, __b) ((__a) == (__b))
++#define cputime_gt(__a, __b) ((__a) > (__b))
++#define cputime_ge(__a, __b) ((__a) >= (__b))
++#define cputime_lt(__a, __b) ((__a) < (__b))
++#define cputime_le(__a, __b) ((__a) <= (__b))
++#define cputime_to_jiffies(__ct) (__ct)
++#define jiffies_to_cputime(__hz) (__hz)
++
++typedef u64 cputime64_t;
++
++#define cputime64_zero (0ULL)
++#define cputime64_add(__a, __b) ((__a) + (__b))
++#define cputime64_to_jiffies64(__ct) (__ct)
++#define cputime_to_cputime64(__ct) ((u64) __ct)
++
++
++/*
++ * Convert cputime to milliseconds and back.
++ */
++#define cputime_to_msecs(__ct) jiffies_to_msecs(__ct)
++#define msecs_to_cputime(__msecs) msecs_to_jiffies(__msecs)
++
++/*
++ * Convert cputime to seconds and back.
++ */
++#define cputime_to_secs(jif) ((jif) / HZ)
++#define secs_to_cputime(sec) ((sec) * HZ)
++
++/*
++ * Convert cputime to timespec and back.
++ */
++#define timespec_to_cputime(__val) timespec_to_jiffies(__val)
++#define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val)
++
++/*
++ * Convert cputime to timeval and back.
++ */
++#define timeval_to_cputime(__val) timeval_to_jiffies(__val)
++#define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val)
++
++/*
++ * Convert cputime to clock and back.
++ */
++#define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct)
++#define clock_t_to_cputime(__x) clock_t_to_jiffies(__x)
++
++/*
++ * Convert cputime64 to clock.
++ */
++#define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct)
++
++#endif
+--- linux/include/asm-generic/div64.h
++++ linux/include/asm-generic/div64.h
+@@ -0,0 +1,58 @@
++#ifndef _ASM_GENERIC_DIV64_H
++#define _ASM_GENERIC_DIV64_H
++/*
++ * Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com>
++ * Based on former asm-ppc/div64.h and asm-m68knommu/div64.h
++ *
++ * The semantics of do_div() are:
++ *
++ * uint32_t do_div(uint64_t *n, uint32_t base)
++ * {
++ * uint32_t remainder = *n % base;
++ * *n = *n / base;
++ * return remainder;
++ * }
++ *
++ * NOTE: macro parameter n is evaluated multiple times,
++ * beware of side effects!
++ */
++
++#include <linux/types.h>
++#include <linux/compiler.h>
++
++#if BITS_PER_LONG == 64
++
++# define do_div(n,base) ({ \
++ uint32_t __base = (base); \
++ uint32_t __rem; \
++ __rem = ((uint64_t)(n)) % __base; \
++ (n) = ((uint64_t)(n)) / __base; \
++ __rem; \
++ })
++
++#elif BITS_PER_LONG == 32
++
++extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
++
++/* The unnecessary pointer compare is there
++ * to check for type safety (n must be 64bit)
++ */
++# define do_div(n,base) ({ \
++ uint32_t __base = (base); \
++ uint32_t __rem; \
++ (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
++ if (likely(((n) >> 32) == 0)) { \
++ __rem = (uint32_t)(n) % __base; \
++ (n) = (uint32_t)(n) / __base; \
++ } else \
++ __rem = __div64_32(&(n), __base); \
++ __rem; \
++ })
++
++#else /* BITS_PER_LONG == ?? */
++
++# error do_div() does not yet support the C64
++
++#endif /* BITS_PER_LONG */
++
++#endif /* _ASM_GENERIC_DIV64_H */
+--- linux/include/asm-generic/dma-mapping-broken.h
++++ linux/include/asm-generic/dma-mapping-broken.h
+@@ -0,0 +1,22 @@
++#ifndef _ASM_GENERIC_DMA_MAPPING_H
++#define _ASM_GENERIC_DMA_MAPPING_H
++
++/* This is used for archs that do not support DMA */
++
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG();
++ return NULL;
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++#endif /* _ASM_GENERIC_DMA_MAPPING_H */
+--- linux/include/asm-generic/dma-mapping.h
++++ linux/include/asm-generic/dma-mapping.h
+@@ -0,0 +1,309 @@
++/* Copyright (C) 2002 by James.Bottomley@HansenPartnership.com
++ *
++ * Implements the generic device dma API via the existing pci_ one
++ * for unconverted architectures
++ */
++
++#ifndef _ASM_GENERIC_DMA_MAPPING_H
++#define _ASM_GENERIC_DMA_MAPPING_H
++
++// #include <linux/config.h>
++
++#ifdef CONFIG_PCI
++
++/* we implement the API below in terms of the existing PCI one,
++ * so include it */
++#include <linux/pci.h>
++/* need struct page definitions */
++#include <linux/mm.h>
++
++static inline int
++dma_supported(struct device *dev, u64 mask)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_dma_supported(to_pci_dev(dev), mask);
++}
++
++static inline int
++dma_set_mask(struct device *dev, u64 dma_mask)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
++}
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
++}
++
++static inline dma_addr_t
++dma_map_single(struct device *dev, void *cpu_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
++}
++
++static inline void
++dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
++}
++
++static inline dma_addr_t
++dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
++}
++
++static inline void
++dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
++}
++
++static inline int
++dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
++}
++
++static inline void
++dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
++}
++
++static inline void
++dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
++ size, (int)direction);
++}
++
++static inline void
++dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
++ size, (int)direction);
++}
++
++static inline void
++dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
++}
++
++static inline void
++dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
++}
++
++static inline int
++dma_mapping_error(dma_addr_t dma_addr)
++{
++ return pci_dma_mapping_error(dma_addr);
++}
++
++
++#else
++
++static inline int
++dma_supported(struct device *dev, u64 mask)
++{
++ return 0;
++}
++
++static inline int
++dma_set_mask(struct device *dev, u64 dma_mask)
++{
++ BUG();
++ return 0;
++}
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG();
++ return NULL;
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++static inline dma_addr_t
++dma_map_single(struct device *dev, void *cpu_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline dma_addr_t
++dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline int
++dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline int
++dma_error(dma_addr_t dma_addr)
++{
++ return 0;
++}
++
++#endif
++
++/* Now for the API extensions over the pci_ one */
++
++#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
++#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
++#define dma_is_consistent(d) (1)
++
++static inline int
++dma_get_cache_alignment(void)
++{
++ /* no easy way to get cache size on all processors, so return
++ * the maximum possible, to be safe */
++ return (1 << L1_CACHE_SHIFT_MAX);
++}
++
++static inline void
++dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ /* just sync everything, that's all the pci API can do */
++ dma_sync_single_for_cpu(dev, dma_handle, offset+size, direction);
++}
++
++static inline void
++dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ /* just sync everything, that's all the pci API can do */
++ dma_sync_single_for_device(dev, dma_handle, offset+size, direction);
++}
++
++static inline void
++dma_cache_sync(void *vaddr, size_t size,
++ enum dma_data_direction direction)
++{
++ /* could define this in terms of the dma_cache ... operations,
++ * but if you get this on a platform, you should convert the platform
++ * to using the generic device DMA API */
++ BUG();
++}
++
++#endif
++
+--- linux/include/asm-generic/errno-base.h
++++ linux/include/asm-generic/errno-base.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_GENERIC_ERRNO_BASE_H
++#define _ASM_GENERIC_ERRNO_BASE_H
++
++#define EPERM 1 /* Operation not permitted */
++#define ENOENT 2 /* No such file or directory */
++#define ESRCH 3 /* No such process */
++#define EINTR 4 /* Interrupted system call */
++#define EIO 5 /* I/O error */
++#define ENXIO 6 /* No such device or address */
++#define E2BIG 7 /* Argument list too long */
++#define ENOEXEC 8 /* Exec format error */
++#define EBADF 9 /* Bad file number */
++#define ECHILD 10 /* No child processes */
++#define EAGAIN 11 /* Try again */
++#define ENOMEM 12 /* Out of memory */
++#define EACCES 13 /* Permission denied */
++#define EFAULT 14 /* Bad address */
++#define ENOTBLK 15 /* Block device required */
++#define EBUSY 16 /* Device or resource busy */
++#define EEXIST 17 /* File exists */
++#define EXDEV 18 /* Cross-device link */
++#define ENODEV 19 /* No such device */
++#define ENOTDIR 20 /* Not a directory */
++#define EISDIR 21 /* Is a directory */
++#define EINVAL 22 /* Invalid argument */
++#define ENFILE 23 /* File table overflow */
++#define EMFILE 24 /* Too many open files */
++#define ENOTTY 25 /* Not a typewriter */
++#define ETXTBSY 26 /* Text file busy */
++#define EFBIG 27 /* File too large */
++#define ENOSPC 28 /* No space left on device */
++#define ESPIPE 29 /* Illegal seek */
++#define EROFS 30 /* Read-only file system */
++#define EMLINK 31 /* Too many links */
++#define EPIPE 32 /* Broken pipe */
++#define EDOM 33 /* Math argument out of domain of func */
++#define ERANGE 34 /* Math result not representable */
++
++#endif
+--- linux/include/asm-generic/errno.h
++++ linux/include/asm-generic/errno.h
+@@ -0,0 +1,105 @@
++#ifndef _ASM_GENERIC_ERRNO_H
++#define _ASM_GENERIC_ERRNO_H
++
++#include <asm-generic/errno-base.h>
++
++#define EDEADLK 35 /* Resource deadlock would occur */
++#define ENAMETOOLONG 36 /* File name too long */
++#define ENOLCK 37 /* No record locks available */
++#define ENOSYS 38 /* Function not implemented */
++#define ENOTEMPTY 39 /* Directory not empty */
++#define ELOOP 40 /* Too many symbolic links encountered */
++#define EWOULDBLOCK EAGAIN /* Operation would block */
++#define ENOMSG 42 /* No message of desired type */
++#define EIDRM 43 /* Identifier removed */
++#define ECHRNG 44 /* Channel number out of range */
++#define EL2NSYNC 45 /* Level 2 not synchronized */
++#define EL3HLT 46 /* Level 3 halted */
++#define EL3RST 47 /* Level 3 reset */
++#define ELNRNG 48 /* Link number out of range */
++#define EUNATCH 49 /* Protocol driver not attached */
++#define ENOCSI 50 /* No CSI structure available */
++#define EL2HLT 51 /* Level 2 halted */
++#define EBADE 52 /* Invalid exchange */
++#define EBADR 53 /* Invalid request descriptor */
++#define EXFULL 54 /* Exchange full */
++#define ENOANO 55 /* No anode */
++#define EBADRQC 56 /* Invalid request code */
++#define EBADSLT 57 /* Invalid slot */
++
++#define EDEADLOCK EDEADLK
++
++#define EBFONT 59 /* Bad font file format */
++#define ENOSTR 60 /* Device not a stream */
++#define ENODATA 61 /* No data available */
++#define ETIME 62 /* Timer expired */
++#define ENOSR 63 /* Out of streams resources */
++#define ENONET 64 /* Machine is not on the network */
++#define ENOPKG 65 /* Package not installed */
++#define EREMOTE 66 /* Object is remote */
++#define ENOLINK 67 /* Link has been severed */
++#define EADV 68 /* Advertise error */
++#define ESRMNT 69 /* Srmount error */
++#define ECOMM 70 /* Communication error on send */
++#define EPROTO 71 /* Protocol error */
++#define EMULTIHOP 72 /* Multihop attempted */
++#define EDOTDOT 73 /* RFS specific error */
++#define EBADMSG 74 /* Not a data message */
++#define EOVERFLOW 75 /* Value too large for defined data type */
++#define ENOTUNIQ 76 /* Name not unique on network */
++#define EBADFD 77 /* File descriptor in bad state */
++#define EREMCHG 78 /* Remote address changed */
++#define ELIBACC 79 /* Can not access a needed shared library */
++#define ELIBBAD 80 /* Accessing a corrupted shared library */
++#define ELIBSCN 81 /* .lib section in a.out corrupted */
++#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
++#define ELIBEXEC 83 /* Cannot exec a shared library directly */
++#define EILSEQ 84 /* Illegal byte sequence */
++#define ERESTART 85 /* Interrupted system call should be restarted */
++#define ESTRPIPE 86 /* Streams pipe error */
++#define EUSERS 87 /* Too many users */
++#define ENOTSOCK 88 /* Socket operation on non-socket */
++#define EDESTADDRREQ 89 /* Destination address required */
++#define EMSGSIZE 90 /* Message too long */
++#define EPROTOTYPE 91 /* Protocol wrong type for socket */
++#define ENOPROTOOPT 92 /* Protocol not available */
++#define EPROTONOSUPPORT 93 /* Protocol not supported */
++#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
++#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
++#define EPFNOSUPPORT 96 /* Protocol family not supported */
++#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
++#define EADDRINUSE 98 /* Address already in use */
++#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
++#define ENETDOWN 100 /* Network is down */
++#define ENETUNREACH 101 /* Network is unreachable */
++#define ENETRESET 102 /* Network dropped connection because of reset */
++#define ECONNABORTED 103 /* Software caused connection abort */
++#define ECONNRESET 104 /* Connection reset by peer */
++#define ENOBUFS 105 /* No buffer space available */
++#define EISCONN 106 /* Transport endpoint is already connected */
++#define ENOTCONN 107 /* Transport endpoint is not connected */
++#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
++#define ETOOMANYREFS 109 /* Too many references: cannot splice */
++#define ETIMEDOUT 110 /* Connection timed out */
++#define ECONNREFUSED 111 /* Connection refused */
++#define EHOSTDOWN 112 /* Host is down */
++#define EHOSTUNREACH 113 /* No route to host */
++#define EALREADY 114 /* Operation already in progress */
++#define EINPROGRESS 115 /* Operation now in progress */
++#define ESTALE 116 /* Stale NFS file handle */
++#define EUCLEAN 117 /* Structure needs cleaning */
++#define ENOTNAM 118 /* Not a XENIX named type file */
++#define ENAVAIL 119 /* No XENIX semaphores available */
++#define EISNAM 120 /* Is a named type file */
++#define EREMOTEIO 121 /* Remote I/O error */
++#define EDQUOT 122 /* Quota exceeded */
++
++#define ENOMEDIUM 123 /* No medium found */
++#define EMEDIUMTYPE 124 /* Wrong medium type */
++#define ECANCELED 125 /* Operation Canceled */
++#define ENOKEY 126 /* Required key not available */
++#define EKEYEXPIRED 127 /* Key has expired */
++#define EKEYREVOKED 128 /* Key has been revoked */
++#define EKEYREJECTED 129 /* Key was rejected by service */
++
++#endif
+--- linux/include/asm-generic/hdreg.h
++++ linux/include/asm-generic/hdreg.h
+@@ -0,0 +1,8 @@
++#warning <asm/hdreg.h> is obsolete, please do not use it
++
++#ifndef __ASM_GENERIC_HDREG_H
++#define __ASM_GENERIC_HDREG_H
++
++typedef unsigned long ide_ioreg_t;
++
++#endif /* __ASM_GENERIC_HDREG_H */
+--- linux/include/asm-generic/ide_iops.h
++++ linux/include/asm-generic/ide_iops.h
+@@ -0,0 +1,38 @@
++/* Generic I/O and MEMIO string operations. */
++
++#define __ide_insw insw
++#define __ide_insl insl
++#define __ide_outsw outsw
++#define __ide_outsl outsl
++
++static __inline__ void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ *(u16 *)addr = readw(port);
++ addr += 2;
++ }
++}
++
++static __inline__ void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ *(u32 *)addr = readl(port);
++ addr += 4;
++ }
++}
++
++static __inline__ void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ writew(*(u16 *)addr, port);
++ addr += 2;
++ }
++}
++
++static __inline__ void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
++{
++ while (count--) {
++ writel(*(u32 *)addr, port);
++ addr += 4;
++ }
++}
+--- linux/include/asm-generic/iomap.h
++++ linux/include/asm-generic/iomap.h
+@@ -0,0 +1,63 @@
++#ifndef __GENERIC_IO_H
++#define __GENERIC_IO_H
++
++#include <linux/linkage.h>
++
++/*
++ * These are the "generic" interfaces for doing new-style
++ * memory-mapped or PIO accesses. Architectures may do
++ * their own arch-optimized versions, these just act as
++ * wrappers around the old-style IO register access functions:
++ * read[bwl]/write[bwl]/in[bwl]/out[bwl]
++ *
++ * Don't include this directly, include it from <asm/io.h>.
++ */
++
++/*
++ * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
++ * access or a MMIO access, these functions don't care. The info is
++ * encoded in the hardware mapping set up by the mapping functions
++ * (or the cookie itself, depending on implementation and hw).
++ *
++ * The generic routines just encode the PIO/MMIO as part of the
++ * cookie, and coldly assume that the MMIO IO mappings are not
++ * in the low address range. Architectures for which this is not
++ * true can't use this generic implementation.
++ */
++extern unsigned int fastcall ioread8(void __iomem *);
++extern unsigned int fastcall ioread16(void __iomem *);
++extern unsigned int fastcall ioread32(void __iomem *);
++
++extern void fastcall iowrite8(u8, void __iomem *);
++extern void fastcall iowrite16(u16, void __iomem *);
++extern void fastcall iowrite32(u32, void __iomem *);
++
++/*
++ * "string" versions of the above. Note that they
++ * use native byte ordering for the accesses (on
++ * the assumption that IO and memory agree on a
++ * byte order, and CPU byteorder is irrelevant).
++ *
++ * They do _not_ update the port address. If you
++ * want MMIO that copies stuff laid out in MMIO
++ * memory across multiple ports, use "memcpy_toio()"
++ * and friends.
++ */
++extern void fastcall ioread8_rep(void __iomem *port, void *buf, unsigned long count);
++extern void fastcall ioread16_rep(void __iomem *port, void *buf, unsigned long count);
++extern void fastcall ioread32_rep(void __iomem *port, void *buf, unsigned long count);
++
++extern void fastcall iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
++extern void fastcall iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
++extern void fastcall iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
++
++/* Create a virtual mapping cookie for an IO port range */
++extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
++extern void ioport_unmap(void __iomem *);
++
++/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
++struct pci_dev;
++extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
++extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
++
++#endif
+--- linux/include/asm-generic/local.h
++++ linux/include/asm-generic/local.h
+@@ -0,0 +1,118 @@
++#ifndef _ASM_GENERIC_LOCAL_H
++#define _ASM_GENERIC_LOCAL_H
++
++// #include <linux/config.h>
++#include <linux/percpu.h>
++#include <linux/hardirq.h>
++#include <asm/types.h>
++
++/* An unsigned long type for operations which are atomic for a single
++ * CPU. Usually used in combination with per-cpu variables. */
++
++#if BITS_PER_LONG == 32
++/* Implement in terms of atomics. */
++
++/* Don't use typedef: don't want them to be mixed with atomic_t's. */
++typedef struct
++{
++ atomic_t a;
++} local_t;
++
++#define LOCAL_INIT(i) { ATOMIC_INIT(i) }
++
++#define local_read(l) ((unsigned long)atomic_read(&(l)->a))
++#define local_set(l,i) atomic_set((&(l)->a),(i))
++#define local_inc(l) atomic_inc(&(l)->a)
++#define local_dec(l) atomic_dec(&(l)->a)
++#define local_add(i,l) atomic_add((i),(&(l)->a))
++#define local_sub(i,l) atomic_sub((i),(&(l)->a))
++
++/* Non-atomic variants, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well. */
++#define __local_inc(l) local_set((l), local_read(l) + 1)
++#define __local_dec(l) local_set((l), local_read(l) - 1)
++#define __local_add(i,l) local_set((l), local_read(l) + (i))
++#define __local_sub(i,l) local_set((l), local_read(l) - (i))
++
++#else /* ... can't use atomics. */
++/* Implement in terms of three variables.
++ Another option would be to use local_irq_save/restore. */
++
++typedef struct
++{
++ /* 0 = in hardirq, 1 = in softirq, 2 = usermode. */
++ unsigned long v[3];
++} local_t;
++
++#define _LOCAL_VAR(l) ((l)->v[!in_interrupt() + !in_irq()])
++
++#define LOCAL_INIT(i) { { (i), 0, 0 } }
++
++static inline unsigned long local_read(local_t *l)
++{
++ return l->v[0] + l->v[1] + l->v[2];
++}
++
++static inline void local_set(local_t *l, unsigned long v)
++{
++ l->v[0] = v;
++ l->v[1] = l->v[2] = 0;
++}
++
++static inline void local_inc(local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l)++;
++ preempt_enable();
++}
++
++static inline void local_dec(local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l)--;
++ preempt_enable();
++}
++
++static inline void local_add(unsigned long v, local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l) += v;
++ preempt_enable();
++}
++
++static inline void local_sub(unsigned long v, local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l) -= v;
++ preempt_enable();
++}
++
++/* Non-atomic variants, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well. */
++#define __local_inc(l) ((l)->v[0]++)
++#define __local_dec(l) ((l)->v[0]--)
++#define __local_add(i,l) ((l)->v[0] += (i))
++#define __local_sub(i,l) ((l)->v[0] -= (i))
++
++#endif /* Non-atomic implementation */
++
++/* Use these for per-cpu local_t variables: on some archs they are
++ * much more efficient than these naive implementations. Note they take
++ * a variable (eg. mystruct.foo), not an address.
++ */
++#define cpu_local_read(v) local_read(&__get_cpu_var(v))
++#define cpu_local_set(v, i) local_set(&__get_cpu_var(v), (i))
++#define cpu_local_inc(v) local_inc(&__get_cpu_var(v))
++#define cpu_local_dec(v) local_dec(&__get_cpu_var(v))
++#define cpu_local_add(i, v) local_add((i), &__get_cpu_var(v))
++#define cpu_local_sub(i, v) local_sub((i), &__get_cpu_var(v))
++
++/* Non-atomic increments, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well.
++ */
++#define __cpu_local_inc(v) __local_inc(&__get_cpu_var(v))
++#define __cpu_local_dec(v) __local_dec(&__get_cpu_var(v))
++#define __cpu_local_add(i, v) __local_add((i), &__get_cpu_var(v))
++#define __cpu_local_sub(i, v) __local_sub((i), &__get_cpu_var(v))
++
++#endif /* _ASM_GENERIC_LOCAL_H */
+--- linux/include/asm-generic/pci-dma-compat.h
++++ linux/include/asm-generic/pci-dma-compat.h
+@@ -0,0 +1,107 @@
++/* include this file if the platform implements the dma_ DMA Mapping API
++ * and wants to provide the pci_ DMA Mapping API in terms of it */
++
++#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
++#define _ASM_GENERIC_PCI_DMA_COMPAT_H
++
++#include <linux/dma-mapping.h>
++
++/* note pci_set_dma_mask isn't here, since it's a public function
++ * exported from drivers/pci, use dma_supported instead */
++
++static inline int
++pci_dma_supported(struct pci_dev *hwdev, u64 mask)
++{
++ return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
++}
++
++static inline void *
++pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
++ dma_addr_t *dma_handle)
++{
++ return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
++}
++
++static inline void
++pci_free_consistent(struct pci_dev *hwdev, size_t size,
++ void *vaddr, dma_addr_t dma_handle)
++{
++ dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
++}
++
++static inline dma_addr_t
++pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
++{
++ return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
++ size_t size, int direction)
++{
++ dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
++}
++
++static inline dma_addr_t
++pci_map_page(struct pci_dev *hwdev, struct page *page,
++ unsigned long offset, size_t size, int direction)
++{
++ return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
++ size_t size, int direction)
++{
++ dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
++}
++
++static inline int
++pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nents, int direction)
++{
++ return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nents, int direction)
++{
++ dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
++ size_t size, int direction)
++{
++ dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
++ size_t size, int direction)
++{
++ dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nelems, int direction)
++{
++ dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nelems, int direction)
++{
++ dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
++}
++
++static inline int
++pci_dma_mapping_error(dma_addr_t dma_addr)
++{
++ return dma_mapping_error(dma_addr);
++}
++
++#endif
+--- linux/include/asm-generic/pci.h
++++ linux/include/asm-generic/pci.h
+@@ -0,0 +1,34 @@
++/*
++ * linux/include/asm-generic/pci.h
++ *
++ * Copyright (C) 2003 Russell King
++ */
++#ifndef _ASM_GENERIC_PCI_H
++#define _ASM_GENERIC_PCI_H
++
++/**
++ * pcibios_resource_to_bus - convert resource to PCI bus address
++ * @dev: device which owns this resource
++ * @region: converted bus-centric region (start,end)
++ * @res: resource to convert
++ *
++ * Convert a resource to a PCI device bus address or bus window.
++ */
++static inline void
++pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
++ struct resource *res)
++{
++ region->start = res->start;
++ region->end = res->end;
++}
++
++#define pcibios_scan_all_fns(a, b) 0
++
++#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
++static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
++{
++ return channel ? 15 : 14;
++}
++#endif /* HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ */
++
++#endif
+--- linux/include/asm-generic/percpu.h
++++ linux/include/asm-generic/percpu.h
+@@ -0,0 +1,42 @@
++#ifndef _ASM_GENERIC_PERCPU_H_
++#define _ASM_GENERIC_PERCPU_H_
++#include <linux/compiler.h>
++
++#define __GENERIC_PER_CPU
++#ifdef CONFIG_SMP
++
++extern unsigned long __per_cpu_offset[NR_CPUS];
++
++/* Separate out the type, so (int[3], foo) works. */
++#define DEFINE_PER_CPU(type, name) \
++ __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
++
++/* var is in discarded region: offset to particular copy we want */
++#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
++#define __get_cpu_var(var) per_cpu(var, smp_processor_id())
++
++/* A macro to avoid #include hell... */
++#define percpu_modcopy(pcpudst, src, size) \
++do { \
++ unsigned int __i; \
++ for (__i = 0; __i < NR_CPUS; __i++) \
++ if (cpu_possible(__i)) \
++ memcpy((pcpudst)+__per_cpu_offset[__i], \
++ (src), (size)); \
++} while (0)
++#else /* ! SMP */
++
++#define DEFINE_PER_CPU(type, name) \
++ __typeof__(type) per_cpu__##name
++
++#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))
++#define __get_cpu_var(var) per_cpu__##var
++
++#endif /* SMP */
++
++#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
++
++#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
++#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
++
++#endif /* _ASM_GENERIC_PERCPU_H_ */
+--- linux/include/asm-generic/pgtable.h
++++ linux/include/asm-generic/pgtable.h
+@@ -0,0 +1,137 @@
++#ifndef _ASM_GENERIC_PGTABLE_H
++#define _ASM_GENERIC_PGTABLE_H
++
++#ifndef __HAVE_ARCH_PTEP_ESTABLISH
++/*
++ * Establish a new mapping:
++ * - flush the old one
++ * - update the page tables
++ * - inform the TLB about the new one
++ *
++ * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock.
++ *
++ * Note: the old pte is known to not be writable, so we don't need to
++ * worry about dirty bits etc getting lost.
++ */
++#ifndef __HAVE_ARCH_SET_PTE_ATOMIC
++#define ptep_establish(__vma, __address, __ptep, __entry) \
++do { \
++ set_pte(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#else /* __HAVE_ARCH_SET_PTE_ATOMIC */
++#define ptep_establish(__vma, __address, __ptep, __entry) \
++do { \
++ set_pte_atomic(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#endif /* __HAVE_ARCH_SET_PTE_ATOMIC */
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
++/*
++ * Largely same as above, but only sets the access flags (dirty,
++ * accessed, and writable). Furthermore, we know it always gets set
++ * to a "more permissive" setting, which allows most architectures
++ * to optimize this.
++ */
++#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
++do { \
++ set_pte(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
++static inline int ptep_test_and_clear_young(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_young(pte))
++ return 0;
++ set_pte(ptep, pte_mkold(pte));
++ return 1;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
++#define ptep_clear_flush_young(__vma, __address, __ptep) \
++({ \
++ int __young = ptep_test_and_clear_young(__ptep); \
++ if (__young) \
++ flush_tlb_page(__vma, __address); \
++ __young; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
++static inline int ptep_test_and_clear_dirty(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_dirty(pte))
++ return 0;
++ set_pte(ptep, pte_mkclean(pte));
++ return 1;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
++#define ptep_clear_flush_dirty(__vma, __address, __ptep) \
++({ \
++ int __dirty = ptep_test_and_clear_dirty(__ptep); \
++ if (__dirty) \
++ flush_tlb_page(__vma, __address); \
++ __dirty; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
++static inline pte_t ptep_get_and_clear(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ pte_clear(ptep);
++ return pte;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
++#define ptep_clear_flush(__vma, __address, __ptep) \
++({ \
++ pte_t __pte = ptep_get_and_clear(__ptep); \
++ flush_tlb_page(__vma, __address); \
++ __pte; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
++static inline void ptep_set_wrprotect(pte_t *ptep)
++{
++ pte_t old_pte = *ptep;
++ set_pte(ptep, pte_wrprotect(old_pte));
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_MKDIRTY
++static inline void ptep_mkdirty(pte_t *ptep)
++{
++ pte_t old_pte = *ptep;
++ set_pte(ptep, pte_mkdirty(old_pte));
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTE_SAME
++#define pte_same(A,B) (pte_val(A) == pte_val(B))
++#endif
++
++#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
++#define page_test_and_clear_dirty(page) (0)
++#endif
++
++#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
++#define page_test_and_clear_young(page) (0)
++#endif
++
++#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
++#define pgd_offset_gate(mm, addr) pgd_offset(mm, addr)
++#endif
++
++#endif /* _ASM_GENERIC_PGTABLE_H */
+--- linux/include/asm-generic/pgtable-nopmd.h
++++ linux/include/asm-generic/pgtable-nopmd.h
+@@ -0,0 +1,60 @@
++#ifndef _PGTABLE_NOPMD_H
++#define _PGTABLE_NOPMD_H
++
++#ifndef __ASSEMBLY__
++
++#include <asm-generic/pgtable-nopud.h>
++
++/*
++ * Having the pmd type consist of a pud gets the size right, and allows
++ * us to conceptually access the pud entry that this pmd is folded into
++ * without casting.
++ */
++typedef struct { pud_t pud; } pmd_t;
++
++#define PMD_SHIFT PUD_SHIFT
++#define PTRS_PER_PMD 1
++#define PMD_SIZE (1UL << PMD_SHIFT)
++#define PMD_MASK (~(PMD_SIZE-1))
++
++/*
++ * The "pud_xxx()" functions here are trivial for a folded two-level
++ * setup: the pmd is never bad, and a pmd always exists (as it's folded
++ * into the pud entry)
++ */
++static inline int pud_none(pud_t pud) { return 0; }
++static inline int pud_bad(pud_t pud) { return 0; }
++static inline int pud_present(pud_t pud) { return 1; }
++static inline void pud_clear(pud_t *pud) { }
++#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
++
++#define pud_populate(mm, pmd, pte) do { } while (0)
++
++/*
++ * (pmds are folded into puds so this doesn't get actually called,
++ * but the define is needed for a generic inline function.)
++ */
++#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
++
++static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
++{
++ return (pmd_t *)pud;
++}
++
++#define pmd_val(x) (pud_val((x).pud))
++#define __pmd(x) ((pmd_t) { __pud(x) } )
++
++#define pud_page(pud) (pmd_page((pmd_t){ pud }))
++#define pud_page_kernel(pud) (pmd_page_kernel((pmd_t){ pud }))
++
++/*
++ * allocating and freeing a pmd is trivial: the 1-entry pmd is
++ * inside the pud, so has no extra memory associated with it.
++ */
++#define pmd_alloc_one(mm, address) NULL
++#define pmd_free(x) do { } while (0)
++#define __pmd_free_tlb(tlb, x) do { } while (0)
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* _PGTABLE_NOPMD_H */
+--- linux/include/asm-generic/pgtable-nopud.h
++++ linux/include/asm-generic/pgtable-nopud.h
+@@ -0,0 +1,56 @@
++#ifndef _PGTABLE_NOPUD_H
++#define _PGTABLE_NOPUD_H
++
++#ifndef __ASSEMBLY__
++
++/*
++ * Having the pud type consist of a pgd gets the size right, and allows
++ * us to conceptually access the pgd entry that this pud is folded into
++ * without casting.
++ */
++typedef struct { pgd_t pgd; } pud_t;
++
++#define PUD_SHIFT PGDIR_SHIFT
++#define PTRS_PER_PUD 1
++#define PUD_SIZE (1UL << PUD_SHIFT)
++#define PUD_MASK (~(PUD_SIZE-1))
++
++/*
++ * The "pgd_xxx()" functions here are trivial for a folded two-level
++ * setup: the pud is never bad, and a pud always exists (as it's folded
++ * into the pgd entry)
++ */
++static inline int pgd_none(pgd_t pgd) { return 0; }
++static inline int pgd_bad(pgd_t pgd) { return 0; }
++static inline int pgd_present(pgd_t pgd) { return 1; }
++static inline void pgd_clear(pgd_t *pgd) { }
++#define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
++
++#define pgd_populate(mm, pgd, pud) do { } while (0)
++/*
++ * (puds are folded into pgds so this doesn't get actually called,
++ * but the define is needed for a generic inline function.)
++ */
++#define set_pgd(pgdptr, pgdval) set_pud((pud_t *)(pgdptr), (pud_t) { pgdval })
++
++static inline pud_t * pud_offset(pgd_t * pgd, unsigned long address)
++{
++ return (pud_t *)pgd;
++}
++
++#define pud_val(x) (pgd_val((x).pgd))
++#define __pud(x) ((pud_t) { __pgd(x) } )
++
++#define pgd_page(pgd) (pud_page((pud_t){ pgd }))
++#define pgd_page_kernel(pgd) (pud_page_kernel((pud_t){ pgd }))
++
++/*
++ * allocating and freeing a pud is trivial: the 1-entry pud is
++ * inside the pgd, so has no extra memory associated with it.
++ */
++#define pud_alloc_one(mm, address) NULL
++#define pud_free(x) do { } while (0)
++#define __pud_free_tlb(tlb, x) do { } while (0)
++
++#endif /* __ASSEMBLY__ */
++#endif /* _PGTABLE_NOPUD_H */
+--- linux/include/asm-generic/resource.h
++++ linux/include/asm-generic/resource.h
+@@ -0,0 +1,60 @@
++#ifndef _ASM_GENERIC_RESOURCE_H
++#define _ASM_GENERIC_RESOURCE_H
++
++/*
++ * Resource limits
++ */
++
++/* Allow arch to control resource order */
++#ifndef __ARCH_RLIMIT_ORDER
++#define RLIMIT_CPU 0 /* CPU time in ms */
++#define RLIMIT_FSIZE 1 /* Maximum filesize */
++#define RLIMIT_DATA 2 /* max data size */
++#define RLIMIT_STACK 3 /* max stack size */
++#define RLIMIT_CORE 4 /* max core file size */
++#define RLIMIT_RSS 5 /* max resident set size */
++#define RLIMIT_NPROC 6 /* max number of processes */
++#define RLIMIT_NOFILE 7 /* max number of open files */
++#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
++#define RLIMIT_AS 9 /* address space limit */
++#define RLIMIT_LOCKS 10 /* maximum file locks held */
++#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
++#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
++
++#define RLIM_NLIMITS 13
++#endif
++
++/*
++ * SuS says limits have to be unsigned.
++ * Which makes a ton more sense anyway.
++ */
++#ifndef RLIM_INFINITY
++#define RLIM_INFINITY (~0UL)
++#endif
++
++#ifndef _STK_LIM_MAX
++#define _STK_LIM_MAX RLIM_INFINITY
++#endif
++
++#ifdef __KERNEL__
++
++#define INIT_RLIMITS \
++{ \
++ [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_STACK] = { _STK_LIM, _STK_LIM_MAX }, \
++ [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \
++ [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_NPROC] = { 0, 0 }, \
++ [RLIMIT_NOFILE] = { INR_OPEN, INR_OPEN }, \
++ [RLIMIT_MEMLOCK] = { MLOCK_LIMIT, MLOCK_LIMIT }, \
++ [RLIMIT_AS] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \
++ [RLIMIT_SIGPENDING] = { MAX_SIGPENDING, MAX_SIGPENDING }, \
++ [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
++}
++
++#endif /* __KERNEL__ */
++
++#endif
+--- linux/include/asm-generic/rmap.h
++++ linux/include/asm-generic/rmap.h
+@@ -0,0 +1,90 @@
++#ifndef _GENERIC_RMAP_H
++#define _GENERIC_RMAP_H
++/*
++ * linux/include/asm-generic/rmap.h
++ *
++ * Architecture dependent parts of the reverse mapping code,
++ * this version should work for most architectures with a
++ * 'normal' page table layout.
++ *
++ * We use the struct page of the page table page to find out
++ * the process and full address of a page table entry:
++ * - page->mapping points to the process' mm_struct
++ * - page->index has the high bits of the address
++ * - the lower bits of the address are calculated from the
++ * offset of the page table entry within the page table page
++ *
++ * For CONFIG_HIGHPTE, we need to represent the address of a pte in a
++ * scalar pte_addr_t. The pfn of the pte's page is shifted left by PAGE_SIZE
++ * bits and is then ORed with the byte offset of the pte within its page.
++ *
++ * For CONFIG_HIGHMEM4G, the pte_addr_t is 32 bits. 20 for the pfn, 12 for
++ * the offset.
++ *
++ * For CONFIG_HIGHMEM64G, the pte_addr_t is 64 bits. 52 for the pfn, 12 for
++ * the offset.
++ */
++#include <linux/mm.h>
++
++static inline void pgtable_add_rmap(struct page * page, struct mm_struct * mm, unsigned long address)
++{
++#ifdef BROKEN_PPC_PTE_ALLOC_ONE
++ /* OK, so PPC calls pte_alloc() before mem_map[] is setup ... ;( */
++ extern int mem_init_done;
++
++ if (!mem_init_done)
++ return;
++#endif
++ page->mapping = (void *)mm;
++ page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
++ inc_page_state(nr_page_table_pages);
++}
++
++static inline void pgtable_remove_rmap(struct page * page)
++{
++ page->mapping = NULL;
++ page->index = 0;
++ dec_page_state(nr_page_table_pages);
++}
++
++static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
++{
++ struct page * page = kmap_atomic_to_page(ptep);
++ return (struct mm_struct *) page->mapping;
++}
++
++static inline unsigned long ptep_to_address(pte_t * ptep)
++{
++ struct page * page = kmap_atomic_to_page(ptep);
++ unsigned long low_bits;
++ low_bits = ((unsigned long)ptep & ~PAGE_MASK) * PTRS_PER_PTE;
++ return page->index + low_bits;
++}
++
++#ifdef CONFIG_HIGHPTE
++static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
++{
++ pte_addr_t paddr;
++ paddr = ((pte_addr_t)page_to_pfn(kmap_atomic_to_page(ptep))) << PAGE_SHIFT;
++ return paddr + (pte_addr_t)((unsigned long)ptep & ~PAGE_MASK);
++}
++#else
++static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
++{
++ return (pte_addr_t)ptep;
++}
++#endif
++
++#ifndef CONFIG_HIGHPTE
++static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
++{
++ return (pte_t *)pte_paddr;
++}
++
++static inline void rmap_ptep_unmap(pte_t *pte)
++{
++ return;
++}
++#endif
++
++#endif /* _GENERIC_RMAP_H */
+--- linux/include/asm-generic/rtc.h
++++ linux/include/asm-generic/rtc.h
+@@ -0,0 +1,213 @@
++/*
++ * inclue/asm-generic/rtc.h
++ *
++ * Author: Tom Rini <trini@mvista.com>
++ *
++ * Based on:
++ * drivers/char/rtc.c
++ *
++ * Please read the COPYING file for all license details.
++ */
++
++#ifndef __ASM_RTC_H__
++#define __ASM_RTC_H__
++
++#ifdef __KERNEL__
++
++#include <linux/mc146818rtc.h>
++#include <linux/rtc.h>
++#include <linux/bcd.h>
++
++#define RTC_PIE 0x40 /* periodic interrupt enable */
++#define RTC_AIE 0x20 /* alarm interrupt enable */
++#define RTC_UIE 0x10 /* update-finished interrupt enable */
++
++/* some dummy definitions */
++#define RTC_BATT_BAD 0x100 /* battery bad */
++#define RTC_SQWE 0x08 /* enable square-wave output */
++#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
++#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
++#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
++
++/*
++ * Returns true if a clock update is in progress
++ */
++static inline unsigned char rtc_is_updating(void)
++{
++ unsigned char uip;
++
++ spin_lock_irq(&rtc_lock);
++ uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
++ spin_unlock_irq(&rtc_lock);
++ return uip;
++}
++
++static inline unsigned int get_rtc_time(struct rtc_time *time)
++{
++ unsigned long uip_watchdog = jiffies;
++ unsigned char ctrl;
++#ifdef CONFIG_MACH_DECSTATION
++ unsigned int real_year;
++#endif
++
++ /*
++ * read RTC once any update in progress is done. The update
++ * can take just over 2ms. We wait 10 to 20ms. There is no need to
++ * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.
++ * If you need to know *exactly* when a second has started, enable
++ * periodic update complete interrupts, (via ioctl) and then
++ * immediately read /dev/rtc which will block until you get the IRQ.
++ * Once the read clears, read the RTC time (again via ioctl). Easy.
++ */
++
++ if (rtc_is_updating() != 0)
++ while (jiffies - uip_watchdog < 2*HZ/100) {
++ barrier();
++ cpu_relax();
++ }
++
++ /*
++ * Only the values that we read from the RTC are set. We leave
++ * tm_wday, tm_yday and tm_isdst untouched. Even though the
++ * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
++ * by the RTC when initially set to a non-zero value.
++ */
++ spin_lock_irq(&rtc_lock);
++ time->tm_sec = CMOS_READ(RTC_SECONDS);
++ time->tm_min = CMOS_READ(RTC_MINUTES);
++ time->tm_hour = CMOS_READ(RTC_HOURS);
++ time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
++ time->tm_mon = CMOS_READ(RTC_MONTH);
++ time->tm_year = CMOS_READ(RTC_YEAR);
++#ifdef CONFIG_MACH_DECSTATION
++ real_year = CMOS_READ(RTC_DEC_YEAR);
++#endif
++ ctrl = CMOS_READ(RTC_CONTROL);
++ spin_unlock_irq(&rtc_lock);
++
++ if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
++ {
++ BCD_TO_BIN(time->tm_sec);
++ BCD_TO_BIN(time->tm_min);
++ BCD_TO_BIN(time->tm_hour);
++ BCD_TO_BIN(time->tm_mday);
++ BCD_TO_BIN(time->tm_mon);
++ BCD_TO_BIN(time->tm_year);
++ }
++
++#ifdef CONFIG_MACH_DECSTATION
++ time->tm_year += real_year - 72;
++#endif
++
++ /*
++ * Account for differences between how the RTC uses the values
++ * and how they are defined in a struct rtc_time;
++ */
++ if (time->tm_year <= 69)
++ time->tm_year += 100;
++
++ time->tm_mon--;
++
++ return RTC_24H;
++}
++
++/* Set the current date and time in the real time clock. */
++static inline int set_rtc_time(struct rtc_time *time)
++{
++ unsigned char mon, day, hrs, min, sec;
++ unsigned char save_control, save_freq_select;
++ unsigned int yrs;
++#ifdef CONFIG_MACH_DECSTATION
++ unsigned int real_yrs, leap_yr;
++#endif
++
++ yrs = time->tm_year;
++ mon = time->tm_mon + 1; /* tm_mon starts at zero */
++ day = time->tm_mday;
++ hrs = time->tm_hour;
++ min = time->tm_min;
++ sec = time->tm_sec;
++
++ if (yrs > 255) /* They are unsigned */
++ return -EINVAL;
++
++ spin_lock_irq(&rtc_lock);
++#ifdef CONFIG_MACH_DECSTATION
++ real_yrs = yrs;
++ leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
++ !((yrs + 1900) % 400));
++ yrs = 72;
++
++ /*
++ * We want to keep the year set to 73 until March
++ * for non-leap years, so that Feb, 29th is handled
++ * correctly.
++ */
++ if (!leap_yr && mon < 3) {
++ real_yrs--;
++ yrs = 73;
++ }
++#endif
++ /* These limits and adjustments are independent of
++ * whether the chip is in binary mode or not.
++ */
++ if (yrs > 169) {
++ spin_unlock_irq(&rtc_lock);
++ return -EINVAL;
++ }
++
++ if (yrs >= 100)
++ yrs -= 100;
++
++ if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
++ || RTC_ALWAYS_BCD) {
++ BIN_TO_BCD(sec);
++ BIN_TO_BCD(min);
++ BIN_TO_BCD(hrs);
++ BIN_TO_BCD(day);
++ BIN_TO_BCD(mon);
++ BIN_TO_BCD(yrs);
++ }
++
++ save_control = CMOS_READ(RTC_CONTROL);
++ CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
++ save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
++ CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
++
++#ifdef CONFIG_MACH_DECSTATION
++ CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
++#endif
++ CMOS_WRITE(yrs, RTC_YEAR);
++ CMOS_WRITE(mon, RTC_MONTH);
++ CMOS_WRITE(day, RTC_DAY_OF_MONTH);
++ CMOS_WRITE(hrs, RTC_HOURS);
++ CMOS_WRITE(min, RTC_MINUTES);
++ CMOS_WRITE(sec, RTC_SECONDS);
++
++ CMOS_WRITE(save_control, RTC_CONTROL);
++ CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
++
++ spin_unlock_irq(&rtc_lock);
++
++ return 0;
++}
++
++static inline unsigned int get_rtc_ss(void)
++{
++ struct rtc_time h;
++
++ get_rtc_time(&h);
++ return h.tm_sec;
++}
++
++static inline int get_rtc_pll(struct rtc_pll_info *pll)
++{
++ return -EINVAL;
++}
++static inline int set_rtc_pll(struct rtc_pll_info *pll)
++{
++ return -EINVAL;
++}
++
++#endif /* __KERNEL__ */
++#endif /* __ASM_RTC_H__ */
+--- linux/include/asm-generic/sections.h
++++ linux/include/asm-generic/sections.h
+@@ -0,0 +1,13 @@
++#ifndef _ASM_GENERIC_SECTIONS_H_
++#define _ASM_GENERIC_SECTIONS_H_
++
++/* References to section boundaries */
++
++extern char _text[], _stext[], _etext[];
++extern char _data[], _sdata[], _edata[];
++extern char __bss_start[], __bss_stop[];
++extern char __init_begin[], __init_end[];
++extern char _sinittext[], _einittext[];
++extern char _end[];
++
++#endif /* _ASM_GENERIC_SECTIONS_H_ */
+--- linux/include/asm-generic/siginfo.h
++++ linux/include/asm-generic/siginfo.h
+@@ -0,0 +1,288 @@
++#ifndef _ASM_GENERIC_SIGINFO_H
++#define _ASM_GENERIC_SIGINFO_H
++
++#include <linux/compiler.h>
++#include <linux/types.h>
++#include <linux/resource.h>
++
++typedef union sigval {
++ int sival_int;
++ void __user *sival_ptr;
++} sigval_t;
++
++/*
++ * This is the size (including padding) of the part of the
++ * struct siginfo that is before the union.
++ */
++#ifndef __ARCH_SI_PREAMBLE_SIZE
++#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
++#endif
++
++#define SI_MAX_SIZE 128
++#ifndef SI_PAD_SIZE
++#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
++#endif
++
++#ifndef __ARCH_SI_UID_T
++#define __ARCH_SI_UID_T uid_t
++#endif
++
++/*
++ * The default "si_band" type is "long", as specified by POSIX.
++ * However, some architectures want to override this to "int"
++ * for historical compatibility reasons, so we allow that.
++ */
++#ifndef __ARCH_SI_BAND_T
++#define __ARCH_SI_BAND_T long
++#endif
++
++#ifndef HAVE_ARCH_SIGINFO_T
++
++typedef struct siginfo {
++ int si_signo;
++ int si_errno;
++ int si_code;
++
++ union {
++ int _pad[SI_PAD_SIZE];
++
++ /* kill() */
++ struct {
++ pid_t _pid; /* sender's pid */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ } _kill;
++
++ /* POSIX.1b timers */
++ struct {
++ timer_t _tid; /* timer id */
++ int _overrun; /* overrun count */
++ char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
++ sigval_t _sigval; /* same as below */
++ int _sys_private; /* not to be passed to user */
++ } _timer;
++
++ /* POSIX.1b signals */
++ struct {
++ pid_t _pid; /* sender's pid */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ sigval_t _sigval;
++ } _rt;
++
++ /* SIGCHLD */
++ struct {
++ pid_t _pid; /* which child */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ int _status; /* exit code */
++ clock_t _utime;
++ clock_t _stime;
++ } _sigchld;
++
++ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
++ struct {
++ void __user *_addr; /* faulting insn/memory ref. */
++#ifdef __ARCH_SI_TRAPNO
++ int _trapno; /* TRAP # which caused the signal */
++#endif
++ } _sigfault;
++
++ /* SIGPOLL */
++ struct {
++ __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
++ int _fd;
++ } _sigpoll;
++ } _sifields;
++} siginfo_t;
++
++#endif
++
++/*
++ * How these fields are to be accessed.
++ */
++#define si_pid _sifields._kill._pid
++#define si_uid _sifields._kill._uid
++#define si_tid _sifields._timer._tid
++#define si_overrun _sifields._timer._overrun
++#define si_sys_private _sifields._timer._sys_private
++#define si_status _sifields._sigchld._status
++#define si_utime _sifields._sigchld._utime
++#define si_stime _sifields._sigchld._stime
++#define si_value _sifields._rt._sigval
++#define si_int _sifields._rt._sigval.sival_int
++#define si_ptr _sifields._rt._sigval.sival_ptr
++#define si_addr _sifields._sigfault._addr
++#ifdef __ARCH_SI_TRAPNO
++#define si_trapno _sifields._sigfault._trapno
++#endif
++#define si_band _sifields._sigpoll._band
++#define si_fd _sifields._sigpoll._fd
++
++#ifdef __KERNEL__
++#define __SI_MASK 0xffff0000u
++#define __SI_KILL (0 << 16)
++#define __SI_TIMER (1 << 16)
++#define __SI_POLL (2 << 16)
++#define __SI_FAULT (3 << 16)
++#define __SI_CHLD (4 << 16)
++#define __SI_RT (5 << 16)
++#define __SI_MESGQ (6 << 16)
++#define __SI_CODE(T,N) ((T) | ((N) & 0xffff))
++#else
++#define __SI_KILL 0
++#define __SI_TIMER 0
++#define __SI_POLL 0
++#define __SI_FAULT 0
++#define __SI_CHLD 0
++#define __SI_RT 0
++#define __SI_MESGQ 0
++#define __SI_CODE(T,N) (N)
++#endif
++
++/*
++ * si_code values
++ * Digital reserves positive values for kernel-generated signals.
++ */
++#define SI_USER 0 /* sent by kill, sigsend, raise */
++#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
++#define SI_QUEUE -1 /* sent by sigqueue */
++#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
++#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */
++#define SI_ASYNCIO -4 /* sent by AIO completion */
++#define SI_SIGIO -5 /* sent by queued SIGIO */
++#define SI_TKILL -6 /* sent by tkill system call */
++#define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
++
++#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
++#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
++
++/*
++ * SIGILL si_codes
++ */
++#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */
++#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */
++#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */
++#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */
++#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */
++#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */
++#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */
++#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */
++#define NSIGILL 8
++
++/*
++ * SIGFPE si_codes
++ */
++#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */
++#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */
++#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */
++#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */
++#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */
++#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */
++#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */
++#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */
++#define NSIGFPE 8
++
++/*
++ * SIGSEGV si_codes
++ */
++#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
++#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */
++#define NSIGSEGV 2
++
++/*
++ * SIGBUS si_codes
++ */
++#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
++#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */
++#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
++#define NSIGBUS 3
++
++/*
++ * SIGTRAP si_codes
++ */
++#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */
++#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */
++#define NSIGTRAP 2
++
++/*
++ * SIGCHLD si_codes
++ */
++#define CLD_EXITED (__SI_CHLD|1) /* child has exited */
++#define CLD_KILLED (__SI_CHLD|2) /* child was killed */
++#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */
++#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */
++#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */
++#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */
++#define NSIGCHLD 6
++
++/*
++ * SIGPOLL si_codes
++ */
++#define POLL_IN (__SI_POLL|1) /* data input available */
++#define POLL_OUT (__SI_POLL|2) /* output buffers available */
++#define POLL_MSG (__SI_POLL|3) /* input message available */
++#define POLL_ERR (__SI_POLL|4) /* i/o error */
++#define POLL_PRI (__SI_POLL|5) /* high priority input available */
++#define POLL_HUP (__SI_POLL|6) /* device disconnected */
++#define NSIGPOLL 6
++
++/*
++ * sigevent definitions
++ *
++ * It seems likely that SIGEV_THREAD will have to be handled from
++ * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
++ * thread manager then catches and does the appropriate nonsense.
++ * However, everything is written out here so as to not get lost.
++ */
++#define SIGEV_SIGNAL 0 /* notify via signal */
++#define SIGEV_NONE 1 /* other notification: meaningless */
++#define SIGEV_THREAD 2 /* deliver via thread creation */
++#define SIGEV_THREAD_ID 4 /* deliver to thread */
++
++#define SIGEV_MAX_SIZE 64
++#ifndef SIGEV_PAD_SIZE
++#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
++#endif
++
++typedef struct sigevent {
++ sigval_t sigev_value;
++ int sigev_signo;
++ int sigev_notify;
++ union {
++ int _pad[SIGEV_PAD_SIZE];
++ int _tid;
++
++ struct {
++ void (*_function)(sigval_t);
++ void *_attribute; /* really pthread_attr_t */
++ } _sigev_thread;
++ } _sigev_un;
++} sigevent_t;
++
++#define sigev_notify_function _sigev_un._sigev_thread._function
++#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
++#define sigev_notify_thread_id _sigev_un._tid
++
++#ifdef __KERNEL__
++
++struct siginfo;
++void do_schedule_next_timer(struct siginfo *info);
++
++#ifndef HAVE_ARCH_COPY_SIGINFO
++
++#include <linux/string.h>
++
++static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
++{
++ if (from->si_code < 0)
++ memcpy(to, from, sizeof(*to));
++ else
++ /* _sigchld is currently the largest know union member */
++ memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
++}
++
++#endif
++
++extern int copy_siginfo_to_user(struct siginfo __user *to, struct siginfo *from);
++
++#endif /* __KERNEL__ */
++
++#endif
+--- linux/include/asm-generic/statfs.h
++++ linux/include/asm-generic/statfs.h
+@@ -0,0 +1,51 @@
++#ifndef _GENERIC_STATFS_H
++#define _GENERIC_STATFS_H
++
++#ifndef __KERNEL_STRICT_NAMES
++# include <linux/types.h>
++typedef __kernel_fsid_t fsid_t;
++#endif
++
++struct statfs {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u32 f_blocks;
++ __u32 f_bfree;
++ __u32 f_bavail;
++ __u32 f_files;
++ __u32 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++struct statfs64 {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u64 f_blocks;
++ __u64 f_bfree;
++ __u64 f_bavail;
++ __u64 f_files;
++ __u64 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++struct compat_statfs64 {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u64 f_blocks;
++ __u64 f_bfree;
++ __u64 f_bavail;
++ __u64 f_files;
++ __u64 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++#endif
+--- linux/include/asm-generic/termios.h
++++ linux/include/asm-generic/termios.h
+@@ -0,0 +1,69 @@
++/* termios.h: generic termios/termio user copying/translation
++ */
++
++#ifndef _ASM_GENERIC_TERMIOS_H
++#define _ASM_GENERIC_TERMIOS_H
++
++#include <asm/uaccess.h>
++
++#ifndef __ARCH_TERMIO_GETPUT
++
++/*
++ * Translate a "termio" structure into a "termios". Ugh.
++ */
++static inline int user_termio_to_kernel_termios(struct termios *termios,
++ struct termio __user *termio)
++{
++ unsigned short tmp;
++
++ if (get_user(tmp, &termio->c_iflag) < 0)
++ goto fault;
++ termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp;
++
++ if (get_user(tmp, &termio->c_oflag) < 0)
++ goto fault;
++ termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp;
++
++ if (get_user(tmp, &termio->c_cflag) < 0)
++ goto fault;
++ termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp;
++
++ if (get_user(tmp, &termio->c_lflag) < 0)
++ goto fault;
++ termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp;
++
++ if (get_user(termios->c_line, &termio->c_line) < 0)
++ goto fault;
++
++ if (copy_from_user(termios->c_cc, termio->c_cc, NCC) != 0)
++ goto fault;
++
++ return 0;
++
++ fault:
++ return -EFAULT;
++}
++
++/*
++ * Translate a "termios" structure into a "termio". Ugh.
++ */
++static inline int kernel_termios_to_user_termio(struct termio __user *termio,
++ struct termios *termios)
++{
++ if (put_user(termios->c_iflag, &termio->c_iflag) < 0 ||
++ put_user(termios->c_oflag, &termio->c_oflag) < 0 ||
++ put_user(termios->c_cflag, &termio->c_cflag) < 0 ||
++ put_user(termios->c_lflag, &termio->c_lflag) < 0 ||
++ put_user(termios->c_line, &termio->c_line) < 0 ||
++ copy_to_user(termio->c_cc, termios->c_cc, NCC) != 0)
++ return -EFAULT;
++
++ return 0;
++}
++
++#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
++#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
++
++#endif /* __ARCH_TERMIO_GETPUT */
++
++#endif /* _ASM_GENERIC_TERMIOS_H */
+--- linux/include/asm-generic/tlb.h
++++ linux/include/asm-generic/tlb.h
+@@ -0,0 +1,160 @@
++/* asm-generic/tlb.h
++ *
++ * Generic TLB shootdown code
++ *
++ * Copyright 2001 Red Hat, Inc.
++ * Based on code from mm/memory.c Copyright Linus Torvalds and others.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++ */
++#ifndef _ASM_GENERIC__TLB_H
++#define _ASM_GENERIC__TLB_H
++
++// #include <linux/config.h>
++#include <linux/swap.h>
++#include <asm/pgalloc.h>
++#include <asm/tlbflush.h>
++
++/*
++ * For UP we don't need to worry about TLB flush
++ * and page free order so much..
++ */
++#ifdef CONFIG_SMP
++ #define FREE_PTE_NR 506
++ #define tlb_fast_mode(tlb) ((tlb)->nr == ~0U)
++#else
++ #define FREE_PTE_NR 1
++ #define tlb_fast_mode(tlb) 1
++#endif
++
++/* struct mmu_gather is an opaque type used by the mm code for passing around
++ * any data needed by arch specific code for tlb_remove_page. This structure
++ * can be per-CPU or per-MM as the page table lock is held for the duration of
++ * TLB shootdown.
++ */
++struct mmu_gather {
++ struct mm_struct *mm;
++ unsigned int nr; /* set to ~0U means fast mode */
++ unsigned int need_flush;/* Really unmapped some ptes? */
++ unsigned int fullmm; /* non-zero means full mm flush */
++ unsigned long freed;
++ struct page * pages[FREE_PTE_NR];
++};
++
++/* Users of the generic TLB shootdown code must declare this storage space. */
++DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
++
++/* tlb_gather_mmu
++ * Return a pointer to an initialized struct mmu_gather.
++ */
++static inline struct mmu_gather *
++tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
++{
++ struct mmu_gather *tlb = &per_cpu(mmu_gathers, smp_processor_id());
++
++ tlb->mm = mm;
++
++ /* Use fast mode if only one CPU is online */
++ tlb->nr = num_online_cpus() > 1 ? 0U : ~0U;
++
++ tlb->fullmm = full_mm_flush;
++ tlb->freed = 0;
++
++ return tlb;
++}
++
++static inline void
++tlb_flush_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
++{
++ if (!tlb->need_flush)
++ return;
++ tlb->need_flush = 0;
++ tlb_flush(tlb);
++ if (!tlb_fast_mode(tlb)) {
++ free_pages_and_swap_cache(tlb->pages, tlb->nr);
++ tlb->nr = 0;
++ }
++}
++
++/* tlb_finish_mmu
++ * Called at the end of the shootdown operation to free up any resources
++ * that were required. The page table lock is still held at this point.
++ */
++static inline void
++tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
++{
++ int freed = tlb->freed;
++ struct mm_struct *mm = tlb->mm;
++ int rss = mm->rss;
++
++ if (rss < freed)
++ freed = rss;
++ mm->rss = rss - freed;
++ tlb_flush_mmu(tlb, start, end);
++
++ /* keep the page table cache within bounds */
++ check_pgt_cache();
++}
++
++static inline unsigned int
++tlb_is_full_mm(struct mmu_gather *tlb)
++{
++ return tlb->fullmm;
++}
++
++/* tlb_remove_page
++ * Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), while
++ * handling the additional races in SMP caused by other CPUs caching valid
++ * mappings in their TLBs.
++ */
++static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
++{
++ tlb->need_flush = 1;
++ if (tlb_fast_mode(tlb)) {
++ free_page_and_swap_cache(page);
++ return;
++ }
++ tlb->pages[tlb->nr++] = page;
++ if (tlb->nr >= FREE_PTE_NR)
++ tlb_flush_mmu(tlb, 0, 0);
++}
++
++/**
++ * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation.
++ *
++ * Record the fact that pte's were really umapped in ->need_flush, so we can
++ * later optimise away the tlb invalidate. This helps when userspace is
++ * unmapping already-unmapped pages, which happens quite a lot.
++ */
++#define tlb_remove_tlb_entry(tlb, ptep, address) \
++ do { \
++ tlb->need_flush = 1; \
++ __tlb_remove_tlb_entry(tlb, ptep, address); \
++ } while (0)
++
++#define pte_free_tlb(tlb, ptep) \
++ do { \
++ tlb->need_flush = 1; \
++ __pte_free_tlb(tlb, ptep); \
++ } while (0)
++
++#ifndef __ARCH_HAS_4LEVEL_HACK
++#define pud_free_tlb(tlb, pudp) \
++ do { \
++ tlb->need_flush = 1; \
++ __pud_free_tlb(tlb, pudp); \
++ } while (0)
++#endif
++
++#define pmd_free_tlb(tlb, pmdp) \
++ do { \
++ tlb->need_flush = 1; \
++ __pmd_free_tlb(tlb, pmdp); \
++ } while (0)
++
++#define tlb_migrate_finish(mm) do {} while (0)
++
++#endif /* _ASM_GENERIC__TLB_H */
+--- linux/include/asm-generic/topology.h
++++ linux/include/asm-generic/topology.h
+@@ -0,0 +1,48 @@
++/*
++ * linux/include/asm-generic/topology.h
++ *
++ * Written by: Matthew Dobson, IBM Corporation
++ *
++ * Copyright (C) 2002, IBM Corp.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ * Send feedback to <colpatch@us.ibm.com>
++ */
++#ifndef _ASM_GENERIC_TOPOLOGY_H
++#define _ASM_GENERIC_TOPOLOGY_H
++
++/* Other architectures wishing to use this simple topology API should fill
++ in the below functions as appropriate in their own <asm/topology.h> file. */
++#ifndef cpu_to_node
++#define cpu_to_node(cpu) (0)
++#endif
++#ifndef parent_node
++#define parent_node(node) (0)
++#endif
++#ifndef node_to_cpumask
++#define node_to_cpumask(node) (cpu_online_map)
++#endif
++#ifndef node_to_first_cpu
++#define node_to_first_cpu(node) (0)
++#endif
++#ifndef pcibus_to_cpumask
++#define pcibus_to_cpumask(bus) (cpu_online_map)
++#endif
++
++#endif /* _ASM_GENERIC_TOPOLOGY_H */
+--- linux/include/asm-generic/uaccess.h
++++ linux/include/asm-generic/uaccess.h
+@@ -0,0 +1,26 @@
++#ifndef _ASM_GENERIC_UACCESS_H_
++#define _ASM_GENERIC_UACCESS_H_
++
++/*
++ * This macro should be used instead of __get_user() when accessing
++ * values at locations that are not known to be aligned.
++ */
++#define __get_user_unaligned(x, ptr) \
++({ \
++ __typeof__ (*(ptr)) __x; \
++ __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0; \
++ (x) = __x; \
++})
++
++
++/*
++ * This macro should be used instead of __put_user() when accessing
++ * values at locations that are not known to be aligned.
++ */
++#define __put_user_unaligned(x, ptr) \
++({ \
++ __typeof__ (*(ptr)) __x = (x); \
++ __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0; \
++})
++
++#endif /* _ASM_GENERIC_UACCESS_H */
+--- linux/include/asm-generic/unaligned.h
++++ linux/include/asm-generic/unaligned.h
+@@ -0,0 +1,20 @@
++#ifndef _ASM_GENERIC_UNALIGNED_H_
++#define _ASM_GENERIC_UNALIGNED_H_
++
++/*
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents.
++ */
++
++#include <asm/string.h>
++
++
++#define get_unaligned(ptr) \
++ ({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
++
++#define put_unaligned(val, ptr) \
++ ({ __typeof__(*(ptr)) __tmp = (val); \
++ memcpy((ptr), &__tmp, sizeof(*(ptr))); \
++ (void)0; })
++
++#endif /* _ASM_GENERIC_UNALIGNED_H */
+--- linux/include/asm-generic/vmlinux.lds.h
++++ linux/include/asm-generic/vmlinux.lds.h
+@@ -0,0 +1,90 @@
++#ifndef LOAD_OFFSET
++#define LOAD_OFFSET 0
++#endif
++
++#ifndef VMLINUX_SYMBOL
++#define VMLINUX_SYMBOL(_sym_) _sym_
++#endif
++
++#define RODATA \
++ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
++ *(.rodata) *(.rodata.*) \
++ *(__vermagic) /* Kernel version magic */ \
++ } \
++ \
++ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
++ *(.rodata1) \
++ } \
++ \
++ /* PCI quirks */ \
++ .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
++ *(.pci_fixup_early) \
++ VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
++ VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
++ *(.pci_fixup_header) \
++ VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
++ VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
++ *(.pci_fixup_final) \
++ VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
++ VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
++ *(.pci_fixup_enable) \
++ VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
++ } \
++ \
++ /* Kernel symbol table: Normal symbols */ \
++ __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___ksymtab) = .; \
++ *(__ksymtab) \
++ VMLINUX_SYMBOL(__stop___ksymtab) = .; \
++ } \
++ \
++ /* Kernel symbol table: GPL-only symbols */ \
++ __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
++ *(__ksymtab_gpl) \
++ VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
++ } \
++ \
++ /* Kernel symbol table: Normal symbols */ \
++ __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___kcrctab) = .; \
++ *(__kcrctab) \
++ VMLINUX_SYMBOL(__stop___kcrctab) = .; \
++ } \
++ \
++ /* Kernel symbol table: GPL-only symbols */ \
++ __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
++ *(__kcrctab_gpl) \
++ VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
++ } \
++ \
++ /* Kernel symbol table: strings */ \
++ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
++ *(__ksymtab_strings) \
++ } \
++ \
++ /* Built-in module parameters. */ \
++ __param : AT(ADDR(__param) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___param) = .; \
++ *(__param) \
++ VMLINUX_SYMBOL(__stop___param) = .; \
++ }
++
++#define SECURITY_INIT \
++ .security_initcall.init : { \
++ VMLINUX_SYMBOL(__security_initcall_start) = .; \
++ *(.security_initcall.init) \
++ VMLINUX_SYMBOL(__security_initcall_end) = .; \
++ }
++
++#define SCHED_TEXT \
++ VMLINUX_SYMBOL(__sched_text_start) = .; \
++ *(.sched.text) \
++ VMLINUX_SYMBOL(__sched_text_end) = .;
++
++#define LOCK_TEXT \
++ VMLINUX_SYMBOL(__lock_text_start) = .; \
++ *(.spinlock.text) \
++ VMLINUX_SYMBOL(__lock_text_end) = .;
+--- linux/include/asm-generic/xor.h
++++ linux/include/asm-generic/xor.h
+@@ -0,0 +1,718 @@
++/*
++ * include/asm-generic/xor.h
++ *
++ * Generic optimized RAID-5 checksumming functions.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * You should have received a copy of the GNU General Public License
++ * (for example /usr/src/linux/COPYING); if not, write to the Free
++ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <asm/processor.h>
++
++static void
++xor_8regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0];
++ p1[1] ^= p2[1];
++ p1[2] ^= p2[2];
++ p1[3] ^= p2[3];
++ p1[4] ^= p2[4];
++ p1[5] ^= p2[5];
++ p1[6] ^= p2[6];
++ p1[7] ^= p2[7];
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0];
++ p1[1] ^= p2[1] ^ p3[1];
++ p1[2] ^= p2[2] ^ p3[2];
++ p1[3] ^= p2[3] ^ p3[3];
++ p1[4] ^= p2[4] ^ p3[4];
++ p1[5] ^= p2[5] ^ p3[5];
++ p1[6] ^= p2[6] ^ p3[6];
++ p1[7] ^= p2[7] ^ p3[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ d0 ^= p5[0];
++ d1 ^= p5[1];
++ d2 ^= p5[2];
++ d3 ^= p5[3];
++ d4 ^= p5[4];
++ d5 ^= p5[5];
++ d6 ^= p5[6];
++ d7 ^= p5[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++ prefetchw(p1);
++ prefetch(p2);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ once_more:
++ p1[0] ^= p2[0];
++ p1[1] ^= p2[1];
++ p1[2] ^= p2[2];
++ p1[3] ^= p2[3];
++ p1[4] ^= p2[4];
++ p1[5] ^= p2[5];
++ p1[6] ^= p2[6];
++ p1[7] ^= p2[7];
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0];
++ p1[1] ^= p2[1] ^ p3[1];
++ p1[2] ^= p2[2] ^ p3[2];
++ p1[3] ^= p2[3] ^ p3[3];
++ p1[4] ^= p2[4] ^ p3[4];
++ p1[5] ^= p2[5] ^ p3[5];
++ p1[6] ^= p2[6] ^ p3[6];
++ p1[7] ^= p2[7] ^ p3[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++ prefetch(p5);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ prefetch(p5+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++ prefetch(p5);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ prefetch(p5+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ d0 ^= p5[0];
++ d1 ^= p5[1];
++ d2 ^= p5[2];
++ d3 ^= p5[3];
++ d4 ^= p5[4];
++ d5 ^= p5[5];
++ d6 ^= p5[6];
++ d7 ^= p5[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static struct xor_block_template xor_block_8regs = {
++ .name = "8regs",
++ .do_2 = xor_8regs_2,
++ .do_3 = xor_8regs_3,
++ .do_4 = xor_8regs_4,
++ .do_5 = xor_8regs_5,
++};
++
++static struct xor_block_template xor_block_32regs = {
++ .name = "32regs",
++ .do_2 = xor_32regs_2,
++ .do_3 = xor_32regs_3,
++ .do_4 = xor_32regs_4,
++ .do_5 = xor_32regs_5,
++};
++
++static struct xor_block_template xor_block_8regs_p = {
++ .name = "8regs_prefetch",
++ .do_2 = xor_8regs_p_2,
++ .do_3 = xor_8regs_p_3,
++ .do_4 = xor_8regs_p_4,
++ .do_5 = xor_8regs_p_5,
++};
++
++static struct xor_block_template xor_block_32regs_p = {
++ .name = "32regs_prefetch",
++ .do_2 = xor_32regs_p_2,
++ .do_3 = xor_32regs_p_3,
++ .do_4 = xor_32regs_p_4,
++ .do_5 = xor_32regs_p_5,
++};
++
++#define XOR_TRY_TEMPLATES \
++ do { \
++ xor_speed(&xor_block_8regs); \
++ xor_speed(&xor_block_8regs_p); \
++ xor_speed(&xor_block_32regs); \
++ xor_speed(&xor_block_32regs_p); \
++ } while (0)
+--- linux/include/asm-nios2nommu/altera_juart.h
++++ linux/include/asm-nios2nommu/altera_juart.h
+@@ -0,0 +1,36 @@
++/*------------------------------------------------------------------------
++ *
++ * linux/drivers/serial/altera_juart.h
++ *
++ * Driver for Altera JTAG UART core with Avalon interface
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * History:
++ * Jun/20/2005 DGT Microtronix Datacom NiosII
++ *
++ -----------------------------------------------------------------------*/
++
++#ifndef _ALTERA_JUART_H_
++ #define _ALTERA_JUART_H_
++
++ /* jtag uart details needed outside of the driver itself: */
++ /* by: arch/kernel/start.c - boot time error message(s) */
++
++ void jtaguart_console_write
++ ( struct console *co,
++ const char *s,
++ unsigned int count);
++
++#endif /* _ALTERA_JUART_H_ */
+--- linux/include/asm-nios2nommu/a.out.h
++++ linux/include/asm-nios2nommu/a.out.h
+@@ -0,0 +1,85 @@
++/* $Id: a.out.h,v 1.4 2004/03/30 19:35:04 ken-h Exp $ */
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2NOMMU_A_OUT_H__
++#define __NIOS2NOMMU_A_OUT_H__
++
++#define SPARC_PGSIZE 0x1000 /* Thanks to the sun4 architecture... */
++#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
++
++struct exec {
++ unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
++ unsigned char a_toolversion:7;
++ unsigned char a_machtype;
++ unsigned short a_info;
++ unsigned long a_text; /* length of text, in bytes */
++ unsigned long a_data; /* length of data, in bytes */
++ unsigned long a_bss; /* length of bss, in bytes */
++ unsigned long a_syms; /* length of symbol table, in bytes */
++ unsigned long a_entry; /* where program begins */
++ unsigned long a_trsize;
++ unsigned long a_drsize;
++};
++
++#define INIT_EXEC { \
++ .a_dynamic = 0, \
++ .a_toolversion = 0, \
++ .a_machtype = 0, \
++ .a_info = 0, \
++ .a_text = 0, \
++ .a_data = 0, \
++ .a_bss = 0, \
++ .a_syms = 0, \
++ .a_entry = 0, \
++ .a_trsize = 0, \
++ .a_drsize = 0, \
++}
++
++/* Where in the file does the text information begin? */
++#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
++
++/* Where do the Symbols start? */
++#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
++ (x).a_data + (x).a_trsize + \
++ (x).a_drsize)
++
++/* Where does text segment go in memory after being loaded? */
++#define N_TXTADDR(x) (((N_MAGIC(x) == ZMAGIC) && \
++ ((x).a_entry < SPARC_PGSIZE)) ? \
++ 0 : SPARC_PGSIZE)
++
++/* And same for the data segment.. */
++#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
++ (N_TXTADDR(x) + (x).a_text) \
++ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
++
++#define N_TRSIZE(a) ((a).a_trsize)
++#define N_DRSIZE(a) ((a).a_drsize)
++#define N_SYMSIZE(a) ((a).a_syms)
++
++#ifdef __KERNEL__
++
++#define STACK_TOP TASK_SIZE
++
++#endif
++
++#endif /* __NIOS2NOMMU_A_OUT_H__ */
+--- linux/include/asm-nios2nommu/asm-macros.h
++++ linux/include/asm-nios2nommu/asm-macros.h
+@@ -0,0 +1,331 @@
++/*
++ * Macro used to simplify coding multi-line assembler.
++ * Some of the bit test macro can simplify down to one line
++ * depending on the mask value.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++/*
++ * ANDs reg2 with mask and places the result in reg1.
++ *
++ * You cannnot use the same register for reg1 & reg2.
++ */
++
++.macro ANDI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ movhi \reg1,%hi(\mask)
++ movui \reg1,%lo(\mask)
++ and \reg1,\reg1,\reg2
++ .else
++ andi \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ andhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * ORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro ORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ orhi \reg1,\reg2,%hi(\mask)
++ ori \reg1,\reg2,%lo(\mask)
++ .else
++ ori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ orhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * XORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro XORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ xorhi \reg1,\reg2,%hi(\mask)
++ xori \reg1,\reg1,%lo(\mask)
++ .else
++ xori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ xorhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * This is a support macro for BTBZ & BTBNZ. It checks
++ * the bit to make sure it is valid 32 value.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BT reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is non-zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBNZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTC reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ xori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ xorhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTS reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ ori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ orhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTR reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ andi \reg2,\reg2,%lo(~(1 << \bit))
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ andhi \reg2,\reg2,%lo(~(1 << (\bit - 16)))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBNZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBNZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBNZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the all the bits in the mask are zero it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the any of the bits in the mask are 1 it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBNZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Pushes reg onto the stack.
++ */
++
++.macro PUSH reg
++ addi sp,sp,-4
++ stw \reg,0(sp)
++.endm
++
++/*
++ * Pops the top of the stack into reg.
++ */
++
++.macro POP reg
++ ldw \reg,0(sp)
++ addi sp,sp,4
++.endm
++
++/*
++ * Clears reg
++ */
++
++.macro CLR reg
++ mov \reg,r0
++.endm
++
++/*
++ * The preprocessor macro does not work for
++ * the nios2 compiler. Undefine ENTRY and define
++ * a real assembler macro.
++ */
++#undef ENTRY
++#define ENTRY(name) ASM_ENTRY name
++
++.macro ASM_ENTRY name
++.globl \name
++__ALIGN
++ \name:
++.endm
+--- linux/include/asm-nios2nommu/atomic.h
++++ linux/include/asm-nios2nommu/atomic.h
+@@ -0,0 +1,190 @@
++//vic - add 'atomic_add/sub_return', 'atomic_add_negative'
++//vic from v850 architecture
++
++/* atomic.h:
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2001 Vic Phillips (vic@microtronix.com)
++ *
++ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ARCH_NIOS2NOMMU_ATOMIC__
++#define __ARCH_NIOS2NOMMU_ATOMIC__
++
++#include <asm/system.h>
++
++typedef struct { int counter; } atomic_t;
++#define ATOMIC_INIT(i) { (i) }
++
++#define atomic_read(v) ((v)->counter)
++#define atomic_set(v, i) (((v)->counter) = i)
++
++
++extern __inline__ void atomic_add(int i, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter += i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_add_negative(int i, atomic_t *v)
++{
++ unsigned long flags;
++ int result;
++
++ local_irq_save(flags);
++ v->counter += i;
++ result = (v->counter < 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_sub(int i, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_sub_and_test(int i, atomic_t *v)
++{
++ int result;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_inc(atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter += 1;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_inc_and_test(atomic_t *v)
++{
++ unsigned long flags;
++ int result;
++
++ local_irq_save(flags);
++ v->counter += 1;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_dec(atomic_t *v)
++{
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_dec_and_test(atomic_t *v)
++{
++ int result;
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_inc_return(atomic_t *v)
++{
++ int result;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ result = ++v->counter;
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_dec_return(atomic_t *v)
++{
++ int result;
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = v->counter;
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_add_return (int i, volatile atomic_t *v)
++{
++ int res;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ res = v->counter + i;
++ v->counter = res;
++ local_irq_restore(flags);
++
++ return res;
++}
++
++static __inline__ int atomic_sub_return (int i, volatile atomic_t *v)
++{
++ int res;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ res = v->counter - i;
++ v->counter = res;
++ local_irq_restore(flags);
++
++ return res;
++}
++
++#define atomic_dec_return(v) atomic_sub_return(1,(v))
++#define atomic_inc_return(v) atomic_add_return(1,(v))
++
++/* Atomic operations are already serializing */
++#define smp_mb__before_atomic_dec() barrier()
++#define smp_mb__after_atomic_dec() barrier()
++#define smp_mb__before_atomic_inc() barrier()
++#define smp_mb__after_atomic_inc() barrier()
++
++
++#endif /* !(__ARCH_NIOS2NOMMU_ATOMIC__) */
++
++
+--- linux/include/asm-nios2nommu/bitops.h
++++ linux/include/asm-nios2nommu/bitops.h
+@@ -0,0 +1,472 @@
++#ifndef _ASM_NIOS_BITOPS_H_
++#define _ASM_NIOS_BITOPS_H_
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bitops.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef __KERNEL__
++// #include <linux/config.h>
++#include <linux/compiler.h>
++#include <asm/byteorder.h> /* swab32 */
++#include <asm/system.h>
++#endif
++
++/*
++ * Adapted to NIOS from generic bitops.h:
++ *
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents. You should
++ * recode these in the native assembly language, if at all possible.
++ * To guarantee atomicity, these routines call cli() and sti() to
++ * disable interrupts while they operate. (You have to provide inline
++ * routines to cli() and sti().)
++ *
++ * Also note, these routines assume that you have 32 bit integers.
++ * You will have to change this if you are trying to port Linux to the
++ * Alpha architecture or to a Cray. :-)
++ *
++ * C language equivalents written by Theodore Ts'o, 9/26/92
++ */
++
++/*
++ * Generic ffs().
++ */
++static inline int ffs(int x)
++{
++ int r = 1;
++
++ if (!x)
++ return 0;
++ if (!(x & 0xffff)) {
++ x >>= 16;
++ r += 16;
++ }
++ if (!(x & 0xff)) {
++ x >>= 8;
++ r += 8;
++ }
++ if (!(x & 0xf)) {
++ x >>= 4;
++ r += 4;
++ }
++ if (!(x & 3)) {
++ x >>= 2;
++ r += 2;
++ }
++ if (!(x & 1)) {
++ x >>= 1;
++ r += 1;
++ }
++ return r;
++}
++
++/*
++ * Generic __ffs().
++ */
++static inline int __ffs(int x)
++{
++ int r = 0;
++
++ if (!x)
++ return 0;
++ if (!(x & 0xffff)) {
++ x >>= 16;
++ r += 16;
++ }
++ if (!(x & 0xff)) {
++ x >>= 8;
++ r += 8;
++ }
++ if (!(x & 0xf)) {
++ x >>= 4;
++ r += 4;
++ }
++ if (!(x & 3)) {
++ x >>= 2;
++ r += 2;
++ }
++ if (!(x & 1)) {
++ x >>= 1;
++ r += 1;
++ }
++ return r;
++}
++
++/*
++ * fls: find last bit set.
++ */
++#define fls(x) generic_fls(x)
++
++
++/*
++ * Every architecture must define this function. It's the fastest
++ * way of searching a 140-bit bitmap where the first 100 bits are
++ * unlikely to be set. It's guaranteed that at least one of the 140
++ * bits is cleared.
++ */
++static inline int sched_find_first_bit(unsigned long *b)
++{
++ if (unlikely(b[0]))
++ return __ffs(b[0]);
++ if (unlikely(b[1]))
++ return __ffs(b[1]) + 32;
++ if (unlikely(b[2]))
++ return __ffs(b[2]) + 64;
++ if (b[3])
++ return __ffs(b[3]) + 96;
++ return __ffs(b[4]) + 128;
++}
++
++/*
++ * ffz = Find First Zero in word. Undefined if no zero exists,
++ * so code should check against ~0UL first..
++ */
++static __inline__ unsigned long ffz(unsigned long word)
++{
++ unsigned long result = 0;
++
++ while(word & 1) {
++ result++;
++ word >>= 1;
++ }
++ return result;
++}
++
++
++static __inline__ void set_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ *a |= mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __set_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ *a |= mask;
++}
++
++/*
++ * clear_bit() doesn't provide any barrier for the compiler.
++ */
++#define smp_mb__before_clear_bit() barrier()
++#define smp_mb__after_clear_bit() barrier()
++
++static __inline__ void clear_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ *a &= ~mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __clear_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ *a &= ~mask;
++}
++
++static __inline__ void change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, flags;
++ unsigned long *ADDR = (unsigned long *) addr;
++
++ ADDR += nr >> 5;
++ mask = 1 << (nr & 31);
++ local_irq_save(flags);
++ *ADDR ^= mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask;
++ unsigned long *ADDR = (unsigned long *) addr;
++
++ ADDR += nr >> 5;
++ mask = 1 << (nr & 31);
++ *ADDR ^= mask;
++}
++
++static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a |= mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a |= mask;
++ return retval;
++}
++
++static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a &= ~mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a &= ~mask;
++ return retval;
++}
++
++static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a ^= mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a ^= mask;
++ return retval;
++}
++
++/*
++ * This routine doesn't need to be atomic.
++ */
++static __inline__ int __constant_test_bit(int nr, const volatile unsigned long * addr)
++{
++ return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
++}
++
++static __inline__ int __test_bit(int nr, const volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ return ((mask & *a) != 0);
++}
++
++#define test_bit(nr,addr) \
++(__builtin_constant_p(nr) ? \
++ __constant_test_bit((nr),(unsigned long *)(addr)) : \
++ __test_bit((nr),(unsigned long *)(addr)))
++
++
++/* find_next_zero_bit() finds the first zero bit in a bit string of length
++ * 'size' bits, starting the search at bit 'offset'. This is largely based
++ * on Linus's ALPHA routines, which are pretty portable BTW.
++ */
++
++extern __inline__ unsigned long find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
++{
++ unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
++ unsigned long result = offset & ~31UL;
++ unsigned long tmp;
++
++ if (offset >= size)
++ return size;
++ size -= result;
++ offset &= 31UL;
++ if (offset) {
++ tmp = *(p++);
++ tmp |= ~0UL >> (32-offset);
++ if (size < 32)
++ goto found_first;
++ if (~tmp)
++ goto found_middle;
++ size -= 32;
++ result += 32;
++ }
++ while (size & ~31UL) {
++ if (~(tmp = *(p++)))
++ goto found_middle;
++ result += 32;
++ size -= 32;
++ }
++ if (!size)
++ return result;
++ tmp = *p;
++
++found_first:
++ tmp |= ~0UL << size;
++ if (tmp == ~0UL)
++ return result + size;
++found_middle:
++ return result + ffz(tmp);
++}
++
++/*
++ * Find next one bit in a bitmap reasonably efficiently.
++ */
++extern __inline__ unsigned long find_next_bit(const unsigned long *addr,
++ unsigned long size, unsigned long offset)
++{
++ unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
++ unsigned int result = offset & ~31UL;
++ unsigned int tmp;
++
++ if (offset >= size)
++ return size;
++ size -= result;
++ offset &= 31UL;
++ if (offset) {
++ tmp = *p++;
++ tmp &= ~0UL << offset;
++ if (size < 32)
++ goto found_first;
++ if (tmp)
++ goto found_middle;
++ size -= 32;
++ result += 32;
++ }
++ while (size >= 32) {
++ if ((tmp = *p++) != 0)
++ goto found_middle;
++ result += 32;
++ size -= 32;
++ }
++ if (!size)
++ return result;
++ tmp = *p;
++
++found_first:
++ tmp &= ~0UL >> (32 - size);
++ if (tmp == 0UL) /* Are any bits set? */
++ return result + size; /* Nope. */
++found_middle:
++ return result + __ffs(tmp);
++}
++
++/*
++ * hweightN: returns the hamming weight (i.e. the number
++ * of bits set) of a N-bit word
++ */
++
++#define hweight32(x) generic_hweight32(x)
++#define hweight16(x) generic_hweight16(x)
++#define hweight8(x) generic_hweight8(x)
++
++/* Linus sez that gcc can optimize the following correctly, we'll see if this
++ * holds on the Sparc as it does for the ALPHA.
++ */
++
++#define find_first_zero_bit(addr, size) \
++ find_next_zero_bit((addr), (size), 0)
++#define find_first_bit(addr, size) \
++ find_next_bit((addr), (size), 0)
++
++/* Now for the ext2 filesystem bit operations and helper routines.
++ *
++ * Both NIOS and ext2 are little endian, so these are the same as above.
++ */
++
++#define ext2_set_bit test_and_set_bit
++#define ext2_clear_bit test_and_clear_bit
++#define ext2_test_bit test_bit
++
++#define ext2_set_bit_atomic(lock, nr, addr) \
++ ({ \
++ int ret; \
++ spin_lock(lock); \
++ ret = ext2_set_bit((nr),(unsigned long *) (addr)); \
++ spin_unlock(lock); \
++ ret; \
++ })
++
++#define ext2_clear_bit_atomic(lock, nr, addr) \
++ ({ \
++ int ret; \
++ spin_lock(lock); \
++ ret = ext2_clear_bit((nr),(unsigned long *) (addr)); \
++ spin_unlock(lock); \
++ ret; \
++ })
++
++#define ext2_find_first_zero_bit find_first_zero_bit
++#define ext2_find_next_zero_bit find_next_zero_bit
++
++#endif /* _ASM_NIOS_BITOPS_H */
+--- linux/include/asm-nios2nommu/bootinfo.h
++++ linux/include/asm-nios2nommu/bootinfo.h
+@@ -0,0 +1,2 @@
++
++/* Nothing for nios2nommu */
+--- linux/include/asm-nios2nommu/bug.h
++++ linux/include/asm-nios2nommu/bug.h
+@@ -0,0 +1,48 @@
++#ifndef _NIOS2NOMMU_BUG_H
++#define _NIOS2NOMMU_BUG_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bug.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define BUG() do { \
++ printk("%s(%d): kernel BUG!\n", __FILE__, __LINE__); \
++} while (0)
++
++#define BUG_ON(condition) do { \
++ if (unlikely((condition)!=0)) \
++ BUG(); \
++} while(0)
++
++#define PAGE_BUG(page) do { \
++ BUG(); \
++} while (0)
++
++#define WARN_ON(condition) do { \
++ if (unlikely((condition)!=0)) { \
++ printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
++ dump_stack(); \
++ } \
++} while (0)
++
++#endif
+--- linux/include/asm-nios2nommu/bugs.h
++++ linux/include/asm-nios2nommu/bugs.h
+@@ -0,0 +1,40 @@
++#ifndef __ASM_NIOS_BUGS_H
++#define __ASM_NIOS_BUGS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bugs.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1994 Linus Torvalds
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This is included by init/main.c to check for architecture-dependent bugs.
++ *
++ * Needs:
++ * void check_bugs(void);
++ */
++
++static void check_bugs(void)
++{
++}
++
++#endif
+--- linux/include/asm-nios2nommu/byteorder.h
++++ linux/include/asm-nios2nommu/byteorder.h
+@@ -0,0 +1,38 @@
++#ifndef __ASM_NIOS_BYTEORDER_H
++#define __ASM_NIOS_BYTEORDER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/byteorder.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/types.h>
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
++# define __BYTEORDER_HAS_U64__
++# define __SWAB_64_THRU_32__
++#endif
++
++#include <linux/byteorder/little_endian.h>
++
++#endif
++
+--- linux/include/asm-nios2nommu/cachectl.h
++++ linux/include/asm-nios2nommu/cachectl.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_CACHECTL_H
++#define _NIOS2NOMMU_CACHECTL_H
++
++/* Definitions for the cacheflush system call. */
++
++#define FLUSH_SCOPE_LINE 1 /* Flush a cache line */
++#define FLUSH_SCOPE_PAGE 2 /* Flush a page */
++#define FLUSH_SCOPE_ALL 3 /* Flush the whole cache -- superuser only */
++
++#define FLUSH_CACHE_DATA 1 /* Writeback and flush data cache */
++#define FLUSH_CACHE_INSN 2 /* Flush instruction cache */
++#define FLUSH_CACHE_BOTH 3 /* Flush both caches */
++
++#endif /* _NIOS2NOMMU_CACHECTL_H */
+--- linux/include/asm-nios2nommu/cacheflush.h
++++ linux/include/asm-nios2nommu/cacheflush.h
+@@ -0,0 +1,59 @@
++#ifndef _NIOS2NOMMU_CACHEFLUSH_H
++#define _NIOS2NOMMU_CACHEFLUSH_H
++
++/*
++ * Ported from m68knommu.
++ *
++ * (C) Copyright 2003, Microtronix Datacom Ltd.
++ * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com>
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#include <linux/mm.h>
++
++extern void cache_push (unsigned long vaddr, int len);
++extern void dcache_push (unsigned long vaddr, int len);
++extern void icache_push (unsigned long vaddr, int len);
++extern void cache_push_all (void);
++extern void cache_clear (unsigned long paddr, int len);
++
++#define flush_cache_all() __flush_cache_all()
++#define flush_cache_mm(mm) do { } while (0)
++#define flush_cache_range(vma, start, end) cache_push(start, end - start)
++#define flush_cache_page(vma, vmaddr) do { } while (0)
++#define flush_dcache_range(start,end) dcache_push(start, end - start)
++#define flush_dcache_page(page) do { } while (0)
++#define flush_dcache_mmap_lock(mapping) do { } while (0)
++#define flush_dcache_mmap_unlock(mapping) do { } while (0)
++#define flush_icache_range(start,end) cache_push(start, end - start)
++#define flush_icache_page(vma,pg) do { } while (0)
++#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
++
++#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++
++
++extern inline void __flush_cache_all(void)
++{
++ cache_push_all();
++}
++
++#endif /* _NIOS2NOMMU_CACHEFLUSH_H */
+--- linux/include/asm-nios2nommu/cache.h
++++ linux/include/asm-nios2nommu/cache.h
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __ARCH_NIOS2NOMMU_CACHE_H
++#define __ARCH_NIOS2NOMMU_CACHE_H
++
++#include <asm/nios.h>
++
++/* bytes per L1 cache line */
++#define L1_CACHE_BYTES nasys_icache_line_size /* this need to be at least 1 */
++
++
++#define __cacheline_aligned
++#define ____cacheline_aligned
++
++#endif
+--- linux/include/asm-nios2nommu/ChangeLog
++++ linux/include/asm-nios2nommu/ChangeLog
+@@ -0,0 +1,14 @@
++2004-06-29 Ken Hill <khill@microtronix.com>
++
++ * bitops.h (find_next_zero_bit): Fix problem with with masking for found_first
++ handling. The masking of the upper bits for size < 32 bits would set all
++ the bits to 1. Removing any zero's there may have been.
++
++2004-06-02 Ken Hill <khill@microtronix.com>
++
++ * processor.h (TASK_SIZE): Change na_sdram_end to nasys_program_mem_end to remove
++ dependancy on quartus memory component name.
++
++ * page.h (PAGE_OFFSET): Change na_sdram to nasys_program_mem to remove
++ dependancy on quartus memory component name.
++
+--- linux/include/asm-nios2nommu/checksum.h
++++ linux/include/asm-nios2nommu/checksum.h
+@@ -0,0 +1,320 @@
++#ifndef __NIOS2_CHECKSUM_H
++#define __NIOS2_CHECKSUM_H
++
++/* checksum.h: IP/UDP/TCP checksum routines on the NIOS.
++ *
++ * Copyright(C) 1995 Linus Torvalds
++ * Copyright(C) 1995 Miguel de Icaza
++ * Copyright(C) 1996 David S. Miller
++ * Copyright(C) 2001 Ken Hill
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * derived from:
++ * Alpha checksum c-code
++ * ix86 inline assembly
++ * Spar nommu
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * computes the checksum of the TCP/UDP pseudo-header
++ * returns a 16-bit checksum, already complemented
++ */
++
++extern inline unsigned short csum_tcpudp_magic(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++" add %0, %3, %0\n"
++" bgeu %0, %3, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %4, %0\n"
++" bgeu %0, %4, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %5, %0\n"
++" bgeu %0, %5, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++/*
++ We need the carry from the addition of 16-bit
++ significant addition, so we zap out the low bits
++ in one half, zap out the high bits in another,
++ shift them both up to the top 16-bits of a word
++ and do the carry producing addition, finally
++ shift the result back down to the low 16-bits.
++
++ Actually, we can further optimize away two shifts
++ because we know the low bits of the original
++ value will be added to zero-only bits so cannot
++ affect the addition result nor the final carry
++ bit.
++*/
++" slli %1,%0, 16\n" /* Need a copy to fold with */
++ /* Bring the LOW 16 bits up */
++" add %0, %1, %0\n" /* add and set carry, neat eh? */
++" cmpltu r15, %0, %1\n" /* get remaining carry bit */
++" srli %0, %0, 16\n" /* shift back down the result */
++" add %0, %0, r15\n"
++" nor %0, %0, %0\n" /* negate */
++ : "=&r" (sum), "=&r" (saddr)
++ : "0" (sum), "1" (saddr), "r" (ntohl(len+proto)), "r" (daddr)
++ : "r15");
++ return ((unsigned short) sum);
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++ extern inline unsigned short from32to16(unsigned long x)
++ {
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r15, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r15\n"
++ : "=r" (x)
++ : "r" (x << 16), "0" (x)
++ : "r15");
++ return x;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern inline unsigned long do_csum(const unsigned char * buff, int len)
++{
++ int odd, count;
++ unsigned long result = 0;
++
++ barrier();
++ if (len <= 0)
++ goto out;
++ odd = 1 & (unsigned long) buff;
++ if (odd) {
++////result = *buff; // dgt: Big endian
++ result = *buff << 8; // dgt: Little endian
++
++ len--;
++ buff++;
++ }
++ count = len >> 1; /* nr of 16-bit words.. */
++ if (count) {
++ if (2 & (unsigned long) buff) {
++ result += *(unsigned short *) buff;
++ count--;
++ len -= 2;
++ buff += 2;
++ }
++ count >>= 1; /* nr of 32-bit words.. */
++ if (count) {
++ unsigned long carry = 0;
++ do {
++ unsigned long w = *(unsigned long *) buff;
++ count--;
++ buff += 4;
++ result += carry;
++ result += w;
++ carry = (w > result);
++ } while (count);
++ result += carry;
++ result = (result & 0xffff) + (result >> 16);
++ }
++ if (len & 2) {
++ result += *(unsigned short *) buff;
++ buff += 2;
++ }
++ }
++ if (len & 1)
++ result += *buff; /* This is little machine, byte is right */
++ result = from32to16(result);
++ if (odd)
++ result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
++out:
++ return result;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/* ihl is always 5 or greater, almost always is 5, iph is always word
++ * aligned but can fail to be dword aligned very often.
++ */
++
++ extern inline unsigned short ip_fast_csum(const unsigned char *iph, unsigned int ihl)
++ {
++ unsigned int sum;
++
++ barrier();
++ __asm__ __volatile__(
++" andi r8, %1, 2\n" /* Remember original alignment */
++" ldw %0, (%1)\n" /* 16 or 32 bit boundary */
++" beq r8, r0, 1f\n" /* Aligned on 32 bit boundary, go */
++" srli %0, %0, 16\n" /* Get correct 16 bits */
++" addi %2, %2, -1\n" /* Take off for 4 bytes, pickup last 2 at end */
++" addi %1, %1, 2\n" /* Adjust pointer to 32 bit boundary */
++" br 2f\n"
++"1:\n"
++" addi %2, %2, -1\n"
++" addi %1, %1, 4\n" /* Bump ptr a long word */
++"2:\n"
++" ldw r9, (%1)\n"
++"1:\n"
++" add %0, r9, %0\n"
++" bgeu %0, r9, 2f\n"
++" addi %0, %0, 1\n"
++"2:\n"
++" addi %1, %1, 4\n"
++" addi %2, %2, -1\n"
++" ldw r9, (%1)\n"
++" bne %2, r0, 1b\n"
++" beq r8, r0, 1f\n" /* 32 bit boundary time to leave */
++" srli r9, r9, 16\n" /* 16 bit boundary, get correct 16 bits */
++" add %0, r9, %0\n"
++" bgeu %0, r9, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++" slli %2, %0, 16\n"
++" add %0, %2, %0\n"
++" cmpltu r8, %0, %2\n"
++" srli %0, %0, 16\n"
++" add %0, %0, r8\n"
++" nor %0, %0, %0\n"
++ : "=&r" (sum), "=&r" (iph), "=&r" (ihl)
++ : "1" (iph), "2" (ihl)
++ : "r8", "r9");
++ return sum;
++ barrier();
++ }
++
++/*these 2 functions are now in checksum.c */
++unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
++unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * the same as csum_partial_copy, but copies from user space.
++ *
++ * here even more important to align src and dst on a 32-bit (or even
++ * better 64-bit) boundary
++ */
++extern inline unsigned int
++csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err)
++{
++ barrier();
++ if (csum_err) *csum_err = 0;
++ memcpy(dst, src, len);
++ return csum_partial(dst, len, sum);
++ barrier();
++}
++
++#define csum_partial_copy_nocheck(src, dst, len, sum) \
++ csum_partial_copy ((src), (dst), (len), (sum))
++
++
++/*
++ * this routine is used for miscellaneous IP-like checksums, mainly
++ * in icmp.c
++ */
++
++extern inline unsigned short ip_compute_csum(unsigned char * buff, int len)
++{
++ barrier();
++ return ~from32to16(do_csum(buff,len));
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++#define csum_partial_copy_fromuser(s, d, l, w) \
++ csum_partial_copy((char *) (s), (d), (l), (w))
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/*
++ * Fold a partial checksum without adding pseudo headers
++ */
++extern __inline__ unsigned int csum_fold(unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r8\n"
++ "nor %0, %0, %0\n"
++ : "=r" (sum)
++ : "r" (sum << 16), "0" (sum)
++ : "r8");
++ return sum;
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %2, %0\n"
++ "cmpltu r8, %0, %2\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %3, %0\n"
++ "cmpltu r8, %0, %3\n"
++ "add %0, %0, r8\n" /* add carry */
++ : "=r" (sum), "=r" (saddr)
++ : "r" (daddr), "r" ( (ntohs(len)<<16) + (proto*256) ),
++ "0" (sum),
++ "1" (saddr)
++ : "r8");
++
++ return sum;
++ barrier();
++}
++
++
++#endif /* (__NIOS2_CHECKSUM_H) */
+--- linux/include/asm-nios2nommu/cprefix.h
++++ linux/include/asm-nios2nommu/cprefix.h
+@@ -0,0 +1,38 @@
++/* cprefix.h: This file is included by assembly source which needs
++ * to know what the c-label prefixes are. The newer versions
++ * of cpp that come with gcc predefine such things to help
++ * us out. The reason this stuff is needed is to make
++ * solaris compiles of the kernel work.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_CPREFIX_H
++#define __NIOS2_CPREFIX_H
++
++#define C_LABEL_PREFIX
++
++#define CONCAT(a, b) CONCAT2(a, b)
++#define CONCAT2(a, b) a##b
++
++#define C_LABEL(name) CONCAT(C_LABEL_PREFIX, name)
++
++#endif /* !(__NIOS2_CPREFIX_H) */
+--- linux/include/asm-nios2nommu/cpumask.h
++++ linux/include/asm-nios2nommu/cpumask.h
+@@ -0,0 +1,28 @@
++/*
++ * All rights reserved.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_CPUMASK_H
++#define _ASM_NIOS2NOMMU_CPUMASK_H
++
++#include <asm-generic/cpumask.h>
++
++#endif /* _ASM_NIOS2NOMMU_CPUMASK_H */
+--- linux/include/asm-nios2nommu/cputime.h
++++ linux/include/asm-nios2nommu/cputime.h
+@@ -0,0 +1,31 @@
++/*
++ * cputime.h
++ * (C) Copyright 2004, Microtronix Datacom Ltd.
++ *
++ * Taken from m68knommu
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_CPUTIME_H
++#define __NIOS2NOMMU_CPUTIME_H
++
++#include <asm-generic/cputime.h>
++
++#endif /* __NIOS@NOMMU_CPUTIME_H */
+--- linux/include/asm-nios2nommu/current.h
++++ linux/include/asm-nios2nommu/current.h
+@@ -0,0 +1,39 @@
++#ifndef _NIOS2NOMMU_CURRENT_H
++#define _NIOS2NOMMU_CURRENT_H
++/*
++ * current.h
++ * (C) Copyright 2000, Lineo, David McCullough <davidm@uclinux.org>
++ * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
++ * (C) Copyright 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/thread_info.h>
++
++struct task_struct;
++
++static inline struct task_struct *get_current(void)
++{
++ return(current_thread_info()->task);
++}
++
++#define current get_current()
++
++#endif /* _NIOS2NOMMU_CURRENT_H */
+--- linux/include/asm-nios2nommu/delay.h
++++ linux/include/asm-nios2nommu/delay.h
+@@ -0,0 +1,96 @@
++#ifndef _NIOS_DELAY_H
++#define _NIOS_DELAY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/delay.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/param.h>
++
++extern __inline__ void __delay(unsigned long loops)
++{
++ int dummy;
++
++ __asm__ __volatile__(
++ "1: \n\t"
++ " beq %0,zero,2f\n\t"
++ " addi %0, %0, -1\n\t"
++ " br 1b\n\t"
++ "2: \n\t"
++
++ : "=r" (dummy) /* Need output for optimizer */
++
++ : "0" (loops) /* %0 Input */
++ );
++}
++
++/*
++ * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
++ * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
++ *
++ * The mul instruction gives us loops = (a * b) / 2^32.
++ * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
++ * because this lets us support a wide range of HZ and
++ * loops_per_jiffy values without either a or b overflowing 2^32.
++ * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
++ * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
++ * (which corresponds to ~3800 bogomips at HZ = 100).
++ * -- paulus
++ */
++#define __MAX_UDELAY (226050910UL/HZ) /* maximum udelay argument */
++#define __MAX_NDELAY (4294967295UL/HZ) /* maximum ndelay argument */
++
++extern unsigned long loops_per_jiffy;
++
++extern __inline__ void __udelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 226));
++ __delay(loops);
++}
++
++extern __inline__ void __ndelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 5));
++ __delay(loops);
++}
++
++extern void __bad_udelay(void); /* deliberately undefined */
++extern void __bad_ndelay(void); /* deliberately undefined */
++
++#define udelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
++ __udelay((n) * (19 * HZ)))
++
++#define ndelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
++ __ndelay((n) * HZ))
++
++#define muldiv(a, b, c) (((a)*(b))/(c))
++
++#endif /* defined(_NIOS_DELAY_H) */
+--- linux/include/asm-nios2nommu/div64.h
++++ linux/include/asm-nios2nommu/div64.h
+@@ -0,0 +1,31 @@
++#ifndef __ASMNIOS_DIV64_H
++#define __ASMNIOS_DIV64_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/div64.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/div64.h>
++
++#endif
++
+--- linux/include/asm-nios2nommu/dma.h
++++ linux/include/asm-nios2nommu/dma.h
+@@ -0,0 +1,57 @@
++/* $Id: dma.h,v 1.6 2005/04/07 21:00:26 wentao Exp $
++ *
++ * Copyright 2004 (C) Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2_DMA_H
++#define _ASM_NIOS2_DMA_H
++
++#include <linux/kernel.h>
++#include <asm/asm-offsets.h>
++
++#define MAX_DMA_ADDRESS (LINUX_SDRAM_END)
++
++int request_dma(unsigned int, const char *);
++void free_dma(unsigned int);
++void enable_dma(unsigned int dmanr);
++void disable_dma(unsigned int dmanr);
++void set_dma_count(unsigned int dmanr, unsigned int count);
++int get_dma_residue(unsigned int dmanr);
++void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width);
++
++void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user);
++int nios2_request_dma(const char *);
++
++void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode);
++void nios2_set_dma_rcon(unsigned int dmanr, unsigned int set);
++void nios2_set_dma_wcon(unsigned int dmanr, unsigned int set);
++void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a);
++void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a);
++
++static inline unsigned long claim_dma_lock(void)
++{
++}
++
++static inline void release_dma_lock(unsigned long flags)
++{
++}
++
++#endif /* !(_ASM_NIOS2_DMA_H) */
+--- linux/include/asm-nios2nommu/dma-mapping.h
++++ linux/include/asm-nios2nommu/dma-mapping.h
+@@ -0,0 +1,133 @@
++/*
++ * include/asm-nios2nommu/dma-mapping.h
++ *
++ * This file exists so that #include <dma-mapping.h> doesn't break anything.
++ */
++
++#ifndef _ASM_DMA_MAPPING_H
++#define _ASM_DMA_MAPPING_H
++
++#include <asm/scatterlist.h>
++#include <linux/mm.h>
++#include <asm/io.h>
++#include <asm/cacheflush.h>
++
++static inline void *dma_alloc_coherent(struct device *dev, size_t size,
++ dma_addr_t *dma_handle, int flag)
++{
++ BUG();
++ return 0;
++}
++
++static inline void dma_free_coherent(struct device *dev, size_t size,
++ void *vaddr, dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++/**
++ * dma_map_single - map a single buffer for streaming DMA
++ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
++ * @cpu_addr: CPU direct mapped address of buffer
++ * @size: size of buffer to map
++ * @dir: DMA transfer direction
++ *
++ * Ensure that any data held in the cache is appropriately discarded
++ * or written back.
++ *
++ * The device owns this memory once this call has completed. The CPU
++ * can regain ownership by calling dma_unmap_single() or
++ * dma_sync_single_for_cpu().
++ */
++static inline dma_addr_t
++dma_map_single(struct device *dev, void *cpu_addr, size_t size,
++ enum dma_data_direction dir)
++{
++ cache_push ((unsigned long)cpu_addr, size);
++ return virt_to_bus((unsigned long)cpu_addr);
++}
++
++/**
++ * dma_unmap_single - unmap a single buffer previously mapped
++ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
++ * @handle: DMA address of buffer
++ * @size: size of buffer to map
++ * @dir: DMA transfer direction
++ *
++ * Unmap a single streaming mode DMA translation. The handle and size
++ * must match what was provided in the previous dma_map_single() call.
++ * All other usages are undefined.
++ *
++ * After this call, reads by the CPU to the buffer are guaranteed to see
++ * whatever the device wrote there.
++ */
++static inline void
++dma_unmap_single(struct device *dev, dma_addr_t handle, size_t size,
++ enum dma_data_direction dir)
++{
++ cache_clear((unsigned long)bus_to_virt(handle), size);
++}
++
++/**
++ * dma_map_sg - map a set of SG buffers for streaming mode DMA
++ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
++ * @sg: list of buffers
++ * @nents: number of buffers to map
++ * @dir: DMA transfer direction
++ *
++ * Map a set of buffers described by scatterlist in streaming
++ * mode for DMA. This is the scatter-gather version of the
++ * above dma_map_single interface. Here the scatter gather list
++ * elements are each tagged with the appropriate dma address
++ * and length. They are obtained via sg_dma_{address,length}(SG).
++ *
++ * NOTE: An implementation may be able to use a smaller number of
++ * DMA address/length pairs than there are SG table elements.
++ * (for example via virtual mapping capabilities)
++ * The routine returns the number of addr/length pairs actually
++ * used, at most nents.
++ *
++ * Device ownership issues as mentioned above for dma_map_single are
++ * the same here.
++ */
++static inline int
++dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction dir)
++{
++ int i;
++
++ for (i = 0; i < nents; i++, sg++) {
++ char *virt;
++
++ sg->dma_address = page_to_bus(sg->page) + sg->offset;
++ virt = page_address(sg->page) + sg->offset;
++ cache_push ((unsigned long)virt, sg->length);
++ }
++
++ return nents;
++}
++
++/**
++ * dma_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
++ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
++ * @sg: list of buffers
++ * @nents: number of buffers to map
++ * @dir: DMA transfer direction
++ *
++ * Unmap a set of streaming mode DMA translations.
++ * Again, CPU read rules concerning calls here are the same as for
++ * dma_unmap_single() above.
++ */
++static inline void
++dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction dir)
++{
++ int i;
++
++ for (i = 0; i < nents; i++, sg++) {
++ char *virt;
++ virt = page_address(sg->page) + sg->offset;
++ cache_clear ((unsigned long)virt, sg->length);
++ }
++}
++#endif /* _ASM_DMA_MAPPING_H */
+--- linux/include/asm-nios2nommu/elf.h
++++ linux/include/asm-nios2nommu/elf.h
+@@ -0,0 +1,141 @@
++#ifndef __NIOS2_ELF_H
++#define __NIOS2_ELF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/elf.h
++ *
++ * Nio2 ELF relocation types
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ * Mar/18/2004 xwt NiosII relocation types added
++ *
++ ---------------------------------------------------------------------*/
++
++// #include <linux/config.h>
++#include <asm/ptrace.h>
++#include <asm/user.h>
++
++#define R_NIOS2_NONE 0
++#define R_NIOS2_S16 1
++#define R_NIOS2_U16 2
++#define R_NIOS2_PCREL16 3
++#define R_NIOS2_CALL26 4
++#define R_NIOS2_IMM5 5
++#define R_NIOS2_CACHE_OPX 6
++#define R_NIOS2_IMM6 7
++#define R_NIOS2_IMM8 8
++#define R_NIOS2_HI16 9
++#define R_NIOS2_LO16 10
++#define R_NIOS2_HIADJ16 11
++#define R_NIOS2_BFD_RELOC_32 12
++#define R_NIOS2_BFD_RELOC_16 13
++#define R_NIOS2_BFD_RELOC_8 14
++#define R_NIOS2_GPREL 15
++#define R_NIOS2_GNU_VTINHERIT 16
++#define R_NIOS2_GNU_VTENTRY 17
++#define R_NIOS2_UJMP 18
++#define R_NIOS2_CJMP 19
++#define R_NIOS2_CALLR 20
++#define R_NIOS2_ALIGN 21
++/* Keep this the last entry. */
++#define R_NIOS2_NUM 22
++
++typedef unsigned long elf_greg_t;
++
++#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
++typedef elf_greg_t elf_gregset_t[ELF_NGREG];
++
++typedef unsigned long elf_fpregset_t;
++
++/*
++ * This is used to ensure we don't load something for the wrong architecture.
++ */
++#define elf_check_arch(x) \
++ ((x)->e_machine == EM_ALTERA_NIOS2)
++
++/*
++ * These are used to set parameters in the core dumps.
++ */
++#define ELF_CLASS ELFCLASS32
++#define ELF_DATA ELFDATA2LSB
++#define ELF_ARCH EM_ALTERA_NIOS2
++
++#define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0
++
++#define USE_ELF_CORE_DUMP
++#define ELF_EXEC_PAGESIZE 4096
++
++/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
++ use of this is to invoke "./ld.so someprog" to test out a new version of
++ the loader. We need to make sure that it is out of the way of the program
++ that it will "exec", and that there is sufficient room for the brk. */
++
++#define ELF_ET_DYN_BASE 0xD0000000UL
++
++/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
++ now struct_user_regs, they are different) */
++
++#define ELF_CORE_COPY_REGS(pr_reg, regs) \
++ /* Bleech. */ \
++ pr_reg[0] = regs->r1; \
++ pr_reg[1] = regs->r2; \
++ pr_reg[2] = regs->r3; \
++ pr_reg[3] = regs->r4; \
++ pr_reg[4] = regs->r5; \
++ pr_reg[5] = regs->r6; \
++ pr_reg[6] = regs->r7; \
++ pr_reg[7] = regs->r8; \
++ pr_reg[8] = regs->r9; \
++ pr_reg[9] = regs->r10; \
++ pr_reg[10] = regs->r11; \
++ pr_reg[11] = regs->r12; \
++ pr_reg[12] = regs->r13; \
++ pr_reg[13] = regs->r14; \
++ pr_reg[14] = regs->r15; \
++ pr_reg[23] = regs->sp; \
++ pr_reg[26] = regs->estatus; \
++ { \
++ struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
++ pr_reg[15] = sw->r16; \
++ pr_reg[16] = sw->r17; \
++ pr_reg[17] = sw->r18; \
++ pr_reg[18] = sw->r19; \
++ pr_reg[19] = sw->r20; \
++ pr_reg[20] = sw->r21; \
++ pr_reg[21] = sw->r22; \
++ pr_reg[22] = sw->r23; \
++ pr_reg[24] = sw->fp; \
++ pr_reg[25] = sw->gp; \
++ }
++
++/* This yields a mask that user programs can use to figure out what
++ instruction set this cpu supports. */
++
++#define ELF_HWCAP (0)
++
++/* This yields a string that ld.so will use to load implementation
++ specific libraries for optimization. This is more specific in
++ intent than poking at uname or /proc/cpuinfo. */
++
++#define ELF_PLATFORM (NULL)
++
++#ifdef __KERNEL__
++#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
++#endif
++
++#endif
+--- linux/include/asm-nios2nommu/entry.h
++++ linux/include/asm-nios2nommu/entry.h
+@@ -0,0 +1,188 @@
++/*
++ * Hacked from m68knommu port.
++ *
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_ENTRY_H
++#define __NIOS2NOMMU_ENTRY_H
++
++#ifdef __ASSEMBLY__
++
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/asm-offsets.h>
++
++/*
++ * Stack layout in 'ret_from_exception':
++ *
++ * This allows access to the syscall arguments in registers r4-r8
++ *
++ * 0(sp) - r8
++ * 4(sp) - r9
++ * 8(sp) - r10
++ * C(sp) - r11
++ * 10(sp) - r12
++ * 14(sp) - r13
++ * 18(sp) - r14
++ * 1C(sp) - r15
++ * 20(sp) - r1
++ * 24(sp) - r2
++ * 28(sp) - r3
++ * 2C(sp) - r4
++ * 30(sp) - r5
++ * 34(sp) - r6
++ * 38(sp) - r7
++ * 3C(sp) - orig_r2
++ * 40(sp) - ra
++ * 44(sp) - fp
++ * 48(sp) - sp
++ * 4C(sp) - gp
++ * 50(sp) - estatus
++ * 54(sp) - status_extension
++ * 58(sp) - ea
++ *
++ */
++
++/* process bits for task_struct.flags */
++PF_TRACESYS_OFF = 3
++PF_TRACESYS_BIT = 5
++PF_PTRACED_OFF = 3
++PF_PTRACED_BIT = 4
++PF_DTRACE_OFF = 1
++PF_DTRACE_BIT = 5
++
++LENOSYS = 38
++
++/*
++ * This defines the normal kernel pt-regs layout.
++ *
++ */
++
++/*
++ * Standard Nios2 interrupt entry and exit macros.
++ * Must be called with interrupts disabled.
++ */
++.macro SAVE_ALL
++ movia r24,status_extension // Read status extension
++ ldw r24,0(r24)
++ andi r24,r24,PS_S_ASM
++ bne r24,r0,1f // In supervisor mode, already on kernel stack
++ movia r24,_current_thread // Switch to current kernel stack
++ ldw r24,0(r24) // using the thread_info
++ addi r24,r24,THREAD_SIZE_ASM-PT_REGS_SIZE
++ stw sp,PT_SP(r24) // Save user stack before changing
++ mov sp,r24
++ br 2f
++
++1: mov r24,sp
++ addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
++ stw r24,PT_SP(sp)
++2: stw r1,PT_R1(sp)
++ stw r2,PT_R2(sp)
++ stw r3,PT_R3(sp)
++ stw r4,PT_R4(sp)
++ stw r5,PT_R5(sp)
++ stw r6,PT_R6(sp)
++ stw r7,PT_R7(sp)
++ stw r8,PT_R8(sp)
++ stw r9,PT_R9(sp)
++ stw r10,PT_R10(sp)
++ stw r11,PT_R11(sp)
++ stw r12,PT_R12(sp)
++ stw r13,PT_R13(sp)
++ stw r14,PT_R14(sp)
++ stw r15,PT_R15(sp)
++ stw r2,PT_ORIG_R2(sp)
++ stw ra,PT_RA(sp)
++ stw fp,PT_FP(sp)
++ stw gp,PT_GP(sp)
++ rdctl r24,estatus
++ stw r24,PT_ESTATUS(sp)
++ movia r24,status_extension // Read status extension
++ ldw r1,0(r24)
++ stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
++ ORI32 r1,r1,PS_S_ASM // Set supervisor mode
++ stw r1,0(r24)
++ stw ea,PT_EA(sp)
++.endm
++
++.macro RESTORE_ALL
++ ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
++ movia r24,status_extension
++ stw r1,0(r24)
++ ldw r1,PT_R1(sp) // Restore registers
++ ldw r2,PT_R2(sp)
++ ldw r3,PT_R3(sp)
++ ldw r4,PT_R4(sp)
++ ldw r5,PT_R5(sp)
++ ldw r6,PT_R6(sp)
++ ldw r7,PT_R7(sp)
++ ldw r8,PT_R8(sp)
++ ldw r9,PT_R9(sp)
++ ldw r10,PT_R10(sp)
++ ldw r11,PT_R11(sp)
++ ldw r12,PT_R12(sp)
++ ldw r13,PT_R13(sp)
++ ldw r14,PT_R14(sp)
++ ldw r15,PT_R15(sp)
++ ldw ra,PT_RA(sp)
++ ldw fp,PT_FP(sp)
++ ldw gp,PT_GP(sp)
++ ldw r24,PT_ESTATUS(sp)
++ wrctl estatus,r24
++ ldw ea,PT_EA(sp)
++ ldw sp,PT_SP(sp) // Restore sp last
++.endm
++
++.macro SAVE_SWITCH_STACK
++ addi sp,sp,-SWITCH_STACK_SIZE
++ stw r16,SW_R16(sp)
++ stw r17,SW_R17(sp)
++ stw r18,SW_R18(sp)
++ stw r19,SW_R19(sp)
++ stw r20,SW_R20(sp)
++ stw r21,SW_R21(sp)
++ stw r22,SW_R22(sp)
++ stw r23,SW_R23(sp)
++ stw fp,SW_FP(sp)
++ stw gp,SW_GP(sp)
++ stw ra,SW_RA(sp)
++.endm
++
++.macro RESTORE_SWITCH_STACK
++ ldw r16,SW_R16(sp)
++ ldw r17,SW_R17(sp)
++ ldw r18,SW_R18(sp)
++ ldw r19,SW_R19(sp)
++ ldw r20,SW_R20(sp)
++ ldw r21,SW_R21(sp)
++ ldw r22,SW_R22(sp)
++ ldw r23,SW_R23(sp)
++ ldw fp,SW_FP(sp)
++ ldw gp,SW_GP(sp)
++ ldw ra,SW_RA(sp)
++ addi sp,sp,SWITCH_STACK_SIZE
++.endm
++
++#endif /* __ASSEMBLY__ */
++#endif /* __NIOS2NOMMU_ENTRY_H */
+--- linux/include/asm-nios2nommu/errno.h
++++ linux/include/asm-nios2nommu/errno.h
+@@ -0,0 +1,6 @@
++#ifndef _NIOS2NOMMU_ERRNO_H
++#define _NIOS2NOMMU_ERRNO_H
++
++#include <asm-generic/errno.h>
++
++#endif /* _NIOS2NOMMU_ERRNO_H */
+--- linux/include/asm-nios2nommu/fcntl.h
++++ linux/include/asm-nios2nommu/fcntl.h
+@@ -0,0 +1,110 @@
++/*
++ * This file came from the m68k port.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_FCNTL_H
++#define _NIOS2_FCNTL_H
++
++/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
++ located on an ext2 file system */
++#define O_ACCMODE 0003
++#define O_RDONLY 00
++#define O_WRONLY 01
++#define O_RDWR 02
++#define O_CREAT 0100 /* not fcntl */
++#define O_EXCL 0200 /* not fcntl */
++#define O_NOCTTY 0400 /* not fcntl */
++#define O_TRUNC 01000 /* not fcntl */
++#define O_APPEND 02000
++#define O_NONBLOCK 04000
++#define O_NDELAY O_NONBLOCK
++#define O_SYNC 010000
++#define FASYNC 020000 /* fcntl, for BSD compatibility */
++#define O_DIRECTORY 040000 /* must be a directory */
++#define O_NOFOLLOW 0100000 /* don't follow links */
++#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
++#define O_LARGEFILE 0400000
++#define O_NOATIME 01000000
++
++#define F_DUPFD 0 /* dup */
++#define F_GETFD 1 /* get close_on_exec */
++#define F_SETFD 2 /* set/clear close_on_exec */
++#define F_GETFL 3 /* get file->f_flags */
++#define F_SETFL 4 /* set file->f_flags */
++#define F_GETLK 5
++#define F_SETLK 6
++#define F_SETLKW 7
++
++#define F_SETOWN 8 /* for sockets. */
++#define F_GETOWN 9 /* for sockets. */
++#define F_SETSIG 10 /* for sockets. */
++#define F_GETSIG 11 /* for sockets. */
++
++#define F_GETLK64 12 /* using 'struct flock64' */
++#define F_SETLK64 13
++#define F_SETLKW64 14
++
++/* for F_[GET|SET]FL */
++#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
++
++/* for posix fcntl() and lockf() */
++#define F_RDLCK 0
++#define F_WRLCK 1
++#define F_UNLCK 2
++
++/* for old implementation of bsd flock () */
++#define F_EXLCK 4 /* or 3 */
++#define F_SHLCK 8 /* or 4 */
++
++/* for leases */
++#define F_INPROGRESS 16
++
++/* operations for bsd flock(), also used by the kernel implementation */
++#define LOCK_SH 1 /* shared lock */
++#define LOCK_EX 2 /* exclusive lock */
++#define LOCK_NB 4 /* or'd with one of the above to prevent
++ blocking */
++#define LOCK_UN 8 /* remove lock */
++
++#define LOCK_MAND 32 /* This is a mandatory flock */
++#define LOCK_READ 64 /* ... Which allows concurrent read operations */
++#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
++#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
++
++struct flock {
++ short l_type;
++ short l_whence;
++ off_t l_start;
++ off_t l_len;
++ pid_t l_pid;
++};
++
++struct flock64 {
++ short l_type;
++ short l_whence;
++ loff_t l_start;
++ loff_t l_len;
++ pid_t l_pid;
++};
++
++#define F_LINUX_SPECIFIC_BASE 1024
++#endif /* _NIOS2_FCNTL_H */
+--- linux/include/asm-nios2nommu/flat.h
++++ linux/include/asm-nios2nommu/flat.h
+@@ -0,0 +1,126 @@
++/*
++ * include/asm-nios2nommu/flat.h -- uClinux bFLT relocations
++ *
++ * Copyright (C) 2004,05 Microtronix Datacom Ltd
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License. See the file COPYING in the main directory of this
++ * archive for more details.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#ifndef __NIOS2_FLAT_H__
++#define __NIOS2_FLAT_H__
++
++#define flat_reloc_valid(reloc, size) ((reloc) <= (size + 0x8000))
++
++/* The stack is 64-bit aligned for Nios II, so (sp - 1) shall
++ * be 64-bit aligned, where -1 is for argc
++ */
++#define flat_stack_align(sp) (sp = (unsigned long *)(((unsigned long)sp - 1) & (-8)))
++
++/* The uClibc port for Nios II expects the argc is followed by argv and envp */
++#define flat_argvp_envp_on_stack() 1
++
++#define flat_old_ram_flag(flags) (flags)
++
++/* We store the type of relocation in the top 4 bits of the `relval.' */
++
++/* Convert a relocation entry into an address. */
++static inline unsigned long
++flat_get_relocate_addr (unsigned long relval)
++{
++ return relval & 0x0fffffff; /* Mask out top 4-bits */
++}
++
++#define FLAT_NIOS2_RELOC_TYPE(relval) ((relval) >> 28)
++
++#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
++#define FLAT_NIOS2_R_HI_LO 1 /* High 16-bits + low 16-bits field */
++#define FLAT_NIOS2_R_HIADJ_LO 2 /* High 16-bits adjust + low 16-bits field */
++#define FLAT_NIOS2_R_CALL26 4 /* Call imm26 */
++
++/* Extract the address to be relocated from the symbol reference at rp;
++ * relval is the raw relocation-table entry from which RP is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
++ unsigned long relval,
++ unsigned long flags)
++{
++ switch (FLAT_NIOS2_RELOC_TYPE(relval))
++ {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. The loader expect it in bigger endian */
++ return htonl(*rp);
++
++ case FLAT_NIOS2_R_HI_LO:
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ return htonl ((((rp[0] >> 6) & 0xFFFF) << 16 ) |
++ ((rp[1] >> 6) & 0xFFFF));
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ unsigned int low, high;
++ high = (rp[0] >> 6) & 0xFFFF;
++ low = (rp[1] >> 6) & 0xFFFF;
++
++ if ((low >> 15) & 1) high--;
++
++ return htonl ((high << 16 ) | low );
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the 26-bit immediate value is actually 28-bit */
++ return htonl(((*rp) >> 6) << 2);
++
++ default:
++ return ~0; /* bogus value */
++ }
++}
++
++/* Insert the address addr into the symbol reference at rp;
++ * relval is the raw relocation-table entry from which rp is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline void flat_put_addr_at_rp (unsigned long *rp, unsigned long addr,
++ unsigned long relval)
++{
++ unsigned long exist_val;
++ switch (FLAT_NIOS2_RELOC_TYPE (relval)) {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. */
++ *rp = addr;
++ break;
++
++ case FLAT_NIOS2_R_HI_LO:
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | (addr >> 16)) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ unsigned int high = (addr >> 16);
++ if ((addr >> 15) & 1)
++ high = (high + 1) & 0xFFFF;
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | high) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the opcode of CALL is 0, so just store the value */
++ *rp = ((addr >> 2) << 6);
++ break;
++ }
++}
++
++#endif /* __NIOS2_FLAT_H__ */
+--- linux/include/asm-nios2nommu/hardirq.h
++++ linux/include/asm-nios2nommu/hardirq.h
+@@ -0,0 +1,53 @@
++/*
++ * Ported from m68knommu
++ *
++ * Copyright (C) 2003, Microtronix Datacom Ltd.
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_HARDIRQ_H
++#define __NIOS2_HARDIRQ_H
++
++// #include <linux/config.h>
++#include <linux/cache.h>
++#include <linux/threads.h>
++
++typedef struct {
++ unsigned int __softirq_pending;
++} ____cacheline_aligned irq_cpustat_t;
++
++#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
++
++#define HARDIRQ_BITS 8
++
++/*
++ * The hardirq mask has to be large enough to have
++ * space for potentially all IRQ sources in the system
++ * nesting on a single CPU:
++ */
++#if (1 << HARDIRQ_BITS) < NR_IRQS
++# error HARDIRQ_BITS is too low!
++#endif
++
++#ifdef CONFIG_SMP
++# error nios2nommu SMP is not available
++#endif /* CONFIG_SMP */
++
++#endif /* __NIOS2_HARDIRQ_H */
+--- linux/include/asm-nios2nommu/hdreg.h
++++ linux/include/asm-nios2nommu/hdreg.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2002 Wentau Xu (www.microtronix.com)
++ * copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_HDREG_H
++#define __NIOS2_HDREG_H
++
++typedef unsigned long ide_ioreg_t;
++
++#endif /* __NIOS2_HDREG_H */
+--- linux/include/asm-nios2nommu/hw_irq.h
++++ linux/include/asm-nios2nommu/hw_irq.h
+@@ -0,0 +1,16 @@
++#ifndef _ASM_HW_IRQ_H
++#define _ASM_HW_IRQ_H
++
++/*
++ * linux/include/asm/hw_irq.h
++ *
++ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
++ *
++ * moved some of the old arch/i386/kernel/irq.h to here. VY
++ *
++ * IRQ/IPI changes taken from work by Thomas Radke
++ * <tomsoft@informatik.tu-chemnitz.de>
++ */
++
++
++#endif /* _ASM_HW_IRQ_H */
+--- linux/include/asm-nios2nommu/ide.h
++++ linux/include/asm-nios2nommu/ide.h
+@@ -0,0 +1,47 @@
++/*
++ * linux/include/asm-niosnommu2/ide.h
++ *
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASMNIOS2_IDE_H
++#define __ASMNIOS2_IDE_H
++
++#ifdef __KERNEL__
++#undef MAX_HWIFS /* we're going to force it */
++
++#ifndef MAX_HWIFS
++#define MAX_HWIFS 1
++#endif
++
++#define IDE_ARCH_OBSOLETE_INIT
++#define IDE_ARCH_OBSOLETE_DEFAULTS
++#define ide_default_io_base(i) ((unsigned long)na_ide_ide)
++#define ide_default_irq(b) (na_ide_ide_irq)
++#define ide_init_default_irq(base) ide_default_irq(base)
++#define ide_default_io_ctl(base) ((base) + (0xE*4))
++
++#include <asm-generic/ide_iops.h>
++
++#endif /* __KERNEL__ */
++
++#endif /* __ASMNIOS2_IDE_H */
+--- linux/include/asm-nios2nommu/init.h
++++ linux/include/asm-nios2nommu/init.h
+@@ -0,0 +1,22 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+--- linux/include/asm-nios2nommu/ioctl.h
++++ linux/include/asm-nios2nommu/ioctl.h
+@@ -0,0 +1,100 @@
++/* $Id: ioctl.h,v 1.3 2004/02/12 23:06:40 ken-h Exp $
++ *
++ * linux/ioctl.h for Linux by H.H. Bergman.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_IOCTL_H
++#define _NIOS2_IOCTL_H
++
++/* ioctl command encoding: 32 bits total, command in lower 16 bits,
++ * size of the parameter structure in the lower 14 bits of the
++ * upper 16 bits.
++ * Encoding the size of the parameter structure in the ioctl request
++ * is useful for catching programs compiled with old versions
++ * and to avoid overwriting user space outside the user buffer area.
++ * The highest 2 bits are reserved for indicating the ``access mode''.
++ * NOTE: This limits the max parameter size to 16kB -1 !
++ */
++
++/*
++ * I don't really have any idea about what this should look like, so
++ * for the time being, this is heavily based on the PC definitions.
++ */
++
++/*
++ * The following is for compatibility across the various Linux
++ * platforms. The i386 ioctl numbering scheme doesn't really enforce
++ * a type field. De facto, however, the top 8 bits of the lower 16
++ * bits are indeed used as a type field, so we might just as well make
++ * this explicit here. Please be sure to use the decoding macros
++ * below from now on.
++ */
++#define _IOC_NRBITS 8
++#define _IOC_TYPEBITS 8
++#define _IOC_SIZEBITS 14
++#define _IOC_DIRBITS 2
++
++#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
++#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
++#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
++#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
++
++#define _IOC_NRSHIFT 0
++#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
++#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
++#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
++
++/*
++ * Direction bits.
++ */
++#define _IOC_NONE 0U
++#define _IOC_WRITE 1U
++#define _IOC_READ 2U
++
++#define _IOC(dir,type,nr,size) \
++ (((dir) << _IOC_DIRSHIFT) | \
++ ((type) << _IOC_TYPESHIFT) | \
++ ((nr) << _IOC_NRSHIFT) | \
++ ((size) << _IOC_SIZESHIFT))
++
++/* used to create numbers */
++#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
++#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
++#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
++#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
++
++/* used to decode ioctl numbers.. */
++#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
++#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
++#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
++#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
++
++/* ...and for the drivers/sound files... */
++
++#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
++#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
++#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
++#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
++#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
++
++#endif /* _NIOS2_IOCTL_H */
+--- linux/include/asm-nios2nommu/ioctls.h
++++ linux/include/asm-nios2nommu/ioctls.h
+@@ -0,0 +1,103 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ARCH_NIOS2_IOCTLS_H__
++#define __ARCH_NIOS2_IOCTLS_H__
++
++#include <asm/ioctl.h>
++
++/* 0x54 is just a magic number to make these relatively unique ('T') */
++
++#define TCGETS 0x5401
++#define TCSETS 0x5402
++#define TCSETSW 0x5403
++#define TCSETSF 0x5404
++#define TCGETA 0x5405
++#define TCSETA 0x5406
++#define TCSETAW 0x5407
++#define TCSETAF 0x5408
++#define TCSBRK 0x5409
++#define TCXONC 0x540A
++#define TCFLSH 0x540B
++#define TIOCEXCL 0x540C
++#define TIOCNXCL 0x540D
++#define TIOCSCTTY 0x540E
++#define TIOCGPGRP 0x540F
++#define TIOCSPGRP 0x5410
++#define TIOCOUTQ 0x5411
++#define TIOCSTI 0x5412
++#define TIOCGWINSZ 0x5413
++#define TIOCSWINSZ 0x5414
++#define TIOCMGET 0x5415
++#define TIOCMBIS 0x5416
++#define TIOCMBIC 0x5417
++#define TIOCMSET 0x5418
++#define TIOCGSOFTCAR 0x5419
++#define TIOCSSOFTCAR 0x541A
++#define FIONREAD 0x541B
++#define TIOCINQ FIONREAD
++#define TIOCLINUX 0x541C
++#define TIOCCONS 0x541D
++#define TIOCGSERIAL 0x541E
++#define TIOCSSERIAL 0x541F
++#define TIOCPKT 0x5420
++#define FIONBIO 0x5421
++#define TIOCNOTTY 0x5422
++#define TIOCSETD 0x5423
++#define TIOCGETD 0x5424
++#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
++#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
++#define TIOCSBRK 0x5427 /* BSD compatibility */
++#define TIOCCBRK 0x5428 /* BSD compatibility */
++#define TIOCGSID 0x5429 /* Return the session ID of FD */
++#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
++#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
++
++#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
++#define FIOCLEX 0x5451
++#define FIOASYNC 0x5452
++#define TIOCSERCONFIG 0x5453
++#define TIOCSERGWILD 0x5454
++#define TIOCSERSWILD 0x5455
++#define TIOCGLCKTRMIOS 0x5456
++#define TIOCSLCKTRMIOS 0x5457
++#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
++#define TIOCSERGETLSR 0x5459 /* Get line status register */
++#define TIOCSERGETMULTI 0x545A /* Get multiport config */
++#define TIOCSERSETMULTI 0x545B /* Set multiport config */
++
++#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
++#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
++#define FIOQSIZE 0x545E
++
++/* Used for packet mode */
++#define TIOCPKT_DATA 0
++#define TIOCPKT_FLUSHREAD 1
++#define TIOCPKT_FLUSHWRITE 2
++#define TIOCPKT_STOP 4
++#define TIOCPKT_START 8
++#define TIOCPKT_NOSTOP 16
++#define TIOCPKT_DOSTOP 32
++
++#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
++
++#endif /* __ARCH_NIOS2_IOCTLS_H__ */
+--- linux/include/asm-nios2nommu/io.h
++++ linux/include/asm-nios2nommu/io.h
+@@ -0,0 +1,240 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_IO_H
++#define __NIOS2_IO_H
++
++#ifdef __KERNEL__
++
++#include <linux/kernel.h>
++
++#include <asm/page.h> /* IO address mapping routines need this */
++#include <asm/system.h>
++#include <asm/unaligned.h>
++
++extern void insw(unsigned long port, void *dst, unsigned long count);
++extern void outsw(unsigned long port, void *src, unsigned long count);
++extern void insl(unsigned long port, void *dst, unsigned long count);
++extern void outsl(unsigned long port, void *src, unsigned long count);
++
++
++/*
++ * readX/writeX() are used to access memory mapped devices. On some
++ * architectures the memory mapped IO stuff needs to be accessed
++ * differently. On the Nios architecture, we just read/write the
++ * memory location directly.
++ */
++
++#define readb(addr) \
++({ \
++ unsigned char __res;\
++ __asm__ __volatile__( \
++ "ldbuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readw(addr) \
++({ \
++ unsigned short __res;\
++ __asm__ __volatile__( \
++ "ldhuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readl(addr) \
++({ \
++ unsigned int __res;\
++ __asm__ __volatile__( \
++ "ldwio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define writeb(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stbio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writew(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "sthio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writel(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stwio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define __raw_readb readb
++#define __raw_readw readw
++#define __raw_readl readl
++#define __raw_writeb writeb
++#define __raw_writew writew
++#define __raw_writel writel
++
++#define mmiowb()
++
++/*
++ * make the short names macros so specific devices
++ * can override them as required
++ */
++
++#define memset_io(addr,c,len) memset((void *)(((unsigned int)(addr)) | 0x80000000),(c),(len))
++#define memcpy_fromio(to,from,len) memcpy((to),(void *)(((unsigned int)(from)) | 0x80000000),(len))
++#define memcpy_toio(to,from,len) memcpy((void *)(((unsigned int)(to)) | 0x80000000),(from),(len))
++
++#define inb(addr) readb(addr)
++#define inw(addr) readw(addr)
++#define inl(addr) readl(addr)
++
++#define outb(x,addr) ((void) writeb(x,addr))
++#define outw(x,addr) ((void) writew(x,addr))
++#define outl(x,addr) ((void) writel(x,addr))
++
++#define inb_p(addr) inb(addr)
++#define inw_p(addr) inw(addr)
++#define inl_p(addr) inl(addr)
++
++#define outb_p(x,addr) outb(x,addr)
++#define outw_p(x,addr) outw(x,addr)
++#define outl_p(x,addr) outl(x,addr)
++
++
++
++extern inline void insb(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)dst;
++ while (count--)
++ *p++ = inb(port);
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _insw(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)dst;
++ while (count--)
++ *p++ = inw(port);
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned destination pointer */
++extern inline void _insl(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)dst;
++ while (count--)
++ *p++ = inl(port);
++}
++
++extern inline void outsb(unsigned long port, void *src, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)src;
++ while (count--)
++ outb( *p++, port );
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _outsw(unsigned long port, void *src, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)src;
++ while (count--)
++ outw( *p++, port );
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned source pointer */
++extern inline void _outsl(unsigned long port, void *src, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)src;
++ while (count--)
++ outl( *p++, port );
++}
++
++
++
++extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr,
++ int bus, int rdonly)
++{
++ return;
++}
++
++//vic - copied from m68knommu
++
++/* Values for nocacheflag and cmode */
++#define IOMAP_FULL_CACHING 0
++#define IOMAP_NOCACHE_SER 1
++#define IOMAP_NOCACHE_NONSER 2
++#define IOMAP_WRITETHROUGH 3
++
++extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
++extern void __iounmap(void *addr, unsigned long size);
++
++extern inline void *ioremap(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
++}
++extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
++}
++
++extern void iounmap(void *addr);
++
++
++#define IO_SPACE_LIMIT 0xffffffff
++
++#define dma_cache_inv(_start,_size) do { } while (0)
++#define dma_cache_wback(_start,_size) do { } while (0)
++#define dma_cache_wback_inv(_start,_size) do { } while (0)
++
++/* Pages to physical address... */
++#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
++#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#endif /* __KERNEL__ */
++
++#endif /* !(__NIOS2_IO_H) */
++
+--- linux/include/asm-nios2nommu/ipcbuf.h
++++ linux/include/asm-nios2nommu/ipcbuf.h
+@@ -0,0 +1,49 @@
++#ifndef __NIOS2_IPCBUF_H__
++#define __NIOS2_IPCBUF_H__
++
++/* Copied from asm-m68k/ipcbuf.h
++ * The user_ipc_perm structure for Nios architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 32-bit mode_t and seq
++ * - 2 miscellaneous 32-bit values
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++struct ipc64_perm
++{
++ __kernel_key_t key;
++ __kernel_uid32_t uid;
++ __kernel_gid32_t gid;
++ __kernel_uid32_t cuid;
++ __kernel_gid32_t cgid;
++ __kernel_mode_t mode;
++ unsigned short __pad1;
++ unsigned short seq;
++ unsigned short __pad2;
++ unsigned long __unused1;
++ unsigned long __unused2;
++};
++
++#endif /* __NIOS2_IPCBUF_H__ */
+--- linux/include/asm-nios2nommu/ipc.h
++++ linux/include/asm-nios2nommu/ipc.h
+@@ -0,0 +1,51 @@
++#ifndef __NIOS2_IPC_H__
++#define __NIOS2_IPC_H__
++
++/* Copied from sparc version
++ * These are used to wrap system calls on the Nios.
++ *
++ * See arch/niosnommu/kernel/sys_nios.c for ugly details..
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++struct ipc_kludge {
++ struct msgbuf *msgp;
++ long msgtyp;
++};
++
++#define SEMOP 1
++#define SEMGET 2
++#define SEMCTL 3
++#define MSGSND 11
++#define MSGRCV 12
++#define MSGGET 13
++#define MSGCTL 14
++#define SHMAT 21
++#define SHMDT 22
++#define SHMGET 23
++#define SHMCTL 24
++
++/* Used by the DIPC package, try and avoid reusing it */
++#define DIPC 25
++
++#define IPCCALL(version,op) ((version)<<16 | (op))
++
++#endif
+--- linux/include/asm-nios2nommu/irq.h
++++ linux/include/asm-nios2nommu/irq.h
+@@ -0,0 +1,182 @@
++/*
++ * 21Mar2001 1.1 dgt/microtronix
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++#ifndef _NIOS2NOMMU_IRQ_H_
++#define _NIOS2NOMMU_IRQ_H_
++
++extern void disable_irq(unsigned int);
++extern void enable_irq(unsigned int);
++
++// #include <linux/config.h>
++#include <linux/interrupt.h>
++
++#define SYS_IRQS 32
++#define NR_IRQS SYS_IRQS
++
++/*
++ * Interrupt source definitions
++ * General interrupt sources are the level 1-7.
++ * Adding an interrupt service routine for one of these sources
++ * results in the addition of that routine to a chain of routines.
++ * Each one is called in succession. Each individual interrupt
++ * service routine should determine if the device associated with
++ * that routine requires service.
++ */
++
++#define IRQ01 (1) /* level 1 interrupt */
++#define IRQ02 (2) /* level 2 interrupt */
++#define IRQ03 (3) /* level 3 interrupt */
++#define IRQ04 (4) /* level 4 interrupt */
++#define IRQ05 (5) /* level 5 interrupt */
++#define IRQ06 (6) /* level 6 interrupt */
++#define IRQ07 (7) /* level 7 interrupt */
++#define IRQ08 (8) /* level 8 interrupt */
++#define IRQ09 (9) /* level 9 interrupt */
++#define IRQ0A (10) /* level 10 interrupt */
++#define IRQ0B (11) /* level 11 interrupt */
++#define IRQ0C (12) /* level 12 interrupt */
++#define IRQ0D (13) /* level 13 interrupt */
++#define IRQ0E (14) /* level 14 interrupt */
++#define IRQ0F (15) /* level 15 interrupt */
++#define IRQ10 (16) /* level 16 interrupt */
++#define IRQ12 (17) /* level 17 interrupt */
++#define IRQ13 (18) /* level 18 interrupt */
++#define IRQ14 (19) /* level 19 interrupt */
++#define IRQ15 (20) /* level 20 interrupt */
++#define IRQ16 (21) /* level 21 interrupt */
++#define IRQ17 (22) /* level 22 interrupt */
++#define IRQ18 (23) /* level 23 interrupt */
++#define IRQ19 (24) /* level 24 interrupt */
++#define IRQ1A (25) /* level 25 interrupt */
++#define IRQ1B (26) /* level 26 interrupt */
++#define IRQ1C (27) /* level 27 interrupt */
++#define IRQ1D (28) /* level 28 interrupt */
++#define IRQ1E (29) /* level 29 interrupt */
++#define IRQ1F (30) /* level 30 interrupt */
++#define IRQ20 (31) /* level 31 interrupt */
++#define IRQ21 (32) /* level 32 interrupt */
++
++#define IRQMAX IRQ21
++
++/*
++ * "Generic" interrupt sources
++ */
++
++/*
++ * Machine specific interrupt sources.
++ *
++ * Adding an interrupt service routine for a source with this bit
++ * set indicates a special machine specific interrupt source.
++ * The machine specific files define these sources.
++ *
++ * Removed, they are not used by any one.
++ */
++
++/*
++ * various flags for request_irq()
++ */
++#define IRQ_FLG_LOCK (0x0001) /* handler is not replaceable */
++#define IRQ_FLG_REPLACE (0x0002) /* replace existing handler */
++#define IRQ_FLG_FAST (0x0004)
++#define IRQ_FLG_SLOW (0x0008)
++#define IRQ_FLG_STD (0x8000) /* internally used */
++
++/*
++ * Functions to set and clear the interrupt mask.
++ */
++
++/*
++ * Use a zero to clean the bit.
++ */
++static inline void clrimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "and r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * Use a one to set the bit.
++ */
++static inline void setimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "or r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * This structure is used to chain together the ISRs for a particular
++ * interrupt source (if it supports chaining).
++ */
++typedef struct irq_node {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++ struct irq_node *next;
++} irq_node_t;
++
++/*
++ * This function returns a new irq_node_t
++ */
++extern irq_node_t *new_irq_node(void);
++
++/*
++ * This structure has only 4 elements for speed reasons
++ */
++typedef struct irq_handler {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++} irq_handler_t;
++
++/* count of spurious interrupts */
++extern volatile unsigned int num_spurious;
++
++#define disable_irq_nosync(i) disable_irq(i)
++
++#ifndef irq_canonicalize
++#define irq_canonicalize(i) (i)
++#endif
++
++#endif /* _NIOS2NOMMU_IRQ_H_ */
+--- linux/include/asm-nios2nommu/kmap_types.h
++++ linux/include/asm-nios2nommu/kmap_types.h
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_KMAP_TYPES_H
++#define _ASM_KMAP_TYPES_H
++
++enum km_type {
++ KM_BOUNCE_READ,
++ KM_SKB_SUNRPC_DATA,
++ KM_SKB_DATA_SOFTIRQ,
++ KM_USER0,
++ KM_USER1,
++ KM_BIO_SRC_IRQ,
++ KM_BIO_DST_IRQ,
++ KM_PTE0,
++ KM_PTE1,
++ KM_IRQ0,
++ KM_IRQ1,
++ KM_SOFTIRQ0,
++ KM_SOFTIRQ1,
++ KM_TYPE_NR
++};
++
++#endif
+--- linux/include/asm-nios2nommu/linkage.h
++++ linux/include/asm-nios2nommu/linkage.h
+@@ -0,0 +1,29 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASM_LINKAGE_H
++#define __ASM_LINKAGE_H
++
++#define __ALIGN .align 3
++#define __ALIGN_STR ".align 3"
++
++#endif
+--- linux/include/asm-nios2nommu/linux_logo.h
++++ linux/include/asm-nios2nommu/linux_logo.h
+@@ -0,0 +1,953 @@
++/* $Id: linux_logo.h,v 1.3 2004/02/12 23:06:40 ken-h Exp $
++ * include/asm-nios/linux_logo.h: This is a linux logo
++ * to be displayed on boot.
++ *
++ * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
++ * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
++ * Copyright (C) 2004 Micrtronix Datacom Ltd.
++ *
++ * You can put anything here, but:
++ * LINUX_LOGO_COLORS has to be less than 224
++ * image size has to be 80x80
++ * values have to start from 0x20
++ * (i.e. RGB(linux_logo_red[0],
++ * linux_logo_green[0],
++ * linux_logo_blue[0]) is color 0x20)
++ * BW image has to be 80x80 as well, with MS bit
++ * on the left
++ * Serial_console ascii image can be any size,
++ * but should contain %s to display the version
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/init.h>
++#include <linux/version.h>
++
++#define linux_logo_banner "Linux/NIOS2 version " UTS_RELEASE
++
++#define __HAVE_ARCH_LINUX_LOGO
++#define __HAVE_ARCH_LINUX_LOGO16
++
++#define LINUX_LOGO_COLORS 221
++
++#ifdef INCLUDE_LINUX_LOGO_DATA
++
++unsigned char linux_logo_red[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x65, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x76, 0x79,
++ 0x62, 0x36, 0x9a, 0xe2, 0xec, 0xe1, 0xb8, 0xd7,
++ 0xaf, 0x25, 0xbc, 0xc0, 0xef, 0xea, 0xe8, 0xe8,
++ 0xf5, 0xf1, 0xda, 0xd3, 0x79, 0xdb, 0xf4, 0xf6,
++ 0xf6, 0xf6, 0xe2, 0x3d, 0xb4, 0xce, 0xe6, 0xee,
++ 0xf6, 0x68, 0xd8, 0xec, 0xf5, 0xc6, 0xc8, 0x9c,
++ 0x89, 0xd2, 0xee, 0xcb, 0xb9, 0xd2, 0x66, 0x5e,
++ 0x8b, 0xbe, 0xa8, 0xd5, 0xca, 0xb6, 0xae, 0x9c,
++ 0xc5, 0xbe, 0xbe, 0xca, 0x90, 0xb2, 0x9a, 0xa8,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfe,
++ 0xf6, 0xec, 0xfe, 0xd2, 0xea, 0xf5, 0xf2, 0xf2,
++ 0xe9, 0xee, 0xf6, 0xf2, 0xee, 0xf6, 0xda, 0xd4,
++ 0xfa, 0xca, 0xf2, 0xf6, 0xfe, 0xf2, 0xda, 0xe4,
++ 0xf6, 0xdd, 0xf2, 0xee, 0xfa, 0xf0, 0x12, 0x4a,
++ 0xd6, 0xf2, 0x8e, 0xf2, 0xf6, 0xf6, 0xb5, 0xf1,
++ 0x26, 0x9a, 0xea, 0xf6, 0xe0, 0xd2, 0x16, 0x9a,
++ 0x2e, 0xd2, 0x70, 0xd6, 0x46, 0x7c, 0xb4, 0x62,
++ 0xda, 0xee, 0xd6, 0xa3, 0x74, 0xa7, 0xa2, 0xe0,
++ 0xae, 0xbe, 0xce, 0xe2, 0xa3, 0x8e, 0x6d, 0x8e,
++ 0x32, 0xaf, 0x50, 0x9e, 0x5b, 0x8a, 0x98, 0x82,
++ 0x7a, 0x82, 0x56, 0x7c, 0x8a, 0x56, 0x5e, 0x86,
++ 0x6a, 0x52, 0x59, 0x64, 0x5e,
++};
++
++unsigned char linux_logo_green[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x62, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x62, 0x5c,
++ 0x4e, 0x26, 0x72, 0xaa, 0xba, 0xaf, 0x90, 0xae,
++ 0x92, 0x1a, 0xa4, 0x85, 0xb6, 0xbe, 0xc3, 0xc8,
++ 0xcf, 0xd0, 0xc2, 0xce, 0x57, 0xa2, 0xd6, 0xda,
++ 0xda, 0xd7, 0xb8, 0x2a, 0x7b, 0x91, 0xae, 0xca,
++ 0xda, 0x45, 0x9e, 0xb2, 0xd7, 0x9b, 0x90, 0x76,
++ 0x5c, 0xa2, 0xbe, 0xa6, 0x85, 0x96, 0x4e, 0x46,
++ 0x66, 0x92, 0x7a, 0x9a, 0x96, 0x9d, 0x9a, 0x6b,
++ 0x8a, 0x8e, 0xb2, 0xca, 0x90, 0xa6, 0x79, 0x7c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfa,
++ 0xea, 0xd7, 0xf6, 0xbc, 0xda, 0xde, 0xda, 0xe6,
++ 0xca, 0xd8, 0xea, 0xe0, 0xcc, 0xf2, 0xce, 0xb2,
++ 0xee, 0xa2, 0xd6, 0xe6, 0xf6, 0xd7, 0xc5, 0xb8,
++ 0xc6, 0xb9, 0xce, 0xde, 0xce, 0xc6, 0x0e, 0x36,
++ 0xae, 0xbe, 0x86, 0xba, 0xbe, 0xe6, 0x8e, 0xc4,
++ 0x1e, 0x8e, 0xae, 0xba, 0xb2, 0xa6, 0x12, 0x7a,
++ 0x20, 0xc6, 0x64, 0xaa, 0x2f, 0x70, 0x85, 0x46,
++ 0xce, 0xd6, 0xa6, 0x6e, 0x51, 0x72, 0x92, 0xa6,
++ 0x87, 0x96, 0xa2, 0xd6, 0x85, 0x7a, 0x6a, 0x6e,
++ 0x22, 0x76, 0x36, 0x76, 0x3c, 0x6e, 0x63, 0x53,
++ 0x66, 0x62, 0x42, 0x50, 0x56, 0x42, 0x56, 0x56,
++ 0x56, 0x3e, 0x51, 0x52, 0x56,
++};
++
++unsigned char linux_logo_blue[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x01, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x06, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x59, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x2e, 0x08,
++ 0x0a, 0x06, 0x0a, 0x0b, 0x0b, 0x0f, 0x0c, 0x0f,
++ 0x3d, 0x09, 0x73, 0x09, 0x0d, 0x0a, 0x10, 0x1e,
++ 0x2d, 0x13, 0x86, 0xba, 0x19, 0x0a, 0x36, 0x3c,
++ 0x26, 0x14, 0x0d, 0x06, 0x07, 0x0a, 0x0b, 0x0f,
++ 0x4a, 0x06, 0x0a, 0x0c, 0x2b, 0x0a, 0x0b, 0x0a,
++ 0x06, 0x0a, 0x0a, 0x11, 0x0b, 0x0a, 0x0a, 0x1e,
++ 0x0f, 0x0d, 0x0a, 0x0b, 0x22, 0x6a, 0x72, 0x0b,
++ 0x0b, 0x22, 0x90, 0xca, 0x90, 0x92, 0x3c, 0x2c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xea,
++ 0xb6, 0x7c, 0xda, 0x8e, 0xa6, 0x87, 0x66, 0xb6,
++ 0x81, 0x6a, 0xc6, 0x9a, 0x5b, 0xd2, 0xb6, 0x6a,
++ 0xca, 0x45, 0x92, 0xb2, 0xca, 0x52, 0x8a, 0x3e,
++ 0x2e, 0x66, 0x66, 0xae, 0x3e, 0x47, 0x06, 0x0e,
++ 0x52, 0x36, 0x6a, 0x0e, 0x0e, 0xbe, 0x2c, 0x0e,
++ 0x0a, 0x5a, 0x0d, 0x0e, 0x3e, 0x0a, 0x06, 0x2e,
++ 0x06, 0x9e, 0x4e, 0x36, 0x06, 0x58, 0x24, 0x06,
++ 0x9e, 0xae, 0x3a, 0x08, 0x08, 0x07, 0x5e, 0x0a,
++ 0x32, 0x2e, 0x2a, 0xb2, 0x43, 0x48, 0x5f, 0x2e,
++ 0x06, 0x06, 0x07, 0x24, 0x06, 0x32, 0x06, 0x06,
++ 0x46, 0x2e, 0x22, 0x06, 0x06, 0x1e, 0x4c, 0x06,
++ 0x3a, 0x22, 0x42, 0x34, 0x42,
++};
++
++unsigned char linux_logo[] __initdata = {
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22,
++ 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
++ 0x26, 0x26, 0x25, 0x28, 0x23, 0x22, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x25, 0x2a, 0x2b, 0x2c, 0x2d, 0x2d,
++ 0x2d, 0x2e, 0x2c, 0x2b, 0x2a, 0x25, 0x28, 0x22,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x24, 0x2a, 0x2c, 0x2f, 0x2c, 0x30, 0x30, 0x24,
++ 0x25, 0x27, 0x2b, 0x2c, 0x2f, 0x31, 0x32, 0x25,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x33, 0x34, 0x35, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x2b, 0x2f, 0x2c,
++ 0x30, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x2d, 0x27, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x31,
++ 0x2d, 0x32, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x28, 0x2a, 0x34,
++ 0x25, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x23, 0x32, 0x27, 0x21, 0x36,
++ 0x2a, 0x2d, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x26, 0x2c, 0x35,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2f, 0x37, 0x32, 0x22,
++ 0x36, 0x35, 0x31, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x22,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x26, 0x38, 0x38, 0x35, 0x25,
++ 0x36, 0x21, 0x2d, 0x2b, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x39, 0x39, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2b, 0x30, 0x28, 0x22,
++ 0x36, 0x36, 0x27, 0x34, 0x30, 0x23, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x26, 0x2d, 0x26, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x22, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2d, 0x33, 0x28, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2b, 0x2c, 0x25, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x36, 0x36,
++ 0x36, 0x21, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x21, 0x23, 0x22, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x28, 0x34, 0x27, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x21, 0x21, 0x24, 0x27, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x27, 0x22, 0x33, 0x24, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x2f, 0x2a, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x30, 0x3a, 0x38, 0x24, 0x24, 0x36, 0x36, 0x36,
++ 0x23, 0x2f, 0x3b, 0x3c, 0x3d, 0x30, 0x25, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x32, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x23,
++ 0x3e, 0x3f, 0x40, 0x3a, 0x22, 0x36, 0x36, 0x21,
++ 0x41, 0x42, 0x43, 0x44, 0x45, 0x3e, 0x23, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x33, 0x28, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x2b,
++ 0x44, 0x40, 0x46, 0x47, 0x35, 0x36, 0x36, 0x26,
++ 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x2e, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x34, 0x36, 0x4d,
++ 0x4e, 0x25, 0x2f, 0x46, 0x4a, 0x22, 0x23, 0x32,
++ 0x4f, 0x50, 0x21, 0x31, 0x51, 0x52, 0x53, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x21, 0x3a,
++ 0x4d, 0x21, 0x31, 0x54, 0x55, 0x28, 0x30, 0x2b,
++ 0x4b, 0x4d, 0x36, 0x23, 0x32, 0x50, 0x3f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x38, 0x23, 0x37,
++ 0x55, 0x36, 0x28, 0x3a, 0x56, 0x57, 0x57, 0x58,
++ 0x3c, 0x4d, 0x36, 0x36, 0x36, 0x40, 0x40, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x29, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x51, 0x23, 0x35,
++ 0x43, 0x25, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
++ 0x5f, 0x60, 0x61, 0x36, 0x31, 0x47, 0x3b, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x2c, 0x25, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x22,
++ 0x40, 0x62, 0x63, 0x5d, 0x64, 0x65, 0x66, 0x67,
++ 0x68, 0x69, 0x66, 0x5e, 0x6a, 0x6b, 0x2a, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x2e, 0x26, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2f, 0x23, 0x36,
++ 0x6c, 0x63, 0x6d, 0x64, 0x5c, 0x66, 0x69, 0x6e,
++ 0x6f, 0x70, 0x71, 0x69, 0x69, 0x72, 0x6c, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x34, 0x27, 0x22,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x34, 0x26, 0x73,
++ 0x74, 0x75, 0x76, 0x64, 0x65, 0x77, 0x69, 0x78,
++ 0x70, 0x71, 0x71, 0x71, 0x72, 0x5f, 0x5e, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x25, 0x38, 0x2a, 0x23,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x33, 0x79,
++ 0x63, 0x7a, 0x7b, 0x5c, 0x66, 0x69, 0x6e, 0x7c,
++ 0x71, 0x71, 0x69, 0x7d, 0x7e, 0x7a, 0x7f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x51, 0x2b, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x32, 0x24,
++ 0x80, 0x81, 0x64, 0x82, 0x77, 0x69, 0x71, 0x71,
++ 0x69, 0x83, 0x84, 0x85, 0x7a, 0x85, 0x86, 0x36,
++ 0x21, 0x2b, 0x23, 0x36, 0x36, 0x39, 0x2e, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2d, 0x33, 0x21,
++ 0x87, 0x88, 0x89, 0x72, 0x67, 0x66, 0x5f, 0x89,
++ 0x8a, 0x63, 0x85, 0x8b, 0x8c, 0x8d, 0x41, 0x36,
++ 0x36, 0x2d, 0x3a, 0x35, 0x36, 0x24, 0x51, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x33, 0x21,
++ 0x55, 0x8e, 0x8f, 0x8a, 0x7d, 0x5e, 0x90, 0x7e,
++ 0x75, 0x75, 0x90, 0x62, 0x40, 0x3f, 0x49, 0x23,
++ 0x36, 0x24, 0x3a, 0x3a, 0x24, 0x36, 0x2e, 0x31,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x33, 0x37, 0x25, 0x22,
++ 0x3b, 0x50, 0x8e, 0x8f, 0x90, 0x7e, 0x90, 0x63,
++ 0x74, 0x91, 0x92, 0x42, 0x93, 0x4b, 0x45, 0x2c,
++ 0x36, 0x36, 0x33, 0x39, 0x21, 0x36, 0x22, 0x51,
++ 0x33, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x27, 0x2e, 0x2e, 0x36, 0x21,
++ 0x94, 0x3f, 0x50, 0x95, 0x96, 0x8f, 0x8f, 0x97,
++ 0x8e, 0x42, 0x50, 0x43, 0x47, 0x48, 0x48, 0x98,
++ 0x21, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39,
++ 0x2e, 0x27, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x24, 0x2b, 0x38, 0x28, 0x36, 0x32,
++ 0x4c, 0x4b, 0x50, 0x50, 0x50, 0x42, 0x42, 0x50,
++ 0x50, 0x40, 0x45, 0x99, 0x48, 0x48, 0x48, 0x48,
++ 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x23,
++ 0x2f, 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x32, 0x51, 0x32, 0x28, 0x21, 0x98,
++ 0x48, 0x47, 0x9a, 0x50, 0x50, 0x50, 0x50, 0x50,
++ 0x9a, 0x4f, 0x9b, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x93, 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2f, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x23, 0x30, 0x2e, 0x2c, 0x36, 0x21, 0x51, 0x9b,
++ 0x48, 0x48, 0x52, 0x3f, 0x50, 0x50, 0x40, 0x4b,
++ 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2d, 0x31, 0x27, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x2c, 0x2d, 0x21, 0x36, 0x28, 0x44, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x46, 0x4f, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x9c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x28, 0x51, 0x39, 0x26, 0x22, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x35, 0x51, 0x28, 0x36, 0x36, 0x9d, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x9b, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4f, 0x28, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x38, 0x2b, 0x25, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x51, 0x25, 0x36, 0x36, 0x23, 0x40, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x9b, 0x99, 0x2b, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x2f, 0x33, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x23, 0x30, 0x34,
++ 0x27, 0x36, 0x36, 0x36, 0x2a, 0x40, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x99, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x47, 0x52,
++ 0x46, 0x4f, 0x37, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x30, 0x34, 0x2a, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x25, 0x39, 0x2c,
++ 0x36, 0x36, 0x36, 0x21, 0x31, 0x4e, 0x9a, 0x4c,
++ 0x47, 0x9b, 0x9b, 0x52, 0x46, 0x4f, 0x52, 0x9b,
++ 0x9b, 0x9b, 0x47, 0x4f, 0x45, 0x9a, 0x93, 0x93,
++ 0x3f, 0x93, 0x98, 0x28, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x28,
++ 0x36, 0x36, 0x36, 0x22, 0x38, 0x98, 0x44, 0x99,
++ 0x9b, 0x48, 0x48, 0x9b, 0x4c, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x52, 0x46, 0x43, 0x93,
++ 0x40, 0x40, 0x43, 0x53, 0x21, 0x23, 0x33, 0x23,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x2f, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x2b, 0x31, 0x36,
++ 0x36, 0x22, 0x36, 0x24, 0x9e, 0x4f, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x9f, 0x52, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x47,
++ 0x4f, 0x9a, 0x3f, 0x46, 0x38, 0x36, 0x21, 0x30,
++ 0x26, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c,
++ 0x25, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2e, 0x33, 0x36,
++ 0x25, 0x25, 0x36, 0x4d, 0x52, 0x48, 0x48, 0x48,
++ 0x47, 0x9f, 0x48, 0x48, 0x48, 0xa0, 0xa1, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x47, 0x44, 0x93, 0x43, 0x23, 0x36, 0x36,
++ 0x26, 0x24, 0x36, 0x36, 0x36, 0x36, 0x28, 0x2f,
++ 0x2a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x51, 0x24, 0x36,
++ 0x2a, 0x36, 0x28, 0x44, 0x48, 0x48, 0x48, 0x48,
++ 0xa3, 0xa4, 0x48, 0x48, 0x9f, 0xa5, 0xa6, 0x9f,
++ 0x48, 0x48, 0x48, 0xa2, 0xa7, 0x47, 0x48, 0x48,
++ 0x48, 0x48, 0x9b, 0x4b, 0x44, 0x37, 0x36, 0x23,
++ 0x28, 0x30, 0x22, 0x36, 0x36, 0x36, 0x36, 0x2d,
++ 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x2b, 0x34, 0x36, 0x25,
++ 0x24, 0x36, 0x4a, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0xa8, 0xa1, 0x48, 0x48, 0x9f, 0xa9, 0xa6, 0x9f,
++ 0x48, 0x48, 0xaa, 0xa1, 0xa5, 0x9f, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x52, 0x3f, 0x21, 0x30,
++ 0x35, 0x25, 0x30, 0x36, 0x36, 0x36, 0x36, 0x32,
++ 0x2d, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x26, 0x2e, 0x35, 0x36, 0x2a,
++ 0x36, 0x24, 0x4f, 0x48, 0x52, 0x52, 0x48, 0x48,
++ 0xab, 0xac, 0xa0, 0x48, 0xad, 0xa6, 0xa6, 0x9f,
++ 0x48, 0xa2, 0xa9, 0xa6, 0xa2, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x47, 0x32, 0x30,
++ 0x2a, 0x23, 0x30, 0x23, 0x36, 0x36, 0x36, 0x21,
++ 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x2a, 0x51, 0x28, 0x28, 0x25,
++ 0x36, 0x3a, 0x48, 0x48, 0xae, 0xaf, 0x48, 0x48,
++ 0xad, 0xac, 0xa1, 0x9f, 0xa2, 0xa9, 0xa9, 0xa2,
++ 0x48, 0xab, 0x78, 0xa7, 0x48, 0x48, 0x48, 0x48,
++ 0x9f, 0x48, 0x48, 0x48, 0x48, 0x48, 0x38, 0x21,
++ 0x36, 0x36, 0x22, 0x27, 0x36, 0x36, 0x36, 0x36,
++ 0x2e, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x25, 0x2c, 0x34, 0x36, 0x30, 0x21,
++ 0x23, 0x43, 0x48, 0x48, 0xb0, 0xb1, 0xb2, 0x9f,
++ 0x48, 0xb3, 0xa5, 0xb3, 0xab, 0xa9, 0xa9, 0xb3,
++ 0xb4, 0xa9, 0xb5, 0xb0, 0x48, 0x48, 0xa0, 0xa5,
++ 0xa1, 0xad, 0x48, 0x48, 0x48, 0x48, 0x94, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2e, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x2a, 0x51, 0x25, 0x21, 0x2a, 0x36,
++ 0x2e, 0x9b, 0x48, 0x48, 0x48, 0xb6, 0xb7, 0xa4,
++ 0xa2, 0xa7, 0xb5, 0x78, 0x6f, 0x6f, 0x6e, 0x6f,
++ 0xa9, 0xb5, 0xab, 0x48, 0x9f, 0xab, 0xa9, 0xa1,
++ 0xaa, 0x48, 0x48, 0x48, 0x48, 0x48, 0x98, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x22, 0x2f, 0x30, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x22, 0x25, 0x2c, 0x34, 0x36, 0x24, 0x28, 0x36,
++ 0x54, 0x48, 0x48, 0x48, 0x48, 0xa2, 0xa8, 0xa1,
++ 0xa5, 0xa6, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x6f, 0x78, 0xa5, 0xa0, 0xa0, 0x78, 0xa6, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x36, 0x36, 0x36, 0x36,
++ 0x21, 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x32, 0x2f, 0x28, 0x36, 0x27, 0x22, 0x21,
++ 0x43, 0x48, 0x4b, 0xa2, 0x9f, 0x48, 0xa2, 0xa1,
++ 0xb8, 0x6e, 0x6e, 0xb5, 0x78, 0x6f, 0x78, 0x78,
++ 0x6e, 0x6f, 0x78, 0xb5, 0xa6, 0xa1, 0xa0, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4b, 0x21,
++ 0x36, 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x25, 0x2c, 0x39, 0x36, 0x36, 0x30, 0x22, 0x25,
++ 0x52, 0x48, 0xa3, 0xb1, 0xb6, 0xb3, 0xaa, 0xac,
++ 0x68, 0x68, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x78, 0x6f, 0x6f, 0xb5, 0xa6, 0xb4, 0x48, 0x9f,
++ 0xb4, 0xb4, 0xa2, 0x9f, 0x48, 0x48, 0x4f, 0x21,
++ 0x36, 0x36, 0x22, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x30, 0x2d, 0x21, 0x36, 0x36, 0x32, 0x23, 0x2a,
++ 0x47, 0x48, 0xa2, 0xb6, 0xaf, 0xb9, 0xba, 0x68,
++ 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x78,
++ 0x6f, 0x6f, 0xa6, 0x6f, 0xb5, 0xa0, 0xaa, 0xa6,
++ 0xa6, 0xa9, 0xb2, 0xb3, 0x48, 0x48, 0x4c, 0x22,
++ 0x36, 0x36, 0x24, 0x23, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0x2e, 0x36, 0x36, 0x23, 0x31, 0x27, 0x39,
++ 0x9b, 0x48, 0x48, 0x48, 0xb0, 0xb0, 0xba, 0xb8,
++ 0x68, 0x68, 0x69, 0x78, 0x6f, 0xb5, 0x6f, 0xb5,
++ 0x78, 0x78, 0x78, 0x78, 0x78, 0xa5, 0xbb, 0xa9,
++ 0xa5, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4c, 0x23,
++ 0x36, 0x36, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x2b, 0x39, 0x36, 0x36, 0x36, 0x26, 0x32, 0x31,
++ 0x9b, 0x48, 0x48, 0x48, 0x48, 0x9f, 0xac, 0x68,
++ 0xbc, 0x6e, 0x6e, 0x6e, 0xb5, 0x6f, 0x6e, 0x6f,
++ 0x6f, 0x78, 0x78, 0xb5, 0xb5, 0xa5, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x46, 0x22,
++ 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x39, 0x36, 0x36, 0x36, 0x36, 0x26, 0x2d,
++ 0x9b, 0x48, 0x48, 0xb0, 0xaa, 0xb3, 0xbd, 0xb8,
++ 0xb8, 0x68, 0x6e, 0x6e, 0xb5, 0x6f, 0x78, 0x6e,
++ 0x78, 0x6f, 0x78, 0x78, 0xb5, 0xa9, 0xa2, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x24, 0x27, 0xbe, 0x24, 0x25, 0x28, 0x21, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x25,
++ 0x39, 0x4d, 0xbf, 0x84, 0x81, 0x57, 0x21, 0x39,
++ 0x52, 0x48, 0x48, 0x62, 0xb1, 0xc0, 0xc1, 0xc1,
++ 0xb8, 0xb8, 0x68, 0xbc, 0x6e, 0x6e, 0x6e, 0x78,
++ 0x78, 0x78, 0x78, 0x6e, 0x78, 0xa9, 0xa0, 0xab,
++ 0xb3, 0xa2, 0x48, 0x48, 0x48, 0x48, 0x53, 0x28,
++ 0x23, 0x36, 0x36, 0x36, 0x21, 0x28, 0x2c, 0x30,
++ 0x21, 0x38, 0x33, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x22, 0x22, 0x28, 0x30,
++ 0x2d, 0xc2, 0x7a, 0xc3, 0xc4, 0xc4, 0x7f, 0x22,
++ 0x51, 0x52, 0x48, 0x48, 0xb0, 0xaa, 0xa8, 0xbd,
++ 0x68, 0xb8, 0xb8, 0x68, 0x68, 0x6e, 0x6e, 0x6f,
++ 0x6e, 0x6e, 0xb5, 0x6e, 0x78, 0xab, 0xab, 0xb5,
++ 0x78, 0xa6, 0xb3, 0xc5, 0xac, 0xac, 0xc6, 0x61,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x30, 0x32,
++ 0x25, 0x4d, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x24, 0x26, 0x30, 0x33, 0x31,
++ 0x4d, 0x91, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0x5a,
++ 0x21, 0x2e, 0x46, 0x48, 0x48, 0x48, 0xb0, 0x64,
++ 0xc1, 0xb8, 0xb8, 0xb8, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6f, 0x71, 0x6f, 0x6f, 0xa6, 0xa0, 0x9f, 0xb4,
++ 0xb4, 0xa0, 0xa1, 0xb7, 0xc7, 0x69, 0x66, 0xc8,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x26, 0x25,
++ 0x83, 0xc9, 0x2c, 0x25, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x30, 0x35, 0x2d, 0x2f, 0x37, 0x4a,
++ 0x60, 0x85, 0xca, 0xcb, 0xc4, 0xc4, 0xc4, 0x82,
++ 0x86, 0x36, 0x32, 0x3f, 0xa2, 0xa4, 0xa8, 0xa9,
++ 0xb8, 0xb8, 0xb8, 0xb8, 0x68, 0x6e, 0x6e, 0x6e,
++ 0x6e, 0x71, 0x6f, 0x71, 0xa6, 0xb4, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0xcc, 0xc3, 0xc7, 0xcd, 0xce,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x57,
++ 0x77, 0x66, 0x34, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x23, 0x30, 0x31, 0xcf, 0x91, 0x7e, 0x90, 0x90,
++ 0x8b, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0x5d, 0xd0, 0x36, 0x24, 0xd1, 0xb1, 0xaf, 0xaa,
++ 0xba, 0xb8, 0x68, 0x68, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6e, 0x6f, 0x6e, 0x78, 0xa1, 0xa9, 0xa1, 0xb0,
++ 0x9f, 0x9b, 0x99, 0xcc, 0x64, 0x5c, 0x8b, 0xd0,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x73, 0x5d,
++ 0x82, 0x5c, 0xd2, 0x2a, 0x23, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x24, 0x2b, 0xcf, 0x8b, 0x5b, 0x76, 0x5b, 0x5b,
++ 0x7b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc7, 0x5e, 0x22, 0x36, 0x21, 0x3a, 0x99, 0x48,
++ 0xa2, 0xa8, 0xb7, 0xc1, 0xb8, 0x68, 0x68, 0xbc,
++ 0x68, 0x6e, 0xb5, 0xb4, 0xb4, 0xab, 0xb5, 0xa1,
++ 0xb0, 0x4f, 0x3f, 0xd3, 0x7b, 0x7b, 0x85, 0x80,
++ 0xbe, 0x36, 0x36, 0x36, 0x21, 0xd4, 0x7e, 0x7b,
++ 0x64, 0x64, 0xd5, 0x35, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x31, 0xd6, 0x5b, 0x64, 0xc3, 0xc3, 0xcb,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x66, 0xd7, 0x36, 0x36, 0x36, 0x2c, 0x4b,
++ 0xd8, 0xd9, 0xb3, 0xa8, 0xbd, 0xbd, 0xbd, 0xbd,
++ 0xa9, 0xab, 0xb3, 0xa5, 0xa2, 0x9f, 0xa2, 0xa1,
++ 0x6a, 0x9a, 0x3f, 0xda, 0x76, 0x76, 0x7a, 0x63,
++ 0xdb, 0xdc, 0x86, 0xdc, 0xdd, 0x90, 0x5b, 0x64,
++ 0xc3, 0xc3, 0xde, 0x2d, 0x27, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x26, 0x2d, 0x91, 0x5b, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc7, 0x83, 0xce, 0x36, 0x36, 0x36, 0x30,
++ 0xb1, 0xd9, 0x48, 0xa1, 0xb2, 0xb0, 0xb0, 0xb3,
++ 0xa2, 0x48, 0xa7, 0xbd, 0xa9, 0xa2, 0x48, 0x9f,
++ 0xaa, 0x9a, 0x3f, 0xb1, 0x5b, 0x7b, 0xdf, 0x85,
++ 0x7e, 0x90, 0x63, 0x90, 0x85, 0x5b, 0xc3, 0xc4,
++ 0xc4, 0xcb, 0x5d, 0xd5, 0x39, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe0, 0xdf, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x88, 0x36, 0x36, 0x36, 0x36,
++ 0x2d, 0x9b, 0x48, 0xb9, 0xaf, 0xa2, 0xa2, 0xb9,
++ 0xa8, 0x9f, 0x48, 0xa7, 0xb7, 0xd9, 0x48, 0x48,
++ 0x9b, 0x45, 0x3f, 0xe1, 0x6d, 0x7b, 0xca, 0xdf,
++ 0x7a, 0x8b, 0x8b, 0x7a, 0x5b, 0x64, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc3, 0xe2, 0x37, 0x35, 0x26, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2e, 0xe0, 0x7a, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x72, 0x73, 0x36, 0x36, 0x36,
++ 0x24, 0x52, 0x48, 0xa3, 0xaf, 0x9f, 0x48, 0xb6,
++ 0xaf, 0xa2, 0x48, 0x9f, 0xe3, 0xd8, 0x48, 0x48,
++ 0x48, 0x46, 0x42, 0xd6, 0x7a, 0x7b, 0x64, 0x7b,
++ 0x76, 0x5b, 0x5b, 0x76, 0x7b, 0xc3, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0x64, 0xe2, 0x4d, 0x2c, 0x27,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x8b, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc7, 0x89, 0xbe, 0x36, 0x36,
++ 0x32, 0x47, 0x48, 0x4f, 0xa0, 0x48, 0x48, 0xe3,
++ 0x92, 0x9f, 0x48, 0x9f, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4b, 0x2f, 0x8f, 0x7a, 0x7b, 0xc3, 0xcb,
++ 0xc3, 0x64, 0x64, 0xc3, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x5d, 0xe5, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x85, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x57, 0x27, 0x4d,
++ 0x4b, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x99, 0x34, 0xbe, 0xdb, 0x7a, 0x7b, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xe4,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe4, 0x85, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc7, 0x5f, 0x92, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x44,
++ 0x35, 0x36, 0xce, 0xdd, 0x7a, 0x7b, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0xc3, 0xe1,
++ 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x30, 0x2f, 0xd6, 0x8b, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x89, 0x45,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x4e, 0x25,
++ 0x36, 0x36, 0x61, 0xdb, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0xdf, 0xe5,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xe6, 0x63, 0xdf, 0xc3, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x72, 0x81, 0xe7,
++ 0x46, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x3f, 0x2c, 0x36, 0x36,
++ 0x36, 0x36, 0xe8, 0x8f, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc3, 0xca, 0x8b, 0xcf, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x96, 0x75, 0xca, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0x81, 0xdb,
++ 0x73, 0x3b, 0x44, 0x9b, 0x48, 0x48, 0x48, 0x9b,
++ 0x99, 0x43, 0x94, 0x2c, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x73, 0xdb, 0x7a, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x64, 0x76, 0x7a, 0x91, 0xd5, 0x31, 0x30,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x39, 0x97, 0x75, 0xdf, 0x7b, 0x64, 0xc3, 0xc3,
++ 0xcb, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x7b, 0x7a, 0xe9,
++ 0xea, 0x36, 0x21, 0x26, 0x2b, 0x39, 0x33, 0x30,
++ 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xdd, 0x8b, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x64, 0x64,
++ 0x76, 0x85, 0xe0, 0xd5, 0x34, 0x2b, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xeb, 0x63, 0x7e, 0x7a, 0x6d, 0xdf, 0x5b,
++ 0x76, 0x7b, 0x64, 0x64, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x76, 0x85, 0xdb,
++ 0x79, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xec, 0xdd, 0x75, 0x76, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0xc3, 0x64, 0x76, 0xdf, 0x8b,
++ 0xd6, 0xd5, 0x2f, 0x35, 0x30, 0x24, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x31, 0xed, 0xeb, 0xdd, 0x74, 0x63, 0x90,
++ 0x7e, 0x75, 0x8b, 0x6d, 0xdf, 0x76, 0x64, 0xc3,
++ 0xcb, 0xcb, 0xcb, 0xcb, 0x64, 0x7a, 0x84, 0xee,
++ 0x79, 0xbe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xee, 0x63, 0x6d, 0x7b, 0x64,
++ 0xcb, 0xc3, 0x64, 0x7b, 0xdf, 0x75, 0x63, 0x96,
++ 0x38, 0x39, 0x2a, 0x24, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x27, 0x35, 0x2d, 0x41, 0xd5, 0xe7, 0x8f,
++ 0xdb, 0xdd, 0xe9, 0x74, 0x84, 0x90, 0x85, 0x6d,
++ 0x5b, 0x7b, 0x7b, 0xca, 0x6d, 0x90, 0xdb, 0xef,
++ 0xec, 0x22, 0x36, 0x36, 0x28, 0x30, 0x30, 0x30,
++ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x25, 0x36,
++ 0x36, 0x21, 0xd4, 0x80, 0xe9, 0x7e, 0x6d, 0x76,
++ 0xca, 0x76, 0x6d, 0x85, 0x63, 0xdb, 0xd5, 0x34,
++ 0x33, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x24, 0x27, 0x2a, 0x35, 0x2e, 0x2f,
++ 0x41, 0xf0, 0xf1, 0x6c, 0x80, 0xee, 0xdb, 0x74,
++ 0x84, 0x90, 0x75, 0x7e, 0x74, 0x8f, 0xef, 0x79,
++ 0xe8, 0x2b, 0x9d, 0x41, 0x2f, 0x34, 0x2d, 0x2d,
++ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x34, 0x2f, 0x38,
++ 0x4d, 0x37, 0xf2, 0xf3, 0x8f, 0x74, 0x63, 0x7e,
++ 0x75, 0x7e, 0x63, 0xe9, 0x88, 0xe6, 0x31, 0x2a,
++ 0x24, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x30,
++ 0x33, 0x39, 0x2e, 0x51, 0x41, 0xd2, 0x6c, 0xf3,
++ 0x80, 0xee, 0xee, 0xee, 0xf4, 0xf3, 0xd7, 0xf5,
++ 0x41, 0x34, 0x35, 0x32, 0x30, 0x27, 0x27, 0x27,
++ 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x30, 0x2a,
++ 0x2b, 0x34, 0xf6, 0xec, 0xf7, 0x8f, 0xdd, 0xe9,
++ 0xe9, 0xdd, 0xee, 0x6c, 0x41, 0x39, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22,
++ 0x28, 0x24, 0x26, 0x2a, 0x33, 0x2c, 0x2f, 0x41,
++ 0xf8, 0xd7, 0x79, 0x79, 0x79, 0xec, 0xf9, 0x51,
++ 0x39, 0x30, 0x24, 0x23, 0x22, 0x22, 0x22, 0x22,
++ 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23,
++ 0x24, 0x2a, 0x31, 0xfa, 0xea, 0x79, 0xf3, 0x80,
++ 0xf7, 0xdc, 0xfb, 0x2f, 0x35, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x28, 0x25, 0x30, 0x2b,
++ 0x31, 0x2f, 0xf6, 0xfa, 0xfa, 0x2f, 0x2e, 0x33,
++ 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x27, 0x35, 0x34, 0xfa, 0xfa, 0xfa,
++ 0xfc, 0xf6, 0x2e, 0x33, 0x25, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x23, 0x28,
++ 0x26, 0x30, 0x32, 0x2b, 0x33, 0x2a, 0x26, 0x28,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x25, 0x30, 0x33, 0x35, 0x35,
++ 0x2b, 0x2a, 0x26, 0x28, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x21, 0x22, 0x23, 0x28, 0x28, 0x23, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x23, 0x28, 0x24, 0x24,
++ 0x28, 0x23, 0x22, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++};
++
++unsigned char linux_logo16[1];
++
++#endif /* INCLUDE_LINUX_LOGO_DATA */
++
++#include <linux/linux_logo.h>
++
+--- linux/include/asm-nios2nommu/local.h
++++ linux/include/asm-nios2nommu/local.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_LOCAL_H
++#define __NIOS2NOMMU_LOCAL_H
++
++#include <asm-generic/local.h>
++
++#endif /* __NIOS2NOMMU_LOCAL_H */
+--- linux/include/asm-nios2nommu/mc146818rtc.h
++++ linux/include/asm-nios2nommu/mc146818rtc.h
+@@ -0,0 +1,29 @@
++/*
++ * Machine dependent access functions for RTC registers.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_MC146818RTC_H
++#define _NIOS2_MC146818RTC_H
++
++/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
++
++#endif /* _NIOS2_MC146818RTC_H */
+--- linux/include/asm-nios2nommu/mman.h
++++ linux/include/asm-nios2nommu/mman.h
+@@ -0,0 +1,68 @@
++/*
++ * Copied from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_MMAN_H__
++#define __NIOS2_MMAN_H__
++
++#define PROT_READ 0x1 /* page can be read */
++#define PROT_WRITE 0x2 /* page can be written */
++#define PROT_EXEC 0x4 /* page can be executed */
++#define PROT_SEM 0x8 /* page may be used for atomic ops */
++#define PROT_NONE 0x0 /* page can not be accessed */
++#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
++#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
++
++#define MAP_SHARED 0x01 /* Share changes */
++#define MAP_PRIVATE 0x02 /* Changes are private */
++#define MAP_TYPE 0x0f /* Mask for type of mapping */
++#define MAP_FIXED 0x10 /* Interpret addr exactly */
++#define MAP_ANONYMOUS 0x20 /* don't use a file */
++
++#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
++#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
++#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
++#define MAP_LOCKED 0x2000 /* pages are locked */
++#define MAP_NORESERVE 0x4000 /* don't check for reservations */
++#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
++#define MAP_NONBLOCK 0x10000 /* do not block on IO */
++
++#define MS_ASYNC 1 /* sync memory asynchronously */
++#define MS_INVALIDATE 2 /* invalidate the caches */
++#define MS_SYNC 4 /* synchronous memory sync */
++
++#define MCL_CURRENT 1 /* lock all current mappings */
++#define MCL_FUTURE 2 /* lock all future mappings */
++
++#define MADV_NORMAL 0x0 /* default page-in behavior */
++#define MADV_RANDOM 0x1 /* page-in minimum required */
++#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
++#define MADV_WILLNEED 0x3 /* pre-fault pages */
++#define MADV_DONTNEED 0x4 /* discard these pages */
++
++/* compatibility flags */
++#define MAP_ANON MAP_ANONYMOUS
++#define MAP_FILE 0
++
++#endif /* __NIOS2_MMAN_H__ */
++
+--- linux/include/asm-nios2nommu/mmu_context.h
++++ linux/include/asm-nios2nommu/mmu_context.h
+@@ -0,0 +1,58 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_CONTEXT_H
++#define __NIOS2NOMMU_MMU_CONTEXT_H
++
++#include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/pgalloc.h>
++
++static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
++{
++}
++
++extern inline int
++init_new_context(struct task_struct *tsk, struct mm_struct *mm)
++{
++ // mm->context = virt_to_phys(mm->pgd);
++ return(0);
++}
++
++#define destroy_context(mm) do { } while(0)
++
++static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
++{
++}
++
++#define deactivate_mm(tsk,mm) do { } while (0)
++
++extern inline void activate_mm(struct mm_struct *prev_mm,
++ struct mm_struct *next_mm)
++{
++}
++
++#endif
+--- linux/include/asm-nios2nommu/mmu.h
++++ linux/include/asm-nios2nommu/mmu.h
+@@ -0,0 +1,36 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_H
++#define __NIOS2NOMMU_MMU_H
++
++/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
++
++typedef struct {
++ struct vm_list_struct *vmlist;
++ unsigned long end_brk;
++} mm_context_t;
++
++#endif /* __NIOS2NOMMU_MMU_H */
+--- linux/include/asm-nios2nommu/module.h
++++ linux/include/asm-nios2nommu/module.h
+@@ -0,0 +1,36 @@
++#ifndef _NIOS2_MODULE_H
++#define _NIOS2_MODULE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/module.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct mod_arch_specific
++{
++};
++
++#define Elf_Shdr Elf32_Shdr
++#define Elf_Sym Elf32_Sym
++#define Elf_Ehdr Elf32_Ehdr
++
++#endif /* _NIOS_MODULE_H */
+--- linux/include/asm-nios2nommu/msgbuf.h
++++ linux/include/asm-nios2nommu/msgbuf.h
+@@ -0,0 +1,56 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_MSGBUF_H
++#define _NIOS2_MSGBUF_H
++
++/*
++ * The msqid64_ds structure for nios2 architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct msqid64_ds {
++ struct ipc64_perm msg_perm;
++ __kernel_time_t msg_stime; /* last msgsnd time */
++ unsigned long __unused1;
++ __kernel_time_t msg_rtime; /* last msgrcv time */
++ unsigned long __unused2;
++ __kernel_time_t msg_ctime; /* last change time */
++ unsigned long __unused3;
++ unsigned long msg_cbytes; /* current number of bytes on queue */
++ unsigned long msg_qnum; /* number of messages in queue */
++ unsigned long msg_qbytes; /* max number of bytes on queue */
++ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
++ __kernel_pid_t msg_lrpid; /* last receive pid */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++#endif /* _NIOS2_MSGBUF_H */
++
+--- linux/include/asm-nios2nommu/namei.h
++++ linux/include/asm-nios2nommu/namei.h
+@@ -0,0 +1,36 @@
++/*
++ * linux/include/asm-nios/namei.h
++ * Moved from m68k version
++ * Included from linux/fs/namei.c
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_NAMEI_H
++#define __NIOS2_NAMEI_H
++
++/* This dummy routine maybe changed to something useful
++ * for /usr/gnemul/ emulation stuff.
++ * Look at asm-sparc/namei.h for details.
++ */
++
++#define __emul_prefix() NULL
++
++#endif
+--- linux/include/asm-nios2nommu/ndma.h
++++ linux/include/asm-nios2nommu/ndma.h
+@@ -0,0 +1,64 @@
++#ifndef __NDMA_H__
++ #define __NDMA_H__
++
++ #ifndef __ASSEMBLY__
++
++// DMA Registers
++typedef volatile struct
++{
++ int np_dmastatus; // status register
++ int np_dmareadaddress; // read address
++ int np_dmawriteaddress; // write address
++ int np_dmalength; // length in bytes
++ int np_dmareserved1; // reserved
++ int np_dmareserved2; // reserved
++ int np_dmacontrol; // control register
++ int np_dmareserved3; // control register alternate
++} np_dma;
++
++// DMA Register Bits
++enum
++{
++ np_dmacontrol_byte_bit = 0, // Byte transaction
++ np_dmacontrol_hw_bit = 1, // Half-word transaction
++ np_dmacontrol_word_bit = 2, // Word transaction
++ np_dmacontrol_go_bit = 3, // enable execution
++ np_dmacontrol_i_en_bit = 4, // enable interrupt
++ np_dmacontrol_reen_bit = 5, // Enable read end-of-packet
++ np_dmacontrol_ween_bit = 6, // Enable write end-of-packet
++ np_dmacontrol_leen_bit = 7, // Enable length=0 transaction end
++ np_dmacontrol_rcon_bit = 8, // Read from a fixed address
++ np_dmacontrol_wcon_bit = 9, // Write to a fixed address
++ np_dmacontrol_doubleword_bit = 10, // Double-word transaction
++ np_dmacontrol_quadword_bit = 11, // Quad-word transaction
++
++ np_dmastatus_done_bit = 0, // 1 when done. Status write clears.
++ np_dmastatus_busy_bit = 1, // 1 when busy.
++ np_dmastatus_reop_bit = 2, // read-eop received
++ np_dmastatus_weop_bit = 3, // write-eop received
++ np_dmastatus_len_bit = 4, // requested length transacted
++
++ np_dmacontrol_byte_mask = (1 << 0), // Byte transaction
++ np_dmacontrol_hw_mask = (1 << 1), // Half-word transaction
++ np_dmacontrol_word_mask = (1 << 2), // Word transaction
++ np_dmacontrol_go_mask = (1 << 3), // enable execution
++ np_dmacontrol_i_en_mask = (1 << 4), // enable interrupt
++ np_dmacontrol_reen_mask = (1 << 5), // Enable read end-of-packet
++ np_dmacontrol_ween_mask = (1 << 6), // Enable write end-of-packet
++ np_dmacontrol_leen_mask = (1 << 7), // Enable length=0 transaction end
++ np_dmacontrol_rcon_mask = (1 << 8), // Read from a fixed address
++ np_dmacontrol_wcon_mask = (1 << 9), // Write to a fixed address
++ np_dmacontrol_doubleword_mask = (1 << 10), // Double-word transaction
++ np_dmacontrol_quadword_mask = (1 << 11), // Quad-word transaction
++
++ np_dmastatus_done_mask = (1 << 0), // 1 when done. Status write clears.
++ np_dmastatus_busy_mask = (1 << 1), // 1 when busy.
++ np_dmastatus_reop_mask = (1 << 2), // read-eop received
++ np_dmastatus_weop_mask = (1 << 3), // write-eop received
++ np_dmastatus_len_mask = (1 << 4), // requested length transacted
++};
++
++ #endif /* __ASSEMBLY__ */
++
++#endif
++/* End of File */
+--- linux/include/asm-nios2nommu/nios.h
++++ linux/include/asm-nios2nommu/nios.h
+@@ -0,0 +1,7 @@
++#ifndef __NIOS_H__
++#define __NIOS_H__
++
++#include "nios2_system.h"
++
++#endif
++
+--- linux/include/asm-nios2nommu/page.h
++++ linux/include/asm-nios2nommu/page.h
+@@ -0,0 +1,135 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_PAGE_H
++#define _NIOS2_PAGE_H
++
++/* copied from m68knommu arch */
++// #include <linux/config.h>
++
++/* PAGE_SHIFT determines the page size */
++
++#define PAGE_SHIFT (12)
++#define PAGE_SIZE (1UL << PAGE_SHIFT)
++#define PAGE_MASK (~(PAGE_SIZE-1))
++
++#ifdef __KERNEL__
++
++#include <asm/setup.h>
++
++#if PAGE_SHIFT < 13
++#define THREAD_SIZE (8192)
++#else
++#define THREAD_SIZE PAGE_SIZE
++#endif
++
++#ifndef __ASSEMBLY__
++
++#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
++#define free_user_page(page, addr) free_page(addr)
++
++#define clear_page(page) memset((page), 0, PAGE_SIZE)
++#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
++
++#define clear_user_page(page, vaddr, pg) clear_page(page)
++#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
++
++/*
++ * These are used to make use of C type-checking..
++ */
++typedef struct { unsigned long pte; } pte_t;
++typedef struct { unsigned long pmd[16]; } pmd_t;
++typedef struct { unsigned long pgd; } pgd_t;
++typedef struct { unsigned long pgprot; } pgprot_t;
++
++#define pte_val(x) ((x).pte)
++#define pmd_val(x) ((&x)->pmd[0])
++#define pgd_val(x) ((x).pgd)
++#define pgprot_val(x) ((x).pgprot)
++
++#define __pte(x) ((pte_t) { (x) } )
++#define __pmd(x) ((pmd_t) { (x) } )
++#define __pgd(x) ((pgd_t) { (x) } )
++#define __pgprot(x) ((pgprot_t) { (x) } )
++
++/* to align the pointer to the (next) page boundary */
++#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
++
++/* Pure 2^n version of get_order */
++extern __inline__ int get_order(unsigned long size)
++{
++ int order;
++
++ size = (size-1) >> (PAGE_SHIFT-1);
++ order = -1;
++ do {
++ size >>= 1;
++ order++;
++ } while (size);
++ return order;
++}
++
++extern unsigned long memory_start;
++extern unsigned long memory_end;
++
++#endif /* !__ASSEMBLY__ */
++#include <asm/nios.h>
++#define PAGE_OFFSET ((int)(nasys_program_mem))
++
++#ifndef __ASSEMBLY__
++
++#define __pa(vaddr) virt_to_phys((void *)vaddr)
++#define __va(paddr) phys_to_virt((unsigned long)paddr)
++
++#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
++
++#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
++#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
++
++#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
++#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
++#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
++
++#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
++#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
++
++#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
++ ((void *)(kaddr) < (void *)memory_end))
++
++#ifdef CONFIG_NO_KERNEL_MSG
++#define BUG_PRINT()
++#else
++#define BUG_PRINT() printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__)
++#endif
++
++#ifdef na_cpu_oci_core
++#define BUG_PANIC() asm volatile ("break") /* drop to debugger */
++#else
++// #define BUG_PANIC() while(1)
++#define BUG_PANIC() panic("BUG!")
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_PAGE_H */
+--- linux/include/asm-nios2nommu/param.h
++++ linux/include/asm-nios2nommu/param.h
+@@ -0,0 +1,49 @@
++#ifndef _NIOS_PARAM_H
++#define _NIOS_PARAM_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/param.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifndef HZ
++#define HZ 100
++#endif
++
++#ifdef __KERNEL__
++#define USER_HZ HZ
++#define CLOCKS_PER_SEC (USER_HZ)
++#endif
++
++#define EXEC_PAGESIZE 4096
++
++#ifndef NGROUPS
++#define NGROUPS 32
++#endif
++
++#ifndef NOGROUP
++#define NOGROUP (-1)
++#endif
++
++#define MAXHOSTNAMELEN 64 /* max length of hostname */
++
++#endif
+--- linux/include/asm-nios2nommu/pci.h
++++ linux/include/asm-nios2nommu/pci.h
+@@ -0,0 +1,75 @@
++#ifndef _ASM_NIOS2NOMMU_PCI_H
++#define _ASM_NIOS2NOMMU_PCI_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pci.h
++ *
++ * Derived from asm-m68k/pci_m68k.h
++ * - m68k specific PCI declarations, by Wout Klaren.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/scatterlist.h>
++
++struct pci_ops;
++
++/*
++ * Structure with hardware dependent information and functions of the
++ * PCI bus.
++ */
++
++struct pci_bus_info
++{
++ /*
++ * Resources of the PCI bus.
++ */
++
++ struct resource mem_space;
++ struct resource io_space;
++
++ /*
++ * System dependent functions.
++ */
++
++ struct pci_ops *m68k_pci_ops;
++
++ void (*fixup)(int pci_modify);
++ void (*conf_device)(struct pci_dev *dev);
++};
++
++#define pcibios_assign_all_busses() 0
++
++extern inline void pcibios_set_master(struct pci_dev *dev)
++{
++ /* No special bus mastering setup handling */
++}
++
++extern inline void pcibios_penalize_isa_irq(int irq)
++{
++ /* We don't do dynamic PCI IRQ allocation */
++}
++
++/* The PCI address space does equal the physical memory
++ * address space. The networking and block device layers use
++ * this boolean for bounce buffer decisions.
++ */
++#define PCI_DMA_BUS_IS_PHYS (1)
++
++#endif /* _ASM_NIOS2NOMMU_PCI_H */
+--- linux/include/asm-nios2nommu/percpu.h
++++ linux/include/asm-nios2nommu/percpu.h
+@@ -0,0 +1,30 @@
++#ifndef __ARCH_NIOS2NOMMU_PERCPU__
++#define __ARCH_NIOS2NOMMU_PERCPU__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/percpu.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/percpu.h>
++
++#endif /* __ARCH_NIOS2NOMMU_PERCPU__ */
+--- linux/include/asm-nios2nommu/pgalloc.h
++++ linux/include/asm-nios2nommu/pgalloc.h
+@@ -0,0 +1,32 @@
++#ifndef _NIOS2NOMMU_PGALLOC_H
++#define _NIOS2NOMMU_PGALLOC_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgalloc.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/setup.h>
++
++#define check_pgt_cache() do { } while (0)
++
++#endif /* _NIOS2NOMMU_PGALLOC_H */
+--- linux/include/asm-nios2nommu/pgtable.h
++++ linux/include/asm-nios2nommu/pgtable.h
+@@ -0,0 +1,104 @@
++#ifndef _NIOS_PGTABLE_H
++#define _NIOS_PGTABLE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgtable.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm-generic/4level-fixup.h>
++
++//vic - this bit copied from m68knommu version
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/io.h>
++
++typedef pte_t *pte_addr_t;
++
++#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
++#define pgd_none(pgd) (0)
++#define pgd_bad(pgd) (0)
++#define pgd_clear(pgdp)
++#define kern_addr_valid(addr) (1)
++#define pmd_offset(a, b) ((void *)0)
++
++#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
++//vic - this bit copied from m68knommu version
++
++extern void paging_init(void);
++#define swapper_pg_dir ((pgd_t *) 0)
++
++#define __swp_type(x) (0)
++#define __swp_offset(x) (0)
++#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
++#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
++#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
++
++static inline int pte_file(pte_t pte) { return 0; }
++
++/*
++ * ZERO_PAGE is a global shared page that is always zero: used
++ * for zero-mapped memory areas etc..
++ */
++#define ZERO_PAGE(vaddr) (virt_to_page(0))
++
++extern unsigned int kobjsize(const void *objp);
++extern int is_in_rom(unsigned long);
++
++/*
++ * No page table caches to initialise
++ */
++#define pgtable_cache_init() do { } while (0)
++#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
++ remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
++
++extern inline void flush_cache_mm(struct mm_struct *mm)
++{
++}
++
++extern inline void flush_cache_range(struct mm_struct *mm,
++ unsigned long start,
++ unsigned long end)
++{
++}
++
++/* Push the page at kernel virtual address and clear the icache */
++extern inline void flush_page_to_ram (unsigned long address)
++{
++}
++
++/* Push n pages at kernel virtual address and clear the icache */
++extern inline void flush_pages_to_ram (unsigned long address, int n)
++{
++}
++
++/*
++ * All 32bit addresses are effectively valid for vmalloc...
++ * Sort of meaningless for non-VM targets.
++ */
++#define VMALLOC_START 0
++#define VMALLOC_END 0xffffffff
++
++#endif /* _NIOS_PGTABLE_H */
+--- linux/include/asm-nios2nommu/pio_struct.h
++++ linux/include/asm-nios2nommu/pio_struct.h
+@@ -0,0 +1,14 @@
++// PIO Peripheral
++
++// PIO Registers
++typedef volatile struct
++ {
++ int np_piodata; // read/write, up to 32 bits
++ int np_piodirection; // write/readable, up to 32 bits, 1->output bit
++ int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
++ int np_pioedgecapture; // read, up to 32 bits, cleared by any write
++ } np_pio;
++
++// PIO Routines
++void nr_pio_showhex(int value); // shows low byte on pio named na_seven_seg_pio
++
+--- linux/include/asm-nios2nommu/poll.h
++++ linux/include/asm-nios2nommu/poll.h
+@@ -0,0 +1,46 @@
++#ifndef __NIOS2_POLL_H
++#define __NIOS2_POLL_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/poll.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define POLLIN 1
++#define POLLPRI 2
++#define POLLOUT 4
++#define POLLERR 8
++#define POLLHUP 16
++#define POLLNVAL 32
++#define POLLRDNORM 64
++#define POLLWRNORM POLLOUT
++#define POLLRDBAND 128
++#define POLLWRBAND 256
++#define POLLMSG 0x0400
++
++struct pollfd {
++ int fd;
++ short events;
++ short revents;
++};
++
++#endif
+--- linux/include/asm-nios2nommu/posix_types.h
++++ linux/include/asm-nios2nommu/posix_types.h
+@@ -0,0 +1,89 @@
++#ifndef __ARCH_NIOS2_POSIX_TYPES_H
++#define __ARCH_NIOS2_POSIX_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/posix_types.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is generally used by user-level software, so you need to
++ * be a little careful about namespace pollution etc. Also, we cannot
++ * assume GCC is being used.
++ */
++
++typedef unsigned long __kernel_ino_t;
++typedef unsigned short __kernel_mode_t;
++typedef unsigned short __kernel_nlink_t;
++typedef long __kernel_off_t;
++typedef int __kernel_pid_t;
++typedef unsigned short __kernel_ipc_pid_t;
++typedef unsigned short __kernel_uid_t;
++typedef unsigned short __kernel_gid_t;
++typedef unsigned int __kernel_size_t;
++typedef int __kernel_ssize_t;
++typedef int __kernel_ptrdiff_t;
++typedef long __kernel_time_t;
++typedef long __kernel_suseconds_t;
++typedef long __kernel_clock_t;
++typedef int __kernel_timer_t;
++typedef int __kernel_clockid_t;
++typedef int __kernel_daddr_t;
++typedef char * __kernel_caddr_t;
++typedef unsigned short __kernel_uid16_t;
++typedef unsigned short __kernel_gid16_t;
++typedef unsigned int __kernel_uid32_t;
++typedef unsigned int __kernel_gid32_t;
++
++typedef unsigned short __kernel_old_uid_t;
++typedef unsigned short __kernel_old_gid_t;
++typedef unsigned short __kernel_old_dev_t;
++
++#ifdef __GNUC__
++typedef long long __kernel_loff_t;
++#endif
++
++typedef struct {
++#if defined(__KERNEL__) || defined(__USE_ALL)
++ int val[2];
++#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++ int __val[2];
++#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++} __kernel_fsid_t;
++
++#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
++
++#undef __FD_SET
++#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
++
++#undef __FD_CLR
++#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
++
++#undef __FD_ISSET
++#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
++
++#undef __FD_ZERO
++#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
++
++#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
++
++#endif
+--- linux/include/asm-nios2nommu/preem_latency.h
++++ linux/include/asm-nios2nommu/preem_latency.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_PREEM_LATENCY_H
++#define _ASM_PREEM_LATENCY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/preem_latency.h
++ *
++ * timing support for preempt-stats patch
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++#define readclock(low) \
++do {\
++ *(volatile unsigned long *)na_Counter_64_bit=1; \
++ low=*(volatile unsigned long *)na_Counter_64_bit; \
++} while (0)
++#define readclock_init()
++
++#endif /* _ASM_PREEM_LATENCY_H */
+--- linux/include/asm-nios2nommu/processor.h
++++ linux/include/asm-nios2nommu/processor.h
+@@ -0,0 +1,148 @@
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/processor.h
++ *
++ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
++ * Vic Phillips (vic@microtronix.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * hacked from:
++ * include/asm-sparc/processor.h
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ * Nov/02/2003 dgt Fix task_size
++ *
++ ---------------------------------------------------------------------*/
++
++#ifndef __ASM_NIOS_PROCESSOR_H
++#define __ASM_NIOS_PROCESSOR_H
++
++#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
++#define NIOS2_FLAG_COPROC 0x00000002 /* Thread used coprocess */
++#define NIOS2_FLAG_DEBUG 0x00000004 /* task is being debugged */
++
++#define NIOS2_OP_NOP 0x1883a
++#define NIOS2_OP_BREAK 0x3da03a
++
++#ifndef __ASSEMBLY__
++
++/*
++ * Default implementation of macro that returns current
++ * instruction pointer ("program counter").
++ */
++#define current_text_addr() ({ __label__ _l; _l: &&_l;})
++
++#include <linux/a.out.h>
++#include <linux/string.h>
++
++#include <asm/ptrace.h>
++#include <asm/signal.h>
++#include <asm/segment.h>
++#include <asm/current.h>
++#include <asm/system.h> /* for get_hi_limit */
++
++/*
++ * Bus types
++ */
++#define EISA_bus 0
++#define EISA_bus__is_a_macro /* for versions in ksyms.c */
++#define MCA_bus 0
++#define MCA_bus__is_a_macro /* for versions in ksyms.c */
++
++/*
++ * The nios has no problems with write protection
++ */
++#define wp_works_ok 1
++#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
++
++/* Whee, this is STACK_TOP and the lowest kernel address too... */
++#if 0
++#define KERNBASE 0x00000000 /* First address the kernel will eventually be */
++#define TASK_SIZE (KERNBASE)
++#define MAX_USER_ADDR TASK_SIZE
++#define MMAP_SEARCH_START (TASK_SIZE/3)
++#endif
++
++#define TASK_SIZE ((unsigned int) nasys_program_mem_end) //...this is better...
++
++/*
++ * This decides where the kernel will search for a free chunk of vm
++ * space during mmap's. We won't be using it
++ */
++#define TASK_UNMAPPED_BASE 0
++
++/* The Nios processor specific thread struct. */
++struct thread_struct {
++ struct pt_regs *kregs;
++
++ /* For signal handling */
++ unsigned long sig_address;
++ unsigned long sig_desc;
++
++ /* Context switch saved kernel state. */
++ unsigned long ksp;
++ unsigned long kpsr;
++ unsigned long kesr;
++
++ /* Flags are defined below */
++
++ unsigned long flags;
++ int current_ds;
++ struct exec core_exec; /* just what it says. */
++};
++
++#define INIT_MMAP { &init_mm, (0), (0), \
++ __pgprot(0x0) , VM_READ | VM_WRITE | VM_EXEC }
++
++#define INIT_THREAD { \
++ .kregs = 0, \
++ .sig_address = 0, \
++ .sig_desc = 0, \
++ .ksp = 0, \
++ .kpsr = 0, \
++ .kesr = PS_S, \
++ .flags = NIOS2_FLAG_KTHREAD, \
++ .current_ds = __KERNEL_DS, \
++ .core_exec = INIT_EXEC \
++}
++
++/* Free all resources held by a thread. */
++extern void release_thread(struct task_struct *);
++
++extern unsigned long thread_saved_pc(struct task_struct *t);
++
++extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
++
++/* Prepare to copy thread state - unlazy all lazy status */
++#define prepare_to_copy(tsk) do { } while (0)
++
++extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
++
++unsigned long get_wchan(struct task_struct *p);
++
++#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
++#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
++
++#ifdef __KERNEL__
++/* Allocation and freeing of basic task resources. */
++
++//;dgt2;#define alloc_task_struct() ((struct task_struct *) xx..see..linux..fork..xx __get_free_pages(GFP_KERNEL,1))
++//;dgt2;#define get_task_struct(tsk) xx..see..linux..sched.h...atomic_inc(&mem_map[MAP_NR(tsk)].count)
++
++#endif
++
++#define cpu_relax() do { } while (0)
++#endif /* __ASSEMBLY__ */
++#endif /* __ASM_NIOS_PROCESSOR_H */
+--- linux/include/asm-nios2nommu/ptrace.h
++++ linux/include/asm-nios2nommu/ptrace.h
+@@ -0,0 +1,141 @@
++/*
++ * Taken from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2NOMMU_PTRACE_H
++#define _NIOS2NOMMU_PTRACE_H
++
++#ifndef __ASSEMBLY__
++
++#define PTR_R0 0
++#define PTR_R1 1
++#define PTR_R2 2
++#define PTR_R3 3
++#define PTR_R4 4
++#define PTR_R5 5
++#define PTR_R6 6
++#define PTR_R7 7
++#define PTR_R8 8
++#define PTR_R9 9
++#define PTR_R10 10
++#define PTR_R11 11
++#define PTR_R12 12
++#define PTR_R13 13
++#define PTR_R14 14
++#define PTR_R15 15
++#define PTR_R16 16
++#define PTR_R17 17
++#define PTR_R18 18
++#define PTR_R19 19
++#define PTR_R20 20
++#define PTR_R21 21
++#define PTR_R22 22
++#define PTR_R23 23
++#define PTR_R24 24
++#define PTR_R25 25
++#define PTR_GP 26
++#define PTR_SP 27
++#define PTR_FP 28
++#define PTR_EA 29
++#define PTR_BA 30
++#define PTR_RA 31
++#define PTR_STATUS 32
++#define PTR_ESTATUS 33
++#define PTR_BSTATUS 34
++#define PTR_IENABLE 35
++#define PTR_IPENDING 36
++
++/* this struct defines the way the registers are stored on the
++ stack during a system call.
++
++ There is a fake_regs in setup.c that has to match pt_regs.*/
++
++struct pt_regs {
++ unsigned long r8;
++ unsigned long r9;
++ unsigned long r10;
++ unsigned long r11;
++ unsigned long r12;
++ unsigned long r13;
++ unsigned long r14;
++ unsigned long r15;
++ unsigned long r1;
++ unsigned long r2;
++ unsigned long r3;
++ unsigned long r4;
++ unsigned long r5;
++ unsigned long r6;
++ unsigned long r7;
++ unsigned long orig_r2;
++ unsigned long ra;
++ unsigned long fp;
++ unsigned long sp;
++ unsigned long gp;
++ unsigned long estatus;
++ unsigned long status_extension;
++ unsigned long ea;
++};
++
++
++/*
++ * This is the extended stack used by signal handlers and the context
++ * switcher: it's pushed after the normal "struct pt_regs".
++ */
++struct switch_stack {
++ unsigned long r16;
++ unsigned long r17;
++ unsigned long r18;
++ unsigned long r19;
++ unsigned long r20;
++ unsigned long r21;
++ unsigned long r22;
++ unsigned long r23;
++ unsigned long fp;
++ unsigned long gp;
++ unsigned long ra;
++};
++
++/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
++#define PTRACE_GETREGS 12
++#define PTRACE_SETREGS 13
++#ifdef CONFIG_FPU
++#define PTRACE_GETFPREGS 14
++#define PTRACE_SETFPREGS 15
++#endif
++
++#ifdef __KERNEL__
++
++#ifndef PS_S
++#define PS_S (0x00000001)
++#endif
++#ifndef PS_T
++#define PS_T (0x00000002)
++#endif
++
++#define user_mode(regs) (!((regs)->status_extension & PS_S))
++#define instruction_pointer(regs) ((regs)->ra)
++#define profile_pc(regs) instruction_pointer(regs)
++extern void show_regs(struct pt_regs *);
++
++#endif /* __KERNEL__ */
++#endif /* __ASSEMBLY__ */
++#endif /* _NIOS2NOMMU_PTRACE_H */
+--- linux/include/asm-nios2nommu/resource.h
++++ linux/include/asm-nios2nommu/resource.h
+@@ -0,0 +1,73 @@
++#ifndef _NIOS2NOMMU_RESOURCE_H
++#define _NIOS2NOMMU_RESOURCE_H
++
++/*--------------------------------------------------------------------
++ *
++ * Resource limits
++ *
++ * include/asm-nios2nommu/resource.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define RLIMIT_CPU 0 /* CPU time in ms */
++#define RLIMIT_FSIZE 1 /* Maximum filesize */
++#define RLIMIT_DATA 2 /* max data size */
++#define RLIMIT_STACK 3 /* max stack size */
++#define RLIMIT_CORE 4 /* max core file size */
++#define RLIMIT_RSS 5 /* max resident set size */
++#define RLIMIT_NPROC 6 /* max number of processes */
++#define RLIMIT_NOFILE 7 /* max number of open files */
++#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
++#define RLIMIT_AS 9 /* address space limit */
++#define RLIMIT_LOCKS 10 /* maximum file locks held */
++#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
++#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
++
++#define RLIM_NLIMITS 13
++
++/*
++ * SuS says limits have to be unsigned.
++ * Which makes a ton more sense anyway.
++ */
++#define RLIM_INFINITY (~0UL)
++
++#ifdef __KERNEL__
++
++#define INIT_RLIMITS \
++{ \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { _STK_LIM, RLIM_INFINITY }, \
++ { 0, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { 0, 0 }, \
++ { INR_OPEN, INR_OPEN }, \
++ { MLOCK_LIMIT, MLOCK_LIMIT }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { MAX_SIGPENDING, MAX_SIGPENDING }, \
++ { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
++}
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2NOMMU_RESOURCE_H */
+--- linux/include/asm-nios2nommu/rmap.h
++++ linux/include/asm-nios2nommu/rmap.h
+@@ -0,0 +1,2 @@
++/* Do not need anything here */
++
+--- linux/include/asm-nios2nommu/scatterlist.h
++++ linux/include/asm-nios2nommu/scatterlist.h
+@@ -0,0 +1,42 @@
++#ifndef _NIOS2NOMMU_SCATTERLIST_H
++#define _NIOS2NOMMU_SCATTERLIST_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/scatterlist.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <linux/mm.h>
++
++struct scatterlist {
++ struct page *page;
++ unsigned int offset;
++ dma_addr_t dma_address;
++ unsigned int length;
++};
++
++#define sg_address(sg) (page_address((sg)->page) + (sg)->offset
++#define sg_dma_address(sg) ((sg)->dma_address)
++#define sg_dma_len(sg) ((sg)->length)
++
++#define ISA_DMA_THRESHOLD (0xffffffff)
++
++#endif /* !(_NIOS2NOMMU_SCATTERLIST_H) */
+--- linux/include/asm-nios2nommu/sections.h
++++ linux/include/asm-nios2nommu/sections.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_SECTIONS_H
++#define _NIOS2NOMMU_SECTIONS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sections.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/sections.h>
++
++#endif /* _NIOS2NOMMU_SECTIONS_H */
+--- linux/include/asm-nios2nommu/segment.h
++++ linux/include/asm-nios2nommu/segment.h
+@@ -0,0 +1,75 @@
++#ifndef _NIOS2NOMMU_SEGMENT_H
++#define _NIOS2NOMMU_SEGMENT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/segment.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* define constants */
++/* Address spaces (FC0-FC2) */
++#define USER_DATA (1)
++#ifndef __USER_DS
++#define __USER_DS (USER_DATA)
++#endif
++#define USER_PROGRAM (2)
++#define SUPER_DATA (5)
++#ifndef __KERNEL_DS
++#define __KERNEL_DS (SUPER_DATA)
++#endif
++#define SUPER_PROGRAM (6)
++#define CPU_SPACE (7)
++
++#ifndef __ASSEMBLY__
++
++typedef struct {
++ unsigned long seg;
++} mm_segment_t;
++
++#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
++#define USER_DS MAKE_MM_SEG(__USER_DS)
++#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
++
++/*
++ * Get/set the SFC/DFC registers for MOVES instructions
++ */
++
++static inline mm_segment_t get_fs(void)
++{
++ return USER_DS;
++}
++
++static inline mm_segment_t get_ds(void)
++{
++ /* return the supervisor data space code */
++ return KERNEL_DS;
++}
++
++static inline void set_fs(mm_segment_t val)
++{
++}
++
++#define segment_eq(a,b) ((a).seg == (b).seg)
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* _NIOS2NOMMU_SEGMENT_H */
+--- linux/include/asm-nios2nommu/semaphore.h
++++ linux/include/asm-nios2nommu/semaphore.h
+@@ -0,0 +1,155 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_H
++#define _NIOS2NOMMU_SEMAPHORE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * Interrupt-safe semaphores..
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define RW_LOCK_BIAS 0x01000000
++
++#ifndef __ASSEMBLY__
++
++#include <linux/linkage.h>
++#include <linux/wait.h>
++#include <linux/spinlock.h>
++#include <linux/rwsem.h>
++
++#include <asm/system.h>
++#include <asm/atomic.h>
++
++struct semaphore {
++ atomic_t count;
++ atomic_t waking;
++ wait_queue_head_t wait;
++};
++
++#define __SEMAPHORE_INITIALIZER(name, n) \
++{ \
++ .count = ATOMIC_INIT(n), \
++ .waking = ATOMIC_INIT(0), \
++ .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
++}
++
++#define __MUTEX_INITIALIZER(name) \
++ __SEMAPHORE_INITIALIZER(name,1)
++
++#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
++ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
++
++#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
++#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
++
++extern inline void sema_init (struct semaphore *sem, int val)
++{
++ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
++}
++
++static inline void init_MUTEX (struct semaphore *sem)
++{
++ sema_init(sem, 1);
++}
++
++static inline void init_MUTEX_LOCKED (struct semaphore *sem)
++{
++ sema_init(sem, 0);
++}
++
++asmlinkage void __down(struct semaphore * sem);
++asmlinkage int __down_interruptible(struct semaphore * sem);
++asmlinkage int __down_trylock(struct semaphore * sem);
++asmlinkage void __up(struct semaphore * sem);
++
++asmlinkage void __down_failed(void /* special register calling convention */);
++asmlinkage int __down_failed_interruptible(void /* params in registers */);
++asmlinkage int __down_failed_trylock(void /* params in registers */);
++asmlinkage void __up_wakeup(void /* special register calling convention */);
++
++extern spinlock_t semaphore_wake_lock;
++
++/*
++ * This is ugly, but we want the default case to fall through.
++ * "down_failed" is a special asm handler that calls the C
++ * routine that actually waits.
++ */
++extern inline void down(struct semaphore * sem)
++{
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if (atomic_dec_return(&sem->count) < 0)
++ __down(sem);
++ #endif
++}
++
++extern inline int down_interruptible(struct semaphore * sem)
++{
++ int ret = 0;
++
++
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if(atomic_dec_return(&sem->count) < 0)
++ ret = __down_interruptible(sem);
++ return ret;
++ #endif
++}
++
++extern inline int down_trylock(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ int ret = 0;
++
++ if (atomic_dec_return (&sem->count) < 0)
++ ret = __down_trylock(sem);
++ return ret;
++ #endif
++}
++
++/*
++ * Note! This is subtle. We jump to wake people up only if
++ * the semaphore was negative (== somebody was waiting on it).
++ * The default case (no contention) will result in NO
++ * jumps for both down() and up().
++ */
++extern inline void up(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "increment memory"....
++ #else
++ if (atomic_inc_return(&sem->count) <= 0)
++ __up(sem);
++ #endif
++}
++
++#endif /* __ASSEMBLY__ */
++
++#endif
+--- linux/include/asm-nios2nommu/semaphore-helper.h
++++ linux/include/asm-nios2nommu/semaphore-helper.h
+@@ -0,0 +1,101 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_HELPER_H
++#define _NIOS2NOMMU_SEMAPHORE_HELPER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * SMP- and interrupt-safe semaphores helper functions.
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++// #include <linux/config.h>
++
++/*
++ * These two _must_ execute atomically wrt each other.
++ */
++static inline void wake_one_more(struct semaphore * sem)
++{
++ atomic_inc(&sem->waking);
++}
++
++static inline int waking_non_zero(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_interruptible:
++ * 1 got the lock
++ * 0 go to sleep
++ * -EINTR interrupted
++ */
++static inline int waking_non_zero_interruptible(struct semaphore *sem,
++ struct task_struct *tsk)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ } else if (signal_pending(tsk)) {
++ atomic_inc(&sem->count);
++ ret = -EINTR;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_trylock:
++ * 1 failed to lock
++ * 0 got the lock
++ */
++static inline int waking_non_zero_trylock(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 1;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 0;
++ } else
++ atomic_inc(&sem->count);
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++#endif
+--- linux/include/asm-nios2nommu/sembuf.h
++++ linux/include/asm-nios2nommu/sembuf.h
+@@ -0,0 +1,48 @@
++#ifndef _NIOS_SEMBUF_H
++#define _NIOS_SEMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sembuf.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct semid64_ds {
++ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
++ __kernel_time_t sem_otime; /* last semop time */
++ unsigned long __unused1;
++ __kernel_time_t sem_ctime; /* last change time */
++ unsigned long __unused2;
++ unsigned long sem_nsems; /* no. of semaphores in array */
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SEMBUF_H */
+--- linux/include/asm-nios2nommu/setup.h
++++ linux/include/asm-nios2nommu/setup.h
+@@ -0,0 +1,31 @@
++/* Copied from i386 port.
++ * Just a place holder. We don't want to have to test x86 before
++ * we include stuff
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SETUP_H
++#define _NIOS2_SETUP_H
++
++#define COMMAND_LINE_SIZE 512
++
++#endif /* _NIOS2_SETUP_H */
+--- linux/include/asm-nios2nommu/shmbuf.h
++++ linux/include/asm-nios2nommu/shmbuf.h
+@@ -0,0 +1,64 @@
++#ifndef _NIOS_SHMBUF_H
++#define _NIOS_SHMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmbuf.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct shmid64_ds {
++ struct ipc64_perm shm_perm; /* operation perms */
++ size_t shm_segsz; /* size of segment (bytes) */
++ __kernel_time_t shm_atime; /* last attach time */
++ unsigned long __unused1;
++ __kernel_time_t shm_dtime; /* last detach time */
++ unsigned long __unused2;
++ __kernel_time_t shm_ctime; /* last change time */
++ unsigned long __unused3;
++ __kernel_pid_t shm_cpid; /* pid of creator */
++ __kernel_pid_t shm_lpid; /* pid of last operator */
++ unsigned long shm_nattch; /* no. of current attaches */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++struct shminfo64 {
++ unsigned long shmmax;
++ unsigned long shmmin;
++ unsigned long shmmni;
++ unsigned long shmseg;
++ unsigned long shmall;
++ unsigned long __unused1;
++ unsigned long __unused2;
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SHMBUF_H */
+--- linux/include/asm-nios2nommu/shmparam.h
++++ linux/include/asm-nios2nommu/shmparam.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS2NOMMU_SHMPARAM_H__
++#define __NIOS2NOMMU_SHMPARAM_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmparam.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
++
++#endif /* __NIOS2NOMMU_SHMPARAM_H__ */
+--- linux/include/asm-nios2nommu/sigcontext.h
++++ linux/include/asm-nios2nommu/sigcontext.h
+@@ -0,0 +1,35 @@
++/*
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_SIGCONTEXT_H
++#define _ASM_NIOS2NOMMU_SIGCONTEXT_H
++
++#include <asm/ptrace.h>
++
++struct sigcontext {
++ struct pt_regs regs;
++ unsigned long sc_mask; /* old sigmask */
++};
++
++#endif
+--- linux/include/asm-nios2nommu/siginfo.h
++++ linux/include/asm-nios2nommu/siginfo.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SIGINFO_H
++#define _NIOS2NOMMU_SIGINFO_H
++
++#include <asm-generic/siginfo.h>
++
++#endif
+--- linux/include/asm-nios2nommu/signal.h
++++ linux/include/asm-nios2nommu/signal.h
+@@ -0,0 +1,207 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SIGNAL_H
++#define _NIOS2_SIGNAL_H
++
++#include <linux/types.h>
++
++/* Avoid too many header ordering problems. */
++struct siginfo;
++
++#ifdef __KERNEL__
++/* Most things should be clean enough to redefine this at will, if care
++ is taken to make libc match. */
++
++#define _NSIG 64
++#define _NSIG_BPW 32
++#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
++
++typedef unsigned long old_sigset_t; /* at least 32 bits */
++
++typedef struct {
++ unsigned long sig[_NSIG_WORDS];
++} sigset_t;
++
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++#define NSIG 32
++typedef unsigned long sigset_t;
++
++#endif /* __KERNEL__ */
++
++#define SIGHUP 1
++#define SIGINT 2
++#define SIGQUIT 3
++#define SIGILL 4
++#define SIGTRAP 5
++#define SIGABRT 6
++#define SIGIOT 6
++#define SIGBUS 7
++#define SIGFPE 8
++#define SIGKILL 9
++#define SIGUSR1 10
++#define SIGSEGV 11
++#define SIGUSR2 12
++#define SIGPIPE 13
++#define SIGALRM 14
++#define SIGTERM 15
++#define SIGSTKFLT 16
++#define SIGCHLD 17
++#define SIGCONT 18
++#define SIGSTOP 19
++#define SIGTSTP 20
++#define SIGTTIN 21
++#define SIGTTOU 22
++#define SIGURG 23
++#define SIGXCPU 24
++#define SIGXFSZ 25
++#define SIGVTALRM 26
++#define SIGPROF 27
++#define SIGWINCH 28
++#define SIGIO 29
++#define SIGPOLL SIGIO
++/*
++#define SIGLOST 29
++*/
++#define SIGPWR 30
++#define SIGSYS 31
++#define SIGUNUSED 31
++
++/* These should not be considered constants from userland. */
++#define SIGRTMIN 32
++#define SIGRTMAX _NSIG-1
++
++/*
++ * SA_FLAGS values:
++ *
++ * SA_ONSTACK indicates that a registered stack_t will be used.
++ * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
++ * SA_RESTART flag to get restarting signals (which were the default long ago)
++ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
++ * SA_RESETHAND clears the handler when the signal is delivered.
++ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
++ * SA_NODEFER prevents the current signal from being masked in the handler.
++ *
++ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
++ * Unix names RESETHAND and NODEFER respectively.
++ */
++#define SA_NOCLDSTOP 0x00000001
++#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
++#define SA_SIGINFO 0x00000004
++#define SA_ONSTACK 0x08000000
++#define SA_RESTART 0x10000000
++#define SA_NODEFER 0x40000000
++#define SA_RESETHAND 0x80000000
++
++#define SA_NOMASK SA_NODEFER
++#define SA_ONESHOT SA_RESETHAND
++#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
++
++#define SA_RESTORER 0x04000000
++
++/*
++ * sigaltstack controls
++ */
++#define SS_ONSTACK 1
++#define SS_DISABLE 2
++
++#define MINSIGSTKSZ 2048
++#define SIGSTKSZ 8192
++
++#ifdef __KERNEL__
++/*
++ * These values of sa_flags are used only by the kernel as part of the
++ * irq handling routines.
++ *
++ * SA_INTERRUPT is also used by the irq handling routines.
++ * SA_SHIRQ is for shared interrupt support on PCI and EISA.
++ */
++#define SA_PROBE SA_ONESHOT
++#define SA_SAMPLE_RANDOM SA_RESTART
++#define SA_SHIRQ 0x04000000
++#endif
++
++#define SIG_BLOCK 0 /* for blocking signals */
++#define SIG_UNBLOCK 1 /* for unblocking signals */
++#define SIG_SETMASK 2 /* for setting the signal mask */
++
++/* Type of a signal handler. */
++typedef void (*__sighandler_t)(int);
++
++#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
++#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
++#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
++
++#ifdef __KERNEL__
++struct old_sigaction {
++ __sighandler_t sa_handler;
++ old_sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++struct sigaction {
++ __sighandler_t sa_handler;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++ sigset_t sa_mask; /* mask last for extensibility */
++};
++
++struct k_sigaction {
++ struct sigaction sa;
++};
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++struct sigaction {
++ union {
++ __sighandler_t _sa_handler;
++ void (*_sa_sigaction)(int, struct siginfo *, void *);
++ } _u;
++ sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++#define sa_handler _u._sa_handler
++#define sa_sigaction _u._sa_sigaction
++
++#endif /* __KERNEL__ */
++
++typedef struct sigaltstack {
++ void *ss_sp;
++ int ss_flags;
++ size_t ss_size;
++} stack_t;
++
++#ifdef __KERNEL__
++
++#include <asm/sigcontext.h>
++#undef __HAVE_ARCH_SIG_BITOPS
++
++#define ptrace_signal_deliver(regs, cookie) do { } while (0)
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_SIGNAL_H */
+--- linux/include/asm-nios2nommu/smp.h
++++ linux/include/asm-nios2nommu/smp.h
+@@ -0,0 +1,34 @@
++#ifndef __ASM_SMP_H
++#define __ASM_SMP_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/smp.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++// #include <linux/config.h>
++
++#ifdef CONFIG_SMP
++#error SMP not supported
++#endif
++
++#endif
+--- linux/include/asm-nios2nommu/socket.h
++++ linux/include/asm-nios2nommu/socket.h
+@@ -0,0 +1,74 @@
++#ifndef _ASM_SOCKET_H
++#define _ASM_SOCKET_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/socket.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/sockios.h>
++
++/* For setsockopt(2) */
++#define SOL_SOCKET 1
++
++#define SO_DEBUG 1
++#define SO_REUSEADDR 2
++#define SO_TYPE 3
++#define SO_ERROR 4
++#define SO_DONTROUTE 5
++#define SO_BROADCAST 6
++#define SO_SNDBUF 7
++#define SO_RCVBUF 8
++#define SO_KEEPALIVE 9
++#define SO_OOBINLINE 10
++#define SO_NO_CHECK 11
++#define SO_PRIORITY 12
++#define SO_LINGER 13
++#define SO_BSDCOMPAT 14
++/* To add :#define SO_REUSEPORT 15 */
++#define SO_PASSCRED 16
++#define SO_PEERCRED 17
++#define SO_RCVLOWAT 18
++#define SO_SNDLOWAT 19
++#define SO_RCVTIMEO 20
++#define SO_SNDTIMEO 21
++
++/* Security levels - as per NRL IPv6 - don't actually do anything */
++#define SO_SECURITY_AUTHENTICATION 22
++#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
++#define SO_SECURITY_ENCRYPTION_NETWORK 24
++
++#define SO_BINDTODEVICE 25
++
++/* Socket filtering */
++#define SO_ATTACH_FILTER 26
++#define SO_DETACH_FILTER 27
++
++#define SO_PEERNAME 28
++#define SO_TIMESTAMP 29
++#define SCM_TIMESTAMP SO_TIMESTAMP
++
++#define SO_ACCEPTCONN 30
++
++#define SO_PEERSEC 31 /* ;dgt2;tmp; */
++
++#endif /* _ASM_SOCKET_H */
+--- linux/include/asm-nios2nommu/sockios.h
++++ linux/include/asm-nios2nommu/sockios.h
+@@ -0,0 +1,38 @@
++#ifndef _ASM_NIOS_SOCKIOS_H
++#define _ASM_NIOS_SOCKIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sockios.h
++ *
++ * Socket-level I/O control calls.
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define FIOSETOWN 0x8901
++#define SIOCSPGRP 0x8902
++#define FIOGETOWN 0x8903
++#define SIOCGPGRP 0x8904
++#define SIOCATMARK 0x8905
++#define SIOCGSTAMP 0x8906 /* Get stamp */
++
++#endif /* !(_ASM_NIOS_SOCKIOS_H) */
++
+--- linux/include/asm-nios2nommu/spi.h
++++ linux/include/asm-nios2nommu/spi.h
+@@ -0,0 +1,92 @@
++#ifndef _ASM_SPI_H_
++#define _ASM_SPI_H_ 1
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spi.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++int register_NIOS_SPI( void );
++void unregister_NIOS_SPI( void );
++
++#if defined(MODULE)
++void cleanup_module( void );
++int init_module( void );
++#endif
++
++#if defined(__KERNEL__)
++int spi_reset ( void );
++#endif
++
++
++#define clockCS 0x01
++#define temperatureCS 0x02
++
++#define clock_read_base 0x00
++#define clock_write_base 0x80
++#define clock_read_control 0x0F
++#define clock_read_trickle 0x11
++
++#define clock_read_sec 0x00
++#define clock_read_min 0x01
++#define clock_read_hour 0x02
++#define clock_read_day 0x03
++#define clock_read_date 0x04
++#define clock_read_month 0x05
++#define clock_read_year 0x06
++
++#define clock_write_control 0x8F
++#define clock_write_trickle 0x91
++#define clock_write_sec 0x80
++#define clock_write_min 0x81
++#define clock_write_hour 0x82
++#define clock_write_day 0x83
++#define clock_write_date 0x84
++#define clock_write_month 0x85
++#define clock_write_year 0x86
++
++#define clock_write_ram_start 0xA0
++#define clock_write_ram_end 0x100
++#define clock_read_ram_start 0x20
++#define clock_read_ram_end 0x80
++
++
++#define clock_sec_def 0x11
++#define clock_min_def 0x59
++#define clock_hour_def 0x71
++#define clock_day_def 0x00
++#define clock_date_def 0x20
++#define clock_month_def 0x12
++#define clock_year_def 0x34
++
++#define temp_read_base 0x00
++#define temp_write_base 0x80
++#define temp_read_control 0x00
++#define temp_write_control 0x80
++#define temp_read_msb 0x02
++#define temp_read_lsb 0x01
++
++#define MAX_TEMP_VAR 10
++
++#endif /*_ASM_SPI_H_*/
+--- linux/include/asm-nios2nommu/spinlock.h
++++ linux/include/asm-nios2nommu/spinlock.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS_SPINLOCK_H
++#define __NIOS_SPINLOCK_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spinlock.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#error "Nios doesn't do SMP yet"
++
++#endif
+--- linux/include/asm-nios2nommu/spi_struct.h
++++ linux/include/asm-nios2nommu/spi_struct.h
+@@ -0,0 +1,57 @@
++// SPI Registers
++typedef volatile struct
++ {
++ int np_spirxdata; // Read-only, 1-16 bit
++ int np_spitxdata; // Write-only, same width as rxdata
++ int np_spistatus; // Read-only, 9-bit
++ int np_spicontrol; // Read/Write, 9-bit
++ int np_spireserved; // reserved
++ int np_spislaveselect; // Read/Write, 1-16 bit, master only
++ int np_spiendofpacket; // Read/write, same width as txdata, rxdata.
++ } np_spi;
++
++// SPI Status Register Bits
++enum
++ {
++ np_spistatus_eop_bit = 9,
++ np_spistatus_e_bit = 8,
++ np_spistatus_rrdy_bit = 7,
++ np_spistatus_trdy_bit = 6,
++ np_spistatus_tmt_bit = 5,
++ np_spistatus_toe_bit = 4,
++ np_spistatus_roe_bit = 3,
++
++ np_spistatus_eop_mask = (1 << 9),
++ np_spistatus_e_mask = (1 << 8),
++ np_spistatus_rrdy_mask = (1 << 7),
++ np_spistatus_trdy_mask = (1 << 6),
++ np_spistatus_tmt_mask = (1 << 5),
++ np_spistatus_toe_mask = (1 << 4),
++ np_spistatus_roe_mask = (1 << 3),
++ };
++
++// SPI Control Register Bits
++enum
++ {
++ np_spicontrol_sso_bit = 10,
++ np_spicontrol_ieop_bit = 9,
++ np_spicontrol_ie_bit = 8,
++ np_spicontrol_irrdy_bit = 7,
++ np_spicontrol_itrdy_bit = 6,
++ np_spicontrol_itoe_bit = 4,
++ np_spicontrol_iroe_bit = 3,
++
++ np_spicontrol_sso_mask = (1 << 10),
++ np_spicontrol_ieop_mask = (1 << 9),
++ np_spicontrol_ie_mask = (1 << 8),
++ np_spicontrol_irrdy_mask = (1 << 7),
++ np_spicontrol_itrdy_mask = (1 << 6),
++ np_spicontrol_itoe_mask = (1 << 4),
++ np_spicontrol_iroe_mask = (1 << 3),
++ };
++
++// SPI Routines.
++int nr_spi_rxchar(np_spi *spiBase);
++int nr_spi_txchar(int i, np_spi *spiBase);
++
++
+--- linux/include/asm-nios2nommu/statfs.h
++++ linux/include/asm-nios2nommu/statfs.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_STATFS_H
++#define _NIOS2NOMMU_STATFS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/statfs.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/statfs.h>
++
++#endif /* _NIOS2NOMMU_STATFS_H */
+--- linux/include/asm-nios2nommu/stat.h
++++ linux/include/asm-nios2nommu/stat.h
+@@ -0,0 +1,102 @@
++#ifndef _ASMNIOS2NOMMU_STAT_H
++#define _ASMNIOS2NOMMU_STAT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/stat.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct __old_kernel_stat {
++ unsigned short st_dev;
++ unsigned short st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned long st_size;
++ unsigned long st_atime;
++ unsigned long st_mtime;
++ unsigned long st_ctime;
++};
++
++struct stat {
++ unsigned short st_dev;
++ unsigned short __pad1;
++ unsigned long st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned short __pad2;
++ unsigned long st_size;
++ unsigned long st_blksize;
++ unsigned long st_blocks;
++ unsigned long st_atime;
++ unsigned long __unused1;
++ unsigned long st_mtime;
++ unsigned long __unused2;
++ unsigned long st_ctime;
++ unsigned long __unused3;
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++/* This matches struct stat64 in glibc2.1, hence the absolutely
++ * insane amounts of padding around dev_t's.
++ */
++struct stat64 {
++ unsigned long long st_dev;
++ unsigned char __pad1[4];
++
++#define STAT64_HAS_BROKEN_ST_INO 1
++ unsigned long __st_ino;
++
++ unsigned int st_mode;
++ unsigned int st_nlink;
++
++ unsigned long st_uid;
++ unsigned long st_gid;
++
++ unsigned long long st_rdev;
++ unsigned char __pad3[4];
++
++ long long st_size;
++ unsigned long st_blksize;
++
++ unsigned long __pad4; /* future possible st_blocks high bits */
++ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
++
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++
++ unsigned long long st_ino;
++};
++
++#endif
+--- linux/include/asm-nios2nommu/string.h
++++ linux/include/asm-nios2nommu/string.h
+@@ -0,0 +1,45 @@
++#ifndef __NIOS_STRING_H__
++#define __NIOS_STRING_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/string.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef __KERNEL__ /* only set these up for kernel code */
++
++#define __HAVE_ARCH_MEMMOVE
++void * memmove(void * d, const void * s, size_t count);
++#define __HAVE_ARCH_MEMCPY
++extern void * memcpy(void *d, const void *s, size_t count);
++#define __HAVE_ARCH_MEMSET
++extern void * memset(void * s,int c,size_t count);
++
++#if 0
++#define __HAVE_ARCH_BCOPY
++#define __HAVE_ARCH_STRLEN
++#endif
++
++#endif /* KERNEL */
++
++#endif /* !(__NIOS_STRING_H__) */
+--- linux/include/asm-nios2nommu/system.h
++++ linux/include/asm-nios2nommu/system.h
+@@ -0,0 +1,172 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SYSTEM_H
++#define _NIOS2NOMMU_SYSTEM_H
++
++// #include <linux/config.h> /* get configuration macros */
++#include <linux/linkage.h>
++#include <asm/segment.h>
++#include <asm/entry.h>
++#include <asm/nios.h>
++
++/*
++ * switch_to(n) should switch tasks to task ptr, first checking that
++ * ptr isn't the current task, in which case it does nothing. This
++ * also clears the TS-flag if the task we switched to has used the
++ * math co-processor latest.
++ */
++
++/*
++ */
++asmlinkage void resume(void);
++#define switch_to(prev,next,last) \
++{ \
++ void *_last; \
++ __asm__ __volatile__( \
++ "mov r4, %1\n" \
++ "mov r5, %2\n" \
++ "call resume\n" \
++ "mov %0,r4\n" \
++ : "=r" (_last) \
++ : "r" (prev), "r" (next) \
++ : "r4","r5","r7","r8","ra"); \
++ (last) = _last; \
++}
++
++#define local_irq_enable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "ori r8, r8, 1\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_irq_disable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "andi r8, r8, 0xfffe\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_save_flags(x) __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "mov %0, r8\n" \
++ :"=r" (x) : : "r8", "memory")
++
++#define local_irq_restore(x) __asm__ __volatile__ ( \
++ "mov r8, %0\n" \
++ "wrctl status, r8\n" \
++ : :"r" (x) : "memory")
++
++/* For spinlocks etc */
++#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
++
++#define irqs_disabled() \
++({ \
++ unsigned long flags; \
++ local_save_flags(flags); \
++ ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
++})
++
++#define iret() __asm__ __volatile__ ("eret": : :"memory", "ea")
++
++/*
++ * Force strict CPU ordering.
++ * Not really required on m68k...
++ */
++#define nop() asm volatile ("nop"::)
++#define mb() asm volatile ("" : : :"memory")
++#define rmb() asm volatile ("" : : :"memory")
++#define wmb() asm volatile ("" : : :"memory")
++#define set_rmb(var, value) do { xchg(&var, value); } while (0)
++#define set_mb(var, value) set_rmb(var, value)
++#define set_wmb(var, value) do { var = value; wmb(); } while (0)
++
++#ifdef CONFIG_SMP
++#define smp_mb() mb()
++#define smp_rmb() rmb()
++#define smp_wmb() wmb()
++#define smp_read_barrier_depends() read_barrier_depends()
++#else
++#define smp_mb() barrier()
++#define smp_rmb() barrier()
++#define smp_wmb() barrier()
++#define smp_read_barrier_depends() do { } while(0)
++#endif
++
++#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
++#define tas(ptr) (xchg((ptr),1))
++
++struct __xchg_dummy { unsigned long a[100]; };
++#define __xg(x) ((volatile struct __xchg_dummy *)(x))
++
++static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
++{
++ unsigned long tmp, flags;
++
++ local_irq_save(flags);
++
++ switch (size) {
++ case 1:
++ __asm__ __volatile__( \
++ "ldb %0, %2\n" \
++ "stb %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 2:
++ __asm__ __volatile__( \
++ "ldh %0, %2\n" \
++ "sth %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 4:
++ __asm__ __volatile__( \
++ "ldw %0, %2\n" \
++ "stw %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ }
++ local_irq_restore(flags);
++ return tmp;
++}
++
++/*
++ * Atomic compare and exchange. Compare OLD with MEM, if identical,
++ * store NEW in MEM. Return the initial value in MEM. Success is
++ * indicated by comparing RETURN with OLD.
++ */
++#define __HAVE_ARCH_CMPXCHG 1
++
++static __inline__ unsigned long
++cmpxchg(volatile int *p, int old, int new)
++{
++ unsigned long flags;
++ int prev;
++
++ local_irq_save(flags);
++ if ((prev = *p) == old)
++ *p = new;
++ local_irq_restore(flags);
++ return(prev);
++}
++
++#endif /* _NIOS2NOMMU_SYSTEM_H */
+--- linux/include/asm-nios2nommu/termbits.h
++++ linux/include/asm-nios2nommu/termbits.h
+@@ -0,0 +1,199 @@
++#ifndef __ARCH_NIOS_TERMBITS_H__
++#define __ARCH_NIOS_TERMBITS_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termbits.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/posix_types.h>
++
++typedef unsigned char cc_t;
++typedef unsigned int speed_t;
++typedef unsigned int tcflag_t;
++
++#define NCCS 19
++struct termios {
++ tcflag_t c_iflag; /* input mode flags */
++ tcflag_t c_oflag; /* output mode flags */
++ tcflag_t c_cflag; /* control mode flags */
++ tcflag_t c_lflag; /* local mode flags */
++ cc_t c_line; /* line discipline */
++ cc_t c_cc[NCCS]; /* control characters */
++};
++
++/* c_cc characters */
++#define VINTR 0
++#define VQUIT 1
++#define VERASE 2
++#define VKILL 3
++#define VEOF 4
++#define VTIME 5
++#define VMIN 6
++#define VSWTC 7
++#define VSTART 8
++#define VSTOP 9
++#define VSUSP 10
++#define VEOL 11
++#define VREPRINT 12
++#define VDISCARD 13
++#define VWERASE 14
++#define VLNEXT 15
++#define VEOL2 16
++
++
++/* c_iflag bits */
++#define IGNBRK 0000001
++#define BRKINT 0000002
++#define IGNPAR 0000004
++#define PARMRK 0000010
++#define INPCK 0000020
++#define ISTRIP 0000040
++#define INLCR 0000100
++#define IGNCR 0000200
++#define ICRNL 0000400
++#define IUCLC 0001000
++#define IXON 0002000
++#define IXANY 0004000
++#define IXOFF 0010000
++#define IMAXBEL 0020000
++#define IUTF8 0040000
++
++/* c_oflag bits */
++#define OPOST 0000001
++#define OLCUC 0000002
++#define ONLCR 0000004
++#define OCRNL 0000010
++#define ONOCR 0000020
++#define ONLRET 0000040
++#define OFILL 0000100
++#define OFDEL 0000200
++#define NLDLY 0000400
++#define NL0 0000000
++#define NL1 0000400
++#define CRDLY 0003000
++#define CR0 0000000
++#define CR1 0001000
++#define CR2 0002000
++#define CR3 0003000
++#define TABDLY 0014000
++#define TAB0 0000000
++#define TAB1 0004000
++#define TAB2 0010000
++#define TAB3 0014000
++#define XTABS 0014000
++#define BSDLY 0020000
++#define BS0 0000000
++#define BS1 0020000
++#define VTDLY 0040000
++#define VT0 0000000
++#define VT1 0040000
++#define FFDLY 0100000
++#define FF0 0000000
++#define FF1 0100000
++
++/* c_cflag bit meaning */
++#define CBAUD 0010017
++#define B0 0000000 /* hang up */
++#define B50 0000001
++#define B75 0000002
++#define B110 0000003
++#define B134 0000004
++#define B150 0000005
++#define B200 0000006
++#define B300 0000007
++#define B600 0000010
++#define B1200 0000011
++#define B1800 0000012
++#define B2400 0000013
++#define B4800 0000014
++#define B9600 0000015
++#define B19200 0000016
++#define B38400 0000017
++#define EXTA B19200
++#define EXTB B38400
++#define CSIZE 0000060
++#define CS5 0000000
++#define CS6 0000020
++#define CS7 0000040
++#define CS8 0000060
++#define CSTOPB 0000100
++#define CREAD 0000200
++#define PARENB 0000400
++#define PARODD 0001000
++#define HUPCL 0002000
++#define CLOCAL 0004000
++#define CBAUDEX 0010000
++#define B57600 0010001
++#define B115200 0010002
++#define B230400 0010003
++#define B460800 0010004
++#define B500000 0010005
++#define B576000 0010006
++#define B921600 0010007
++#define B1000000 0010010
++#define B1152000 0010011
++#define B1500000 0010012
++#define B2000000 0010013
++#define B2500000 0010014
++#define B3000000 0010015
++#define B3500000 0010016
++#define B4000000 0010017
++#define CIBAUD 002003600000 /* input baud rate (not used) */
++#define CMSPAR 010000000000 /* mark or space (stick) parity */
++#define CRTSCTS 020000000000 /* flow control */
++
++/* c_lflag bits */
++#define ISIG 0000001
++#define ICANON 0000002
++#define XCASE 0000004
++#define ECHO 0000010
++#define ECHOE 0000020
++#define ECHOK 0000040
++#define ECHONL 0000100
++#define NOFLSH 0000200
++#define TOSTOP 0000400
++#define ECHOCTL 0001000
++#define ECHOPRT 0002000
++#define ECHOKE 0004000
++#define FLUSHO 0010000
++#define PENDIN 0040000
++#define IEXTEN 0100000
++
++
++/* tcflow() and TCXONC use these */
++#define TCOOFF 0
++#define TCOON 1
++#define TCIOFF 2
++#define TCION 3
++
++/* tcflush() and TCFLSH use these */
++#define TCIFLUSH 0
++#define TCOFLUSH 1
++#define TCIOFLUSH 2
++
++/* tcsetattr uses these */
++#define TCSANOW 0
++#define TCSADRAIN 1
++#define TCSAFLUSH 2
++
++#endif /* __ARCH_NIOS_TERMBITS_H__ */
+--- linux/include/asm-nios2nommu/termios.h
++++ linux/include/asm-nios2nommu/termios.h
+@@ -0,0 +1,132 @@
++#ifndef _NIOS_TERMIOS_H
++#define _NIOS_TERMIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termios.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/termbits.h>
++#include <asm/ioctls.h>
++
++struct winsize {
++ unsigned short ws_row;
++ unsigned short ws_col;
++ unsigned short ws_xpixel;
++ unsigned short ws_ypixel;
++};
++
++#define NCC 8
++struct termio {
++ unsigned short c_iflag; /* input mode flags */
++ unsigned short c_oflag; /* output mode flags */
++ unsigned short c_cflag; /* control mode flags */
++ unsigned short c_lflag; /* local mode flags */
++ unsigned char c_line; /* line discipline */
++ unsigned char c_cc[NCC]; /* control characters */
++};
++
++#ifdef __KERNEL__
++/* intr=^C quit=^| erase=del kill=^U
++ eof=^D vtime=\0 vmin=\1 sxtc=\0
++ start=^Q stop=^S susp=^Z eol=\0
++ reprint=^R discard=^U werase=^W lnext=^V
++ eol2=\0
++*/
++#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
++#endif
++
++/* modem lines */
++#define TIOCM_LE 0x001
++#define TIOCM_DTR 0x002
++#define TIOCM_RTS 0x004
++#define TIOCM_ST 0x008
++#define TIOCM_SR 0x010
++#define TIOCM_CTS 0x020
++#define TIOCM_CAR 0x040
++#define TIOCM_RNG 0x080
++#define TIOCM_DSR 0x100
++#define TIOCM_CD TIOCM_CAR
++#define TIOCM_RI TIOCM_RNG
++#define TIOCM_OUT1 0x2000
++#define TIOCM_OUT2 0x4000
++#define TIOCM_LOOP 0x8000
++
++/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
++
++/* line disciplines */
++#define N_TTY 0
++#define N_SLIP 1
++#define N_MOUSE 2
++#define N_PPP 3
++#define N_STRIP 4
++#define N_AX25 5
++#define N_X25 6 /* X.25 async */
++#define N_6PACK 7
++#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
++#define N_R3964 9 /* Reserved for Simatic R3964 module */
++#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
++#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
++#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
++#define N_HDLC 13 /* synchronous HDLC */
++#define N_SYNC_PPP 14
++#define N_HCI 15 /* Bluetooth HCI UART */
++
++#ifdef __KERNEL__
++
++/*
++ * Translate a "termio" structure into a "termios". Ugh.
++ */
++#define user_termio_to_kernel_termios(termios, termio) \
++({ \
++ unsigned short tmp; \
++ get_user(tmp, &(termio)->c_iflag); \
++ (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
++ get_user(tmp, &(termio)->c_oflag); \
++ (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
++ get_user(tmp, &(termio)->c_cflag); \
++ (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
++ get_user(tmp, &(termio)->c_lflag); \
++ (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
++ get_user((termios)->c_line, &(termio)->c_line); \
++ copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
++})
++
++/*
++ * Translate a "termios" structure into a "termio". Ugh.
++ */
++#define kernel_termios_to_user_termio(termio, termios) \
++({ \
++ put_user((termios)->c_iflag, &(termio)->c_iflag); \
++ put_user((termios)->c_oflag, &(termio)->c_oflag); \
++ put_user((termios)->c_cflag, &(termio)->c_cflag); \
++ put_user((termios)->c_lflag, &(termio)->c_lflag); \
++ put_user((termios)->c_line, &(termio)->c_line); \
++ copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
++})
++
++#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
++#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TERMIOS_H */
+--- linux/include/asm-nios2nommu/thread_info.h
++++ linux/include/asm-nios2nommu/thread_info.h
+@@ -0,0 +1,127 @@
++/* thread_info.h: niosnommu low-level thread information
++ * adapted from the m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2002 Microtronix Datacom
++ *
++ * - Incorporating suggestions made by Linus Torvalds and Dave Miller
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_THREAD_INFO_H
++#define _ASM_THREAD_INFO_H
++
++#include <asm/page.h>
++
++#ifdef __KERNEL__
++
++#ifndef __ASSEMBLY__
++
++/*
++ * low level task data.
++ */
++struct thread_info {
++ struct task_struct *task; /* main task structure */
++ struct exec_domain *exec_domain; /* execution domain */
++ unsigned long flags; /* low level flags */
++ int cpu; /* cpu we're on */
++ int preempt_count; /* 0 => preemptable, <0 => BUG*/
++ struct restart_block restart_block;
++};
++
++/*
++ * macros/functions for gaining access to the thread information structure
++ */
++#define INIT_THREAD_INFO(tsk) \
++{ \
++ .task = &tsk, \
++ .exec_domain = &default_exec_domain, \
++ .flags = 0, \
++ .cpu = 0, \
++ .preempt_count = 1, \
++ .restart_block = { \
++ .fn = do_no_restart_syscall, \
++ }, \
++}
++
++#define init_thread_info (init_thread_union.thread_info)
++#define init_stack (init_thread_union.stack)
++
++
++/* how to get the thread information struct from C
++ usable only in supervisor mode */
++static inline struct thread_info *current_thread_info(void)
++{
++ struct thread_info *ti;
++ __asm__ __volatile__(
++ "mov %0, sp\n"
++ "and %0, %0, %1\n"
++ : "=&r"(ti)
++ : "r" (~(THREAD_SIZE-1))
++ );
++ return ti;
++}
++
++/* thread information allocation */
++#define alloc_thread_info(tsk) ((struct thread_info *) \
++ __get_free_pages(GFP_KERNEL, 1))
++#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
++#define put_thread_info(ti) put_task_struct((ti)->task)
++
++#define PREEMPT_ACTIVE 0x4000000
++
++/*
++ * thread information flag bit numbers
++ */
++#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
++#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
++#define TIF_SIGPENDING 2 /* signal pending */
++#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
++#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
++ TIF_NEED_RESCHED */
++#define TIF_MEMDIE 5
++
++/* as above, but as bit values */
++#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
++#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
++#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
++#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
++#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
++
++#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
++
++#else /* __ASSEMBLY__ */
++
++/* how to get the thread information struct from ASM
++ usable only in supervisor mode */
++.macro GET_THREAD_INFO reg
++.if THREAD_SIZE & 0xffff0000
++ andhi \reg, sp, %hi(~(THREAD_SIZE-1))
++.else
++ addi \reg, r0, %lo(~(THREAD_SIZE-1))
++ and \reg, \reg, sp
++.endif
++.endm
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_THREAD_INFO_H */
+--- linux/include/asm-nios2nommu/timer_struct.h
++++ linux/include/asm-nios2nommu/timer_struct.h
+@@ -0,0 +1,38 @@
++
++// ----------------------------------------------
++// Timer Peripheral
++
++// Timer Registers
++typedef volatile struct
++ {
++ int np_timerstatus; // read only, 2 bits (any write to clear TO)
++ int np_timercontrol; // write/readable, 4 bits
++ int np_timerperiodl; // write/readable, 16 bits
++ int np_timerperiodh; // write/readable, 16 bits
++ int np_timersnapl; // read only, 16 bits
++ int np_timersnaph; // read only, 16 bits
++ } np_timer;
++
++// Timer Register Bits
++enum
++ {
++ np_timerstatus_run_bit = 1, // timer is running
++ np_timerstatus_to_bit = 0, // timer has timed out
++
++ np_timercontrol_stop_bit = 3, // stop the timer
++ np_timercontrol_start_bit = 2, // start the timer
++ np_timercontrol_cont_bit = 1, // continous mode
++ np_timercontrol_ito_bit = 0, // enable time out interrupt
++
++ np_timerstatus_run_mask = (1<<1), // timer is running
++ np_timerstatus_to_mask = (1<<0), // timer has timed out
++
++ np_timercontrol_stop_mask = (1<<3), // stop the timer
++ np_timercontrol_start_mask = (1<<2), // start the timer
++ np_timercontrol_cont_mask = (1<<1), // continous mode
++ np_timercontrol_ito_mask = (1<<0) // enable time out interrupt
++ };
++
++// Timer Routines
++int nr_timer_milliseconds(void); // Starts on first call, hogs timer1.
++
+--- linux/include/asm-nios2nommu/timex.h
++++ linux/include/asm-nios2nommu/timex.h
+@@ -0,0 +1,48 @@
++#ifndef _ASMNIOS2NOMMU_TIMEX_H
++#define _ASMNIOS2NOMMU_TIMEX_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/timex.h
++ *
++ * timex specifications
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++
++#define CLOCK_TICK_RATE nasys_clock_freq /* Underlying HZ */
++
++#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
++
++#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
++ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
++ << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
++
++typedef unsigned long cycles_t;
++
++static inline cycles_t get_cycles(void)
++{
++ return 0;
++}
++
++#endif
+--- linux/include/asm-nios2nommu/tlbflush.h
++++ linux/include/asm-nios2nommu/tlbflush.h
+@@ -0,0 +1,86 @@
++#ifndef _NIOS2NOMMU_TLBFLUSH_H
++#define _NIOS2NOMMU_TLBFLUSH_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlbflush.h
++ *
++ * Ported from m68knommu.
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm/setup.h>
++
++/*
++ * flush all user-space atc entries.
++ */
++static inline void __flush_tlb(void)
++{
++ BUG();
++}
++
++static inline void __flush_tlb_one(unsigned long addr)
++{
++ BUG();
++}
++
++#define flush_tlb() __flush_tlb()
++
++/*
++ * flush all atc entries (both kernel and user-space entries).
++ */
++static inline void flush_tlb_all(void)
++{
++ BUG();
++}
++
++static inline void flush_tlb_mm(struct mm_struct *mm)
++{
++ BUG();
++}
++
++static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
++{
++ BUG();
++}
++
++static inline void flush_tlb_range(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_kernel_page(unsigned long addr)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_pgtables(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++#endif /* _NIOS2NOMMU_TLBFLUSH_H */
+--- linux/include/asm-nios2nommu/tlb.h
++++ linux/include/asm-nios2nommu/tlb.h
+@@ -0,0 +1,35 @@
++#ifndef __NIOS_TLB_H__
++#define __NIOS_TLB_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlb.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd
++ * Copyright (C) 2002 NEC Corporation
++ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Written by Miles Bader <miles@gnu.org>
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define tlb_flush(tlb) ((void)0)
++
++#include <asm-generic/tlb.h>
++
++#endif /* __NIOS_TLB_H__ */
++
+--- linux/include/asm-nios2nommu/topology.h
++++ linux/include/asm-nios2nommu/topology.h
+@@ -0,0 +1,30 @@
++#ifndef _ASM_NIOS2NOMMU_TOPOLOGY_H
++#define _ASM_NIOS2NOMMU_TOPOLOGY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/topology.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/topology.h>
++
++#endif /* _ASM_NIOS2NOMMU_TOPOLOGY_H */
+--- linux/include/asm-nios2nommu/traps.h
++++ linux/include/asm-nios2nommu/traps.h
+@@ -0,0 +1,27 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_TRAPS_H
++#define _NIOS2_TRAPS_H
++
++#define TRAP_ID_SYSCALL 0
++#define TRAP_ID_APPDEBUG 1
++#endif /* !(_NIOS2_TRAPS_H) */
+--- linux/include/asm-nios2nommu/types.h
++++ linux/include/asm-nios2nommu/types.h
+@@ -0,0 +1,93 @@
++#ifndef _NIOS_TYPES_H
++#define _NIOS_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/types.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is never included by application software unless
++ * explicitly requested (e.g., via linux/types.h) in which case the
++ * application is Linux specific so (user-) name space pollution is
++ * not a major issue. However, for interoperability, libraries still
++ * need to be careful to avoid a name clashes.
++ */
++
++#ifndef __ASSEMBLY__
++
++typedef unsigned short umode_t;
++
++/*
++ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
++ * header files exported to user space
++ */
++
++typedef __signed__ char __s8;
++typedef unsigned char __u8;
++
++typedef __signed__ short __s16;
++typedef unsigned short __u16;
++
++typedef __signed__ int __s32;
++typedef unsigned int __u32;
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
++typedef __signed__ long long __s64;
++typedef unsigned long long __u64;
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++/*
++ * These aren't exported outside the kernel to avoid name space clashes
++ */
++#ifdef __KERNEL__
++
++#define BITS_PER_LONG 32
++
++#ifndef __ASSEMBLY__
++
++typedef signed char s8;
++typedef unsigned char u8;
++
++typedef signed short s16;
++typedef unsigned short u16;
++
++typedef signed int s32;
++typedef unsigned int u32;
++
++typedef signed long long s64;
++typedef unsigned long long u64;
++
++/* DMA addresses are always 32-bits wide */
++
++typedef u32 dma_addr_t;
++typedef u32 dma64_addr_t;
++
++typedef unsigned short kmem_bufctl_t;
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TYPES_H */
+--- linux/include/asm-nios2nommu/uaccess.h
++++ linux/include/asm-nios2nommu/uaccess.h
+@@ -0,0 +1,183 @@
++#ifndef __NIOS2NOMMU_UACCESS_H
++#define __NIOS2NOMMU_UACCESS_H
++
++/*--------------------------------------------------------------------
++ *
++ * asm-nios2nommu/uaccess.h
++ *
++ * User space memory access functions
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Ported from asm-m68knommu/uaccess.h --wentao
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <asm/segment.h>
++#include <asm/nios.h>
++
++#define VERIFY_READ 0
++#define VERIFY_WRITE 1
++
++#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size))
++
++static inline int _access_ok(unsigned long addr, unsigned long size)
++{
++ return (((unsigned long)addr < (unsigned long)nasys_program_mem_end) &&
++ (((unsigned long)addr >= (unsigned long)nasys_program_mem)));
++}
++
++extern inline int verify_area(int type, const void * addr, unsigned long size)
++{
++ return access_ok(type,addr,size)?0:-EFAULT;
++}
++
++/*
++ * The exception table consists of pairs of addresses: the first is the
++ * address of an instruction that is allowed to fault, and the second is
++ * the address at which the program should continue. No registers are
++ * modified, so it is entirely up to the continuation code to figure out
++ * what to do.
++ *
++ * All the routines below use bits of fixup code that are out of line
++ * with the main instruction path. This means when everything is well,
++ * we don't even have to jump over them. Further, they do not intrude
++ * on our cache or tlb entries.
++ */
++
++#define ARCH_HAS_SEARCH_EXTABLE
++//;dgt2;tmp;
++
++struct exception_table_entry
++{
++ unsigned long insn, fixup;
++};
++
++/* Returns 0 if exception not found and fixup otherwise. */
++extern unsigned long search_exception_table(unsigned long);
++
++
++/*
++ * These are the main single-value transfer routines. They automatically
++ * use the right size if we just have the right pointer type.
++ */
++
++#define put_user(x, ptr) \
++({ \
++ int __pu_err = 0; \
++ typeof(*(ptr)) __pu_val = (x); \
++ switch (sizeof (*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __pu_err = __put_user_bad(); \
++ break; \
++ } \
++ __pu_err; \
++})
++#define __put_user(x, ptr) put_user(x, ptr)
++
++extern int __put_user_bad(void);
++
++/*
++ * Tell gcc we read from memory instead of writing: this is because
++ * we do not write to any memory gcc knows about, so there are no
++ * aliasing issues.
++ */
++
++#define __ptr(x) ((unsigned long *)(x))
++
++#define get_user(x, ptr) \
++({ \
++ int __gu_err = 0; \
++ typeof(*(ptr)) __gu_val = 0; \
++ switch (sizeof(*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(&__gu_val, ptr, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __gu_val = 0; \
++ __gu_err = __get_user_bad(); \
++ break; \
++ } \
++ (x) = __gu_val; \
++ __gu_err; \
++})
++#define __get_user(x, ptr) get_user(x, ptr)
++
++extern int __get_user_bad(void);
++
++#define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
++#define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
++
++#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
++#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
++#define __copy_to_user_inatomic __copy_to_user
++#define __copy_from_user_inatomic __copy_from_user
++
++#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
++
++#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
++
++/*
++ * Copy a null terminated string from userspace.
++ */
++
++static inline long
++strncpy_from_user(char *dst, const char *src, long count)
++{
++ char *tmp;
++ strncpy(dst, src, count);
++ for (tmp = dst; *tmp && count > 0; tmp++, count--)
++ ;
++ return(tmp - dst); /* DAVIDM should we count a NUL ? check getname */
++}
++
++/*
++ * Return the size of a string (including the ending 0)
++ *
++ * Return 0 on exception, a value greater than N if too long
++ */
++static inline long strnlen_user(const char *src, long n)
++{
++ return(strlen(src) + 1); /* DAVIDM make safer */
++}
++
++#define strlen_user(str) strnlen_user(str, 32767)
++
++/*
++ * Zero Userspace
++ */
++
++static inline unsigned long
++clear_user(void *to, unsigned long n)
++{
++ memset(to, 0, n);
++ return(0);
++}
++
++#endif /* _NIOS2NOMMU_UACCESS_H */
+--- linux/include/asm-nios2nommu/uart_struct.h
++++ linux/include/asm-nios2nommu/uart_struct.h
+@@ -0,0 +1,83 @@
++
++// UART Registers
++typedef volatile struct
++ {
++ int np_uartrxdata; // Read-only, 8-bit
++ int np_uarttxdata; // Write-only, 8-bit
++ int np_uartstatus; // Read-only, 8-bit
++ int np_uartcontrol; // Read/Write, 9-bit
++ int np_uartdivisor; // Read/Write, 16-bit, optional
++ int np_uartendofpacket; // Read/Write, end-of-packet character
++ } np_uart;
++
++// UART Status Register Bits
++enum
++ {
++ np_uartstatus_eop_bit = 12,
++ np_uartstatus_cts_bit = 11,
++ np_uartstatus_dcts_bit = 10,
++ np_uartstatus_e_bit = 8,
++ np_uartstatus_rrdy_bit = 7,
++ np_uartstatus_trdy_bit = 6,
++ np_uartstatus_tmt_bit = 5,
++ np_uartstatus_toe_bit = 4,
++ np_uartstatus_roe_bit = 3,
++ np_uartstatus_brk_bit = 2,
++ np_uartstatus_fe_bit = 1,
++ np_uartstatus_pe_bit = 0,
++
++ np_uartstatus_eop_mask = (1<<12),
++ np_uartstatus_cts_mask = (1<<11),
++ np_uartstatus_dcts_mask = (1<<10),
++ np_uartstatus_e_mask = (1<<8),
++ np_uartstatus_rrdy_mask = (1<<7),
++ np_uartstatus_trdy_mask = (1<<6),
++ np_uartstatus_tmt_mask = (1<<5),
++ np_uartstatus_toe_mask = (1<<4),
++ np_uartstatus_roe_mask = (1<<3),
++ np_uartstatus_brk_mask = (1<<2),
++ np_uartstatus_fe_mask = (1<<1),
++ np_uartstatus_pe_mask = (1<<0)
++ };
++
++// UART Control Register Bits
++enum
++ {
++ np_uartcontrol_ieop_bit = 12,
++ np_uartcontrol_rts_bit = 11,
++ np_uartcontrol_idcts_bit = 10,
++ np_uartcontrol_tbrk_bit = 9,
++ np_uartcontrol_ie_bit = 8,
++ np_uartcontrol_irrdy_bit = 7,
++ np_uartcontrol_itrdy_bit = 6,
++ np_uartcontrol_itmt_bit = 5,
++ np_uartcontrol_itoe_bit = 4,
++ np_uartcontrol_iroe_bit = 3,
++ np_uartcontrol_ibrk_bit = 2,
++ np_uartcontrol_ife_bit = 1,
++ np_uartcontrol_ipe_bit = 0,
++
++ np_uartcontrol_ieop_mask = (1<<12),
++ np_uartcontrol_rts_mask = (1<<11),
++ np_uartcontrol_idcts_mask = (1<<10),
++ np_uartcontrol_tbrk_mask = (1<<9),
++ np_uartcontrol_ie_mask = (1<<8),
++ np_uartcontrol_irrdy_mask = (1<<7),
++ np_uartcontrol_itrdy_mask = (1<<6),
++ np_uartcontrol_itmt_mask = (1<<5),
++ np_uartcontrol_itoe_mask = (1<<4),
++ np_uartcontrol_iroe_mask = (1<<3),
++ np_uartcontrol_ibrk_mask = (1<<2),
++ np_uartcontrol_ife_mask = (1<<1),
++ np_uartcontrol_ipe_mask = (1<<0)
++ };
++
++// UART Routines
++int nr_uart_rxchar(np_uart *uartBase); // 0 for default UART
++void nr_uart_txcr(void);
++void nr_uart_txchar(int c,np_uart *uartBase); // 0 for default UART
++void nr_uart_txhex(int x); // 16 or 32 bits
++void nr_uart_txhex16(short x);
++void nr_uart_txhex32(long x);
++void nr_uart_txstring(char *s);
++
+--- linux/include/asm-nios2nommu/ucontext.h
++++ linux/include/asm-nios2nommu/ucontext.h
+@@ -0,0 +1,63 @@
++#ifndef _NIOSKNOMMU_UCONTEXT_H
++#define _NIOSKNOMMU_UCONTEXT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/ucontext.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++typedef int greg_t;
++#define NGREG 32
++typedef greg_t gregset_t[NGREG];
++
++#ifdef CONFIG_FPU
++typedef struct fpregset {
++ int f_pcr;
++ int f_psr;
++ int f_fpiaddr;
++ int f_fpregs[8][3];
++} fpregset_t;
++#endif
++
++struct mcontext {
++ int version;
++ int status_extension;
++ gregset_t gregs;
++#ifdef CONFIG_FPU
++ fpregset_t fpregs;
++#endif
++};
++
++#define MCONTEXT_VERSION 2
++
++struct ucontext {
++ unsigned long uc_flags;
++ struct ucontext *uc_link;
++ stack_t uc_stack;
++ struct mcontext uc_mcontext;
++#ifdef CONFIG_FPU
++ unsigned long uc_filler[80];
++#endif
++ sigset_t uc_sigmask; /* mask last for extensibility */
++};
++
++#endif
+--- linux/include/asm-nios2nommu/unaligned.h
++++ linux/include/asm-nios2nommu/unaligned.h
+@@ -0,0 +1,43 @@
++#ifndef __NIOS_UNALIGNED_H
++#define __NIOS_UNALIGNED_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/unaligned.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * The nios cannot do unaligned accesses itself.
++ */
++
++#define get_unaligned(ptr) ({ \
++ typeof((*(ptr))) x; \
++ memcpy(&x, (void*)ptr, sizeof(*(ptr))); \
++ x; \
++})
++
++#define put_unaligned(val, ptr) ({ \
++ typeof((*(ptr))) x = val; \
++ memcpy((void*)ptr, &x, sizeof(*(ptr))); \
++})
++
++#endif /* __NIOS_UNALIGNED_H */
+--- linux/include/asm-nios2nommu/unistd.h
++++ linux/include/asm-nios2nommu/unistd.h
+@@ -0,0 +1,686 @@
++#ifndef _ASM_NIOS_UNISTD_H_
++#define _ASM_NIOS_UNISTD_H_
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/unistd.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * //vic - kernel_thread moved to process.c
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/traps.h>
++
++/* TRAP isr expects the trap# (syscall=#TRAP_ID_SYSCALL) in r2,
++ * the syscall # in r3, and arguments in r4, r5, ...
++ * Return argument expected in r2.
++ */
++
++#define __NR_restart_syscall 0
++#define __NR_exit 1
++#define __NR_fork 2
++#define __NR_read 3
++#define __NR_write 4
++#define __NR_open 5
++#define __NR_close 6
++#define __NR_waitpid 7
++#define __NR_creat 8
++#define __NR_link 9
++#define __NR_unlink 10
++#define __NR_execve 11
++#define __NR_chdir 12
++#define __NR_time 13
++#define __NR_mknod 14
++#define __NR_chmod 15
++#define __NR_chown 16
++#define __NR_break 17
++#define __NR_oldstat 18
++#define __NR_lseek 19
++#define __NR_getpid 20
++#define __NR_mount 21
++#define __NR_umount 22
++#define __NR_setuid 23
++#define __NR_getuid 24
++#define __NR_stime 25
++#define __NR_ptrace 26
++#define __NR_alarm 27
++#define __NR_oldfstat 28
++#define __NR_pause 29
++#define __NR_utime 30
++#define __NR_stty 31
++#define __NR_gtty 32
++#define __NR_access 33
++#define __NR_nice 34
++#define __NR_ftime 35
++#define __NR_sync 36
++#define __NR_kill 37
++#define __NR_rename 38
++#define __NR_mkdir 39
++#define __NR_rmdir 40
++#define __NR_dup 41
++#define __NR_pipe 42
++#define __NR_times 43
++#define __NR_prof 44
++#define __NR_brk 45
++#define __NR_setgid 46
++#define __NR_getgid 47
++#define __NR_signal 48
++#define __NR_geteuid 49
++#define __NR_getegid 50
++#define __NR_acct 51
++#define __NR_umount2 52 //vic #define __NR_phys 52
++#define __NR_lock 53
++#define __NR_ioctl 54
++#define __NR_fcntl 55
++#define __NR_mpx 56
++#define __NR_setpgid 57
++#define __NR_ulimit 58
++#define __NR_oldolduname 59
++#define __NR_umask 60
++#define __NR_chroot 61
++#define __NR_ustat 62
++#define __NR_dup2 63
++#define __NR_getppid 64
++#define __NR_getpgrp 65
++#define __NR_setsid 66
++#define __NR_sigaction 67
++#define __NR_sgetmask 68
++#define __NR_ssetmask 69
++#define __NR_setreuid 70
++#define __NR_setregid 71
++#define __NR_sigsuspend 72
++#define __NR_sigpending 73
++#define __NR_sethostname 74
++#define __NR_setrlimit 75
++#define __NR_getrlimit 76
++#define __NR_getrusage 77
++#define __NR_gettimeofday 78
++#define __NR_settimeofday 79
++#define __NR_getgroups 80
++#define __NR_setgroups 81
++#define __NR_select 82
++#define __NR_symlink 83
++#define __NR_oldlstat 84
++#define __NR_readlink 85
++#define __NR_uselib 86
++#define __NR_swapon 87
++#define __NR_reboot 88
++#define __NR_readdir 89
++#define __NR_mmap 90
++#define __NR_munmap 91
++#define __NR_truncate 92
++#define __NR_ftruncate 93
++#define __NR_fchmod 94
++#define __NR_fchown 95
++#define __NR_getpriority 96
++#define __NR_setpriority 97
++#define __NR_profil 98
++#define __NR_statfs 99
++#define __NR_fstatfs 100
++#define __NR_ioperm 101
++#define __NR_socketcall 102
++#define __NR_syslog 103
++#define __NR_setitimer 104
++#define __NR_getitimer 105
++#define __NR_stat 106
++#define __NR_lstat 107
++#define __NR_fstat 108
++#define __NR_olduname 109
++#define __NR_iopl /* 110 */ not supported
++#define __NR_vhangup 111
++#define __NR_idle /* 112 */ Obsolete
++#define __NR_vm86 /* 113 */ not supported
++#define __NR_wait4 114
++#define __NR_swapoff 115
++#define __NR_sysinfo 116
++#define __NR_ipc 117
++#define __NR_fsync 118
++#define __NR_sigreturn 119
++#define __NR_clone 120
++#define __NR_setdomainname 121
++#define __NR_uname 122
++#define __NR_cacheflush 123
++#define __NR_adjtimex 124
++#define __NR_mprotect 125
++#define __NR_sigprocmask 126
++#define __NR_create_module 127
++#define __NR_init_module 128
++#define __NR_delete_module 129
++#define __NR_get_kernel_syms 130
++#define __NR_quotactl 131
++#define __NR_getpgid 132
++#define __NR_fchdir 133
++#define __NR_bdflush 134
++#define __NR_sysfs 135
++#define __NR_personality 136
++#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
++#define __NR_setfsuid 138
++#define __NR_setfsgid 139
++#define __NR__llseek 140
++#define __NR_getdents 141
++#define __NR__newselect 142
++#define __NR_flock 143
++#define __NR_msync 144
++#define __NR_readv 145
++#define __NR_writev 146
++#define __NR_getsid 147
++#define __NR_fdatasync 148
++#define __NR__sysctl 149
++#define __NR_mlock 150
++#define __NR_munlock 151
++#define __NR_mlockall 152
++#define __NR_munlockall 153
++#define __NR_sched_setparam 154
++#define __NR_sched_getparam 155
++#define __NR_sched_setscheduler 156
++#define __NR_sched_getscheduler 157
++#define __NR_sched_yield 158
++#define __NR_sched_get_priority_max 159
++#define __NR_sched_get_priority_min 160
++#define __NR_sched_rr_get_interval 161
++#define __NR_nanosleep 162
++#define __NR_mremap 163
++#define __NR_setresuid 164
++#define __NR_getresuid 165
++#define __NR_getpagesize 166
++#define __NR_query_module 167
++#define __NR_poll 168
++#define __NR_nfsservctl 169
++#define __NR_setresgid 170
++#define __NR_getresgid 171
++#define __NR_prctl 172
++#define __NR_rt_sigreturn 173
++#define __NR_rt_sigaction 174
++#define __NR_rt_sigprocmask 175
++#define __NR_rt_sigpending 176
++#define __NR_rt_sigtimedwait 177
++#define __NR_rt_sigqueueinfo 178
++#define __NR_rt_sigsuspend 179
++#define __NR_pread 180
++#define __NR_pwrite 181
++#define __NR_lchown 182
++#define __NR_getcwd 183
++#define __NR_capget 184
++#define __NR_capset 185
++#define __NR_sigaltstack 186
++#define __NR_sendfile 187
++#define __NR_getpmsg 188 /* some people actually want streams */
++#define __NR_putpmsg 189 /* some people actually want streams */
++#define __NR_vfork 190
++#define __NR_ugetrlimit 191
++#define __NR_mmap2 192
++#define __NR_truncate64 193
++#define __NR_ftruncate64 194
++#define __NR_stat64 195
++#define __NR_lstat64 196
++#define __NR_fstat64 197
++#define __NR_chown32 198
++#define __NR_getuid32 199
++#define __NR_getgid32 200
++#define __NR_geteuid32 201
++#define __NR_getegid32 202
++#define __NR_setreuid32 203
++#define __NR_setregid32 204
++#define __NR_getgroups32 205
++#define __NR_setgroups32 206
++#define __NR_fchown32 207
++#define __NR_setresuid32 208
++#define __NR_getresuid32 209
++#define __NR_setresgid32 210
++#define __NR_getresgid32 211
++#define __NR_lchown32 212
++#define __NR_setuid32 213
++#define __NR_setgid32 214
++#define __NR_setfsuid32 215
++#define __NR_setfsgid32 216
++#define __NR_pivot_root 217
++/* 218 unused */
++/* 219 unused */
++#define __NR_getdents64 220
++#define __NR_gettid 221
++#define __NR_tkill 222
++#define __NR_setxattr 223
++#define __NR_lsetxattr 224
++#define __NR_fsetxattr 225
++#define __NR_getxattr 226
++#define __NR_lgetxattr 227
++#define __NR_fgetxattr 228
++#define __NR_listxattr 229
++#define __NR_llistxattr 230
++#define __NR_flistxattr 231
++#define __NR_removexattr 232
++#define __NR_lremovexattr 233
++#define __NR_fremovexattr 234
++#define __NR_futex 235
++#define __NR_sendfile64 236
++#define __NR_mincore 237
++#define __NR_madvise 238
++#define __NR_fcntl64 239
++#define __NR_readahead 240
++#define __NR_io_setup 241
++#define __NR_io_destroy 242
++#define __NR_io_getevents 243
++#define __NR_io_submit 244
++#define __NR_io_cancel 245
++#define __NR_fadvise64 246
++#define __NR_exit_group 247
++#define __NR_lookup_dcookie 248
++#define __NR_epoll_create 249
++#define __NR_epoll_ctl 250
++#define __NR_epoll_wait 251
++#define __NR_remap_file_pages 252
++#define __NR_set_tid_address 253
++#define __NR_timer_create 254
++#define __NR_timer_settime 255
++#define __NR_timer_gettime 256
++#define __NR_timer_getoverrun 257
++#define __NR_timer_delete 258
++#define __NR_clock_settime 259
++#define __NR_clock_gettime 260
++#define __NR_clock_getres 261
++#define __NR_clock_nanosleep 262
++#define __NR_statfs64 263
++#define __NR_fstatfs64 264
++#define __NR_tgkill 265
++#define __NR_utimes 266
++#define __NR_fadvise64_64 267
++#define __NR_mbind 268
++#define __NR_get_mempolicy 269
++#define __NR_set_mempolicy 270
++#define __NR_mq_open 271
++#define __NR_mq_unlink 272
++#define __NR_mq_timedsend 273
++#define __NR_mq_timedreceive 274
++#define __NR_mq_notify 275
++#define __NR_mq_getsetattr 276
++#define __NR_waitid 277
++#define __NR_sys_setaltroot 278
++#define __NR_add_key 279
++#define __NR_request_key 280
++#define __NR_keyctl 281
++
++#define NR_syscalls 282
++
++/* user-visible error numbers are in the range -1 - -122: see
++ <asm-nios2nommu/errno.h> */
++
++#define __syscall_return(type, res) \
++do { \
++ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
++ \
++ /* avoid using res which is declared to be in \
++ register r2; errno might expand to a function \
++ call and clobber it. */ \
++ \
++ int __err = -(res); \
++ errno = __err; \
++ res = -1; \
++ } \
++ return (type) (res); \
++} while (0)
++
++#define _syscall0(type,name) \
++type name(void) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall1 arg a
++//;dgt2;tmp; already being in r4 ?
++#define _syscall1(type,name,atype,a) \
++type name(atype a) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall2 args a,b
++//;dgt2;tmp; already being in r4,r5 ?
++#define _syscall2(type,name,atype,a,btype,b) \
++type name(atype a,btype b) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall3 args a,b,c
++//;dgt2;tmp; already being in r4,r5,r6 ?
++#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
++type name(atype a,btype b,ctype c) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall4 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
++type name (atype a, btype b, ctype c, dtype d) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) d */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall5 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
++type name (atype a,btype b,ctype c,dtype d,etype e) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) c */ \
++ " mov r8, %7\n\t" /* (long) e */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ , "r" ((long) e) /* %7 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ , "r8" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall6 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
++type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) c */ \
++ " mov r8, %7\n\t" /* (long) e */ \
++ " mov r9, %8\n\t" /* (long) f */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ , "r" ((long) e) /* %7 */ \
++ , "r" ((long) f) /* %8 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ , "r8" /* Clobbered */ \
++ , "r9" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++#ifdef __KERNEL__
++#define __ARCH_WANT_IPC_PARSE_VERSION
++#define __ARCH_WANT_OLD_READDIR
++#define __ARCH_WANT_OLD_STAT
++#define __ARCH_WANT_STAT64
++#define __ARCH_WANT_SYS_ALARM
++#define __ARCH_WANT_SYS_GETHOSTNAME
++#define __ARCH_WANT_SYS_PAUSE
++#define __ARCH_WANT_SYS_SGETMASK
++#define __ARCH_WANT_SYS_SIGNAL
++#define __ARCH_WANT_SYS_TIME
++#define __ARCH_WANT_SYS_UTIME
++#define __ARCH_WANT_SYS_WAITPID
++#define __ARCH_WANT_SYS_SOCKETCALL
++#define __ARCH_WANT_SYS_FADVISE64
++#define __ARCH_WANT_SYS_GETPGRP
++#define __ARCH_WANT_SYS_LLSEEK
++#define __ARCH_WANT_SYS_NICE
++#define __ARCH_WANT_SYS_OLD_GETRLIMIT
++#define __ARCH_WANT_SYS_OLDUMOUNT
++#define __ARCH_WANT_SYS_SIGPENDING
++#define __ARCH_WANT_SYS_SIGPROCMASK
++#define __ARCH_WANT_SYS_RT_SIGACTION
++#endif
++
++#ifdef __KERNEL_SYSCALLS__
++
++/*
++ * we need this inline - forking from kernel space will result
++ * in NO COPY ON WRITE (!!!), until an execve is executed. This
++ * is no problem, but for the stack. This is handled by not letting
++ * main() use the stack at all after fork(). Thus, no function
++ * calls - which means inline code for fork too, as otherwise we
++ * would use the stack upon exit from 'fork()'.
++ *
++ * Actually only pause and fork are needed inline, so that there
++ * won't be any messing with the stack from main(), but we define
++ * some others too.
++ */
++#define __NR__exit __NR_exit
++static inline _syscall0(int,pause)
++static inline _syscall0(int,sync)
++static inline _syscall0(pid_t,setsid)
++static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
++static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
++static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
++static inline _syscall1(int,dup,int,fd)
++static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
++static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
++static inline _syscall1(int,close,int,fd)
++static inline _syscall1(int,_exit,int,exitcode)
++static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
++static inline _syscall1(int,delete_module,const char *,name)
++
++static inline pid_t wait(int * wait_stat)
++{
++ return waitpid(-1,wait_stat,0);
++}
++
++#endif
++
++/*
++ * "Conditional" syscalls
++ *
++ * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
++ * but it doesn't work on all toolchains, so we just do it by hand
++ */
++#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
++
++#endif /* _ASM_NIOS_UNISTD_H_ */
+--- linux/include/asm-nios2nommu/user.h
++++ linux/include/asm-nios2nommu/user.h
+@@ -0,0 +1,112 @@
++#ifndef _NIOS2NOMMU_USER_H
++#define _NIOS2NOMMU_USER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/user.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/page.h>
++
++/* Core file format: The core file is written in such a way that gdb
++ can understand it and provide useful information to the user (under
++ linux we use the 'trad-core' bfd). There are quite a number of
++ obstacles to being able to view the contents of the floating point
++ registers, and until these are solved you will not be able to view the
++ contents of them. Actually, you can read in the core file and look at
++ the contents of the user struct to find out what the floating point
++ registers contain.
++ The actual file contents are as follows:
++ UPAGE: 1 page consisting of a user struct that tells gdb what is present
++ in the file. Directly after this is a copy of the task_struct, which
++ is currently not used by gdb, but it may come in useful at some point.
++ All of the registers are stored as part of the upage. The upage should
++ always be only one page.
++ DATA: The data area is stored. We use current->end_text to
++ current->brk to pick up all of the user variables, plus any memory
++ that may have been malloced. No attempt is made to determine if a page
++ is demand-zero or if a page is totally unused, we just cover the entire
++ range. All of the addresses are rounded in such a way that an integral
++ number of pages is written.
++ STACK: We need the stack information in order to get a meaningful
++ backtrace. We need to write the data from (esp) to
++ current->start_stack, so we round each of these off in order to be able
++ to write an integer number of pages.
++ The minimum core file size is 3 pages, or 12288 bytes.
++*/
++
++struct user_m68kfp_struct {
++ unsigned long fpregs[8*3]; /* fp0-fp7 registers */
++ unsigned long fpcntl[3]; /* fp control regs */
++};
++
++/* This is needs more work, probably should look like gdb useage */
++struct user_regs_struct {
++ long r1,r2,r3,r4,r5,r6,r7,r8;
++ long r9,r10,r11,r12,r13,r14,r15;
++ long r16,r17,r18,r19,r20,r21,r22,r23;
++ long gp;
++ long sp;
++ long ra;
++ long fp;
++ long orig_r2;
++ long estatus;
++ long status_extension;
++ long ea;
++};
++
++
++/* When the kernel dumps core, it starts by dumping the user struct -
++ this will be used by gdb to figure out where the data and stack segments
++ are within the file, and what virtual addresses to use. */
++struct user{
++/* We start with the registers, to mimic the way that "memory" is returned
++ from the ptrace(3,...) function. */
++ struct user_regs_struct regs; /* Where the registers are actually stored */
++/* ptrace does not yet supply these. Someday.... */
++ int u_fpvalid; /* True if math co-processor being used. */
++ /* for this mess. Not yet used. */
++ struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
++/* The rest of this junk is to help gdb figure out what goes where */
++ unsigned long int u_tsize; /* Text segment size (pages). */
++ unsigned long int u_dsize; /* Data segment size (pages). */
++ unsigned long int u_ssize; /* Stack segment size (pages). */
++ unsigned long start_code; /* Starting virtual address of text. */
++ unsigned long start_stack; /* Starting virtual address of stack area.
++ This is actually the bottom of the stack,
++ the top of the stack is always found in the
++ esp register. */
++ long int signal; /* Signal that caused the core dump. */
++ int reserved; /* No longer used */
++ struct user_regs_struct *u_ar0;
++ /* Used by gdb to help find the values for */
++ /* the registers. */
++ struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
++ unsigned long magic; /* To uniquely identify a core file */
++ char u_comm[32]; /* User command that was responsible */
++};
++#define NBPG PAGE_SIZE
++#define UPAGES 1
++#define HOST_TEXT_START_ADDR (u.start_code)
++#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
++
++#endif
+--- linux/include/asm-nios2nommu/virtconvert.h
++++ linux/include/asm-nios2nommu/virtconvert.h
+@@ -0,0 +1,47 @@
++#ifndef __NIOS_VIRT_CONVERT__
++#define __NIOS_VIRT_CONVERT__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/virtconvert.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Macros used for converting between virtual and physical mappings.
++ */
++
++#ifdef __KERNEL__
++
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#endif /*__KERNEL__ */
++#endif /*__NIOS_VIRT_CONVERT__*/
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0-mips-nptl.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0-mips-nptl.patch
new file mode 100644
index 0000000000..72571b05e9
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0-mips-nptl.patch
@@ -0,0 +1,75 @@
+diff -urN linux-libc-headers-2.6.11.0/include/asm-mips/inst.h linux-libc-headers-2.6.11.0-nptl/include/asm-mips/inst.h
+--- linux-libc-headers-2.6.11.0/include/asm-mips/inst.h 2004-10-31 13:54:20.000000000 -0600
++++ linux-libc-headers-2.6.11.0-nptl/include/asm-mips/inst.h 2005-05-04 23:15:45.890613280 -0500
+@@ -28,7 +28,7 @@
+ sdl_op, sdr_op, swr_op, cache_op,
+ ll_op, lwc1_op, lwc2_op, pref_op,
+ lld_op, ldc1_op, ldc2_op, ld_op,
+- sc_op, swc1_op, swc2_op, major_3b_op, /* Opcode 0x3b is unused */
++ sc_op, swc1_op, swc2_op, rdhwr_op,
+ scd_op, sdc1_op, sdc2_op, sd_op
+ };
+
+diff -urN linux-libc-headers-2.6.11.0/include/asm-mips/unistd.h linux-libc-headers-2.6.11.0-nptl/include/asm-mips/unistd.h
+--- linux-libc-headers-2.6.11.0/include/asm-mips/unistd.h 2005-01-08 08:02:51.000000000 -0600
++++ linux-libc-headers-2.6.11.0-nptl/include/asm-mips/unistd.h 2005-05-04 23:16:48.240229738 -0500
+@@ -303,16 +303,17 @@
+ #define __NR_add_key (__NR_Linux + 280)
+ #define __NR_request_key (__NR_Linux + 281)
+ #define __NR_keyctl (__NR_Linux + 282)
++#define __NR_set_thread_area (__NR_Linux + 283)
+
+ /*
+ * Offset of the last Linux o32 flavoured syscall
+ */
+-#define __NR_Linux_syscalls 282
++#define __NR_Linux_syscalls 283
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
+
+ #define __NR_O32_Linux 4000
+-#define __NR_O32_Linux_syscalls 282
++#define __NR_O32_Linux_syscalls 283
+
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
+
+@@ -562,16 +563,17 @@
+ #define __NR_add_key (__NR_Linux + 239)
+ #define __NR_request_key (__NR_Linux + 240)
+ #define __NR_keyctl (__NR_Linux + 241)
++#define __NR_set_thread_area (__NR_Linux + 242)
+
+ /*
+ * Offset of the last Linux 64-bit flavoured syscall
+ */
+-#define __NR_Linux_syscalls 241
++#define __NR_Linux_syscalls 242
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
+
+ #define __NR_64_Linux 5000
+-#define __NR_64_Linux_syscalls 241
++#define __NR_64_Linux_syscalls 242
+
+ #if _MIPS_SIM == _MIPS_SIM_NABI32
+
+@@ -825,16 +827,17 @@
+ #define __NR_add_key (__NR_Linux + 243)
+ #define __NR_request_key (__NR_Linux + 244)
+ #define __NR_keyctl (__NR_Linux + 245)
++#define __NR_set_thread_area (__NR_Linux + 246)
+
+ /*
+ * Offset of the last N32 flavoured syscall
+ */
+-#define __NR_Linux_syscalls 245
++#define __NR_Linux_syscalls 246
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
+
+ #define __NR_N32_Linux 6000
+-#define __NR_N32_Linux_syscalls 245
++#define __NR_N32_Linux_syscalls 246
+
+ #ifndef __ASSEMBLY__
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0.patch
new file mode 100644
index 0000000000..f528b8b4c3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.11.0.patch
@@ -0,0 +1,18 @@
+--- linux/include/linux/netfilter_ipv4/ip_nat.h.orig 2005-03-21 16:18:40.000000000 -0700
++++ linux/include/linux/netfilter_ipv4/ip_nat.h 2005-03-21 16:23:54.000000000 -0700
+@@ -66,6 +66,15 @@
+ struct ip_conntrack_manip manip;
+ };
+
++/* For backwards compat: don't use in modern code. */
++struct ip_nat_multi_range_compat
++{
++ unsigned int rangesize; /* Must be 1. */
++
++ /* hangs off end. */
++ struct ip_nat_range range[1];
++};
++
+ #define ip_nat_multi_range ip_nat_multi_range_compat
+
+ #endif
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-arm-eabi.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-arm-eabi.patch
new file mode 100644
index 0000000000..dcbd21b0a1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-arm-eabi.patch
@@ -0,0 +1,166 @@
+--- linux-libc-headers-2.6.12.0/include/asm-arm/unistd.h 2005-07-06 03:17:41.000000000 +0300
++++ linux-libc-headers-2.6.12.0-arm-eabi/include/asm-arm/unistd.h 2006-06-05 17:14:09.000000000 +0300
+@@ -15,10 +15,12 @@
+
+ #include <linux/linkage.h>
+
+-#if defined(__thumb__)
++#define __NR_OABI_SYSCALL_BASE 0x900000
++
++#if defined(__thumb__) || defined(__ARM_EABI__)
+ #define __NR_SYSCALL_BASE 0
+ #else
+-#define __NR_SYSCALL_BASE 0x900000
++#define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE
+ #endif
+
+ /*
+@@ -365,13 +375,13 @@
+ #define __sys1(x) __sys2(x)
+
+ #ifndef __syscall
+-#if defined(__thumb__)
+-#define __syscall(name) \
+- "push {r7}\n\t" \
+- "mov r7, #" __sys1(__NR_##name) "\n\t" \
+- "swi 0\n\t" \
+- "pop {r7}"
++#if defined(__thumb__) || defined(__ARM_EABI__)
++#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
++#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
++#define __syscall(name) "swi\t0"
+ #else
++#define __SYS_REG(name)
++#define __SYS_REG_LIST(regs...) regs
+ #define __syscall(name) "swi\t" __sys1(__NR_##name) ""
+ #endif
+ #endif
+@@ -387,33 +397,34 @@
+
+ #define _syscall0(type,name) \
+ type name(void) { \
++ __SYS_REG(name) \
+ register long __res_r0 __asm__("r0"); \
+ long __res; \
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : \
+- : "lr"); \
++ : __SYS_REG_LIST() ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+
+ #define _syscall1(type,name,type1,arg1) \
+ type name(type1 arg1) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __res_r0 __asm__("r0"); \
+ long __res; \
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+
+ #define _syscall2(type,name,type1,arg1,type2,arg2) \
+ type name(type1 arg1,type2 arg2) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __r1 __asm__("r1") = (long)arg2; \
+ register long __res_r0 __asm__("r0"); \
+@@ -421,8 +432,7 @@
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0),"r" (__r1) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0), "r" (__r1) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+@@ -430,6 +440,7 @@
+
+ #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+ type name(type1 arg1,type2 arg2,type3 arg3) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __r1 __asm__("r1") = (long)arg2; \
+ register long __r2 __asm__("r2") = (long)arg3; \
+@@ -438,8 +449,7 @@
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0),"r" (__r1),"r" (__r2) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+@@ -447,6 +457,7 @@
+
+ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
+ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __r1 __asm__("r1") = (long)arg2; \
+ register long __r2 __asm__("r2") = (long)arg3; \
+@@ -456,8 +467,7 @@
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+@@ -465,6 +475,7 @@
+
+ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
+ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __r1 __asm__("r1") = (long)arg2; \
+ register long __r2 __asm__("r2") = (long)arg3; \
+@@ -475,14 +486,15 @@
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
++ "r" (__r3), "r" (__r4) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+
+ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
+ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
++ __SYS_REG(name) \
+ register long __r0 __asm__("r0") = (long)arg1; \
+ register long __r1 __asm__("r1") = (long)arg2; \
+ register long __r2 __asm__("r2") = (long)arg3; \
+@@ -494,14 +506,15 @@
+ __asm__ __volatile__ ( \
+ __syscall(name) \
+ : "=r" (__res_r0) \
+- : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5) \
+- : "lr"); \
++ : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
++ "r" (__r3), "r" (__r4), "r" (__r5) ) ); \
+ __res = __res_r0; \
+ __syscall_return(type,__res); \
+ }
+
+ #ifdef __KERNEL_SYSCALLS__
+
++#include <linux/compiler.h>
+ #include <linux/types.h>
+ #include <linux/syscalls.h>
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-config-base-small.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-config-base-small.patch
new file mode 100644
index 0000000000..b6bbfd64ab
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-config-base-small.patch
@@ -0,0 +1,30 @@
+diff -urN linux-libc-headers-2.6.12.0/include/linux/threads.h linux-libc-headers-2.6.12.0-patched/include/linux/threads.h
+--- linux-libc-headers-2.6.12.0/include/linux/threads.h 2005-07-05 19:17:23.000000000 -0500
++++ linux-libc-headers-2.6.12.0-patched/include/linux/threads.h 2005-08-18 11:39:15.000000000 -0500
+@@ -24,12 +24,11 @@
+ /*
+ * This controls the default maximum pid allocated to a process
+ */
+-#define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)
++#define PID_MAX_DEFAULT 0x8000
+
+ /*
+ * A maximum of 4 million PIDs should be enough for a while:
+ */
+-#define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
+- (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))
++#define PID_MAX_LIMIT (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)
+
+ #endif
+diff -urN linux-libc-headers-2.6.12.0/include/linux/vt_kern.h linux-libc-headers-2.6.12.0-patched/include/linux/vt_kern.h
+--- linux-libc-headers-2.6.12.0/include/linux/vt_kern.h 2005-07-05 19:17:23.000000000 -0500
++++ linux-libc-headers-2.6.12.0-patched/include/linux/vt_kern.h 2005-08-18 11:39:30.000000000 -0500
+@@ -77,7 +77,7 @@
+ * we can easily avoid touching user space while holding the console spinlock.
+ */
+
+-#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
++#define CON_BUF_SIZE PAGE_SIZE
+ extern char con_buf[CON_BUF_SIZE];
+ extern struct semaphore con_buf_sem;
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-i2c_msg.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-i2c_msg.patch
new file mode 100644
index 0000000000..2c1eac3f8b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-i2c_msg.patch
@@ -0,0 +1,12 @@
+diff -urpN linux-libc-headers-2.6.12.0/include/linux/i2c-dev.h linux-libc-headers-2.6.12.0-patched/include/linux/i2c-dev.h
+--- linux-libc-headers-2.6.12.0/include/linux/i2c-dev.h 2005-07-06 02:17:21.000000000 +0200
++++ linux-libc-headers-2.6.12.0-patched/include/linux/i2c-dev.h 2006-04-26 13:10:56.000000000 +0200
+@@ -44,8 +44,6 @@ struct i2c_msg {
+ #define I2C_M_NO_RD_ACK 0x0800
+ short len; /* msg length */
+ char *buf; /* pointer to msg data */
+- int err;
+- short done;
+ };
+
+ /* To determine what functionality is present */
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-mips-nptl.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-mips-nptl.patch
new file mode 100644
index 0000000000..5f7167b62b
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.12.0-mips-nptl.patch
@@ -0,0 +1,90 @@
+diff -urN linux-libc-headers-2.6.12.0/include/asm-mips/inst.h linux-libc-headers-2.6.12.0-mips-nptl/include/asm-mips/inst.h
+--- linux-libc-headers-2.6.12.0/include/asm-mips/inst.h 2004-10-31 13:54:20.000000000 -0600
++++ linux-libc-headers-2.6.12.0-mips-nptl/include/asm-mips/inst.h 2005-08-10 21:20:57.000000000 -0500
+@@ -28,7 +28,7 @@
+ sdl_op, sdr_op, swr_op, cache_op,
+ ll_op, lwc1_op, lwc2_op, pref_op,
+ lld_op, ldc1_op, ldc2_op, ld_op,
+- sc_op, swc1_op, swc2_op, major_3b_op, /* Opcode 0x3b is unused */
++ sc_op, swc1_op, swc2_op, rdhwr_op,
+ scd_op, sdc1_op, sdc2_op, sd_op
+ };
+
+@@ -62,10 +62,10 @@
+ spimi_op, unused_rt_op_0x05, unused_rt_op_0x06, unused_rt_op_0x07,
+ tgei_op, tgeiu_op, tlti_op, tltiu_op,
+ teqi_op, unused_0x0d_rt_op, tnei_op, unused_0x0f_rt_op,
+- bltzal_op, bgezal_op, bltzall_op, bgezall_op
+- /*
+- * The others (0x14 - 0x1f) are unused.
+- */
++ bltzal_op, bgezal_op, bltzall_op, bgezall_op,
++ rt_op_0x14, rt_op_0x15, rt_op_0x16, rt_op_0x17,
++ rt_op_0x18, rt_op_0x19, rt_op_0x1a, rt_op_0x1b,
++ bposge32_op, rt_op_0x1d, rt_op_0x1e, rt_op_0x1f
+ };
+
+ /*
+diff -urN linux-libc-headers-2.6.12.0/include/asm-mips/unistd.h linux-libc-headers-2.6.12.0-mips-nptl/include/asm-mips/unistd.h
+--- linux-libc-headers-2.6.12.0/include/asm-mips/unistd.h 2005-07-05 19:17:29.000000000 -0500
++++ linux-libc-headers-2.6.12.0-mips-nptl/include/asm-mips/unistd.h 2005-08-10 21:22:27.000000000 -0500
+@@ -303,16 +303,17 @@
+ #define __NR_add_key (__NR_Linux + 280)
+ #define __NR_request_key (__NR_Linux + 281)
+ #define __NR_keyctl (__NR_Linux + 282)
++#define __NR_set_thread_area (__NR_Linux + 283)
+
+ /*
+ * Offset of the last Linux o32 flavoured syscall
+ */
+-#define __NR_Linux_syscalls 282
++#define __NR_Linux_syscalls 283
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
+
+ #define __NR_O32_Linux 4000
+-#define __NR_O32_Linux_syscalls 282
++#define __NR_O32_Linux_syscalls 283
+
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
+
+@@ -562,16 +563,17 @@
+ #define __NR_add_key (__NR_Linux + 239)
+ #define __NR_request_key (__NR_Linux + 240)
+ #define __NR_keyctl (__NR_Linux + 241)
++#define __NR_set_thread_area (__NR_Linux + 242)
+
+ /*
+ * Offset of the last Linux 64-bit flavoured syscall
+ */
+-#define __NR_Linux_syscalls 241
++#define __NR_Linux_syscalls 242
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
+
+ #define __NR_64_Linux 5000
+-#define __NR_64_Linux_syscalls 241
++#define __NR_64_Linux_syscalls 242
+
+ #if _MIPS_SIM == _MIPS_SIM_NABI32
+
+@@ -825,16 +827,17 @@
+ #define __NR_add_key (__NR_Linux + 243)
+ #define __NR_request_key (__NR_Linux + 244)
+ #define __NR_keyctl (__NR_Linux + 245)
++#define __NR_set_thread_area (__NR_Linux + 246)
+
+ /*
+ * Offset of the last N32 flavoured syscall
+ */
+-#define __NR_Linux_syscalls 245
++#define __NR_Linux_syscalls 246
+
+ #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
+
+ #define __NR_N32_Linux 6000
+-#define __NR_N32_Linux_syscalls 245
++#define __NR_N32_Linux_syscalls 246
+
+ #ifndef __ASSEMBLY__
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.8-cleanup.patch b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.8-cleanup.patch
new file mode 100644
index 0000000000..44461d1abf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.8-cleanup.patch
@@ -0,0 +1,8153 @@
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/addrspace.h linux-libc-headers-2.6.8.0/include/asm-mips/addrspace.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/addrspace.h 2004-03-28 07:51:50.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/addrspace.h 2004-08-26 05:53:12.000000000 -0500
+@@ -10,7 +10,23 @@
+ #ifndef _ASM_ADDRSPACE_H
+ #define _ASM_ADDRSPACE_H
+
+-#include <spaces.h>
++/**********************************************************************/
++/* Include the common bits for #include <spaces.h> */
++#ifndef __mips64
++
++#define CAC_BASE 0x80000000
++#define IO_BASE 0xa0000000
++#define UNCAC_BASE 0xa0000000
++#define MAP_BASE 0xc0000000
++
++/*
++ * This handles the memory map.
++ * We handle pages at KSEG0 for kernels with 32 bit address space.
++ */
++#define PAGE_OFFSET 0x80000000UL
++
++#endif /* ndef __mips64 */
++/**********************************************************************/
+
+ /*
+ * Configure language
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/asmmacro.h linux-libc-headers-2.6.8.0/include/asm-mips/asmmacro.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/asmmacro.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/asmmacro.h 2004-08-26 05:14:41.000000000 -0500
+@@ -9,10 +9,10 @@
+ #define _ASM_ASMMACRO_H
+
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #include <asm/asmmacro-32.h>
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ #include <asm/asmmacro-64.h>
+ #endif
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/checksum.h linux-libc-headers-2.6.8.0/include/asm-mips/checksum.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/checksum.h 2004-06-23 16:52:45.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/checksum.h 2004-08-26 05:14:41.000000000 -0500
+@@ -125,7 +125,7 @@
+ {
+ __asm__(
+ ".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t"
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ "addu\t%0, %2\n\t"
+ "sltu\t$1, %0, %2\n\t"
+ "addu\t%0, $1\n\t"
+@@ -138,7 +138,7 @@
+ "sltu\t$1, %0, %4\n\t"
+ "addu\t%0, $1\n\t"
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ "daddu\t%0, %2\n\t"
+ "daddu\t%0, %3\n\t"
+ "daddu\t%0, %4\n\t"
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/compat.h linux-libc-headers-2.6.8.0/include/asm-mips/compat.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/compat.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/compat.h 2004-08-26 05:23:05.000000000 -0500
+@@ -8,64 +8,64 @@
+
+ #define COMPAT_USER_HZ 100
+
+-typedef u32 compat_size_t;
+-typedef s32 compat_ssize_t;
+-typedef s32 compat_time_t;
+-typedef s32 compat_clock_t;
+-typedef s32 compat_suseconds_t;
+-
+-typedef s32 compat_pid_t;
+-typedef s32 compat_uid_t;
+-typedef s32 compat_gid_t;
+-typedef u32 compat_mode_t;
+-typedef u32 compat_ino_t;
+-typedef u32 compat_dev_t;
+-typedef s32 compat_off_t;
+-typedef s64 compat_loff_t;
+-typedef u32 compat_nlink_t;
+-typedef s32 compat_ipc_pid_t;
+-typedef s32 compat_daddr_t;
+-typedef s32 compat_caddr_t;
++typedef __u32 compat_size_t;
++typedef __s32 compat_ssize_t;
++typedef __s32 compat_time_t;
++typedef __s32 compat_clock_t;
++typedef __s32 compat_suseconds_t;
++
++typedef __s32 compat_pid_t;
++typedef __s32 compat_uid_t;
++typedef __s32 compat_gid_t;
++typedef __u32 compat_mode_t;
++typedef __u32 compat_ino_t;
++typedef __u32 compat_dev_t;
++typedef __s32 compat_off_t;
++typedef __s64 compat_loff_t;
++typedef __u32 compat_nlink_t;
++typedef __s32 compat_ipc_pid_t;
++typedef __s32 compat_daddr_t;
++typedef __s32 compat_caddr_t;
+ typedef struct {
+- s32 val[2];
++ __s32 val[2];
+ } compat_fsid_t;
+
+-typedef s32 compat_int_t;
+-typedef s32 compat_long_t;
+-typedef u32 compat_uint_t;
+-typedef u32 compat_ulong_t;
++typedef __s32 compat_int_t;
++typedef __s32 compat_long_t;
++typedef __u32 compat_uint_t;
++typedef __u32 compat_ulong_t;
+
+ struct compat_timespec {
+ compat_time_t tv_sec;
+- s32 tv_nsec;
++ __s32 tv_nsec;
+ };
+
+ struct compat_timeval {
+ compat_time_t tv_sec;
+- s32 tv_usec;
++ __s32 tv_usec;
+ };
+
+ struct compat_stat {
+ compat_dev_t st_dev;
+- s32 st_pad1[3];
++ __s32 st_pad1[3];
+ compat_ino_t st_ino;
+ compat_mode_t st_mode;
+ compat_nlink_t st_nlink;
+ compat_uid_t st_uid;
+ compat_gid_t st_gid;
+ compat_dev_t st_rdev;
+- s32 st_pad2[2];
++ __s32 st_pad2[2];
+ compat_off_t st_size;
+- s32 st_pad3;
++ __s32 st_pad3;
+ compat_time_t st_atime;
+- s32 st_atime_nsec;
++ __s32 st_atime_nsec;
+ compat_time_t st_mtime;
+- s32 st_mtime_nsec;
++ __s32 st_mtime_nsec;
+ compat_time_t st_ctime;
+- s32 st_ctime_nsec;
+- s32 st_blksize;
+- s32 st_blocks;
+- s32 st_pad4[14];
++ __s32 st_ctime_nsec;
++ __s32 st_blksize;
++ __s32 st_blocks;
++ __s32 st_pad4[14];
+ };
+
+ struct compat_flock {
+@@ -73,10 +73,10 @@
+ short l_whence;
+ compat_off_t l_start;
+ compat_off_t l_len;
+- s32 l_sysid;
++ __s32 l_sysid;
+ compat_pid_t l_pid;
+ short __unused;
+- s32 pad[4];
++ __s32 pad[4];
+ };
+
+ #define F_GETLK64 33
+@@ -107,12 +107,12 @@
+
+ #define COMPAT_RLIM_INFINITY 0x7fffffffUL
+
+-typedef u32 compat_old_sigset_t; /* at least 32 bits */
++typedef __u32 compat_old_sigset_t; /* at least 32 bits */
+
+ #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */
+ #define _COMPAT_NSIG_BPW 32
+
+-typedef u32 compat_sigset_word;
++typedef __u32 compat_sigset_word;
+
+ #define COMPAT_OFF_T_MAX 0x7fffffff
+ #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+@@ -123,7 +123,7 @@
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+-typedef u32 compat_uptr_t;
++typedef __u32 compat_uptr_t;
+
+ static inline void *compat_ptr(compat_uptr_t uptr)
+ {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5074.h linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5074.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5074.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5074.h 2004-08-26 13:21:48.000000000 -0500
+@@ -34,5 +34,5 @@
+ extern void ddb5074_led_d2(int on);
+ extern void ddb5074_led_d3(int on);
+
+-extern void nile4_irq_setup(u32 base);
++extern void nile4_irq_setup(__u32 base);
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5476.h linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5476.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5476.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5476.h 2004-08-26 05:24:06.000000000 -0500
+@@ -145,13 +145,13 @@
+ extern void nile4_enable_irq(int nile4_irq);
+ extern void nile4_disable_irq(int nile4_irq);
+ extern void nile4_disable_irq_all(void);
+-extern u16 nile4_get_irq_stat(int cpu_irq);
++extern __u16 nile4_get_irq_stat(int cpu_irq);
+ extern void nile4_enable_irq_output(int cpu_irq);
+ extern void nile4_disable_irq_output(int cpu_irq);
+ extern void nile4_set_pci_irq_polarity(int pci_irq, int high);
+ extern void nile4_set_pci_irq_level_or_edge(int pci_irq, int level);
+ extern void nile4_clear_irq(int nile4_irq);
+-extern void nile4_clear_irq_mask(u32 mask);
+-extern u8 nile4_i8259_iack(void);
++extern void nile4_clear_irq_mask(__u32 mask);
++extern __u8 nile4_i8259_iack(void);
+ extern void nile4_dump_irq_status(void); /* Debug */
+ #endif /* !__ASSEMBLY__ */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5xxx.h linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5xxx.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/ddb5xxx/ddb5xxx.h 2004-01-17 17:03:47.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/ddb5xxx/ddb5xxx.h 2004-08-26 05:24:01.000000000 -0500
+@@ -177,46 +177,46 @@
+ * interrupt load
+ */
+ #ifndef CONFIG_DDB5074
+- volatile u32 *p = (volatile u32 *)0xbfc00000;
++ volatile __u32 *p = (volatile __u32 *)0xbfc00000;
+ (void)(*p);
+ #endif
+ }
+
+-static inline void ddb_out32(u32 offset, u32 val)
++static inline void ddb_out32(__u32 offset, __u32 val)
+ {
+- *(volatile u32 *)(DDB_BASE+offset) = val;
++ *(volatile __u32 *)(DDB_BASE+offset) = val;
+ ddb_sync();
+ }
+
+-static inline u32 ddb_in32(u32 offset)
++static inline __u32 ddb_in32(__u32 offset)
+ {
+- u32 val = *(volatile u32 *)(DDB_BASE+offset);
++ __u32 val = *(volatile __u32 *)(DDB_BASE+offset);
+ ddb_sync();
+ return val;
+ }
+
+-static inline void ddb_out16(u32 offset, u16 val)
++static inline void ddb_out16(__u32 offset, __u16 val)
+ {
+- *(volatile u16 *)(DDB_BASE+offset) = val;
++ *(volatile __u16 *)(DDB_BASE+offset) = val;
+ ddb_sync();
+ }
+
+-static inline u16 ddb_in16(u32 offset)
++static inline __u16 ddb_in16(__u32 offset)
+ {
+- u16 val = *(volatile u16 *)(DDB_BASE+offset);
++ __u16 val = *(volatile __u16 *)(DDB_BASE+offset);
+ ddb_sync();
+ return val;
+ }
+
+-static inline void ddb_out8(u32 offset, u8 val)
++static inline void ddb_out8(__u32 offset, __u8 val)
+ {
+- *(volatile u8 *)(DDB_BASE+offset) = val;
++ *(volatile __u8 *)(DDB_BASE+offset) = val;
+ ddb_sync();
+ }
+
+-static inline u8 ddb_in8(u32 offset)
++static inline __u8 ddb_in8(__u32 offset)
+ {
+- u8 val = *(volatile u8 *)(DDB_BASE+offset);
++ __u8 val = *(volatile __u8 *)(DDB_BASE+offset);
+ ddb_sync();
+ return val;
+ }
+@@ -226,10 +226,10 @@
+ * Physical Device Address Registers
+ */
+
+-extern u32
+-ddb_calc_pdar(u32 phys, u32 size, int width, int on_memory_bus, int pci_visible);
++extern __u32
++ddb_calc_pdar(__u32 phys, __u32 size, int width, int on_memory_bus, int pci_visible);
+ extern void
+-ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
++ddb_set_pdar(__u32 pdar, __u32 phys, __u32 size, int width,
+ int on_memory_bus, int pci_visible);
+
+ /*
+@@ -248,7 +248,7 @@
+ #define DDB_PCI_ACCESS_32 0x10 /* for pci init0/1 regs */
+
+
+-extern void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options);
++extern void ddb_set_pmr(__u32 pmr, __u32 type, __u32 addr, __u32 options);
+
+ /*
+ * we need to reset pci bus when we start up and shutdown
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/dec/ioasic.h linux-libc-headers-2.6.8.0/include/asm-mips/dec/ioasic.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/dec/ioasic.h 2004-01-17 17:03:47.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/dec/ioasic.h 2004-08-26 05:25:44.000000000 -0500
+@@ -18,14 +18,14 @@
+
+ extern spinlock_t ioasic_ssr_lock;
+
+-extern volatile u32 *ioasic_base;
++extern volatile __u32 *ioasic_base;
+
+-static inline void ioasic_write(unsigned int reg, u32 v)
++static inline void ioasic_write(unsigned int reg, __u32 v)
+ {
+ ioasic_base[reg / 4] = v;
+ }
+
+-static inline u32 ioasic_read(unsigned int reg)
++static inline __u32 ioasic_read(unsigned int reg)
+ {
+ return ioasic_base[reg / 4];
+ }
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/dec/kn02.h linux-libc-headers-2.6.8.0/include/asm-mips/dec/kn02.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/dec/kn02.h 2004-01-17 17:03:47.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/dec/kn02.h 2004-08-26 05:25:47.000000000 -0500
+@@ -97,7 +97,7 @@
+
+
+ #ifndef __ASSEMBLY__
+-extern u32 cached_kn02_csr;
++extern __u32 cached_kn02_csr;
+ extern spinlock_t kn02_lock;
+ extern void init_kn02_irqs(int base);
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/elf.h linux-libc-headers-2.6.8.0/include/asm-mips/elf.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/elf.h 2004-03-28 07:51:51.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/elf.h 2004-08-26 05:17:25.000000000 -0500
+@@ -122,7 +122,7 @@
+ typedef double elf_fpreg_t;
+ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+
+ /*
+ * This is used to ensure we don't load something for the wrong architecture.
+@@ -150,9 +150,9 @@
+ */
+ #define ELF_CLASS ELFCLASS32
+
+-#endif /* CONFIG_MIPS32 */
++#endif /* ndef __mips64 */
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ /*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+@@ -174,7 +174,7 @@
+ */
+ #define ELF_CLASS ELFCLASS64
+
+-#endif /* CONFIG_MIPS64 */
++#endif /* __mips64 */
+
+ /*
+ * These are used to set parameters in the core dumps.
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/galileo-boards/ev96100.h linux-libc-headers-2.6.8.0/include/asm-mips/galileo-boards/ev96100.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/galileo-boards/ev96100.h 2004-03-28 07:51:53.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/galileo-boards/ev96100.h 2004-08-26 05:23:12.000000000 -0500
+@@ -46,9 +46,9 @@
+ * bytes when running bigendian.
+ */
+ #define __GT_READ(ofs) \
+- (*(volatile u32 *)(GT64120_BASE+(ofs)))
++ (*(volatile __u32 *)(GT64120_BASE+(ofs)))
+ #define __GT_WRITE(ofs, data) \
+- do { *(volatile u32 *)(GT64120_BASE+(ofs)) = (data); } while (0)
++ do { *(volatile __u32 *)(GT64120_BASE+(ofs)) = (data); } while (0)
+ #define GT_READ(ofs) le32_to_cpu(__GT_READ(ofs))
+ #define GT_WRITE(ofs, data) __GT_WRITE(ofs, cpu_to_le32(data))
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/galileo-boards/gt96100.h linux-libc-headers-2.6.8.0/include/asm-mips/galileo-boards/gt96100.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/galileo-boards/gt96100.h 2004-03-28 07:51:53.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/galileo-boards/gt96100.h 2004-08-26 05:23:17.000000000 -0500
+@@ -27,9 +27,9 @@
+ #define MIPS_GT96100_BASE (KSEG1ADDR(0x14000000))
+
+ #define GT96100_WRITE(ofs, data) \
+- *(volatile u32 *)(MIPS_GT96100_BASE+ofs) = cpu_to_le32(data)
++ *(volatile __u32 *)(MIPS_GT96100_BASE+ofs) = cpu_to_le32(data)
+ #define GT96100_READ(ofs) \
+- le32_to_cpu(*(volatile u32 *)(MIPS_GT96100_BASE+ofs))
++ le32_to_cpu(*(volatile __u32 *)(MIPS_GT96100_BASE+ofs))
+
+ #define GT96100_ETH_IO_SIZE 0x4000
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/gt64120.h linux-libc-headers-2.6.8.0/include/asm-mips/gt64120.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/gt64120.h 2004-03-28 07:51:51.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/gt64120.h 2004-08-26 05:22:36.000000000 -0500
+@@ -420,9 +420,9 @@
+ * bytes when running bigendian. We also provide non-swapping versions.
+ */
+ #define __GT_READ(ofs) \
+- (*(volatile u32 *)(GT64120_BASE+(ofs)))
++ (*(volatile __u32 *)(GT64120_BASE+(ofs)))
+ #define __GT_WRITE(ofs, data) \
+- do { *(volatile u32 *)(GT64120_BASE+(ofs)) = (data); } while (0)
++ do { *(volatile __u32 *)(GT64120_BASE+(ofs)) = (data); } while (0)
+ #define GT_READ(ofs) le32_to_cpu(__GT_READ(ofs))
+ #define GT_WRITE(ofs, data) __GT_WRITE(ofs, cpu_to_le32(data))
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/io.h linux-libc-headers-2.6.8.0/include/asm-mips/io.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/io.h 2004-03-28 07:51:51.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/io.h 2004-08-26 05:24:16.000000000 -0500
+@@ -173,14 +173,14 @@
+ unsigned long flags)
+ {
+ if (cpu_has_64bit_addresses) {
+- u64 base = UNCAC_BASE;
++ __u64 base = UNCAC_BASE;
+
+ /*
+ * R10000 supports a 2 bit uncached attribute therefore
+ * UNCAC_BASE may not equal IO_BASE.
+ */
+ if (flags == _CACHE_UNCACHED)
+- base = (u64) IO_BASE;
++ base = (__u64) IO_BASE;
+ return (void *) (unsigned long) (base + offset);
+ }
+
+@@ -245,10 +245,10 @@
+ #define __raw_readb(addr) (*(volatile unsigned char *)(addr))
+ #define __raw_readw(addr) (*(volatile unsigned short *)(addr))
+ #define __raw_readl(addr) (*(volatile unsigned int *)(addr))
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #define ____raw_readq(addr) \
+ ({ \
+- u64 __res; \
++ __u64 __res; \
+ \
+ __asm__ __volatile__ ( \
+ " .set mips3 # ____raw_readq \n" \
+@@ -263,7 +263,7 @@
+ #define __raw_readq(addr) \
+ ({ \
+ unsigned long __flags; \
+- u64 __res; \
++ __u64 __res; \
+ \
+ local_irq_save(__flags); \
+ __res = ____raw_readq(addr); \
+@@ -271,7 +271,7 @@
+ __res; \
+ })
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ #define ____raw_readq(addr) (*(volatile unsigned long *)(addr))
+ #define __raw_readq(addr) ____raw_readq(addr)
+ #endif
+@@ -288,10 +288,10 @@
+ #define __raw_writeb(b,addr) ((*(volatile unsigned char *)(addr)) = (b))
+ #define __raw_writew(w,addr) ((*(volatile unsigned short *)(addr)) = (w))
+ #define __raw_writel(l,addr) ((*(volatile unsigned int *)(addr)) = (l))
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #define ____raw_writeq(val,addr) \
+ ({ \
+- u64 __tmp; \
++ __u64 __tmp; \
+ \
+ __asm__ __volatile__ ( \
+ " .set mips3 \n" \
+@@ -313,7 +313,7 @@
+ local_irq_restore(__flags); \
+ })
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ #define ____raw_writeq(q,addr) ((*(volatile unsigned long *)(addr)) = (q))
+ #define __raw_writeq(q,addr) ____raw_writeq(q, addr)
+ #endif
+@@ -400,28 +400,28 @@
+ {
+ port = __swizzle_addr_b(port);
+
+- *(volatile u8 *)(mips_io_port_base + port) = __ioswab8(val);
++ *(volatile __u8 *)(mips_io_port_base + port) = __ioswab8(val);
+ }
+
+ static inline void __outw(unsigned short val, unsigned long port)
+ {
+ port = __swizzle_addr_w(port);
+
+- *(volatile u16 *)(mips_io_port_base + port) = __ioswab16(val);
++ *(volatile __u16 *)(mips_io_port_base + port) = __ioswab16(val);
+ }
+
+ static inline void __outl(unsigned int val, unsigned long port)
+ {
+ port = __swizzle_addr_l(port);
+
+- *(volatile u32 *)(mips_io_port_base + port) = __ioswab32(val);
++ *(volatile __u32 *)(mips_io_port_base + port) = __ioswab32(val);
+ }
+
+ static inline void __outb_p(unsigned char val, unsigned long port)
+ {
+ port = __swizzle_addr_b(port);
+
+- *(volatile u8 *)(mips_io_port_base + port) = __ioswab8(val);
++ *(volatile __u8 *)(mips_io_port_base + port) = __ioswab8(val);
+ SLOW_DOWN_IO;
+ }
+
+@@ -429,7 +429,7 @@
+ {
+ port = __swizzle_addr_w(port);
+
+- *(volatile u16 *)(mips_io_port_base + port) = __ioswab16(val);
++ *(volatile __u16 *)(mips_io_port_base + port) = __ioswab16(val);
+ SLOW_DOWN_IO;
+ }
+
+@@ -437,7 +437,7 @@
+ {
+ port = __swizzle_addr_l(port);
+
+- *(volatile u32 *)(mips_io_port_base + port) = __ioswab32(val);
++ *(volatile __u32 *)(mips_io_port_base + port) = __ioswab32(val);
+ SLOW_DOWN_IO;
+ }
+
+@@ -452,30 +452,30 @@
+ {
+ port = __swizzle_addr_b(port);
+
+- return __ioswab8(*(volatile u8 *)(mips_io_port_base + port));
++ return __ioswab8(*(volatile __u8 *)(mips_io_port_base + port));
+ }
+
+ static inline unsigned short __inw(unsigned long port)
+ {
+ port = __swizzle_addr_w(port);
+
+- return __ioswab16(*(volatile u16 *)(mips_io_port_base + port));
++ return __ioswab16(*(volatile __u16 *)(mips_io_port_base + port));
+ }
+
+ static inline unsigned int __inl(unsigned long port)
+ {
+ port = __swizzle_addr_l(port);
+
+- return __ioswab32(*(volatile u32 *)(mips_io_port_base + port));
++ return __ioswab32(*(volatile __u32 *)(mips_io_port_base + port));
+ }
+
+ static inline unsigned char __inb_p(unsigned long port)
+ {
+- u8 __val;
++ __u8 __val;
+
+ port = __swizzle_addr_b(port);
+
+- __val = *(volatile u8 *)(mips_io_port_base + port);
++ __val = *(volatile __u8 *)(mips_io_port_base + port);
+ SLOW_DOWN_IO;
+
+ return __ioswab8(__val);
+@@ -483,11 +483,11 @@
+
+ static inline unsigned short __inw_p(unsigned long port)
+ {
+- u16 __val;
++ __u16 __val;
+
+ port = __swizzle_addr_w(port);
+
+- __val = *(volatile u16 *)(mips_io_port_base + port);
++ __val = *(volatile __u16 *)(mips_io_port_base + port);
+ SLOW_DOWN_IO;
+
+ return __ioswab16(__val);
+@@ -495,11 +495,11 @@
+
+ static inline unsigned int __inl_p(unsigned long port)
+ {
+- u32 __val;
++ __u32 __val;
+
+ port = __swizzle_addr_l(port);
+
+- __val = *(volatile u32 *)(mips_io_port_base + port);
++ __val = *(volatile __u32 *)(mips_io_port_base + port);
+ SLOW_DOWN_IO;
+
+ return __ioswab32(__val);
+@@ -515,7 +515,7 @@
+ static inline void __outsb(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- outb(*(u8 *)addr, port);
++ outb(*(__u8 *)addr, port);
+ addr++;
+ }
+ }
+@@ -523,7 +523,7 @@
+ static inline void __insb(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- *(u8 *)addr = inb(port);
++ *(__u8 *)addr = inb(port);
+ addr++;
+ }
+ }
+@@ -531,7 +531,7 @@
+ static inline void __outsw(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- outw(*(u16 *)addr, port);
++ outw(*(__u16 *)addr, port);
+ addr += 2;
+ }
+ }
+@@ -539,7 +539,7 @@
+ static inline void __insw(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- *(u16 *)addr = inw(port);
++ *(__u16 *)addr = inw(port);
+ addr += 2;
+ }
+ }
+@@ -547,7 +547,7 @@
+ static inline void __outsl(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- outl(*(u32 *)addr, port);
++ outl(*(__u32 *)addr, port);
+ addr += 4;
+ }
+ }
+@@ -555,7 +555,7 @@
+ static inline void __insl(unsigned long port, void *addr, unsigned int count)
+ {
+ while (count--) {
+- *(u32 *)addr = inl(port);
++ *(__u32 *)addr = inl(port);
+ addr += 4;
+ }
+ }
+@@ -617,7 +617,7 @@
+ #define __CSR_32_ADJUST 0
+ #endif
+
+-#define csr_out32(v,a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
+-#define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
++#define csr_out32(v,a) (*(volatile __u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
++#define csr_in32(a) (*(volatile __u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
+
+ #endif /* _ASM_IO_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/ip32/mace.h linux-libc-headers-2.6.8.0/include/asm-mips/ip32/mace.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/ip32/mace.h 2004-06-09 07:00:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/ip32/mace.h 2004-08-26 05:14:41.000000000 -0500
+@@ -22,7 +22,7 @@
+ #undef BIT
+ #define BIT(x) (1ULL << (x))
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ typedef struct {
+ volatile unsigned long long reg;
+ } mace64_t;
+@@ -32,7 +32,7 @@
+ volatile unsigned long reg;
+ } mace32_t;
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ typedef struct {
+ volatile unsigned long reg;
+ } mace64_t;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/it8172/it8172.h linux-libc-headers-2.6.8.0/include/asm-mips/it8172/it8172.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/it8172/it8172.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/it8172/it8172.h 2004-08-26 05:22:54.000000000 -0500
+@@ -336,13 +336,13 @@
+ #define TIMER_TIDR 0x0E
+
+
+-#define IT_WRITE(ofs, data) *(volatile u32 *)KSEG1ADDR((IT8172_BASE+ofs)) = data
+-#define IT_READ(ofs, data) data = *(volatile u32 *)KSEG1ADDR((IT8172_BASE+ofs))
++#define IT_WRITE(ofs, data) *(volatile __u32 *)KSEG1ADDR((IT8172_BASE+ofs)) = data
++#define IT_READ(ofs, data) data = *(volatile __u32 *)KSEG1ADDR((IT8172_BASE+ofs))
+
+-#define IT_IO_WRITE(ofs, data) *(volatile u32 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs)) = data
+-#define IT_IO_READ(ofs, data) data = *(volatile u32 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs))
++#define IT_IO_WRITE(ofs, data) *(volatile __u32 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs)) = data
++#define IT_IO_READ(ofs, data) data = *(volatile __u32 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs))
+
+-#define IT_IO_WRITE16(ofs, data) *(volatile u16 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs)) = data
+-#define IT_IO_READ16(ofs, data) data = *(volatile u16 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs))
++#define IT_IO_WRITE16(ofs, data) *(volatile __u16 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs)) = data
++#define IT_IO_READ16(ofs, data) data = *(volatile __u16 *)KSEG1ADDR((IT8172_PCI_IO_BASE+ofs))
+
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/lasat/head.h linux-libc-headers-2.6.8.0/include/asm-mips/lasat/head.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/lasat/head.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/lasat/head.h 2004-08-26 05:23:42.000000000 -0500
+@@ -10,12 +10,12 @@
+ #ifndef _LANGUAGE_ASSEMBLY
+ #include <linux/types.h>
+ struct bootloader_header {
+- u32 magic[2];
+- u32 version;
+- u32 image_start;
+- u32 image_size;
+- u32 kernel_start;
+- u32 kernel_entry;
++ __u32 magic[2];
++ __u32 version;
++ __u32 image_start;
++ __u32 image_size;
++ __u32 kernel_start;
++ __u32 kernel_entry;
+ };
+ #endif
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/lasat/lasat.h linux-libc-headers-2.6.8.0/include/asm-mips/lasat/lasat.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/lasat/lasat.h 2004-06-09 07:00:42.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/lasat/lasat.h 2004-08-26 05:23:50.000000000 -0500
+@@ -25,9 +25,9 @@
+ #ifndef _LANGUAGE_ASSEMBLY
+
+ extern struct lasat_misc {
+- volatile u32 *reset_reg;
+- volatile u32 *flash_wp_reg;
+- u32 flash_wp_bit;
++ volatile __u32 *reset_reg;
++ volatile __u32 *flash_wp_reg;
++ __u32 flash_wp_bit;
+ } *lasat_misc;
+
+ enum lasat_mtdparts {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/m48t35.h linux-libc-headers-2.6.8.0/include/asm-mips/m48t35.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/m48t35.h 2004-01-17 17:03:44.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/m48t35.h 2004-08-26 05:23:39.000000000 -0500
+@@ -8,15 +8,15 @@
+ extern spinlock_t rtc_lock;
+
+ struct m48t35_rtc {
+- volatile u8 pad[0x7ff8]; /* starts at 0x7ff8 */
+- volatile u8 control;
+- volatile u8 sec;
+- volatile u8 min;
+- volatile u8 hour;
+- volatile u8 day;
+- volatile u8 date;
+- volatile u8 month;
+- volatile u8 year;
++ volatile __u8 pad[0x7ff8]; /* starts at 0x7ff8 */
++ volatile __u8 control;
++ volatile __u8 sec;
++ volatile __u8 min;
++ volatile __u8 hour;
++ volatile __u8 day;
++ volatile __u8 date;
++ volatile __u8 month;
++ volatile __u8 year;
+ };
+
+ #define M48T35_RTC_SET 0x80
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/bonito64.h linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/bonito64.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/bonito64.h 2004-03-28 07:51:54.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/bonito64.h 2004-08-26 05:21:59.000000000 -0500
+@@ -34,7 +34,7 @@
+ extern unsigned long _pcictrl_bonito;
+ extern unsigned long _pcictrl_bonito_pcicfg;
+
+-#define BONITO(x) *(volatile u32 *)(_pcictrl_bonito + (x))
++#define BONITO(x) *(volatile __u32 *)(_pcictrl_bonito + (x))
+
+ #endif /* __ASSEMBLY__ */
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/generic.h linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/generic.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/generic.h 2004-03-28 07:51:54.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/generic.h 2004-08-26 05:22:06.000000000 -0500
+@@ -74,7 +74,7 @@
+ #define MIPS_REVISION_CORID_CORE_EMUL_BON 0x63
+ #define MIPS_REVISION_CORID_CORE_EMUL_MSC 0x65
+
+-#define MIPS_REVISION_CORID (((*(volatile u32 *)ioremap(MIPS_REVISION_REG, 4)) >> 10) & 0x3f)
++#define MIPS_REVISION_CORID (((*(volatile __u32 *)ioremap(MIPS_REVISION_REG, 4)) >> 10) & 0x3f)
+
+ extern unsigned int mips_revision_corid;
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/msc01_pci.h linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/msc01_pci.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/mips-boards/msc01_pci.h 2004-03-28 07:51:54.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/mips-boards/msc01_pci.h 2004-08-26 05:22:10.000000000 -0500
+@@ -212,8 +212,8 @@
+
+ #define MSC01_PCI_REG_BASE _pcictrl_msc
+
+-#define MSC_WRITE(reg, data) do { *(volatile u32 *)(reg) = data; } while (0)
+-#define MSC_READ(reg, data) do { data = *(volatile u32 *)(reg); } while (0)
++#define MSC_WRITE(reg, data) do { *(volatile __u32 *)(reg) = data; } while (0)
++#define MSC_READ(reg, data) do { data = *(volatile __u32 *)(reg); } while (0)
+
+ /*
+ * Registers absolute addresses
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/mipsregs.h linux-libc-headers-2.6.8.0/include/asm-mips/mipsregs.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/mipsregs.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/mipsregs.h 2004-08-26 13:00:51.000000000 -0500
+@@ -14,7 +14,6 @@
+ #define _ASM_MIPSREGS_H
+
+ #include <linux/linkage.h>
+-#include <asm/hazards.h>
+
+ /*
+ * The following macros are especially useful for __asm__
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/mmu_context.h linux-libc-headers-2.6.8.0/include/asm-mips/mmu_context.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/mmu_context.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/mmu_context.h 2004-08-26 05:14:41.000000000 -0500
+@@ -27,12 +27,12 @@
+ */
+ #define TLBMISS_HANDLER_SETUP_PGD(pgd) \
+ pgd_current[smp_processor_id()] = (unsigned long)(pgd)
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #define TLBMISS_HANDLER_SETUP() \
+ write_c0_context((unsigned long) smp_processor_id() << 23); \
+ TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ #define TLBMISS_HANDLER_SETUP() \
+ write_c0_context((unsigned long) &pgd_current[smp_processor_id()] << 23); \
+ TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/module.h linux-libc-headers-2.6.8.0/include/asm-mips/module.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/module.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/module.h 2004-08-26 05:14:41.000000000 -0500
+@@ -21,7 +21,7 @@
+ Elf64_Sxword r_addend; /* Addend. */
+ } Elf64_Mips_Rela;
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+
+ #define Elf_Shdr Elf32_Shdr
+ #define Elf_Sym Elf32_Sym
+@@ -29,7 +29,7 @@
+
+ #endif
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+
+ #define Elf_Shdr Elf64_Shdr
+ #define Elf_Sym Elf64_Sym
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/msgbuf.h linux-libc-headers-2.6.8.0/include/asm-mips/msgbuf.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/msgbuf.h 2004-01-17 17:03:44.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/msgbuf.h 2004-08-26 05:15:04.000000000 -0500
+@@ -14,25 +14,25 @@
+
+ struct msqid64_ds {
+ struct ipc64_perm msg_perm;
+-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused1;
+ #endif
+ __kernel_time_t msg_stime; /* last msgsnd time */
+-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused1;
+ #endif
+-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused2;
+ #endif
+ __kernel_time_t msg_rtime; /* last msgrcv time */
+-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused2;
+ #endif
+-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused3;
+ #endif
+ __kernel_time_t msg_ctime; /* last change time */
+-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
++#if !defined(__mips64) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+ unsigned long __unused3;
+ #endif
+ unsigned long msg_cbytes; /* current number of bytes on queue */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/nile4.h linux-libc-headers-2.6.8.0/include/asm-mips/nile4.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/nile4.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/nile4.h 2004-08-26 05:22:46.000000000 -0500
+@@ -202,45 +202,45 @@
+
+ static inline void nile4_sync(void)
+ {
+- volatile u32 *p = (volatile u32 *)0xbfc00000;
++ volatile __u32 *p = (volatile __u32 *)0xbfc00000;
+ (void)(*p);
+ }
+
+-static inline void nile4_out32(u32 offset, u32 val)
++static inline void nile4_out32(__u32 offset, __u32 val)
+ {
+- *(volatile u32 *)(NILE4_BASE+offset) = val;
++ *(volatile __u32 *)(NILE4_BASE+offset) = val;
+ nile4_sync();
+ }
+
+-static inline u32 nile4_in32(u32 offset)
++static inline __u32 nile4_in32(__u32 offset)
+ {
+- u32 val = *(volatile u32 *)(NILE4_BASE+offset);
++ __u32 val = *(volatile __u32 *)(NILE4_BASE+offset);
+ nile4_sync();
+ return val;
+ }
+
+-static inline void nile4_out16(u32 offset, u16 val)
++static inline void nile4_out16(__u32 offset, __u16 val)
+ {
+- *(volatile u16 *)(NILE4_BASE+offset) = val;
++ *(volatile __u16 *)(NILE4_BASE+offset) = val;
+ nile4_sync();
+ }
+
+-static inline u16 nile4_in16(u32 offset)
++static inline __u16 nile4_in16(__u32 offset)
+ {
+- u16 val = *(volatile u16 *)(NILE4_BASE+offset);
++ __u16 val = *(volatile __u16 *)(NILE4_BASE+offset);
+ nile4_sync();
+ return val;
+ }
+
+-static inline void nile4_out8(u32 offset, u8 val)
++static inline void nile4_out8(__u32 offset, __u8 val)
+ {
+- *(volatile u8 *)(NILE4_BASE+offset) = val;
++ *(volatile __u8 *)(NILE4_BASE+offset) = val;
+ nile4_sync();
+ }
+
+-static inline u8 nile4_in8(u32 offset)
++static inline __u8 nile4_in8(__u32 offset)
+ {
+- u8 val = *(volatile u8 *)(NILE4_BASE+offset);
++ __u8 val = *(volatile __u8 *)(NILE4_BASE+offset);
+ nile4_sync();
+ return val;
+ }
+@@ -250,7 +250,7 @@
+ * Physical Device Address Registers
+ */
+
+-extern void nile4_set_pdar(u32 pdar, u32 phys, u32 size, int width,
++extern void nile4_set_pdar(__u32 pdar, __u32 phys, __u32 size, int width,
+ int on_memory_bus, int visible);
+
+
+@@ -276,7 +276,7 @@
+ #define NILE4_PCI_IACK_BASE NILE4_PCI_IO_BASE
+
+
+-extern void nile4_set_pmr(u32 pmr, u32 type, u32 addr);
++extern void nile4_set_pmr(__u32 pmr, __u32 type, __u32 addr);
+
+
+ /*
+@@ -296,14 +296,14 @@
+ extern void nile4_enable_irq(unsigned int nile4_irq);
+ extern void nile4_disable_irq(unsigned int nile4_irq);
+ extern void nile4_disable_irq_all(void);
+-extern u16 nile4_get_irq_stat(int cpu_irq);
++extern __u16 nile4_get_irq_stat(int cpu_irq);
+ extern void nile4_enable_irq_output(int cpu_irq);
+ extern void nile4_disable_irq_output(int cpu_irq);
+ extern void nile4_set_pci_irq_polarity(int pci_irq, int high);
+ extern void nile4_set_pci_irq_level_or_edge(int pci_irq, int level);
+ extern void nile4_clear_irq(int nile4_irq);
+-extern void nile4_clear_irq_mask(u32 mask);
+-extern u8 nile4_i8259_iack(void);
++extern void nile4_clear_irq_mask(__u32 mask);
++extern __u8 nile4_i8259_iack(void);
+ extern void nile4_dump_irq_status(void); /* Debug */
+
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/paccess.h linux-libc-headers-2.6.8.0/include/asm-mips/paccess.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/paccess.h 2004-01-17 17:03:44.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/paccess.h 2004-08-26 05:17:48.000000000 -0500
+@@ -14,11 +14,12 @@
+ #define _ASM_PACCESS_H
+
+ #include <linux/errno.h>
++#include <linux/linkage.h>
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #define __PA_ADDR ".word"
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ #define __PA_ADDR ".dword"
+ #endif
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/pci/bridge.h linux-libc-headers-2.6.8.0/include/asm-mips/pci/bridge.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/pci/bridge.h 2004-03-28 07:51:54.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/pci/bridge.h 2004-08-26 05:25:40.000000000 -0500
+@@ -48,9 +48,9 @@
+ * All accesses to bridge hardware registers must be done
+ * using 32-bit loads and stores.
+ */
+-typedef u32 bridgereg_t;
++typedef __u32 bridgereg_t;
+
+-typedef u64 bridge_ate_t;
++typedef __u64 bridge_ate_t;
+
+ /* pointers to bridge ATEs
+ * are always "pointer to volatile"
+@@ -199,37 +199,37 @@
+
+ /* PCI Device Configuration Spaces 0x020000-0x027FFF */
+ union { /* make all access sizes available. */
+- u8 c[0x1000 / 1];
+- u16 s[0x1000 / 2];
+- u32 l[0x1000 / 4];
+- u64 d[0x1000 / 8];
++ __u8 c[0x1000 / 1];
++ __u16 s[0x1000 / 2];
++ __u32 l[0x1000 / 4];
++ __u64 d[0x1000 / 8];
+ union {
+- u8 c[0x100 / 1];
+- u16 s[0x100 / 2];
+- u32 l[0x100 / 4];
+- u64 d[0x100 / 8];
++ __u8 c[0x100 / 1];
++ __u16 s[0x100 / 2];
++ __u32 l[0x100 / 4];
++ __u64 d[0x100 / 8];
+ } f[8];
+ } b_type0_cfg_dev[8]; /* 0x020000 */
+
+ /* PCI Type 1 Configuration Space 0x028000-0x028FFF */
+ union { /* make all access sizes available. */
+- u8 c[0x1000 / 1];
+- u16 s[0x1000 / 2];
+- u32 l[0x1000 / 4];
+- u64 d[0x1000 / 8];
++ __u8 c[0x1000 / 1];
++ __u16 s[0x1000 / 2];
++ __u32 l[0x1000 / 4];
++ __u64 d[0x1000 / 8];
+ } b_type1_cfg; /* 0x028000-0x029000 */
+
+ char _pad_029000[0x007000]; /* 0x029000-0x030000 */
+
+ /* PCI Interrupt Acknowledge Cycle 0x030000 */
+ union {
+- u8 c[8 / 1];
+- u16 s[8 / 2];
+- u32 l[8 / 4];
+- u64 d[8 / 8];
++ __u8 c[8 / 1];
++ __u16 s[8 / 2];
++ __u32 l[8 / 4];
++ __u64 d[8 / 8];
+ } b_pci_iack; /* 0x030000 */
+
+- u8 _pad_030007[0x04fff8]; /* 0x030008-0x07FFFF */
++ __u8 _pad_030007[0x04fff8]; /* 0x030008-0x07FFFF */
+
+ /* External Address Translation Entry RAM 0x080000-0x0FFFFF */
+ bridge_ate_t b_ext_ate_ram[0x10000];
+@@ -239,10 +239,10 @@
+
+ /* PCI/GIO Device Spaces 0x200000-0xBFFFFF */
+ union { /* make all access sizes available. */
+- u8 c[0x100000 / 1];
+- u16 s[0x100000 / 2];
+- u32 l[0x100000 / 4];
+- u64 d[0x100000 / 8];
++ __u8 c[0x100000 / 1];
++ __u16 s[0x100000 / 2];
++ __u32 l[0x100000 / 4];
++ __u64 d[0x100000 / 8];
+ } b_devio_raw[10]; /* 0x200000 */
+
+ /* b_devio macro is a bit strange; it reflects the
+@@ -253,10 +253,10 @@
+
+ /* External Flash Proms 1,0 0xC00000-0xFFFFFF */
+ union { /* make all access sizes available. */
+- u8 c[0x400000 / 1]; /* read-only */
+- u16 s[0x400000 / 2]; /* read-write */
+- u32 l[0x400000 / 4]; /* read-only */
+- u64 d[0x400000 / 8]; /* read-only */
++ __u8 c[0x400000 / 1]; /* read-only */
++ __u16 s[0x400000 / 2]; /* read-write */
++ __u32 l[0x400000 / 4]; /* read-only */
++ __u64 d[0x400000 / 8]; /* read-only */
+ } b_external_flash; /* 0xC00000 */
+ } bridge_t;
+
+@@ -266,9 +266,9 @@
+ */
+ typedef struct bridge_err_cmdword_s {
+ union {
+- u32 cmd_word;
++ __u32 cmd_word;
+ struct {
+- u32 didn:4, /* Destination ID */
++ __u32 didn:4, /* Destination ID */
+ sidn:4, /* Source ID */
+ pactyp:4, /* Packet type */
+ tnum:5, /* Trans Number */
+@@ -799,17 +799,17 @@
+ #ifndef __ASSEMBLY__
+ /* Address translation entry for mapped pci32 accesses */
+ typedef union ate_u {
+- u64 ent;
++ __u64 ent;
+ struct ate_s {
+- u64 rmf:16;
+- u64 addr:36;
+- u64 targ:4;
+- u64 reserved:3;
+- u64 barrier:1;
+- u64 prefetch:1;
+- u64 precise:1;
+- u64 coherent:1;
+- u64 valid:1;
++ __u64 rmf:16;
++ __u64 addr:36;
++ __u64 targ:4;
++ __u64 reserved:3;
++ __u64 barrier:1;
++ __u64 prefetch:1;
++ __u64 precise:1;
++ __u64 coherent:1;
++ __u64 valid:1;
+ } field;
+ } ate_t;
+ #endif /* !__ASSEMBLY__ */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/pci_channel.h linux-libc-headers-2.6.8.0/include/asm-mips/pci_channel.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/pci_channel.h 2004-03-28 07:51:52.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/pci_channel.h 2004-08-26 05:21:47.000000000 -0500
+@@ -41,6 +41,6 @@
+ /*
+ * board supplied pci irq fixup routine
+ */
+-extern int pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
++extern int pcibios_map_irq(struct pci_dev *dev, __u8 slot, __u8 pin);
+
+ #endif /* __ASM_PCI_CHANNEL_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/pgalloc.h linux-libc-headers-2.6.8.0/include/asm-mips/pgalloc.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/pgalloc.h 2004-06-09 07:00:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/pgalloc.h 2004-08-26 05:14:41.000000000 -0500
+@@ -85,7 +85,7 @@
+
+ #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ #define pgd_populate(mm, pmd, pte) BUG()
+
+ /*
+@@ -97,7 +97,7 @@
+ #define __pmd_free_tlb(tlb,x) do { } while (0)
+ #endif
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+
+ #define pgd_populate(mm, pgd, pmd) set_pgd(pgd, __pgd(pmd))
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/prctl.h linux-libc-headers-2.6.8.0/include/asm-mips/prctl.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/prctl.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/prctl.h 2004-08-26 05:21:43.000000000 -0500
+@@ -12,21 +12,21 @@
+ #define PRDA ((struct prda *) PRDA_ADDRESS)
+
+ struct prda_sys {
+- pid_t t_pid;
+- u32 t_hint;
+- u32 t_dlactseq;
+- u32 t_fpflags;
+- u32 t_prid; /* processor type, $prid CP0 register */
+- u32 t_dlendseq;
+- u64 t_unused1[5];
+- pid_t t_rpid;
+- s32 t_resched;
+- u32 t_unused[8];
+- u32 t_cpu; /* current/last cpu */
++ pid_t t_pid;
++ __u32 t_hint;
++ __u32 t_dlactseq;
++ __u32 t_fpflags;
++ __u32 t_prid; /* processor type, $prid CP0 register */
++ __u32 t_dlendseq;
++ __u64 t_unused1[5];
++ pid_t t_rpid;
++ __s32 t_resched;
++ __u32 t_unused[8];
++ __u32 t_cpu; /* current/last cpu */
+
+ /* FIXME: The signal information, not supported by Linux now */
+- u32 t_flags; /* if true, then the sigprocmask is in userspace */
+- u32 t_sigprocmask [1]; /* the sigprocmask */
++ __u32 t_flags; /* if true, then the sigprocmask is in userspace */
++ __u32 t_sigprocmask [1]; /* the sigprocmask */
+ };
+
+ struct prda {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/processor.h linux-libc-headers-2.6.8.0/include/asm-mips/processor.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/processor.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/processor.h 2004-08-26 05:23:24.000000000 -0500
+@@ -102,7 +102,7 @@
+ #define MCA_bus 0
+ #define MCA_bus__is_a_macro /* for versions in ksyms.c */
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ /*
+ * User space process size: 2GB. This is hardcoded into a few places,
+ * so don't change it unless you know what you are doing.
+@@ -116,7 +116,7 @@
+ #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
+ #endif
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ /*
+ * User space process size: 1TB. This is hardcoded into a few places,
+ * so don't change it unless you know what you are doing. TASK_SIZE
+@@ -142,7 +142,7 @@
+
+ #define NUM_FPU_REGS 32
+
+-typedef u64 fpureg_t;
++typedef __u64 fpureg_t;
+
+ struct mips_fpu_hard_struct {
+ fpureg_t fpr[NUM_FPU_REGS];
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/ptrace.h linux-libc-headers-2.6.8.0/include/asm-mips/ptrace.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/ptrace.h 2004-03-28 07:51:52.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/ptrace.h 2004-08-26 05:14:41.000000000 -0500
+@@ -27,7 +27,7 @@
+ * system call/exception. As usual the registers k0/k1 aren't being saved.
+ */
+ struct pt_regs {
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ /* Pad bytes for argument save space on the stack. */
+ unsigned long pad0[6];
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/serial.h linux-libc-headers-2.6.8.0/include/asm-mips/serial.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/serial.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/serial.h 2004-08-26 13:21:37.000000000 -0500
+@@ -68,7 +68,7 @@
+
+ #define _JAZZ_SERIAL_INIT(int, base) \
+ { .baud_base = JAZZ_BASE_BAUD, .irq = int, .flags = STD_COM_FLAGS, \
+- .iomem_base = (u8 *) base, .iomem_reg_shift = 0, \
++ .iomem_base = (__u8 *) base, .iomem_reg_shift = 0, \
+ .io_type = SERIAL_IO_MEM }
+ #define JAZZ_SERIAL_PORT_DEFNS \
+ _JAZZ_SERIAL_INIT(JAZZ_SERIAL1_IRQ, JAZZ_SERIAL1_BASE), \
+@@ -243,7 +243,7 @@
+ #define _JAGUAR_ATX_SERIAL_INIT(int, base) \
+ { baud_base: JAGUAR_ATX_BASE_BAUD, irq: int, \
+ flags: (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \
+- iomem_base: (u8 *) base, iomem_reg_shift: 2, \
++ iomem_base: (__u8 *) base, iomem_reg_shift: 2, \
+ io_type: SERIAL_IO_MEM }
+ #define MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS \
+ _JAGUAR_ATX_SERIAL_INIT(JAGUAR_ATX_SERIAL1_IRQ, JAGUAR_ATX_SERIAL1_BASE)
+@@ -260,7 +260,7 @@
+
+ #define _OCELOT_SERIAL_INIT(int, base) \
+ { .baud_base = OCELOT_BASE_BAUD, .irq = int, .flags = STD_COM_FLAGS, \
+- .iomem_base = (u8 *) base, .iomem_reg_shift = 2, \
++ .iomem_base = (__u8 *) base, .iomem_reg_shift = 2, \
+ .io_type = SERIAL_IO_MEM }
+ #define MOMENCO_OCELOT_SERIAL_PORT_DEFNS \
+ _OCELOT_SERIAL_INIT(OCELOT_SERIAL1_IRQ, OCELOT_SERIAL1_BASE)
+@@ -281,7 +281,7 @@
+
+ #define _OCELOT_G_SERIAL_INIT(int, base) \
+ { .baud_base = OCELOT_G_BASE_BAUD, .irq = int, .flags = STD_COM_FLAGS,\
+- .iomem_base = (u8 *) base, .iomem_reg_shift = 2, \
++ .iomem_base = (__u8 *) base, .iomem_reg_shift = 2, \
+ .io_type = SERIAL_IO_MEM }
+ #define MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS \
+ _OCELOT_G_SERIAL_INIT(OCELOT_G_SERIAL1_IRQ, OCELOT_G_SERIAL1_BASE)
+@@ -303,7 +303,7 @@
+ { .baud_base = OCELOT_C_BASE_BAUD, \
+ .irq = (int), \
+ .flags = STD_COM_FLAGS, \
+- .iomem_base = (u8 *) base, \
++ .iomem_base = (__u8 *) base, \
+ .iomem_reg_shift = 2, \
+ .io_type = SERIAL_IO_MEM \
+ }
+@@ -318,10 +318,10 @@
+ #include <asm/ddb5xxx/ddb5477.h>
+ #define DDB5477_SERIAL_PORT_DEFNS \
+ { .baud_base = BASE_BAUD, .irq = VRC5477_IRQ_UART0, \
+- .flags = STD_COM_FLAGS, .iomem_base = (u8*)0xbfa04200, \
++ .flags = STD_COM_FLAGS, .iomem_base = (__u8*)0xbfa04200, \
+ .iomem_reg_shift = 3, .io_type = SERIAL_IO_MEM}, \
+ { .baud_base = BASE_BAUD, .irq = VRC5477_IRQ_UART1, \
+- .flags = STD_COM_FLAGS, .iomem_base = (u8*)0xbfa04240, \
++ .flags = STD_COM_FLAGS, .iomem_base = (__u8*)0xbfa04240, \
+ .iomem_reg_shift = 3, .io_type = SERIAL_IO_MEM},
+ #else
+ #define DDB5477_SERIAL_PORT_DEFNS
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/hpc3.h linux-libc-headers-2.6.8.0/include/asm-mips/sgi/hpc3.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/hpc3.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sgi/hpc3.h 2004-08-26 05:24:34.000000000 -0500
+@@ -17,8 +17,8 @@
+
+ /* An HPC DMA descriptor. */
+ struct hpc_dma_desc {
+- u32 pbuf; /* physical address of data buffer */
+- u32 cntinfo; /* counter and info bits */
++ __u32 pbuf; /* physical address of data buffer */
++ __u32 cntinfo; /* counter and info bits */
+ #define HPCDMA_EOX 0x80000000 /* last desc in chain for tx */
+ #define HPCDMA_EOR 0x80000000 /* last desc in chain for rx */
+ #define HPCDMA_EOXP 0x40000000 /* end of packet for tx */
+@@ -30,15 +30,15 @@
+ #define HPCDMA_OWN 0x00004000 /* Denotes ring buffer ownership on rx */
+ #define HPCDMA_BCNT 0x00003fff /* size in bytes of this dma buffer */
+
+- u32 pnext; /* paddr of next hpc_dma_desc if any */
++ __u32 pnext; /* paddr of next hpc_dma_desc if any */
+ };
+
+ /* The set of regs for each HPC3 PBUS DMA channel. */
+ struct hpc3_pbus_dmacregs {
+- volatile u32 pbdma_bptr; /* pbus dma channel buffer ptr */
+- volatile u32 pbdma_dptr; /* pbus dma channel desc ptr */
+- u32 _unused0[0x1000/4 - 2]; /* padding */
+- volatile u32 pbdma_ctrl; /* pbus dma channel control register has
++ volatile __u32 pbdma_bptr; /* pbus dma channel buffer ptr */
++ volatile __u32 pbdma_dptr; /* pbus dma channel desc ptr */
++ __u32 _unused0[0x1000/4 - 2]; /* padding */
++ volatile __u32 pbdma_ctrl; /* pbus dma channel control register has
+ * copletely different meaning for read
+ * compared with write */
+ /* read */
+@@ -55,20 +55,20 @@
+ #define HPC3_PDMACTRL_FB 0x003f0000 /* Ptr to beginning of fifo */
+ #define HPC3_PDMACTRL_FE 0x3f000000 /* Ptr to end of fifo */
+
+- u32 _unused1[0x1000/4 - 1]; /* padding */
++ __u32 _unused1[0x1000/4 - 1]; /* padding */
+ };
+
+ /* The HPC3 SCSI registers, this does not include external ones. */
+ struct hpc3_scsiregs {
+- volatile u32 cbptr; /* current dma buffer ptr, diagnostic use only */
+- volatile u32 ndptr; /* next dma descriptor ptr */
+- u32 _unused0[0x1000/4 - 2]; /* padding */
+- volatile u32 bcd; /* byte count info */
++ volatile __u32 cbptr; /* current dma buffer ptr, diagnostic use only */
++ volatile __u32 ndptr; /* next dma descriptor ptr */
++ __u32 _unused0[0x1000/4 - 2]; /* padding */
++ volatile __u32 bcd; /* byte count info */
+ #define HPC3_SBCD_BCNTMSK 0x00003fff /* bytes to transfer from/to memory */
+ #define HPC3_SBCD_XIE 0x00004000 /* Send IRQ when done with cur buf */
+ #define HPC3_SBCD_EOX 0x00008000 /* Indicates this is last buf in chain */
+
+- volatile u32 ctrl; /* control register */
++ volatile __u32 ctrl; /* control register */
+ #define HPC3_SCTRL_IRQ 0x01 /* IRQ asserted, either dma done or parity */
+ #define HPC3_SCTRL_ENDIAN 0x02 /* DMA endian mode, 0=big 1=little */
+ #define HPC3_SCTRL_DIR 0x04 /* DMA direction, 1=dev2mem 0=mem2dev */
+@@ -78,9 +78,9 @@
+ #define HPC3_SCTRL_CRESET 0x40 /* Resets dma channel and external controller */
+ #define HPC3_SCTRL_PERR 0x80 /* Bad parity on HPC3 iface to scsi controller */
+
+- volatile u32 gfptr; /* current GIO fifo ptr */
+- volatile u32 dfptr; /* current device fifo ptr */
+- volatile u32 dconfig; /* DMA configuration register */
++ volatile __u32 gfptr; /* current GIO fifo ptr */
++ volatile __u32 dfptr; /* current device fifo ptr */
++ volatile __u32 dconfig; /* DMA configuration register */
+ #define HPC3_SDCFG_HCLK 0x00001 /* Enable DMA half clock mode */
+ #define HPC3_SDCFG_D1 0x00006 /* Cycles to spend in D1 state */
+ #define HPC3_SDCFG_D2 0x00038 /* Cycles to spend in D2 state */
+@@ -92,7 +92,7 @@
+ #define HPC3_SDCFG_POLL 0x08000 /* hd_dreq polarity control */
+ #define HPC3_SDCFG_ERLY 0x30000 /* hd_dreq behavior control bits */
+
+- volatile u32 pconfig; /* PIO configuration register */
++ volatile __u32 pconfig; /* PIO configuration register */
+ #define HPC3_SPCFG_P3 0x0003 /* Cycles to spend in P3 state */
+ #define HPC3_SPCFG_P2W 0x001c /* Cycles to spend in P2 state for writes */
+ #define HPC3_SPCFG_P2R 0x01e0 /* Cycles to spend in P2 state for reads */
+@@ -102,21 +102,21 @@
+ #define HPC3_SPCFG_EPAR 0x4000 /* Enable parity checking for PIO */
+ #define HPC3_SPCFG_FUJI 0x8000 /* Fujitsu scsi controller mode for faster dma/pio */
+
+- u32 _unused1[0x1000/4 - 6]; /* padding */
++ __u32 _unused1[0x1000/4 - 6]; /* padding */
+ };
+
+ /* SEEQ ethernet HPC3 registers, only one seeq per HPC3. */
+ struct hpc3_ethregs {
+ /* Receiver registers. */
+- volatile u32 rx_cbptr; /* current dma buffer ptr, diagnostic use only */
+- volatile u32 rx_ndptr; /* next dma descriptor ptr */
+- u32 _unused0[0x1000/4 - 2]; /* padding */
+- volatile u32 rx_bcd; /* byte count info */
++ volatile __u32 rx_cbptr; /* current dma buffer ptr, diagnostic use only */
++ volatile __u32 rx_ndptr; /* next dma descriptor ptr */
++ __u32 _unused0[0x1000/4 - 2]; /* padding */
++ volatile __u32 rx_bcd; /* byte count info */
+ #define HPC3_ERXBCD_BCNTMSK 0x00003fff /* bytes to be sent to memory */
+ #define HPC3_ERXBCD_XIE 0x20000000 /* HPC3 interrupts cpu at end of this buf */
+ #define HPC3_ERXBCD_EOX 0x80000000 /* flags this as end of descriptor chain */
+
+- volatile u32 rx_ctrl; /* control register */
++ volatile __u32 rx_ctrl; /* control register */
+ #define HPC3_ERXCTRL_STAT50 0x0000003f /* Receive status reg bits of Seeq8003 */
+ #define HPC3_ERXCTRL_STAT6 0x00000040 /* Rdonly irq status */
+ #define HPC3_ERXCTRL_STAT7 0x00000080 /* Rdonlt old/new status bit from Seeq */
+@@ -125,15 +125,15 @@
+ #define HPC3_ERXCTRL_AMASK 0x00000400 /* Tells if ACTIVE inhibits PIO's to hpc3 */
+ #define HPC3_ERXCTRL_RBO 0x00000800 /* Receive buffer overflow if set to 1 */
+
+- volatile u32 rx_gfptr; /* current GIO fifo ptr */
+- volatile u32 rx_dfptr; /* current device fifo ptr */
+- u32 _unused1; /* padding */
+- volatile u32 rx_reset; /* reset register */
++ volatile __u32 rx_gfptr; /* current GIO fifo ptr */
++ volatile __u32 rx_dfptr; /* current device fifo ptr */
++ __u32 _unused1; /* padding */
++ volatile __u32 rx_reset; /* reset register */
+ #define HPC3_ERXRST_CRESET 0x1 /* Reset dma channel and external controller */
+ #define HPC3_ERXRST_CLRIRQ 0x2 /* Clear channel interrupt */
+ #define HPC3_ERXRST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */
+
+- volatile u32 rx_dconfig; /* DMA configuration register */
++ volatile __u32 rx_dconfig; /* DMA configuration register */
+ #define HPC3_ERXDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */
+ #define HPC3_ERXDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */
+ #define HPC3_ERXDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */
+@@ -143,26 +143,26 @@
+ #define HPC3_ERXDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */
+ #define HPC3_ERXDCFG_PTO 0x30000 /* Programmed timeout value for above two */
+
+- volatile u32 rx_pconfig; /* PIO configuration register */
++ volatile __u32 rx_pconfig; /* PIO configuration register */
+ #define HPC3_ERXPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */
+ #define HPC3_ERXPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */
+ #define HPC3_ERXPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */
+ #define HPC3_ERXPCFG_TST 0x1000 /* Diagnistic ram test feature bit */
+
+- u32 _unused2[0x1000/4 - 8]; /* padding */
++ __u32 _unused2[0x1000/4 - 8]; /* padding */
+
+ /* Transmitter registers. */
+- volatile u32 tx_cbptr; /* current dma buffer ptr, diagnostic use only */
+- volatile u32 tx_ndptr; /* next dma descriptor ptr */
+- u32 _unused3[0x1000/4 - 2]; /* padding */
+- volatile u32 tx_bcd; /* byte count info */
++ volatile __u32 tx_cbptr; /* current dma buffer ptr, diagnostic use only */
++ volatile __u32 tx_ndptr; /* next dma descriptor ptr */
++ __u32 _unused3[0x1000/4 - 2]; /* padding */
++ volatile __u32 tx_bcd; /* byte count info */
+ #define HPC3_ETXBCD_BCNTMSK 0x00003fff /* bytes to be read from memory */
+ #define HPC3_ETXBCD_ESAMP 0x10000000 /* if set, too late to add descriptor */
+ #define HPC3_ETXBCD_XIE 0x20000000 /* Interrupt cpu at end of cur desc */
+ #define HPC3_ETXBCD_EOP 0x40000000 /* Last byte of cur buf is end of packet */
+ #define HPC3_ETXBCD_EOX 0x80000000 /* This buf is the end of desc chain */
+
+- volatile u32 tx_ctrl; /* control register */
++ volatile __u32 tx_ctrl; /* control register */
+ #define HPC3_ETXCTRL_STAT30 0x0000000f /* Rdonly copy of seeq tx stat reg */
+ #define HPC3_ETXCTRL_STAT4 0x00000010 /* Indicate late collision occurred */
+ #define HPC3_ETXCTRL_STAT75 0x000000e0 /* Rdonly irq status from seeq */
+@@ -170,9 +170,9 @@
+ #define HPC3_ETXCTRL_ACTIVE 0x00000200 /* DMA tx channel is active */
+ #define HPC3_ETXCTRL_AMASK 0x00000400 /* Indicates ACTIVE inhibits PIO's */
+
+- volatile u32 tx_gfptr; /* current GIO fifo ptr */
+- volatile u32 tx_dfptr; /* current device fifo ptr */
+- u32 _unused4[0x1000/4 - 4]; /* padding */
++ volatile __u32 tx_gfptr; /* current GIO fifo ptr */
++ volatile __u32 tx_dfptr; /* current device fifo ptr */
++ __u32 _unused4[0x1000/4 - 4]; /* padding */
+ };
+
+ struct hpc3_regs {
+@@ -188,7 +188,7 @@
+ /* Here are where the hpc3 fifo's can be directly accessed
+ * via PIO accesses. Under normal operation we never stick
+ * our grubby paws in here so it's just padding. */
+- u32 _unused0[0x18000/4];
++ __u32 _unused0[0x18000/4];
+
+ /* HPC3 irq status regs. Due to a peculiar bug you need to
+ * look at two different register addresses to get at all of
+@@ -197,42 +197,42 @@
+ * reliably report bits 9:5 of the hpc3 irq status. I told
+ * you it was a peculiar bug. ;-)
+ */
+- volatile u32 istat0; /* Irq status, only bits <4:0> reliable. */
++ volatile __u32 istat0; /* Irq status, only bits <4:0> reliable. */
+ #define HPC3_ISTAT_PBIMASK 0x0ff /* irq bits for pbus devs 0 --> 7 */
+ #define HPC3_ISTAT_SC0MASK 0x100 /* irq bit for scsi channel 0 */
+ #define HPC3_ISTAT_SC1MASK 0x200 /* irq bit for scsi channel 1 */
+
+- volatile u32 gio_misc; /* GIO misc control bits. */
++ volatile __u32 gio_misc; /* GIO misc control bits. */
+ #define HPC3_GIOMISC_ERTIME 0x1 /* Enable external timer real time. */
+ #define HPC3_GIOMISC_DENDIAN 0x2 /* dma descriptor endian, 1=lit 0=big */
+
+- volatile u32 eeprom; /* EEPROM data reg. */
++ volatile __u32 eeprom; /* EEPROM data reg. */
+ #define HPC3_EEPROM_EPROT 0x01 /* Protect register enable */
+ #define HPC3_EEPROM_CSEL 0x02 /* Chip select */
+ #define HPC3_EEPROM_ECLK 0x04 /* EEPROM clock */
+ #define HPC3_EEPROM_DATO 0x08 /* Data out */
+ #define HPC3_EEPROM_DATI 0x10 /* Data in */
+
+- volatile u32 istat1; /* Irq status, only bits <9:5> reliable. */
+- volatile u32 bestat; /* Bus error interrupt status reg. */
++ volatile __u32 istat1; /* Irq status, only bits <9:5> reliable. */
++ volatile __u32 bestat; /* Bus error interrupt status reg. */
+ #define HPC3_BESTAT_BLMASK 0x000ff /* Bus lane where bad parity occurred */
+ #define HPC3_BESTAT_CTYPE 0x00100 /* Bus cycle type, 0=PIO 1=DMA */
+ #define HPC3_BESTAT_PIDSHIFT 9
+ #define HPC3_BESTAT_PIDMASK 0x3f700 /* DMA channel parity identifier */
+
+- u32 _unused1[0x14000/4 - 5]; /* padding */
++ __u32 _unused1[0x14000/4 - 5]; /* padding */
+
+ /* Now direct PIO per-HPC3 peripheral access to external regs. */
+- volatile u32 scsi0_ext[256]; /* SCSI channel 0 external regs */
+- u32 _unused2[0x7c00/4];
+- volatile u32 scsi1_ext[256]; /* SCSI channel 1 external regs */
+- u32 _unused3[0x7c00/4];
+- volatile u32 eth_ext[320]; /* Ethernet external registers */
+- u32 _unused4[0x3b00/4];
++ volatile __u32 scsi0_ext[256]; /* SCSI channel 0 external regs */
++ __u32 _unused2[0x7c00/4];
++ volatile __u32 scsi1_ext[256]; /* SCSI channel 1 external regs */
++ __u32 _unused3[0x7c00/4];
++ volatile __u32 eth_ext[320]; /* Ethernet external registers */
++ __u32 _unused4[0x3b00/4];
+
+ /* Per-peripheral device external registers and DMA/PIO control. */
+- volatile u32 pbus_extregs[16][256];
+- volatile u32 pbus_dmacfg[8][128];
++ volatile __u32 pbus_extregs[16][256];
++ volatile __u32 pbus_dmacfg[8][128];
+ /* Cycles to spend in D3 for reads */
+ #define HPC3_DMACFG_D3R_MASK 0x00000001
+ #define HPC3_DMACFG_D3R_SHIFT 0
+@@ -262,7 +262,7 @@
+ #define HPC3_DMACFG_BURST_SHIFT 22
+ /* Use live pbus_dreq unsynchronized signal */
+ #define HPC3_DMACFG_DRQLIVE 0x08000000
+- volatile u32 pbus_piocfg[16][64];
++ volatile __u32 pbus_piocfg[16][64];
+ /* Cycles to spend in P2 state for reads */
+ #define HPC3_PIOCFG_P2R_MASK 0x00001
+ #define HPC3_PIOCFG_P2R_SHIFT 0
+@@ -287,21 +287,21 @@
+ #define HPC3_PIOCFG_EVENHI 0x80000
+
+ /* PBUS PROM control regs. */
+- volatile u32 pbus_promwe; /* PROM write enable register */
++ volatile __u32 pbus_promwe; /* PROM write enable register */
+ #define HPC3_PROM_WENAB 0x1 /* Enable writes to the PROM */
+
+- u32 _unused5[0x0800/4 - 1];
+- volatile u32 pbus_promswap; /* Chip select swap reg */
++ __u32 _unused5[0x0800/4 - 1];
++ volatile __u32 pbus_promswap; /* Chip select swap reg */
+ #define HPC3_PROM_SWAP 0x1 /* invert GIO addr bit to select prom0 or prom1 */
+
+- u32 _unused6[0x0800/4 - 1];
+- volatile u32 pbus_gout; /* PROM general purpose output reg */
++ __u32 _unused6[0x0800/4 - 1];
++ volatile __u32 pbus_gout; /* PROM general purpose output reg */
+ #define HPC3_PROM_STAT 0x1 /* General purpose status bit in gout */
+
+- u32 _unused7[0x1000/4 - 1];
+- volatile u32 rtcregs[14]; /* Dallas clock registers */
+- u32 _unused8[50];
+- volatile u32 bbram[8192-50-14]; /* Battery backed ram */
++ __u32 _unused7[0x1000/4 - 1];
++ volatile __u32 rtcregs[14]; /* Dallas clock registers */
++ __u32 _unused8[50];
++ volatile __u32 bbram[8192-50-14]; /* Battery backed ram */
+ };
+
+ /*
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/ioc.h linux-libc-headers-2.6.8.0/include/asm-mips/sgi/ioc.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/ioc.h 2004-03-28 07:51:54.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sgi/ioc.h 2004-08-26 05:24:48.000000000 -0500
+@@ -22,26 +22,26 @@
+ */
+
+ struct sgioc_uart_regs {
+- u8 _ctrl1[3];
+- volatile u8 ctrl1;
+- u8 _data1[3];
+- volatile u8 data1;
+- u8 _ctrl2[3];
+- volatile u8 ctrl2;
+- u8 _data2[3];
+- volatile u8 data2;
++ __u8 _ctrl1[3];
++ volatile __u8 ctrl1;
++ __u8 _data1[3];
++ volatile __u8 data1;
++ __u8 _ctrl2[3];
++ volatile __u8 ctrl2;
++ __u8 _data2[3];
++ volatile __u8 data2;
+ };
+
+ struct sgioc_keyb_regs {
+- u8 _data[3];
+- volatile u8 data;
+- u8 _command[3];
+- volatile u8 command;
++ __u8 _data[3];
++ volatile __u8 data;
++ __u8 _command[3];
++ volatile __u8 command;
+ };
+
+ struct sgint_regs {
+- u8 _istat0[3];
+- volatile u8 istat0; /* Interrupt status zero */
++ __u8 _istat0[3];
++ volatile __u8 istat0; /* Interrupt status zero */
+ #define SGINT_ISTAT0_FFULL 0x01
+ #define SGINT_ISTAT0_SCSI0 0x02
+ #define SGINT_ISTAT0_SCSI1 0x04
+@@ -50,10 +50,10 @@
+ #define SGINT_ISTAT0_PPORT 0x20
+ #define SGINT_ISTAT0_HPC2 0x40
+ #define SGINT_ISTAT0_LIO2 0x80
+- u8 _imask0[3];
+- volatile u8 imask0; /* Interrupt mask zero */
+- u8 _istat1[3];
+- volatile u8 istat1; /* Interrupt status one */
++ __u8 _imask0[3];
++ volatile __u8 imask0; /* Interrupt mask zero */
++ __u8 _istat1[3];
++ volatile __u8 istat1; /* Interrupt status one */
+ #define SGINT_ISTAT1_ISDNI 0x01
+ #define SGINT_ISTAT1_PWR 0x02
+ #define SGINT_ISTAT1_ISDNH 0x04
+@@ -62,29 +62,29 @@
+ #define SGINT_ISTAT1_AFAIL 0x20
+ #define SGINT_ISTAT1_VIDEO 0x40
+ #define SGINT_ISTAT1_GIO2 0x80
+- u8 _imask1[3];
+- volatile u8 imask1; /* Interrupt mask one */
+- u8 _vmeistat[3];
+- volatile u8 vmeistat; /* VME interrupt status */
+- u8 _cmeimask0[3];
+- volatile u8 cmeimask0; /* VME interrupt mask zero */
+- u8 _cmeimask1[3];
+- volatile u8 cmeimask1; /* VME interrupt mask one */
+- u8 _cmepol[3];
+- volatile u8 cmepol; /* VME polarity */
+- u8 _tclear[3];
+- volatile u8 tclear;
+- u8 _errstat[3];
+- volatile u8 errstat; /* Error status reg, reserved on INT2 */
+- u32 _unused0[2];
+- u8 _tcnt0[3];
+- volatile u8 tcnt0; /* counter 0 */
+- u8 _tcnt1[3];
+- volatile u8 tcnt1; /* counter 1 */
+- u8 _tcnt2[3];
+- volatile u8 tcnt2; /* counter 2 */
+- u8 _tcword[3];
+- volatile u8 tcword; /* control word */
++ __u8 _imask1[3];
++ volatile __u8 imask1; /* Interrupt mask one */
++ __u8 _vmeistat[3];
++ volatile __u8 vmeistat; /* VME interrupt status */
++ __u8 _cmeimask0[3];
++ volatile __u8 cmeimask0; /* VME interrupt mask zero */
++ __u8 _cmeimask1[3];
++ volatile __u8 cmeimask1; /* VME interrupt mask one */
++ __u8 _cmepol[3];
++ volatile __u8 cmepol; /* VME polarity */
++ __u8 _tclear[3];
++ volatile __u8 tclear;
++ __u8 _errstat[3];
++ volatile __u8 errstat; /* Error status reg, reserved on INT2 */
++ __u32 _unused0[2];
++ __u8 _tcnt0[3];
++ volatile __u8 tcnt0; /* counter 0 */
++ __u8 _tcnt1[3];
++ volatile __u8 tcnt1; /* counter 1 */
++ __u8 _tcnt2[3];
++ volatile __u8 tcnt2; /* counter 2 */
++ __u8 _tcword[3];
++ volatile __u8 tcword; /* control word */
+ #define SGINT_TCWORD_BCD 0x01 /* Use BCD mode for counters */
+ #define SGINT_TCWORD_MMASK 0x0e /* Mode bitmask. */
+ #define SGINT_TCWORD_MITC 0x00 /* IRQ on terminal count (doesn't work) */
+@@ -115,55 +115,55 @@
+ #define SGINT_TCSAMP_COUNTER ((SGINT_TIMER_CLOCK / HZ) + 255)
+
+ /* We need software copies of these because they are write only. */
+-extern u8 sgi_ioc_reset, sgi_ioc_write;
++extern __u8 sgi_ioc_reset, sgi_ioc_write;
+
+ struct sgioc_regs {
+ struct pi1_regs pport;
+- u32 _unused0[2];
++ __u32 _unused0[2];
+ struct sgioc_uart_regs serport;
+ struct sgioc_keyb_regs kbdmouse;
+- u8 _gcsel[3];
+- volatile u8 gcsel;
+- u8 _genctrl[3];
+- volatile u8 genctrl;
+- u8 _panel[3];
+- volatile u8 panel;
++ __u8 _gcsel[3];
++ volatile __u8 gcsel;
++ __u8 _genctrl[3];
++ volatile __u8 genctrl;
++ __u8 _panel[3];
++ volatile __u8 panel;
+ #define SGIOC_PANEL_POWERON 0x01
+ #define SGIOC_PANEL_POWERINTR 0x02
+ #define SGIOC_PANEL_VOLDNINTR 0x10
+ #define SGIOC_PANEL_VOLDNHOLD 0x20
+ #define SGIOC_PANEL_VOLUPINTR 0x40
+ #define SGIOC_PANEL_VOLUPHOLD 0x80
+- u32 _unused1;
+- u8 _sysid[3];
+- volatile u8 sysid;
++ __u32 _unused1;
++ __u8 _sysid[3];
++ volatile __u8 sysid;
+ #define SGIOC_SYSID_FULLHOUSE 0x01
+ #define SGIOC_SYSID_BOARDREV(x) ((x & 0xe0) > 5)
+ #define SGIOC_SYSID_CHIPREV(x) ((x & 0x1e) > 1)
+- u32 _unused2;
+- u8 _read[3];
+- volatile u8 read;
+- u32 _unused3;
+- u8 _dmasel[3];
+- volatile u8 dmasel;
++ __u32 _unused2;
++ __u8 _read[3];
++ volatile __u8 read;
++ __u32 _unused3;
++ __u8 _dmasel[3];
++ volatile __u8 dmasel;
+ #define SGIOC_DMASEL_SCLK10MHZ 0x00 /* use 10MHZ serial clock */
+ #define SGIOC_DMASEL_ISDNB 0x01 /* enable isdn B */
+ #define SGIOC_DMASEL_ISDNA 0x02 /* enable isdn A */
+ #define SGIOC_DMASEL_PPORT 0x04 /* use parallel DMA */
+ #define SGIOC_DMASEL_SCLK667MHZ 0x10 /* use 6.67MHZ serial clock */
+ #define SGIOC_DMASEL_SCLKEXT 0x20 /* use external serial clock */
+- u32 _unused4;
+- u8 _reset[3];
+- volatile u8 reset;
++ __u32 _unused4;
++ __u8 _reset[3];
++ volatile __u8 reset;
+ #define SGIOC_RESET_PPORT 0x01 /* 0=parport reset, 1=nornal */
+ #define SGIOC_RESET_KBDMOUSE 0x02 /* 0=kbdmouse reset, 1=normal */
+ #define SGIOC_RESET_EISA 0x04 /* 0=eisa reset, 1=normal */
+ #define SGIOC_RESET_ISDN 0x08 /* 0=isdn reset, 1=normal */
+ #define SGIOC_RESET_LC0OFF 0x10 /* guiness: turn led off (red, else green) */
+ #define SGIOC_RESET_LC1OFF 0x20 /* guiness: turn led off (green, else amber) */
+- u32 _unused5;
+- u8 _write[3];
+- volatile u8 write;
++ __u32 _unused5;
++ __u8 _write[3];
++ volatile __u8 write;
+ #define SGIOC_WRITE_NTHRESH 0x01 /* use 4.5db threshhold */
+ #define SGIOC_WRITE_TPSPEED 0x02 /* use 100ohm TP speed */
+ #define SGIOC_WRITE_EPSEL 0x04 /* force cable mode: 1=AUI 0=TP */
+@@ -172,10 +172,10 @@
+ #define SGIOC_WRITE_U0AMODE 0x20 /* 1=PC 0=MAC UART mode */
+ #define SGIOC_WRITE_MLO 0x40 /* 1=4.75V 0=+5V */
+ #define SGIOC_WRITE_MHI 0x80 /* 1=5.25V 0=+5V */
+- u32 _unused6;
++ __u32 _unused6;
+ struct sgint_regs int3;
+- u32 _unused7[16];
+- volatile u32 extio; /* FullHouse only */
++ __u32 _unused7[16];
++ volatile __u32 extio; /* FullHouse only */
+ #define EXTIO_S0_IRQ_3 0x8000 /* S0: vid.vsync */
+ #define EXTIO_S0_IRQ_2 0x4000 /* S0: gfx.fifofull */
+ #define EXTIO_S0_IRQ_1 0x2000 /* S0: gfx.int */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/mc.h linux-libc-headers-2.6.8.0/include/asm-mips/sgi/mc.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgi/mc.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sgi/mc.h 2004-08-26 05:25:28.000000000 -0500
+@@ -14,8 +14,8 @@
+ #define _SGI_MC_H
+
+ struct sgimc_regs {
+- u32 _unused0;
+- volatile u32 cpuctrl0; /* CPU control register 0, readwrite */
++ __u32 _unused0;
++ volatile __u32 cpuctrl0; /* CPU control register 0, readwrite */
+ #define SGIMC_CCTRL0_REFS 0x0000000f /* REFS mask */
+ #define SGIMC_CCTRL0_EREFRESH 0x00000010 /* Memory refresh enable */
+ #define SGIMC_CCTRL0_EPERRGIO 0x00000020 /* GIO parity error enable */
+@@ -35,8 +35,8 @@
+ #define SGIMC_CCTRL0_CMEMBADPAR 0x02000000 /* Generate bad perr from cpu to mem */
+ #define SGIMC_CCTRL0_R4KNOCHKPARR 0x04000000 /* Don't chk parity on mem data reads */
+ #define SGIMC_CCTRL0_GIOBTOB 0x08000000 /* Allow GIO back to back writes */
+- u32 _unused1;
+- volatile u32 cpuctrl1; /* CPU control register 1, readwrite */
++ __u32 _unused1;
++ volatile __u32 cpuctrl1; /* CPU control register 1, readwrite */
+ #define SGIMC_CCTRL1_EGIOTIMEO 0x00000010 /* GIO bus timeout enable */
+ #define SGIMC_CCTRL1_FIXEDEHPC 0x00001000 /* Fixed HPC endianness */
+ #define SGIMC_CCTRL1_LITTLEHPC 0x00002000 /* Little endian HPC */
+@@ -45,33 +45,33 @@
+ #define SGIMC_CCTRL1_FIXEDEEXP1 0x00010000 /* Fixed EXP1 endianness */
+ #define SGIMC_CCTRL1_LITTLEEXP1 0x00020000 /* Little endian EXP1 */
+
+- u32 _unused2;
+- volatile u32 watchdogt; /* Watchdog reg rdonly, write clears */
++ __u32 _unused2;
++ volatile __u32 watchdogt; /* Watchdog reg rdonly, write clears */
+
+- u32 _unused3;
+- volatile u32 systemid; /* MC system ID register, readonly */
++ __u32 _unused3;
++ volatile __u32 systemid; /* MC system ID register, readonly */
+ #define SGIMC_SYSID_MASKREV 0x0000000f /* Revision of MC controller */
+ #define SGIMC_SYSID_EPRESENT 0x00000010 /* Indicates presence of EISA bus */
+
+- u32 _unused4[3];
+- volatile u32 divider; /* Divider reg for RPSS */
++ __u32 _unused4[3];
++ volatile __u32 divider; /* Divider reg for RPSS */
+
+- u32 _unused5;
+- volatile u32 eeprom; /* EEPROM byte reg for r4k */
++ __u32 _unused5;
++ volatile __u32 eeprom; /* EEPROM byte reg for r4k */
+ #define SGIMC_EEPROM_PRE 0x00000001 /* eeprom chip PRE pin assertion */
+ #define SGIMC_EEPROM_CSEL 0x00000002 /* Active high, eeprom chip select */
+ #define SGIMC_EEPROM_SECLOCK 0x00000004 /* EEPROM serial clock */
+ #define SGIMC_EEPROM_SDATAO 0x00000008 /* Serial EEPROM data-out */
+ #define SGIMC_EEPROM_SDATAI 0x00000010 /* Serial EEPROM data-in */
+
+- u32 _unused6[3];
+- volatile u32 rcntpre; /* Preload refresh counter */
++ __u32 _unused6[3];
++ volatile __u32 rcntpre; /* Preload refresh counter */
+
+- u32 _unused7;
+- volatile u32 rcounter; /* Readonly refresh counter */
++ __u32 _unused7;
++ volatile __u32 rcounter; /* Readonly refresh counter */
+
+- u32 _unused8[13];
+- volatile u32 giopar; /* Parameter word for GIO64 */
++ __u32 _unused8[13];
++ volatile __u32 giopar; /* Parameter word for GIO64 */
+ #define SGIMC_GIOPAR_HPC64 0x00000001 /* HPC talks to GIO using 64-bits */
+ #define SGIMC_GIOPAR_GFX64 0x00000002 /* GFX talks to GIO using 64-bits */
+ #define SGIMC_GIOPAR_EXP064 0x00000004 /* EXP(slot0) talks using 64-bits */
+@@ -89,36 +89,36 @@
+ #define SGIMC_GIOPAR_PLINEEXP0 0x00004000 /* EXP(slot0) has pipeline attr */
+ #define SGIMC_GIOPAR_PLINEEXP1 0x00008000 /* EXP(slot1) has pipeline attr */
+
+- u32 _unused9;
+- volatile u32 cputp; /* CPU bus arb time period */
++ __u32 _unused9;
++ volatile __u32 cputp; /* CPU bus arb time period */
+
+- u32 _unused10[3];
+- volatile u32 lbursttp; /* Time period for long bursts */
++ __u32 _unused10[3];
++ volatile __u32 lbursttp; /* Time period for long bursts */
+
+ /* MC chip can drive up to 4 bank 4 SIMMs each. All SIMMs in bank must
+ * be the same size. The size encoding for supported SIMMs is bellow */
+- u32 _unused11[9];
+- volatile u32 mconfig0; /* Memory config register zero */
+- u32 _unused12;
+- volatile u32 mconfig1; /* Memory config register one */
++ __u32 _unused11[9];
++ volatile __u32 mconfig0; /* Memory config register zero */
++ __u32 _unused12;
++ volatile __u32 mconfig1; /* Memory config register one */
+ #define SGIMC_MCONFIG_BASEADDR 0x000000ff /* Base address of bank*/
+ #define SGIMC_MCONFIG_RMASK 0x00001f00 /* Ram config bitmask */
+ #define SGIMC_MCONFIG_BVALID 0x00002000 /* Bank is valid */
+ #define SGIMC_MCONFIG_SBANKS 0x00004000 /* Number of subbanks */
+
+- u32 _unused13;
+- volatile u32 cmacc; /* Mem access config for CPU */
+- u32 _unused14;
+- volatile u32 gmacc; /* Mem access config for GIO */
++ __u32 _unused13;
++ volatile __u32 cmacc; /* Mem access config for CPU */
++ __u32 _unused14;
++ volatile __u32 gmacc; /* Mem access config for GIO */
+
+ /* This define applies to both cmacc and gmacc registers above. */
+ #define SGIMC_MACC_ALIASBIG 0x20000000 /* 512MB home for alias */
+
+ /* Error address/status regs from GIO and CPU perspectives. */
+- u32 _unused15;
+- volatile u32 cerr; /* Error address reg for CPU */
+- u32 _unused16;
+- volatile u32 cstat; /* Status reg for CPU */
++ __u32 _unused15;
++ volatile __u32 cerr; /* Error address reg for CPU */
++ __u32 _unused16;
++ volatile __u32 cstat; /* Status reg for CPU */
+ #define SGIMC_CSTAT_RD 0x00000100 /* read parity error */
+ #define SGIMC_CSTAT_PAR 0x00000200 /* CPU parity error */
+ #define SGIMC_CSTAT_ADDR 0x00000400 /* memory bus error bad addr */
+@@ -128,10 +128,10 @@
+ #define SGIMC_CSTAT_PAR_MASK 0x00001f00 /* parity error mask */
+ #define SGIMC_CSTAT_RD_PAR (SGIMC_CSTAT_RD | SGIMC_CSTAT_PAR)
+
+- u32 _unused17;
+- volatile u32 gerr; /* Error address reg for GIO */
+- u32 _unused18;
+- volatile u32 gstat; /* Status reg for GIO */
++ __u32 _unused17;
++ volatile __u32 gerr; /* Error address reg for GIO */
++ __u32 _unused18;
++ volatile __u32 gstat; /* Status reg for GIO */
+ #define SGIMC_GSTAT_RD 0x00000100 /* read parity error */
+ #define SGIMC_GSTAT_WR 0x00000200 /* write parity error */
+ #define SGIMC_GSTAT_TIME 0x00000400 /* GIO bus timed out */
+@@ -142,76 +142,76 @@
+ #define SGIMC_GSTAT_PIO_WR 0x00008000 /* write data parity on pio */
+
+ /* Special hard bus locking registers. */
+- u32 _unused19;
+- volatile u32 syssembit; /* Uni-bit system semaphore */
+- u32 _unused20;
+- volatile u32 mlock; /* Global GIO memory access lock */
+- u32 _unused21;
+- volatile u32 elock; /* Locks EISA from GIO accesses */
++ __u32 _unused19;
++ volatile __u32 syssembit; /* Uni-bit system semaphore */
++ __u32 _unused20;
++ volatile __u32 mlock; /* Global GIO memory access lock */
++ __u32 _unused21;
++ volatile __u32 elock; /* Locks EISA from GIO accesses */
+
+ /* GIO dma control registers. */
+- u32 _unused22[15];
+- volatile u32 gio_dma_trans; /* DMA mask to translation GIO addrs */
+- u32 _unused23;
+- volatile u32 gio_dma_sbits; /* DMA GIO addr substitution bits */
+- u32 _unused24;
+- volatile u32 dma_intr_cause; /* DMA IRQ cause indicator bits */
+- u32 _unused25;
+- volatile u32 dma_ctrl; /* Main DMA control reg */
++ __u32 _unused22[15];
++ volatile __u32 gio_dma_trans; /* DMA mask to translation GIO addrs */
++ __u32 _unused23;
++ volatile __u32 gio_dma_sbits; /* DMA GIO addr substitution bits */
++ __u32 _unused24;
++ volatile __u32 dma_intr_cause; /* DMA IRQ cause indicator bits */
++ __u32 _unused25;
++ volatile __u32 dma_ctrl; /* Main DMA control reg */
+
+ /* DMA TLB entry 0 */
+- u32 _unused26[5];
+- volatile u32 dtlb_hi0;
+- u32 _unused27;
+- volatile u32 dtlb_lo0;
++ __u32 _unused26[5];
++ volatile __u32 dtlb_hi0;
++ __u32 _unused27;
++ volatile __u32 dtlb_lo0;
+
+ /* DMA TLB entry 1 */
+- u32 _unused28;
+- volatile u32 dtlb_hi1;
+- u32 _unused29;
+- volatile u32 dtlb_lo1;
++ __u32 _unused28;
++ volatile __u32 dtlb_hi1;
++ __u32 _unused29;
++ volatile __u32 dtlb_lo1;
+
+ /* DMA TLB entry 2 */
+- u32 _unused30;
+- volatile u32 dtlb_hi2;
+- u32 _unused31;
+- volatile u32 dtlb_lo2;
++ __u32 _unused30;
++ volatile __u32 dtlb_hi2;
++ __u32 _unused31;
++ volatile __u32 dtlb_lo2;
+
+ /* DMA TLB entry 3 */
+- u32 _unused32;
+- volatile u32 dtlb_hi3;
+- u32 _unused33;
+- volatile u32 dtlb_lo3;
++ __u32 _unused32;
++ volatile __u32 dtlb_hi3;
++ __u32 _unused33;
++ volatile __u32 dtlb_lo3;
+
+- u32 _unused34[0x0392];
++ __u32 _unused34[0x0392];
+
+- u32 _unused35;
+- volatile u32 rpsscounter; /* Chirps at 100ns */
++ __u32 _unused35;
++ volatile __u32 rpsscounter; /* Chirps at 100ns */
+
+- u32 _unused36[0x1000/4-2*4];
++ __u32 _unused36[0x1000/4-2*4];
+
+- u32 _unused37;
+- volatile u32 maddronly; /* Address DMA goes at */
+- u32 _unused38;
+- volatile u32 maddrpdeflts; /* Same as above, plus set defaults */
+- u32 _unused39;
+- volatile u32 dmasz; /* DMA count */
+- u32 _unused40;
+- volatile u32 ssize; /* DMA stride size */
+- u32 _unused41;
+- volatile u32 gmaddronly; /* Set GIO DMA but don't start trans */
+- u32 _unused42;
+- volatile u32 dmaddnpgo; /* Set GIO DMA addr + start transfer */
+- u32 _unused43;
+- volatile u32 dmamode; /* DMA mode config bit settings */
+- u32 _unused44;
+- volatile u32 dmaccount; /* Zoom and byte count for DMA */
+- u32 _unused45;
+- volatile u32 dmastart; /* Pedal to the metal. */
+- u32 _unused46;
+- volatile u32 dmarunning; /* DMA op is in progress */
+- u32 _unused47;
+- volatile u32 maddrdefstart; /* Set dma addr, defaults, and kick it */
++ __u32 _unused37;
++ volatile __u32 maddronly; /* Address DMA goes at */
++ __u32 _unused38;
++ volatile __u32 maddrpdeflts; /* Same as above, plus set defaults */
++ __u32 _unused39;
++ volatile __u32 dmasz; /* DMA count */
++ __u32 _unused40;
++ volatile __u32 ssize; /* DMA stride size */
++ __u32 _unused41;
++ volatile __u32 gmaddronly; /* Set GIO DMA but don't start trans */
++ __u32 _unused42;
++ volatile __u32 dmaddnpgo; /* Set GIO DMA addr + start transfer */
++ __u32 _unused43;
++ volatile __u32 dmamode; /* DMA mode config bit settings */
++ __u32 _unused44;
++ volatile __u32 dmaccount; /* Zoom and byte count for DMA */
++ __u32 _unused45;
++ volatile __u32 dmastart; /* Pedal to the metal. */
++ __u32 _unused46;
++ volatile __u32 dmarunning; /* DMA op is in progress */
++ __u32 _unused47;
++ volatile __u32 maddrdefstart; /* Set dma addr, defaults, and kick it */
+ };
+
+ extern struct sgimc_regs *sgimc;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgiarcs.h linux-libc-headers-2.6.8.0/include/asm-mips/sgiarcs.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sgiarcs.h 2004-03-28 07:51:52.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sgiarcs.h 2004-08-26 05:21:53.000000000 -0500
+@@ -164,11 +164,11 @@
+ /* This prom has a bolixed design. */
+ struct linux_bigint {
+ #ifdef __MIPSEL__
+- u32 lo;
+- s32 hi;
++ __u32 lo;
++ __s32 hi;
+ #else /* !(__MIPSEL__) */
+- s32 hi;
+- u32 lo;
++ __s32 hi;
++ __u32 lo;
+ #endif
+ };
+
+@@ -366,7 +366,7 @@
+ * Macros for calling a 32-bit ARC implementation from 64-bit code
+ */
+
+-#if defined(CONFIG_MIPS64) && defined(CONFIG_ARC32)
++#if defined(__mips64) && defined(CONFIG_ARC32)
+
+ #define __arc_clobbers \
+ "$2","$3" /* ... */, "$8","$9","$10","$11", \
+@@ -475,10 +475,10 @@
+ __res; \
+ })
+
+-#endif /* defined(CONFIG_MIPS64) && defined(CONFIG_ARC32) */
++#endif /* defined(__mips64) && defined(CONFIG_ARC32) */
+
+-#if (defined(CONFIG_MIPS32) && defined(CONFIG_ARC32)) || \
+- (defined(CONFIG_MIPS64) && defined(CONFIG_ARC64))
++#if (!defined(__mips64) && defined(CONFIG_ARC32)) || \
++ (defined(__mips64) && defined(CONFIG_ARC64))
+
+ #define ARC_CALL0(dest) \
+ ({ long __res; \
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/siginfo.h linux-libc-headers-2.6.8.0/include/asm-mips/siginfo.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/siginfo.h 2004-06-09 07:00:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/siginfo.h 2004-08-26 05:14:41.000000000 -0500
+@@ -66,10 +66,10 @@
+
+ /* SIGPOLL, SIGXFSZ (To do ...) */
+ struct {
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ long _band; /* POLL_IN, POLL_OUT, POLL_MSG */
+ #endif
+ int _fd;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sim.h linux-libc-headers-2.6.8.0/include/asm-mips/sim.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sim.h 2004-03-28 07:51:52.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sim.h 2004-08-26 05:17:16.000000000 -0500
+@@ -18,7 +18,7 @@
+ #define __str2(x) #x
+ #define __str(x) __str2(x)
+
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+
+ #define save_static_function(symbol) \
+ __asm__ ( \
+@@ -43,9 +43,9 @@
+
+ #define nabi_no_regargs
+
+-#endif /* CONFIG_MIPS32 */
++#endif /* ndef __mips64 */
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+
+ #define save_static_function(symbol) \
+ __asm__ ( \
+@@ -78,6 +78,6 @@
+ unsigned long __dummy6, \
+ unsigned long __dummy7,
+
+-#endif /* CONFIG_MIPS64 */
++#endif /* __mips64 */
+
+ #endif /* _ASM_SIM_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/arch.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/arch.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/arch.h 2004-06-09 07:00:42.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/arch.h 2004-08-26 05:26:16.000000000 -0500
+@@ -17,8 +17,8 @@
+ #include <asm/sn/sn0/arch.h>
+ #endif
+
+-typedef u64 hubreg_t;
+-typedef u64 nic_t;
++typedef __u64 hubreg_t;
++typedef __u64 nic_t;
+
+ #define cputonasid(cpu) (cpu_data[(cpu)].p_nasid)
+ #define cputoslice(cpu) (cpu_data[(cpu)].p_slice)
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/gda.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/gda.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/gda.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/gda.h 2004-08-26 05:26:30.000000000 -0500
+@@ -44,11 +44,11 @@
+ #ifndef __ASSEMBLY__
+
+ typedef struct gda {
+- u32 g_magic; /* GDA magic number */
+- u16 g_version; /* Version of this structure */
+- u16 g_masterid; /* The NASID:CPUNUM of the master cpu */
+- u32 g_promop; /* Passes requests from the kernel to prom */
+- u32 g_vds; /* Store the virtual dipswitches here */
++ __u32 g_magic; /* GDA magic number */
++ __u16 g_version; /* Version of this structure */
++ __u16 g_masterid; /* The NASID:CPUNUM of the master cpu */
++ __u32 g_promop; /* Passes requests from the kernel to prom */
++ __u32 g_vds; /* Store the virtual dipswitches here */
+ void **g_hooked_norm;/* ptr to pda loc for norm hndlr */
+ void **g_hooked_utlb;/* ptr to pda loc for utlb hndlr */
+ void **g_hooked_xtlb;/* ptr to pda loc for xtlb hndlr */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/ioc3.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/ioc3.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/ioc3.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/ioc3.h 2004-08-26 05:26:06.000000000 -0500
+@@ -8,23 +8,23 @@
+ /* SUPERIO uart register map */
+ typedef volatile struct ioc3_uartregs {
+ union {
+- volatile u8 rbr; /* read only, DLAB == 0 */
+- volatile u8 thr; /* write only, DLAB == 0 */
+- volatile u8 dll; /* DLAB == 1 */
++ volatile __u8 rbr; /* read only, DLAB == 0 */
++ volatile __u8 thr; /* write only, DLAB == 0 */
++ volatile __u8 dll; /* DLAB == 1 */
+ } u1;
+ union {
+- volatile u8 ier; /* DLAB == 0 */
+- volatile u8 dlm; /* DLAB == 1 */
++ volatile __u8 ier; /* DLAB == 0 */
++ volatile __u8 dlm; /* DLAB == 1 */
+ } u2;
+ union {
+- volatile u8 iir; /* read only */
+- volatile u8 fcr; /* write only */
++ volatile __u8 iir; /* read only */
++ volatile __u8 fcr; /* write only */
+ } u3;
+- volatile u8 iu_lcr;
+- volatile u8 iu_mcr;
+- volatile u8 iu_lsr;
+- volatile u8 iu_msr;
+- volatile u8 iu_scr;
++ volatile __u8 iu_lcr;
++ volatile __u8 iu_mcr;
++ volatile __u8 iu_lsr;
++ volatile __u8 iu_msr;
++ volatile __u8 iu_scr;
+ } ioc3_uregs_t;
+
+ #define iu_rbr u1.rbr
+@@ -36,29 +36,29 @@
+ #define iu_fcr u3.fcr
+
+ struct ioc3_sioregs {
+- volatile u8 fill[0x141]; /* starts at 0x141 */
++ volatile __u8 fill[0x141]; /* starts at 0x141 */
+
+- volatile u8 uartc;
+- volatile u8 kbdcg;
++ volatile __u8 uartc;
++ volatile __u8 kbdcg;
+
+- volatile u8 fill0[0x150 - 0x142 - 1];
++ volatile __u8 fill0[0x150 - 0x142 - 1];
+
+- volatile u8 pp_data;
+- volatile u8 pp_dsr;
+- volatile u8 pp_dcr;
++ volatile __u8 pp_data;
++ volatile __u8 pp_dsr;
++ volatile __u8 pp_dcr;
+
+- volatile u8 fill1[0x158 - 0x152 - 1];
++ volatile __u8 fill1[0x158 - 0x152 - 1];
+
+- volatile u8 pp_fifa;
+- volatile u8 pp_cfgb;
+- volatile u8 pp_ecr;
++ volatile __u8 pp_fifa;
++ volatile __u8 pp_cfgb;
++ volatile __u8 pp_ecr;
+
+- volatile u8 fill2[0x168 - 0x15a - 1];
++ volatile __u8 fill2[0x168 - 0x15a - 1];
+
+- volatile u8 rtcad;
+- volatile u8 rtcdat;
++ volatile __u8 rtcad;
++ volatile __u8 rtcdat;
+
+- volatile u8 fill3[0x170 - 0x169 - 1];
++ volatile __u8 fill3[0x170 - 0x169 - 1];
+
+ struct ioc3_uartregs uartb; /* 0x20170 */
+ struct ioc3_uartregs uarta; /* 0x20178 */
+@@ -66,103 +66,103 @@
+
+ /* Register layout of IOC3 in configuration space. */
+ struct ioc3 {
+- volatile u32 pad0[7]; /* 0x00000 */
+- volatile u32 sio_ir; /* 0x0001c */
+- volatile u32 sio_ies; /* 0x00020 */
+- volatile u32 sio_iec; /* 0x00024 */
+- volatile u32 sio_cr; /* 0x00028 */
+- volatile u32 int_out; /* 0x0002c */
+- volatile u32 mcr; /* 0x00030 */
++ volatile __u32 pad0[7]; /* 0x00000 */
++ volatile __u32 sio_ir; /* 0x0001c */
++ volatile __u32 sio_ies; /* 0x00020 */
++ volatile __u32 sio_iec; /* 0x00024 */
++ volatile __u32 sio_cr; /* 0x00028 */
++ volatile __u32 int_out; /* 0x0002c */
++ volatile __u32 mcr; /* 0x00030 */
+
+ /* General Purpose I/O registers */
+- volatile u32 gpcr_s; /* 0x00034 */
+- volatile u32 gpcr_c; /* 0x00038 */
+- volatile u32 gpdr; /* 0x0003c */
+- volatile u32 gppr_0; /* 0x00040 */
+- volatile u32 gppr_1; /* 0x00044 */
+- volatile u32 gppr_2; /* 0x00048 */
+- volatile u32 gppr_3; /* 0x0004c */
+- volatile u32 gppr_4; /* 0x00050 */
+- volatile u32 gppr_5; /* 0x00054 */
+- volatile u32 gppr_6; /* 0x00058 */
+- volatile u32 gppr_7; /* 0x0005c */
+- volatile u32 gppr_8; /* 0x00060 */
+- volatile u32 gppr_9; /* 0x00064 */
+- volatile u32 gppr_10; /* 0x00068 */
+- volatile u32 gppr_11; /* 0x0006c */
+- volatile u32 gppr_12; /* 0x00070 */
+- volatile u32 gppr_13; /* 0x00074 */
+- volatile u32 gppr_14; /* 0x00078 */
+- volatile u32 gppr_15; /* 0x0007c */
++ volatile __u32 gpcr_s; /* 0x00034 */
++ volatile __u32 gpcr_c; /* 0x00038 */
++ volatile __u32 gpdr; /* 0x0003c */
++ volatile __u32 gppr_0; /* 0x00040 */
++ volatile __u32 gppr_1; /* 0x00044 */
++ volatile __u32 gppr_2; /* 0x00048 */
++ volatile __u32 gppr_3; /* 0x0004c */
++ volatile __u32 gppr_4; /* 0x00050 */
++ volatile __u32 gppr_5; /* 0x00054 */
++ volatile __u32 gppr_6; /* 0x00058 */
++ volatile __u32 gppr_7; /* 0x0005c */
++ volatile __u32 gppr_8; /* 0x00060 */
++ volatile __u32 gppr_9; /* 0x00064 */
++ volatile __u32 gppr_10; /* 0x00068 */
++ volatile __u32 gppr_11; /* 0x0006c */
++ volatile __u32 gppr_12; /* 0x00070 */
++ volatile __u32 gppr_13; /* 0x00074 */
++ volatile __u32 gppr_14; /* 0x00078 */
++ volatile __u32 gppr_15; /* 0x0007c */
+
+ /* Parallel Port Registers */
+- volatile u32 ppbr_h_a; /* 0x00080 */
+- volatile u32 ppbr_l_a; /* 0x00084 */
+- volatile u32 ppcr_a; /* 0x00088 */
+- volatile u32 ppcr; /* 0x0008c */
+- volatile u32 ppbr_h_b; /* 0x00090 */
+- volatile u32 ppbr_l_b; /* 0x00094 */
+- volatile u32 ppcr_b; /* 0x00098 */
++ volatile __u32 ppbr_h_a; /* 0x00080 */
++ volatile __u32 ppbr_l_a; /* 0x00084 */
++ volatile __u32 ppcr_a; /* 0x00088 */
++ volatile __u32 ppcr; /* 0x0008c */
++ volatile __u32 ppbr_h_b; /* 0x00090 */
++ volatile __u32 ppbr_l_b; /* 0x00094 */
++ volatile __u32 ppcr_b; /* 0x00098 */
+
+ /* Keyboard and Mouse Registers */
+- volatile u32 km_csr; /* 0x0009c */
+- volatile u32 k_rd; /* 0x000a0 */
+- volatile u32 m_rd; /* 0x000a4 */
+- volatile u32 k_wd; /* 0x000a8 */
+- volatile u32 m_wd; /* 0x000ac */
++ volatile __u32 km_csr; /* 0x0009c */
++ volatile __u32 k_rd; /* 0x000a0 */
++ volatile __u32 m_rd; /* 0x000a4 */
++ volatile __u32 k_wd; /* 0x000a8 */
++ volatile __u32 m_wd; /* 0x000ac */
+
+ /* Serial Port Registers */
+- volatile u32 sbbr_h; /* 0x000b0 */
+- volatile u32 sbbr_l; /* 0x000b4 */
+- volatile u32 sscr_a; /* 0x000b8 */
+- volatile u32 stpir_a; /* 0x000bc */
+- volatile u32 stcir_a; /* 0x000c0 */
+- volatile u32 srpir_a; /* 0x000c4 */
+- volatile u32 srcir_a; /* 0x000c8 */
+- volatile u32 srtr_a; /* 0x000cc */
+- volatile u32 shadow_a; /* 0x000d0 */
+- volatile u32 sscr_b; /* 0x000d4 */
+- volatile u32 stpir_b; /* 0x000d8 */
+- volatile u32 stcir_b; /* 0x000dc */
+- volatile u32 srpir_b; /* 0x000e0 */
+- volatile u32 srcir_b; /* 0x000e4 */
+- volatile u32 srtr_b; /* 0x000e8 */
+- volatile u32 shadow_b; /* 0x000ec */
++ volatile __u32 sbbr_h; /* 0x000b0 */
++ volatile __u32 sbbr_l; /* 0x000b4 */
++ volatile __u32 sscr_a; /* 0x000b8 */
++ volatile __u32 stpir_a; /* 0x000bc */
++ volatile __u32 stcir_a; /* 0x000c0 */
++ volatile __u32 srpir_a; /* 0x000c4 */
++ volatile __u32 srcir_a; /* 0x000c8 */
++ volatile __u32 srtr_a; /* 0x000cc */
++ volatile __u32 shadow_a; /* 0x000d0 */
++ volatile __u32 sscr_b; /* 0x000d4 */
++ volatile __u32 stpir_b; /* 0x000d8 */
++ volatile __u32 stcir_b; /* 0x000dc */
++ volatile __u32 srpir_b; /* 0x000e0 */
++ volatile __u32 srcir_b; /* 0x000e4 */
++ volatile __u32 srtr_b; /* 0x000e8 */
++ volatile __u32 shadow_b; /* 0x000ec */
+
+ /* Ethernet Registers */
+- volatile u32 emcr; /* 0x000f0 */
+- volatile u32 eisr; /* 0x000f4 */
+- volatile u32 eier; /* 0x000f8 */
+- volatile u32 ercsr; /* 0x000fc */
+- volatile u32 erbr_h; /* 0x00100 */
+- volatile u32 erbr_l; /* 0x00104 */
+- volatile u32 erbar; /* 0x00108 */
+- volatile u32 ercir; /* 0x0010c */
+- volatile u32 erpir; /* 0x00110 */
+- volatile u32 ertr; /* 0x00114 */
+- volatile u32 etcsr; /* 0x00118 */
+- volatile u32 ersr; /* 0x0011c */
+- volatile u32 etcdc; /* 0x00120 */
+- volatile u32 ebir; /* 0x00124 */
+- volatile u32 etbr_h; /* 0x00128 */
+- volatile u32 etbr_l; /* 0x0012c */
+- volatile u32 etcir; /* 0x00130 */
+- volatile u32 etpir; /* 0x00134 */
+- volatile u32 emar_h; /* 0x00138 */
+- volatile u32 emar_l; /* 0x0013c */
+- volatile u32 ehar_h; /* 0x00140 */
+- volatile u32 ehar_l; /* 0x00144 */
+- volatile u32 micr; /* 0x00148 */
+- volatile u32 midr_r; /* 0x0014c */
+- volatile u32 midr_w; /* 0x00150 */
+- volatile u32 pad1[(0x20000 - 0x00154) / 4];
++ volatile __u32 emcr; /* 0x000f0 */
++ volatile __u32 eisr; /* 0x000f4 */
++ volatile __u32 eier; /* 0x000f8 */
++ volatile __u32 ercsr; /* 0x000fc */
++ volatile __u32 erbr_h; /* 0x00100 */
++ volatile __u32 erbr_l; /* 0x00104 */
++ volatile __u32 erbar; /* 0x00108 */
++ volatile __u32 ercir; /* 0x0010c */
++ volatile __u32 erpir; /* 0x00110 */
++ volatile __u32 ertr; /* 0x00114 */
++ volatile __u32 etcsr; /* 0x00118 */
++ volatile __u32 ersr; /* 0x0011c */
++ volatile __u32 etcdc; /* 0x00120 */
++ volatile __u32 ebir; /* 0x00124 */
++ volatile __u32 etbr_h; /* 0x00128 */
++ volatile __u32 etbr_l; /* 0x0012c */
++ volatile __u32 etcir; /* 0x00130 */
++ volatile __u32 etpir; /* 0x00134 */
++ volatile __u32 emar_h; /* 0x00138 */
++ volatile __u32 emar_l; /* 0x0013c */
++ volatile __u32 ehar_h; /* 0x00140 */
++ volatile __u32 ehar_l; /* 0x00144 */
++ volatile __u32 micr; /* 0x00148 */
++ volatile __u32 midr_r; /* 0x0014c */
++ volatile __u32 midr_w; /* 0x00150 */
++ volatile __u32 pad1[(0x20000 - 0x00154) / 4];
+
+ /* SuperIO Registers XXX */
+ struct ioc3_sioregs sregs; /* 0x20000 */
+- volatile u32 pad2[(0x40000 - 0x20180) / 4];
++ volatile __u32 pad2[(0x40000 - 0x20180) / 4];
+
+ /* SSRAM Diagnostic Access */
+- volatile u32 ssram[(0x80000 - 0x40000) / 4];
++ volatile __u32 ssram[(0x80000 - 0x40000) / 4];
+
+ /* Bytebus device offsets
+ 0x80000 - Access to the generic devices selected with DEV0
+@@ -179,8 +179,8 @@
+ * Ethernet RX Buffer
+ */
+ struct ioc3_erxbuf {
+- u32 w0; /* first word (valid,bcnt,cksum) */
+- u32 err; /* second word various errors */
++ __u32 w0; /* first word (valid,bcnt,cksum) */
++ __u32 err; /* second word various errors */
+ /* next comes n bytes of padding */
+ /* then the received ethernet frame itself */
+ };
+@@ -208,11 +208,11 @@
+ */
+ #define ETXD_DATALEN 104
+ struct ioc3_etxd {
+- u32 cmd; /* command field */
+- u32 bufcnt; /* buffer counts field */
+- u64 p1; /* buffer pointer 1 */
+- u64 p2; /* buffer pointer 2 */
+- u8 data[ETXD_DATALEN]; /* opt. tx data */
++ __u32 cmd; /* command field */
++ __u32 bufcnt; /* buffer counts field */
++ __u64 p1; /* buffer pointer 1 */
++ __u64 p2; /* buffer pointer 2 */
++ __u8 data[ETXD_DATALEN]; /* opt. tx data */
+ };
+
+ #define ETXD_BYTECNT_MASK 0x000007ff /* total byte count */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/klconfig.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/klconfig.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/klconfig.h 2004-03-28 07:51:55.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/klconfig.h 2004-08-26 05:26:13.000000000 -0500
+@@ -64,9 +64,9 @@
+ #define KLCFGINFO_MAGIC 0xbeedbabe
+
+ #ifdef FRUTEST
+-typedef u64 klconf_off_t;
++typedef __u64 klconf_off_t;
+ #else
+-typedef s32 klconf_off_t;
++typedef __s32 klconf_off_t;
+ #endif
+
+ /*
+@@ -160,8 +160,8 @@
+ /* Functions/macros needed to use this structure */
+
+ typedef struct kl_config_hdr {
+- u64 ch_magic; /* set this to KLCFGINFO_MAGIC */
+- u32 ch_version; /* structure version number */
++ __u64 ch_magic; /* set this to KLCFGINFO_MAGIC */
++ __u32 ch_version; /* structure version number */
+ klconf_off_t ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
+ klconf_off_t ch_cons_off; /* offset of ch_cons */
+ klconf_off_t ch_board_info; /* the link list of boards */
+@@ -609,14 +609,14 @@
+
+ /* Info holders for various hardware components */
+
+-typedef u64 *pci_t;
+-typedef u64 *vmeb_t;
+-typedef u64 *vmed_t;
+-typedef u64 *fddi_t;
+-typedef u64 *scsi_t;
+-typedef u64 *mio_t;
+-typedef u64 *graphics_t;
+-typedef u64 *router_t;
++typedef __u64 *pci_t;
++typedef __u64 *vmeb_t;
++typedef __u64 *vmed_t;
++typedef __u64 *fddi_t;
++typedef __u64 *scsi_t;
++typedef __u64 *mio_t;
++typedef __u64 *graphics_t;
++typedef __u64 *router_t;
+
+ /*
+ * The port info in ip27_cfg area translates to a lboart_t in the
+@@ -659,7 +659,7 @@
+ klport_t hub_port; /* hub is connected to this */
+ nic_t hub_box_nic; /* nic of containing box */
+ klconf_off_t hub_mfg_nic; /* MFG NIC string */
+- u64 hub_speed; /* Speed of hub in HZ */
++ __u64 hub_speed; /* Speed of hub in HZ */
+ } klhub_t ;
+
+ typedef struct klhub_uart_s { /* HUB */
+@@ -716,8 +716,8 @@
+ #define MAX_PCI_SLOTS 8
+
+ typedef struct klpci_device_s {
+- s32 pci_device_id; /* 32 bits of vendor/device ID. */
+- s32 pci_device_pad; /* 32 bits of padding. */
++ __s32 pci_device_id; /* 32 bits of vendor/device ID. */
++ __s32 pci_device_pad; /* 32 bits of padding. */
+ } klpci_device_t;
+
+ #define BRIDGE_STRUCT_VERSION 2
+@@ -767,7 +767,7 @@
+ nic_t rou_box_nic ; /* nic of the containing module */
+ klport_t rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
+ klconf_off_t rou_mfg_nic ; /* MFG NIC string */
+- u64 rou_vector; /* vector from master node */
++ __u64 rou_vector; /* vector from master node */
+ } klrou_t ;
+
+ /*
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/kldir.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/kldir.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/kldir.h 2004-01-17 17:03:49.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/kldir.h 2004-08-26 05:26:25.000000000 -0500
+@@ -210,7 +210,7 @@
+
+ #ifndef __ASSEMBLY__
+ typedef struct kldir_ent_s {
+- u64 magic; /* Indicates validity of entry */
++ __u64 magic; /* Indicates validity of entry */
+ off_t offset; /* Offset from start of node space */
+ #if defined(CONFIG_SGI_IO) /* FIXME */
+ __psunsigned_t pointer; /* Pointer to area in some cases */
+@@ -218,7 +218,7 @@
+ unsigned long pointer; /* Pointer to area in some cases */
+ #endif
+ size_t size; /* Size in bytes */
+- u64 count; /* Repeat count if array, 1 if not */
++ __u64 count; /* Repeat count if array, 1 if not */
+ size_t stride; /* Stride if array, 0 if not */
+ char rsvd[16]; /* Pad entry to 0x40 bytes */
+ /* NOTE: These 16 bytes are used in the Partition KLDIR
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/launch.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/launch.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/launch.h 2004-01-17 17:03:49.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/launch.h 2004-08-26 05:25:52.000000000 -0500
+@@ -62,14 +62,14 @@
+ #ifndef __ASSEMBLY__
+
+ typedef int launch_state_t;
+-typedef void (*launch_proc_t)(u64 call_parm);
++typedef void (*launch_proc_t)(__u64 call_parm);
+
+ typedef struct launch_s {
+- volatile u64 magic; /* Magic number */
+- volatile u64 busy; /* Slave currently active */
++ volatile __u64 magic; /* Magic number */
++ volatile __u64 busy; /* Slave currently active */
+ volatile launch_proc_t call_addr; /* Func. for slave to call */
+- volatile u64 call_addr_c; /* 1's complement of call_addr*/
+- volatile u64 call_parm; /* Single parm passed to call*/
++ volatile __u64 call_addr_c; /* 1's complement of call_addr*/
++ volatile __u64 call_parm; /* Single parm passed to call*/
+ volatile void *stack_addr; /* Stack pointer for slave function */
+ volatile void *gp_addr; /* Global pointer for slave func. */
+ volatile char *bevutlb;/* Address of bev utlb ex handler */
+@@ -84,7 +84,7 @@
+
+ #define LAUNCH_SLAVE (*(void (*)(int nasid, int cpu, \
+ launch_proc_t call_addr, \
+- u64 call_parm, \
++ __u64 call_parm, \
+ void *stack_addr, \
+ void *gp_addr)) \
+ IP27PROM_LAUNCHSLAVE)
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubio.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubio.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubio.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubio.h 2004-08-26 05:27:21.000000000 -0500
+@@ -172,9 +172,9 @@
+ #ifndef __ASSEMBLY__
+
+ typedef union hubii_wid_u {
+- u64 wid_reg_value;
++ __u64 wid_reg_value;
+ struct {
+- u64 wid_rsvd: 32, /* unused */
++ __u64 wid_rsvd: 32, /* unused */
+ wid_rev_num: 4, /* revision number */
+ wid_part_num: 16, /* the widget type: hub=c101 */
+ wid_mfg_num: 11, /* Manufacturer id (IBM) */
+@@ -184,9 +184,9 @@
+
+
+ typedef union hubii_wcr_u {
+- u64 wcr_reg_value;
++ __u64 wcr_reg_value;
+ struct {
+- u64 wcr_rsvd: 41, /* unused */
++ __u64 wcr_rsvd: 41, /* unused */
+ wcr_e_thresh: 5, /* elasticity threshold */
+ wcr_dir_con: 1, /* widget direct connect */
+ wcr_f_bad_pkt: 1, /* Force bad llp pkt enable */
+@@ -200,9 +200,9 @@
+ #define iwcr_dir_con wcr_fields_s.wcr_dir_con
+
+ typedef union hubii_wstat_u {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd1: 31,
++ __u64 rsvd1: 31,
+ crazy: 1, /* Crazy bit */
+ rsvd2: 8,
+ llp_tx_cnt: 8, /* LLP Xmit retry counter */
+@@ -217,9 +217,9 @@
+
+
+ typedef union hubii_ilcsr_u {
+- u64 icsr_reg_value;
++ __u64 icsr_reg_value;
+ struct {
+- u64 icsr_rsvd: 22, /* unused */
++ __u64 icsr_rsvd: 22, /* unused */
+ icsr_max_burst: 10, /* max burst */
+ icsr_rsvd4: 6, /* reserved */
+ icsr_max_retry: 10, /* max retry */
+@@ -237,9 +237,9 @@
+
+
+ typedef union hubii_iowa_u {
+- u64 iowa_reg_value;
++ __u64 iowa_reg_value;
+ struct {
+- u64 iowa_rsvd: 48, /* unused */
++ __u64 iowa_rsvd: 48, /* unused */
+ iowa_wxoac: 8, /* xtalk widget access bits */
+ iowa_rsvd1: 7, /* xtalk widget access bits */
+ iowa_w0oac: 1; /* xtalk widget access bits */
+@@ -247,9 +247,9 @@
+ } hubii_iowa_t;
+
+ typedef union hubii_iiwa_u {
+- u64 iiwa_reg_value;
++ __u64 iiwa_reg_value;
+ struct {
+- u64 iiwa_rsvd: 48, /* unused */
++ __u64 iiwa_rsvd: 48, /* unused */
+ iiwa_wxiac: 8, /* hub wid access bits */
+ iiwa_rsvd1: 7, /* reserved */
+ iiwa_w0iac: 1; /* hub wid0 access */
+@@ -257,9 +257,9 @@
+ } hubii_iiwa_t;
+
+ typedef union hubii_illr_u {
+- u64 illr_reg_value;
++ __u64 illr_reg_value;
+ struct {
+- u64 illr_rsvd: 32, /* unused */
++ __u64 illr_rsvd: 32, /* unused */
+ illr_cb_cnt: 16, /* checkbit error count */
+ illr_sn_cnt: 16; /* sequence number count */
+ } illr_fields_s;
+@@ -271,9 +271,9 @@
+ /* io_perf_sel allows the caller to specify what tests will be
+ performed */
+ typedef union io_perf_sel {
+- u64 perf_sel_reg;
++ __u64 perf_sel_reg;
+ struct {
+- u64 perf_rsvd : 48,
++ __u64 perf_rsvd : 48,
+ perf_icct : 8,
+ perf_ippr1 : 4,
+ perf_ippr0 : 4;
+@@ -284,9 +284,9 @@
+ hardware problems there is only one counter, not two. */
+
+ typedef union io_perf_cnt {
+- u64 perf_cnt;
++ __u64 perf_cnt;
+ struct {
+- u64 perf_rsvd1 : 32,
++ __u64 perf_rsvd1 : 32,
+ perf_rsvd2 : 12,
+ perf_cnt : 20;
+ } perf_cnt_bits;
+@@ -442,9 +442,9 @@
+ */
+ #ifndef __ASSEMBLY__
+ typedef union icrba_u {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 resvd: 6,
++ __u64 resvd: 6,
+ stall_bte0: 1, /* Stall BTE 0 */
+ stall_bte1: 1, /* Stall BTE 1 */
+ error: 1, /* CRB has an error */
+@@ -464,10 +464,10 @@
+ runtime selection of the format based on the REV_ID field of the
+ NI_STATUS_REV_ID register. */
+ typedef union h1_icrba_u {
+- u64 reg_value;
++ __u64 reg_value;
+
+ struct {
+- u64 resvd: 6,
++ __u64 resvd: 6,
+ unused: 1, /* Unused but RW!! */
+ error: 1, /* CRB has an error */
+ ecode: 4, /* Error Code */
+@@ -525,9 +525,9 @@
+ */
+ #ifndef __ASSEMBLY__
+ typedef union icrbb_u {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd1: 5,
++ __u64 rsvd1: 5,
+ btenum: 1, /* BTE to which entry belongs to */
+ cohtrans: 1, /* Coherent transaction */
+ xtsize: 2, /* Xtalk operation size
+@@ -567,9 +567,9 @@
+ runtime selection of the format based on the REV_ID field of the
+ NI_STATUS_REV_ID register. */
+ typedef union h1_icrbb_u {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd1: 5,
++ __u64 rsvd1: 5,
+ btenum: 1, /* BTE to which entry belongs to */
+ cohtrans: 1, /* Coherent transaction */
+ xtsize: 2, /* Xtalk operation size
+@@ -683,9 +683,9 @@
+ #ifndef __ASSEMBLY__
+
+ typedef union icrbc_s {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd: 6,
++ __u64 rsvd: 6,
+ sleep: 1,
+ pricnt: 4, /* Priority count sent with Read req */
+ pripsc: 4, /* Priority Pre scalar */
+@@ -720,9 +720,9 @@
+
+ #ifndef __ASSEMBLY__
+ typedef union icrbd_s {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd: 38,
++ __u64 rsvd: 38,
+ toutvld: 1, /* Timeout in progress for this CRB */
+ ctxtvld: 1, /* Context field below is valid */
+ rsvd2: 1,
+@@ -742,9 +742,9 @@
+
+
+ typedef union hubii_ifdr_u {
+- u64 hi_ifdr_value;
++ __u64 hi_ifdr_value;
+ struct {
+- u64 ifdr_rsvd: 49,
++ __u64 ifdr_rsvd: 49,
+ ifdr_maxrp: 7,
+ ifdr_rsvd1: 1,
+ ifdr_maxrq: 7;
+@@ -801,9 +801,9 @@
+ #ifndef __ASSEMBLY__
+
+ typedef union iprte_a {
+- u64 entry;
++ __u64 entry;
+ struct {
+- u64 rsvd1 : 7, /* Reserved field */
++ __u64 rsvd1 : 7, /* Reserved field */
+ valid : 1, /* Maps to a timeout entry */
+ rsvd2 : 1,
+ srcnode : 9, /* Node which did this PIO */
+@@ -835,9 +835,9 @@
+ */
+
+ typedef union iprb_u {
+- u64 reg_value;
++ __u64 reg_value;
+ struct {
+- u64 rsvd1: 15,
++ __u64 rsvd1: 15,
+ error: 1, /* Widget rcvd wr resp pkt w/ error */
+ ovflow: 5, /* Over flow count. perf measurement */
+ fire_and_forget: 1, /* Launch Write without response */
+@@ -877,9 +877,9 @@
+ */
+ #ifndef __ASSEMBLY__
+ typedef union icrbp_a {
+- u64 ip_reg; /* the entire register value */
++ __u64 ip_reg; /* the entire register value */
+ struct {
+- u64 error: 1, /* 63, error occurred */
++ __u64 error: 1, /* 63, error occurred */
+ ln_uce: 1, /* 62: uncorrectable memory */
+ ln_ae: 1, /* 61: protection violation */
+ ln_werr:1, /* 60: write access error */
+@@ -919,9 +919,9 @@
+
+ #ifndef __ASSEMBLY__
+ typedef union hubii_idsr {
+- u64 iin_reg;
++ __u64 iin_reg;
+ struct {
+- u64 rsvd1 : 35,
++ __u64 rsvd1 : 35,
+ isent : 1,
+ rsvd2 : 3,
+ ienable: 1,
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubmd.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubmd.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubmd.h 2004-01-17 17:03:49.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubmd.h 2004-08-26 05:27:00.000000000 -0500
+@@ -541,7 +541,7 @@
+ */
+
+ struct dir_error_reg {
+- u64 uce_vld: 1, /* 63: valid directory uce */
++ __u64 uce_vld: 1, /* 63: valid directory uce */
+ ae_vld: 1, /* 62: valid dir prot ecc error */
+ ce_vld: 1, /* 61: valid correctable ECC err*/
+ rsvd1: 19, /* 60-42: reserved */
+@@ -555,13 +555,13 @@
+ };
+
+ typedef union md_dir_error {
+- u64 derr_reg; /* the entire register */
++ __u64 derr_reg; /* the entire register */
+ struct dir_error_reg derr_fmt; /* the register format */
+ } md_dir_error_t;
+
+
+ struct mem_error_reg {
+- u64 uce_vld: 1, /* 63: valid memory uce */
++ __u64 uce_vld: 1, /* 63: valid memory uce */
+ ce_vld: 1, /* 62: valid correctable ECC err*/
+ rsvd1: 22, /* 61-40: reserved */
+ bad_syn: 8, /* 39-32: bad mem ecc syndrome */
+@@ -573,13 +573,13 @@
+
+
+ typedef union md_mem_error {
+- u64 merr_reg; /* the entire register */
++ __u64 merr_reg; /* the entire register */
+ struct mem_error_reg merr_fmt; /* format of the mem_error reg */
+ } md_mem_error_t;
+
+
+ struct proto_error_reg {
+- u64 valid: 1, /* 63: valid protocol error */
++ __u64 valid: 1, /* 63: valid protocol error */
+ rsvd1: 2, /* 62-61: reserved */
+ initiator:11, /* 60-50: id of request initiator*/
+ backoff: 2, /* 49-48: backoff control */
+@@ -594,7 +594,7 @@
+ };
+
+ typedef union md_proto_error {
+- u64 perr_reg; /* the entire register */
++ __u64 perr_reg; /* the entire register */
+ struct proto_error_reg perr_fmt; /* format of the register */
+ } md_proto_error_t;
+
+@@ -642,7 +642,7 @@
+
+
+ struct md_pdir_high_fmt {
+- u64 pd_hi_unused : 16,
++ __u64 pd_hi_unused : 16,
+ pd_hi_bvec : 38,
+ pd_hi_unused1 : 3,
+ pd_hi_ecc : 7;
+@@ -651,14 +651,14 @@
+
+ typedef union md_pdir_high {
+ /* The 48 bits of standard directory, upper word */
+- u64 pd_hi_val;
++ __u64 pd_hi_val;
+ struct md_pdir_high_fmt pd_hi_fmt;
+ }md_pdir_high_t;
+
+
+ struct md_pdir_low_shared_fmt {
+ /* The meaning of lower directory, shared */
+- u64 pds_lo_unused : 16,
++ __u64 pds_lo_unused : 16,
+ pds_lo_bvec : 26,
+ pds_lo_cnt : 6,
+ pds_lo_state : 3,
+@@ -670,7 +670,7 @@
+
+ struct md_pdir_low_exclusive_fmt {
+ /* The meaning of lower directory, exclusive */
+- u64 pde_lo_unused : 31,
++ __u64 pde_lo_unused : 31,
+ pde_lo_ptr : 11,
+ pde_lo_unused1 : 6,
+ pde_lo_state : 3,
+@@ -683,7 +683,7 @@
+
+ typedef union md_pdir_loent {
+ /* The 48 bits of premium directory, lower word */
+- u64 pd_lo_val;
++ __u64 pd_lo_val;
+ struct md_pdir_low_exclusive_fmt pde_lo_fmt;
+ struct md_pdir_low_shared_fmt pds_lo_fmt;
+ }md_pdir_low_t;
+@@ -711,25 +711,25 @@
+ } bddir_entry_t;
+
+ typedef struct dir_mem_entry {
+- u64 prcpf[MAX_REGIONS];
++ __u64 prcpf[MAX_REGIONS];
+ bddir_entry_t directory_words[MD_PAGE_SIZE/CACHE_SLINE_SIZE];
+ } dir_mem_entry_t;
+
+
+
+ typedef union md_perf_sel {
+- u64 perf_sel_reg;
++ __u64 perf_sel_reg;
+ struct {
+- u64 perf_rsvd : 60,
++ __u64 perf_rsvd : 60,
+ perf_en : 1,
+ perf_sel : 3;
+ } perf_sel_bits;
+ } md_perf_sel_t;
+
+ typedef union md_perf_cnt {
+- u64 perf_cnt;
++ __u64 perf_cnt;
+ struct {
+- u64 perf_rsvd : 44,
++ __u64 perf_rsvd : 44,
+ perf_cnt : 20;
+ } perf_cnt_bits;
+ } md_perf_cnt_t;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubni.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubni.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubni.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubni.h 2004-08-26 05:26:48.000000000 -0500
+@@ -229,9 +229,9 @@
+ #ifndef __ASSEMBLY__
+
+ typedef union hubni_port_error_u {
+- u64 nipe_reg_value;
++ __u64 nipe_reg_value;
+ struct {
+- u64 nipe_rsvd: 26, /* unused */
++ __u64 nipe_rsvd: 26, /* unused */
+ nipe_lnk_reset: 1, /* link reset */
+ nipe_intl_err: 1, /* internal error */
+ nipe_bad_msg: 1, /* bad message */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubpi.h linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubpi.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/sn/sn0/hubpi.h 2003-12-15 12:47:02.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/sn/sn0/hubpi.h 2004-08-26 05:26:36.000000000 -0500
+@@ -312,7 +312,7 @@
+ */
+
+ struct err_stack_format {
+- u64 sk_addr : 33, /* address */
++ __u64 sk_addr : 33, /* address */
+ sk_cmd : 8, /* message command */
+ sk_crb_sts : 10, /* status from RRB or WRB */
+ sk_rw_rb : 1, /* RRB == 0, WRB == 1 */
+@@ -323,12 +323,12 @@
+ };
+
+ typedef union pi_err_stack {
+- u64 pi_stk_word;
++ __u64 pi_stk_word;
+ struct err_stack_format pi_stk_fmt;
+ } pi_err_stack_t;
+
+ struct err_status0_format {
+- u64 s0_valid : 1, /* Valid */
++ __u64 s0_valid : 1, /* Valid */
+ s0_ovr_run : 1, /* Overrun, spooled to memory */
+ s0_addr : 37, /* address */
+ s0_cmd : 8, /* message command */
+@@ -338,12 +338,12 @@
+ };
+
+ typedef union pi_err_stat0 {
+- u64 pi_stat0_word;
++ __u64 pi_stat0_word;
+ struct err_status0_format pi_stat0_fmt;
+ } pi_err_stat0_t;
+
+ struct err_status1_format {
+- u64 s1_src : 11, /* message source */
++ __u64 s1_src : 11, /* message source */
+ s1_crb_sts : 10, /* status from RRB or WRB */
+ s1_rw_rb : 1, /* RRB == 0, WRB == 1 */
+ s1_crb_num : 3, /* WRB (0 to 7) or RRB (0 to 4) */
+@@ -353,11 +353,11 @@
+ };
+
+ typedef union pi_err_stat1 {
+- u64 pi_stat1_word;
++ __u64 pi_stat1_word;
+ struct err_status1_format pi_stat1_fmt;
+ } pi_err_stat1_t;
+
+-typedef u64 rtc_time_t;
++typedef __u64 rtc_time_t;
+
+ #endif /* !__ASSEMBLY__ */
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/stackframe.h linux-libc-headers-2.6.8.0/include/asm-mips/stackframe.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/stackframe.h 2004-08-18 13:15:41.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/stackframe.h 2004-08-26 05:14:41.000000000 -0500
+@@ -25,7 +25,7 @@
+
+ .macro SAVE_TEMP
+ mfhi v1
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ LONG_S $8, PT_R8(sp)
+ LONG_S $9, PT_R9(sp)
+ #endif
+@@ -55,7 +55,7 @@
+
+ #ifdef CONFIG_SMP
+ .macro get_saved_sp /* SMP variation */
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ mfc0 k0, CP0_CONTEXT
+ lui k1, %hi(kernelsp)
+ srl k0, k0, 23
+@@ -63,7 +63,7 @@
+ addu k1, k0
+ LONG_L k1, %lo(kernelsp)(k1)
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ MFC0 k1, CP0_CONTEXT
+ dsra k1, 23
+ lui k0, %hi(pgd_current)
+@@ -76,13 +76,13 @@
+ .endm
+
+ .macro set_saved_sp stackp temp temp2
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ mfc0 \temp, CP0_CONTEXT
+ srl \temp, 23
+ sll \temp, 2
+ LONG_S \stackp, kernelsp(\temp)
+ #endif
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ lw \temp, TI_CPU(gp)
+ dsll \temp, 3
+ lui \temp2, %hi(kernelsp)
+@@ -127,7 +127,7 @@
+ LONG_S $6, PT_R6(sp)
+ MFC0 v1, CP0_EPC
+ LONG_S $7, PT_R7(sp)
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ LONG_S $8, PT_R8(sp)
+ LONG_S $9, PT_R9(sp)
+ #endif
+@@ -156,7 +156,7 @@
+
+ .macro RESTORE_TEMP
+ LONG_L $24, PT_LO(sp)
+-#ifdef CONFIG_MIPS32
++#ifndef __mips64
+ LONG_L $8, PT_R8(sp)
+ LONG_L $9, PT_R9(sp)
+ #endif
+@@ -204,7 +204,7 @@
+ LONG_L $31, PT_R31(sp)
+ LONG_L $28, PT_R28(sp)
+ LONG_L $25, PT_R25(sp)
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ LONG_L $8, PT_R8(sp)
+ LONG_L $9, PT_R9(sp)
+ #endif
+@@ -249,7 +249,7 @@
+ LONG_L $31, PT_R31(sp)
+ LONG_L $28, PT_R28(sp)
+ LONG_L $25, PT_R25(sp)
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ LONG_L $8, PT_R8(sp)
+ LONG_L $9, PT_R9(sp)
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/system.h linux-libc-headers-2.6.8.0/include/asm-mips/system.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/system.h 2004-08-18 13:15:42.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/system.h 2004-08-28 18:13:39.000000000 -0500
+@@ -15,10 +15,11 @@
+ #include <asm/sgidefs.h>
+
+ #include <linux/kernel.h>
++#include <linux/linkage.h>
+
+ #include <asm/addrspace.h>
+ #include <asm/ptrace.h>
+-#include <asm/hazards.h>
++#include <asm/types.h>
+
+ __asm__ (
+ ".macro\tlocal_irq_enable\n\t"
+@@ -311,7 +312,7 @@
+ return retval;
+ }
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
+ {
+ __u64 retval;
+@@ -406,7 +407,7 @@
+ return retval;
+ }
+
+-#ifdef CONFIG_MIPS64
++#ifdef __mips64
+ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
+ unsigned long new)
+ {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/tx4927/tx4927_mips.h linux-libc-headers-2.6.8.0/include/asm-mips/tx4927/tx4927_mips.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/tx4927/tx4927_mips.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/tx4927/tx4927_mips.h 2004-08-26 05:22:30.000000000 -0500
+@@ -36,15 +36,15 @@
+ ".set\tmips0");
+ }
+
+-#define reg_rd08(r) ((u8 )(*((vu8 *)(r))))
+-#define reg_rd16(r) ((u16)(*((vu16*)(r))))
+-#define reg_rd32(r) ((u32)(*((vu32*)(r))))
+-#define reg_rd64(r) ((u64)(*((vu64*)(r))))
++#define reg_rd08(r) ((__u8 )(*((vu8 *)(r))))
++#define reg_rd16(r) ((__u16)(*((vu16*)(r))))
++#define reg_rd32(r) ((__u32)(*((vu32*)(r))))
++#define reg_rd64(r) ((__u64)(*((vu64*)(r))))
+
+-#define reg_wr08(r,v) ((*((vu8 *)(r)))=((u8 )(v)))
+-#define reg_wr16(r,v) ((*((vu16*)(r)))=((u16)(v)))
+-#define reg_wr32(r,v) ((*((vu32*)(r)))=((u32)(v)))
+-#define reg_wr64(r,v) ((*((vu64*)(r)))=((u64)(v)))
++#define reg_wr08(r,v) ((*((vu8 *)(r)))=((__u8 )(v)))
++#define reg_wr16(r,v) ((*((vu16*)(r)))=((__u16)(v)))
++#define reg_wr32(r,v) ((*((vu32*)(r)))=((__u32)(v)))
++#define reg_wr64(r,v) ((*((vu64*)(r)))=((__u64)(v)))
+
+ typedef volatile __signed char vs8;
+ typedef volatile unsigned char vu8;
+@@ -55,10 +55,10 @@
+ typedef volatile __signed int vs32;
+ typedef volatile unsigned int vu32;
+
+-typedef s8 s08;
++typedef __s8 s08;
+ typedef vs8 vs08;
+
+-typedef u8 u08;
++typedef __u8 u08;
+ typedef vu8 vu08;
+
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/unaligned.h linux-libc-headers-2.6.8.0/include/asm-mips/unaligned.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/unaligned.h 2004-08-15 15:38:27.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/asm-mips/unaligned.h 2004-08-26 05:22:21.000000000 -0500
+@@ -17,7 +17,7 @@
+ *
+ * This macro should be used for accessing values larger in size than
+ * single bytes at locations that are expected to be improperly aligned,
+- * e.g. retrieving a u16 value from a location not u16-aligned.
++ * e.g. retrieving a __u16 value from a location not __u16-aligned.
+ *
+ * Note that unaligned accesses can be very expensive on some architectures.
+ */
+@@ -31,7 +31,7 @@
+ *
+ * This macro should be used for placing values larger in size than
+ * single bytes at locations that are expected to be improperly aligned,
+- * e.g. writing a u16 value to a location not u16-aligned.
++ * e.g. writing a __u16 value to a location not __u16-aligned.
+ *
+ * Note that unaligned accesses can be very expensive on some architectures.
+ */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/asm-mips/xtalk/xwidget.h linux-libc-headers-2.6.8.0/include/asm-mips/xtalk/xwidget.h
+--- linux-libc-headers-2.6.8.0-dist/include/asm-mips/xtalk/xwidget.h 2003-12-15 12:47:03.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/asm-mips/xtalk/xwidget.h 2004-08-26 05:23:33.000000000 -0500
+@@ -92,7 +92,7 @@
+ * defined here
+ */
+ #ifndef __ASSEMBLY__
+-typedef u32 widgetreg_t;
++typedef __u32 widgetreg_t;
+
+ /* widget configuration registers */
+ typedef volatile struct widget_cfg {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/acpi.h linux-libc-headers-2.6.8.0/include/linux/acpi.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/acpi.h 2004-08-18 13:16:01.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/acpi.h 2004-08-26 05:41:49.000000000 -0500
+@@ -51,49 +51,49 @@
+
+ struct acpi_table_rsdp {
+ char signature[8];
+- u8 checksum;
++ __u8 checksum;
+ char oem_id[6];
+- u8 revision;
+- u32 rsdt_address;
++ __u8 revision;
++ __u32 rsdt_address;
+ } __attribute__ ((packed));
+
+ struct acpi20_table_rsdp {
+ char signature[8];
+- u8 checksum;
++ __u8 checksum;
+ char oem_id[6];
+- u8 revision;
+- u32 rsdt_address;
+- u32 length;
+- u64 xsdt_address;
+- u8 ext_checksum;
+- u8 reserved[3];
++ __u8 revision;
++ __u32 rsdt_address;
++ __u32 length;
++ __u64 xsdt_address;
++ __u8 ext_checksum;
++ __u8 reserved[3];
+ } __attribute__ ((packed));
+
+ typedef struct {
+- u8 type;
+- u8 length;
++ __u8 type;
++ __u8 length;
+ } __attribute__ ((packed)) acpi_table_entry_header;
+
+ /* Root System Description Table (RSDT) */
+
+ struct acpi_table_rsdt {
+ struct acpi_table_header header;
+- u32 entry[8];
++ __u32 entry[8];
+ } __attribute__ ((packed));
+
+ /* Extended System Description Table (XSDT) */
+
+ struct acpi_table_xsdt {
+ struct acpi_table_header header;
+- u64 entry[1];
++ __u64 entry[1];
+ } __attribute__ ((packed));
+
+ /* Fixed ACPI Description Table (FADT) */
+
+ struct acpi_table_fadt {
+ struct acpi_table_header header;
+- u32 facs_addr;
+- u32 dsdt_addr;
++ __u32 facs_addr;
++ __u32 dsdt_addr;
+ /* ... */
+ } __attribute__ ((packed));
+
+@@ -101,10 +101,10 @@
+
+ struct acpi_table_madt {
+ struct acpi_table_header header;
+- u32 lapic_address;
++ __u32 lapic_address;
+ struct {
+- u32 pcat_compat:1;
+- u32 reserved:31;
++ __u32 pcat_compat:1;
++ __u32 reserved:31;
+ } flags;
+ } __attribute__ ((packed));
+
+@@ -122,85 +122,85 @@
+ };
+
+ typedef struct {
+- u16 polarity:2;
+- u16 trigger:2;
+- u16 reserved:12;
++ __u16 polarity:2;
++ __u16 trigger:2;
++ __u16 reserved:12;
+ } __attribute__ ((packed)) acpi_interrupt_flags;
+
+ struct acpi_table_lapic {
+ acpi_table_entry_header header;
+- u8 acpi_id;
+- u8 id;
++ __u8 acpi_id;
++ __u8 id;
+ struct {
+- u32 enabled:1;
+- u32 reserved:31;
++ __u32 enabled:1;
++ __u32 reserved:31;
+ } flags;
+ } __attribute__ ((packed));
+
+ struct acpi_table_ioapic {
+ acpi_table_entry_header header;
+- u8 id;
+- u8 reserved;
+- u32 address;
+- u32 global_irq_base;
++ __u8 id;
++ __u8 reserved;
++ __u32 address;
++ __u32 global_irq_base;
+ } __attribute__ ((packed));
+
+ struct acpi_table_int_src_ovr {
+ acpi_table_entry_header header;
+- u8 bus;
+- u8 bus_irq;
+- u32 global_irq;
++ __u8 bus;
++ __u8 bus_irq;
++ __u32 global_irq;
+ acpi_interrupt_flags flags;
+ } __attribute__ ((packed));
+
+ struct acpi_table_nmi_src {
+ acpi_table_entry_header header;
+ acpi_interrupt_flags flags;
+- u32 global_irq;
++ __u32 global_irq;
+ } __attribute__ ((packed));
+
+ struct acpi_table_lapic_nmi {
+ acpi_table_entry_header header;
+- u8 acpi_id;
++ __u8 acpi_id;
+ acpi_interrupt_flags flags;
+- u8 lint;
++ __u8 lint;
+ } __attribute__ ((packed));
+
+ struct acpi_table_lapic_addr_ovr {
+ acpi_table_entry_header header;
+- u8 reserved[2];
+- u64 address;
++ __u8 reserved[2];
++ __u64 address;
+ } __attribute__ ((packed));
+
+ struct acpi_table_iosapic {
+ acpi_table_entry_header header;
+- u8 id;
+- u8 reserved;
+- u32 global_irq_base;
+- u64 address;
++ __u8 id;
++ __u8 reserved;
++ __u32 global_irq_base;
++ __u64 address;
+ } __attribute__ ((packed));
+
+ struct acpi_table_lsapic {
+ acpi_table_entry_header header;
+- u8 acpi_id;
+- u8 id;
+- u8 eid;
+- u8 reserved[3];
++ __u8 acpi_id;
++ __u8 id;
++ __u8 eid;
++ __u8 reserved[3];
+ struct {
+- u32 enabled:1;
+- u32 reserved:31;
++ __u32 enabled:1;
++ __u32 reserved:31;
+ } flags;
+ } __attribute__ ((packed));
+
+ struct acpi_table_plat_int_src {
+ acpi_table_entry_header header;
+ acpi_interrupt_flags flags;
+- u8 type; /* See acpi_interrupt_type */
+- u8 id;
+- u8 eid;
+- u8 iosapic_vector;
+- u32 global_irq;
+- u32 reserved;
++ __u8 type; /* See acpi_interrupt_type */
++ __u8 id;
++ __u8 eid;
++ __u8 iosapic_vector;
++ __u32 global_irq;
++ __u32 reserved;
+ } __attribute__ ((packed));
+
+ enum acpi_interrupt_id {
+@@ -213,21 +213,21 @@
+ #define ACPI_SPACE_MEM 0
+
+ struct acpi_gen_regaddr {
+- u8 space_id;
+- u8 bit_width;
+- u8 bit_offset;
+- u8 resv;
+- u32 addrl;
+- u32 addrh;
++ __u8 space_id;
++ __u8 bit_width;
++ __u8 bit_offset;
++ __u8 resv;
++ __u32 addrl;
++ __u32 addrh;
+ } __attribute__ ((packed));
+
+ struct acpi_table_hpet {
+ struct acpi_table_header header;
+- u32 id;
++ __u32 id;
+ struct acpi_gen_regaddr addr;
+- u8 number;
+- u16 min_tick;
+- u8 page_protect;
++ __u8 number;
++ __u16 min_tick;
++ __u8 page_protect;
+ } __attribute__ ((packed));
+
+ /*
+@@ -236,17 +236,17 @@
+ */
+ struct acpi_table_sbf
+ {
+- u8 sbf_signature[4];
+- u32 sbf_len;
+- u8 sbf_revision;
+- u8 sbf_csum;
+- u8 sbf_oemid[6];
+- u8 sbf_oemtable[8];
+- u8 sbf_revdata[4];
+- u8 sbf_creator[4];
+- u8 sbf_crearev[4];
+- u8 sbf_cmos;
+- u8 sbf_spare[3];
++ __u8 sbf_signature[4];
++ __u32 sbf_len;
++ __u8 sbf_revision;
++ __u8 sbf_csum;
++ __u8 sbf_oemid[6];
++ __u8 sbf_oemtable[8];
++ __u8 sbf_revdata[4];
++ __u8 sbf_creator[4];
++ __u8 sbf_crearev[4];
++ __u8 sbf_cmos;
++ __u8 sbf_spare[3];
+ } __attribute__ ((packed));
+
+ /*
+@@ -256,8 +256,8 @@
+
+ struct acpi_table_srat {
+ struct acpi_table_header header;
+- u32 table_revision;
+- u64 reserved;
++ __u32 table_revision;
++ __u64 reserved;
+ } __attribute__ ((packed));
+
+ enum acpi_srat_entry_id {
+@@ -268,31 +268,31 @@
+
+ struct acpi_table_processor_affinity {
+ acpi_table_entry_header header;
+- u8 proximity_domain;
+- u8 apic_id;
++ __u8 proximity_domain;
++ __u8 apic_id;
+ struct {
+- u32 enabled:1;
+- u32 reserved:31;
++ __u32 enabled:1;
++ __u32 reserved:31;
+ } flags;
+- u8 lsapic_eid;
+- u8 reserved[7];
++ __u8 lsapic_eid;
++ __u8 reserved[7];
+ } __attribute__ ((packed));
+
+ struct acpi_table_memory_affinity {
+ acpi_table_entry_header header;
+- u8 proximity_domain;
+- u8 reserved1[5];
+- u32 base_addr_lo;
+- u32 base_addr_hi;
+- u32 length_lo;
+- u32 length_hi;
+- u32 memory_type; /* See acpi_address_range_id */
++ __u8 proximity_domain;
++ __u8 reserved1[5];
++ __u32 base_addr_lo;
++ __u32 base_addr_hi;
++ __u32 length_lo;
++ __u32 length_hi;
++ __u32 memory_type; /* See acpi_address_range_id */
+ struct {
+- u32 enabled:1;
+- u32 hot_pluggable:1;
+- u32 reserved:30;
++ __u32 enabled:1;
++ __u32 hot_pluggable:1;
++ __u32 reserved:30;
+ } flags;
+- u64 reserved2;
++ __u64 reserved2;
+ } __attribute__ ((packed));
+
+ enum acpi_address_range_id {
+@@ -310,17 +310,17 @@
+
+ struct acpi_table_slit {
+ struct acpi_table_header header;
+- u64 localities;
+- u8 entry[1]; /* real size = localities^2 */
++ __u64 localities;
++ __u8 entry[1]; /* real size = localities^2 */
+ } __attribute__ ((packed));
+
+ /* Smart Battery Description Table (SBST) */
+
+ struct acpi_table_sbst {
+ struct acpi_table_header header;
+- u32 warning; /* Warn user */
+- u32 low; /* Critical sleep */
+- u32 critical; /* Critical shutdown */
++ __u32 warning; /* Warn user */
++ __u32 low; /* Critical sleep */
++ __u32 critical; /* Critical shutdown */
+ } __attribute__ ((packed));
+
+ /* Embedded Controller Boot Resources Table (ECDT) */
+@@ -329,8 +329,8 @@
+ struct acpi_table_header header;
+ struct acpi_generic_address ec_control;
+ struct acpi_generic_address ec_data;
+- u32 uid;
+- u8 gpe_bit;
++ __u32 uid;
++ __u8 gpe_bit;
+ char ec_id[0];
+ } __attribute__ ((packed));
+
+@@ -338,9 +338,9 @@
+
+ struct acpi_table_mcfg {
+ struct acpi_table_header header;
+- u8 reserved[8];
+- u32 base_address;
+- u32 base_reserved;
++ __u8 reserved[8];
++ __u32 base_address;
++ __u32 base_reserved;
+ } __attribute__ ((packed));
+
+ /* Table Handlers */
+@@ -396,7 +396,7 @@
+
+ extern int acpi_mp_config;
+
+-extern u32 pci_mmcfg_base_addr;
++extern __u32 pci_mmcfg_base_addr;
+
+ extern int sbf_port ;
+
+@@ -411,20 +411,20 @@
+
+ #endif /*!CONFIG_ACPI_BOOT*/
+
+-unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
+-int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
++unsigned int acpi_register_gsi (__u32 gsi, int edge_level, int active_high_low);
++int acpi_gsi_to_irq (__u32 gsi, unsigned int *irq);
+
+ #ifdef CONFIG_ACPI_PCI
+
+ struct acpi_prt_entry {
+ struct list_head node;
+ struct acpi_pci_id id;
+- u8 pin;
++ __u8 pin;
+ struct {
+ acpi_handle handle;
+- u32 index;
++ __u32 index;
+ } link;
+- u32 irq;
++ __u32 irq;
+ };
+
+ struct acpi_prt_list {
+@@ -451,8 +451,8 @@
+
+ #ifdef CONFIG_ACPI_EC
+
+-int ec_read(u8 addr, u8 *val);
+-int ec_write(u8 addr, u8 val);
++int ec_read(__u8 addr, __u8 *val);
++int ec_write(__u8 addr, __u8 val);
+
+ #endif /*CONFIG_ACPI_EC*/
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/affs_fs_i.h linux-libc-headers-2.6.8.0/include/linux/affs_fs_i.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/affs_fs_i.h 2003-12-31 17:46:48.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/affs_fs_i.h 2004-08-26 05:41:49.000000000 -0500
+@@ -9,13 +9,13 @@
+ //#define AFFS_CACHE_SIZE (4*4)
+
+ #define AFFS_MAX_PREALLOC 32
+-#define AFFS_LC_SIZE (AFFS_CACHE_SIZE/sizeof(u32)/2)
++#define AFFS_LC_SIZE (AFFS_CACHE_SIZE/sizeof(__u32)/2)
+ #define AFFS_AC_SIZE (AFFS_CACHE_SIZE/sizeof(struct affs_ext_key)/2)
+ #define AFFS_AC_MASK (AFFS_AC_SIZE-1)
+
+ struct affs_ext_key {
+- u32 ext; /* idx of the extended block */
+- u32 key; /* block number */
++ __u32 ext; /* idx of the extended block */
++ __u32 key; /* block number */
+ };
+
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/affs_fs_sb.h linux-libc-headers-2.6.8.0/include/linux/affs_fs_sb.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/affs_fs_sb.h 2004-08-18 13:16:01.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/affs_fs_sb.h 2004-08-26 05:41:49.000000000 -0500
+@@ -9,8 +9,8 @@
+ */
+
+ struct affs_bm_info {
+- u32 bm_key; /* Disk block number */
+- u32 bm_free; /* Free blocks in here */
++ __u32 bm_key; /* Disk block number */
++ __u32 bm_free; /* Free blocks in here */
+ };
+
+ #define SF_INTL 0x0001 /* International filesystem. */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/affs_hardblocks.h linux-libc-headers-2.6.8.0/include/linux/affs_hardblocks.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/affs_hardblocks.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/affs_hardblocks.h 2004-08-26 05:41:49.000000000 -0500
+@@ -4,59 +4,59 @@
+ /* Just the needed definitions for the RDB of an Amiga HD. */
+
+ struct RigidDiskBlock {
+- u32 rdb_ID;
+- u32 rdb_SummedLongs;
+- s32 rdb_ChkSum;
+- u32 rdb_HostID;
+- u32 rdb_BlockBytes;
+- u32 rdb_Flags;
+- u32 rdb_BadBlockList;
+- u32 rdb_PartitionList;
+- u32 rdb_FileSysHeaderList;
+- u32 rdb_DriveInit;
+- u32 rdb_Reserved1[6];
+- u32 rdb_Cylinders;
+- u32 rdb_Sectors;
+- u32 rdb_Heads;
+- u32 rdb_Interleave;
+- u32 rdb_Park;
+- u32 rdb_Reserved2[3];
+- u32 rdb_WritePreComp;
+- u32 rdb_ReducedWrite;
+- u32 rdb_StepRate;
+- u32 rdb_Reserved3[5];
+- u32 rdb_RDBBlocksLo;
+- u32 rdb_RDBBlocksHi;
+- u32 rdb_LoCylinder;
+- u32 rdb_HiCylinder;
+- u32 rdb_CylBlocks;
+- u32 rdb_AutoParkSeconds;
+- u32 rdb_HighRDSKBlock;
+- u32 rdb_Reserved4;
++ __u32 rdb_ID;
++ __u32 rdb_SummedLongs;
++ __s32 rdb_ChkSum;
++ __u32 rdb_HostID;
++ __u32 rdb_BlockBytes;
++ __u32 rdb_Flags;
++ __u32 rdb_BadBlockList;
++ __u32 rdb_PartitionList;
++ __u32 rdb_FileSysHeaderList;
++ __u32 rdb_DriveInit;
++ __u32 rdb_Reserved1[6];
++ __u32 rdb_Cylinders;
++ __u32 rdb_Sectors;
++ __u32 rdb_Heads;
++ __u32 rdb_Interleave;
++ __u32 rdb_Park;
++ __u32 rdb_Reserved2[3];
++ __u32 rdb_WritePreComp;
++ __u32 rdb_ReducedWrite;
++ __u32 rdb_StepRate;
++ __u32 rdb_Reserved3[5];
++ __u32 rdb_RDBBlocksLo;
++ __u32 rdb_RDBBlocksHi;
++ __u32 rdb_LoCylinder;
++ __u32 rdb_HiCylinder;
++ __u32 rdb_CylBlocks;
++ __u32 rdb_AutoParkSeconds;
++ __u32 rdb_HighRDSKBlock;
++ __u32 rdb_Reserved4;
+ char rdb_DiskVendor[8];
+ char rdb_DiskProduct[16];
+ char rdb_DiskRevision[4];
+ char rdb_ControllerVendor[8];
+ char rdb_ControllerProduct[16];
+ char rdb_ControllerRevision[4];
+- u32 rdb_Reserved5[10];
++ __u32 rdb_Reserved5[10];
+ };
+
+ #define IDNAME_RIGIDDISK 0x5244534B /* "RDSK" */
+
+ struct PartitionBlock {
+- u32 pb_ID;
+- u32 pb_SummedLongs;
+- s32 pb_ChkSum;
+- u32 pb_HostID;
+- u32 pb_Next;
+- u32 pb_Flags;
+- u32 pb_Reserved1[2];
+- u32 pb_DevFlags;
+- u8 pb_DriveName[32];
+- u32 pb_Reserved2[15];
+- u32 pb_Environment[17];
+- u32 pb_EReserved[15];
++ __u32 pb_ID;
++ __u32 pb_SummedLongs;
++ __s32 pb_ChkSum;
++ __u32 pb_HostID;
++ __u32 pb_Next;
++ __u32 pb_Flags;
++ __u32 pb_Reserved1[2];
++ __u32 pb_DevFlags;
++ __u8 pb_DriveName[32];
++ __u32 pb_Reserved2[15];
++ __u32 pb_Environment[17];
++ __u32 pb_EReserved[15];
+ };
+
+ #define IDNAME_PARTITION 0x50415254 /* "PART" */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/amigaffs.h linux-libc-headers-2.6.8.0/include/linux/amigaffs.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/amigaffs.h 2003-12-31 17:46:48.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/amigaffs.h 2004-08-26 05:41:49.000000000 -0500
+@@ -64,90 +64,90 @@
+ #define AFFS_DATA(bh) (((struct affs_data_head *)(bh)->b_data)->data)
+
+ struct affs_date {
+- u32 days;
+- u32 mins;
+- u32 ticks;
++ __u32 days;
++ __u32 mins;
++ __u32 ticks;
+ };
+
+ struct affs_short_date {
+- u16 days;
+- u16 mins;
+- u16 ticks;
++ __u16 days;
++ __u16 mins;
++ __u16 ticks;
+ };
+
+ struct affs_root_head {
+- u32 ptype;
+- u32 spare1;
+- u32 spare2;
+- u32 hash_size;
+- u32 spare3;
+- u32 checksum;
+- u32 hashtable[1];
++ __u32 ptype;
++ __u32 spare1;
++ __u32 spare2;
++ __u32 hash_size;
++ __u32 spare3;
++ __u32 checksum;
++ __u32 hashtable[1];
+ };
+
+ struct affs_root_tail {
+- u32 bm_flag;
+- u32 bm_blk[AFFS_ROOT_BMAPS];
+- u32 bm_ext;
++ __u32 bm_flag;
++ __u32 bm_blk[AFFS_ROOT_BMAPS];
++ __u32 bm_ext;
+ struct affs_date root_change;
+- u8 disk_name[32];
+- u32 spare1;
+- u32 spare2;
++ __u8 disk_name[32];
++ __u32 spare1;
++ __u32 spare2;
+ struct affs_date disk_change;
+ struct affs_date disk_create;
+- u32 spare3;
+- u32 spare4;
+- u32 dcache;
+- u32 stype;
++ __u32 spare3;
++ __u32 spare4;
++ __u32 dcache;
++ __u32 stype;
+ };
+
+ struct affs_head {
+- u32 ptype;
+- u32 key;
+- u32 block_count;
+- u32 spare1;
+- u32 first_data;
+- u32 checksum;
+- u32 table[1];
++ __u32 ptype;
++ __u32 key;
++ __u32 block_count;
++ __u32 spare1;
++ __u32 first_data;
++ __u32 checksum;
++ __u32 table[1];
+ };
+
+ struct affs_tail {
+- u32 spare1;
+- u16 uid;
+- u16 gid;
+- u32 protect;
+- u32 size;
+- u8 comment[92];
++ __u32 spare1;
++ __u16 uid;
++ __u16 gid;
++ __u32 protect;
++ __u32 size;
++ __u8 comment[92];
+ struct affs_date change;
+- u8 name[32];
+- u32 spare2;
+- u32 original;
+- u32 link_chain;
+- u32 spare[5];
+- u32 hash_chain;
+- u32 parent;
+- u32 extension;
+- u32 stype;
++ __u8 name[32];
++ __u32 spare2;
++ __u32 original;
++ __u32 link_chain;
++ __u32 spare[5];
++ __u32 hash_chain;
++ __u32 parent;
++ __u32 extension;
++ __u32 stype;
+ };
+
+ struct slink_front
+ {
+- u32 ptype;
+- u32 key;
+- u32 spare1[3];
+- u32 checksum;
+- u8 symname[1]; /* depends on block size */
++ __u32 ptype;
++ __u32 key;
++ __u32 spare1[3];
++ __u32 checksum;
++ __u8 symname[1]; /* depends on block size */
+ };
+
+ struct affs_data_head
+ {
+- u32 ptype;
+- u32 key;
+- u32 sequence;
+- u32 size;
+- u32 next;
+- u32 checksum;
+- u8 data[1]; /* depends on block size */
++ __u32 ptype;
++ __u32 key;
++ __u32 sequence;
++ __u32 size;
++ __u32 next;
++ __u32 checksum;
++ __u8 data[1]; /* depends on block size */
+ };
+
+ /* Permission bits */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/ata.h linux-libc-headers-2.6.8.0/include/linux/ata.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/ata.h 2004-08-18 13:16:01.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/ata.h 2004-08-26 05:41:49.000000000 -0500
+@@ -34,7 +34,7 @@
+ ATA_MAX_PRD = 256, /* we could make these 256/256 */
+ ATA_SECT_SIZE = 512,
+ ATA_SECT_SIZE_MASK = (ATA_SECT_SIZE - 1),
+- ATA_SECT_DWORDS = ATA_SECT_SIZE / sizeof(u32),
++ ATA_SECT_DWORDS = ATA_SECT_SIZE / sizeof(__u32),
+
+ ATA_ID_WORDS = 256,
+ ATA_ID_PROD_OFS = 27,
+@@ -176,31 +176,31 @@
+ /* core structures */
+
+ struct ata_prd {
+- u32 addr;
+- u32 flags_len;
++ __u32 addr;
++ __u32 flags_len;
+ } __attribute__((packed));
+
+ struct ata_taskfile {
+ unsigned long flags; /* ATA_TFLAG_xxx */
+- u8 protocol; /* ATA_PROT_xxx */
++ __u8 protocol; /* ATA_PROT_xxx */
+
+- u8 ctl; /* control reg */
++ __u8 ctl; /* control reg */
+
+- u8 hob_feature; /* additional data */
+- u8 hob_nsect; /* to support LBA48 */
+- u8 hob_lbal;
+- u8 hob_lbam;
+- u8 hob_lbah;
++ __u8 hob_feature; /* additional data */
++ __u8 hob_nsect; /* to support LBA48 */
++ __u8 hob_lbal;
++ __u8 hob_lbam;
++ __u8 hob_lbah;
+
+- u8 feature;
+- u8 nsect;
+- u8 lbal;
+- u8 lbam;
+- u8 lbah;
++ __u8 feature;
++ __u8 nsect;
++ __u8 lbal;
++ __u8 lbam;
++ __u8 lbah;
+
+- u8 device;
++ __u8 device;
+
+- u8 command; /* IO operation */
++ __u8 command; /* IO operation */
+ };
+
+ #define ata_id_is_ata(dev) (((dev)->id[0] & (1 << 15)) == 0)
+@@ -213,12 +213,12 @@
+ #define ata_id_has_dma(dev) ((dev)->id[49] & (1 << 8))
+ #define ata_id_removeable(dev) ((dev)->id[0] & (1 << 7))
+ #define ata_id_u32(dev,n) \
+- (((u32) (dev)->id[(n) + 1] << 16) | ((u32) (dev)->id[(n)]))
++ (((__u32) (dev)->id[(n) + 1] << 16) | ((__u32) (dev)->id[(n)]))
+ #define ata_id_u64(dev,n) \
+- ( ((u64) dev->id[(n) + 3] << 48) | \
+- ((u64) dev->id[(n) + 2] << 32) | \
+- ((u64) dev->id[(n) + 1] << 16) | \
+- ((u64) dev->id[(n) + 0]) )
++ ( ((__u64) dev->id[(n) + 3] << 48) | \
++ ((__u64) dev->id[(n) + 2] << 32) | \
++ ((__u64) dev->id[(n) + 1] << 16) | \
++ ((__u64) dev->id[(n) + 0]) )
+
+ static inline int is_atapi_taskfile(struct ata_taskfile *tf)
+ {
+@@ -226,7 +226,7 @@
+ (tf->protocol == ATA_PROT_ATAPI_DMA);
+ }
+
+-static inline int ata_ok(u8 status)
++static inline int ata_ok(__u8 status)
+ {
+ return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
+ == ATA_DRDY);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/bitops.h linux-libc-headers-2.6.8.0/include/linux/bitops.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/bitops.h 2004-06-09 07:00:49.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/bitops.h 2004-08-26 05:41:49.000000000 -0500
+@@ -114,7 +114,7 @@
+ return generic_hweight32((unsigned int)(w >> 32)) +
+ generic_hweight32((unsigned int)w);
+ #else
+- u64 res;
++ __u64 res;
+ res = (w & 0x5555555555555555ul) + ((w >> 1) & 0x5555555555555555ul);
+ res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
+ res = (res & 0x0F0F0F0F0F0F0F0Ful) + ((res >> 4) & 0x0F0F0F0F0F0F0F0Ful);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/compat.h linux-libc-headers-2.6.8.0/include/linux/compat.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/compat.h 2004-06-09 07:00:49.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/compat.h 2004-08-26 05:41:49.000000000 -0500
+@@ -78,9 +78,9 @@
+ };
+
+ struct compat_dirent {
+- u32 d_ino;
++ __u32 d_ino;
+ compat_off_t d_off;
+- u16 d_reclen;
++ __u16 d_reclen;
+ char d_name[256];
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/console.h linux-libc-headers-2.6.8.0/include/linux/console.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/console.h 2004-08-18 13:16:02.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/console.h 2004-08-26 05:41:49.000000000 -0500
+@@ -49,9 +49,9 @@
+ int (*con_scrolldelta)(struct vc_data *, int);
+ int (*con_set_origin)(struct vc_data *);
+ void (*con_save_screen)(struct vc_data *);
+- u8 (*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8);
+- void (*con_invert_region)(struct vc_data *, u16 *, int);
+- u16 *(*con_screen_pos)(struct vc_data *, int);
++ __u8 (*con_build_attr)(struct vc_data *, __u8, __u8, __u8, __u8, __u8);
++ void (*con_invert_region)(struct vc_data *, __u16 *, int);
++ __u16 *(*con_screen_pos)(struct vc_data *, int);
+ unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/cpufreq.h linux-libc-headers-2.6.8.0/include/linux/cpufreq.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/cpufreq.h 2004-06-23 16:52:53.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/cpufreq.h 2004-08-26 05:41:49.000000000 -0500
+@@ -103,7 +103,7 @@
+ unsigned int cpu; /* cpu nr */
+ unsigned int old;
+ unsigned int new;
+- u8 flags; /* flags of cpufreq_driver, see below. */
++ __u8 flags; /* flags of cpufreq_driver, see below. */
+ };
+
+
+@@ -120,13 +120,13 @@
+ {
+ #if BITS_PER_LONG == 32
+
+- u64 result = ((u64) old) * ((u64) mult);
++ __u64 result = ((__u64) old) * ((__u64) mult);
+ do_div(result, div);
+ return (unsigned long) result;
+
+ #elif BITS_PER_LONG == 64
+
+- unsigned long result = old * ((u64) mult);
++ unsigned long result = old * ((__u64) mult);
+ result /= div;
+ return result;
+
+@@ -178,7 +178,7 @@
+ struct cpufreq_driver {
+ struct module *owner;
+ char name[CPUFREQ_NAME_LEN];
+- u8 flags;
++ __u8 flags;
+
+ /* needed by all drivers */
+ int (*init) (struct cpufreq_policy *policy);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/cramfs_fs.h linux-libc-headers-2.6.8.0/include/linux/cramfs_fs.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/cramfs_fs.h 2004-01-05 12:42:27.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/cramfs_fs.h 2004-08-26 05:41:49.000000000 -0500
+@@ -2,9 +2,9 @@
+ #define __CRAMFS_H
+
+
+-typedef unsigned char u8;
+-typedef unsigned short u16;
+-typedef unsigned int u32;
++typedef unsigned char __u8;
++typedef unsigned short __u16;
++typedef unsigned int __u32;
+
+
+ #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
+@@ -31,9 +31,9 @@
+ * Reasonably terse representation of the inode data.
+ */
+ struct cramfs_inode {
+- u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH;
++ __u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH;
+ /* SIZE for device files is i_rdev */
+- u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH;
++ __u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH;
+ /* NAMELEN is the length of the file name, divided by 4 and
+ rounded up. (cramfs doesn't support hard links.) */
+ /* OFFSET: For symlinks and non-empty regular files, this
+@@ -42,27 +42,27 @@
+ see README). For non-empty directories it is the offset
+ (divided by 4) of the inode of the first file in that
+ directory. For anything else, offset is zero. */
+- u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH;
++ __u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH;
+ };
+
+ struct cramfs_info {
+- u32 crc;
+- u32 edition;
+- u32 blocks;
+- u32 files;
++ __u32 crc;
++ __u32 edition;
++ __u32 blocks;
++ __u32 files;
+ };
+
+ /*
+ * Superblock information at the beginning of the FS.
+ */
+ struct cramfs_super {
+- u32 magic; /* 0x28cd3d45 - random number */
+- u32 size; /* length in bytes */
+- u32 flags; /* feature flags */
+- u32 future; /* reserved for future use */
+- u8 signature[16]; /* "Compressed ROMFS" */
++ __u32 magic; /* 0x28cd3d45 - random number */
++ __u32 size; /* length in bytes */
++ __u32 flags; /* feature flags */
++ __u32 future; /* reserved for future use */
++ __u8 signature[16]; /* "Compressed ROMFS" */
+ struct cramfs_info fsid; /* unique filesystem info */
+- u8 name[16]; /* user-defined name */
++ __u8 name[16]; /* user-defined name */
+ struct cramfs_inode root; /* root inode data */
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/crc32.h linux-libc-headers-2.6.8.0/include/linux/crc32.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/crc32.h 2003-12-15 12:46:57.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/crc32.h 2004-08-26 05:41:49.000000000 -0500
+@@ -7,9 +7,9 @@
+
+ #include <linux/types.h>
+
+-extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
+-extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len);
+-extern u32 bitreverse(u32 in);
++extern __u32 crc32_le(__u32 crc, unsigned char const *p, size_t len);
++extern __u32 crc32_be(__u32 crc, unsigned char const *p, size_t len);
++extern __u32 bitreverse(__u32 in);
+
+ #define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)data, length)
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/crypto.h linux-libc-headers-2.6.8.0/include/linux/crypto.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/crypto.h 2004-04-19 16:13:51.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/crypto.h 2004-08-26 05:41:49.000000000 -0500
+@@ -63,28 +63,28 @@
+ struct cipher_alg {
+ unsigned int cia_min_keysize;
+ unsigned int cia_max_keysize;
+- int (*cia_setkey)(void *ctx, const u8 *key,
+- unsigned int keylen, u32 *flags);
+- void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
+- void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
++ int (*cia_setkey)(void *ctx, const __u8 *key,
++ unsigned int keylen, __u32 *flags);
++ void (*cia_encrypt)(void *ctx, __u8 *dst, const __u8 *src);
++ void (*cia_decrypt)(void *ctx, __u8 *dst, const __u8 *src);
+ };
+
+ struct digest_alg {
+ unsigned int dia_digestsize;
+ void (*dia_init)(void *ctx);
+- void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
+- void (*dia_final)(void *ctx, u8 *out);
+- int (*dia_setkey)(void *ctx, const u8 *key,
+- unsigned int keylen, u32 *flags);
++ void (*dia_update)(void *ctx, const __u8 *data, unsigned int len);
++ void (*dia_final)(void *ctx, __u8 *out);
++ int (*dia_setkey)(void *ctx, const __u8 *key,
++ unsigned int keylen, __u32 *flags);
+ };
+
+ struct compress_alg {
+ int (*coa_init)(void *ctx);
+ void (*coa_exit)(void *ctx);
+- int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen);
+- int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen);
++ int (*coa_compress)(void *ctx, const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen);
++ int (*coa_decompress)(void *ctx, const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen);
+ };
+
+ #define cra_cipher cra_u.cipher
+@@ -93,7 +93,7 @@
+
+ struct crypto_alg {
+ struct list_head cra_list;
+- u32 cra_flags;
++ __u32 cra_flags;
+ unsigned int cra_blocksize;
+ unsigned int cra_ctxsize;
+ const char cra_name[CRYPTO_MAX_ALG_NAME];
+@@ -116,7 +116,7 @@
+ /*
+ * Algorithm query interface.
+ */
+-int crypto_alg_available(const char *name, u32 flags);
++int crypto_alg_available(const char *name, __u32 flags);
+
+ /*
+ * Transforms: user-instantiated objects which encapsulate algorithms
+@@ -128,9 +128,9 @@
+ struct cipher_tfm {
+ void *cit_iv;
+ unsigned int cit_ivsize;
+- u32 cit_mode;
++ __u32 cit_mode;
+ int (*cit_setkey)(struct crypto_tfm *tfm,
+- const u8 *key, unsigned int keylen);
++ const __u8 *key, unsigned int keylen);
+ int (*cit_encrypt)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+@@ -138,7 +138,7 @@
+ int (*cit_encrypt_iv)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+- unsigned int nbytes, u8 *iv);
++ unsigned int nbytes, __u8 *iv);
+ int (*cit_decrypt)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+@@ -146,19 +146,19 @@
+ int (*cit_decrypt_iv)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+- unsigned int nbytes, u8 *iv);
+- void (*cit_xor_block)(u8 *dst, const u8 *src);
++ unsigned int nbytes, __u8 *iv);
++ void (*cit_xor_block)(__u8 *dst, const __u8 *src);
+ };
+
+ struct digest_tfm {
+ void (*dit_init)(struct crypto_tfm *tfm);
+ void (*dit_update)(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg);
+- void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
++ void (*dit_final)(struct crypto_tfm *tfm, __u8 *out);
+ void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
+- unsigned int nsg, u8 *out);
++ unsigned int nsg, __u8 *out);
+ int (*dit_setkey)(struct crypto_tfm *tfm,
+- const u8 *key, unsigned int keylen);
++ const __u8 *key, unsigned int keylen);
+ #ifdef CONFIG_CRYPTO_HMAC
+ void *dit_hmac_block;
+ #endif
+@@ -166,11 +166,11 @@
+
+ struct compress_tfm {
+ int (*cot_compress)(struct crypto_tfm *tfm,
+- const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen);
++ const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen);
+ int (*cot_decompress)(struct crypto_tfm *tfm,
+- const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen);
++ const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen);
+ };
+
+ #define crt_cipher crt_u.cipher
+@@ -179,7 +179,7 @@
+
+ struct crypto_tfm {
+
+- u32 crt_flags;
++ __u32 crt_flags;
+
+ union {
+ struct cipher_tfm cipher;
+@@ -203,7 +203,7 @@
+ * crypto_free_tfm() frees up the transform and any associated resources,
+ * then drops the refcount on the associated algorithm.
+ */
+-struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
++struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, __u32 tfm_flags);
+ void crypto_free_tfm(struct crypto_tfm *tfm);
+
+ /*
+@@ -219,7 +219,7 @@
+ return module_name(tfm->__crt_alg->cra_module);
+ }
+
+-static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
++static inline __u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
+ {
+ return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
+ }
+@@ -270,7 +270,7 @@
+ tfm->crt_digest.dit_update(tfm, sg, nsg);
+ }
+
+-static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
++static inline void crypto_digest_final(struct crypto_tfm *tfm, __u8 *out)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_final(tfm, out);
+@@ -278,14 +278,14 @@
+
+ static inline void crypto_digest_digest(struct crypto_tfm *tfm,
+ struct scatterlist *sg,
+- unsigned int nsg, u8 *out)
++ unsigned int nsg, __u8 *out)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
+ }
+
+ static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
+- const u8 *key, unsigned int keylen)
++ const __u8 *key, unsigned int keylen)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ if (tfm->crt_digest.dit_setkey == NULL)
+@@ -294,7 +294,7 @@
+ }
+
+ static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
+- const u8 *key, unsigned int keylen)
++ const __u8 *key, unsigned int keylen)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
+@@ -312,7 +312,7 @@
+ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+- unsigned int nbytes, u8 *iv)
++ unsigned int nbytes, __u8 *iv)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
+@@ -331,7 +331,7 @@
+ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+- unsigned int nbytes, u8 *iv)
++ unsigned int nbytes, __u8 *iv)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
+@@ -339,30 +339,30 @@
+ }
+
+ static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
+- const u8 *src, unsigned int len)
++ const __u8 *src, unsigned int len)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ memcpy(tfm->crt_cipher.cit_iv, src, len);
+ }
+
+ static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
+- u8 *dst, unsigned int len)
++ __u8 *dst, unsigned int len)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ memcpy(dst, tfm->crt_cipher.cit_iv, len);
+ }
+
+ static inline int crypto_comp_compress(struct crypto_tfm *tfm,
+- const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen)
++ const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
+ return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen);
+ }
+
+ static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
+- const u8 *src, unsigned int slen,
+- u8 *dst, unsigned int *dlen)
++ const __u8 *src, unsigned int slen,
++ __u8 *dst, unsigned int *dlen)
+ {
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
+ return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen);
+@@ -372,13 +372,13 @@
+ * HMAC support.
+ */
+ #ifdef CONFIG_CRYPTO_HMAC
+-void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen);
++void crypto_hmac_init(struct crypto_tfm *tfm, __u8 *key, unsigned int *keylen);
+ void crypto_hmac_update(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg);
+-void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
+- unsigned int *keylen, u8 *out);
+-void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen,
+- struct scatterlist *sg, unsigned int nsg, u8 *out);
++void crypto_hmac_final(struct crypto_tfm *tfm, __u8 *key,
++ unsigned int *keylen, __u8 *out);
++void crypto_hmac(struct crypto_tfm *tfm, __u8 *key, unsigned int *keylen,
++ struct scatterlist *sg, unsigned int nsg, __u8 *out);
+ #endif /* CONFIG_CRYPTO_HMAC */
+
+ #endif /* _LINUX_CRYPTO_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/cycx_drv.h linux-libc-headers-2.6.8.0/include/linux/cycx_drv.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/cycx_drv.h 2003-12-15 12:46:57.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/cycx_drv.h 2004-08-26 05:41:49.000000000 -0500
+@@ -14,9 +14,9 @@
+ * ============================================================================
+ * 1999/10/23 acme cycxhw_t cleanup
+ * 1999/01/03 acme more judicious use of data types...
+-* uclong, ucchar, etc deleted, the u8, u16, u32
++* uclong, ucchar, etc deleted, the __u8, __u16, __u32
+ * types are the portable way to go.
+-* 1999/01/03 acme judicious use of data types... u16, u32, etc
++* 1999/01/03 acme judicious use of data types... __u16, __u32, etc
+ * 1998/12/26 acme FIXED_BUFFERS, CONF_OFFSET,
+ * removal of cy_read{bwl}
+ * 1998/08/08 acme Initial version.
+@@ -46,18 +46,18 @@
+ * @reserved - reserved for future use
+ */
+ struct cycx_hw {
+- u32 fwid;
++ __u32 fwid;
+ int irq;
+ void *dpmbase;
+- u32 dpmsize;
+- u32 reserved[5];
++ __u32 dpmsize;
++ __u32 reserved[5];
+ };
+
+ /* Function Prototypes */
+-extern int cycx_setup(struct cycx_hw *hw, void *sfm, u32 len);
++extern int cycx_setup(struct cycx_hw *hw, void *sfm, __u32 len);
+ extern int cycx_down(struct cycx_hw *hw);
+-extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
+-extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
++extern int cycx_peek(struct cycx_hw *hw, __u32 addr, void *buf, __u32 len);
++extern int cycx_poke(struct cycx_hw *hw, __u32 addr, void *buf, __u32 len);
+ extern int cycx_exec(void *addr);
+
+ extern void cycx_inten(struct cycx_hw *hw);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/cycx_x25.h linux-libc-headers-2.6.8.0/include/linux/cycx_x25.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/cycx_x25.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/cycx_x25.h 2004-08-26 05:41:49.000000000 -0500
+@@ -38,10 +38,10 @@
+ /* Data Structures */
+ /* X.25 Command Block. */
+ struct cycx_x25_cmd {
+- u16 command PACKED;
+- u16 link PACKED; /* values: 0 or 1 */
+- u16 len PACKED; /* values: 0 thru 0x205 (517) */
+- u32 buf PACKED;
++ __u16 command PACKED;
++ __u16 link PACKED; /* values: 0 or 1 */
++ __u16 len PACKED; /* values: 0 thru 0x205 (517) */
++ __u32 buf PACKED;
+ };
+
+ /* Defines for the 'command' field. */
+@@ -92,34 +92,34 @@
+ * @flags - see dosx25.doc, in portuguese, for details
+ */
+ struct cycx_x25_config {
+- u8 link PACKED;
+- u8 speed PACKED;
+- u8 clock PACKED;
+- u8 n2 PACKED;
+- u8 n2win PACKED;
+- u8 n3win PACKED;
+- u8 nvc PACKED;
+- u8 pktlen PACKED;
+- u8 locaddr PACKED;
+- u8 remaddr PACKED;
+- u16 t1 PACKED;
+- u16 t2 PACKED;
+- u8 t21 PACKED;
+- u8 npvc PACKED;
+- u8 t23 PACKED;
+- u8 flags PACKED;
++ __u8 link PACKED;
++ __u8 speed PACKED;
++ __u8 clock PACKED;
++ __u8 n2 PACKED;
++ __u8 n2win PACKED;
++ __u8 n3win PACKED;
++ __u8 nvc PACKED;
++ __u8 pktlen PACKED;
++ __u8 locaddr PACKED;
++ __u8 remaddr PACKED;
++ __u16 t1 PACKED;
++ __u16 t2 PACKED;
++ __u8 t21 PACKED;
++ __u8 npvc PACKED;
++ __u8 t23 PACKED;
++ __u8 flags PACKED;
+ };
+
+ struct cycx_x25_stats {
+- u16 rx_crc_errors PACKED;
+- u16 rx_over_errors PACKED;
+- u16 n2_tx_frames PACKED;
+- u16 n2_rx_frames PACKED;
+- u16 tx_timeouts PACKED;
+- u16 rx_timeouts PACKED;
+- u16 n3_tx_packets PACKED;
+- u16 n3_rx_packets PACKED;
+- u16 tx_aborts PACKED;
+- u16 rx_aborts PACKED;
++ __u16 rx_crc_errors PACKED;
++ __u16 rx_over_errors PACKED;
++ __u16 n2_tx_frames PACKED;
++ __u16 n2_rx_frames PACKED;
++ __u16 tx_timeouts PACKED;
++ __u16 rx_timeouts PACKED;
++ __u16 n3_tx_packets PACKED;
++ __u16 n3_rx_packets PACKED;
++ __u16 tx_aborts PACKED;
++ __u16 rx_aborts PACKED;
+ };
+ #endif /* _CYCX_X25_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/device.h linux-libc-headers-2.6.8.0/include/linux/device.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/device.h 2004-08-18 13:16:02.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/device.h 2004-08-26 05:41:49.000000000 -0500
+@@ -57,7 +57,7 @@
+ struct device * (*add) (struct device * parent, char * bus_id);
+ int (*hotplug) (struct device *dev, char **envp,
+ int num_envp, char *buffer, int buffer_size);
+- int (*suspend)(struct device * dev, u32 state);
++ int (*suspend)(struct device * dev, __u32 state);
+ int (*resume)(struct device * dev);
+ };
+
+@@ -105,8 +105,8 @@
+ int (*probe) (struct device * dev);
+ int (*remove) (struct device * dev);
+ void (*shutdown) (struct device * dev);
+- int (*suspend) (struct device * dev, u32 state, u32 level);
+- int (*resume) (struct device * dev, u32 level);
++ int (*suspend) (struct device * dev, __u32 state, __u32 level);
++ int (*resume) (struct device * dev, __u32 level);
+ };
+
+
+@@ -262,17 +262,17 @@
+ void *platform_data; /* Platform specific data (e.g. ACPI,
+ BIOS data relevant to device) */
+ struct dev_pm_info power;
+- u32 power_state; /* Current operating state. In
++ __u32 power_state; /* Current operating state. In
+ ACPI-speak, this is D0-D3, D0
+ being fully functional, and D3
+ being off. */
+
+ unsigned char *saved_state; /* saved device state */
+- u32 detach_state; /* State to enter when device is
++ __u32 detach_state; /* State to enter when device is
+ detached from its driver. */
+
+- u64 *dma_mask; /* dma mask (if dma'able device) */
+- u64 coherent_dma_mask;/* Like dma_mask, but for
++ __u64 *dma_mask; /* dma mask (if dma'able device) */
++ __u64 coherent_dma_mask;/* Like dma_mask, but for
+ alloc_coherent mappings as
+ not all hardware supports
+ 64 bit addresses for consistent
+@@ -360,9 +360,9 @@
+
+ struct platform_device {
+ char * name;
+- u32 id;
++ __u32 id;
+ struct device dev;
+- u32 num_resources;
++ __u32 num_resources;
+ struct resource * resource;
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/divert.h linux-libc-headers-2.6.8.0/include/linux/divert.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/divert.h 2004-06-09 07:00:49.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/divert.h 2004-08-26 05:41:49.000000000 -0500
+@@ -27,10 +27,10 @@
+ {
+ int divert; /* are we active */
+ unsigned int protos; /* protocols */
+- u16 tcp_dst[MAX_DIVERT_PORTS]; /* specific tcp dst ports to divert */
+- u16 tcp_src[MAX_DIVERT_PORTS]; /* specific tcp src ports to divert */
+- u16 udp_dst[MAX_DIVERT_PORTS]; /* specific udp dst ports to divert */
+- u16 udp_src[MAX_DIVERT_PORTS]; /* specific udp src ports to divert */
++ __u16 tcp_dst[MAX_DIVERT_PORTS]; /* specific tcp dst ports to divert */
++ __u16 tcp_src[MAX_DIVERT_PORTS]; /* specific tcp src ports to divert */
++ __u16 udp_dst[MAX_DIVERT_PORTS]; /* specific udp dst ports to divert */
++ __u16 udp_src[MAX_DIVERT_PORTS]; /* specific udp src ports to divert */
+ };
+
+ /*
+@@ -40,12 +40,12 @@
+
+ typedef union _divert_cf_arg
+ {
+- s16 int16;
+- u16 uint16;
+- s32 int32;
+- u32 uint32;
+- s64 int64;
+- u64 uint64;
++ __s16 int16;
++ __u16 uint16;
++ __s32 int32;
++ __u32 uint32;
++ __s64 int64;
++ __u64 uint64;
+ void *ptr;
+ } divert_cf_arg;
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/eeprom.h linux-libc-headers-2.6.8.0/include/linux/eeprom.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/eeprom.h 2003-12-19 07:05:15.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/eeprom.h 2004-08-26 13:26:38.000000000 -0500
+@@ -26,15 +26,15 @@
+ unsigned ee_state;
+
+ spinlock_t *lock;
+- u32 *cache;
++ __u32 *cache;
+ };
+
+
+-u8 eeprom_readb(struct eeprom *ee, unsigned address);
+-void eeprom_read(struct eeprom *ee, unsigned address, u8 *bytes,
++__u8 eeprom_readb(struct eeprom *ee, unsigned address);
++void eeprom_read(struct eeprom *ee, unsigned address, __u8 *bytes,
+ unsigned count);
+-void eeprom_writeb(struct eeprom *ee, unsigned address, u8 data);
+-void eeprom_write(struct eeprom *ee, unsigned address, u8 *bytes,
++void eeprom_writeb(struct eeprom *ee, unsigned address, __u8 data);
++void eeprom_write(struct eeprom *ee, unsigned address, __u8 *bytes,
+ unsigned count);
+
+ /* The EEPROM commands include the alway-set leading bit. */
+@@ -56,10 +56,10 @@
+ }
+
+ /* foo. put this in a .c file */
+-static inline void eeprom_update(struct eeprom *ee, u32 mask, int pol)
++static inline void eeprom_update(struct eeprom *ee, __u32 mask, int pol)
+ {
+ unsigned long flags;
+- u32 data;
++ __u32 data;
+
+ spin_lock_irqsave(ee->lock, flags);
+ data = *ee->cache;
+@@ -106,17 +106,17 @@
+ eeprom_update(ee, ee->eedi, pol);
+ }
+
+-u16 eeprom_readw(struct eeprom *ee, unsigned address)
++__u16 eeprom_readw(struct eeprom *ee, unsigned address)
+ {
+ unsigned i;
+- u16 res = 0;
++ __u16 res = 0;
+
+ eeprom_clk_lo(ee);
+ eeprom_update(ee, ee->eesel, 1 ^ !!(ee->polarity & EEPOL_EESEL));
+ eeprom_send_addr(ee, address);
+
+ for (i=0; i<16; i++) {
+- u32 data;
++ __u32 data;
+ eeprom_clk_hi(ee);
+ res <<= 1;
+ data = readl(ee->addr);
+@@ -130,6 +130,6 @@
+ }
+
+
+-void eeprom_writeb(struct eeprom *ee, unsigned address, u8 data)
++void eeprom_writeb(struct eeprom *ee, unsigned address, __u8 data)
+ {
+ }
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/efi.h linux-libc-headers-2.6.8.0/include/linux/efi.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/efi.h 2004-08-18 13:16:02.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/efi.h 2004-08-26 05:42:08.000000000 -0500
+@@ -30,12 +30,12 @@
+ #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1)))
+
+ typedef unsigned long efi_status_t;
+-typedef u8 efi_bool_t;
+-typedef u16 efi_char16_t; /* UNICODE character */
++typedef __u8 efi_bool_t;
++typedef __u16 efi_char16_t; /* UNICODE character */
+
+
+ typedef struct {
+- u8 b[16];
++ __u8 b[16];
+ } efi_guid_t;
+
+ #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
+@@ -49,11 +49,11 @@
+ * Generic EFI table header
+ */
+ typedef struct {
+- u64 signature;
+- u32 revision;
+- u32 headersize;
+- u32 crc32;
+- u32 reserved;
++ __u64 signature;
++ __u32 revision;
++ __u32 headersize;
++ __u32 crc32;
++ __u32 reserved;
+ } efi_table_hdr_t;
+
+ /*
+@@ -78,14 +78,14 @@
+ #define EFI_MAX_MEMORY_TYPE 14
+
+ /* Attribute values: */
+-#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
+-#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
+-#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
+-#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
+-#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
+-#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
+-#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
+-#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
++#define EFI_MEMORY_UC ((__u64)0x0000000000000001ULL) /* uncached */
++#define EFI_MEMORY_WC ((__u64)0x0000000000000002ULL) /* write-coalescing */
++#define EFI_MEMORY_WT ((__u64)0x0000000000000004ULL) /* write-through */
++#define EFI_MEMORY_WB ((__u64)0x0000000000000008ULL) /* write-back */
++#define EFI_MEMORY_WP ((__u64)0x0000000000001000ULL) /* write-protect */
++#define EFI_MEMORY_RP ((__u64)0x0000000000002000ULL) /* read-protect */
++#define EFI_MEMORY_XP ((__u64)0x0000000000004000ULL) /* execute-protect */
++#define EFI_MEMORY_RUNTIME ((__u64)0x8000000000000000ULL) /* range requires runtime mapping */
+ #define EFI_MEMORY_DESCRIPTOR_VERSION 1
+
+ #define EFI_PAGE_SHIFT 12
+@@ -96,14 +96,14 @@
+ * the case in ia64. Need to have this fixed in the f/w.
+ */
+ typedef struct {
+- u32 type;
+- u32 pad;
+- u64 phys_addr;
+- u64 virt_addr;
+- u64 num_pages;
+- u64 attribute;
++ __u32 type;
++ __u32 pad;
++ __u64 phys_addr;
++ __u64 virt_addr;
++ __u64 num_pages;
++ __u64 attribute;
+ #if defined (__i386__)
+- u64 pad1;
++ __u64 pad1;
+ #endif
+ } efi_memory_desc_t;
+
+@@ -117,23 +117,23 @@
+ #define EFI_UNSPECIFIED_TIMEZONE 0x07ff
+
+ typedef struct {
+- u16 year;
+- u8 month;
+- u8 day;
+- u8 hour;
+- u8 minute;
+- u8 second;
+- u8 pad1;
+- u32 nanosecond;
+- s16 timezone;
+- u8 daylight;
+- u8 pad2;
++ __u16 year;
++ __u8 month;
++ __u8 day;
++ __u8 hour;
++ __u8 minute;
++ __u8 second;
++ __u8 pad1;
++ __u32 nanosecond;
++ __s16 timezone;
++ __u8 daylight;
++ __u8 pad2;
+ } efi_time_t;
+
+ typedef struct {
+- u32 resolution;
+- u32 accuracy;
+- u8 sets_to_zero;
++ __u32 resolution;
++ __u32 accuracy;
++ __u8 sets_to_zero;
+ } efi_time_cap_t;
+
+ /*
+@@ -146,7 +146,7 @@
+ /*
+ * EFI Runtime Services table
+ */
+-#define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL)
++#define EFI_RUNTIME_SERVICES_SIGNATURE ((__u64)0x5652453544e5552ULL)
+ #define EFI_RUNTIME_SERVICES_REVISION 0x00010000
+
+ typedef struct {
+@@ -169,19 +169,19 @@
+ typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
+ efi_time_t *tm);
+ typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
+-typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
++typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, __u32 *attr,
+ unsigned long *data_size, void *data);
+ typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
+ efi_guid_t *vendor);
+ typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
+ unsigned long attr, unsigned long data_size,
+ void *data);
+-typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
++typedef efi_status_t efi_get_next_high_mono_count_t (__u32 *count);
+ typedef void efi_reset_system_t (int reset_type, efi_status_t status,
+ unsigned long data_size, efi_char16_t *data);
+ typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
+ unsigned long descriptor_size,
+- u32 descriptor_version,
++ __u32 descriptor_version,
+ efi_memory_desc_t *virtual_map);
+
+ /*
+@@ -219,13 +219,13 @@
+ unsigned long table;
+ } efi_config_table_t;
+
+-#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
++#define EFI_SYSTEM_TABLE_SIGNATURE ((__u64)0x5453595320494249ULL)
+ #define EFI_SYSTEM_TABLE_REVISION ((1 << 16) | 00)
+
+ typedef struct {
+ efi_table_hdr_t hdr;
+ unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */
+- u32 fw_revision;
++ __u32 fw_revision;
+ unsigned long con_in_handle;
+ unsigned long con_in;
+ unsigned long con_out_handle;
+@@ -293,9 +293,9 @@
+ extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
+ extern void efi_gettimeofday (struct timespec *ts);
+ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
+-extern u64 efi_get_iobase (void);
+-extern u32 efi_mem_type (unsigned long phys_addr);
+-extern u64 efi_mem_attributes (unsigned long phys_addr);
++extern __u64 efi_get_iobase (void);
++extern __u32 efi_mem_type (unsigned long phys_addr);
++extern __u64 efi_mem_attributes (unsigned long phys_addr);
+ extern int __init efi_uart_console_only (void);
+ extern void efi_initialize_iomem_resources(struct resource *code_resource,
+ struct resource *data_resource);
+@@ -368,9 +368,9 @@
+ #define EFI_DEV_END_ENTIRE 0xFF
+
+ struct efi_generic_dev_path {
+- u8 type;
+- u8 sub_type;
+- u16 length;
++ __u8 type;
++ __u8 sub_type;
++ __u16 length;
+ } __attribute ((packed));
+
+ #endif /* _LINUX_EFI_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/eisa.h linux-libc-headers-2.6.8.0/include/linux/eisa.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/eisa.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/eisa.h 2004-08-26 05:42:08.000000000 -0500
+@@ -43,7 +43,7 @@
+ int state;
+ unsigned long base_addr;
+ struct resource res[EISA_MAX_RESOURCES];
+- u64 dma_mask;
++ __u64 dma_mask;
+ struct device dev; /* generic device */
+ #ifdef CONFIG_EISA_NAMES
+ char pretty_name[DEVICE_NAME_SIZE];
+@@ -91,7 +91,7 @@
+ unsigned long bus_base_addr;
+ int slots; /* Max slot number */
+ int force_probe; /* Probe even when no slot 0 */
+- u64 dma_mask; /* from bridge device */
++ __u64 dma_mask; /* from bridge device */
+ int bus_nr; /* Set by eisa_root_register */
+ struct resource eisa_root_res; /* ditto */
+ };
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/ethtool.h linux-libc-headers-2.6.8.0/include/linux/ethtool.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/ethtool.h 2004-06-23 16:52:54.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/ethtool.h 2004-08-26 13:29:11.000000000 -0500
+@@ -15,24 +15,24 @@
+
+ /* This should work for both 32 and 64 bit userland. */
+ struct ethtool_cmd {
+- u32 cmd;
+- u32 supported; /* Features this interface supports */
+- u32 advertising; /* Features this interface advertises */
+- u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */
+- u8 duplex; /* Duplex, half or full */
+- u8 port; /* Which connector port */
+- u8 phy_address;
+- u8 transceiver; /* Which transceiver to use */
+- u8 autoneg; /* Enable or disable autonegotiation */
+- u32 maxtxpkt; /* Tx pkts before generating tx int */
+- u32 maxrxpkt; /* Rx pkts before generating rx int */
+- u32 reserved[4];
++ __u32 cmd;
++ __u32 supported; /* Features this interface supports */
++ __u32 advertising; /* Features this interface advertises */
++ __u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */
++ __u8 duplex; /* Duplex, half or full */
++ __u8 port; /* Which connector port */
++ __u8 phy_address;
++ __u8 transceiver; /* Which transceiver to use */
++ __u8 autoneg; /* Enable or disable autonegotiation */
++ __u32 maxtxpkt; /* Tx pkts before generating tx int */
++ __u32 maxrxpkt; /* Rx pkts before generating rx int */
++ __u32 reserved[4];
+ };
+
+ #define ETHTOOL_BUSINFO_LEN 32
+ /* these strings are set to whatever the driver author decides... */
+ struct ethtool_drvinfo {
+- u32 cmd;
++ __u32 cmd;
+ char driver[32]; /* driver short name, "tulip", "eepro100" */
+ char version[32]; /* driver version string */
+ char fw_version[32]; /* firmware version string, if applicable */
+@@ -40,53 +40,53 @@
+ /* For PCI devices, use pci_name(pci_dev). */
+ char reserved1[32];
+ char reserved2[16];
+- u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
+- u32 testinfo_len;
+- u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
+- u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
++ __u32 n_stats; /* number of __u64's from ETHTOOL_GSTATS */
++ __u32 testinfo_len;
++ __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
++ __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
+ };
+
+ #define SOPASS_MAX 6
+ /* wake-on-lan settings */
+ struct ethtool_wolinfo {
+- u32 cmd;
+- u32 supported;
+- u32 wolopts;
+- u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
++ __u32 cmd;
++ __u32 supported;
++ __u32 wolopts;
++ __u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
+ };
+
+ /* for passing single values */
+ struct ethtool_value {
+- u32 cmd;
+- u32 data;
++ __u32 cmd;
++ __u32 data;
+ };
+
+ /* for passing big chunks of data */
+ struct ethtool_regs {
+- u32 cmd;
+- u32 version; /* driver-specific, indicates different chips/revs */
+- u32 len; /* bytes */
+- u8 data[0];
++ __u32 cmd;
++ __u32 version; /* driver-specific, indicates different chips/revs */
++ __u32 len; /* bytes */
++ __u8 data[0];
+ };
+
+ /* for passing EEPROM chunks */
+ struct ethtool_eeprom {
+- u32 cmd;
+- u32 magic;
+- u32 offset; /* in bytes */
+- u32 len; /* in bytes */
+- u8 data[0];
++ __u32 cmd;
++ __u32 magic;
++ __u32 offset; /* in bytes */
++ __u32 len; /* in bytes */
++ __u8 data[0];
+ };
+
+ /* for configuring coalescing parameters of chip */
+ struct ethtool_coalesce {
+- u32 cmd; /* ETHTOOL_{G,S}COALESCE */
++ __u32 cmd; /* ETHTOOL_{G,S}COALESCE */
+
+ /* How many usecs to delay an RX interrupt after
+ * a packet arrives. If 0, only rx_max_coalesced_frames
+ * is used.
+ */
+- u32 rx_coalesce_usecs;
++ __u32 rx_coalesce_usecs;
+
+ /* How many packets to delay an RX interrupt after
+ * a packet arrives. If 0, only rx_coalesce_usecs is
+@@ -94,21 +94,21 @@
+ * to zero as this would cause RX interrupts to never be
+ * generated.
+ */
+- u32 rx_max_coalesced_frames;
++ __u32 rx_max_coalesced_frames;
+
+ /* Same as above two parameters, except that these values
+ * apply while an IRQ is being serviced by the host. Not
+ * all cards support this feature and the values are ignored
+ * in that case.
+ */
+- u32 rx_coalesce_usecs_irq;
+- u32 rx_max_coalesced_frames_irq;
++ __u32 rx_coalesce_usecs_irq;
++ __u32 rx_max_coalesced_frames_irq;
+
+ /* How many usecs to delay a TX interrupt after
+ * a packet is sent. If 0, only tx_max_coalesced_frames
+ * is used.
+ */
+- u32 tx_coalesce_usecs;
++ __u32 tx_coalesce_usecs;
+
+ /* How many packets to delay a TX interrupt after
+ * a packet is sent. If 0, only tx_coalesce_usecs is
+@@ -116,22 +116,22 @@
+ * to zero as this would cause TX interrupts to never be
+ * generated.
+ */
+- u32 tx_max_coalesced_frames;
++ __u32 tx_max_coalesced_frames;
+
+ /* Same as above two parameters, except that these values
+ * apply while an IRQ is being serviced by the host. Not
+ * all cards support this feature and the values are ignored
+ * in that case.
+ */
+- u32 tx_coalesce_usecs_irq;
+- u32 tx_max_coalesced_frames_irq;
++ __u32 tx_coalesce_usecs_irq;
++ __u32 tx_max_coalesced_frames_irq;
+
+ /* How many usecs to delay in-memory statistics
+ * block updates. Some drivers do not have an in-memory
+ * statistic block, and in such cases this value is ignored.
+ * This value must not be zero.
+ */
+- u32 stats_block_coalesce_usecs;
++ __u32 stats_block_coalesce_usecs;
+
+ /* Adaptive RX/TX coalescing is an algorithm implemented by
+ * some drivers to improve latency under low packet rates and
+@@ -140,18 +140,18 @@
+ * not implemented by the driver causes these values to be
+ * silently ignored.
+ */
+- u32 use_adaptive_rx_coalesce;
+- u32 use_adaptive_tx_coalesce;
++ __u32 use_adaptive_rx_coalesce;
++ __u32 use_adaptive_tx_coalesce;
+
+ /* When the packet rate (measured in packets per second)
+ * is below pkt_rate_low, the {rx,tx}_*_low parameters are
+ * used.
+ */
+- u32 pkt_rate_low;
+- u32 rx_coalesce_usecs_low;
+- u32 rx_max_coalesced_frames_low;
+- u32 tx_coalesce_usecs_low;
+- u32 tx_max_coalesced_frames_low;
++ __u32 pkt_rate_low;
++ __u32 rx_coalesce_usecs_low;
++ __u32 rx_max_coalesced_frames_low;
++ __u32 tx_coalesce_usecs_low;
++ __u32 tx_max_coalesced_frames_low;
+
+ /* When the packet rate is below pkt_rate_high but above
+ * pkt_rate_low (both measured in packets per second) the
+@@ -162,43 +162,43 @@
+ * is above pkt_rate_high, the {rx,tx}_*_high parameters are
+ * used.
+ */
+- u32 pkt_rate_high;
+- u32 rx_coalesce_usecs_high;
+- u32 rx_max_coalesced_frames_high;
+- u32 tx_coalesce_usecs_high;
+- u32 tx_max_coalesced_frames_high;
++ __u32 pkt_rate_high;
++ __u32 rx_coalesce_usecs_high;
++ __u32 rx_max_coalesced_frames_high;
++ __u32 tx_coalesce_usecs_high;
++ __u32 tx_max_coalesced_frames_high;
+
+ /* How often to do adaptive coalescing packet rate sampling,
+ * measured in seconds. Must not be zero.
+ */
+- u32 rate_sample_interval;
++ __u32 rate_sample_interval;
+ };
+
+ /* for configuring RX/TX ring parameters */
+ struct ethtool_ringparam {
+- u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
++ __u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
+
+ /* Read only attributes. These indicate the maximum number
+ * of pending RX/TX ring entries the driver will allow the
+ * user to set.
+ */
+- u32 rx_max_pending;
+- u32 rx_mini_max_pending;
+- u32 rx_jumbo_max_pending;
+- u32 tx_max_pending;
++ __u32 rx_max_pending;
++ __u32 rx_mini_max_pending;
++ __u32 rx_jumbo_max_pending;
++ __u32 tx_max_pending;
+
+ /* Values changeable by the user. The valid values are
+ * in the range 1 to the "*_max_pending" counterpart above.
+ */
+- u32 rx_pending;
+- u32 rx_mini_pending;
+- u32 rx_jumbo_pending;
+- u32 tx_pending;
++ __u32 rx_pending;
++ __u32 rx_mini_pending;
++ __u32 rx_jumbo_pending;
++ __u32 tx_pending;
+ };
+
+ /* for configuring link flow control parameters */
+ struct ethtool_pauseparam {
+- u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
++ __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
+
+ /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
+ * being true) the user may set 'autonet' here non-zero to have the
+@@ -210,9 +210,9 @@
+ * then {rx,tx}_pause force the driver to use/not-use pause
+ * flow control.
+ */
+- u32 autoneg;
+- u32 rx_pause;
+- u32 tx_pause;
++ __u32 autoneg;
++ __u32 rx_pause;
++ __u32 tx_pause;
+ };
+
+ #define ETH_GSTRING_LEN 32
+@@ -223,10 +223,10 @@
+
+ /* for passing string sets for data tagging */
+ struct ethtool_gstrings {
+- u32 cmd; /* ETHTOOL_GSTRINGS */
+- u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
+- u32 len; /* number of strings in the string set */
+- u8 data[0];
++ __u32 cmd; /* ETHTOOL_GSTRINGS */
++ __u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
++ __u32 len; /* number of strings in the string set */
++ __u8 data[0];
+ };
+
+ enum ethtool_test_flags {
+@@ -236,30 +236,30 @@
+
+ /* for requesting NIC test and getting results*/
+ struct ethtool_test {
+- u32 cmd; /* ETHTOOL_TEST */
+- u32 flags; /* ETH_TEST_FL_xxx */
+- u32 reserved;
+- u32 len; /* result length, in number of u64 elements */
+- u64 data[0];
++ __u32 cmd; /* ETHTOOL_TEST */
++ __u32 flags; /* ETH_TEST_FL_xxx */
++ __u32 reserved;
++ __u32 len; /* result length, in number of __u64 elements */
++ __u64 data[0];
+ };
+
+ /* for dumping NIC-specific statistics */
+ struct ethtool_stats {
+- u32 cmd; /* ETHTOOL_GSTATS */
+- u32 n_stats; /* number of u64's being returned */
+- u64 data[0];
++ __u32 cmd; /* ETHTOOL_GSTATS */
++ __u32 n_stats; /* number of __u64's being returned */
++ __u64 data[0];
+ };
+
+ struct net_device;
+
+ /* Some generic methods drivers may use in their ethtool_ops */
+-u32 ethtool_op_get_link(struct net_device *dev);
+-u32 ethtool_op_get_tx_csum(struct net_device *dev);
+-int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
+-u32 ethtool_op_get_sg(struct net_device *dev);
+-int ethtool_op_set_sg(struct net_device *dev, u32 data);
+-u32 ethtool_op_get_tso(struct net_device *dev);
+-int ethtool_op_set_tso(struct net_device *dev, u32 data);
++__u32 ethtool_op_get_link(struct net_device *dev);
++__u32 ethtool_op_get_tx_csum(struct net_device *dev);
++int ethtool_op_set_tx_csum(struct net_device *dev, __u32 data);
++__u32 ethtool_op_get_sg(struct net_device *dev);
++int ethtool_op_set_sg(struct net_device *dev, __u32 data);
++__u32 ethtool_op_get_tso(struct net_device *dev);
++int ethtool_op_set_tso(struct net_device *dev, __u32 data);
+
+ /**
+ * &ethtool_ops - Alter and report network device settings
+@@ -324,33 +324,33 @@
+ void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
+ void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
+ int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
+- u32 (*get_msglevel)(struct net_device *);
+- void (*set_msglevel)(struct net_device *, u32);
++ __u32 (*get_msglevel)(struct net_device *);
++ void (*set_msglevel)(struct net_device *, __u32);
+ int (*nway_reset)(struct net_device *);
+- u32 (*get_link)(struct net_device *);
++ __u32 (*get_link)(struct net_device *);
+ int (*get_eeprom_len)(struct net_device *);
+- int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
+- int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
++ int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, __u8 *);
++ int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, __u8 *);
+ int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
+ int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
+ void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
+ int (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
+ void (*get_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
+ int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam*);
+- u32 (*get_rx_csum)(struct net_device *);
+- int (*set_rx_csum)(struct net_device *, u32);
+- u32 (*get_tx_csum)(struct net_device *);
+- int (*set_tx_csum)(struct net_device *, u32);
+- u32 (*get_sg)(struct net_device *);
+- int (*set_sg)(struct net_device *, u32);
+- u32 (*get_tso)(struct net_device *);
+- int (*set_tso)(struct net_device *, u32);
++ __u32 (*get_rx_csum)(struct net_device *);
++ int (*set_rx_csum)(struct net_device *, __u32);
++ __u32 (*get_tx_csum)(struct net_device *);
++ int (*set_tx_csum)(struct net_device *, __u32);
++ __u32 (*get_sg)(struct net_device *);
++ int (*set_sg)(struct net_device *, __u32);
++ __u32 (*get_tso)(struct net_device *);
++ int (*set_tso)(struct net_device *, __u32);
+ int (*self_test_count)(struct net_device *);
+- void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
+- void (*get_strings)(struct net_device *, u32 stringset, u8 *);
+- int (*phys_id)(struct net_device *, u32);
++ void (*self_test)(struct net_device *, struct ethtool_test *, __u64 *);
++ void (*get_strings)(struct net_device *, __u32 stringset, __u8 *);
++ int (*phys_id)(struct net_device *, __u32);
+ int (*get_stats_count)(struct net_device *);
+- void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *);
++ void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, __u64 *);
+ int (*begin)(struct net_device *);
+ void (*complete)(struct net_device *);
+ };
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/firmware.h linux-libc-headers-2.6.8.0/include/linux/firmware.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/firmware.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/firmware.h 2004-08-26 05:42:08.000000000 -0500
+@@ -5,7 +5,7 @@
+ #define FIRMWARE_NAME_MAX 30
+ struct firmware {
+ size_t size;
+- u8 *data;
++ __u8 *data;
+ };
+ int request_firmware(const struct firmware **fw, const char *name,
+ struct device *device);
+@@ -15,5 +15,5 @@
+ void (*cont)(const struct firmware *fw, void *context));
+
+ void release_firmware(const struct firmware *fw);
+-void register_firmware(const char *name, const u8 *data, size_t size);
++void register_firmware(const char *name, const __u8 *data, size_t size);
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/fs.h linux-libc-headers-2.6.8.0/include/linux/fs.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/fs.h 2004-08-18 13:16:02.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/fs.h 2004-08-26 05:42:08.000000000 -0500
+@@ -198,7 +198,7 @@
+ /* A jump here: 108-111 have been used for various private purposes. */
+ #define BLKBSZGET _IOR(0x12,112,size_t)
+ #define BLKBSZSET _IOW(0x12,113,size_t)
+-#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
++#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (__u64 *arg) */
+
+ #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
+ #define FIBMAP _IO(0x00,1) /* bmap access */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/i2c.h linux-libc-headers-2.6.8.0/include/linux/i2c.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/i2c.h 2004-06-23 16:52:54.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/i2c.h 2004-08-26 05:42:08.000000000 -0500
+@@ -70,36 +70,36 @@
+ and probably just as fast.
+ Note that we use i2c_adapter here, because you do not need a specific
+ smbus adapter to call this function. */
+-extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
++extern __s32 i2c_smbus_xfer (struct i2c_adapter * adapter, __u16 addr,
+ unsigned short flags,
+- char read_write, u8 command, int size,
++ char read_write, __u8 command, int size,
+ union i2c_smbus_data * data);
+
+ /* Now follow the 'nice' access routines. These also document the calling
+ conventions of smbus_access. */
+
+-extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
+-extern s32 i2c_smbus_read_byte(struct i2c_client * client);
+-extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
+-extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
+-extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
+- u8 command, u8 value);
+-extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
+-extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
+- u8 command, u16 value);
+-extern s32 i2c_smbus_process_call(struct i2c_client * client,
+- u8 command, u16 value);
++extern __s32 i2c_smbus_write_quick(struct i2c_client * client, __u8 value);
++extern __s32 i2c_smbus_read_byte(struct i2c_client * client);
++extern __s32 i2c_smbus_write_byte(struct i2c_client * client, __u8 value);
++extern __s32 i2c_smbus_read_byte_data(struct i2c_client * client, __u8 command);
++extern __s32 i2c_smbus_write_byte_data(struct i2c_client * client,
++ __u8 command, __u8 value);
++extern __s32 i2c_smbus_read_word_data(struct i2c_client * client, __u8 command);
++extern __s32 i2c_smbus_write_word_data(struct i2c_client * client,
++ __u8 command, __u16 value);
++extern __s32 i2c_smbus_process_call(struct i2c_client * client,
++ __u8 command, __u16 value);
+ /* Returns the number of read bytes */
+-extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
+- u8 command, u8 *values);
+-extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
+- u8 command, u8 length,
+- u8 *values);
+-extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
+- u8 command, u8 *values);
+-extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
+- u8 command, u8 length,
+- u8 *values);
++extern __s32 i2c_smbus_read_block_data(struct i2c_client * client,
++ __u8 command, __u8 *values);
++extern __s32 i2c_smbus_write_block_data(struct i2c_client * client,
++ __u8 command, __u8 length,
++ __u8 *values);
++extern __s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
++ __u8 command, __u8 *values);
++extern __s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
++ __u8 command, __u8 length,
++ __u8 *values);
+
+
+ /*
+@@ -203,9 +203,9 @@
+ using common I2C messages */
+ int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg msgs[],
+ int num);
+- int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
++ int (*smbus_xfer) (struct i2c_adapter *adap, __u16 addr,
+ unsigned short flags, char read_write,
+- u8 command, int size, union i2c_smbus_data * data);
++ __u8 command, int size, union i2c_smbus_data * data);
+
+ /* --- these optional/future use for some adapter types.*/
+ int (*slave_send)(struct i2c_adapter *,char*,int);
+@@ -215,7 +215,7 @@
+ int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
+
+ /* To determine what the adapter supports */
+- u32 (*functionality) (struct i2c_adapter *);
++ __u32 (*functionality) (struct i2c_adapter *);
+ };
+
+ /*
+@@ -381,10 +381,10 @@
+
+
+ /* Return the functionality mask */
+-extern u32 i2c_get_functionality (struct i2c_adapter *adap);
++extern __u32 i2c_get_functionality (struct i2c_adapter *adap);
+
+ /* Return 1 if adapter supports everything we need, 0 if not. */
+-extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func);
++extern int i2c_check_functionality (struct i2c_adapter *adap, __u32 func);
+
+ /*
+ * I2C Message - used for pure i2c transaction, also from /dev interface
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/i2o-dev.h linux-libc-headers-2.6.8.0/include/linux/i2o-dev.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/i2o-dev.h 2004-06-23 16:52:54.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/i2o-dev.h 2004-08-26 05:42:08.000000000 -0500
+@@ -29,7 +29,7 @@
+ * I2O Control IOCTLs and structures
+ */
+ #define I2O_MAGIC_NUMBER 'i'
+-#define I2OGETIOPS _IOR(I2O_MAGIC_NUMBER,0,u8[MAX_I2O_CONTROLLERS])
++#define I2OGETIOPS _IOR(I2O_MAGIC_NUMBER,0,__u8[MAX_I2O_CONTROLLERS])
+ #define I2OHRTGET _IOWR(I2O_MAGIC_NUMBER,1,struct i2o_cmd_hrtlct)
+ #define I2OLCTGET _IOWR(I2O_MAGIC_NUMBER,2,struct i2o_cmd_hrtlct)
+ #define I2OPARMSET _IOWR(I2O_MAGIC_NUMBER,3,struct i2o_cmd_psetget)
+@@ -37,7 +37,7 @@
+ #define I2OSWDL _IOWR(I2O_MAGIC_NUMBER,5,struct i2o_sw_xfer)
+ #define I2OSWUL _IOWR(I2O_MAGIC_NUMBER,6,struct i2o_sw_xfer)
+ #define I2OSWDEL _IOWR(I2O_MAGIC_NUMBER,7,struct i2o_sw_xfer)
+-#define I2OVALIDATE _IOR(I2O_MAGIC_NUMBER,8,u32)
++#define I2OVALIDATE _IOR(I2O_MAGIC_NUMBER,8,__u32)
+ #define I2OHTML _IOWR(I2O_MAGIC_NUMBER,9,struct i2o_html)
+ #define I2OEVTREG _IOW(I2O_MAGIC_NUMBER,10,struct i2o_evt_id)
+ #define I2OEVTGET _IOR(I2O_MAGIC_NUMBER,11,struct i2o_evt_info)
+@@ -129,65 +129,65 @@
+ #define I2O_BUS_CARDBUS 7
+ #define I2O_BUS_UNKNOWN 0x80
+
+-typedef unsigned char u8;
+-typedef unsigned short u16;
+-typedef unsigned int u32;
++typedef unsigned char __u8;
++typedef unsigned short __u16;
++typedef unsigned int __u32;
+
+ typedef struct _i2o_pci_bus
+ {
+- u8 PciFunctionNumber;
+- u8 PciDeviceNumber;
+- u8 PciBusNumber;
+- u8 reserved;
+- u16 PciVendorID;
+- u16 PciDeviceID;
++ __u8 PciFunctionNumber;
++ __u8 PciDeviceNumber;
++ __u8 PciBusNumber;
++ __u8 reserved;
++ __u16 PciVendorID;
++ __u16 PciDeviceID;
+ } i2o_pci_bus;
+
+ typedef struct _i2o_local_bus
+ {
+- u16 LbBaseIOPort;
+- u16 reserved;
+- u32 LbBaseMemoryAddress;
++ __u16 LbBaseIOPort;
++ __u16 reserved;
++ __u32 LbBaseMemoryAddress;
+ } i2o_local_bus;
+
+ typedef struct _i2o_isa_bus
+ {
+- u16 IsaBaseIOPort;
+- u8 CSN;
+- u8 reserved;
+- u32 IsaBaseMemoryAddress;
++ __u16 IsaBaseIOPort;
++ __u8 CSN;
++ __u8 reserved;
++ __u32 IsaBaseMemoryAddress;
+ } i2o_isa_bus;
+
+ typedef struct _i2o_eisa_bus_info
+ {
+- u16 EisaBaseIOPort;
+- u8 reserved;
+- u8 EisaSlotNumber;
+- u32 EisaBaseMemoryAddress;
++ __u16 EisaBaseIOPort;
++ __u8 reserved;
++ __u8 EisaSlotNumber;
++ __u32 EisaBaseMemoryAddress;
+ } i2o_eisa_bus;
+
+ typedef struct _i2o_mca_bus
+ {
+- u16 McaBaseIOPort;
+- u8 reserved;
+- u8 McaSlotNumber;
+- u32 McaBaseMemoryAddress;
++ __u16 McaBaseIOPort;
++ __u8 reserved;
++ __u8 McaSlotNumber;
++ __u32 McaBaseMemoryAddress;
+ } i2o_mca_bus;
+
+ typedef struct _i2o_other_bus
+ {
+- u16 BaseIOPort;
+- u16 reserved;
+- u32 BaseMemoryAddress;
++ __u16 BaseIOPort;
++ __u16 reserved;
++ __u32 BaseMemoryAddress;
+ } i2o_other_bus;
+
+ typedef struct _i2o_hrt_entry
+ {
+- u32 adapter_id;
+- u32 parent_tid:12;
+- u32 state:4;
+- u32 bus_num:8;
+- u32 bus_type:8;
++ __u32 adapter_id;
++ __u32 parent_tid:12;
++ __u32 state:4;
++ __u32 bus_num:8;
++ __u32 bus_type:8;
+ union
+ {
+ i2o_pci_bus pci_bus;
+@@ -201,69 +201,69 @@
+
+ typedef struct _i2o_hrt
+ {
+- u16 num_entries;
+- u8 entry_len;
+- u8 hrt_version;
+- u32 change_ind;
++ __u16 num_entries;
++ __u8 entry_len;
++ __u8 hrt_version;
++ __u32 change_ind;
+ i2o_hrt_entry hrt_entry[1];
+ } i2o_hrt;
+
+ typedef struct _i2o_lct_entry
+ {
+- u32 entry_size:16;
+- u32 tid:12;
+- u32 reserved:4;
+- u32 change_ind;
+- u32 device_flags;
+- u32 class_id:12;
+- u32 version:4;
+- u32 vendor_id:16;
+- u32 sub_class;
+- u32 user_tid:12;
+- u32 parent_tid:12;
+- u32 bios_info:8;
+- u8 identity_tag[8];
+- u32 event_capabilities;
++ __u32 entry_size:16;
++ __u32 tid:12;
++ __u32 reserved:4;
++ __u32 change_ind;
++ __u32 device_flags;
++ __u32 class_id:12;
++ __u32 version:4;
++ __u32 vendor_id:16;
++ __u32 sub_class;
++ __u32 user_tid:12;
++ __u32 parent_tid:12;
++ __u32 bios_info:8;
++ __u8 identity_tag[8];
++ __u32 event_capabilities;
+ } i2o_lct_entry;
+
+ typedef struct _i2o_lct
+ {
+- u32 table_size:16;
+- u32 boot_tid:12;
+- u32 lct_ver:4;
+- u32 iop_flags;
+- u32 change_ind;
++ __u32 table_size:16;
++ __u32 boot_tid:12;
++ __u32 lct_ver:4;
++ __u32 iop_flags;
++ __u32 change_ind;
+ i2o_lct_entry lct_entry[1];
+ } i2o_lct;
+
+ typedef struct _i2o_status_block
+ {
+- u16 org_id;
+- u16 reserved;
+- u16 iop_id:12;
+- u16 reserved1:4;
+- u16 host_unit_id;
+- u16 segment_number:12;
+- u16 i2o_version:4;
+- u8 iop_state;
+- u8 msg_type;
+- u16 inbound_frame_size;
+- u8 init_code;
+- u8 reserved2;
+- u32 max_inbound_frames;
+- u32 cur_inbound_frames;
+- u32 max_outbound_frames;
++ __u16 org_id;
++ __u16 reserved;
++ __u16 iop_id:12;
++ __u16 reserved1:4;
++ __u16 host_unit_id;
++ __u16 segment_number:12;
++ __u16 i2o_version:4;
++ __u8 iop_state;
++ __u8 msg_type;
++ __u16 inbound_frame_size;
++ __u8 init_code;
++ __u8 reserved2;
++ __u32 max_inbound_frames;
++ __u32 cur_inbound_frames;
++ __u32 max_outbound_frames;
+ char product_id[24];
+- u32 expected_lct_size;
+- u32 iop_capabilities;
+- u32 desired_mem_size;
+- u32 current_mem_size;
+- u32 current_mem_base;
+- u32 desired_io_size;
+- u32 current_io_size;
+- u32 current_io_base;
+- u32 reserved3:24;
+- u32 cmd_status:8;
++ __u32 expected_lct_size;
++ __u32 iop_capabilities;
++ __u32 desired_mem_size;
++ __u32 current_mem_size;
++ __u32 current_mem_base;
++ __u32 desired_io_size;
++ __u32 current_io_size;
++ __u32 current_io_base;
++ __u32 reserved3:24;
++ __u32 cmd_status:8;
+ } i2o_status_block;
+
+ /* Event indicator mask flags */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/isdn/capilli.h linux-libc-headers-2.6.8.0/include/linux/isdn/capilli.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/isdn/capilli.h 2004-03-28 07:52:12.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/isdn/capilli.h 2004-08-26 13:26:47.000000000 -0500
+@@ -43,20 +43,20 @@
+ char *driver_name; /* name of driver */
+ int (*load_firmware)(struct capi_ctr *, capiloaddata *);
+ void (*reset_ctr)(struct capi_ctr *);
+- void (*register_appl)(struct capi_ctr *, u16 appl,
++ void (*register_appl)(struct capi_ctr *, __u16 appl,
+ capi_register_params *);
+- void (*release_appl)(struct capi_ctr *, u16 appl);
+- u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
++ void (*release_appl)(struct capi_ctr *, __u16 appl);
++ __u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
+
+ char *(*procinfo)(struct capi_ctr *);
+ int (*ctr_read_proc)(char *page, char **start, off_t off,
+ int count, int *eof, struct capi_ctr *card);
+
+ /* filled in before calling ready callback */
+- u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
++ __u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
+ capi_version version; /* CAPI_GET_VERSION */
+ capi_profile profile; /* CAPI_GET_PROFILE */
+- u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
++ __u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
+
+ /* management information for kcapi */
+
+@@ -81,7 +81,7 @@
+ void capi_ctr_reseted(struct capi_ctr * card);
+ void capi_ctr_suspend_output(struct capi_ctr * card);
+ void capi_ctr_resume_output(struct capi_ctr * card);
+-void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb);
++void capi_ctr_handle_message(struct capi_ctr * card, __u16 appl, struct sk_buff *skb);
+
+ // ---------------------------------------------------------------------------
+ // needed for AVM capi drivers
+@@ -102,11 +102,11 @@
+ // ---------------------------------------------------------------------------
+ // library functions for use by hardware controller drivers
+
+-void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize);
+-void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci);
+-void capilib_release_appl(struct list_head *head, u16 applid);
++void capilib_new_ncci(struct list_head *head, __u16 applid, __u32 ncci, __u32 winsize);
++void capilib_free_ncci(struct list_head *head, __u16 applid, __u32 ncci);
++void capilib_release_appl(struct list_head *head, __u16 applid);
+ void capilib_release(struct list_head *head);
+-void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
+-u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
++void capilib_data_b3_conf(struct list_head *head, __u16 applid, __u32 ncci, __u16 msgid);
++__u16 capilib_data_b3_req(struct list_head *head, __u16 applid, __u32 ncci, __u16 msgid);
+
+ #endif /* __CAPILLI_H__ */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/jhash.h linux-libc-headers-2.6.8.0/include/linux/jhash.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/jhash.h 2004-03-28 07:52:09.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/jhash.h 2004-08-26 05:42:08.000000000 -0500
+@@ -41,19 +41,19 @@
+ * of bytes. No alignment or length assumptions are made about
+ * the input key.
+ */
+-static inline u32 jhash(const void *key, u32 length, u32 initval)
++static inline __u32 jhash(const void *key, __u32 length, __u32 initval)
+ {
+- u32 a, b, c, len;
+- const u8 *k = key;
++ __u32 a, b, c, len;
++ const __u8 *k = key;
+
+ len = length;
+ a = b = JHASH_GOLDEN_RATIO;
+ c = initval;
+
+ while (len >= 12) {
+- a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
+- b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
+- c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
++ a += (k[0] +((__u32)k[1]<<8) +((__u32)k[2]<<16) +((__u32)k[3]<<24));
++ b += (k[4] +((__u32)k[5]<<8) +((__u32)k[6]<<16) +((__u32)k[7]<<24));
++ c += (k[8] +((__u32)k[9]<<8) +((__u32)k[10]<<16)+((__u32)k[11]<<24));
+
+ __jhash_mix(a,b,c);
+
+@@ -63,16 +63,16 @@
+
+ c += length;
+ switch (len) {
+- case 11: c += ((u32)k[10]<<24);
+- case 10: c += ((u32)k[9]<<16);
+- case 9 : c += ((u32)k[8]<<8);
+- case 8 : b += ((u32)k[7]<<24);
+- case 7 : b += ((u32)k[6]<<16);
+- case 6 : b += ((u32)k[5]<<8);
++ case 11: c += ((__u32)k[10]<<24);
++ case 10: c += ((__u32)k[9]<<16);
++ case 9 : c += ((__u32)k[8]<<8);
++ case 8 : b += ((__u32)k[7]<<24);
++ case 7 : b += ((__u32)k[6]<<16);
++ case 6 : b += ((__u32)k[5]<<8);
+ case 5 : b += k[4];
+- case 4 : a += ((u32)k[3]<<24);
+- case 3 : a += ((u32)k[2]<<16);
+- case 2 : a += ((u32)k[1]<<8);
++ case 4 : a += ((__u32)k[3]<<24);
++ case 3 : a += ((__u32)k[2]<<16);
++ case 2 : a += ((__u32)k[1]<<8);
+ case 1 : a += k[0];
+ };
+
+@@ -81,12 +81,12 @@
+ return c;
+ }
+
+-/* A special optimized version that handles 1 or more of u32s.
+- * The length parameter here is the number of u32s in the key.
++/* A special optimized version that handles 1 or more of __u32s.
++ * The length parameter here is the number of __u32s in the key.
+ */
+-static inline u32 jhash2(u32 *k, u32 length, u32 initval)
++static inline __u32 jhash2(__u32 *k, __u32 length, __u32 initval)
+ {
+- u32 a, b, c, len;
++ __u32 a, b, c, len;
+
+ a = b = JHASH_GOLDEN_RATIO;
+ c = initval;
+@@ -119,7 +119,7 @@
+ * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
+ * done at the end is not done here.
+ */
+-static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
++static inline __u32 jhash_3words(__u32 a, __u32 b, __u32 c, __u32 initval)
+ {
+ a += JHASH_GOLDEN_RATIO;
+ b += JHASH_GOLDEN_RATIO;
+@@ -130,12 +130,12 @@
+ return c;
+ }
+
+-static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
++static inline __u32 jhash_2words(__u32 a, __u32 b, __u32 initval)
+ {
+ return jhash_3words(a, b, 0, initval);
+ }
+
+-static inline u32 jhash_1word(u32 a, u32 initval)
++static inline __u32 jhash_1word(__u32 a, __u32 initval)
+ {
+ return jhash_3words(a, 0, 0, initval);
+ }
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/jiffies.h linux-libc-headers-2.6.8.0/include/linux/jiffies.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/jiffies.h 2004-01-17 17:04:30.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/jiffies.h 2004-08-26 13:26:33.000000000 -0500
+@@ -12,15 +12,15 @@
+ * without sampling the sequence number in xtime_lock.
+ * get_jiffies_64() will do this for you as appropriate.
+ */
+-extern u64 jiffies_64;
++extern __u64 jiffies_64;
+ extern unsigned long volatile jiffies;
+
+ #if (BITS_PER_LONG < 64)
+-u64 get_jiffies_64(void);
++__u64 get_jiffies_64(void);
+ #else
+-static inline u64 get_jiffies_64(void)
++static inline __u64 get_jiffies_64(void)
+ {
+- return (u64)jiffies;
++ return (__u64)jiffies;
+ }
+ #endif
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/kernel_stat.h linux-libc-headers-2.6.8.0/include/linux/kernel_stat.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/kernel_stat.h 2004-04-19 16:13:51.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/kernel_stat.h 2004-08-26 05:42:08.000000000 -0500
+@@ -12,13 +12,13 @@
+ */
+
+ struct cpu_usage_stat {
+- u64 user;
+- u64 nice;
+- u64 system;
+- u64 softirq;
+- u64 irq;
+- u64 idle;
+- u64 iowait;
++ __u64 user;
++ __u64 nice;
++ __u64 system;
++ __u64 softirq;
++ __u64 irq;
++ __u64 idle;
++ __u64 iowait;
+ };
+
+ struct kernel_stat {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/libata.h linux-libc-headers-2.6.8.0/include/linux/libata.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/libata.h 2004-08-18 13:16:03.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/libata.h 2004-08-26 05:42:08.000000000 -0500
+@@ -160,7 +160,7 @@
+ struct ata_queued_cmd;
+
+ /* typedefs */
+-typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat);
++typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, __u8 drv_stat);
+
+ struct ata_ioports {
+ unsigned long cmd_addr;
+@@ -246,18 +246,18 @@
+ };
+
+ struct ata_device {
+- u64 n_sectors; /* size of device, if ATA */
++ __u64 n_sectors; /* size of device, if ATA */
+ unsigned long flags; /* ATA_DFLAG_xxx */
+ unsigned int class; /* ATA_DEV_xxx */
+ unsigned int devno; /* 0 or 1 */
+- u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
++ __u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
+ unsigned int pio_mode;
+ unsigned int udma_mode;
+
+ /* cache info about current transfer mode */
+- u8 xfer_protocol; /* taskfile xfer protocol */
+- u8 read_cmd; /* opcode to use on read */
+- u8 write_cmd; /* opcode to use on write */
++ __u8 xfer_protocol; /* taskfile xfer protocol */
++ __u8 read_cmd; /* opcode to use on read */
++ __u8 write_cmd; /* opcode to use on write */
+ };
+
+ struct ata_port {
+@@ -272,8 +272,8 @@
+
+ struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
+
+- u8 ctl; /* cache of ATA control register */
+- u8 last_ctl; /* Cache last written value */
++ __u8 ctl; /* cache of ATA control register */
++ __u8 last_ctl; /* Cache last written value */
+ unsigned int bus_state;
+ unsigned int port_state;
+ unsigned int pio_mask;
+@@ -312,7 +312,7 @@
+ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
+
+ void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
+- u8 (*check_status)(struct ata_port *ap);
++ __u8 (*check_status)(struct ata_port *ap);
+
+ void (*phy_reset) (struct ata_port *ap);
+ void (*post_set_mode) (struct ata_port *ap);
+@@ -328,9 +328,9 @@
+ irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
+ void (*irq_clear) (struct ata_port *);
+
+- u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
++ __u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
+ void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
+- u32 val);
++ __u32 val);
+
+ int (*port_start) (struct ata_port *ap);
+ void (*port_stop) (struct ata_port *ap);
+@@ -374,10 +374,10 @@
+ extern void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf);
+ extern void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf);
+ extern void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf);
+-extern void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp);
+-extern void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf);
+-extern u8 ata_check_status_pio(struct ata_port *ap);
+-extern u8 ata_check_status_mmio(struct ata_port *ap);
++extern void ata_tf_to_fis(struct ata_taskfile *tf, __u8 *fis, __u8 pmp);
++extern void ata_tf_from_fis(__u8 *fis, struct ata_taskfile *tf);
++extern __u8 ata_check_status_pio(struct ata_port *ap);
++extern __u8 ata_check_status_mmio(struct ata_port *ap);
+ extern void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf);
+ extern void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
+ extern int ata_port_start (struct ata_port *ap);
+@@ -397,7 +397,7 @@
+ extern void ata_bmdma_start_pio (struct ata_queued_cmd *qc);
+ extern void ata_bmdma_irq_clear(struct ata_port *ap);
+ extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits);
+-extern void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat);
++extern void ata_qc_complete(struct ata_queued_cmd *qc, __u8 drv_stat);
+ extern void ata_eng_timeout(struct ata_port *ap);
+ extern int ata_std_bios_param(struct scsi_device *sdev,
+ struct block_device *bdev,
+@@ -416,7 +416,7 @@
+ (dev->class == ATA_DEV_ATAPI));
+ }
+
+-static inline u8 ata_chk_err(struct ata_port *ap)
++static inline __u8 ata_chk_err(struct ata_port *ap)
+ {
+ if (ap->flags & ATA_FLAG_MMIO) {
+ return readb((void *) ap->ioaddr.error_addr);
+@@ -424,12 +424,12 @@
+ return inb(ap->ioaddr.error_addr);
+ }
+
+-static inline u8 ata_chk_status(struct ata_port *ap)
++static inline __u8 ata_chk_status(struct ata_port *ap)
+ {
+ return ap->ops->check_status(ap);
+ }
+
+-static inline u8 ata_altstatus(struct ata_port *ap)
++static inline __u8 ata_altstatus(struct ata_port *ap)
+ {
+ if (ap->flags & ATA_FLAG_MMIO)
+ return readb(ap->ioaddr.altstatus_addr);
+@@ -442,10 +442,10 @@
+ ndelay(400);
+ }
+
+-static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
++static inline __u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
+ unsigned int max)
+ {
+- u8 status;
++ __u8 status;
+
+ do {
+ udelay(10);
+@@ -456,9 +456,9 @@
+ return status;
+ }
+
+-static inline u8 ata_wait_idle(struct ata_port *ap)
++static inline __u8 ata_wait_idle(struct ata_port *ap)
+ {
+- u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
++ __u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
+
+ if (status & (ATA_BUSY | ATA_DRQ)) {
+ unsigned long l = ap->ioaddr.status_addr;
+@@ -495,10 +495,10 @@
+ tf->device = ATA_DEVICE_OBS | ATA_DEV1;
+ }
+
+-static inline u8 ata_irq_on(struct ata_port *ap)
++static inline __u8 ata_irq_on(struct ata_port *ap)
+ {
+ struct ata_ioports *ioaddr = &ap->ioaddr;
+- u8 tmp;
++ __u8 tmp;
+
+ ap->ctl &= ~ATA_NIEN;
+ ap->last_ctl = ap->ctl;
+@@ -514,10 +514,10 @@
+ return tmp;
+ }
+
+-static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
++static inline __u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
+ {
+ unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
+- u8 host_stat, post_stat, status;
++ __u8 host_stat, post_stat, status;
+
+ status = ata_busy_wait(ap, bits, 1000);
+ if (status & bits)
+@@ -545,12 +545,12 @@
+ return status;
+ }
+
+-static inline u32 scr_read(struct ata_port *ap, unsigned int reg)
++static inline __u32 scr_read(struct ata_port *ap, unsigned int reg)
+ {
+ return ap->ops->scr_read(ap, reg);
+ }
+
+-static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val)
++static inline void scr_write(struct ata_port *ap, unsigned int reg, __u32 val)
+ {
+ ap->ops->scr_write(ap, reg, val);
+ }
+@@ -589,9 +589,9 @@
+ }
+ }
+
+-static inline u8 ata_bmdma_status(struct ata_port *ap)
++static inline __u8 ata_bmdma_status(struct ata_port *ap)
+ {
+- u8 host_stat;
++ __u8 host_stat;
+ if (ap->flags & ATA_FLAG_MMIO) {
+ void *mmio = (void *) ap->ioaddr.bmdma_addr;
+ host_stat = readb(mmio + ATA_DMA_STATUS);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/bind.h linux-libc-headers-2.6.8.0/include/linux/lockd/bind.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/bind.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/bind.h 2004-08-26 05:42:08.000000000 -0500
+@@ -18,7 +18,7 @@
+ * This is the set of functions for lockd->nfsd communication
+ */
+ struct nlmsvc_binding {
+- u32 (*fopen)(struct svc_rqst *,
++ __u32 (*fopen)(struct svc_rqst *,
+ struct nfs_fh *,
+ struct file *);
+ void (*fclose)(struct file *);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/nlm.h linux-libc-headers-2.6.8.0/include/linux/lockd/nlm.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/nlm.h 2004-01-17 17:04:34.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/nlm.h 2004-08-26 05:42:08.000000000 -0500
+@@ -11,8 +11,8 @@
+
+
+ /* Maximum file offset in file_lock.fl_end */
+-# define NLM_OFFSET_MAX ((s32) 0x7fffffff)
+-# define NLM4_OFFSET_MAX ((s64) ((~(u64)0) >> 1))
++# define NLM_OFFSET_MAX ((__s32) 0x7fffffff)
++# define NLM4_OFFSET_MAX ((__s64) ((~(__u64)0) >> 1))
+
+ /* Return states for NLM */
+ enum {
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/share.h linux-libc-headers-2.6.8.0/include/linux/lockd/share.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/share.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/share.h 2004-08-26 13:26:43.000000000 -0500
+@@ -17,13 +17,13 @@
+ struct nlm_host * s_host; /* client host */
+ struct nlm_file * s_file; /* shared file */
+ struct xdr_netobj s_owner; /* owner handle */
+- u32 s_access; /* access mode */
+- u32 s_mode; /* deny mode */
++ __u32 s_access; /* access mode */
++ __u32 s_mode; /* deny mode */
+ };
+
+-u32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *,
++__u32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *,
+ struct nlm_args *);
+-u32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,
++__u32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,
+ struct nlm_args *);
+ int nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *, int);
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/sm_inter.h linux-libc-headers-2.6.8.0/include/linux/lockd/sm_inter.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/sm_inter.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/sm_inter.h 2004-08-26 05:42:08.000000000 -0500
+@@ -24,23 +24,23 @@
+ * Arguments for all calls to statd
+ */
+ struct nsm_args {
+- u32 addr; /* remote address */
+- u32 prog; /* RPC callback info */
+- u32 vers;
+- u32 proc;
+- u32 proto; /* protocol (udp/tcp) plus server/client flag */
++ __u32 addr; /* remote address */
++ __u32 prog; /* RPC callback info */
++ __u32 vers;
++ __u32 proc;
++ __u32 proto; /* protocol (udp/tcp) plus server/client flag */
+ };
+
+ /*
+ * Result returned by statd
+ */
+ struct nsm_res {
+- u32 status;
+- u32 state;
++ __u32 status;
++ __u32 state;
+ };
+
+ int nsm_monitor(struct nlm_host *);
+ int nsm_unmonitor(struct nlm_host *);
+-extern u32 nsm_local_state;
++extern __u32 nsm_local_state;
+
+ #endif /* LINUX_LOCKD_SM_INTER_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/xdr.h linux-libc-headers-2.6.8.0/include/linux/lockd/xdr.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/xdr.h 2004-01-05 12:42:33.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/xdr.h 2004-08-26 05:42:08.000000000 -0500
+@@ -48,12 +48,12 @@
+ struct nlm_args {
+ struct nlm_cookie cookie;
+ struct nlm_lock lock;
+- u32 block;
+- u32 reclaim;
+- u32 state;
+- u32 monitor;
+- u32 fsm_access;
+- u32 fsm_mode;
++ __u32 block;
++ __u32 reclaim;
++ __u32 state;
++ __u32 monitor;
++ __u32 fsm_access;
++ __u32 fsm_mode;
+ };
+
+ typedef struct nlm_args nlm_args;
+@@ -63,7 +63,7 @@
+ */
+ struct nlm_res {
+ struct nlm_cookie cookie;
+- u32 status;
++ __u32 status;
+ struct nlm_lock lock;
+ };
+
+@@ -73,10 +73,10 @@
+ struct nlm_reboot {
+ char * mon;
+ int len;
+- u32 state;
+- u32 addr;
+- u32 vers;
+- u32 proto;
++ __u32 state;
++ __u32 addr;
++ __u32 vers;
++ __u32 proto;
+ };
+
+ /*
+@@ -84,24 +84,24 @@
+ */
+ #define NLMSVC_XDRSIZE sizeof(struct nlm_args)
+
+-int nlmsvc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlmsvc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlmsvc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlmsvc_encode_void(struct svc_rqst *, u32 *, void *);
+-int nlmsvc_decode_void(struct svc_rqst *, u32 *, void *);
+-int nlmsvc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlmsvc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlmsvc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *);
++int nlmsvc_decode_testargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_encode_testres(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlmsvc_decode_lockargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_decode_cancargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_decode_unlockargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_encode_res(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlmsvc_decode_res(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlmsvc_encode_void(struct svc_rqst *, __u32 *, void *);
++int nlmsvc_decode_void(struct svc_rqst *, __u32 *, void *);
++int nlmsvc_decode_shareargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_encode_shareres(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlmsvc_decode_notify(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlmsvc_decode_reboot(struct svc_rqst *, __u32 *, struct nlm_reboot *);
+ /*
+-int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
++int nlmclt_encode_testargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_lockargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_cancargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_unlockargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
+ */
+
+ #endif /* LOCKD_XDR_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/lockd/xdr4.h linux-libc-headers-2.6.8.0/include/linux/lockd/xdr4.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/lockd/xdr4.h 2004-01-05 12:42:33.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/lockd/xdr4.h 2004-08-26 05:42:08.000000000 -0500
+@@ -22,24 +22,24 @@
+
+
+
+-int nlm4svc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlm4svc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlm4svc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlm4svc_encode_void(struct svc_rqst *, u32 *, void *);
+-int nlm4svc_decode_void(struct svc_rqst *, u32 *, void *);
+-int nlm4svc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *);
+-int nlm4svc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *);
+-int nlm4svc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *);
++int nlm4svc_decode_testargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_encode_testres(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlm4svc_decode_lockargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_decode_cancargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_decode_unlockargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_encode_res(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlm4svc_decode_res(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlm4svc_encode_void(struct svc_rqst *, __u32 *, void *);
++int nlm4svc_decode_void(struct svc_rqst *, __u32 *, void *);
++int nlm4svc_decode_shareargs(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_encode_shareres(struct svc_rqst *, __u32 *, struct nlm_res *);
++int nlm4svc_decode_notify(struct svc_rqst *, __u32 *, struct nlm_args *);
++int nlm4svc_decode_reboot(struct svc_rqst *, __u32 *, struct nlm_reboot *);
+ /*
+-int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
+-int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
++int nlmclt_encode_testargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_lockargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_cancargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
++int nlmclt_encode_unlockargs(struct rpc_rqst *, __u32 *, struct nlm_args *);
+ */
+
+ #endif /* LOCKD_XDR4_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/mca.h linux-libc-headers-2.6.8.0/include/linux/mca.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/mca.h 2004-08-18 13:16:03.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/mca.h 2004-08-26 05:42:08.000000000 -0500
+@@ -50,7 +50,7 @@
+ };
+
+ struct mca_device {
+- u64 dma_mask;
++ __u64 dma_mask;
+ int pos_id;
+ int slot;
+
+@@ -91,7 +91,7 @@
+ };
+
+ struct mca_bus {
+- u64 default_dma_mask;
++ __u64 default_dma_mask;
+ int number;
+ struct mca_bus_accessor_functions f;
+ struct device dev;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/mii.h linux-libc-headers-2.6.8.0/include/linux/mii.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/mii.h 2004-06-23 16:52:55.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/mii.h 2004-08-26 05:42:08.000000000 -0500
+@@ -138,10 +138,10 @@
+
+ /* This structure is used in all SIOCxMIIxxx ioctl calls */
+ struct mii_ioctl_data {
+- u16 phy_id;
+- u16 reg_num;
+- u16 val_in;
+- u16 val_out;
++ __u16 phy_id;
++ __u16 reg_num;
++ __u16 val_in;
++ __u16 val_out;
+ };
+
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/mtd/map.h linux-libc-headers-2.6.8.0/include/linux/mtd/map.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/mtd/map.h 2004-08-18 13:16:06.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/mtd/map.h 2004-08-26 05:42:08.000000000 -0500
+@@ -36,20 +36,20 @@
+ int buswidth; /* in octets */
+
+ #ifdef CONFIG_MTD_COMPLEX_MAPPINGS
+- u8 (*read8)(struct map_info *, unsigned long);
+- u16 (*read16)(struct map_info *, unsigned long);
+- u32 (*read32)(struct map_info *, unsigned long);
+- u64 (*read64)(struct map_info *, unsigned long);
++ __u8 (*read8)(struct map_info *, unsigned long);
++ __u16 (*read16)(struct map_info *, unsigned long);
++ __u32 (*read32)(struct map_info *, unsigned long);
++ __u64 (*read64)(struct map_info *, unsigned long);
+ /* If it returned a 'long' I'd call it readl.
+ * It doesn't.
+ * I won't.
+ * dwmw2 */
+
+ void (*copy_from)(struct map_info *, void *, unsigned long, ssize_t);
+- void (*write8)(struct map_info *, u8, unsigned long);
+- void (*write16)(struct map_info *, u16, unsigned long);
+- void (*write32)(struct map_info *, u32, unsigned long);
+- void (*write64)(struct map_info *, u64, unsigned long);
++ void (*write8)(struct map_info *, __u8, unsigned long);
++ void (*write16)(struct map_info *, __u16, unsigned long);
++ void (*write32)(struct map_info *, __u32, unsigned long);
++ void (*write64)(struct map_info *, __u64, unsigned long);
+ void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t);
+
+ /* We can perhaps put in 'point' and 'unpoint' methods, if we really
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/mtd/nand.h linux-libc-headers-2.6.8.0/include/linux/mtd/nand.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/mtd/nand.h 2004-08-18 13:16:06.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/mtd/nand.h 2004-08-26 05:42:08.000000000 -0500
+@@ -271,8 +271,8 @@
+
+ u_char (*read_byte)(struct mtd_info *mtd);
+ void (*write_byte)(struct mtd_info *mtd, u_char byte);
+- u16 (*read_word)(struct mtd_info *mtd);
+- void (*write_word)(struct mtd_info *mtd, u16 word);
++ __u16 (*read_word)(struct mtd_info *mtd);
++ void (*write_word)(struct mtd_info *mtd, __u16 word);
+
+ void (*write_buf)(struct mtd_info *mtd, const u_char *buf, int len);
+ void (*read_buf)(struct mtd_info *mtd, u_char *buf, int len);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/mtd/pmc551.h linux-libc-headers-2.6.8.0/include/linux/mtd/pmc551.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/mtd/pmc551.h 2004-03-28 07:52:13.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/mtd/pmc551.h 2004-08-26 05:42:08.000000000 -0500
+@@ -25,9 +25,9 @@
+ struct mypriv {
+ struct pci_dev *dev;
+ u_char *start;
+- u32 base_map0;
+- u32 curr_map0;
+- u32 asize;
++ __u32 base_map0;
++ __u32 curr_map0;
++ __u32 asize;
+ struct mtd_info *nextpmc551;
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nbd.h linux-libc-headers-2.6.8.0/include/linux/nbd.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nbd.h 2004-03-28 07:52:09.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/nbd.h 2004-08-26 05:42:08.000000000 -0500
+@@ -45,11 +45,11 @@
+ * server. All data are in network byte order.
+ */
+ struct nbd_request {
+- u32 magic;
+- u32 type; /* == READ || == WRITE */
++ __u32 magic;
++ __u32 type; /* == READ || == WRITE */
+ char handle[8];
+- u64 from;
+- u32 len;
++ __u64 from;
++ __u32 len;
+ }
+ #ifdef __GNUC__
+ __attribute__ ((packed))
+@@ -61,8 +61,8 @@
+ * it has completed an I/O request (or an error occurs).
+ */
+ struct nbd_reply {
+- u32 magic;
+- u32 error; /* 0 = ok, else error */
++ __u32 magic;
++ __u32 error; /* 0 = ok, else error */
+ char handle[8]; /* handle you got from request */
+ };
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfs_fs_i.h linux-libc-headers-2.6.8.0/include/linux/nfs_fs_i.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfs_fs_i.h 2004-01-17 17:04:31.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/nfs_fs_i.h 2004-08-26 05:42:08.000000000 -0500
+@@ -8,8 +8,8 @@
+ * NFS lock info
+ */
+ struct nfs_lock_info {
+- u32 state;
+- u32 flags;
++ __u32 state;
++ __u32 flags;
+ struct nlm_host *host;
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfs_fs_sb.h linux-libc-headers-2.6.8.0/include/linux/nfs_fs_sb.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfs_fs_sb.h 2004-06-09 07:00:50.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfs_fs_sb.h 2004-08-26 05:42:08.000000000 -0500
+@@ -37,10 +37,10 @@
+ struct list_head nfs4_siblings; /* List of other nfs_server structs
+ * that share the same clientid
+ */
+- u32 attr_bitmask[2];/* V4 bitmask representing the set
++ __u32 attr_bitmask[2];/* V4 bitmask representing the set
+ of attributes supported on this
+ filesystem */
+- u32 acl_bitmask; /* V4 bitmask representing the ACEs
++ __u32 acl_bitmask; /* V4 bitmask representing the ACEs
+ that are supported on this
+ filesystem */
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfs_xdr.h linux-libc-headers-2.6.8.0/include/linux/nfs_xdr.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfs_xdr.h 2004-06-09 07:00:50.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfs_xdr.h 2004-08-26 05:42:08.000000000 -0500
+@@ -90,9 +90,9 @@
+ };
+
+ struct nfs4_change_info {
+- u32 atomic;
+- u64 before;
+- u64 after;
++ __u32 atomic;
++ __u64 before;
++ __u64 after;
+ };
+
+ /*
+@@ -112,7 +112,7 @@
+ } u;
+ const struct qstr * name;
+ const struct nfs_server *server; /* Needed for ID mapping */
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs_openres {
+@@ -168,7 +168,7 @@
+ * */
+ struct nfs_lowner {
+ __u64 clientid;
+- u32 id;
++ __u32 id;
+ };
+
+ struct nfs_open_to_lock {
+@@ -328,7 +328,7 @@
+ nfs4_stateid stateid;
+ struct iattr * iap;
+ const struct nfs_server * server; /* Needed for name mapping */
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs_setattrres {
+@@ -482,32 +482,32 @@
+
+ #ifdef CONFIG_NFS_V4
+
+-typedef u64 clientid4;
++typedef __u64 clientid4;
+
+ struct nfs4_accessargs {
+ const struct nfs_fh * fh;
+- u32 access;
++ __u32 access;
+ };
+
+ struct nfs4_accessres {
+- u32 supported;
+- u32 access;
++ __u32 supported;
++ __u32 access;
+ };
+
+ struct nfs4_create_arg {
+- u32 ftype;
++ __u32 ftype;
+ union {
+ struct qstr * symlink; /* NF4LNK */
+ struct {
+- u32 specdata1;
+- u32 specdata2;
++ __u32 specdata1;
++ __u32 specdata2;
+ } device; /* NF4BLK, NF4CHR */
+ } u;
+ const struct qstr * name;
+ const struct nfs_server * server;
+ const struct iattr * attrs;
+ const struct nfs_fh * dir_fh;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_create_res {
+@@ -519,12 +519,12 @@
+
+ struct nfs4_fsinfo_arg {
+ const struct nfs_fh * fh;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_getattr_arg {
+ const struct nfs_fh * fh;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_getattr_res {
+@@ -541,7 +541,7 @@
+ struct nfs4_lookup_arg {
+ const struct nfs_fh * dir_fh;
+ const struct qstr * name;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_lookup_res {
+@@ -551,19 +551,19 @@
+ };
+
+ struct nfs4_lookup_root_arg {
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_pathconf_arg {
+ const struct nfs_fh * fh;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_readdir_arg {
+ const struct nfs_fh * fh;
+- u64 cookie;
++ __u64 cookie;
+ nfs4_verifier verifier;
+- u32 count;
++ __u32 count;
+ struct page ** pages; /* zero-copy data */
+ unsigned int pgbase; /* zero-copy data */
+ };
+@@ -575,7 +575,7 @@
+
+ struct nfs4_readlink {
+ const struct nfs_fh * fh;
+- u32 count; /* zero-copy data */
++ __u32 count; /* zero-copy data */
+ struct page ** pages; /* zero-copy data */
+ };
+
+@@ -599,23 +599,23 @@
+ struct nfs4_setclientid {
+ nfs4_verifier sc_verifier; /* request */
+ char * sc_name; /* request */
+- u32 sc_prog; /* request */
++ __u32 sc_prog; /* request */
+ char sc_netid[4]; /* request */
+ char sc_uaddr[24]; /* request */
+- u32 sc_cb_ident; /* request */
++ __u32 sc_cb_ident; /* request */
+ struct nfs4_client * sc_state; /* response */
+ };
+
+ struct nfs4_statfs_arg {
+ const struct nfs_fh * fh;
+- const u32 * bitmask;
++ const __u32 * bitmask;
+ };
+
+ struct nfs4_server_caps_res {
+- u32 attr_bitmask[2];
+- u32 acl_bitmask;
+- u32 has_links;
+- u32 has_symlinks;
++ __u32 attr_bitmask[2];
++ __u32 acl_bitmask;
++ __u32 has_links;
++ __u32 has_symlinks;
+ };
+
+ #endif /* CONFIG_NFS_V4 */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/state.h linux-libc-headers-2.6.8.0/include/linux/nfsd/state.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/state.h 2004-08-18 13:16:07.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfsd/state.h 2004-08-26 05:42:08.000000000 -0500
+@@ -41,18 +41,18 @@
+
+ #define NFS4_OPAQUE_LIMIT 1024
+ typedef struct {
+- u32 cl_boot;
+- u32 cl_id;
++ __u32 cl_boot;
++ __u32 cl_id;
+ } clientid_t;
+
+ typedef struct {
+- u32 so_boot;
+- u32 so_stateownerid;
+- u32 so_fileid;
++ __u32 so_boot;
++ __u32 so_stateownerid;
++ __u32 so_fileid;
+ } stateid_opaque_t;
+
+ typedef struct {
+- u32 si_generation;
++ __u32 si_generation;
+ stateid_opaque_t si_opaque;
+ } stateid_t;
+ #define si_boot si_opaque.so_boot
+@@ -68,14 +68,14 @@
+ /* client delegation callback info */
+ struct nfs4_callback {
+ /* SETCLIENTID info */
+- u32 cb_parsed; /* addr parsed */
+- u32 cb_addr;
++ __u32 cb_parsed; /* addr parsed */
++ __u32 cb_addr;
+ unsigned short cb_port;
+- u32 cb_prog;
+- u32 cb_ident;
++ __u32 cb_prog;
++ __u32 cb_ident;
+ struct xdr_netobj cb_netid;
+ /* RPC client info */
+- u32 cb_set; /* successful CB_NULL call */
++ __u32 cb_set; /* successful CB_NULL call */
+ struct rpc_program cb_program;
+ struct rpc_stat cb_stat;
+ struct rpc_clnt * cb_client;
+@@ -99,7 +99,7 @@
+ struct xdr_netobj cl_name; /* id generated by client */
+ nfs4_verifier cl_verifier; /* generated by client */
+ time_t cl_time; /* time of last lease renewal */
+- u32 cl_addr; /* client ipaddress */
++ __u32 cl_addr; /* client ipaddress */
+ struct svc_cred cl_cred; /* setclientid principal */
+ clientid_t cl_clientid; /* generated by server */
+ nfs4_verifier cl_confirm; /* generated by server */
+@@ -116,7 +116,7 @@
+ struct list_head cr_strhash; /* hash by cr_name */
+ struct xdr_netobj cr_name; /* id generated by client */
+ time_t cr_first_state; /* first state aquisition */
+- u32 cr_expired; /* boolean: lease expired? */
++ __u32 cr_expired; /* boolean: lease expired? */
+ };
+
+ static inline void
+@@ -139,7 +139,7 @@
+ * is cached.
+ */
+ struct nfs4_replay {
+- u32 rp_status;
++ __u32 rp_status;
+ unsigned int rp_buflen;
+ char *rp_buf;
+ unsigned intrp_allocated;
+@@ -175,9 +175,9 @@
+ struct list_head so_close_lru; /* tail queue */
+ time_t so_time; /* time of placement on so_close_lru */
+ int so_is_open_owner; /* 1=openowner,0=lockowner */
+- u32 so_id;
++ __u32 so_id;
+ struct nfs4_client * so_client;
+- u32 so_seqid;
++ __u32 so_seqid;
+ struct xdr_netobj so_owner; /* open owner name */
+ int so_confirmed; /* successful OPEN_CONFIRM? */
+ struct nfs4_replay so_replay;
+@@ -192,7 +192,7 @@
+ struct list_head fi_hash; /* hash by "struct inode *" */
+ struct list_head fi_perfile; /* list: nfs4_stateid */
+ struct inode *fi_inode;
+- u32 fi_id; /* used with stateowner->so_id
++ __u32 fi_id; /* used with stateowner->so_id
+ * for stateid_hashtbl hash */
+ };
+
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr.h linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr.h 2004-08-18 13:16:07.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr.h 2004-08-26 05:42:08.000000000 -0500
+@@ -83,7 +83,7 @@
+ struct svc_fh fh;
+ __u32 cookie;
+ __u32 count;
+- u32 * buffer;
++ __u32 * buffer;
+ };
+
+ struct nfsd_attrstat {
+@@ -107,9 +107,9 @@
+ int count;
+
+ struct readdir_cd common;
+- u32 * buffer;
++ __u32 * buffer;
+ int buflen;
+- u32 * offset;
++ __u32 * offset;
+ };
+
+ struct nfsd_statfsres {
+@@ -134,39 +134,39 @@
+ #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
+
+
+-int nfssvc_decode_void(struct svc_rqst *, u32 *, void *);
+-int nfssvc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
+-int nfssvc_decode_sattrargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_void(struct svc_rqst *, __u32 *, void *);
++int nfssvc_decode_fhandle(struct svc_rqst *, __u32 *, struct nfsd_fhandle *);
++int nfssvc_decode_sattrargs(struct svc_rqst *, __u32 *,
+ struct nfsd_sattrargs *);
+-int nfssvc_decode_diropargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_diropargs(struct svc_rqst *, __u32 *,
+ struct nfsd_diropargs *);
+-int nfssvc_decode_readargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_readargs(struct svc_rqst *, __u32 *,
+ struct nfsd_readargs *);
+-int nfssvc_decode_writeargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_writeargs(struct svc_rqst *, __u32 *,
+ struct nfsd_writeargs *);
+-int nfssvc_decode_createargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_createargs(struct svc_rqst *, __u32 *,
+ struct nfsd_createargs *);
+-int nfssvc_decode_renameargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_renameargs(struct svc_rqst *, __u32 *,
+ struct nfsd_renameargs *);
+-int nfssvc_decode_readlinkargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_readlinkargs(struct svc_rqst *, __u32 *,
+ struct nfsd_readlinkargs *);
+-int nfssvc_decode_linkargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_linkargs(struct svc_rqst *, __u32 *,
+ struct nfsd_linkargs *);
+-int nfssvc_decode_symlinkargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_symlinkargs(struct svc_rqst *, __u32 *,
+ struct nfsd_symlinkargs *);
+-int nfssvc_decode_readdirargs(struct svc_rqst *, u32 *,
++int nfssvc_decode_readdirargs(struct svc_rqst *, __u32 *,
+ struct nfsd_readdirargs *);
+-int nfssvc_encode_void(struct svc_rqst *, u32 *, void *);
+-int nfssvc_encode_attrstat(struct svc_rqst *, u32 *, struct nfsd_attrstat *);
+-int nfssvc_encode_diropres(struct svc_rqst *, u32 *, struct nfsd_diropres *);
+-int nfssvc_encode_readlinkres(struct svc_rqst *, u32 *, struct nfsd_readlinkres *);
+-int nfssvc_encode_readres(struct svc_rqst *, u32 *, struct nfsd_readres *);
+-int nfssvc_encode_statfsres(struct svc_rqst *, u32 *, struct nfsd_statfsres *);
+-int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *);
++int nfssvc_encode_void(struct svc_rqst *, __u32 *, void *);
++int nfssvc_encode_attrstat(struct svc_rqst *, __u32 *, struct nfsd_attrstat *);
++int nfssvc_encode_diropres(struct svc_rqst *, __u32 *, struct nfsd_diropres *);
++int nfssvc_encode_readlinkres(struct svc_rqst *, __u32 *, struct nfsd_readlinkres *);
++int nfssvc_encode_readres(struct svc_rqst *, __u32 *, struct nfsd_readres *);
++int nfssvc_encode_statfsres(struct svc_rqst *, __u32 *, struct nfsd_statfsres *);
++int nfssvc_encode_readdirres(struct svc_rqst *, __u32 *, struct nfsd_readdirres *);
+
+ int nfssvc_encode_entry(struct readdir_cd *, const char *name,
+ int namlen, loff_t offset, ino_t ino, unsigned int);
+
+-int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
++int nfssvc_release_fhandle(struct svc_rqst *, __u32 *, struct nfsd_fhandle *);
+
+ #endif /* LINUX_NFSD_H */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr3.h linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr3.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr3.h 2004-08-18 13:16:07.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr3.h 2004-08-26 05:42:08.000000000 -0500
+@@ -101,7 +101,7 @@
+ __u32 dircount;
+ __u32 count;
+ __u32 * verf;
+- u32 * buffer;
++ __u32 * buffer;
+ };
+
+ struct nfsd3_commitargs {
+@@ -167,10 +167,10 @@
+ __u32 verf[2];
+
+ struct readdir_cd common;
+- u32 * buffer;
++ __u32 * buffer;
+ int buflen;
+- u32 * offset;
+- u32 * offset1;
++ __u32 * offset;
++ __u32 * offset1;
+ struct svc_rqst * rqstp;
+
+ };
+@@ -245,70 +245,70 @@
+
+ #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
+
+-int nfs3svc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *);
+-int nfs3svc_decode_sattrargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_fhandle(struct svc_rqst *, __u32 *, struct nfsd_fhandle *);
++int nfs3svc_decode_sattrargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_sattrargs *);
+-int nfs3svc_decode_diropargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_diropargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_diropargs *);
+-int nfs3svc_decode_accessargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_accessargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_accessargs *);
+-int nfs3svc_decode_readargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_readargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_readargs *);
+-int nfs3svc_decode_writeargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_writeargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_writeargs *);
+-int nfs3svc_decode_createargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_createargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_createargs *);
+-int nfs3svc_decode_mkdirargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_mkdirargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_createargs *);
+-int nfs3svc_decode_mknodargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_mknodargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_mknodargs *);
+-int nfs3svc_decode_renameargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_renameargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_renameargs *);
+-int nfs3svc_decode_readlinkargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_readlinkargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_readlinkargs *);
+-int nfs3svc_decode_linkargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_linkargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_linkargs *);
+-int nfs3svc_decode_symlinkargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_symlinkargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_symlinkargs *);
+-int nfs3svc_decode_readdirargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_readdirargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_readdirargs *);
+-int nfs3svc_decode_readdirplusargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_readdirargs *);
+-int nfs3svc_decode_commitargs(struct svc_rqst *, u32 *,
++int nfs3svc_decode_commitargs(struct svc_rqst *, __u32 *,
+ struct nfsd3_commitargs *);
+-int nfs3svc_encode_voidres(struct svc_rqst *, u32 *, void *);
+-int nfs3svc_encode_attrstat(struct svc_rqst *, u32 *,
++int nfs3svc_encode_voidres(struct svc_rqst *, __u32 *, void *);
++int nfs3svc_encode_attrstat(struct svc_rqst *, __u32 *,
+ struct nfsd3_attrstat *);
+-int nfs3svc_encode_wccstat(struct svc_rqst *, u32 *,
++int nfs3svc_encode_wccstat(struct svc_rqst *, __u32 *,
+ struct nfsd3_attrstat *);
+-int nfs3svc_encode_diropres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_diropres(struct svc_rqst *, __u32 *,
+ struct nfsd3_diropres *);
+-int nfs3svc_encode_accessres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_accessres(struct svc_rqst *, __u32 *,
+ struct nfsd3_accessres *);
+-int nfs3svc_encode_readlinkres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_readlinkres(struct svc_rqst *, __u32 *,
+ struct nfsd3_readlinkres *);
+-int nfs3svc_encode_readres(struct svc_rqst *, u32 *, struct nfsd3_readres *);
+-int nfs3svc_encode_writeres(struct svc_rqst *, u32 *, struct nfsd3_writeres *);
+-int nfs3svc_encode_createres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_readres(struct svc_rqst *, __u32 *, struct nfsd3_readres *);
++int nfs3svc_encode_writeres(struct svc_rqst *, __u32 *, struct nfsd3_writeres *);
++int nfs3svc_encode_createres(struct svc_rqst *, __u32 *,
+ struct nfsd3_diropres *);
+-int nfs3svc_encode_renameres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_renameres(struct svc_rqst *, __u32 *,
+ struct nfsd3_renameres *);
+-int nfs3svc_encode_linkres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_linkres(struct svc_rqst *, __u32 *,
+ struct nfsd3_linkres *);
+-int nfs3svc_encode_readdirres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_readdirres(struct svc_rqst *, __u32 *,
+ struct nfsd3_readdirres *);
+-int nfs3svc_encode_fsstatres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_fsstatres(struct svc_rqst *, __u32 *,
+ struct nfsd3_fsstatres *);
+-int nfs3svc_encode_fsinfores(struct svc_rqst *, u32 *,
++int nfs3svc_encode_fsinfores(struct svc_rqst *, __u32 *,
+ struct nfsd3_fsinfores *);
+-int nfs3svc_encode_pathconfres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_pathconfres(struct svc_rqst *, __u32 *,
+ struct nfsd3_pathconfres *);
+-int nfs3svc_encode_commitres(struct svc_rqst *, u32 *,
++int nfs3svc_encode_commitres(struct svc_rqst *, __u32 *,
+ struct nfsd3_commitres *);
+
+-int nfs3svc_release_fhandle(struct svc_rqst *, u32 *,
++int nfs3svc_release_fhandle(struct svc_rqst *, __u32 *,
+ struct nfsd3_attrstat *);
+-int nfs3svc_release_fhandle2(struct svc_rqst *, u32 *,
++int nfs3svc_release_fhandle2(struct svc_rqst *, __u32 *,
+ struct nfsd3_fhandle_pair *);
+ int nfs3svc_encode_entry(struct readdir_cd *, const char *name,
+ int namlen, loff_t offset, ino_t ino,
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr4.h linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr4.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/nfsd/xdr4.h 2004-08-18 13:16:07.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/nfsd/xdr4.h 2004-08-26 05:42:08.000000000 -0500
+@@ -42,9 +42,9 @@
+ #define NFSD4_MAX_TAGLEN 128
+ #define XDR_LEN(n) (((n) + 3) & ~3)
+
+-typedef u32 delegation_zero_t;
+-typedef u32 delegation_boot_t;
+-typedef u64 delegation_id_t;
++typedef __u32 delegation_zero_t;
++typedef __u32 delegation_boot_t;
++typedef __u64 delegation_id_t;
+
+ typedef struct {
+ delegation_zero_t ds_zero;
+@@ -53,46 +53,46 @@
+ } delegation_stateid_t;
+
+ struct nfsd4_change_info {
+- u32 atomic;
+- u32 before_ctime_sec;
+- u32 before_ctime_nsec;
+- u32 after_ctime_sec;
+- u32 after_ctime_nsec;
++ __u32 atomic;
++ __u32 before_ctime_sec;
++ __u32 before_ctime_nsec;
++ __u32 after_ctime_sec;
++ __u32 after_ctime_nsec;
+ };
+
+ struct nfsd4_access {
+- u32 ac_req_access; /* request */
+- u32 ac_supported; /* response */
+- u32 ac_resp_access; /* response */
++ __u32 ac_req_access; /* request */
++ __u32 ac_supported; /* response */
++ __u32 ac_resp_access; /* response */
+ };
+
+ struct nfsd4_close {
+- u32 cl_seqid; /* request */
++ __u32 cl_seqid; /* request */
+ stateid_t cl_stateid; /* request+response */
+ struct nfs4_stateowner * cl_stateowner; /* response */
+ };
+
+ struct nfsd4_commit {
+- u64 co_offset; /* request */
+- u32 co_count; /* request */
++ __u64 co_offset; /* request */
++ __u32 co_count; /* request */
+ nfs4_verifier co_verf; /* response */
+ };
+
+ struct nfsd4_create {
+- u32 cr_namelen; /* request */
++ __u32 cr_namelen; /* request */
+ char * cr_name; /* request */
+- u32 cr_type; /* request */
++ __u32 cr_type; /* request */
+ union { /* request */
+ struct {
+- u32 namelen;
++ __u32 namelen;
+ char *name;
+ } link; /* NF4LNK */
+ struct {
+- u32 specdata1;
+- u32 specdata2;
++ __u32 specdata1;
++ __u32 specdata2;
+ } dev; /* NF4BLK, NF4CHR */
+ } u;
+- u32 cr_bmval[2]; /* request */
++ __u32 cr_bmval[2]; /* request */
+ struct iattr cr_iattr; /* request */
+ struct nfsd4_change_info cr_cinfo; /* response */
+ };
+@@ -102,41 +102,41 @@
+ #define cr_specdata2 u.dev.specdata2
+
+ struct nfsd4_getattr {
+- u32 ga_bmval[2]; /* request */
++ __u32 ga_bmval[2]; /* request */
+ struct svc_fh *ga_fhp; /* response */
+ };
+
+ struct nfsd4_link {
+- u32 li_namelen; /* request */
++ __u32 li_namelen; /* request */
+ char * li_name; /* request */
+ struct nfsd4_change_info li_cinfo; /* response */
+ };
+
+ struct nfsd4_lock_denied {
+ struct nfs4_stateowner *ld_sop;
+- u64 ld_start;
+- u64 ld_length;
+- u32 ld_type;
++ __u64 ld_start;
++ __u64 ld_length;
++ __u32 ld_type;
+ };
+
+ struct nfsd4_lock {
+ /* request */
+- u32 lk_type;
+- u32 lk_reclaim; /* boolean */
+- u64 lk_offset;
+- u64 lk_length;
+- u32 lk_is_new;
++ __u32 lk_type;
++ __u32 lk_reclaim; /* boolean */
++ __u64 lk_offset;
++ __u64 lk_length;
++ __u32 lk_is_new;
+ union {
+ struct {
+- u32 open_seqid;
++ __u32 open_seqid;
+ stateid_t open_stateid;
+- u32 lock_seqid;
++ __u32 lock_seqid;
+ clientid_t clientid;
+ struct xdr_netobj owner;
+ } new;
+ struct {
+ stateid_t lock_stateid;
+- u32 lock_seqid;
++ __u32 lock_seqid;
+ } old;
+ } v;
+
+@@ -164,56 +164,56 @@
+
+
+ struct nfsd4_lockt {
+- u32 lt_type;
++ __u32 lt_type;
+ clientid_t lt_clientid;
+ struct xdr_netobj lt_owner;
+- u64 lt_offset;
+- u64 lt_length;
++ __u64 lt_offset;
++ __u64 lt_length;
+ struct nfs4_stateowner * lt_stateowner;
+ struct nfsd4_lock_denied lt_denied;
+ };
+
+
+ struct nfsd4_locku {
+- u32 lu_type;
+- u32 lu_seqid;
++ __u32 lu_type;
++ __u32 lu_seqid;
+ stateid_t lu_stateid;
+- u64 lu_offset;
+- u64 lu_length;
++ __u64 lu_offset;
++ __u64 lu_length;
+ struct nfs4_stateowner *lu_stateowner;
+ };
+
+
+ struct nfsd4_lookup {
+- u32 lo_len; /* request */
++ __u32 lo_len; /* request */
+ char * lo_name; /* request */
+ };
+
+ struct nfsd4_putfh {
+- u32 pf_fhlen; /* request */
++ __u32 pf_fhlen; /* request */
+ char *pf_fhval; /* request */
+ };
+
+ struct nfsd4_open {
+- u32 op_claim_type; /* request */
++ __u32 op_claim_type; /* request */
+ struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
+- u32 op_delegate_type; /* request - CLAIM_PREV only */
++ __u32 op_delegate_type; /* request - CLAIM_PREV only */
+ delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */
+- u32 op_create; /* request */
+- u32 op_createmode; /* request */
+- u32 op_bmval[2]; /* request */
++ __u32 op_create; /* request */
++ __u32 op_createmode; /* request */
++ __u32 op_bmval[2]; /* request */
+ union { /* request */
+ struct iattr iattr; /* UNCHECKED4,GUARDED4 */
+ nfs4_verifier verf; /* EXCLUSIVE4 */
+ } u;
+ clientid_t op_clientid; /* request */
+ struct xdr_netobj op_owner; /* request */
+- u32 op_seqid; /* request */
+- u32 op_share_access; /* request */
+- u32 op_share_deny; /* request */
++ __u32 op_seqid; /* request */
++ __u32 op_share_access; /* request */
++ __u32 op_share_deny; /* request */
+ stateid_t op_stateid; /* response */
+ struct nfsd4_change_info op_cinfo; /* response */
+- u32 op_rflags; /* response */
++ __u32 op_rflags; /* response */
+ int op_truncate; /* used during processing */
+ struct nfs4_stateowner *op_stateowner; /* used during processing */
+
+@@ -223,24 +223,24 @@
+
+ struct nfsd4_open_confirm {
+ stateid_t oc_req_stateid /* request */;
+- u32 oc_seqid /* request */;
++ __u32 oc_seqid /* request */;
+ stateid_t oc_resp_stateid /* response */;
+ struct nfs4_stateowner * oc_stateowner; /* response */
+ };
+
+ struct nfsd4_open_downgrade {
+ stateid_t od_stateid;
+- u32 od_seqid;
+- u32 od_share_access;
+- u32 od_share_deny;
++ __u32 od_seqid;
++ __u32 od_share_access;
++ __u32 od_share_deny;
+ struct nfs4_stateowner *od_stateowner;
+ };
+
+
+ struct nfsd4_read {
+ stateid_t rd_stateid; /* request */
+- u64 rd_offset; /* request */
+- u32 rd_length; /* request */
++ __u64 rd_offset; /* request */
++ __u32 rd_length; /* request */
+ struct kvec rd_iov[RPCSVC_MAXPAGES];
+ int rd_vlen;
+
+@@ -249,18 +249,18 @@
+ };
+
+ struct nfsd4_readdir {
+- u64 rd_cookie; /* request */
++ __u64 rd_cookie; /* request */
+ nfs4_verifier rd_verf; /* request */
+- u32 rd_dircount; /* request */
+- u32 rd_maxcount; /* request */
+- u32 rd_bmval[2]; /* request */
++ __u32 rd_dircount; /* request */
++ __u32 rd_maxcount; /* request */
++ __u32 rd_bmval[2]; /* request */
+ struct svc_rqst *rd_rqstp; /* response */
+ struct svc_fh * rd_fhp; /* response */
+
+ struct readdir_cd common;
+- u32 * buffer;
++ __u32 * buffer;
+ int buflen;
+- u32 * offset;
++ __u32 * offset;
+ };
+
+ struct nfsd4_release_lockowner {
+@@ -273,15 +273,15 @@
+ };
+
+ struct nfsd4_remove {
+- u32 rm_namelen; /* request */
++ __u32 rm_namelen; /* request */
+ char * rm_name; /* request */
+ struct nfsd4_change_info rm_cinfo; /* response */
+ };
+
+ struct nfsd4_rename {
+- u32 rn_snamelen; /* request */
++ __u32 rn_snamelen; /* request */
+ char * rn_sname; /* request */
+- u32 rn_tnamelen; /* request */
++ __u32 rn_tnamelen; /* request */
+ char * rn_tname; /* request */
+ struct nfsd4_change_info rn_sinfo; /* response */
+ struct nfsd4_change_info rn_tinfo; /* response */
+@@ -289,20 +289,20 @@
+
+ struct nfsd4_setattr {
+ stateid_t sa_stateid; /* request */
+- u32 sa_bmval[2]; /* request */
++ __u32 sa_bmval[2]; /* request */
+ struct iattr sa_iattr; /* request */
+ };
+
+ struct nfsd4_setclientid {
+ nfs4_verifier se_verf; /* request */
+- u32 se_namelen; /* request */
++ __u32 se_namelen; /* request */
+ char * se_name; /* request */
+- u32 se_callback_prog; /* request */
+- u32 se_callback_netid_len; /* request */
++ __u32 se_callback_prog; /* request */
++ __u32 se_callback_netid_len; /* request */
+ char * se_callback_netid_val; /* request */
+- u32 se_callback_addr_len; /* request */
++ __u32 se_callback_addr_len; /* request */
+ char * se_callback_addr_val; /* request */
+- u32 se_callback_ident; /* request */
++ __u32 se_callback_ident; /* request */
+ clientid_t se_clientid; /* response */
+ nfs4_verifier se_confirm; /* response */
+ };
+@@ -314,21 +314,21 @@
+
+ /* also used for NVERIFY */
+ struct nfsd4_verify {
+- u32 ve_bmval[2]; /* request */
+- u32 ve_attrlen; /* request */
++ __u32 ve_bmval[2]; /* request */
++ __u32 ve_attrlen; /* request */
+ char * ve_attrval; /* request */
+ };
+
+ struct nfsd4_write {
+ stateid_t wr_stateid; /* request */
+- u64 wr_offset; /* request */
+- u32 wr_stable_how; /* request */
+- u32 wr_buflen; /* request */
++ __u64 wr_offset; /* request */
++ __u32 wr_stable_how; /* request */
++ __u32 wr_buflen; /* request */
+ struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
+ int wr_vlen;
+
+- u32 wr_bytes_written; /* response */
+- u32 wr_how_written; /* response */
++ __u32 wr_bytes_written; /* response */
++ __u32 wr_how_written; /* response */
+ nfs4_verifier wr_verifier; /* response */
+ };
+
+@@ -370,12 +370,12 @@
+
+ struct nfsd4_compoundargs {
+ /* scratch variables for XDR decode */
+- u32 * p;
+- u32 * end;
++ __u32 * p;
++ __u32 * end;
+ struct page ** pagelist;
+ int pagelen;
+- u32 tmp[8];
+- u32 * tmpp;
++ __u32 tmp[8];
++ __u32 * tmpp;
+ struct tmpbuf {
+ struct tmpbuf *next;
+ void (*release)(const void *);
+@@ -384,25 +384,25 @@
+
+ struct svc_rqst *rqstp;
+
+- u32 taglen;
++ __u32 taglen;
+ char * tag;
+- u32 minorversion;
+- u32 opcnt;
++ __u32 minorversion;
++ __u32 opcnt;
+ struct nfsd4_op *ops;
+ struct nfsd4_op iops[8];
+ };
+
+ struct nfsd4_compoundres {
+ /* scratch variables for XDR encode */
+- u32 * p;
+- u32 * end;
++ __u32 * p;
++ __u32 * end;
+ struct xdr_buf * xbuf;
+ struct svc_rqst * rqstp;
+
+- u32 taglen;
++ __u32 taglen;
+ char * tag;
+- u32 opcnt;
+- u32 * tagp; /* where to encode tag and opcount */
++ __u32 opcnt;
++ __u32 * tagp; /* where to encode tag and opcount */
+ };
+
+ #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
+@@ -418,16 +418,16 @@
+ cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
+ }
+
+-int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *);
+-int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *,
++int nfs4svc_encode_voidres(struct svc_rqst *, __u32 *, void *);
++int nfs4svc_decode_compoundargs(struct svc_rqst *, __u32 *,
+ struct nfsd4_compoundargs *);
+-int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *,
++int nfs4svc_encode_compoundres(struct svc_rqst *, __u32 *,
+ struct nfsd4_compoundres *);
+ void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
+ void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
+ int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
+- struct dentry *dentry, u32 *buffer, int *countp,
+- u32 *bmval, struct svc_rqst *);
++ struct dentry *dentry, __u32 *buffer, int *countp,
++ __u32 *bmval, struct svc_rqst *);
+ extern int nfsd4_setclientid(struct svc_rqst *rqstp,
+ struct nfsd4_setclientid *setclid);
+ extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/pmu.h linux-libc-headers-2.6.8.0/include/linux/pmu.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/pmu.h 2004-01-17 17:04:31.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/pmu.h 2004-08-26 05:42:08.000000000 -0500
+@@ -120,15 +120,15 @@
+
+ /* no param */
+ #define PMU_IOC_SLEEP _IO('B', 0)
+-/* out param: u32* backlight value: 0 to 15 */
++/* out param: __u32* backlight value: 0 to 15 */
+ #define PMU_IOC_GET_BACKLIGHT _IOR('B', 1, size_t)
+-/* in param: u32 backlight value: 0 to 15 */
++/* in param: __u32 backlight value: 0 to 15 */
+ #define PMU_IOC_SET_BACKLIGHT _IOW('B', 2, size_t)
+-/* out param: u32* PMU model */
++/* out param: __u32* PMU model */
+ #define PMU_IOC_GET_MODEL _IOR('B', 3, size_t)
+-/* out param: u32* has_adb: 0 or 1 */
++/* out param: __u32* has_adb: 0 or 1 */
+ #define PMU_IOC_HAS_ADB _IOR('B', 4, size_t)
+-/* out param: u32* can_sleep: 0 or 1 */
++/* out param: __u32* can_sleep: 0 or 1 */
+ #define PMU_IOC_CAN_SLEEP _IOR('B', 5, size_t)
+ /* no param, but historically was _IOR('B', 6, 0), meaning 4 bytes */
+ #define PMU_IOC_GRAB_BACKLIGHT _IOR('B', 6, size_t)
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/reiserfs_fs.h linux-libc-headers-2.6.8.0/include/linux/reiserfs_fs.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/reiserfs_fs.h 2004-08-18 13:16:04.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/reiserfs_fs.h 2004-08-26 13:26:06.000000000 -0500
+@@ -1821,7 +1821,7 @@
+ * to use for a new object underneat it. The locality is returned
+ * in disk byte order (le).
+ */
+-u32 reiserfs_choose_packing(struct inode *dir);
++__u32 reiserfs_choose_packing(struct inode *dir);
+
+ int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value);
+ void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/scx200_gpio.h linux-libc-headers-2.6.8.0/include/linux/scx200_gpio.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/scx200_gpio.h 2004-01-17 17:04:32.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/scx200_gpio.h 2004-08-26 13:26:01.000000000 -0500
+@@ -1,5 +1,5 @@
+
+-u32 scx200_gpio_configure(int index, u32 set, u32 clear);
++__u32 scx200_gpio_configure(int index, __u32 set, __u32 clear);
+ void scx200_gpio_dump(unsigned index);
+
+ extern unsigned scx200_gpio_base;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sdladrv.h linux-libc-headers-2.6.8.0/include/linux/sdladrv.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sdladrv.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/sdladrv.h 2004-08-26 05:42:08.000000000 -0500
+@@ -55,8 +55,8 @@
+ extern int sdla_inten (sdlahw_t* hw);
+ extern int sdla_intde (sdlahw_t* hw);
+ extern int sdla_intack (sdlahw_t* hw);
+-extern void S514_intack (sdlahw_t* hw, u32 int_status);
+-extern void read_S514_int_stat (sdlahw_t* hw, u32* int_status);
++extern void S514_intack (sdlahw_t* hw, __u32 int_status);
++extern void read_S514_int_stat (sdlahw_t* hw, __u32* int_status);
+ extern int sdla_intr (sdlahw_t* hw);
+ extern int sdla_mapmem (sdlahw_t* hw, unsigned long addr);
+ extern int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf,
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/selection.h linux-libc-headers-2.6.8.0/include/linux/selection.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/selection.h 2004-06-23 16:52:56.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/selection.h 2004-08-26 05:42:08.000000000 -0500
+@@ -32,14 +32,14 @@
+ extern int default_blu[];
+
+ extern unsigned short *screen_pos(int currcons, int w_offset, int viewed);
+-extern u16 screen_glyph(int currcons, int offset);
++extern __u16 screen_glyph(int currcons, int offset);
+ extern void complement_pos(int currcons, int offset);
+ extern void invert_screen(int currcons, int offset, int count, int shift);
+
+ extern void getconsxy(int currcons, unsigned char *p);
+ extern void putconsxy(int currcons, unsigned char *p);
+
+-extern u16 vcs_scr_readw(int currcons, const u16 *org);
+-extern void vcs_scr_writew(int currcons, u16 val, u16 *org);
++extern __u16 vcs_scr_readw(int currcons, const __u16 *org);
++extern void vcs_scr_writew(int currcons, __u16 val, __u16 *org);
+
+ #endif
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/serialP.h linux-libc-headers-2.6.8.0/include/linux/serialP.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/serialP.h 2004-08-18 13:16:04.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/serialP.h 2004-08-26 05:42:08.000000000 -0500
+@@ -39,8 +39,8 @@
+ int xmit_fifo_size;
+ int custom_divisor;
+ int count;
+- u8 *iomem_base;
+- u16 iomem_reg_shift;
++ __u8 *iomem_base;
++ __u16 iomem_reg_shift;
+ unsigned short close_delay;
+ unsigned short closing_wait; /* time to wait before closing */
+ struct async_icount icount;
+@@ -75,8 +75,8 @@
+ int blocked_open; /* # of blocked opens */
+ struct circ_buf xmit;
+ spinlock_t xmit_lock;
+- u8 *iomem_base;
+- u16 iomem_reg_shift;
++ __u8 *iomem_base;
++ __u16 iomem_reg_shift;
+ int io_type;
+ struct work_struct work;
+ struct tasklet_struct tlet;
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/clnt.h linux-libc-headers-2.6.8.0/include/linux/sunrpc/clnt.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/clnt.h 2004-02-29 10:36:05.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/sunrpc/clnt.h 2004-08-26 05:42:08.000000000 -0500
+@@ -36,7 +36,7 @@
+ atomic_t cl_users; /* number of references */
+ struct rpc_xprt * cl_xprt; /* transport */
+ struct rpc_procinfo * cl_procinfo; /* procedure info */
+- u32 cl_maxproc; /* max procedure number */
++ __u32 cl_maxproc; /* max procedure number */
+
+ char * cl_server; /* server machine name */
+ char * cl_protname; /* protocol name */
+@@ -75,7 +75,7 @@
+ #define RPC_MAXVERSION 4
+ struct rpc_program {
+ char * name; /* protocol name */
+- u32 number; /* program number */
++ __u32 number; /* program number */
+ unsigned int nrvers; /* number of versions */
+ struct rpc_version ** version; /* version array */
+ struct rpc_stat * stats; /* statistics */
+@@ -83,7 +83,7 @@
+ };
+
+ struct rpc_version {
+- u32 number; /* version number */
++ __u32 number; /* version number */
+ unsigned int nrprocs; /* number of procs */
+ struct rpc_procinfo * procs; /* procedure array */
+ };
+@@ -92,7 +92,7 @@
+ * Procedure information
+ */
+ struct rpc_procinfo {
+- u32 p_proc; /* RPC procedure number */
++ __u32 p_proc; /* RPC procedure number */
+ kxdrproc_t p_encode; /* XDR encode function */
+ kxdrproc_t p_decode; /* XDR decode function */
+ unsigned int p_bufsiz; /* req. buffer size */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/gss_asn1.h linux-libc-headers-2.6.8.0/include/linux/sunrpc/gss_asn1.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/gss_asn1.h 2004-06-23 16:52:58.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/sunrpc/gss_asn1.h 2004-08-26 13:26:25.000000000 -0500
+@@ -64,14 +64,14 @@
+ (((o1)->len == (o2)->len) && \
+ (memcmp((o1)->data,(o2)->data,(int) (o1)->len) == 0))
+
+-u32 g_verify_token_header(
++__u32 g_verify_token_header(
+ struct xdr_netobj *mech,
+ int *body_size,
+ unsigned char **buf_in,
+ int tok_type,
+ int toksize);
+
+-u32 g_get_mech_oid(struct xdr_netobj *mech, struct xdr_netobj * in_buf);
++__u32 g_get_mech_oid(struct xdr_netobj *mech, struct xdr_netobj * in_buf);
+
+ int g_token_size(
+ struct xdr_netobj *mech,
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/gss_krb5.h linux-libc-headers-2.6.8.0/include/linux/sunrpc/gss_krb5.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/gss_krb5.h 2004-06-23 16:52:58.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/sunrpc/gss_krb5.h 2004-08-26 13:26:21.000000000 -0500
+@@ -46,8 +46,8 @@
+ int sealalg;
+ struct crypto_tfm *enc;
+ struct crypto_tfm *seq;
+- s32 endtime;
+- u32 seq_send;
++ __s32 endtime;
++ __u32 seq_send;
+ struct xdr_netobj mech_used;
+ };
+
+@@ -112,35 +112,35 @@
+ #define ENCTYPE_DES3_CBC_SHA1 0x0010
+ #define ENCTYPE_UNKNOWN 0x01ff
+
+-s32
+-make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
++__s32
++make_checksum(__s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
+ struct xdr_netobj *cksum);
+
+-u32
++__u32
+ krb5_make_token(struct krb5_ctx *context_handle, int qop_req,
+ struct xdr_buf *input_message_buffer,
+ struct xdr_netobj *output_message_buffer, int toktype);
+
+-u32
++__u32
+ krb5_read_token(struct krb5_ctx *context_handle,
+ struct xdr_netobj *input_token_buffer,
+ struct xdr_buf *message_buffer,
+ int *qop_state, int toktype);
+
+-u32
++__u32
+ krb5_encrypt(struct crypto_tfm * key,
+ void *iv, void *in, void *out, int length);
+
+-u32
++__u32
+ krb5_decrypt(struct crypto_tfm * key,
+ void *iv, void *in, void *out, int length);
+
+-s32
++__s32
+ krb5_make_seq_num(struct crypto_tfm * key,
+ int direction,
+- s32 seqnum, unsigned char *cksum, unsigned char *buf);
++ __s32 seqnum, unsigned char *cksum, unsigned char *buf);
+
+-s32
++__s32
+ krb5_get_seq_num(struct crypto_tfm * key,
+ unsigned char *cksum,
+- unsigned char *buf, int *direction, s32 * seqnum);
++ unsigned char *buf, int *direction, __s32 * seqnum);
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/svc.h linux-libc-headers-2.6.8.0/include/linux/sunrpc/svc.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/svc.h 2004-08-18 13:16:07.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/sunrpc/svc.h 2004-08-26 05:42:08.000000000 -0500
+@@ -75,20 +75,20 @@
+ */
+ #define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2)
+
+-static inline u32 svc_getu32(struct kvec *iov)
++static inline __u32 svc_getu32(struct kvec *iov)
+ {
+- u32 val, *vp;
++ __u32 val, *vp;
+ vp = iov->iov_base;
+ val = *vp++;
+ iov->iov_base = (void*)vp;
+- iov->iov_len -= sizeof(u32);
++ iov->iov_len -= sizeof(__u32);
+ return val;
+ }
+-static inline void svc_putu32(struct kvec *iov, u32 val)
++static inline void svc_putu32(struct kvec *iov, __u32 val)
+ {
+- u32 *vp = iov->iov_base + iov->iov_len;
++ __u32 *vp = iov->iov_base + iov->iov_len;
+ *vp = val;
+- iov->iov_len += sizeof(u32);
++ iov->iov_len += sizeof(__u32);
+ }
+
+
+@@ -119,11 +119,11 @@
+ short rq_arghi; /* pages available in argument page list */
+ short rq_resused; /* pages used for result */
+
+- u32 rq_xid; /* transmission id */
+- u32 rq_prog; /* program number */
+- u32 rq_vers; /* program version */
+- u32 rq_proc; /* procedure number */
+- u32 rq_prot; /* IP protocol */
++ __u32 rq_xid; /* transmission id */
++ __u32 rq_prog; /* program number */
++ __u32 rq_vers; /* program version */
++ __u32 rq_proc; /* procedure number */
++ __u32 rq_prot; /* IP protocol */
+ unsigned short
+ rq_secure : 1; /* secure port */
+
+@@ -156,7 +156,7 @@
+ * Check buffer bounds after decoding arguments
+ */
+ static inline int
+-xdr_argsize_check(struct svc_rqst *rqstp, u32 *p)
++xdr_argsize_check(struct svc_rqst *rqstp, __u32 *p)
+ {
+ char *cp = (char *)p;
+ struct kvec *vec = &rqstp->rq_arg.head[0];
+@@ -164,7 +164,7 @@
+ }
+
+ static inline int
+-xdr_ressize_check(struct svc_rqst *rqstp, u32 *p)
++xdr_ressize_check(struct svc_rqst *rqstp, __u32 *p)
+ {
+ struct kvec *vec = &rqstp->rq_res.head[0];
+ char *cp = (char*)p;
+@@ -220,19 +220,19 @@
+ }
+
+ struct svc_deferred_req {
+- u32 prot; /* protocol (UDP or TCP) */
++ __u32 prot; /* protocol (UDP or TCP) */
+ struct sockaddr_in addr;
+ struct svc_sock *svsk; /* where reply must go */
+ struct cache_deferred_req handle;
+ int argslen;
+- u32 args[0];
++ __u32 args[0];
+ };
+
+ /*
+ * RPC program
+ */
+ struct svc_program {
+- u32 pg_prog; /* program number */
++ __u32 pg_prog; /* program number */
+ unsigned int pg_lovers; /* lowest version */
+ unsigned int pg_hivers; /* lowest version */
+ unsigned int pg_nvers; /* number of versions */
+@@ -246,16 +246,16 @@
+ * RPC program version
+ */
+ struct svc_version {
+- u32 vs_vers; /* version number */
+- u32 vs_nproc; /* number of procedures */
++ __u32 vs_vers; /* version number */
++ __u32 vs_nproc; /* number of procedures */
+ struct svc_procedure * vs_proc; /* per-procedure info */
+- u32 vs_xdrsize; /* xdrsize needed for this version */
++ __u32 vs_xdrsize; /* xdrsize needed for this version */
+
+ /* Override dispatch function (e.g. when caching replies).
+ * A return value of 0 means drop the request.
+ * vs_dispatch == NULL means use default dispatcher.
+ */
+- int (*vs_dispatch)(struct svc_rqst *, u32 *);
++ int (*vs_dispatch)(struct svc_rqst *, __u32 *);
+ };
+
+ /*
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/xprt.h linux-libc-headers-2.6.8.0/include/linux/sunrpc/xprt.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sunrpc/xprt.h 2004-06-23 16:52:58.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/sunrpc/xprt.h 2004-08-26 05:42:08.000000000 -0500
+@@ -93,7 +93,7 @@
+ __u32 rq_xid; /* request XID */
+ int rq_cong; /* has incremented xprt->cong */
+ int rq_received; /* receive completed */
+- u32 rq_seqno; /* gss seq no. used on req. */
++ __u32 rq_seqno; /* gss seq no. used on req. */
+
+ struct list_head rq_list;
+
+@@ -106,13 +106,13 @@
+ /*
+ * For authentication (e.g. auth_des)
+ */
+- u32 rq_creddata[2];
++ __u32 rq_creddata[2];
+
+ /*
+ * Partial send handling
+ */
+
+- u32 rq_bytes_sent; /* Bytes we have sent */
++ __u32 rq_bytes_sent; /* Bytes we have sent */
+
+ unsigned long rq_xtime; /* when transmitted */
+ int rq_ntrans;
+@@ -160,7 +160,7 @@
+ /*
+ * State of TCP reply receive stuff
+ */
+- u32 tcp_recm, /* Fragment header */
++ __u32 tcp_recm, /* Fragment header */
+ tcp_xid, /* Current XID */
+ tcp_reclen, /* fragment length */
+ tcp_offset; /* fragment offset */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/suspend.h linux-libc-headers-2.6.8.0/include/linux/suspend.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/suspend.h 2004-08-18 13:16:05.000000000 -0500
++++ linux-libc-headers-2.6.8.0/include/linux/suspend.h 2004-08-26 05:42:08.000000000 -0500
+@@ -23,7 +23,7 @@
+ #define SWAP_FILENAME_MAXLENGTH 32
+
+ struct suspend_header {
+- u32 version_code;
++ __u32 version_code;
+ unsigned long num_physpages;
+ char machine[8];
+ char version[20];
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sysdev.h linux-libc-headers-2.6.8.0/include/linux/sysdev.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sysdev.h 2004-03-28 07:52:11.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/sysdev.h 2004-08-26 05:42:08.000000000 -0500
+@@ -31,7 +31,7 @@
+
+ /* Default operations for these types of devices */
+ int (*shutdown)(struct sys_device *);
+- int (*suspend)(struct sys_device *, u32 state);
++ int (*suspend)(struct sys_device *, __u32 state);
+ int (*resume)(struct sys_device *);
+ struct kset kset;
+ };
+@@ -50,7 +50,7 @@
+ int (*add)(struct sys_device *);
+ int (*remove)(struct sys_device *);
+ int (*shutdown)(struct sys_device *);
+- int (*suspend)(struct sys_device *, u32 state);
++ int (*suspend)(struct sys_device *, __u32 state);
+ int (*resume)(struct sys_device *);
+ };
+
+@@ -65,7 +65,7 @@
+ */
+
+ struct sys_device {
+- u32 id;
++ __u32 id;
+ struct sysdev_class * cls;
+ struct kobject kobj;
+ };
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/sysv_fs.h linux-libc-headers-2.6.8.0/include/linux/sysv_fs.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/sysv_fs.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/sysv_fs.h 2004-08-26 05:42:08.000000000 -0500
+@@ -9,12 +9,12 @@
+
+
+ /* inode numbers are 16 bit */
+-typedef u16 sysv_ino_t;
++typedef __u16 sysv_ino_t;
+
+ /* Block numbers are 24 bit, sometimes stored in 32 bit.
+ On Coherent FS, they are always stored in PDP-11 manner: the least
+ significant 16 bits come last. */
+-typedef u32 sysv_zone_t;
++typedef __u32 sysv_zone_t;
+
+ /* 0 is non-existent */
+ #define SYSV_BADBL_INO 1 /* inode of bad blocks file */
+@@ -25,29 +25,29 @@
+ #define XENIX_NICINOD 100 /* number of inode cache entries */
+ #define XENIX_NICFREE 100 /* number of free block list chunk entries */
+ struct xenix_super_block {
+- u16 s_isize; /* index of first data zone */
+- u32 s_fsize __packed2__; /* total number of zones of this fs */
++ __u16 s_isize; /* index of first data zone */
++ __u32 s_fsize __packed2__; /* total number of zones of this fs */
+ /* the start of the free block list: */
+- u16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
+- u32 s_free[XENIX_NICFREE]; /* first free block list chunk */
++ __u16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
++ __u32 s_free[XENIX_NICFREE]; /* first free block list chunk */
+ /* the cache of free inodes: */
+- u16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
++ __u16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
+ sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */
+ /* locks, not used by Linux: */
+ char s_flock; /* lock during free block list manipulation */
+ char s_ilock; /* lock during inode cache manipulation */
+ char s_fmod; /* super-block modified flag */
+ char s_ronly; /* flag whether fs is mounted read-only */
+- u32 s_time __packed2__; /* time of last super block update */
+- u32 s_tfree __packed2__; /* total number of free zones */
+- u16 s_tinode; /* total number of free inodes */
+- s16 s_dinfo[4]; /* device information ?? */
++ __u32 s_time __packed2__; /* time of last super block update */
++ __u32 s_tfree __packed2__; /* total number of free zones */
++ __u16 s_tinode; /* total number of free inodes */
++ __s16 s_dinfo[4]; /* device information ?? */
+ char s_fname[6]; /* file system volume name */
+ char s_fpack[6]; /* file system pack name */
+ char s_clean; /* set to 0x46 when filesystem is properly unmounted */
+ char s_fill[371];
+- s32 s_magic; /* version of file system */
+- s32 s_type; /* type of file system: 1 for 512 byte blocks
++ __s32 s_magic; /* version of file system */
++ __s32 s_type; /* type of file system: 1 for 512 byte blocks
+ 2 for 1024 byte blocks
+ 3 for 2048 byte blocks */
+
+@@ -63,61 +63,61 @@
+
+ /* SystemV4 super-block data on disk */
+ struct sysv4_super_block {
+- u16 s_isize; /* index of first data zone */
+- u16 s_pad0;
+- u32 s_fsize; /* total number of zones of this fs */
++ __u16 s_isize; /* index of first data zone */
++ __u16 s_pad0;
++ __u32 s_fsize; /* total number of zones of this fs */
+ /* the start of the free block list: */
+- u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
+- u16 s_pad1;
+- u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
++ __u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
++ __u16 s_pad1;
++ __u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
+ /* the cache of free inodes: */
+- u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
+- u16 s_pad2;
++ __u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
++ __u16 s_pad2;
+ sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
+ /* locks, not used by Linux: */
+ char s_flock; /* lock during free block list manipulation */
+ char s_ilock; /* lock during inode cache manipulation */
+ char s_fmod; /* super-block modified flag */
+ char s_ronly; /* flag whether fs is mounted read-only */
+- u32 s_time; /* time of last super block update */
+- s16 s_dinfo[4]; /* device information ?? */
+- u32 s_tfree; /* total number of free zones */
+- u16 s_tinode; /* total number of free inodes */
+- u16 s_pad3;
++ __u32 s_time; /* time of last super block update */
++ __s16 s_dinfo[4]; /* device information ?? */
++ __u32 s_tfree; /* total number of free zones */
++ __u16 s_tinode; /* total number of free inodes */
++ __u16 s_pad3;
+ char s_fname[6]; /* file system volume name */
+ char s_fpack[6]; /* file system pack name */
+- s32 s_fill[12];
+- s32 s_state; /* file system state: 0x7c269d38-s_time means clean */
+- s32 s_magic; /* version of file system */
+- s32 s_type; /* type of file system: 1 for 512 byte blocks
++ __s32 s_fill[12];
++ __s32 s_state; /* file system state: 0x7c269d38-s_time means clean */
++ __s32 s_magic; /* version of file system */
++ __s32 s_type; /* type of file system: 1 for 512 byte blocks
+ 2 for 1024 byte blocks */
+ };
+
+ /* SystemV2 super-block data on disk */
+ struct sysv2_super_block {
+- u16 s_isize; /* index of first data zone */
+- u32 s_fsize __packed2__; /* total number of zones of this fs */
++ __u16 s_isize; /* index of first data zone */
++ __u32 s_fsize __packed2__; /* total number of zones of this fs */
+ /* the start of the free block list: */
+- u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
+- u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
++ __u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
++ __u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
+ /* the cache of free inodes: */
+- u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
++ __u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
+ sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
+ /* locks, not used by Linux: */
+ char s_flock; /* lock during free block list manipulation */
+ char s_ilock; /* lock during inode cache manipulation */
+ char s_fmod; /* super-block modified flag */
+ char s_ronly; /* flag whether fs is mounted read-only */
+- u32 s_time __packed2__; /* time of last super block update */
+- s16 s_dinfo[4]; /* device information ?? */
+- u32 s_tfree __packed2__; /* total number of free zones */
+- u16 s_tinode; /* total number of free inodes */
++ __u32 s_time __packed2__; /* time of last super block update */
++ __s16 s_dinfo[4]; /* device information ?? */
++ __u32 s_tfree __packed2__; /* total number of free zones */
++ __u16 s_tinode; /* total number of free inodes */
+ char s_fname[6]; /* file system volume name */
+ char s_fpack[6]; /* file system pack name */
+- s32 s_fill[14];
+- s32 s_state; /* file system state: 0xcb096f43 means clean */
+- s32 s_magic; /* version of file system */
+- s32 s_type; /* type of file system: 1 for 512 byte blocks
++ __s32 s_fill[14];
++ __s32 s_state; /* file system state: 0xcb096f43 means clean */
++ __s32 s_magic; /* version of file system */
++ __s32 s_type; /* type of file system: 1 for 512 byte blocks
+ 2 for 1024 byte blocks */
+ };
+
+@@ -125,25 +125,25 @@
+ #define V7_NICINOD 100 /* number of inode cache entries */
+ #define V7_NICFREE 50 /* number of free block list chunk entries */
+ struct v7_super_block {
+- u16 s_isize; /* index of first data zone */
+- u32 s_fsize __packed2__; /* total number of zones of this fs */
++ __u16 s_isize; /* index of first data zone */
++ __u32 s_fsize __packed2__; /* total number of zones of this fs */
+ /* the start of the free block list: */
+- u16 s_nfree; /* number of free blocks in s_free, <= V7_NICFREE */
+- u32 s_free[V7_NICFREE]; /* first free block list chunk */
++ __u16 s_nfree; /* number of free blocks in s_free, <= V7_NICFREE */
++ __u32 s_free[V7_NICFREE]; /* first free block list chunk */
+ /* the cache of free inodes: */
+- u16 s_ninode; /* number of free inodes in s_inode, <= V7_NICINOD */
++ __u16 s_ninode; /* number of free inodes in s_inode, <= V7_NICINOD */
+ sysv_ino_t s_inode[V7_NICINOD]; /* some free inodes */
+ /* locks, not used by Linux or V7: */
+ char s_flock; /* lock during free block list manipulation */
+ char s_ilock; /* lock during inode cache manipulation */
+ char s_fmod; /* super-block modified flag */
+ char s_ronly; /* flag whether fs is mounted read-only */
+- u32 s_time __packed2__; /* time of last super block update */
++ __u32 s_time __packed2__; /* time of last super block update */
+ /* the following fields are not maintained by V7: */
+- u32 s_tfree __packed2__; /* total number of free zones */
+- u16 s_tinode; /* total number of free inodes */
+- u16 s_m; /* interleave factor */
+- u16 s_n; /* interleave factor */
++ __u32 s_tfree __packed2__; /* total number of free zones */
++ __u16 s_tinode; /* total number of free inodes */
++ __u16 s_m; /* interleave factor */
++ __u16 s_n; /* interleave factor */
+ char s_fname[6]; /* file system name */
+ char s_fpack[6]; /* file system pack name */
+ };
+@@ -152,41 +152,41 @@
+ #define COH_NICINOD 100 /* number of inode cache entries */
+ #define COH_NICFREE 64 /* number of free block list chunk entries */
+ struct coh_super_block {
+- u16 s_isize; /* index of first data zone */
+- u32 s_fsize __packed2__; /* total number of zones of this fs */
++ __u16 s_isize; /* index of first data zone */
++ __u32 s_fsize __packed2__; /* total number of zones of this fs */
+ /* the start of the free block list: */
+- u16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
+- u32 s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
++ __u16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
++ __u32 s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
+ /* the cache of free inodes: */
+- u16 s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */
++ __u16 s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */
+ sysv_ino_t s_inode[COH_NICINOD]; /* some free inodes */
+ /* locks, not used by Linux: */
+ char s_flock; /* lock during free block list manipulation */
+ char s_ilock; /* lock during inode cache manipulation */
+ char s_fmod; /* super-block modified flag */
+ char s_ronly; /* flag whether fs is mounted read-only */
+- u32 s_time __packed2__; /* time of last super block update */
+- u32 s_tfree __packed2__; /* total number of free zones */
+- u16 s_tinode; /* total number of free inodes */
+- u16 s_interleave_m; /* interleave factor */
+- u16 s_interleave_n;
++ __u32 s_time __packed2__; /* time of last super block update */
++ __u32 s_tfree __packed2__; /* total number of free zones */
++ __u16 s_tinode; /* total number of free inodes */
++ __u16 s_interleave_m; /* interleave factor */
++ __u16 s_interleave_n;
+ char s_fname[6]; /* file system volume name */
+ char s_fpack[6]; /* file system pack name */
+- u32 s_unique; /* zero, not used */
++ __u32 s_unique; /* zero, not used */
+ };
+
+ /* SystemV/Coherent inode data on disk */
+ struct sysv_inode {
+- u16 i_mode;
+- u16 i_nlink;
+- u16 i_uid;
+- u16 i_gid;
+- u32 i_size;
+- u8 i_data[3*(10+1+1+1)];
+- u8 i_gen;
+- u32 i_atime; /* time of last access */
+- u32 i_mtime; /* time of last modification */
+- u32 i_ctime; /* time of creation */
++ __u16 i_mode;
++ __u16 i_nlink;
++ __u16 i_uid;
++ __u16 i_gid;
++ __u32 i_size;
++ __u8 i_data[3*(10+1+1+1)];
++ __u8 i_gen;
++ __u32 i_atime; /* time of last access */
++ __u32 i_mtime; /* time of last modification */
++ __u32 i_ctime; /* time of creation */
+ };
+
+ /* SystemV/Coherent directory entry on disk */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/tiocl.h linux-libc-headers-2.6.8.0/include/linux/tiocl.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/tiocl.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/tiocl.h 2004-08-26 05:42:08.000000000 -0500
+@@ -23,7 +23,7 @@
+
+ #define TIOCL_SELLOADLUT 5
+ /* set characters to be considered alphabetic when selecting */
+- /* u32[8] bit array, 4 bytes-aligned with type */
++ /* __u32[8] bit array, 4 bytes-aligned with type */
+
+ /* these two don't return a value: they write it back in the type */
+ #define TIOCL_GETSHIFTSTATE 6 /* write shift state */
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/umem.h linux-libc-headers-2.6.8.0/include/linux/umem.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/umem.h 2003-12-15 12:46:58.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/umem.h 2004-08-26 05:42:08.000000000 -0500
+@@ -110,19 +110,19 @@
+ #define DMA_WRITE_TO_HOST 1
+
+ struct mm_dma_desc {
+- u64 pci_addr;
+- u64 local_addr;
+- u32 transfer_size;
+- u32 zero1;
+- u64 next_desc_addr;
+- u64 sem_addr;
+- u32 control_bits;
+- u32 zero2;
++ __u64 pci_addr;
++ __u64 local_addr;
++ __u32 transfer_size;
++ __u32 zero1;
++ __u64 next_desc_addr;
++ __u64 sem_addr;
++ __u32 control_bits;
++ __u32 zero2;
+
+ dma_addr_t data_dma_handle;
+
+ /* Copy of the bits */
+- u64 sem_control_bits;
++ __u64 sem_control_bits;
+ } __attribute__((aligned(8)));
+
+ #define PCI_VENDOR_ID_MICRO_MEMORY 0x1332
+diff -urN linux-libc-headers-2.6.8.0-dist/include/linux/vt_buffer.h linux-libc-headers-2.6.8.0/include/linux/vt_buffer.h
+--- linux-libc-headers-2.6.8.0-dist/include/linux/vt_buffer.h 2004-01-17 17:04:33.000000000 -0600
++++ linux-libc-headers-2.6.8.0/include/linux/vt_buffer.h 2004-08-26 05:42:08.000000000 -0500
+@@ -28,7 +28,7 @@
+ #endif
+
+ #ifndef VT_BUF_HAVE_MEMSETW
+-static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
++static inline void scr_memsetw(__u16 *s, __u16 c, unsigned int count)
+ {
+ count /= 2;
+ while (count--)
+@@ -37,7 +37,7 @@
+ #endif
+
+ #ifndef VT_BUF_HAVE_MEMCPYW
+-static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
++static inline void scr_memcpyw(__u16 *d, const __u16 *s, unsigned int count)
+ {
+ count /= 2;
+ while (count--)
+@@ -46,7 +46,7 @@
+ #endif
+
+ #ifndef VT_BUF_HAVE_MEMMOVEW
+-static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
++static inline void scr_memmovew(__u16 *d, const __u16 *s, unsigned int count)
+ {
+ if (d < s)
+ scr_memcpyw(d, s, count);
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.9-nios2nommu.patch.conditional b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.9-nios2nommu.patch.conditional
new file mode 100644
index 0000000000..b828b3bb3f
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/linux-libc-headers-2.6.9-nios2nommu.patch.conditional
@@ -0,0 +1,12925 @@
+--- linux/include/asm-generic/bitops.h
++++ linux/include/asm-generic/bitops.h
+@@ -0,0 +1,81 @@
++#ifndef _ASM_GENERIC_BITOPS_H_
++#define _ASM_GENERIC_BITOPS_H_
++
++/*
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents. You should
++ * recode these in the native assembly language, if at all possible.
++ * To guarantee atomicity, these routines call cli() and sti() to
++ * disable interrupts while they operate. (You have to provide inline
++ * routines to cli() and sti().)
++ *
++ * Also note, these routines assume that you have 32 bit longs.
++ * You will have to change this if you are trying to port Linux to the
++ * Alpha architecture or to a Cray. :-)
++ *
++ * C language equivalents written by Theodore Ts'o, 9/26/92
++ */
++
++extern __inline__ int set_bit(int nr,long * addr)
++{
++ int mask, retval;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ cli();
++ retval = (mask & *addr) != 0;
++ *addr |= mask;
++ sti();
++ return retval;
++}
++
++extern __inline__ int clear_bit(int nr, long * addr)
++{
++ int mask, retval;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ cli();
++ retval = (mask & *addr) != 0;
++ *addr &= ~mask;
++ sti();
++ return retval;
++}
++
++extern __inline__ int test_bit(int nr, const unsigned long * addr)
++{
++ int mask;
++
++ addr += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ return ((mask & *addr) != 0);
++}
++
++/*
++ * fls: find last bit set.
++ */
++
++#define fls(x) generic_fls(x)
++
++#ifdef __KERNEL__
++
++/*
++ * ffs: find first bit set. This is defined the same way as
++ * the libc and compiler builtin ffs routines, therefore
++ * differs in spirit from the above ffz (man ffs).
++ */
++
++#define ffs(x) generic_ffs(x)
++
++/*
++ * hweightN: returns the hamming weight (i.e. the number
++ * of bits set) of a N-bit word
++ */
++
++#define hweight32(x) generic_hweight32(x)
++#define hweight16(x) generic_hweight16(x)
++#define hweight8(x) generic_hweight8(x)
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_GENERIC_BITOPS_H */
+--- linux/include/asm-generic/bug.h
++++ linux/include/asm-generic/bug.h
+@@ -0,0 +1,34 @@
++#ifndef _ASM_GENERIC_BUG_H
++#define _ASM_GENERIC_BUG_H
++
++#include <linux/compiler.h>
++// #include <linux/config.h>
++
++#ifndef HAVE_ARCH_BUG
++#define BUG() do { \
++ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
++ panic("BUG!"); \
++} while (0)
++#endif
++
++#ifndef HAVE_ARCH_PAGE_BUG
++#define PAGE_BUG(page) do { \
++ printk("page BUG for page at %p\n", page); \
++ BUG(); \
++} while (0)
++#endif
++
++#ifndef HAVE_ARCH_BUG_ON
++#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
++#endif
++
++#ifndef HAVE_ARCH_WARN_ON
++#define WARN_ON(condition) do { \
++ if (unlikely((condition)!=0)) { \
++ printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
++ dump_stack(); \
++ } \
++} while (0)
++#endif
++
++#endif
+--- linux/include/asm-generic/cpumask.h
++++ linux/include/asm-generic/cpumask.h
+@@ -0,0 +1,40 @@
++#ifndef __ASM_GENERIC_CPUMASK_H
++#define __ASM_GENERIC_CPUMASK_H
++
++// #include <linux/config.h>
++#include <linux/kernel.h>
++#include <linux/threads.h>
++#include <linux/types.h>
++#include <linux/bitmap.h>
++
++#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1
++#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
++
++struct cpumask
++{
++ unsigned long mask[CPU_ARRAY_SIZE];
++};
++
++typedef struct cpumask cpumask_t;
++
++#else
++typedef unsigned long cpumask_t;
++#endif
++
++#ifdef CONFIG_SMP
++#if NR_CPUS > BITS_PER_LONG
++#include <asm-generic/cpumask_array.h>
++#else
++#include <asm-generic/cpumask_arith.h>
++#endif
++#else
++#include <asm-generic/cpumask_up.h>
++#endif
++
++#if NR_CPUS <= 4*BITS_PER_LONG
++#include <asm-generic/cpumask_const_value.h>
++#else
++#include <asm-generic/cpumask_const_reference.h>
++#endif
++
++#endif /* __ASM_GENERIC_CPUMASK_H */
+--- linux/include/asm-generic/cpumask_arith.h
++++ linux/include/asm-generic/cpumask_arith.h
+@@ -0,0 +1,49 @@
++#ifndef __ASM_GENERIC_CPUMASK_ARITH_H
++#define __ASM_GENERIC_CPUMASK_ARITH_H
++
++/*
++ * Arithmetic type -based cpu bitmaps. A single unsigned long is used
++ * to contain the whole cpu bitmap.
++ */
++
++#define cpu_set(cpu, map) set_bit(cpu, &(map))
++#define cpu_clear(cpu, map) clear_bit(cpu, &(map))
++#define cpu_isset(cpu, map) test_bit(cpu, &(map))
++#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, &(map))
++
++#define cpus_and(dst,src1,src2) do { dst = (src1) & (src2); } while (0)
++#define cpus_or(dst,src1,src2) do { dst = (src1) | (src2); } while (0)
++#define cpus_clear(map) do { map = 0; } while (0)
++#define cpus_complement(map) do { map = ~(map); } while (0)
++#define cpus_equal(map1, map2) ((map1) == (map2))
++#define cpus_empty(map) ((map) == 0)
++#define cpus_addr(map) (&(map))
++
++#if BITS_PER_LONG == 32
++#define cpus_weight(map) hweight32(map)
++#elif BITS_PER_LONG == 64
++#define cpus_weight(map) hweight64(map)
++#endif
++
++#define cpus_shift_right(dst, src, n) do { dst = (src) >> (n); } while (0)
++#define cpus_shift_left(dst, src, n) do { dst = (src) << (n); } while (0)
++
++#define any_online_cpu(map) \
++({ \
++ cpumask_t __tmp__; \
++ cpus_and(__tmp__, map, cpu_online_map); \
++ __tmp__ ? first_cpu(__tmp__) : NR_CPUS; \
++})
++
++#define CPU_MASK_ALL (~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS))
++#define CPU_MASK_NONE ((cpumask_t)0)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce(map) ((unsigned long)(map))
++#define cpus_promote(map) ({ map; })
++#define cpumask_of_cpu(cpu) ({ ((cpumask_t)1) << (cpu); })
++
++#define first_cpu(map) __ffs(map)
++#define next_cpu(cpu, map) find_next_bit(&(map), NR_CPUS, cpu + 1)
++
++#endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
+--- linux/include/asm-generic/cpumask_array.h
++++ linux/include/asm-generic/cpumask_array.h
+@@ -0,0 +1,54 @@
++#ifndef __ASM_GENERIC_CPUMASK_ARRAY_H
++#define __ASM_GENERIC_CPUMASK_ARRAY_H
++
++/*
++ * Array-based cpu bitmaps. An array of unsigned longs is used to contain
++ * the bitmap, and then contained in a structure so it may be passed by
++ * value.
++ */
++
++#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
++
++#define cpu_set(cpu, map) set_bit(cpu, (map).mask)
++#define cpu_clear(cpu, map) clear_bit(cpu, (map).mask)
++#define cpu_isset(cpu, map) test_bit(cpu, (map).mask)
++#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, (map).mask)
++
++#define cpus_and(dst,src1,src2) bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)
++#define cpus_or(dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
++#define cpus_clear(map) bitmap_clear((map).mask, NR_CPUS)
++#define cpus_complement(map) bitmap_complement((map).mask, NR_CPUS)
++#define cpus_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, NR_CPUS)
++#define cpus_empty(map) bitmap_empty(map.mask, NR_CPUS)
++#define cpus_addr(map) ((map).mask)
++#define cpus_weight(map) bitmap_weight((map).mask, NR_CPUS)
++#define cpus_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, NR_CPUS)
++#define cpus_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, NR_CPUS)
++#define first_cpu(map) find_first_bit((map).mask, NR_CPUS)
++#define next_cpu(cpu, map) find_next_bit((map).mask, NR_CPUS, cpu + 1)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce(map) ((map).mask[0])
++#define cpus_promote(map) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
++ __cpu_mask.mask[0] = map; \
++ __cpu_mask; \
++ })
++#define cpumask_of_cpu(cpu) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
++ cpu_set(cpu, __cpu_mask); \
++ __cpu_mask; \
++ })
++#define any_online_cpu(map) \
++({ \
++ cpumask_t __tmp__; \
++ cpus_and(__tmp__, map, cpu_online_map); \
++ find_first_bit(__tmp__.mask, NR_CPUS); \
++})
++
++
++/*
++ * um, these need to be usable as static initializers
++ */
++#define CPU_MASK_ALL { {[0 ... CPU_ARRAY_SIZE-1] = ~0UL} }
++#define CPU_MASK_NONE { {[0 ... CPU_ARRAY_SIZE-1] = 0UL} }
++
++#endif /* __ASM_GENERIC_CPUMASK_ARRAY_H */
+--- linux/include/asm-generic/cpumask_const_reference.h
++++ linux/include/asm-generic/cpumask_const_reference.h
+@@ -0,0 +1,29 @@
++#ifndef __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
++#define __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
++
++struct cpumask_ref {
++ const cpumask_t *val;
++};
++
++typedef const struct cpumask_ref cpumask_const_t;
++
++#define mk_cpumask_const(map) ((cpumask_const_t){ &(map) })
++#define cpu_isset_const(cpu, map) cpu_isset(cpu, *(map).val)
++
++#define cpus_and_const(dst,src1,src2) cpus_and(dst,*(src1).val,*(src2).val)
++#define cpus_or_const(dst,src1,src2) cpus_or(dst,*(src1).val,*(src2).val)
++
++#define cpus_equal_const(map1, map2) cpus_equal(*(map1).val, *(map2).val)
++
++#define cpus_copy_const(map1, map2) bitmap_copy((map1).mask, (map2).val->mask, NR_CPUS)
++
++#define cpus_empty_const(map) cpus_empty(*(map).val)
++#define cpus_weight_const(map) cpus_weight(*(map).val)
++#define first_cpu_const(map) first_cpu(*(map).val)
++#define next_cpu_const(cpu, map) next_cpu(cpu, *(map).val)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce_const(map) cpus_coerce(*(map).val)
++#define any_online_cpu_const(map) any_online_cpu(*(map).val)
++
++#endif /* __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H */
+--- linux/include/asm-generic/cpumask_const_value.h
++++ linux/include/asm-generic/cpumask_const_value.h
+@@ -0,0 +1,21 @@
++#ifndef __ASM_GENERIC_CPUMASK_CONST_VALUE_H
++#define __ASM_GENERIC_CPUMASK_CONST_VALUE_H
++
++typedef const cpumask_t cpumask_const_t;
++
++#define mk_cpumask_const(map) (map)
++#define cpu_isset_const(cpu, map) cpu_isset(cpu, map)
++#define cpus_and_const(dst,src1,src2) cpus_and(dst, src1, src2)
++#define cpus_or_const(dst,src1,src2) cpus_or(dst, src1, src2)
++#define cpus_equal_const(map1, map2) cpus_equal(map1, map2)
++#define cpus_empty_const(map) cpus_empty(map)
++#define cpus_copy_const(map1, map2) do { map1 = (cpumask_t)map2; } while (0)
++#define cpus_weight_const(map) cpus_weight(map)
++#define first_cpu_const(map) first_cpu(map)
++#define next_cpu_const(cpu, map) next_cpu(cpu, map)
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_coerce_const(map) cpus_coerce(map)
++#define any_online_cpu_const(map) any_online_cpu(map)
++
++#endif /* __ASM_GENERIC_CPUMASK_CONST_VALUE_H */
+--- linux/include/asm-generic/cpumask_up.h
++++ linux/include/asm-generic/cpumask_up.h
+@@ -0,0 +1,59 @@
++#ifndef __ASM_GENERIC_CPUMASK_UP_H
++#define __ASM_GENERIC_CPUMASK_UP_H
++
++#define cpus_coerce(map) (map)
++
++#define cpu_set(cpu, map) do { (void)(cpu); cpus_coerce(map) = 1UL; } while (0)
++#define cpu_clear(cpu, map) do { (void)(cpu); cpus_coerce(map) = 0UL; } while (0)
++#define cpu_isset(cpu, map) ((void)(cpu), cpus_coerce(map) != 0UL)
++#define cpu_test_and_set(cpu, map) ((void)(cpu), test_and_set_bit(0, &(map)))
++
++#define cpus_and(dst, src1, src2) \
++ do { \
++ if (cpus_coerce(src1) && cpus_coerce(src2)) \
++ cpus_coerce(dst) = 1UL; \
++ else \
++ cpus_coerce(dst) = 0UL; \
++ } while (0)
++
++#define cpus_or(dst, src1, src2) \
++ do { \
++ if (cpus_coerce(src1) || cpus_coerce(src2)) \
++ cpus_coerce(dst) = 1UL; \
++ else \
++ cpus_coerce(dst) = 0UL; \
++ } while (0)
++
++#define cpus_clear(map) do { cpus_coerce(map) = 0UL; } while (0)
++
++#define cpus_complement(map) \
++ do { \
++ cpus_coerce(map) = !cpus_coerce(map); \
++ } while (0)
++
++#define cpus_equal(map1, map2) (cpus_coerce(map1) == cpus_coerce(map2))
++#define cpus_empty(map) (cpus_coerce(map) == 0UL)
++#define cpus_addr(map) (&(map))
++#define cpus_weight(map) (cpus_coerce(map) ? 1UL : 0UL)
++#define cpus_shift_right(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
++#define cpus_shift_left(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
++#define first_cpu(map) (cpus_coerce(map) ? 0 : 1)
++#define next_cpu(cpu, map) 1
++
++/* only ever use this for things that are _never_ used on large boxen */
++#define cpus_promote(map) \
++ ({ \
++ cpumask_t __tmp__; \
++ cpus_coerce(__tmp__) = map; \
++ __tmp__; \
++ })
++#define cpumask_of_cpu(cpu) ((void)(cpu), cpus_promote(1))
++#define any_online_cpu(map) (cpus_coerce(map) ? 0 : 1)
++
++/*
++ * um, these need to be usable as static initializers
++ */
++#define CPU_MASK_ALL 1UL
++#define CPU_MASK_NONE 0UL
++
++#endif /* __ASM_GENERIC_CPUMASK_UP_H */
+--- linux/include/asm-generic/div64.h
++++ linux/include/asm-generic/div64.h
+@@ -0,0 +1,58 @@
++#ifndef _ASM_GENERIC_DIV64_H
++#define _ASM_GENERIC_DIV64_H
++/*
++ * Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com>
++ * Based on former asm-ppc/div64.h and asm-m68knommu/div64.h
++ *
++ * The semantics of do_div() are:
++ *
++ * uint32_t do_div(uint64_t *n, uint32_t base)
++ * {
++ * uint32_t remainder = *n % base;
++ * *n = *n / base;
++ * return remainder;
++ * }
++ *
++ * NOTE: macro parameter n is evaluated multiple times,
++ * beware of side effects!
++ */
++
++#include <linux/types.h>
++#include <linux/compiler.h>
++
++#if BITS_PER_LONG == 64
++
++# define do_div(n,base) ({ \
++ uint32_t __base = (base); \
++ uint32_t __rem; \
++ __rem = ((uint64_t)(n)) % __base; \
++ (n) = ((uint64_t)(n)) / __base; \
++ __rem; \
++ })
++
++#elif BITS_PER_LONG == 32
++
++extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
++
++/* The unnecessary pointer compare is there
++ * to check for type safety (n must be 64bit)
++ */
++# define do_div(n,base) ({ \
++ uint32_t __base = (base); \
++ uint32_t __rem; \
++ (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
++ if (likely(((n) >> 32) == 0)) { \
++ __rem = (uint32_t)(n) % __base; \
++ (n) = (uint32_t)(n) / __base; \
++ } else \
++ __rem = __div64_32(&(n), __base); \
++ __rem; \
++ })
++
++#else /* BITS_PER_LONG == ?? */
++
++# error do_div() does not yet support the C64
++
++#endif /* BITS_PER_LONG */
++
++#endif /* _ASM_GENERIC_DIV64_H */
+--- linux/include/asm-generic/dma-mapping-broken.h
++++ linux/include/asm-generic/dma-mapping-broken.h
+@@ -0,0 +1,22 @@
++#ifndef _ASM_GENERIC_DMA_MAPPING_H
++#define _ASM_GENERIC_DMA_MAPPING_H
++
++/* This is used for archs that do not support DMA */
++
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++#endif /* _ASM_GENERIC_DMA_MAPPING_H */
+--- linux/include/asm-generic/dma-mapping.h
++++ linux/include/asm-generic/dma-mapping.h
+@@ -0,0 +1,309 @@
++/* Copyright (C) 2002 by James.Bottomley@HansenPartnership.com
++ *
++ * Implements the generic device dma API via the existing pci_ one
++ * for unconverted architectures
++ */
++
++#ifndef _ASM_GENERIC_DMA_MAPPING_H
++#define _ASM_GENERIC_DMA_MAPPING_H
++
++// #include <linux/config.h>
++
++#ifdef CONFIG_PCI
++
++/* we implement the API below in terms of the existing PCI one,
++ * so include it */
++#include <linux/pci.h>
++/* need struct page definitions */
++#include <linux/mm.h>
++
++static inline int
++dma_supported(struct device *dev, u64 mask)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_dma_supported(to_pci_dev(dev), mask);
++}
++
++static inline int
++dma_set_mask(struct device *dev, u64 dma_mask)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
++}
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
++}
++
++static inline dma_addr_t
++dma_map_single(struct device *dev, void *cpu_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
++}
++
++static inline void
++dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
++}
++
++static inline dma_addr_t
++dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
++}
++
++static inline void
++dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
++}
++
++static inline int
++dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
++}
++
++static inline void
++dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
++}
++
++static inline void
++dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
++ size, (int)direction);
++}
++
++static inline void
++dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
++ size, (int)direction);
++}
++
++static inline void
++dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
++}
++
++static inline void
++dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG_ON(dev->bus != &pci_bus_type);
++
++ pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
++}
++
++static inline int
++dma_mapping_error(dma_addr_t dma_addr)
++{
++ return pci_dma_mapping_error(dma_addr);
++}
++
++
++#else
++
++static inline int
++dma_supported(struct device *dev, u64 mask)
++{
++ return 0;
++}
++
++static inline int
++dma_set_mask(struct device *dev, u64 dma_mask)
++{
++ BUG();
++ return 0;
++}
++
++static inline void *
++dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
++ int flag)
++{
++ BUG();
++ return NULL;
++}
++
++static inline void
++dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
++ dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++static inline dma_addr_t
++dma_map_single(struct device *dev, void *cpu_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline dma_addr_t
++dma_map_page(struct device *dev, struct page *page,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline int
++dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
++ enum dma_data_direction direction)
++{
++ BUG();
++ return 0;
++}
++
++static inline void
++dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline void
++dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
++ enum dma_data_direction direction)
++{
++ BUG();
++}
++
++static inline int
++dma_error(dma_addr_t dma_addr)
++{
++ return 0;
++}
++
++#endif
++
++/* Now for the API extensions over the pci_ one */
++
++#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
++#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
++#define dma_is_consistent(d) (1)
++
++static inline int
++dma_get_cache_alignment(void)
++{
++ /* no easy way to get cache size on all processors, so return
++ * the maximum possible, to be safe */
++ return (1 << L1_CACHE_SHIFT_MAX);
++}
++
++static inline void
++dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ /* just sync everything, that's all the pci API can do */
++ dma_sync_single_for_cpu(dev, dma_handle, offset+size, direction);
++}
++
++static inline void
++dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction)
++{
++ /* just sync everything, that's all the pci API can do */
++ dma_sync_single_for_device(dev, dma_handle, offset+size, direction);
++}
++
++static inline void
++dma_cache_sync(void *vaddr, size_t size,
++ enum dma_data_direction direction)
++{
++ /* could define this in terms of the dma_cache ... operations,
++ * but if you get this on a platform, you should convert the platform
++ * to using the generic device DMA API */
++ BUG();
++}
++
++#endif
++
+--- linux/include/asm-generic/errno-base.h
++++ linux/include/asm-generic/errno-base.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_GENERIC_ERRNO_BASE_H
++#define _ASM_GENERIC_ERRNO_BASE_H
++
++#define EPERM 1 /* Operation not permitted */
++#define ENOENT 2 /* No such file or directory */
++#define ESRCH 3 /* No such process */
++#define EINTR 4 /* Interrupted system call */
++#define EIO 5 /* I/O error */
++#define ENXIO 6 /* No such device or address */
++#define E2BIG 7 /* Argument list too long */
++#define ENOEXEC 8 /* Exec format error */
++#define EBADF 9 /* Bad file number */
++#define ECHILD 10 /* No child processes */
++#define EAGAIN 11 /* Try again */
++#define ENOMEM 12 /* Out of memory */
++#define EACCES 13 /* Permission denied */
++#define EFAULT 14 /* Bad address */
++#define ENOTBLK 15 /* Block device required */
++#define EBUSY 16 /* Device or resource busy */
++#define EEXIST 17 /* File exists */
++#define EXDEV 18 /* Cross-device link */
++#define ENODEV 19 /* No such device */
++#define ENOTDIR 20 /* Not a directory */
++#define EISDIR 21 /* Is a directory */
++#define EINVAL 22 /* Invalid argument */
++#define ENFILE 23 /* File table overflow */
++#define EMFILE 24 /* Too many open files */
++#define ENOTTY 25 /* Not a typewriter */
++#define ETXTBSY 26 /* Text file busy */
++#define EFBIG 27 /* File too large */
++#define ENOSPC 28 /* No space left on device */
++#define ESPIPE 29 /* Illegal seek */
++#define EROFS 30 /* Read-only file system */
++#define EMLINK 31 /* Too many links */
++#define EPIPE 32 /* Broken pipe */
++#define EDOM 33 /* Math argument out of domain of func */
++#define ERANGE 34 /* Math result not representable */
++
++#endif
+--- linux/include/asm-generic/errno.h
++++ linux/include/asm-generic/errno.h
+@@ -0,0 +1,100 @@
++#ifndef _ASM_GENERIC_ERRNO_H
++#define _ASM_GENERIC_ERRNO_H
++
++#include <asm-generic/errno-base.h>
++
++#define EDEADLK 35 /* Resource deadlock would occur */
++#define ENAMETOOLONG 36 /* File name too long */
++#define ENOLCK 37 /* No record locks available */
++#define ENOSYS 38 /* Function not implemented */
++#define ENOTEMPTY 39 /* Directory not empty */
++#define ELOOP 40 /* Too many symbolic links encountered */
++#define EWOULDBLOCK EAGAIN /* Operation would block */
++#define ENOMSG 42 /* No message of desired type */
++#define EIDRM 43 /* Identifier removed */
++#define ECHRNG 44 /* Channel number out of range */
++#define EL2NSYNC 45 /* Level 2 not synchronized */
++#define EL3HLT 46 /* Level 3 halted */
++#define EL3RST 47 /* Level 3 reset */
++#define ELNRNG 48 /* Link number out of range */
++#define EUNATCH 49 /* Protocol driver not attached */
++#define ENOCSI 50 /* No CSI structure available */
++#define EL2HLT 51 /* Level 2 halted */
++#define EBADE 52 /* Invalid exchange */
++#define EBADR 53 /* Invalid request descriptor */
++#define EXFULL 54 /* Exchange full */
++#define ENOANO 55 /* No anode */
++#define EBADRQC 56 /* Invalid request code */
++#define EBADSLT 57 /* Invalid slot */
++
++#define EDEADLOCK EDEADLK
++
++#define EBFONT 59 /* Bad font file format */
++#define ENOSTR 60 /* Device not a stream */
++#define ENODATA 61 /* No data available */
++#define ETIME 62 /* Timer expired */
++#define ENOSR 63 /* Out of streams resources */
++#define ENONET 64 /* Machine is not on the network */
++#define ENOPKG 65 /* Package not installed */
++#define EREMOTE 66 /* Object is remote */
++#define ENOLINK 67 /* Link has been severed */
++#define EADV 68 /* Advertise error */
++#define ESRMNT 69 /* Srmount error */
++#define ECOMM 70 /* Communication error on send */
++#define EPROTO 71 /* Protocol error */
++#define EMULTIHOP 72 /* Multihop attempted */
++#define EDOTDOT 73 /* RFS specific error */
++#define EBADMSG 74 /* Not a data message */
++#define EOVERFLOW 75 /* Value too large for defined data type */
++#define ENOTUNIQ 76 /* Name not unique on network */
++#define EBADFD 77 /* File descriptor in bad state */
++#define EREMCHG 78 /* Remote address changed */
++#define ELIBACC 79 /* Can not access a needed shared library */
++#define ELIBBAD 80 /* Accessing a corrupted shared library */
++#define ELIBSCN 81 /* .lib section in a.out corrupted */
++#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
++#define ELIBEXEC 83 /* Cannot exec a shared library directly */
++#define EILSEQ 84 /* Illegal byte sequence */
++#define ERESTART 85 /* Interrupted system call should be restarted */
++#define ESTRPIPE 86 /* Streams pipe error */
++#define EUSERS 87 /* Too many users */
++#define ENOTSOCK 88 /* Socket operation on non-socket */
++#define EDESTADDRREQ 89 /* Destination address required */
++#define EMSGSIZE 90 /* Message too long */
++#define EPROTOTYPE 91 /* Protocol wrong type for socket */
++#define ENOPROTOOPT 92 /* Protocol not available */
++#define EPROTONOSUPPORT 93 /* Protocol not supported */
++#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
++#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
++#define EPFNOSUPPORT 96 /* Protocol family not supported */
++#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
++#define EADDRINUSE 98 /* Address already in use */
++#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
++#define ENETDOWN 100 /* Network is down */
++#define ENETUNREACH 101 /* Network is unreachable */
++#define ENETRESET 102 /* Network dropped connection because of reset */
++#define ECONNABORTED 103 /* Software caused connection abort */
++#define ECONNRESET 104 /* Connection reset by peer */
++#define ENOBUFS 105 /* No buffer space available */
++#define EISCONN 106 /* Transport endpoint is already connected */
++#define ENOTCONN 107 /* Transport endpoint is not connected */
++#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
++#define ETOOMANYREFS 109 /* Too many references: cannot splice */
++#define ETIMEDOUT 110 /* Connection timed out */
++#define ECONNREFUSED 111 /* Connection refused */
++#define EHOSTDOWN 112 /* Host is down */
++#define EHOSTUNREACH 113 /* No route to host */
++#define EALREADY 114 /* Operation already in progress */
++#define EINPROGRESS 115 /* Operation now in progress */
++#define ESTALE 116 /* Stale NFS file handle */
++#define EUCLEAN 117 /* Structure needs cleaning */
++#define ENOTNAM 118 /* Not a XENIX named type file */
++#define ENAVAIL 119 /* No XENIX semaphores available */
++#define EISNAM 120 /* Is a named type file */
++#define EREMOTEIO 121 /* Remote I/O error */
++#define EDQUOT 122 /* Quota exceeded */
++
++#define ENOMEDIUM 123 /* No medium found */
++#define EMEDIUMTYPE 124 /* Wrong medium type */
++
++#endif
+--- linux/include/asm-generic/hdreg.h
++++ linux/include/asm-generic/hdreg.h
+@@ -0,0 +1,8 @@
++#warning <asm/hdreg.h> is obsolete, please do not use it
++
++#ifndef __ASM_GENERIC_HDREG_H
++#define __ASM_GENERIC_HDREG_H
++
++typedef unsigned long ide_ioreg_t;
++
++#endif /* __ASM_GENERIC_HDREG_H */
+--- linux/include/asm-generic/ide_iops.h
++++ linux/include/asm-generic/ide_iops.h
+@@ -0,0 +1,38 @@
++/* Generic I/O and MEMIO string operations. */
++
++#define __ide_insw insw
++#define __ide_insl insl
++#define __ide_outsw outsw
++#define __ide_outsl outsl
++
++static __inline__ void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ *(u16 *)addr = readw(port);
++ addr += 2;
++ }
++}
++
++static __inline__ void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ *(u32 *)addr = readl(port);
++ addr += 4;
++ }
++}
++
++static __inline__ void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
++{
++ while (count--) {
++ writew(*(u16 *)addr, port);
++ addr += 2;
++ }
++}
++
++static __inline__ void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
++{
++ while (count--) {
++ writel(*(u32 *)addr, port);
++ addr += 4;
++ }
++}
+--- linux/include/asm-generic/iomap.h
++++ linux/include/asm-generic/iomap.h
+@@ -0,0 +1,63 @@
++#ifndef __GENERIC_IO_H
++#define __GENERIC_IO_H
++
++#include <linux/linkage.h>
++
++/*
++ * These are the "generic" interfaces for doing new-style
++ * memory-mapped or PIO accesses. Architectures may do
++ * their own arch-optimized versions, these just act as
++ * wrappers around the old-style IO register access functions:
++ * read[bwl]/write[bwl]/in[bwl]/out[bwl]
++ *
++ * Don't include this directly, include it from <asm/io.h>.
++ */
++
++/*
++ * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
++ * access or a MMIO access, these functions don't care. The info is
++ * encoded in the hardware mapping set up by the mapping functions
++ * (or the cookie itself, depending on implementation and hw).
++ *
++ * The generic routines just encode the PIO/MMIO as part of the
++ * cookie, and coldly assume that the MMIO IO mappings are not
++ * in the low address range. Architectures for which this is not
++ * true can't use this generic implementation.
++ */
++extern unsigned int fastcall ioread8(void __iomem *);
++extern unsigned int fastcall ioread16(void __iomem *);
++extern unsigned int fastcall ioread32(void __iomem *);
++
++extern void fastcall iowrite8(u8, void __iomem *);
++extern void fastcall iowrite16(u16, void __iomem *);
++extern void fastcall iowrite32(u32, void __iomem *);
++
++/*
++ * "string" versions of the above. Note that they
++ * use native byte ordering for the accesses (on
++ * the assumption that IO and memory agree on a
++ * byte order, and CPU byteorder is irrelevant).
++ *
++ * They do _not_ update the port address. If you
++ * want MMIO that copies stuff laid out in MMIO
++ * memory across multiple ports, use "memcpy_toio()"
++ * and friends.
++ */
++extern void fastcall ioread8_rep(void __iomem *port, void *buf, unsigned long count);
++extern void fastcall ioread16_rep(void __iomem *port, void *buf, unsigned long count);
++extern void fastcall ioread32_rep(void __iomem *port, void *buf, unsigned long count);
++
++extern void fastcall iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
++extern void fastcall iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
++extern void fastcall iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
++
++/* Create a virtual mapping cookie for an IO port range */
++extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
++extern void ioport_unmap(void __iomem *);
++
++/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
++struct pci_dev;
++extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
++extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
++
++#endif
+--- linux/include/asm-generic/local.h
++++ linux/include/asm-generic/local.h
+@@ -0,0 +1,118 @@
++#ifndef _ASM_GENERIC_LOCAL_H
++#define _ASM_GENERIC_LOCAL_H
++
++// #include <linux/config.h>
++#include <linux/percpu.h>
++#include <linux/hardirq.h>
++#include <asm/types.h>
++
++/* An unsigned long type for operations which are atomic for a single
++ * CPU. Usually used in combination with per-cpu variables. */
++
++#if BITS_PER_LONG == 32
++/* Implement in terms of atomics. */
++
++/* Don't use typedef: don't want them to be mixed with atomic_t's. */
++typedef struct
++{
++ atomic_t a;
++} local_t;
++
++#define LOCAL_INIT(i) { ATOMIC_INIT(i) }
++
++#define local_read(l) ((unsigned long)atomic_read(&(l)->a))
++#define local_set(l,i) atomic_set((&(l)->a),(i))
++#define local_inc(l) atomic_inc(&(l)->a)
++#define local_dec(l) atomic_dec(&(l)->a)
++#define local_add(i,l) atomic_add((i),(&(l)->a))
++#define local_sub(i,l) atomic_sub((i),(&(l)->a))
++
++/* Non-atomic variants, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well. */
++#define __local_inc(l) local_set((l), local_read(l) + 1)
++#define __local_dec(l) local_set((l), local_read(l) - 1)
++#define __local_add(i,l) local_set((l), local_read(l) + (i))
++#define __local_sub(i,l) local_set((l), local_read(l) - (i))
++
++#else /* ... can't use atomics. */
++/* Implement in terms of three variables.
++ Another option would be to use local_irq_save/restore. */
++
++typedef struct
++{
++ /* 0 = in hardirq, 1 = in softirq, 2 = usermode. */
++ unsigned long v[3];
++} local_t;
++
++#define _LOCAL_VAR(l) ((l)->v[!in_interrupt() + !in_irq()])
++
++#define LOCAL_INIT(i) { { (i), 0, 0 } }
++
++static inline unsigned long local_read(local_t *l)
++{
++ return l->v[0] + l->v[1] + l->v[2];
++}
++
++static inline void local_set(local_t *l, unsigned long v)
++{
++ l->v[0] = v;
++ l->v[1] = l->v[2] = 0;
++}
++
++static inline void local_inc(local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l)++;
++ preempt_enable();
++}
++
++static inline void local_dec(local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l)--;
++ preempt_enable();
++}
++
++static inline void local_add(unsigned long v, local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l) += v;
++ preempt_enable();
++}
++
++static inline void local_sub(unsigned long v, local_t *l)
++{
++ preempt_disable();
++ _LOCAL_VAR(l) -= v;
++ preempt_enable();
++}
++
++/* Non-atomic variants, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well. */
++#define __local_inc(l) ((l)->v[0]++)
++#define __local_dec(l) ((l)->v[0]--)
++#define __local_add(i,l) ((l)->v[0] += (i))
++#define __local_sub(i,l) ((l)->v[0] -= (i))
++
++#endif /* Non-atomic implementation */
++
++/* Use these for per-cpu local_t variables: on some archs they are
++ * much more efficient than these naive implementations. Note they take
++ * a variable (eg. mystruct.foo), not an address.
++ */
++#define cpu_local_read(v) local_read(&__get_cpu_var(v))
++#define cpu_local_set(v, i) local_set(&__get_cpu_var(v), (i))
++#define cpu_local_inc(v) local_inc(&__get_cpu_var(v))
++#define cpu_local_dec(v) local_dec(&__get_cpu_var(v))
++#define cpu_local_add(i, v) local_add((i), &__get_cpu_var(v))
++#define cpu_local_sub(i, v) local_sub((i), &__get_cpu_var(v))
++
++/* Non-atomic increments, ie. preemption disabled and won't be touched
++ * in interrupt, etc. Some archs can optimize this case well.
++ */
++#define __cpu_local_inc(v) __local_inc(&__get_cpu_var(v))
++#define __cpu_local_dec(v) __local_dec(&__get_cpu_var(v))
++#define __cpu_local_add(i, v) __local_add((i), &__get_cpu_var(v))
++#define __cpu_local_sub(i, v) __local_sub((i), &__get_cpu_var(v))
++
++#endif /* _ASM_GENERIC_LOCAL_H */
+--- linux/include/asm-generic/pci-dma-compat.h
++++ linux/include/asm-generic/pci-dma-compat.h
+@@ -0,0 +1,107 @@
++/* include this file if the platform implements the dma_ DMA Mapping API
++ * and wants to provide the pci_ DMA Mapping API in terms of it */
++
++#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
++#define _ASM_GENERIC_PCI_DMA_COMPAT_H
++
++#include <linux/dma-mapping.h>
++
++/* note pci_set_dma_mask isn't here, since it's a public function
++ * exported from drivers/pci, use dma_supported instead */
++
++static inline int
++pci_dma_supported(struct pci_dev *hwdev, u64 mask)
++{
++ return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
++}
++
++static inline void *
++pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
++ dma_addr_t *dma_handle)
++{
++ return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
++}
++
++static inline void
++pci_free_consistent(struct pci_dev *hwdev, size_t size,
++ void *vaddr, dma_addr_t dma_handle)
++{
++ dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
++}
++
++static inline dma_addr_t
++pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
++{
++ return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
++ size_t size, int direction)
++{
++ dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
++}
++
++static inline dma_addr_t
++pci_map_page(struct pci_dev *hwdev, struct page *page,
++ unsigned long offset, size_t size, int direction)
++{
++ return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
++ size_t size, int direction)
++{
++ dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
++}
++
++static inline int
++pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nents, int direction)
++{
++ return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nents, int direction)
++{
++ dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
++ size_t size, int direction)
++{
++ dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
++ size_t size, int direction)
++{
++ dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nelems, int direction)
++{
++ dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
++}
++
++static inline void
++pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
++ int nelems, int direction)
++{
++ dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
++}
++
++static inline int
++pci_dma_mapping_error(dma_addr_t dma_addr)
++{
++ return dma_mapping_error(dma_addr);
++}
++
++#endif
+--- linux/include/asm-generic/pci.h
++++ linux/include/asm-generic/pci.h
+@@ -0,0 +1,27 @@
++/*
++ * linux/include/asm-generic/pci.h
++ *
++ * Copyright (C) 2003 Russell King
++ */
++#ifndef _ASM_GENERIC_PCI_H
++#define _ASM_GENERIC_PCI_H
++
++/**
++ * pcibios_resource_to_bus - convert resource to PCI bus address
++ * @dev: device which owns this resource
++ * @region: converted bus-centric region (start,end)
++ * @res: resource to convert
++ *
++ * Convert a resource to a PCI device bus address or bus window.
++ */
++static inline void
++pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
++ struct resource *res)
++{
++ region->start = res->start;
++ region->end = res->end;
++}
++
++#define pcibios_scan_all_fns(a, b) 0
++
++#endif
+--- linux/include/asm-generic/percpu.h
++++ linux/include/asm-generic/percpu.h
+@@ -0,0 +1,42 @@
++#ifndef _ASM_GENERIC_PERCPU_H_
++#define _ASM_GENERIC_PERCPU_H_
++#include <linux/compiler.h>
++
++#define __GENERIC_PER_CPU
++#ifdef CONFIG_SMP
++
++extern unsigned long __per_cpu_offset[NR_CPUS];
++
++/* Separate out the type, so (int[3], foo) works. */
++#define DEFINE_PER_CPU(type, name) \
++ __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
++
++/* var is in discarded region: offset to particular copy we want */
++#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
++#define __get_cpu_var(var) per_cpu(var, smp_processor_id())
++
++/* A macro to avoid #include hell... */
++#define percpu_modcopy(pcpudst, src, size) \
++do { \
++ unsigned int __i; \
++ for (__i = 0; __i < NR_CPUS; __i++) \
++ if (cpu_possible(__i)) \
++ memcpy((pcpudst)+__per_cpu_offset[__i], \
++ (src), (size)); \
++} while (0)
++#else /* ! SMP */
++
++#define DEFINE_PER_CPU(type, name) \
++ __typeof__(type) per_cpu__##name
++
++#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))
++#define __get_cpu_var(var) per_cpu__##var
++
++#endif /* SMP */
++
++#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
++
++#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
++#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
++
++#endif /* _ASM_GENERIC_PERCPU_H_ */
+--- linux/include/asm-generic/pgtable.h
++++ linux/include/asm-generic/pgtable.h
+@@ -0,0 +1,137 @@
++#ifndef _ASM_GENERIC_PGTABLE_H
++#define _ASM_GENERIC_PGTABLE_H
++
++#ifndef __HAVE_ARCH_PTEP_ESTABLISH
++/*
++ * Establish a new mapping:
++ * - flush the old one
++ * - update the page tables
++ * - inform the TLB about the new one
++ *
++ * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock.
++ *
++ * Note: the old pte is known to not be writable, so we don't need to
++ * worry about dirty bits etc getting lost.
++ */
++#ifndef __HAVE_ARCH_SET_PTE_ATOMIC
++#define ptep_establish(__vma, __address, __ptep, __entry) \
++do { \
++ set_pte(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#else /* __HAVE_ARCH_SET_PTE_ATOMIC */
++#define ptep_establish(__vma, __address, __ptep, __entry) \
++do { \
++ set_pte_atomic(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#endif /* __HAVE_ARCH_SET_PTE_ATOMIC */
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
++/*
++ * Largely same as above, but only sets the access flags (dirty,
++ * accessed, and writable). Furthermore, we know it always gets set
++ * to a "more permissive" setting, which allows most architectures
++ * to optimize this.
++ */
++#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
++do { \
++ set_pte(__ptep, __entry); \
++ flush_tlb_page(__vma, __address); \
++} while (0)
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
++static inline int ptep_test_and_clear_young(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_young(pte))
++ return 0;
++ set_pte(ptep, pte_mkold(pte));
++ return 1;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
++#define ptep_clear_flush_young(__vma, __address, __ptep) \
++({ \
++ int __young = ptep_test_and_clear_young(__ptep); \
++ if (__young) \
++ flush_tlb_page(__vma, __address); \
++ __young; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
++static inline int ptep_test_and_clear_dirty(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_dirty(pte))
++ return 0;
++ set_pte(ptep, pte_mkclean(pte));
++ return 1;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
++#define ptep_clear_flush_dirty(__vma, __address, __ptep) \
++({ \
++ int __dirty = ptep_test_and_clear_dirty(__ptep); \
++ if (__dirty) \
++ flush_tlb_page(__vma, __address); \
++ __dirty; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
++static inline pte_t ptep_get_and_clear(pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ pte_clear(ptep);
++ return pte;
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
++#define ptep_clear_flush(__vma, __address, __ptep) \
++({ \
++ pte_t __pte = ptep_get_and_clear(__ptep); \
++ flush_tlb_page(__vma, __address); \
++ __pte; \
++})
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
++static inline void ptep_set_wrprotect(pte_t *ptep)
++{
++ pte_t old_pte = *ptep;
++ set_pte(ptep, pte_wrprotect(old_pte));
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTEP_MKDIRTY
++static inline void ptep_mkdirty(pte_t *ptep)
++{
++ pte_t old_pte = *ptep;
++ set_pte(ptep, pte_mkdirty(old_pte));
++}
++#endif
++
++#ifndef __HAVE_ARCH_PTE_SAME
++#define pte_same(A,B) (pte_val(A) == pte_val(B))
++#endif
++
++#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
++#define page_test_and_clear_dirty(page) (0)
++#endif
++
++#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
++#define page_test_and_clear_young(page) (0)
++#endif
++
++#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
++#define pgd_offset_gate(mm, addr) pgd_offset(mm, addr)
++#endif
++
++#endif /* _ASM_GENERIC_PGTABLE_H */
+--- linux/include/asm-generic/rmap.h
++++ linux/include/asm-generic/rmap.h
+@@ -0,0 +1,90 @@
++#ifndef _GENERIC_RMAP_H
++#define _GENERIC_RMAP_H
++/*
++ * linux/include/asm-generic/rmap.h
++ *
++ * Architecture dependent parts of the reverse mapping code,
++ * this version should work for most architectures with a
++ * 'normal' page table layout.
++ *
++ * We use the struct page of the page table page to find out
++ * the process and full address of a page table entry:
++ * - page->mapping points to the process' mm_struct
++ * - page->index has the high bits of the address
++ * - the lower bits of the address are calculated from the
++ * offset of the page table entry within the page table page
++ *
++ * For CONFIG_HIGHPTE, we need to represent the address of a pte in a
++ * scalar pte_addr_t. The pfn of the pte's page is shifted left by PAGE_SIZE
++ * bits and is then ORed with the byte offset of the pte within its page.
++ *
++ * For CONFIG_HIGHMEM4G, the pte_addr_t is 32 bits. 20 for the pfn, 12 for
++ * the offset.
++ *
++ * For CONFIG_HIGHMEM64G, the pte_addr_t is 64 bits. 52 for the pfn, 12 for
++ * the offset.
++ */
++#include <linux/mm.h>
++
++static inline void pgtable_add_rmap(struct page * page, struct mm_struct * mm, unsigned long address)
++{
++#ifdef BROKEN_PPC_PTE_ALLOC_ONE
++ /* OK, so PPC calls pte_alloc() before mem_map[] is setup ... ;( */
++ extern int mem_init_done;
++
++ if (!mem_init_done)
++ return;
++#endif
++ page->mapping = (void *)mm;
++ page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
++ inc_page_state(nr_page_table_pages);
++}
++
++static inline void pgtable_remove_rmap(struct page * page)
++{
++ page->mapping = NULL;
++ page->index = 0;
++ dec_page_state(nr_page_table_pages);
++}
++
++static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
++{
++ struct page * page = kmap_atomic_to_page(ptep);
++ return (struct mm_struct *) page->mapping;
++}
++
++static inline unsigned long ptep_to_address(pte_t * ptep)
++{
++ struct page * page = kmap_atomic_to_page(ptep);
++ unsigned long low_bits;
++ low_bits = ((unsigned long)ptep & ~PAGE_MASK) * PTRS_PER_PTE;
++ return page->index + low_bits;
++}
++
++#ifdef CONFIG_HIGHPTE
++static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
++{
++ pte_addr_t paddr;
++ paddr = ((pte_addr_t)page_to_pfn(kmap_atomic_to_page(ptep))) << PAGE_SHIFT;
++ return paddr + (pte_addr_t)((unsigned long)ptep & ~PAGE_MASK);
++}
++#else
++static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
++{
++ return (pte_addr_t)ptep;
++}
++#endif
++
++#ifndef CONFIG_HIGHPTE
++static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
++{
++ return (pte_t *)pte_paddr;
++}
++
++static inline void rmap_ptep_unmap(pte_t *pte)
++{
++ return;
++}
++#endif
++
++#endif /* _GENERIC_RMAP_H */
+--- linux/include/asm-generic/rtc.h
++++ linux/include/asm-generic/rtc.h
+@@ -0,0 +1,213 @@
++/*
++ * inclue/asm-generic/rtc.h
++ *
++ * Author: Tom Rini <trini@mvista.com>
++ *
++ * Based on:
++ * drivers/char/rtc.c
++ *
++ * Please read the COPYING file for all license details.
++ */
++
++#ifndef __ASM_RTC_H__
++#define __ASM_RTC_H__
++
++#ifdef __KERNEL__
++
++#include <linux/mc146818rtc.h>
++#include <linux/rtc.h>
++#include <linux/bcd.h>
++
++#define RTC_PIE 0x40 /* periodic interrupt enable */
++#define RTC_AIE 0x20 /* alarm interrupt enable */
++#define RTC_UIE 0x10 /* update-finished interrupt enable */
++
++/* some dummy definitions */
++#define RTC_BATT_BAD 0x100 /* battery bad */
++#define RTC_SQWE 0x08 /* enable square-wave output */
++#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
++#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
++#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
++
++/*
++ * Returns true if a clock update is in progress
++ */
++static inline unsigned char rtc_is_updating(void)
++{
++ unsigned char uip;
++
++ spin_lock_irq(&rtc_lock);
++ uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
++ spin_unlock_irq(&rtc_lock);
++ return uip;
++}
++
++static inline unsigned int get_rtc_time(struct rtc_time *time)
++{
++ unsigned long uip_watchdog = jiffies;
++ unsigned char ctrl;
++#ifdef CONFIG_MACH_DECSTATION
++ unsigned int real_year;
++#endif
++
++ /*
++ * read RTC once any update in progress is done. The update
++ * can take just over 2ms. We wait 10 to 20ms. There is no need to
++ * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.
++ * If you need to know *exactly* when a second has started, enable
++ * periodic update complete interrupts, (via ioctl) and then
++ * immediately read /dev/rtc which will block until you get the IRQ.
++ * Once the read clears, read the RTC time (again via ioctl). Easy.
++ */
++
++ if (rtc_is_updating() != 0)
++ while (jiffies - uip_watchdog < 2*HZ/100) {
++ barrier();
++ cpu_relax();
++ }
++
++ /*
++ * Only the values that we read from the RTC are set. We leave
++ * tm_wday, tm_yday and tm_isdst untouched. Even though the
++ * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
++ * by the RTC when initially set to a non-zero value.
++ */
++ spin_lock_irq(&rtc_lock);
++ time->tm_sec = CMOS_READ(RTC_SECONDS);
++ time->tm_min = CMOS_READ(RTC_MINUTES);
++ time->tm_hour = CMOS_READ(RTC_HOURS);
++ time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
++ time->tm_mon = CMOS_READ(RTC_MONTH);
++ time->tm_year = CMOS_READ(RTC_YEAR);
++#ifdef CONFIG_MACH_DECSTATION
++ real_year = CMOS_READ(RTC_DEC_YEAR);
++#endif
++ ctrl = CMOS_READ(RTC_CONTROL);
++ spin_unlock_irq(&rtc_lock);
++
++ if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
++ {
++ BCD_TO_BIN(time->tm_sec);
++ BCD_TO_BIN(time->tm_min);
++ BCD_TO_BIN(time->tm_hour);
++ BCD_TO_BIN(time->tm_mday);
++ BCD_TO_BIN(time->tm_mon);
++ BCD_TO_BIN(time->tm_year);
++ }
++
++#ifdef CONFIG_MACH_DECSTATION
++ time->tm_year += real_year - 72;
++#endif
++
++ /*
++ * Account for differences between how the RTC uses the values
++ * and how they are defined in a struct rtc_time;
++ */
++ if (time->tm_year <= 69)
++ time->tm_year += 100;
++
++ time->tm_mon--;
++
++ return RTC_24H;
++}
++
++/* Set the current date and time in the real time clock. */
++static inline int set_rtc_time(struct rtc_time *time)
++{
++ unsigned char mon, day, hrs, min, sec;
++ unsigned char save_control, save_freq_select;
++ unsigned int yrs;
++#ifdef CONFIG_MACH_DECSTATION
++ unsigned int real_yrs, leap_yr;
++#endif
++
++ yrs = time->tm_year;
++ mon = time->tm_mon + 1; /* tm_mon starts at zero */
++ day = time->tm_mday;
++ hrs = time->tm_hour;
++ min = time->tm_min;
++ sec = time->tm_sec;
++
++ if (yrs > 255) /* They are unsigned */
++ return -EINVAL;
++
++ spin_lock_irq(&rtc_lock);
++#ifdef CONFIG_MACH_DECSTATION
++ real_yrs = yrs;
++ leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
++ !((yrs + 1900) % 400));
++ yrs = 72;
++
++ /*
++ * We want to keep the year set to 73 until March
++ * for non-leap years, so that Feb, 29th is handled
++ * correctly.
++ */
++ if (!leap_yr && mon < 3) {
++ real_yrs--;
++ yrs = 73;
++ }
++#endif
++ /* These limits and adjustments are independent of
++ * whether the chip is in binary mode or not.
++ */
++ if (yrs > 169) {
++ spin_unlock_irq(&rtc_lock);
++ return -EINVAL;
++ }
++
++ if (yrs >= 100)
++ yrs -= 100;
++
++ if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
++ || RTC_ALWAYS_BCD) {
++ BIN_TO_BCD(sec);
++ BIN_TO_BCD(min);
++ BIN_TO_BCD(hrs);
++ BIN_TO_BCD(day);
++ BIN_TO_BCD(mon);
++ BIN_TO_BCD(yrs);
++ }
++
++ save_control = CMOS_READ(RTC_CONTROL);
++ CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
++ save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
++ CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
++
++#ifdef CONFIG_MACH_DECSTATION
++ CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
++#endif
++ CMOS_WRITE(yrs, RTC_YEAR);
++ CMOS_WRITE(mon, RTC_MONTH);
++ CMOS_WRITE(day, RTC_DAY_OF_MONTH);
++ CMOS_WRITE(hrs, RTC_HOURS);
++ CMOS_WRITE(min, RTC_MINUTES);
++ CMOS_WRITE(sec, RTC_SECONDS);
++
++ CMOS_WRITE(save_control, RTC_CONTROL);
++ CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
++
++ spin_unlock_irq(&rtc_lock);
++
++ return 0;
++}
++
++static inline unsigned int get_rtc_ss(void)
++{
++ struct rtc_time h;
++
++ get_rtc_time(&h);
++ return h.tm_sec;
++}
++
++static inline int get_rtc_pll(struct rtc_pll_info *pll)
++{
++ return -EINVAL;
++}
++static inline int set_rtc_pll(struct rtc_pll_info *pll)
++{
++ return -EINVAL;
++}
++
++#endif /* __KERNEL__ */
++#endif /* __ASM_RTC_H__ */
+--- linux/include/asm-generic/sections.h
++++ linux/include/asm-generic/sections.h
+@@ -0,0 +1,12 @@
++#ifndef _ASM_GENERIC_SECTIONS_H_
++#define _ASM_GENERIC_SECTIONS_H_
++
++/* References to section boundaries */
++
++extern char _text[], _stext[], _etext[];
++extern char _data[], _sdata[], _edata[];
++extern char __bss_start[], __bss_stop[];
++extern char __init_begin[], __init_end[];
++extern char _sinittext[], _einittext[];
++
++#endif /* _ASM_GENERIC_SECTIONS_H_ */
+--- linux/include/asm-generic/siginfo.h
++++ linux/include/asm-generic/siginfo.h
+@@ -0,0 +1,295 @@
++#ifndef _ASM_GENERIC_SIGINFO_H
++#define _ASM_GENERIC_SIGINFO_H
++
++#include <linux/compiler.h>
++#include <linux/types.h>
++#include <linux/resource.h>
++
++typedef union sigval {
++ int sival_int;
++ void __user *sival_ptr;
++} sigval_t;
++
++/*
++ * This is the size (including padding) of the part of the
++ * struct siginfo that is before the union.
++ */
++#ifndef __ARCH_SI_PREAMBLE_SIZE
++#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
++#endif
++
++#define SI_MAX_SIZE 128
++#ifndef SI_PAD_SIZE
++#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
++#endif
++
++#ifndef __ARCH_SI_UID_T
++#define __ARCH_SI_UID_T uid_t
++#endif
++
++/*
++ * The default "si_band" type is "long", as specified by POSIX.
++ * However, some architectures want to override this to "int"
++ * for historical compatibility reasons, so we allow that.
++ */
++#ifndef __ARCH_SI_BAND_T
++#define __ARCH_SI_BAND_T long
++#endif
++
++#ifndef HAVE_ARCH_SIGINFO_T
++
++typedef struct siginfo {
++ int si_signo;
++ int si_errno;
++ int si_code;
++
++ union {
++ int _pad[SI_PAD_SIZE];
++
++ /* kill() */
++ struct {
++ pid_t _pid; /* sender's pid */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ } _kill;
++
++ /* POSIX.1b timers */
++ struct {
++ timer_t _tid; /* timer id */
++ int _overrun; /* overrun count */
++ char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
++ sigval_t _sigval; /* same as below */
++ int _sys_private; /* not to be passed to user */
++ } _timer;
++
++ /* POSIX.1b signals */
++ struct {
++ pid_t _pid; /* sender's pid */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ sigval_t _sigval;
++ } _rt;
++
++ /* SIGCHLD */
++ struct {
++ pid_t _pid; /* which child */
++ __ARCH_SI_UID_T _uid; /* sender's uid */
++ int _status; /* exit code */
++ clock_t _utime;
++ clock_t _stime;
++ } _sigchld;
++
++ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
++ struct {
++ void __user *_addr; /* faulting insn/memory ref. */
++#ifdef __ARCH_SI_TRAPNO
++ int _trapno; /* TRAP # which caused the signal */
++#endif
++ } _sigfault;
++
++ /* SIGPOLL */
++ struct {
++ __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
++ int _fd;
++ } _sigpoll;
++ } _sifields;
++} siginfo_t;
++
++#endif
++
++/*
++ * How these fields are to be accessed.
++ */
++#define si_pid _sifields._kill._pid
++#define si_uid _sifields._kill._uid
++#define si_tid _sifields._timer._tid
++#define si_overrun _sifields._timer._overrun
++#define si_sys_private _sifields._timer._sys_private
++#define si_status _sifields._sigchld._status
++#define si_utime _sifields._sigchld._utime
++#define si_stime _sifields._sigchld._stime
++#define si_value _sifields._rt._sigval
++#define si_int _sifields._rt._sigval.sival_int
++#define si_ptr _sifields._rt._sigval.sival_ptr
++#define si_addr _sifields._sigfault._addr
++#ifdef __ARCH_SI_TRAPNO
++#define si_trapno _sifields._sigfault._trapno
++#endif
++#define si_band _sifields._sigpoll._band
++#define si_fd _sifields._sigpoll._fd
++
++#ifdef __KERNEL__
++#define __SI_MASK 0xffff0000u
++#define __SI_KILL (0 << 16)
++#define __SI_TIMER (1 << 16)
++#define __SI_POLL (2 << 16)
++#define __SI_FAULT (3 << 16)
++#define __SI_CHLD (4 << 16)
++#define __SI_RT (5 << 16)
++#define __SI_MESGQ (6 << 16)
++#define __SI_CODE(T,N) ((T) | ((N) & 0xffff))
++#else
++#define __SI_KILL 0
++#define __SI_TIMER 0
++#define __SI_POLL 0
++#define __SI_FAULT 0
++#define __SI_CHLD 0
++#define __SI_RT 0
++#define __SI_MESGQ 0
++#define __SI_CODE(T,N) (N)
++#endif
++
++/*
++ * si_code values
++ * Digital reserves positive values for kernel-generated signals.
++ */
++#define SI_USER 0 /* sent by kill, sigsend, raise */
++#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
++#define SI_QUEUE -1 /* sent by sigqueue */
++#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
++#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */
++#define SI_ASYNCIO -4 /* sent by AIO completion */
++#define SI_SIGIO -5 /* sent by queued SIGIO */
++#define SI_TKILL -6 /* sent by tkill system call */
++#define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
++
++#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
++#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
++
++#ifndef HAVE_ARCH_SI_CODES
++/*
++ * SIGILL si_codes
++ */
++#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */
++#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */
++#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */
++#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */
++#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */
++#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */
++#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */
++#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */
++#define NSIGILL 8
++
++/*
++ * SIGFPE si_codes
++ */
++#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */
++#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */
++#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */
++#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */
++#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */
++#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */
++#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */
++#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */
++#define NSIGFPE 8
++
++/*
++ * SIGSEGV si_codes
++ */
++#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
++#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */
++#define NSIGSEGV 2
++
++/*
++ * SIGBUS si_codes
++ */
++#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
++#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */
++#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
++#define NSIGBUS 3
++
++/*
++ * SIGTRAP si_codes
++ */
++#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */
++#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */
++#define NSIGTRAP 2
++
++/*
++ * SIGCHLD si_codes
++ */
++#define CLD_EXITED (__SI_CHLD|1) /* child has exited */
++#define CLD_KILLED (__SI_CHLD|2) /* child was killed */
++#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */
++#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */
++#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */
++#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */
++#define NSIGCHLD 6
++
++/*
++ * SIGPOLL si_codes
++ */
++#define POLL_IN (__SI_POLL|1) /* data input available */
++#define POLL_OUT (__SI_POLL|2) /* output buffers available */
++#define POLL_MSG (__SI_POLL|3) /* input message available */
++#define POLL_ERR (__SI_POLL|4) /* i/o error */
++#define POLL_PRI (__SI_POLL|5) /* high priority input available */
++#define POLL_HUP (__SI_POLL|6) /* device disconnected */
++#define NSIGPOLL 6
++
++#endif
++
++/*
++ * sigevent definitions
++ *
++ * It seems likely that SIGEV_THREAD will have to be handled from
++ * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
++ * thread manager then catches and does the appropriate nonsense.
++ * However, everything is written out here so as to not get lost.
++ */
++#define SIGEV_SIGNAL 0 /* notify via signal */
++#define SIGEV_NONE 1 /* other notification: meaningless */
++#define SIGEV_THREAD 2 /* deliver via thread creation */
++#define SIGEV_THREAD_ID 4 /* deliver to thread */
++
++#define SIGEV_MAX_SIZE 64
++#ifndef SIGEV_PAD_SIZE
++#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
++#endif
++
++#ifndef HAVE_ARCH_SIGEVENT_T
++
++typedef struct sigevent {
++ sigval_t sigev_value;
++ int sigev_signo;
++ int sigev_notify;
++ union {
++ int _pad[SIGEV_PAD_SIZE];
++ int _tid;
++
++ struct {
++ void (*_function)(sigval_t);
++ void *_attribute; /* really pthread_attr_t */
++ } _sigev_thread;
++ } _sigev_un;
++} sigevent_t;
++
++#endif
++
++#define sigev_notify_function _sigev_un._sigev_thread._function
++#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
++#define sigev_notify_thread_id _sigev_un._tid
++
++#ifdef __KERNEL__
++
++struct siginfo;
++void do_schedule_next_timer(struct siginfo *info);
++
++#ifndef HAVE_ARCH_COPY_SIGINFO
++
++#include <linux/string.h>
++
++static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
++{
++ if (from->si_code < 0)
++ memcpy(to, from, sizeof(*to));
++ else
++ /* _sigchld is currently the largest know union member */
++ memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
++}
++
++#endif
++
++extern int copy_siginfo_to_user(struct siginfo __user *to, struct siginfo *from);
++
++#endif /* __KERNEL__ */
++
++#endif
+--- linux/include/asm-generic/statfs.h
++++ linux/include/asm-generic/statfs.h
+@@ -0,0 +1,51 @@
++#ifndef _GENERIC_STATFS_H
++#define _GENERIC_STATFS_H
++
++#ifndef __KERNEL_STRICT_NAMES
++# include <linux/types.h>
++typedef __kernel_fsid_t fsid_t;
++#endif
++
++struct statfs {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u32 f_blocks;
++ __u32 f_bfree;
++ __u32 f_bavail;
++ __u32 f_files;
++ __u32 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++struct statfs64 {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u64 f_blocks;
++ __u64 f_bfree;
++ __u64 f_bavail;
++ __u64 f_files;
++ __u64 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++struct compat_statfs64 {
++ __u32 f_type;
++ __u32 f_bsize;
++ __u64 f_blocks;
++ __u64 f_bfree;
++ __u64 f_bavail;
++ __u64 f_files;
++ __u64 f_ffree;
++ __kernel_fsid_t f_fsid;
++ __u32 f_namelen;
++ __u32 f_frsize;
++ __u32 f_spare[5];
++};
++
++#endif
+--- linux/include/asm-generic/tlb.h
++++ linux/include/asm-generic/tlb.h
+@@ -0,0 +1,152 @@
++/* asm-generic/tlb.h
++ *
++ * Generic TLB shootdown code
++ *
++ * Copyright 2001 Red Hat, Inc.
++ * Based on code from mm/memory.c Copyright Linus Torvalds and others.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++ */
++#ifndef _ASM_GENERIC__TLB_H
++#define _ASM_GENERIC__TLB_H
++
++// #include <linux/config.h>
++#include <linux/swap.h>
++#include <asm/pgalloc.h>
++#include <asm/tlbflush.h>
++
++/*
++ * For UP we don't need to worry about TLB flush
++ * and page free order so much..
++ */
++#ifdef CONFIG_SMP
++ #define FREE_PTE_NR 506
++ #define tlb_fast_mode(tlb) ((tlb)->nr == ~0U)
++#else
++ #define FREE_PTE_NR 1
++ #define tlb_fast_mode(tlb) 1
++#endif
++
++/* struct mmu_gather is an opaque type used by the mm code for passing around
++ * any data needed by arch specific code for tlb_remove_page. This structure
++ * can be per-CPU or per-MM as the page table lock is held for the duration of
++ * TLB shootdown.
++ */
++struct mmu_gather {
++ struct mm_struct *mm;
++ unsigned int nr; /* set to ~0U means fast mode */
++ unsigned int need_flush;/* Really unmapped some ptes? */
++ unsigned int fullmm; /* non-zero means full mm flush */
++ unsigned long freed;
++ struct page * pages[FREE_PTE_NR];
++};
++
++/* Users of the generic TLB shootdown code must declare this storage space. */
++DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
++
++/* tlb_gather_mmu
++ * Return a pointer to an initialized struct mmu_gather.
++ */
++static inline struct mmu_gather *
++tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
++{
++ struct mmu_gather *tlb = &per_cpu(mmu_gathers, smp_processor_id());
++
++ tlb->mm = mm;
++
++ /* Use fast mode if only one CPU is online */
++ tlb->nr = num_online_cpus() > 1 ? 0U : ~0U;
++
++ tlb->fullmm = full_mm_flush;
++ tlb->freed = 0;
++
++ return tlb;
++}
++
++static inline void
++tlb_flush_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
++{
++ if (!tlb->need_flush)
++ return;
++ tlb->need_flush = 0;
++ tlb_flush(tlb);
++ if (!tlb_fast_mode(tlb)) {
++ free_pages_and_swap_cache(tlb->pages, tlb->nr);
++ tlb->nr = 0;
++ }
++}
++
++/* tlb_finish_mmu
++ * Called at the end of the shootdown operation to free up any resources
++ * that were required. The page table lock is still held at this point.
++ */
++static inline void
++tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
++{
++ int freed = tlb->freed;
++ struct mm_struct *mm = tlb->mm;
++ int rss = mm->rss;
++
++ if (rss < freed)
++ freed = rss;
++ mm->rss = rss - freed;
++ tlb_flush_mmu(tlb, start, end);
++
++ /* keep the page table cache within bounds */
++ check_pgt_cache();
++}
++
++static inline unsigned int
++tlb_is_full_mm(struct mmu_gather *tlb)
++{
++ return tlb->fullmm;
++}
++
++/* tlb_remove_page
++ * Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), while
++ * handling the additional races in SMP caused by other CPUs caching valid
++ * mappings in their TLBs.
++ */
++static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
++{
++ tlb->need_flush = 1;
++ if (tlb_fast_mode(tlb)) {
++ free_page_and_swap_cache(page);
++ return;
++ }
++ tlb->pages[tlb->nr++] = page;
++ if (tlb->nr >= FREE_PTE_NR)
++ tlb_flush_mmu(tlb, 0, 0);
++}
++
++/**
++ * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation.
++ *
++ * Record the fact that pte's were really umapped in ->need_flush, so we can
++ * later optimise away the tlb invalidate. This helps when userspace is
++ * unmapping already-unmapped pages, which happens quite a lot.
++ */
++#define tlb_remove_tlb_entry(tlb, ptep, address) \
++ do { \
++ tlb->need_flush = 1; \
++ __tlb_remove_tlb_entry(tlb, ptep, address); \
++ } while (0)
++
++#define pte_free_tlb(tlb, ptep) \
++ do { \
++ tlb->need_flush = 1; \
++ __pte_free_tlb(tlb, ptep); \
++ } while (0)
++
++#define pmd_free_tlb(tlb, pmdp) \
++ do { \
++ tlb->need_flush = 1; \
++ __pmd_free_tlb(tlb, pmdp); \
++ } while (0)
++
++#define tlb_migrate_finish(mm) do {} while (0)
++
++#endif /* _ASM_GENERIC__TLB_H */
+--- linux/include/asm-generic/topology.h
++++ linux/include/asm-generic/topology.h
+@@ -0,0 +1,53 @@
++/*
++ * linux/include/asm-generic/topology.h
++ *
++ * Written by: Matthew Dobson, IBM Corporation
++ *
++ * Copyright (C) 2002, IBM Corp.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ * Send feedback to <colpatch@us.ibm.com>
++ */
++#ifndef _ASM_GENERIC_TOPOLOGY_H
++#define _ASM_GENERIC_TOPOLOGY_H
++
++/* Other architectures wishing to use this simple topology API should fill
++ in the below functions as appropriate in their own <asm/topology.h> file. */
++#ifndef cpu_to_node
++#define cpu_to_node(cpu) (0)
++#endif
++#ifndef parent_node
++#define parent_node(node) (0)
++#endif
++#ifndef node_to_cpumask
++#define node_to_cpumask(node) (cpu_online_map)
++#endif
++#ifndef node_to_first_cpu
++#define node_to_first_cpu(node) (0)
++#endif
++#ifndef pcibus_to_cpumask
++#define pcibus_to_cpumask(bus) (cpu_online_map)
++#endif
++
++/* Cross-node load balancing interval. */
++#ifndef NODE_BALANCE_RATE
++#define NODE_BALANCE_RATE 10
++#endif
++
++#endif /* _ASM_GENERIC_TOPOLOGY_H */
+--- linux/include/asm-generic/uaccess.h
++++ linux/include/asm-generic/uaccess.h
+@@ -0,0 +1,26 @@
++#ifndef _ASM_GENERIC_UACCESS_H_
++#define _ASM_GENERIC_UACCESS_H_
++
++/*
++ * This macro should be used instead of __get_user() when accessing
++ * values at locations that are not known to be aligned.
++ */
++#define __get_user_unaligned(x, ptr) \
++({ \
++ __typeof__ (*(ptr)) __x; \
++ __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0; \
++ (x) = __x; \
++})
++
++
++/*
++ * This macro should be used instead of __put_user() when accessing
++ * values at locations that are not known to be aligned.
++ */
++#define __put_user_unaligned(x, ptr) \
++({ \
++ __typeof__ (*(ptr)) __x = (x); \
++ __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0; \
++})
++
++#endif /* _ASM_GENERIC_UACCESS_H */
+--- linux/include/asm-generic/unaligned.h
++++ linux/include/asm-generic/unaligned.h
+@@ -0,0 +1,20 @@
++#ifndef _ASM_GENERIC_UNALIGNED_H_
++#define _ASM_GENERIC_UNALIGNED_H_
++
++/*
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents.
++ */
++
++#include <asm/string.h>
++
++
++#define get_unaligned(ptr) \
++ ({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
++
++#define put_unaligned(val, ptr) \
++ ({ __typeof__(*(ptr)) __tmp = (val); \
++ memcpy((ptr), &__tmp, sizeof(*(ptr))); \
++ (void)0; })
++
++#endif /* _ASM_GENERIC_UNALIGNED_H */
+--- linux/include/asm-generic/vmlinux.lds.h
++++ linux/include/asm-generic/vmlinux.lds.h
+@@ -0,0 +1,84 @@
++#ifndef LOAD_OFFSET
++#define LOAD_OFFSET 0
++#endif
++
++#ifndef VMLINUX_SYMBOL
++#define VMLINUX_SYMBOL(_sym_) _sym_
++#endif
++
++#define RODATA \
++ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
++ *(.rodata) *(.rodata.*) \
++ *(__vermagic) /* Kernel version magic */ \
++ } \
++ \
++ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
++ *(.rodata1) \
++ } \
++ \
++ /* PCI quirks */ \
++ .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
++ *(.pci_fixup_header) \
++ VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
++ VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
++ *(.pci_fixup_final) \
++ VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
++ } \
++ \
++ /* Kernel symbol table: Normal symbols */ \
++ __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___ksymtab) = .; \
++ *(__ksymtab) \
++ VMLINUX_SYMBOL(__stop___ksymtab) = .; \
++ } \
++ \
++ /* Kernel symbol table: GPL-only symbols */ \
++ __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
++ *(__ksymtab_gpl) \
++ VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
++ } \
++ \
++ /* Kernel symbol table: Normal symbols */ \
++ __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___kcrctab) = .; \
++ *(__kcrctab) \
++ VMLINUX_SYMBOL(__stop___kcrctab) = .; \
++ } \
++ \
++ /* Kernel symbol table: GPL-only symbols */ \
++ __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
++ *(__kcrctab_gpl) \
++ VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
++ } \
++ \
++ /* Kernel symbol table: strings */ \
++ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
++ *(__ksymtab_strings) \
++ } \
++ \
++ /* Built-in module parameters. */ \
++ __param : AT(ADDR(__param) - LOAD_OFFSET) { \
++ VMLINUX_SYMBOL(__start___param) = .; \
++ *(__param) \
++ VMLINUX_SYMBOL(__stop___param) = .; \
++ }
++
++#define SECURITY_INIT \
++ .security_initcall.init : { \
++ VMLINUX_SYMBOL(__security_initcall_start) = .; \
++ *(.security_initcall.init) \
++ VMLINUX_SYMBOL(__security_initcall_end) = .; \
++ }
++
++#define SCHED_TEXT \
++ VMLINUX_SYMBOL(__sched_text_start) = .; \
++ *(.sched.text) \
++ VMLINUX_SYMBOL(__sched_text_end) = .;
++
++#define LOCK_TEXT \
++ VMLINUX_SYMBOL(__lock_text_start) = .; \
++ *(.spinlock.text) \
++ VMLINUX_SYMBOL(__lock_text_end) = .;
+--- linux/include/asm-generic/xor.h
++++ linux/include/asm-generic/xor.h
+@@ -0,0 +1,718 @@
++/*
++ * include/asm-generic/xor.h
++ *
++ * Generic optimized RAID-5 checksumming functions.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * You should have received a copy of the GNU General Public License
++ * (for example /usr/src/linux/COPYING); if not, write to the Free
++ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <asm/processor.h>
++
++static void
++xor_8regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0];
++ p1[1] ^= p2[1];
++ p1[2] ^= p2[2];
++ p1[3] ^= p2[3];
++ p1[4] ^= p2[4];
++ p1[5] ^= p2[5];
++ p1[6] ^= p2[6];
++ p1[7] ^= p2[7];
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0];
++ p1[1] ^= p2[1] ^ p3[1];
++ p1[2] ^= p2[2] ^ p3[2];
++ p1[3] ^= p2[3] ^ p3[3];
++ p1[4] ^= p2[4] ^ p3[4];
++ p1[5] ^= p2[5] ^ p3[5];
++ p1[6] ^= p2[6] ^ p3[6];
++ p1[7] ^= p2[7] ^ p3[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_32regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8;
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ d0 ^= p5[0];
++ d1 ^= p5[1];
++ d2 ^= p5[2];
++ d3 ^= p5[3];
++ d4 ^= p5[4];
++ d5 ^= p5[5];
++ d6 ^= p5[6];
++ d7 ^= p5[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++}
++
++static void
++xor_8regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++ prefetchw(p1);
++ prefetch(p2);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ once_more:
++ p1[0] ^= p2[0];
++ p1[1] ^= p2[1];
++ p1[2] ^= p2[2];
++ p1[3] ^= p2[3];
++ p1[4] ^= p2[4];
++ p1[5] ^= p2[5];
++ p1[6] ^= p2[6];
++ p1[7] ^= p2[7];
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0];
++ p1[1] ^= p2[1] ^ p3[1];
++ p1[2] ^= p2[2] ^ p3[2];
++ p1[3] ^= p2[3] ^ p3[3];
++ p1[4] ^= p2[4] ^ p3[4];
++ p1[5] ^= p2[5] ^ p3[5];
++ p1[6] ^= p2[6] ^ p3[6];
++ p1[7] ^= p2[7] ^ p3[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_8regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++ prefetch(p5);
++
++ do {
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ prefetch(p5+8);
++ once_more:
++ p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
++ p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
++ p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
++ p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
++ p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
++ p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
++ p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
++ p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static void
++xor_32regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
++ unsigned long *p3, unsigned long *p4, unsigned long *p5)
++{
++ long lines = bytes / (sizeof (long)) / 8 - 1;
++
++ prefetchw(p1);
++ prefetch(p2);
++ prefetch(p3);
++ prefetch(p4);
++ prefetch(p5);
++
++ do {
++ register long d0, d1, d2, d3, d4, d5, d6, d7;
++
++ prefetchw(p1+8);
++ prefetch(p2+8);
++ prefetch(p3+8);
++ prefetch(p4+8);
++ prefetch(p5+8);
++ once_more:
++ d0 = p1[0]; /* Pull the stuff into registers */
++ d1 = p1[1]; /* ... in bursts, if possible. */
++ d2 = p1[2];
++ d3 = p1[3];
++ d4 = p1[4];
++ d5 = p1[5];
++ d6 = p1[6];
++ d7 = p1[7];
++ d0 ^= p2[0];
++ d1 ^= p2[1];
++ d2 ^= p2[2];
++ d3 ^= p2[3];
++ d4 ^= p2[4];
++ d5 ^= p2[5];
++ d6 ^= p2[6];
++ d7 ^= p2[7];
++ d0 ^= p3[0];
++ d1 ^= p3[1];
++ d2 ^= p3[2];
++ d3 ^= p3[3];
++ d4 ^= p3[4];
++ d5 ^= p3[5];
++ d6 ^= p3[6];
++ d7 ^= p3[7];
++ d0 ^= p4[0];
++ d1 ^= p4[1];
++ d2 ^= p4[2];
++ d3 ^= p4[3];
++ d4 ^= p4[4];
++ d5 ^= p4[5];
++ d6 ^= p4[6];
++ d7 ^= p4[7];
++ d0 ^= p5[0];
++ d1 ^= p5[1];
++ d2 ^= p5[2];
++ d3 ^= p5[3];
++ d4 ^= p5[4];
++ d5 ^= p5[5];
++ d6 ^= p5[6];
++ d7 ^= p5[7];
++ p1[0] = d0; /* Store the result (in bursts) */
++ p1[1] = d1;
++ p1[2] = d2;
++ p1[3] = d3;
++ p1[4] = d4;
++ p1[5] = d5;
++ p1[6] = d6;
++ p1[7] = d7;
++ p1 += 8;
++ p2 += 8;
++ p3 += 8;
++ p4 += 8;
++ p5 += 8;
++ } while (--lines > 0);
++ if (lines == 0)
++ goto once_more;
++}
++
++static struct xor_block_template xor_block_8regs = {
++ .name = "8regs",
++ .do_2 = xor_8regs_2,
++ .do_3 = xor_8regs_3,
++ .do_4 = xor_8regs_4,
++ .do_5 = xor_8regs_5,
++};
++
++static struct xor_block_template xor_block_32regs = {
++ .name = "32regs",
++ .do_2 = xor_32regs_2,
++ .do_3 = xor_32regs_3,
++ .do_4 = xor_32regs_4,
++ .do_5 = xor_32regs_5,
++};
++
++static struct xor_block_template xor_block_8regs_p = {
++ .name = "8regs_prefetch",
++ .do_2 = xor_8regs_p_2,
++ .do_3 = xor_8regs_p_3,
++ .do_4 = xor_8regs_p_4,
++ .do_5 = xor_8regs_p_5,
++};
++
++static struct xor_block_template xor_block_32regs_p = {
++ .name = "32regs_prefetch",
++ .do_2 = xor_32regs_p_2,
++ .do_3 = xor_32regs_p_3,
++ .do_4 = xor_32regs_p_4,
++ .do_5 = xor_32regs_p_5,
++};
++
++#define XOR_TRY_TEMPLATES \
++ do { \
++ xor_speed(&xor_block_8regs); \
++ xor_speed(&xor_block_8regs_p); \
++ xor_speed(&xor_block_32regs); \
++ xor_speed(&xor_block_32regs_p); \
++ } while (0)
+--- linux/include/asm-nios2nommu/ChangeLog
++++ linux/include/asm-nios2nommu/ChangeLog
+@@ -0,0 +1,14 @@
++2004-06-29 Ken Hill <khill@microtronix.com>
++
++ * bitops.h (find_next_zero_bit): Fix problem with with masking for found_first
++ handling. The masking of the upper bits for size < 32 bits would set all
++ the bits to 1. Removing any zero's there may have been.
++
++2004-06-02 Ken Hill <khill@microtronix.com>
++
++ * processor.h (TASK_SIZE): Change na_sdram_end to nasys_program_mem_end to remove
++ dependancy on quartus memory component name.
++
++ * page.h (PAGE_OFFSET): Change na_sdram to nasys_program_mem to remove
++ dependancy on quartus memory component name.
++
+--- linux/include/asm-nios2nommu/a.out.h
++++ linux/include/asm-nios2nommu/a.out.h
+@@ -0,0 +1,85 @@
++/* $Id: a.out.h,v 1.4 2004/03/30 19:35:04 ken-h Exp $ */
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2NOMMU_A_OUT_H__
++#define __NIOS2NOMMU_A_OUT_H__
++
++#define SPARC_PGSIZE 0x1000 /* Thanks to the sun4 architecture... */
++#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
++
++struct exec {
++ unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
++ unsigned char a_toolversion:7;
++ unsigned char a_machtype;
++ unsigned short a_info;
++ unsigned long a_text; /* length of text, in bytes */
++ unsigned long a_data; /* length of data, in bytes */
++ unsigned long a_bss; /* length of bss, in bytes */
++ unsigned long a_syms; /* length of symbol table, in bytes */
++ unsigned long a_entry; /* where program begins */
++ unsigned long a_trsize;
++ unsigned long a_drsize;
++};
++
++#define INIT_EXEC { \
++ .a_dynamic = 0, \
++ .a_toolversion = 0, \
++ .a_machtype = 0, \
++ .a_info = 0, \
++ .a_text = 0, \
++ .a_data = 0, \
++ .a_bss = 0, \
++ .a_syms = 0, \
++ .a_entry = 0, \
++ .a_trsize = 0, \
++ .a_drsize = 0, \
++}
++
++/* Where in the file does the text information begin? */
++#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
++
++/* Where do the Symbols start? */
++#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
++ (x).a_data + (x).a_trsize + \
++ (x).a_drsize)
++
++/* Where does text segment go in memory after being loaded? */
++#define N_TXTADDR(x) (((N_MAGIC(x) == ZMAGIC) && \
++ ((x).a_entry < SPARC_PGSIZE)) ? \
++ 0 : SPARC_PGSIZE)
++
++/* And same for the data segment.. */
++#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
++ (N_TXTADDR(x) + (x).a_text) \
++ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
++
++#define N_TRSIZE(a) ((a).a_trsize)
++#define N_DRSIZE(a) ((a).a_drsize)
++#define N_SYMSIZE(a) ((a).a_syms)
++
++#ifdef __KERNEL__
++
++#define STACK_TOP TASK_SIZE
++
++#endif
++
++#endif /* __NIOS2NOMMU_A_OUT_H__ */
+--- linux/include/asm-nios2nommu/asm-macros.h
++++ linux/include/asm-nios2nommu/asm-macros.h
+@@ -0,0 +1,331 @@
++/*
++ * Macro used to simplify coding multi-line assembler.
++ * Some of the bit test macro can simplify down to one line
++ * depending on the mask value.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++/*
++ * ANDs reg2 with mask and places the result in reg1.
++ *
++ * You cannnot use the same register for reg1 & reg2.
++ */
++
++.macro ANDI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ movhi \reg1,%hi(\mask)
++ movui \reg1,%lo(\mask)
++ and \reg1,\reg1,\reg2
++ .else
++ andi \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ andhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * ORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro ORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ orhi \reg1,\reg2,%hi(\mask)
++ ori \reg1,\reg2,%lo(\mask)
++ .else
++ ori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ orhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * XORs reg2 with mask and places the result in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro XORI32 reg1,reg2,mask
++ .if \mask & 0xffff
++ .if \mask & 0xffff0000
++ xorhi \reg1,\reg2,%hi(\mask)
++ xori \reg1,\reg1,%lo(\mask)
++ .else
++ xori \reg1,\reg2,%lo(\mask)
++ .endif
++ .else
++ xorhi \reg1,\reg2,%hi(\mask)
++ .endif
++.endm
++
++/*
++ * This is a support macro for BTBZ & BTBNZ. It checks
++ * the bit to make sure it is valid 32 value.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BT reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and branches to label if the
++ * bit is non-zero. The result of the bit test is stored in reg1.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTBNZ reg1,reg2,bit,label
++ BT \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTC reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ xori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ xorhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTS reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ ori \reg2,\reg2,(1 << \bit)
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ orhi \reg2,\reg2,(1 << (\bit - 16))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTR reg1,reg2,bit
++.if \bit > 31
++ .err
++.else
++ .if \bit < 16
++ andi \reg1,\reg2,(1 << \bit)
++ andi \reg2,\reg2,%lo(~(1 << \bit))
++ .else
++ andhi \reg1,\reg2,(1 << (\bit - 16))
++ andhi \reg2,\reg2,%lo(~(1 << (\bit - 16)))
++ .endif
++.endif
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then compliments the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTCBNZ reg1,reg2,bit,label
++ BTC \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then sets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTSBNZ reg1,reg2,bit,label
++ BTS \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bit in reg2 and then resets the bit in reg2.
++ * The result of the bit test is stored in reg1. If the
++ * original bit was non-zero it branches to label.
++ *
++ * It is NOT safe to use the same register for reg1 & reg2.
++ */
++
++.macro BTRBNZ reg1,reg2,bit,label
++ BTR \reg1,\reg2,\bit
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the all the bits in the mask are zero it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ beq \reg1,r0,\label
++.endm
++
++/*
++ * Tests the bits in mask against reg2 stores the result in reg1.
++ * If the any of the bits in the mask are 1 it branches to label.
++ *
++ * It is safe to use the same register for reg1 & reg2.
++ */
++
++.macro TSTBNZ reg1,reg2,mask,label
++ ANDI32 \reg1,\reg2,\mask
++ bne \reg1,r0,\label
++.endm
++
++/*
++ * Pushes reg onto the stack.
++ */
++
++.macro PUSH reg
++ addi sp,sp,-4
++ stw \reg,0(sp)
++.endm
++
++/*
++ * Pops the top of the stack into reg.
++ */
++
++.macro POP reg
++ ldw \reg,0(sp)
++ addi sp,sp,4
++.endm
++
++/*
++ * Clears reg
++ */
++
++.macro CLR reg
++ mov \reg,r0
++.endm
++
++/*
++ * The preprocessor macro does not work for
++ * the nios2 compiler. Undefine ENTRY and define
++ * a real assembler macro.
++ */
++#undef ENTRY
++#define ENTRY(name) ASM_ENTRY name
++
++.macro ASM_ENTRY name
++.globl \name
++__ALIGN
++ \name:
++.endm
+--- linux/include/asm-nios2nommu/atomic.h
++++ linux/include/asm-nios2nommu/atomic.h
+@@ -0,0 +1,190 @@
++//vic - add 'atomic_add/sub_return', 'atomic_add_negative'
++//vic from v850 architecture
++
++/* atomic.h:
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2001 Vic Phillips (vic@microtronix.com)
++ *
++ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ARCH_NIOS2NOMMU_ATOMIC__
++#define __ARCH_NIOS2NOMMU_ATOMIC__
++
++#include <asm/system.h>
++
++typedef struct { int counter; } atomic_t;
++#define ATOMIC_INIT(i) { (i) }
++
++#define atomic_read(v) ((v)->counter)
++#define atomic_set(v, i) (((v)->counter) = i)
++
++
++extern __inline__ void atomic_add(int i, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter += i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_add_negative(int i, atomic_t *v)
++{
++ unsigned long flags;
++ int result;
++
++ local_irq_save(flags);
++ v->counter += i;
++ result = (v->counter < 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_sub(int i, atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_sub_and_test(int i, atomic_t *v)
++{
++ int result;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_inc(atomic_t *v)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter += 1;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_inc_and_test(atomic_t *v)
++{
++ unsigned long flags;
++ int result;
++
++ local_irq_save(flags);
++ v->counter += 1;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ void atomic_dec(atomic_t *v)
++{
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ local_irq_restore(flags);
++}
++
++extern __inline__ int atomic_dec_and_test(atomic_t *v)
++{
++ int result;
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = (v->counter == 0);
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_inc_return(atomic_t *v)
++{
++ int result;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ result = ++v->counter;
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_dec_return(atomic_t *v)
++{
++ int result;
++ int i = 1; /* the compiler optimizes better this way */
++ unsigned long flags;
++
++ local_irq_save(flags);
++ v->counter -= i;
++ result = v->counter;
++ local_irq_restore(flags);
++ return result;
++}
++
++extern __inline__ int atomic_add_return (int i, volatile atomic_t *v)
++{
++ int res;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ res = v->counter + i;
++ v->counter = res;
++ local_irq_restore(flags);
++
++ return res;
++}
++
++static __inline__ int atomic_sub_return (int i, volatile atomic_t *v)
++{
++ int res;
++ unsigned long flags;
++
++ local_irq_save(flags);
++ res = v->counter - i;
++ v->counter = res;
++ local_irq_restore(flags);
++
++ return res;
++}
++
++#define atomic_dec_return(v) atomic_sub_return(1,(v))
++#define atomic_inc_return(v) atomic_add_return(1,(v))
++
++/* Atomic operations are already serializing */
++#define smp_mb__before_atomic_dec() barrier()
++#define smp_mb__after_atomic_dec() barrier()
++#define smp_mb__before_atomic_inc() barrier()
++#define smp_mb__after_atomic_inc() barrier()
++
++
++#endif /* !(__ARCH_NIOS2NOMMU_ATOMIC__) */
++
++
+--- linux/include/asm-nios2nommu/bitops.h
++++ linux/include/asm-nios2nommu/bitops.h
+@@ -0,0 +1,472 @@
++#ifndef _ASM_NIOS_BITOPS_H_
++#define _ASM_NIOS_BITOPS_H_
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bitops.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef __KERNEL__
++#include <linux/config.h>
++#include <linux/compiler.h>
++#include <asm/byteorder.h> /* swab32 */
++#include <asm/system.h>
++#endif
++
++/*
++ * Adapted to NIOS from generic bitops.h:
++ *
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents. You should
++ * recode these in the native assembly language, if at all possible.
++ * To guarantee atomicity, these routines call cli() and sti() to
++ * disable interrupts while they operate. (You have to provide inline
++ * routines to cli() and sti().)
++ *
++ * Also note, these routines assume that you have 32 bit integers.
++ * You will have to change this if you are trying to port Linux to the
++ * Alpha architecture or to a Cray. :-)
++ *
++ * C language equivalents written by Theodore Ts'o, 9/26/92
++ */
++
++/*
++ * Generic ffs().
++ */
++static inline int ffs(int x)
++{
++ int r = 1;
++
++ if (!x)
++ return 0;
++ if (!(x & 0xffff)) {
++ x >>= 16;
++ r += 16;
++ }
++ if (!(x & 0xff)) {
++ x >>= 8;
++ r += 8;
++ }
++ if (!(x & 0xf)) {
++ x >>= 4;
++ r += 4;
++ }
++ if (!(x & 3)) {
++ x >>= 2;
++ r += 2;
++ }
++ if (!(x & 1)) {
++ x >>= 1;
++ r += 1;
++ }
++ return r;
++}
++
++/*
++ * Generic __ffs().
++ */
++static inline int __ffs(int x)
++{
++ int r = 0;
++
++ if (!x)
++ return 0;
++ if (!(x & 0xffff)) {
++ x >>= 16;
++ r += 16;
++ }
++ if (!(x & 0xff)) {
++ x >>= 8;
++ r += 8;
++ }
++ if (!(x & 0xf)) {
++ x >>= 4;
++ r += 4;
++ }
++ if (!(x & 3)) {
++ x >>= 2;
++ r += 2;
++ }
++ if (!(x & 1)) {
++ x >>= 1;
++ r += 1;
++ }
++ return r;
++}
++
++/*
++ * fls: find last bit set.
++ */
++#define fls(x) generic_fls(x)
++
++
++/*
++ * Every architecture must define this function. It's the fastest
++ * way of searching a 140-bit bitmap where the first 100 bits are
++ * unlikely to be set. It's guaranteed that at least one of the 140
++ * bits is cleared.
++ */
++static inline int sched_find_first_bit(unsigned long *b)
++{
++ if (unlikely(b[0]))
++ return __ffs(b[0]);
++ if (unlikely(b[1]))
++ return __ffs(b[1]) + 32;
++ if (unlikely(b[2]))
++ return __ffs(b[2]) + 64;
++ if (b[3])
++ return __ffs(b[3]) + 96;
++ return __ffs(b[4]) + 128;
++}
++
++/*
++ * ffz = Find First Zero in word. Undefined if no zero exists,
++ * so code should check against ~0UL first..
++ */
++static __inline__ unsigned long ffz(unsigned long word)
++{
++ unsigned long result = 0;
++
++ while(word & 1) {
++ result++;
++ word >>= 1;
++ }
++ return result;
++}
++
++
++static __inline__ void set_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ *a |= mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __set_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ *a |= mask;
++}
++
++/*
++ * clear_bit() doesn't provide any barrier for the compiler.
++ */
++#define smp_mb__before_clear_bit() barrier()
++#define smp_mb__after_clear_bit() barrier()
++
++static __inline__ void clear_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ *a &= ~mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __clear_bit(int nr, volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ *a &= ~mask;
++}
++
++static __inline__ void change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, flags;
++ unsigned long *ADDR = (unsigned long *) addr;
++
++ ADDR += nr >> 5;
++ mask = 1 << (nr & 31);
++ local_irq_save(flags);
++ *ADDR ^= mask;
++ local_irq_restore(flags);
++}
++
++static __inline__ void __change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask;
++ unsigned long *ADDR = (unsigned long *) addr;
++
++ ADDR += nr >> 5;
++ mask = 1 << (nr & 31);
++ *ADDR ^= mask;
++}
++
++static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a |= mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a |= mask;
++ return retval;
++}
++
++static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a &= ~mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a &= ~mask;
++ return retval;
++}
++
++static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++ unsigned long flags;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ local_irq_save(flags);
++ retval = (mask & *a) != 0;
++ *a ^= mask;
++ local_irq_restore(flags);
++
++ return retval;
++}
++
++static __inline__ int __test_and_change_bit(int nr, volatile unsigned long * addr)
++{
++ int mask, retval;
++ volatile unsigned int *a = (volatile unsigned int *) addr;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ retval = (mask & *a) != 0;
++ *a ^= mask;
++ return retval;
++}
++
++/*
++ * This routine doesn't need to be atomic.
++ */
++static __inline__ int __constant_test_bit(int nr, const volatile unsigned long * addr)
++{
++ return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
++}
++
++static __inline__ int __test_bit(int nr, const volatile unsigned long * addr)
++{
++ int * a = (int *) addr;
++ int mask;
++
++ a += nr >> 5;
++ mask = 1 << (nr & 0x1f);
++ return ((mask & *a) != 0);
++}
++
++#define test_bit(nr,addr) \
++(__builtin_constant_p(nr) ? \
++ __constant_test_bit((nr),(unsigned long *)(addr)) : \
++ __test_bit((nr),(unsigned long *)(addr)))
++
++
++/* find_next_zero_bit() finds the first zero bit in a bit string of length
++ * 'size' bits, starting the search at bit 'offset'. This is largely based
++ * on Linus's ALPHA routines, which are pretty portable BTW.
++ */
++
++extern __inline__ unsigned long find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
++{
++ unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
++ unsigned long result = offset & ~31UL;
++ unsigned long tmp;
++
++ if (offset >= size)
++ return size;
++ size -= result;
++ offset &= 31UL;
++ if (offset) {
++ tmp = *(p++);
++ tmp |= ~0UL >> (32-offset);
++ if (size < 32)
++ goto found_first;
++ if (~tmp)
++ goto found_middle;
++ size -= 32;
++ result += 32;
++ }
++ while (size & ~31UL) {
++ if (~(tmp = *(p++)))
++ goto found_middle;
++ result += 32;
++ size -= 32;
++ }
++ if (!size)
++ return result;
++ tmp = *p;
++
++found_first:
++ tmp |= ~0UL << size;
++ if (tmp == ~0UL)
++ return result + size;
++found_middle:
++ return result + ffz(tmp);
++}
++
++/*
++ * Find next one bit in a bitmap reasonably efficiently.
++ */
++extern __inline__ unsigned long find_next_bit(const unsigned long *addr,
++ unsigned long size, unsigned long offset)
++{
++ unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
++ unsigned int result = offset & ~31UL;
++ unsigned int tmp;
++
++ if (offset >= size)
++ return size;
++ size -= result;
++ offset &= 31UL;
++ if (offset) {
++ tmp = *p++;
++ tmp &= ~0UL << offset;
++ if (size < 32)
++ goto found_first;
++ if (tmp)
++ goto found_middle;
++ size -= 32;
++ result += 32;
++ }
++ while (size >= 32) {
++ if ((tmp = *p++) != 0)
++ goto found_middle;
++ result += 32;
++ size -= 32;
++ }
++ if (!size)
++ return result;
++ tmp = *p;
++
++found_first:
++ tmp &= ~0UL >> (32 - size);
++ if (tmp == 0UL) /* Are any bits set? */
++ return result + size; /* Nope. */
++found_middle:
++ return result + __ffs(tmp);
++}
++
++/*
++ * hweightN: returns the hamming weight (i.e. the number
++ * of bits set) of a N-bit word
++ */
++
++#define hweight32(x) generic_hweight32(x)
++#define hweight16(x) generic_hweight16(x)
++#define hweight8(x) generic_hweight8(x)
++
++/* Linus sez that gcc can optimize the following correctly, we'll see if this
++ * holds on the Sparc as it does for the ALPHA.
++ */
++
++#define find_first_zero_bit(addr, size) \
++ find_next_zero_bit((addr), (size), 0)
++#define find_first_bit(addr, size) \
++ find_next_bit((addr), (size), 0)
++
++/* Now for the ext2 filesystem bit operations and helper routines.
++ *
++ * Both NIOS and ext2 are little endian, so these are the same as above.
++ */
++
++#define ext2_set_bit test_and_set_bit
++#define ext2_clear_bit test_and_clear_bit
++#define ext2_test_bit test_bit
++
++#define ext2_set_bit_atomic(lock, nr, addr) \
++ ({ \
++ int ret; \
++ spin_lock(lock); \
++ ret = ext2_set_bit((nr),(unsigned long *) (addr)); \
++ spin_unlock(lock); \
++ ret; \
++ })
++
++#define ext2_clear_bit_atomic(lock, nr, addr) \
++ ({ \
++ int ret; \
++ spin_lock(lock); \
++ ret = ext2_clear_bit((nr),(unsigned long *) (addr)); \
++ spin_unlock(lock); \
++ ret; \
++ })
++
++#define ext2_find_first_zero_bit find_first_zero_bit
++#define ext2_find_next_zero_bit find_next_zero_bit
++
++#endif /* _ASM_NIOS_BITOPS_H */
+--- linux/include/asm-nios2nommu/bootinfo.h
++++ linux/include/asm-nios2nommu/bootinfo.h
+@@ -0,0 +1,2 @@
++
++/* Nothing for nios2nommu */
+--- linux/include/asm-nios2nommu/bug.h
++++ linux/include/asm-nios2nommu/bug.h
+@@ -0,0 +1,48 @@
++#ifndef _NIOS2NOMMU_BUG_H
++#define _NIOS2NOMMU_BUG_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bug.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define BUG() do { \
++ printk("%s(%d): kernel BUG!\n", __FILE__, __LINE__); \
++} while (0)
++
++#define BUG_ON(condition) do { \
++ if (unlikely((condition)!=0)) \
++ BUG(); \
++} while(0)
++
++#define PAGE_BUG(page) do { \
++ BUG(); \
++} while (0)
++
++#define WARN_ON(condition) do { \
++ if (unlikely((condition)!=0)) { \
++ printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
++ dump_stack(); \
++ } \
++} while (0)
++
++#endif
+--- linux/include/asm-nios2nommu/bugs.h
++++ linux/include/asm-nios2nommu/bugs.h
+@@ -0,0 +1,40 @@
++#ifndef __ASM_NIOS_BUGS_H
++#define __ASM_NIOS_BUGS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/bugs.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1994 Linus Torvalds
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This is included by init/main.c to check for architecture-dependent bugs.
++ *
++ * Needs:
++ * void check_bugs(void);
++ */
++
++static void check_bugs(void)
++{
++}
++
++#endif
+--- linux/include/asm-nios2nommu/byteorder.h
++++ linux/include/asm-nios2nommu/byteorder.h
+@@ -0,0 +1,38 @@
++#ifndef __ASM_NIOS_BYTEORDER_H
++#define __ASM_NIOS_BYTEORDER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/byteorder.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/types.h>
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
++# define __BYTEORDER_HAS_U64__
++# define __SWAB_64_THRU_32__
++#endif
++
++#include <linux/byteorder/little_endian.h>
++
++#endif
++
+--- linux/include/asm-nios2nommu/cache.h
++++ linux/include/asm-nios2nommu/cache.h
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __ARCH_NIOS2NOMMU_CACHE_H
++#define __ARCH_NIOS2NOMMU_CACHE_H
++
++#include <asm/nios.h>
++
++/* bytes per L1 cache line */
++#define L1_CACHE_BYTES nasys_icache_line_size /* this need to be at least 1 */
++
++
++#define __cacheline_aligned
++#define ____cacheline_aligned
++
++#endif
+--- linux/include/asm-nios2nommu/cachectl.h
++++ linux/include/asm-nios2nommu/cachectl.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_CACHECTL_H
++#define _NIOS2NOMMU_CACHECTL_H
++
++/* Definitions for the cacheflush system call. */
++
++#define FLUSH_SCOPE_LINE 1 /* Flush a cache line */
++#define FLUSH_SCOPE_PAGE 2 /* Flush a page */
++#define FLUSH_SCOPE_ALL 3 /* Flush the whole cache -- superuser only */
++
++#define FLUSH_CACHE_DATA 1 /* Writeback and flush data cache */
++#define FLUSH_CACHE_INSN 2 /* Flush instruction cache */
++#define FLUSH_CACHE_BOTH 3 /* Flush both caches */
++
++#endif /* _NIOS2NOMMU_CACHECTL_H */
+--- linux/include/asm-nios2nommu/cacheflush.h
++++ linux/include/asm-nios2nommu/cacheflush.h
+@@ -0,0 +1,56 @@
++#ifndef _NIOS2NOMMU_CACHEFLUSH_H
++#define _NIOS2NOMMU_CACHEFLUSH_H
++
++/*
++ * Ported from m68knommu.
++ *
++ * (C) Copyright 2003, Microtronix Datacom Ltd.
++ * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com>
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#include <linux/mm.h>
++
++extern void cache_push (unsigned long vaddr, int len);
++extern void dcache_push (unsigned long vaddr, int len);
++extern void icache_push (unsigned long vaddr, int len);
++extern void cache_push_all (void);
++
++#define flush_cache_all() __flush_cache_all()
++#define flush_cache_mm(mm) do { } while (0)
++#define flush_cache_range(vma, start, end) do { } while (0)
++#define flush_cache_page(vma, vmaddr) do { } while (0)
++#define flush_dcache_range(start,end) dcache_push(start, end - start)
++#define flush_dcache_page(page) do { } while (0)
++#define flush_icache_range(start,end) cache_push(start, end - start)
++#define flush_icache_page(vma,pg) do { } while (0)
++#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
++
++#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
++ memcpy(dst, src, len)
++
++
++extern inline void __flush_cache_all(void)
++{
++ cache_push_all();
++}
++
++#endif /* _NIOS2NOMMU_CACHEFLUSH_H */
+--- linux/include/asm-nios2nommu/checksum.h
++++ linux/include/asm-nios2nommu/checksum.h
+@@ -0,0 +1,320 @@
++#ifndef __NIOS2_CHECKSUM_H
++#define __NIOS2_CHECKSUM_H
++
++/* checksum.h: IP/UDP/TCP checksum routines on the NIOS.
++ *
++ * Copyright(C) 1995 Linus Torvalds
++ * Copyright(C) 1995 Miguel de Icaza
++ * Copyright(C) 1996 David S. Miller
++ * Copyright(C) 2001 Ken Hill
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * derived from:
++ * Alpha checksum c-code
++ * ix86 inline assembly
++ * Spar nommu
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * computes the checksum of the TCP/UDP pseudo-header
++ * returns a 16-bit checksum, already complemented
++ */
++
++extern inline unsigned short csum_tcpudp_magic(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++" add %0, %3, %0\n"
++" bgeu %0, %3, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %4, %0\n"
++" bgeu %0, %4, 1f\n"
++" addi %0, %0, 1\n"
++"1: add %0, %5, %0\n"
++" bgeu %0, %5, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++/*
++ We need the carry from the addition of 16-bit
++ significant addition, so we zap out the low bits
++ in one half, zap out the high bits in another,
++ shift them both up to the top 16-bits of a word
++ and do the carry producing addition, finally
++ shift the result back down to the low 16-bits.
++
++ Actually, we can further optimize away two shifts
++ because we know the low bits of the original
++ value will be added to zero-only bits so cannot
++ affect the addition result nor the final carry
++ bit.
++*/
++" slli %1,%0, 16\n" /* Need a copy to fold with */
++ /* Bring the LOW 16 bits up */
++" add %0, %1, %0\n" /* add and set carry, neat eh? */
++" cmpltu r15, %0, %1\n" /* get remaining carry bit */
++" srli %0, %0, 16\n" /* shift back down the result */
++" add %0, %0, r15\n"
++" nor %0, %0, %0\n" /* negate */
++ : "=&r" (sum), "=&r" (saddr)
++ : "0" (sum), "1" (saddr), "r" (ntohl(len+proto)), "r" (daddr)
++ : "r15");
++ return ((unsigned short) sum);
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++ extern inline unsigned short from32to16(unsigned long x)
++ {
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r15, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r15\n"
++ : "=r" (x)
++ : "r" (x << 16), "0" (x)
++ : "r15");
++ return x;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern inline unsigned long do_csum(const unsigned char * buff, int len)
++{
++ int odd, count;
++ unsigned long result = 0;
++
++ barrier();
++ if (len <= 0)
++ goto out;
++ odd = 1 & (unsigned long) buff;
++ if (odd) {
++////result = *buff; // dgt: Big endian
++ result = *buff << 8; // dgt: Little endian
++
++ len--;
++ buff++;
++ }
++ count = len >> 1; /* nr of 16-bit words.. */
++ if (count) {
++ if (2 & (unsigned long) buff) {
++ result += *(unsigned short *) buff;
++ count--;
++ len -= 2;
++ buff += 2;
++ }
++ count >>= 1; /* nr of 32-bit words.. */
++ if (count) {
++ unsigned long carry = 0;
++ do {
++ unsigned long w = *(unsigned long *) buff;
++ count--;
++ buff += 4;
++ result += carry;
++ result += w;
++ carry = (w > result);
++ } while (count);
++ result += carry;
++ result = (result & 0xffff) + (result >> 16);
++ }
++ if (len & 2) {
++ result += *(unsigned short *) buff;
++ buff += 2;
++ }
++ }
++ if (len & 1)
++ result += *buff; /* This is little machine, byte is right */
++ result = from32to16(result);
++ if (odd)
++ result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
++out:
++ return result;
++ barrier();
++ }
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/* ihl is always 5 or greater, almost always is 5, iph is always word
++ * aligned but can fail to be dword aligned very often.
++ */
++
++ extern inline unsigned short ip_fast_csum(const unsigned char *iph, unsigned int ihl)
++ {
++ unsigned int sum;
++
++ barrier();
++ __asm__ __volatile__(
++" andi r8, %1, 2\n" /* Remember original alignment */
++" ldw %0, (%1)\n" /* 16 or 32 bit boundary */
++" beq r8, r0, 1f\n" /* Aligned on 32 bit boundary, go */
++" srli %0, %0, 16\n" /* Get correct 16 bits */
++" addi %2, %2, -1\n" /* Take off for 4 bytes, pickup last 2 at end */
++" addi %1, %1, 2\n" /* Adjust pointer to 32 bit boundary */
++" br 2f\n"
++"1:\n"
++" addi %2, %2, -1\n"
++" addi %1, %1, 4\n" /* Bump ptr a long word */
++"2:\n"
++" ldw r9, (%1)\n"
++"1:\n"
++" add %0, r9, %0\n"
++" bgeu %0, r9, 2f\n"
++" addi %0, %0, 1\n"
++"2:\n"
++" addi %1, %1, 4\n"
++" addi %2, %2, -1\n"
++" ldw r9, (%1)\n"
++" bne %2, r0, 1b\n"
++" beq r8, r0, 1f\n" /* 32 bit boundary time to leave */
++" srli r9, r9, 16\n" /* 16 bit boundary, get correct 16 bits */
++" add %0, r9, %0\n"
++" bgeu %0, r9, 1f\n"
++" addi %0, %0, 1\n"
++"1:\n"
++" slli %2, %0, 16\n"
++" add %0, %2, %0\n"
++" cmpltu r8, %0, %2\n"
++" srli %0, %0, 16\n"
++" add %0, %0, r8\n"
++" nor %0, %0, %0\n"
++ : "=&r" (sum), "=&r" (iph), "=&r" (ihl)
++ : "1" (iph), "2" (ihl)
++ : "r8", "r9");
++ return sum;
++ barrier();
++ }
++
++/*these 2 functions are now in checksum.c */
++unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
++unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++/*
++ * the same as csum_partial_copy, but copies from user space.
++ *
++ * here even more important to align src and dst on a 32-bit (or even
++ * better 64-bit) boundary
++ */
++extern inline unsigned int
++csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err)
++{
++ barrier();
++ if (csum_err) *csum_err = 0;
++ memcpy(dst, src, len);
++ return csum_partial(dst, len, sum);
++ barrier();
++}
++
++#define csum_partial_copy_nocheck(src, dst, len, sum) \
++ csum_partial_copy ((src), (dst), (len), (sum))
++
++
++/*
++ * this routine is used for miscellaneous IP-like checksums, mainly
++ * in icmp.c
++ */
++
++extern inline unsigned short ip_compute_csum(unsigned char * buff, int len)
++{
++ barrier();
++ return ~from32to16(do_csum(buff,len));
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++#define csum_partial_copy_fromuser(s, d, l, w) \
++ csum_partial_copy((char *) (s), (d), (l), (w))
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++/*
++ * Fold a partial checksum without adding pseudo headers
++ */
++extern __inline__ unsigned int csum_fold(unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "srli %0, %0, 16\n"
++ "add %0, %0, r8\n"
++ "nor %0, %0, %0\n"
++ : "=r" (sum)
++ : "r" (sum << 16), "0" (sum)
++ : "r8");
++ return sum;
++ barrier();
++}
++
++
++/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
++
++
++extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
++ unsigned long daddr,
++ unsigned short len,
++ unsigned short proto,
++ unsigned int sum)
++{
++ barrier();
++ __asm__ __volatile__(
++ "add %0, %1, %0\n"
++ "cmpltu r8, %0, %1\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %2, %0\n"
++ "cmpltu r8, %0, %2\n"
++ "add %0, %0, r8\n" /* add carry */
++ "add %0, %3, %0\n"
++ "cmpltu r8, %0, %3\n"
++ "add %0, %0, r8\n" /* add carry */
++ : "=r" (sum), "=r" (saddr)
++ : "r" (daddr), "r" ( (ntohs(len)<<16) + (proto*256) ),
++ "0" (sum),
++ "1" (saddr)
++ : "r8");
++
++ return sum;
++ barrier();
++}
++
++
++#endif /* (__NIOS2_CHECKSUM_H) */
+--- linux/include/asm-nios2nommu/cprefix.h
++++ linux/include/asm-nios2nommu/cprefix.h
+@@ -0,0 +1,38 @@
++/* cprefix.h: This file is included by assembly source which needs
++ * to know what the c-label prefixes are. The newer versions
++ * of cpp that come with gcc predefine such things to help
++ * us out. The reason this stuff is needed is to make
++ * solaris compiles of the kernel work.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_CPREFIX_H
++#define __NIOS2_CPREFIX_H
++
++#define C_LABEL_PREFIX
++
++#define CONCAT(a, b) CONCAT2(a, b)
++#define CONCAT2(a, b) a##b
++
++#define C_LABEL(name) CONCAT(C_LABEL_PREFIX, name)
++
++#endif /* !(__NIOS2_CPREFIX_H) */
+--- linux/include/asm-nios2nommu/cpumask.h
++++ linux/include/asm-nios2nommu/cpumask.h
+@@ -0,0 +1,28 @@
++/*
++ * All rights reserved.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_CPUMASK_H
++#define _ASM_NIOS2NOMMU_CPUMASK_H
++
++#include <asm-generic/cpumask.h>
++
++#endif /* _ASM_NIOS2NOMMU_CPUMASK_H */
+--- linux/include/asm-nios2nommu/current.h
++++ linux/include/asm-nios2nommu/current.h
+@@ -0,0 +1,39 @@
++#ifndef _NIOS2NOMMU_CURRENT_H
++#define _NIOS2NOMMU_CURRENT_H
++/*
++ * current.h
++ * (C) Copyright 2000, Lineo, David McCullough <davidm@uclinux.org>
++ * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
++ * (C) Copyright 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/thread_info.h>
++
++struct task_struct;
++
++static inline struct task_struct *get_current(void)
++{
++ return(current_thread_info()->task);
++}
++
++#define current get_current()
++
++#endif /* _NIOS2NOMMU_CURRENT_H */
+--- linux/include/asm-nios2nommu/delay.h
++++ linux/include/asm-nios2nommu/delay.h
+@@ -0,0 +1,96 @@
++#ifndef _NIOS_DELAY_H
++#define _NIOS_DELAY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/delay.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/param.h>
++
++extern __inline__ void __delay(unsigned long loops)
++{
++ int dummy;
++
++ __asm__ __volatile__(
++ "1: \n\t"
++ " beq %0,zero,2f\n\t"
++ " addi %0, %0, -1\n\t"
++ " br 1b\n\t"
++ "2: \n\t"
++
++ : "=r" (dummy) /* Need output for optimizer */
++
++ : "0" (loops) /* %0 Input */
++ );
++}
++
++/*
++ * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
++ * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
++ *
++ * The mul instruction gives us loops = (a * b) / 2^32.
++ * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
++ * because this lets us support a wide range of HZ and
++ * loops_per_jiffy values without either a or b overflowing 2^32.
++ * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
++ * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
++ * (which corresponds to ~3800 bogomips at HZ = 100).
++ * -- paulus
++ */
++#define __MAX_UDELAY (226050910UL/HZ) /* maximum udelay argument */
++#define __MAX_NDELAY (4294967295UL/HZ) /* maximum ndelay argument */
++
++extern unsigned long loops_per_jiffy;
++
++extern __inline__ void __udelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 226));
++ __delay(loops);
++}
++
++extern __inline__ void __ndelay(unsigned int x)
++{
++ unsigned int loops;
++
++ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
++ "r" (x), "r" (loops_per_jiffy * 5));
++ __delay(loops);
++}
++
++extern void __bad_udelay(void); /* deliberately undefined */
++extern void __bad_ndelay(void); /* deliberately undefined */
++
++#define udelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
++ __udelay((n) * (19 * HZ)))
++
++#define ndelay(n) (__builtin_constant_p(n)? \
++ ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
++ __ndelay((n) * HZ))
++
++#define muldiv(a, b, c) (((a)*(b))/(c))
++
++#endif /* defined(_NIOS_DELAY_H) */
+--- linux/include/asm-nios2nommu/div64.h
++++ linux/include/asm-nios2nommu/div64.h
+@@ -0,0 +1,31 @@
++#ifndef __ASMNIOS_DIV64_H
++#define __ASMNIOS_DIV64_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/div64.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/div64.h>
++
++#endif
++
+--- linux/include/asm-nios2nommu/dma-mapping.h
++++ linux/include/asm-nios2nommu/dma-mapping.h
+@@ -0,0 +1,25 @@
++/*
++ * include/asm-s390/dma-mapping.h
++ *
++ * S390 version
++ *
++ * This file exists so that #include <dma-mapping.h> doesn't break anything.
++ */
++
++#ifndef _ASM_DMA_MAPPING_H
++#define _ASM_DMA_MAPPING_H
++
++static inline void *dma_alloc_coherent(struct device *dev, size_t size,
++ dma_addr_t *dma_handle, int flag)
++{
++ BUG();
++ return 0;
++}
++
++static inline void dma_free_coherent(struct device *dev, size_t size,
++ void *vaddr, dma_addr_t dma_handle)
++{
++ BUG();
++}
++
++#endif /* _ASM_DMA_MAPPING_H */
+--- linux/include/asm-nios2nommu/dma.h
++++ linux/include/asm-nios2nommu/dma.h
+@@ -0,0 +1,40 @@
++/* $Id: dma.h,v 1.5 2004/03/02 16:05:52 ken-h Exp $
++ *
++ * Copyright 1995 (C) David S. Miller (davem@caip.rutgers.edu)
++ * Copyright 2004 (C) Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2_DMA_H
++#define _ASM_NIOS2_DMA_H
++
++#include <linux/kernel.h>
++#include <asm/asm-offsets.h>
++
++#define MAX_DMA_CHANNELS 2
++#define MAX_DMA_ADDRESS (LINUX_SDRAM_START)
++#define DMA_MODE_READ 1
++#define DMA_MODE_WRITE 2
++
++extern int get_dma_list(char *);
++extern int request_dma(unsigned int, const char *);
++extern void free_dma(unsigned int);
++
++#endif /* !(_ASM_NIOS2_DMA_H) */
+--- linux/include/asm-nios2nommu/elf.h
++++ linux/include/asm-nios2nommu/elf.h
+@@ -0,0 +1,141 @@
++#ifndef __NIOS2_ELF_H
++#define __NIOS2_ELF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/elf.h
++ *
++ * Nio2 ELF relocation types
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ * Mar/18/2004 xwt NiosII relocation types added
++ *
++ ---------------------------------------------------------------------*/
++
++// #include <linux/config.h>
++#include <asm/ptrace.h>
++#include <asm/user.h>
++
++#define R_NIOS2_NONE 0
++#define R_NIOS2_S16 1
++#define R_NIOS2_U16 2
++#define R_NIOS2_PCREL16 3
++#define R_NIOS2_CALL26 4
++#define R_NIOS2_IMM5 5
++#define R_NIOS2_CACHE_OPX 6
++#define R_NIOS2_IMM6 7
++#define R_NIOS2_IMM8 8
++#define R_NIOS2_HI16 9
++#define R_NIOS2_LO16 10
++#define R_NIOS2_HIADJ16 11
++#define R_NIOS2_BFD_RELOC_32 12
++#define R_NIOS2_BFD_RELOC_16 13
++#define R_NIOS2_BFD_RELOC_8 14
++#define R_NIOS2_GPREL 15
++#define R_NIOS2_GNU_VTINHERIT 16
++#define R_NIOS2_GNU_VTENTRY 17
++#define R_NIOS2_UJMP 18
++#define R_NIOS2_CJMP 19
++#define R_NIOS2_CALLR 20
++#define R_NIOS2_ALIGN 21
++/* Keep this the last entry. */
++#define R_NIOS2_NUM 22
++
++typedef unsigned long elf_greg_t;
++
++#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
++typedef elf_greg_t elf_gregset_t[ELF_NGREG];
++
++typedef unsigned long elf_fpregset_t;
++
++/*
++ * This is used to ensure we don't load something for the wrong architecture.
++ */
++#define elf_check_arch(x) \
++ ((x)->e_machine == EM_ALTERA_NIOS2)
++
++/*
++ * These are used to set parameters in the core dumps.
++ */
++#define ELF_CLASS ELFCLASS32
++#define ELF_DATA ELFDATA2LSB
++#define ELF_ARCH EM_ALTERA_NIOS2
++
++#define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0
++
++#define USE_ELF_CORE_DUMP
++#define ELF_EXEC_PAGESIZE 4096
++
++/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
++ use of this is to invoke "./ld.so someprog" to test out a new version of
++ the loader. We need to make sure that it is out of the way of the program
++ that it will "exec", and that there is sufficient room for the brk. */
++
++#define ELF_ET_DYN_BASE 0xD0000000UL
++
++/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
++ now struct_user_regs, they are different) */
++
++#define ELF_CORE_COPY_REGS(pr_reg, regs) \
++ /* Bleech. */ \
++ pr_reg[0] = regs->r1; \
++ pr_reg[1] = regs->r2; \
++ pr_reg[2] = regs->r3; \
++ pr_reg[3] = regs->r4; \
++ pr_reg[4] = regs->r5; \
++ pr_reg[5] = regs->r6; \
++ pr_reg[6] = regs->r7; \
++ pr_reg[7] = regs->r8; \
++ pr_reg[8] = regs->r9; \
++ pr_reg[9] = regs->r10; \
++ pr_reg[10] = regs->r11; \
++ pr_reg[11] = regs->r12; \
++ pr_reg[12] = regs->r13; \
++ pr_reg[13] = regs->r14; \
++ pr_reg[14] = regs->r15; \
++ pr_reg[23] = regs->sp; \
++ pr_reg[26] = regs->estatus; \
++ { \
++ struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
++ pr_reg[15] = sw->r16; \
++ pr_reg[16] = sw->r17; \
++ pr_reg[17] = sw->r18; \
++ pr_reg[18] = sw->r19; \
++ pr_reg[19] = sw->r20; \
++ pr_reg[20] = sw->r21; \
++ pr_reg[21] = sw->r22; \
++ pr_reg[22] = sw->r23; \
++ pr_reg[24] = sw->fp; \
++ pr_reg[25] = sw->gp; \
++ }
++
++/* This yields a mask that user programs can use to figure out what
++ instruction set this cpu supports. */
++
++#define ELF_HWCAP (0)
++
++/* This yields a string that ld.so will use to load implementation
++ specific libraries for optimization. This is more specific in
++ intent than poking at uname or /proc/cpuinfo. */
++
++#define ELF_PLATFORM (NULL)
++
++#ifdef __KERNEL__
++#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
++#endif
++
++#endif
+--- linux/include/asm-nios2nommu/entry.h
++++ linux/include/asm-nios2nommu/entry.h
+@@ -0,0 +1,188 @@
++/*
++ * Hacked from m68knommu port.
++ *
++ * Copyright(C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_ENTRY_H
++#define __NIOS2NOMMU_ENTRY_H
++
++#ifdef __ASSEMBLY__
++
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/asm-offsets.h>
++
++/*
++ * Stack layout in 'ret_from_exception':
++ *
++ * This allows access to the syscall arguments in registers r4-r8
++ *
++ * 0(sp) - r8
++ * 4(sp) - r9
++ * 8(sp) - r10
++ * C(sp) - r11
++ * 10(sp) - r12
++ * 14(sp) - r13
++ * 18(sp) - r14
++ * 1C(sp) - r15
++ * 20(sp) - r1
++ * 24(sp) - r2
++ * 28(sp) - r3
++ * 2C(sp) - r4
++ * 30(sp) - r5
++ * 34(sp) - r6
++ * 38(sp) - r7
++ * 3C(sp) - orig_r2
++ * 40(sp) - ra
++ * 44(sp) - fp
++ * 48(sp) - sp
++ * 4C(sp) - gp
++ * 50(sp) - estatus
++ * 54(sp) - status_extension
++ * 58(sp) - ea
++ *
++ */
++
++/* process bits for task_struct.flags */
++PF_TRACESYS_OFF = 3
++PF_TRACESYS_BIT = 5
++PF_PTRACED_OFF = 3
++PF_PTRACED_BIT = 4
++PF_DTRACE_OFF = 1
++PF_DTRACE_BIT = 5
++
++LENOSYS = 38
++
++/*
++ * This defines the normal kernel pt-regs layout.
++ *
++ */
++
++/*
++ * Standard Nios2 interrupt entry and exit macros.
++ * Must be called with interrupts disabled.
++ */
++.macro SAVE_ALL
++ movia r24,status_extension // Read status extension
++ ldw r24,0(r24)
++ andi r24,r24,PS_S_ASM
++ bne r24,r0,1f // In supervisor mode, already on kernel stack
++ movia r24,_current_thread // Switch to current kernel stack
++ ldw r24,0(r24) // using the thread_info
++ addi r24,r24,THREAD_SIZE_ASM-PT_REGS_SIZE
++ stw sp,PT_SP(r24) // Save user stack before changing
++ mov sp,r24
++ br 2f
++
++1: mov r24,sp
++ addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
++ stw r24,PT_SP(sp)
++2: stw r1,PT_R1(sp)
++ stw r2,PT_R2(sp)
++ stw r3,PT_R3(sp)
++ stw r4,PT_R4(sp)
++ stw r5,PT_R5(sp)
++ stw r6,PT_R6(sp)
++ stw r7,PT_R7(sp)
++ stw r8,PT_R8(sp)
++ stw r9,PT_R9(sp)
++ stw r10,PT_R10(sp)
++ stw r11,PT_R11(sp)
++ stw r12,PT_R12(sp)
++ stw r13,PT_R13(sp)
++ stw r14,PT_R14(sp)
++ stw r15,PT_R15(sp)
++ stw r2,PT_ORIG_R2(sp)
++ stw ra,PT_RA(sp)
++ stw fp,PT_FP(sp)
++ stw gp,PT_GP(sp)
++ rdctl r24,estatus
++ stw r24,PT_ESTATUS(sp)
++ movia r24,status_extension // Read status extension
++ ldw r1,0(r24)
++ stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
++ ORI32 r1,r1,PS_S_ASM // Set supervisor mode
++ stw r1,0(r24)
++ stw ea,PT_EA(sp)
++.endm
++
++.macro RESTORE_ALL
++ ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
++ movia r24,status_extension
++ stw r1,0(r24)
++ ldw r1,PT_R1(sp) // Restore registers
++ ldw r2,PT_R2(sp)
++ ldw r3,PT_R3(sp)
++ ldw r4,PT_R4(sp)
++ ldw r5,PT_R5(sp)
++ ldw r6,PT_R6(sp)
++ ldw r7,PT_R7(sp)
++ ldw r8,PT_R8(sp)
++ ldw r9,PT_R9(sp)
++ ldw r10,PT_R10(sp)
++ ldw r11,PT_R11(sp)
++ ldw r12,PT_R12(sp)
++ ldw r13,PT_R13(sp)
++ ldw r14,PT_R14(sp)
++ ldw r15,PT_R15(sp)
++ ldw ra,PT_RA(sp)
++ ldw fp,PT_FP(sp)
++ ldw gp,PT_GP(sp)
++ ldw r24,PT_ESTATUS(sp)
++ wrctl estatus,r24
++ ldw ea,PT_EA(sp)
++ ldw sp,PT_SP(sp) // Restore sp last
++.endm
++
++.macro SAVE_SWITCH_STACK
++ addi sp,sp,-SWITCH_STACK_SIZE
++ stw r16,SW_R16(sp)
++ stw r17,SW_R17(sp)
++ stw r18,SW_R18(sp)
++ stw r19,SW_R19(sp)
++ stw r20,SW_R20(sp)
++ stw r21,SW_R21(sp)
++ stw r22,SW_R22(sp)
++ stw r23,SW_R23(sp)
++ stw fp,SW_FP(sp)
++ stw gp,SW_GP(sp)
++ stw ra,SW_RA(sp)
++.endm
++
++.macro RESTORE_SWITCH_STACK
++ ldw r16,SW_R16(sp)
++ ldw r17,SW_R17(sp)
++ ldw r18,SW_R18(sp)
++ ldw r19,SW_R19(sp)
++ ldw r20,SW_R20(sp)
++ ldw r21,SW_R21(sp)
++ ldw r22,SW_R22(sp)
++ ldw r23,SW_R23(sp)
++ ldw fp,SW_FP(sp)
++ ldw gp,SW_GP(sp)
++ ldw ra,SW_RA(sp)
++ addi sp,sp,SWITCH_STACK_SIZE
++.endm
++
++#endif /* __ASSEMBLY__ */
++#endif /* __NIOS2NOMMU_ENTRY_H */
+--- linux/include/asm-nios2nommu/errno.h
++++ linux/include/asm-nios2nommu/errno.h
+@@ -0,0 +1,6 @@
++#ifndef _NIOS2NOMMU_ERRNO_H
++#define _NIOS2NOMMU_ERRNO_H
++
++#include <asm-generic/errno.h>
++
++#endif /* _NIOS2NOMMU_ERRNO_H */
+--- linux/include/asm-nios2nommu/fcntl.h
++++ linux/include/asm-nios2nommu/fcntl.h
+@@ -0,0 +1,110 @@
++/*
++ * This file came from the m68k port.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_FCNTL_H
++#define _NIOS2_FCNTL_H
++
++/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
++ located on an ext2 file system */
++#define O_ACCMODE 0003
++#define O_RDONLY 00
++#define O_WRONLY 01
++#define O_RDWR 02
++#define O_CREAT 0100 /* not fcntl */
++#define O_EXCL 0200 /* not fcntl */
++#define O_NOCTTY 0400 /* not fcntl */
++#define O_TRUNC 01000 /* not fcntl */
++#define O_APPEND 02000
++#define O_NONBLOCK 04000
++#define O_NDELAY O_NONBLOCK
++#define O_SYNC 010000
++#define FASYNC 020000 /* fcntl, for BSD compatibility */
++#define O_DIRECTORY 040000 /* must be a directory */
++#define O_NOFOLLOW 0100000 /* don't follow links */
++#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
++#define O_LARGEFILE 0400000
++#define O_NOATIME 01000000
++
++#define F_DUPFD 0 /* dup */
++#define F_GETFD 1 /* get close_on_exec */
++#define F_SETFD 2 /* set/clear close_on_exec */
++#define F_GETFL 3 /* get file->f_flags */
++#define F_SETFL 4 /* set file->f_flags */
++#define F_GETLK 5
++#define F_SETLK 6
++#define F_SETLKW 7
++
++#define F_SETOWN 8 /* for sockets. */
++#define F_GETOWN 9 /* for sockets. */
++#define F_SETSIG 10 /* for sockets. */
++#define F_GETSIG 11 /* for sockets. */
++
++#define F_GETLK64 12 /* using 'struct flock64' */
++#define F_SETLK64 13
++#define F_SETLKW64 14
++
++/* for F_[GET|SET]FL */
++#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
++
++/* for posix fcntl() and lockf() */
++#define F_RDLCK 0
++#define F_WRLCK 1
++#define F_UNLCK 2
++
++/* for old implementation of bsd flock () */
++#define F_EXLCK 4 /* or 3 */
++#define F_SHLCK 8 /* or 4 */
++
++/* for leases */
++#define F_INPROGRESS 16
++
++/* operations for bsd flock(), also used by the kernel implementation */
++#define LOCK_SH 1 /* shared lock */
++#define LOCK_EX 2 /* exclusive lock */
++#define LOCK_NB 4 /* or'd with one of the above to prevent
++ blocking */
++#define LOCK_UN 8 /* remove lock */
++
++#define LOCK_MAND 32 /* This is a mandatory flock */
++#define LOCK_READ 64 /* ... Which allows concurrent read operations */
++#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
++#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
++
++struct flock {
++ short l_type;
++ short l_whence;
++ off_t l_start;
++ off_t l_len;
++ pid_t l_pid;
++};
++
++struct flock64 {
++ short l_type;
++ short l_whence;
++ loff_t l_start;
++ loff_t l_len;
++ pid_t l_pid;
++};
++
++#define F_LINUX_SPECIFIC_BASE 1024
++#endif /* _NIOS2_FCNTL_H */
+--- linux/include/asm-nios2nommu/flat.h
++++ linux/include/asm-nios2nommu/flat.h
+@@ -0,0 +1,126 @@
++/*
++ * include/asm-nios2nommu/flat.h -- uClinux bFLT relocations
++ *
++ * Copyright (C) 2004,05 Microtronix Datacom Ltd
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License. See the file COPYING in the main directory of this
++ * archive for more details.
++ *
++ * Written by Wentao Xu <wentao@microtronix.com>
++ */
++
++#ifndef __NIOS2_FLAT_H__
++#define __NIOS2_FLAT_H__
++
++#define flat_reloc_valid(reloc, size) ((reloc) <= (size + 0x8000))
++
++/* The stack is 64-bit aligned for Nios II, so (sp - 1) shall
++ * be 64-bit aligned, where -1 is for argc
++ */
++#define flat_stack_align(sp) (sp = (unsigned long *)(((unsigned long)sp - 1) & (-8)))
++
++/* The uClibc port for Nios II expects the argc is followed by argv and envp */
++#define flat_argvp_envp_on_stack() 1
++
++#define flat_old_ram_flag(flags) (flags)
++
++/* We store the type of relocation in the top 4 bits of the `relval.' */
++
++/* Convert a relocation entry into an address. */
++static inline unsigned long
++flat_get_relocate_addr (unsigned long relval)
++{
++ return relval & 0x0fffffff; /* Mask out top 4-bits */
++}
++
++#define FLAT_NIOS2_RELOC_TYPE(relval) ((relval) >> 28)
++
++#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
++#define FLAT_NIOS2_R_HI_LO 1 /* High 16-bits + low 16-bits field */
++#define FLAT_NIOS2_R_HIADJ_LO 2 /* High 16-bits adjust + low 16-bits field */
++#define FLAT_NIOS2_R_CALL26 4 /* Call imm26 */
++
++/* Extract the address to be relocated from the symbol reference at rp;
++ * relval is the raw relocation-table entry from which RP is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
++ unsigned long relval,
++ unsigned long flags)
++{
++ switch (FLAT_NIOS2_RELOC_TYPE(relval))
++ {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. The loader expect it in bigger endian */
++ return htonl(*rp);
++
++ case FLAT_NIOS2_R_HI_LO:
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ return htonl ((((rp[0] >> 6) & 0xFFFF) << 16 ) |
++ ((rp[1] >> 6) & 0xFFFF));
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ /* get the two 16-bit immediate value from instructions, then
++ * construct a 32-bit value. Again the loader expect bigger endian
++ */
++ unsigned int low, high;
++ high = (rp[0] >> 6) & 0xFFFF;
++ low = (rp[1] >> 6) & 0xFFFF;
++
++ if ((low >> 15) & 1) high--;
++
++ return htonl ((high << 16 ) | low );
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the 26-bit immediate value is actually 28-bit */
++ return htonl(((*rp) >> 6) << 2);
++
++ default:
++ return ~0; /* bogus value */
++ }
++}
++
++/* Insert the address addr into the symbol reference at rp;
++ * relval is the raw relocation-table entry from which rp is derived.
++ * rp shall always be 32-bit aligned
++ */
++static inline void flat_put_addr_at_rp (unsigned long *rp, unsigned long addr,
++ unsigned long relval)
++{
++ unsigned long exist_val;
++ switch (FLAT_NIOS2_RELOC_TYPE (relval)) {
++ case FLAT_NIOS2_R_32:
++ /* Simple 32-bit address. */
++ *rp = addr;
++ break;
++
++ case FLAT_NIOS2_R_HI_LO:
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | (addr >> 16)) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++
++ case FLAT_NIOS2_R_HIADJ_LO:
++ {
++ unsigned int high = (addr >> 16);
++ if ((addr >> 15) & 1)
++ high = (high + 1) & 0xFFFF;
++ exist_val = rp[0];
++ rp[0] = ((((exist_val >> 22) << 16) | high) << 6) | (exist_val & 0x3F);
++ exist_val = rp[1];
++ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
++ break;
++ }
++ case FLAT_NIOS2_R_CALL26:
++ /* the opcode of CALL is 0, so just store the value */
++ *rp = ((addr >> 2) << 6);
++ break;
++ }
++}
++
++#endif /* __NIOS2_FLAT_H__ */
+--- linux/include/asm-nios2nommu/hardirq.h
++++ linux/include/asm-nios2nommu/hardirq.h
+@@ -0,0 +1,85 @@
++/*
++ * Ported from m68knommu
++ *
++ * Copyright (C) 2003, Microtronix Datacom Ltd.
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef __NIOS2_HARDIRQ_H
++#define __NIOS2_HARDIRQ_H
++
++// #include <linux/config.h>
++#include <linux/cache.h>
++#include <linux/threads.h>
++
++typedef struct {
++ unsigned int __softirq_pending;
++ unsigned int __syscall_count;
++ struct task_struct * __ksoftirqd_task;
++} ____cacheline_aligned irq_cpustat_t;
++
++#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
++
++/*
++ * We put the hardirq and softirq counter into the preemption
++ * counter. The bitmask has the following meaning:
++ *
++ * - bits 0-7 are the preemption count (max preemption depth: 256)
++ * - bits 8-15 are the softirq count (max # of softirqs: 256)
++ * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
++ *
++ * - ( bit 26 is the PREEMPT_ACTIVE flag. )
++ *
++ * PREEMPT_MASK: 0x000000ff
++ * HARDIRQ_MASK: 0x0000ff00
++ * SOFTIRQ_MASK: 0x00ff0000
++ */
++
++#define PREEMPT_BITS 8
++#define SOFTIRQ_BITS 8
++#define HARDIRQ_BITS 8
++
++#define PREEMPT_SHIFT 0
++#define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS)
++#define HARDIRQ_SHIFT (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
++
++/*
++ * The hardirq mask has to be large enough to have
++ * space for potentially all IRQ sources in the system
++ * nesting on a single CPU:
++ */
++#if (1 << HARDIRQ_BITS) < NR_IRQS
++# error HARDIRQ_BITS is too low!
++#endif
++
++#define irq_enter() (preempt_count() += HARDIRQ_OFFSET)
++#define irq_exit() \
++do { \
++ preempt_count() -= IRQ_EXIT_OFFSET; \
++ if (!in_interrupt() && softirq_pending(smp_processor_id())) \
++ do_softirq(); \
++ preempt_enable_no_resched(); \
++} while (0)
++
++#ifdef CONFIG_SMP
++# error nios2nommu SMP is not available
++#endif /* CONFIG_SMP */
++
++#endif /* __NIOS2_HARDIRQ_H */
+--- linux/include/asm-nios2nommu/hdreg.h
++++ linux/include/asm-nios2nommu/hdreg.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2002 Wentau Xu (www.microtronix.com)
++ * copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_HDREG_H
++#define __NIOS2_HDREG_H
++
++typedef unsigned long ide_ioreg_t;
++
++#endif /* __NIOS2_HDREG_H */
+--- linux/include/asm-nios2nommu/hw_irq.h
++++ linux/include/asm-nios2nommu/hw_irq.h
+@@ -0,0 +1,16 @@
++#ifndef _ASM_HW_IRQ_H
++#define _ASM_HW_IRQ_H
++
++/*
++ * linux/include/asm/hw_irq.h
++ *
++ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
++ *
++ * moved some of the old arch/i386/kernel/irq.h to here. VY
++ *
++ * IRQ/IPI changes taken from work by Thomas Radke
++ * <tomsoft@informatik.tu-chemnitz.de>
++ */
++
++
++#endif /* _ASM_HW_IRQ_H */
+--- linux/include/asm-nios2nommu/ide.h
++++ linux/include/asm-nios2nommu/ide.h
+@@ -0,0 +1,47 @@
++/*
++ * linux/include/asm-niosnommu2/ide.h
++ *
++ * Copyright (C) 1994-1996 Linus Torvalds & authors
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASMNIOS2_IDE_H
++#define __ASMNIOS2_IDE_H
++
++#ifdef __KERNEL__
++#undef MAX_HWIFS /* we're going to force it */
++
++#ifndef MAX_HWIFS
++#define MAX_HWIFS 1
++#endif
++
++#define IDE_ARCH_OBSOLETE_INIT
++#define IDE_ARCH_OBSOLETE_DEFAULTS
++#define ide_default_io_base(i) ((unsigned long)na_ide_ide)
++#define ide_default_irq(b) (na_ide_ide_irq)
++#define ide_init_default_irq(base) ide_default_irq(base)
++#define ide_default_io_ctl(base) ((base) + (0xE*4))
++
++#include <asm-generic/ide_iops.h>
++
++#endif /* __KERNEL__ */
++
++#endif /* __ASMNIOS2_IDE_H */
+--- linux/include/asm-nios2nommu/init.h
++++ linux/include/asm-nios2nommu/init.h
+@@ -0,0 +1,22 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+--- linux/include/asm-nios2nommu/io.h
++++ linux/include/asm-nios2nommu/io.h
+@@ -0,0 +1,239 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_IO_H
++#define __NIOS2_IO_H
++
++#ifdef __KERNEL__
++
++#include <linux/kernel.h>
++
++#include <asm/page.h> /* IO address mapping routines need this */
++#include <asm/system.h>
++#include <asm/unaligned.h>
++
++extern void insw(unsigned long port, void *dst, unsigned long count);
++extern void outsw(unsigned long port, void *src, unsigned long count);
++extern void insl(unsigned long port, void *dst, unsigned long count);
++extern void outsl(unsigned long port, void *src, unsigned long count);
++
++
++/*
++ * readX/writeX() are used to access memory mapped devices. On some
++ * architectures the memory mapped IO stuff needs to be accessed
++ * differently. On the Nios architecture, we just read/write the
++ * memory location directly.
++ */
++
++#define readb(addr) \
++({ \
++ unsigned char __res;\
++ __asm__ __volatile__( \
++ "ldbuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readw(addr) \
++({ \
++ unsigned short __res;\
++ __asm__ __volatile__( \
++ "ldhuio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define readl(addr) \
++({ \
++ unsigned int __res;\
++ __asm__ __volatile__( \
++ "ldwio %0, 0(%1)" \
++ : "=r"(__res) \
++ : "r" (addr)); \
++ __res; \
++})
++
++#define writeb(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stbio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writew(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "sthio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define writel(b,addr) \
++({ \
++ __asm__ __volatile__( \
++ "stwio %0, 0(%1)" \
++ : : "r"(b), "r" (addr)); \
++})
++
++#define __raw_readb readb
++#define __raw_readw readw
++#define __raw_readl readl
++#define __raw_writeb writeb
++#define __raw_writew writew
++#define __raw_writel writel
++
++
++/*
++ * make the short names macros so specific devices
++ * can override them as required
++ */
++
++#define memset_io(addr,c,len) memset((void *)(((unsigned int)(addr)) | 0x80000000),(c),(len))
++#define memcpy_fromio(to,from,len) memcpy((to),(void *)(((unsigned int)(from)) | 0x80000000),(len))
++#define memcpy_toio(to,from,len) memcpy((void *)(((unsigned int)(to)) | 0x80000000),(from),(len))
++
++#define inb(addr) readb(addr)
++#define inw(addr) readw(addr)
++#define inl(addr) readl(addr)
++
++#define outb(x,addr) ((void) writeb(x,addr))
++#define outw(x,addr) ((void) writew(x,addr))
++#define outl(x,addr) ((void) writel(x,addr))
++
++#define inb_p(addr) inb(addr)
++#define inw_p(addr) inw(addr)
++#define inl_p(addr) inl(addr)
++
++#define outb_p(x,addr) outb(x,addr)
++#define outw_p(x,addr) outw(x,addr)
++#define outl_p(x,addr) outl(x,addr)
++
++
++
++extern inline void insb(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)dst;
++ while (count--)
++ *p++ = inb(port);
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _insw(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)dst;
++ while (count--)
++ *p++ = inw(port);
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned destination pointer */
++extern inline void _insl(unsigned long port, void *dst, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)dst;
++ while (count--)
++ *p++ = inl(port);
++}
++
++extern inline void outsb(unsigned long port, void *src, unsigned long count)
++{
++ unsigned char *p=(unsigned char*)src;
++ while (count--)
++ outb( *p++, port );
++}
++
++/* See arch/niosnommu/io.c for optimized version */
++extern inline void _outsw(unsigned long port, void *src, unsigned long count)
++{
++ unsigned short *p=(unsigned short*)src;
++ while (count--)
++ outw( *p++, port );
++}
++
++/* See arch/niosnommu/kernel/io.c for unaligned source pointer */
++extern inline void _outsl(unsigned long port, void *src, unsigned long count)
++{
++ unsigned long *p=(unsigned long*)src;
++ while (count--)
++ outl( *p++, port );
++}
++
++
++
++extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr,
++ int bus, int rdonly)
++{
++ return;
++}
++
++//vic - copied from m68knommu
++
++/* Values for nocacheflag and cmode */
++#define IOMAP_FULL_CACHING 0
++#define IOMAP_NOCACHE_SER 1
++#define IOMAP_NOCACHE_NONSER 2
++#define IOMAP_WRITETHROUGH 3
++
++extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
++extern void __iounmap(void *addr, unsigned long size);
++
++extern inline void *ioremap(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
++}
++extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
++}
++extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
++{
++ return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
++}
++
++extern void iounmap(void *addr);
++
++
++#define IO_SPACE_LIMIT 0xffffffff
++
++#define dma_cache_inv(_start,_size) do { } while (0)
++#define dma_cache_wback(_start,_size) do { } while (0)
++#define dma_cache_wback_inv(_start,_size) do { } while (0)
++
++/* Pages to physical address... */
++#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
++#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#endif /* __KERNEL__ */
++
++#endif /* !(__NIOS2_IO_H) */
++
+--- linux/include/asm-nios2nommu/ioctl.h
++++ linux/include/asm-nios2nommu/ioctl.h
+@@ -0,0 +1,100 @@
++/* $Id: ioctl.h,v 1.3 2004/02/12 23:06:40 ken-h Exp $
++ *
++ * linux/ioctl.h for Linux by H.H. Bergman.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_IOCTL_H
++#define _NIOS2_IOCTL_H
++
++/* ioctl command encoding: 32 bits total, command in lower 16 bits,
++ * size of the parameter structure in the lower 14 bits of the
++ * upper 16 bits.
++ * Encoding the size of the parameter structure in the ioctl request
++ * is useful for catching programs compiled with old versions
++ * and to avoid overwriting user space outside the user buffer area.
++ * The highest 2 bits are reserved for indicating the ``access mode''.
++ * NOTE: This limits the max parameter size to 16kB -1 !
++ */
++
++/*
++ * I don't really have any idea about what this should look like, so
++ * for the time being, this is heavily based on the PC definitions.
++ */
++
++/*
++ * The following is for compatibility across the various Linux
++ * platforms. The i386 ioctl numbering scheme doesn't really enforce
++ * a type field. De facto, however, the top 8 bits of the lower 16
++ * bits are indeed used as a type field, so we might just as well make
++ * this explicit here. Please be sure to use the decoding macros
++ * below from now on.
++ */
++#define _IOC_NRBITS 8
++#define _IOC_TYPEBITS 8
++#define _IOC_SIZEBITS 14
++#define _IOC_DIRBITS 2
++
++#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
++#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
++#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
++#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
++
++#define _IOC_NRSHIFT 0
++#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
++#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
++#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
++
++/*
++ * Direction bits.
++ */
++#define _IOC_NONE 0U
++#define _IOC_WRITE 1U
++#define _IOC_READ 2U
++
++#define _IOC(dir,type,nr,size) \
++ (((dir) << _IOC_DIRSHIFT) | \
++ ((type) << _IOC_TYPESHIFT) | \
++ ((nr) << _IOC_NRSHIFT) | \
++ ((size) << _IOC_SIZESHIFT))
++
++/* used to create numbers */
++#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
++#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
++#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
++#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
++
++/* used to decode ioctl numbers.. */
++#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
++#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
++#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
++#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
++
++/* ...and for the drivers/sound files... */
++
++#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
++#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
++#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
++#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
++#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
++
++#endif /* _NIOS2_IOCTL_H */
+--- linux/include/asm-nios2nommu/ioctls.h
++++ linux/include/asm-nios2nommu/ioctls.h
+@@ -0,0 +1,103 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ARCH_NIOS2_IOCTLS_H__
++#define __ARCH_NIOS2_IOCTLS_H__
++
++#include <asm/ioctl.h>
++
++/* 0x54 is just a magic number to make these relatively unique ('T') */
++
++#define TCGETS 0x5401
++#define TCSETS 0x5402
++#define TCSETSW 0x5403
++#define TCSETSF 0x5404
++#define TCGETA 0x5405
++#define TCSETA 0x5406
++#define TCSETAW 0x5407
++#define TCSETAF 0x5408
++#define TCSBRK 0x5409
++#define TCXONC 0x540A
++#define TCFLSH 0x540B
++#define TIOCEXCL 0x540C
++#define TIOCNXCL 0x540D
++#define TIOCSCTTY 0x540E
++#define TIOCGPGRP 0x540F
++#define TIOCSPGRP 0x5410
++#define TIOCOUTQ 0x5411
++#define TIOCSTI 0x5412
++#define TIOCGWINSZ 0x5413
++#define TIOCSWINSZ 0x5414
++#define TIOCMGET 0x5415
++#define TIOCMBIS 0x5416
++#define TIOCMBIC 0x5417
++#define TIOCMSET 0x5418
++#define TIOCGSOFTCAR 0x5419
++#define TIOCSSOFTCAR 0x541A
++#define FIONREAD 0x541B
++#define TIOCINQ FIONREAD
++#define TIOCLINUX 0x541C
++#define TIOCCONS 0x541D
++#define TIOCGSERIAL 0x541E
++#define TIOCSSERIAL 0x541F
++#define TIOCPKT 0x5420
++#define FIONBIO 0x5421
++#define TIOCNOTTY 0x5422
++#define TIOCSETD 0x5423
++#define TIOCGETD 0x5424
++#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
++#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
++#define TIOCSBRK 0x5427 /* BSD compatibility */
++#define TIOCCBRK 0x5428 /* BSD compatibility */
++#define TIOCGSID 0x5429 /* Return the session ID of FD */
++#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
++#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
++
++#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
++#define FIOCLEX 0x5451
++#define FIOASYNC 0x5452
++#define TIOCSERCONFIG 0x5453
++#define TIOCSERGWILD 0x5454
++#define TIOCSERSWILD 0x5455
++#define TIOCGLCKTRMIOS 0x5456
++#define TIOCSLCKTRMIOS 0x5457
++#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
++#define TIOCSERGETLSR 0x5459 /* Get line status register */
++#define TIOCSERGETMULTI 0x545A /* Get multiport config */
++#define TIOCSERSETMULTI 0x545B /* Set multiport config */
++
++#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
++#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
++#define FIOQSIZE 0x545E
++
++/* Used for packet mode */
++#define TIOCPKT_DATA 0
++#define TIOCPKT_FLUSHREAD 1
++#define TIOCPKT_FLUSHWRITE 2
++#define TIOCPKT_STOP 4
++#define TIOCPKT_START 8
++#define TIOCPKT_NOSTOP 16
++#define TIOCPKT_DOSTOP 32
++
++#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
++
++#endif /* __ARCH_NIOS2_IOCTLS_H__ */
+--- linux/include/asm-nios2nommu/ipc.h
++++ linux/include/asm-nios2nommu/ipc.h
+@@ -0,0 +1,51 @@
++#ifndef __NIOS2_IPC_H__
++#define __NIOS2_IPC_H__
++
++/* Copied from sparc version
++ * These are used to wrap system calls on the Nios.
++ *
++ * See arch/niosnommu/kernel/sys_nios.c for ugly details..
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++struct ipc_kludge {
++ struct msgbuf *msgp;
++ long msgtyp;
++};
++
++#define SEMOP 1
++#define SEMGET 2
++#define SEMCTL 3
++#define MSGSND 11
++#define MSGRCV 12
++#define MSGGET 13
++#define MSGCTL 14
++#define SHMAT 21
++#define SHMDT 22
++#define SHMGET 23
++#define SHMCTL 24
++
++/* Used by the DIPC package, try and avoid reusing it */
++#define DIPC 25
++
++#define IPCCALL(version,op) ((version)<<16 | (op))
++
++#endif
+--- linux/include/asm-nios2nommu/ipcbuf.h
++++ linux/include/asm-nios2nommu/ipcbuf.h
+@@ -0,0 +1,49 @@
++#ifndef __NIOS2_IPCBUF_H__
++#define __NIOS2_IPCBUF_H__
++
++/* Copied from asm-m68k/ipcbuf.h
++ * The user_ipc_perm structure for Nios architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 32-bit mode_t and seq
++ * - 2 miscellaneous 32-bit values
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++struct ipc64_perm
++{
++ __kernel_key_t key;
++ __kernel_uid32_t uid;
++ __kernel_gid32_t gid;
++ __kernel_uid32_t cuid;
++ __kernel_gid32_t cgid;
++ __kernel_mode_t mode;
++ unsigned short __pad1;
++ unsigned short seq;
++ unsigned short __pad2;
++ unsigned long __unused1;
++ unsigned long __unused2;
++};
++
++#endif /* __NIOS2_IPCBUF_H__ */
+--- linux/include/asm-nios2nommu/irq.h
++++ linux/include/asm-nios2nommu/irq.h
+@@ -0,0 +1,182 @@
++/*
++ * 21Mar2001 1.1 dgt/microtronix
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++
++#ifndef _NIOS2NOMMU_IRQ_H_
++#define _NIOS2NOMMU_IRQ_H_
++
++extern void disable_irq(unsigned int);
++extern void enable_irq(unsigned int);
++
++// #include <linux/config.h>
++#include <linux/interrupt.h>
++
++#define SYS_IRQS 32
++#define NR_IRQS SYS_IRQS
++
++/*
++ * Interrupt source definitions
++ * General interrupt sources are the level 1-7.
++ * Adding an interrupt service routine for one of these sources
++ * results in the addition of that routine to a chain of routines.
++ * Each one is called in succession. Each individual interrupt
++ * service routine should determine if the device associated with
++ * that routine requires service.
++ */
++
++#define IRQ01 (1) /* level 1 interrupt */
++#define IRQ02 (2) /* level 2 interrupt */
++#define IRQ03 (3) /* level 3 interrupt */
++#define IRQ04 (4) /* level 4 interrupt */
++#define IRQ05 (5) /* level 5 interrupt */
++#define IRQ06 (6) /* level 6 interrupt */
++#define IRQ07 (7) /* level 7 interrupt */
++#define IRQ08 (8) /* level 8 interrupt */
++#define IRQ09 (9) /* level 9 interrupt */
++#define IRQ0A (10) /* level 10 interrupt */
++#define IRQ0B (11) /* level 11 interrupt */
++#define IRQ0C (12) /* level 12 interrupt */
++#define IRQ0D (13) /* level 13 interrupt */
++#define IRQ0E (14) /* level 14 interrupt */
++#define IRQ0F (15) /* level 15 interrupt */
++#define IRQ10 (16) /* level 16 interrupt */
++#define IRQ12 (17) /* level 17 interrupt */
++#define IRQ13 (18) /* level 18 interrupt */
++#define IRQ14 (19) /* level 19 interrupt */
++#define IRQ15 (20) /* level 20 interrupt */
++#define IRQ16 (21) /* level 21 interrupt */
++#define IRQ17 (22) /* level 22 interrupt */
++#define IRQ18 (23) /* level 23 interrupt */
++#define IRQ19 (24) /* level 24 interrupt */
++#define IRQ1A (25) /* level 25 interrupt */
++#define IRQ1B (26) /* level 26 interrupt */
++#define IRQ1C (27) /* level 27 interrupt */
++#define IRQ1D (28) /* level 28 interrupt */
++#define IRQ1E (29) /* level 29 interrupt */
++#define IRQ1F (30) /* level 30 interrupt */
++#define IRQ20 (31) /* level 31 interrupt */
++#define IRQ21 (32) /* level 32 interrupt */
++
++#define IRQMAX IRQ21
++
++/*
++ * "Generic" interrupt sources
++ */
++
++/*
++ * Machine specific interrupt sources.
++ *
++ * Adding an interrupt service routine for a source with this bit
++ * set indicates a special machine specific interrupt source.
++ * The machine specific files define these sources.
++ *
++ * Removed, they are not used by any one.
++ */
++
++/*
++ * various flags for request_irq()
++ */
++#define IRQ_FLG_LOCK (0x0001) /* handler is not replaceable */
++#define IRQ_FLG_REPLACE (0x0002) /* replace existing handler */
++#define IRQ_FLG_FAST (0x0004)
++#define IRQ_FLG_SLOW (0x0008)
++#define IRQ_FLG_STD (0x8000) /* internally used */
++
++/*
++ * Functions to set and clear the interrupt mask.
++ */
++
++/*
++ * Use a zero to clean the bit.
++ */
++static inline void clrimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "and r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * Use a one to set the bit.
++ */
++static inline void setimr(int mask)
++{
++ int flags;
++
++ local_irq_save(flags);
++ __asm__ __volatile__(
++ "rdctl r8, ienable\n"
++ "or r8,r8,%0\n"
++ "wrctl ienable, r8\n"
++ : /* No output */
++ : "r" (mask)
++ : "r8");
++ local_irq_restore(flags);
++}
++
++/*
++ * This structure is used to chain together the ISRs for a particular
++ * interrupt source (if it supports chaining).
++ */
++typedef struct irq_node {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++ struct irq_node *next;
++} irq_node_t;
++
++/*
++ * This function returns a new irq_node_t
++ */
++extern irq_node_t *new_irq_node(void);
++
++/*
++ * This structure has only 4 elements for speed reasons
++ */
++typedef struct irq_handler {
++ irqreturn_t (*handler)(int, void *, struct pt_regs *);
++ unsigned long flags;
++ void *dev_id;
++ const char *devname;
++} irq_handler_t;
++
++/* count of spurious interrupts */
++extern volatile unsigned int num_spurious;
++
++#define disable_irq_nosync(i) disable_irq(i)
++
++#ifndef irq_canonicalize
++#define irq_canonicalize(i) (i)
++#endif
++
++#endif /* _NIOS2NOMMU_IRQ_H_ */
+--- linux/include/asm-nios2nommu/kmap_types.h
++++ linux/include/asm-nios2nommu/kmap_types.h
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_KMAP_TYPES_H
++#define _ASM_KMAP_TYPES_H
++
++enum km_type {
++ KM_BOUNCE_READ,
++ KM_SKB_SUNRPC_DATA,
++ KM_SKB_DATA_SOFTIRQ,
++ KM_USER0,
++ KM_USER1,
++ KM_BIO_SRC_IRQ,
++ KM_BIO_DST_IRQ,
++ KM_PTE0,
++ KM_PTE1,
++ KM_IRQ0,
++ KM_IRQ1,
++ KM_SOFTIRQ0,
++ KM_SOFTIRQ1,
++ KM_TYPE_NR
++};
++
++#endif
+--- linux/include/asm-nios2nommu/linkage.h
++++ linux/include/asm-nios2nommu/linkage.h
+@@ -0,0 +1,29 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __ASM_LINKAGE_H
++#define __ASM_LINKAGE_H
++
++#define __ALIGN .align 3
++#define __ALIGN_STR ".align 3"
++
++#endif
+--- linux/include/asm-nios2nommu/linux_logo.h
++++ linux/include/asm-nios2nommu/linux_logo.h
+@@ -0,0 +1,953 @@
++/* $Id: linux_logo.h,v 1.3 2004/02/12 23:06:40 ken-h Exp $
++ * include/asm-nios/linux_logo.h: This is a linux logo
++ * to be displayed on boot.
++ *
++ * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
++ * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
++ * Copyright (C) 2004 Micrtronix Datacom Ltd.
++ *
++ * You can put anything here, but:
++ * LINUX_LOGO_COLORS has to be less than 224
++ * image size has to be 80x80
++ * values have to start from 0x20
++ * (i.e. RGB(linux_logo_red[0],
++ * linux_logo_green[0],
++ * linux_logo_blue[0]) is color 0x20)
++ * BW image has to be 80x80 as well, with MS bit
++ * on the left
++ * Serial_console ascii image can be any size,
++ * but should contain %s to display the version
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#include <linux/init.h>
++#include <linux/version.h>
++
++#define linux_logo_banner "Linux/NIOS2 version " UTS_RELEASE
++
++#define __HAVE_ARCH_LINUX_LOGO
++#define __HAVE_ARCH_LINUX_LOGO16
++
++#define LINUX_LOGO_COLORS 221
++
++#ifdef INCLUDE_LINUX_LOGO_DATA
++
++unsigned char linux_logo_red[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x65, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x76, 0x79,
++ 0x62, 0x36, 0x9a, 0xe2, 0xec, 0xe1, 0xb8, 0xd7,
++ 0xaf, 0x25, 0xbc, 0xc0, 0xef, 0xea, 0xe8, 0xe8,
++ 0xf5, 0xf1, 0xda, 0xd3, 0x79, 0xdb, 0xf4, 0xf6,
++ 0xf6, 0xf6, 0xe2, 0x3d, 0xb4, 0xce, 0xe6, 0xee,
++ 0xf6, 0x68, 0xd8, 0xec, 0xf5, 0xc6, 0xc8, 0x9c,
++ 0x89, 0xd2, 0xee, 0xcb, 0xb9, 0xd2, 0x66, 0x5e,
++ 0x8b, 0xbe, 0xa8, 0xd5, 0xca, 0xb6, 0xae, 0x9c,
++ 0xc5, 0xbe, 0xbe, 0xca, 0x90, 0xb2, 0x9a, 0xa8,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfe,
++ 0xf6, 0xec, 0xfe, 0xd2, 0xea, 0xf5, 0xf2, 0xf2,
++ 0xe9, 0xee, 0xf6, 0xf2, 0xee, 0xf6, 0xda, 0xd4,
++ 0xfa, 0xca, 0xf2, 0xf6, 0xfe, 0xf2, 0xda, 0xe4,
++ 0xf6, 0xdd, 0xf2, 0xee, 0xfa, 0xf0, 0x12, 0x4a,
++ 0xd6, 0xf2, 0x8e, 0xf2, 0xf6, 0xf6, 0xb5, 0xf1,
++ 0x26, 0x9a, 0xea, 0xf6, 0xe0, 0xd2, 0x16, 0x9a,
++ 0x2e, 0xd2, 0x70, 0xd6, 0x46, 0x7c, 0xb4, 0x62,
++ 0xda, 0xee, 0xd6, 0xa3, 0x74, 0xa7, 0xa2, 0xe0,
++ 0xae, 0xbe, 0xce, 0xe2, 0xa3, 0x8e, 0x6d, 0x8e,
++ 0x32, 0xaf, 0x50, 0x9e, 0x5b, 0x8a, 0x98, 0x82,
++ 0x7a, 0x82, 0x56, 0x7c, 0x8a, 0x56, 0x5e, 0x86,
++ 0x6a, 0x52, 0x59, 0x64, 0x5e,
++};
++
++unsigned char linux_logo_green[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x62, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x62, 0x5c,
++ 0x4e, 0x26, 0x72, 0xaa, 0xba, 0xaf, 0x90, 0xae,
++ 0x92, 0x1a, 0xa4, 0x85, 0xb6, 0xbe, 0xc3, 0xc8,
++ 0xcf, 0xd0, 0xc2, 0xce, 0x57, 0xa2, 0xd6, 0xda,
++ 0xda, 0xd7, 0xb8, 0x2a, 0x7b, 0x91, 0xae, 0xca,
++ 0xda, 0x45, 0x9e, 0xb2, 0xd7, 0x9b, 0x90, 0x76,
++ 0x5c, 0xa2, 0xbe, 0xa6, 0x85, 0x96, 0x4e, 0x46,
++ 0x66, 0x92, 0x7a, 0x9a, 0x96, 0x9d, 0x9a, 0x6b,
++ 0x8a, 0x8e, 0xb2, 0xca, 0x90, 0xa6, 0x79, 0x7c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfa,
++ 0xea, 0xd7, 0xf6, 0xbc, 0xda, 0xde, 0xda, 0xe6,
++ 0xca, 0xd8, 0xea, 0xe0, 0xcc, 0xf2, 0xce, 0xb2,
++ 0xee, 0xa2, 0xd6, 0xe6, 0xf6, 0xd7, 0xc5, 0xb8,
++ 0xc6, 0xb9, 0xce, 0xde, 0xce, 0xc6, 0x0e, 0x36,
++ 0xae, 0xbe, 0x86, 0xba, 0xbe, 0xe6, 0x8e, 0xc4,
++ 0x1e, 0x8e, 0xae, 0xba, 0xb2, 0xa6, 0x12, 0x7a,
++ 0x20, 0xc6, 0x64, 0xaa, 0x2f, 0x70, 0x85, 0x46,
++ 0xce, 0xd6, 0xa6, 0x6e, 0x51, 0x72, 0x92, 0xa6,
++ 0x87, 0x96, 0xa2, 0xd6, 0x85, 0x7a, 0x6a, 0x6e,
++ 0x22, 0x76, 0x36, 0x76, 0x3c, 0x6e, 0x63, 0x53,
++ 0x66, 0x62, 0x42, 0x50, 0x56, 0x42, 0x56, 0x56,
++ 0x56, 0x3e, 0x51, 0x52, 0x56,
++};
++
++unsigned char linux_logo_blue[] __initdata = {
++ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
++ 0x12, 0x01, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
++ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x06, 0x65,
++ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
++ 0xc3, 0x59, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
++ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
++ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x2e, 0x08,
++ 0x0a, 0x06, 0x0a, 0x0b, 0x0b, 0x0f, 0x0c, 0x0f,
++ 0x3d, 0x09, 0x73, 0x09, 0x0d, 0x0a, 0x10, 0x1e,
++ 0x2d, 0x13, 0x86, 0xba, 0x19, 0x0a, 0x36, 0x3c,
++ 0x26, 0x14, 0x0d, 0x06, 0x07, 0x0a, 0x0b, 0x0f,
++ 0x4a, 0x06, 0x0a, 0x0c, 0x2b, 0x0a, 0x0b, 0x0a,
++ 0x06, 0x0a, 0x0a, 0x11, 0x0b, 0x0a, 0x0a, 0x1e,
++ 0x0f, 0x0d, 0x0a, 0x0b, 0x22, 0x6a, 0x72, 0x0b,
++ 0x0b, 0x22, 0x90, 0xca, 0x90, 0x92, 0x3c, 0x2c,
++ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xea,
++ 0xb6, 0x7c, 0xda, 0x8e, 0xa6, 0x87, 0x66, 0xb6,
++ 0x81, 0x6a, 0xc6, 0x9a, 0x5b, 0xd2, 0xb6, 0x6a,
++ 0xca, 0x45, 0x92, 0xb2, 0xca, 0x52, 0x8a, 0x3e,
++ 0x2e, 0x66, 0x66, 0xae, 0x3e, 0x47, 0x06, 0x0e,
++ 0x52, 0x36, 0x6a, 0x0e, 0x0e, 0xbe, 0x2c, 0x0e,
++ 0x0a, 0x5a, 0x0d, 0x0e, 0x3e, 0x0a, 0x06, 0x2e,
++ 0x06, 0x9e, 0x4e, 0x36, 0x06, 0x58, 0x24, 0x06,
++ 0x9e, 0xae, 0x3a, 0x08, 0x08, 0x07, 0x5e, 0x0a,
++ 0x32, 0x2e, 0x2a, 0xb2, 0x43, 0x48, 0x5f, 0x2e,
++ 0x06, 0x06, 0x07, 0x24, 0x06, 0x32, 0x06, 0x06,
++ 0x46, 0x2e, 0x22, 0x06, 0x06, 0x1e, 0x4c, 0x06,
++ 0x3a, 0x22, 0x42, 0x34, 0x42,
++};
++
++unsigned char linux_logo[] __initdata = {
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22,
++ 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
++ 0x26, 0x26, 0x25, 0x28, 0x23, 0x22, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x25, 0x2a, 0x2b, 0x2c, 0x2d, 0x2d,
++ 0x2d, 0x2e, 0x2c, 0x2b, 0x2a, 0x25, 0x28, 0x22,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x24, 0x2a, 0x2c, 0x2f, 0x2c, 0x30, 0x30, 0x24,
++ 0x25, 0x27, 0x2b, 0x2c, 0x2f, 0x31, 0x32, 0x25,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x33, 0x34, 0x35, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x2b, 0x2f, 0x2c,
++ 0x30, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x2d, 0x27, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x31,
++ 0x2d, 0x32, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x28, 0x2a, 0x34,
++ 0x25, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x23, 0x32, 0x27, 0x21, 0x36,
++ 0x2a, 0x2d, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x26, 0x2c, 0x35,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2f, 0x37, 0x32, 0x22,
++ 0x36, 0x35, 0x31, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x22,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x26, 0x38, 0x38, 0x35, 0x25,
++ 0x36, 0x21, 0x2d, 0x2b, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x39, 0x39, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x25, 0x2b, 0x30, 0x28, 0x22,
++ 0x36, 0x36, 0x27, 0x34, 0x30, 0x23, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x26, 0x2d, 0x26, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x22, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2d, 0x33, 0x28, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x2b, 0x2c, 0x25, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x36, 0x36,
++ 0x36, 0x21, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x21, 0x23, 0x22, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x28, 0x34, 0x27, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x21, 0x21, 0x24, 0x27, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x27, 0x22, 0x33, 0x24, 0x36,
++ 0x36, 0x36, 0x36, 0x22, 0x2f, 0x2a, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
++ 0x30, 0x3a, 0x38, 0x24, 0x24, 0x36, 0x36, 0x36,
++ 0x23, 0x2f, 0x3b, 0x3c, 0x3d, 0x30, 0x25, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x32, 0x23, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x23,
++ 0x3e, 0x3f, 0x40, 0x3a, 0x22, 0x36, 0x36, 0x21,
++ 0x41, 0x42, 0x43, 0x44, 0x45, 0x3e, 0x23, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x33, 0x28, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x2b,
++ 0x44, 0x40, 0x46, 0x47, 0x35, 0x36, 0x36, 0x26,
++ 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x2e, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x32, 0x34, 0x36, 0x4d,
++ 0x4e, 0x25, 0x2f, 0x46, 0x4a, 0x22, 0x23, 0x32,
++ 0x4f, 0x50, 0x21, 0x31, 0x51, 0x52, 0x53, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x21, 0x3a,
++ 0x4d, 0x21, 0x31, 0x54, 0x55, 0x28, 0x30, 0x2b,
++ 0x4b, 0x4d, 0x36, 0x23, 0x32, 0x50, 0x3f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x20, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x38, 0x23, 0x37,
++ 0x55, 0x36, 0x28, 0x3a, 0x56, 0x57, 0x57, 0x58,
++ 0x3c, 0x4d, 0x36, 0x36, 0x36, 0x40, 0x40, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x29, 0x29, 0x29, 0x20, 0x29, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x51, 0x23, 0x35,
++ 0x43, 0x25, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
++ 0x5f, 0x60, 0x61, 0x36, 0x31, 0x47, 0x3b, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x31, 0x2c, 0x25, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x22,
++ 0x40, 0x62, 0x63, 0x5d, 0x64, 0x65, 0x66, 0x67,
++ 0x68, 0x69, 0x66, 0x5e, 0x6a, 0x6b, 0x2a, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x2e, 0x26, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2f, 0x23, 0x36,
++ 0x6c, 0x63, 0x6d, 0x64, 0x5c, 0x66, 0x69, 0x6e,
++ 0x6f, 0x70, 0x71, 0x69, 0x69, 0x72, 0x6c, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x33, 0x34, 0x27, 0x22,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x34, 0x26, 0x73,
++ 0x74, 0x75, 0x76, 0x64, 0x65, 0x77, 0x69, 0x78,
++ 0x70, 0x71, 0x71, 0x71, 0x72, 0x5f, 0x5e, 0x21,
++ 0x36, 0x36, 0x36, 0x36, 0x25, 0x38, 0x2a, 0x23,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x33, 0x79,
++ 0x63, 0x7a, 0x7b, 0x5c, 0x66, 0x69, 0x6e, 0x7c,
++ 0x71, 0x71, 0x69, 0x7d, 0x7e, 0x7a, 0x7f, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x21, 0x51, 0x2b, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x32, 0x24,
++ 0x80, 0x81, 0x64, 0x82, 0x77, 0x69, 0x71, 0x71,
++ 0x69, 0x83, 0x84, 0x85, 0x7a, 0x85, 0x86, 0x36,
++ 0x21, 0x2b, 0x23, 0x36, 0x36, 0x39, 0x2e, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2d, 0x33, 0x21,
++ 0x87, 0x88, 0x89, 0x72, 0x67, 0x66, 0x5f, 0x89,
++ 0x8a, 0x63, 0x85, 0x8b, 0x8c, 0x8d, 0x41, 0x36,
++ 0x36, 0x2d, 0x3a, 0x35, 0x36, 0x24, 0x51, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x33, 0x21,
++ 0x55, 0x8e, 0x8f, 0x8a, 0x7d, 0x5e, 0x90, 0x7e,
++ 0x75, 0x75, 0x90, 0x62, 0x40, 0x3f, 0x49, 0x23,
++ 0x36, 0x24, 0x3a, 0x3a, 0x24, 0x36, 0x2e, 0x31,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x33, 0x37, 0x25, 0x22,
++ 0x3b, 0x50, 0x8e, 0x8f, 0x90, 0x7e, 0x90, 0x63,
++ 0x74, 0x91, 0x92, 0x42, 0x93, 0x4b, 0x45, 0x2c,
++ 0x36, 0x36, 0x33, 0x39, 0x21, 0x36, 0x22, 0x51,
++ 0x33, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x27, 0x2e, 0x2e, 0x36, 0x21,
++ 0x94, 0x3f, 0x50, 0x95, 0x96, 0x8f, 0x8f, 0x97,
++ 0x8e, 0x42, 0x50, 0x43, 0x47, 0x48, 0x48, 0x98,
++ 0x21, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39,
++ 0x2e, 0x27, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x24, 0x2b, 0x38, 0x28, 0x36, 0x32,
++ 0x4c, 0x4b, 0x50, 0x50, 0x50, 0x42, 0x42, 0x50,
++ 0x50, 0x40, 0x45, 0x99, 0x48, 0x48, 0x48, 0x48,
++ 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x23,
++ 0x2f, 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x32, 0x51, 0x32, 0x28, 0x21, 0x98,
++ 0x48, 0x47, 0x9a, 0x50, 0x50, 0x50, 0x50, 0x50,
++ 0x9a, 0x4f, 0x9b, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x93, 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2f, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x23, 0x30, 0x2e, 0x2c, 0x36, 0x21, 0x51, 0x9b,
++ 0x48, 0x48, 0x52, 0x3f, 0x50, 0x50, 0x40, 0x4b,
++ 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2d, 0x31, 0x27, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x2c, 0x2d, 0x21, 0x36, 0x28, 0x44, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x46, 0x4f, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x9c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x28, 0x51, 0x39, 0x26, 0x22, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
++ 0x35, 0x51, 0x28, 0x36, 0x36, 0x9d, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x9b, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4f, 0x28, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x28, 0x38, 0x2b, 0x25, 0x22, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
++ 0x51, 0x25, 0x36, 0x36, 0x23, 0x40, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x9b, 0x99, 0x2b, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x2f, 0x33, 0x24, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x23, 0x30, 0x34,
++ 0x27, 0x36, 0x36, 0x36, 0x2a, 0x40, 0x47, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x99, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x47, 0x52,
++ 0x46, 0x4f, 0x37, 0x21, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x30, 0x34, 0x2a, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x22, 0x25, 0x39, 0x2c,
++ 0x36, 0x36, 0x36, 0x21, 0x31, 0x4e, 0x9a, 0x4c,
++ 0x47, 0x9b, 0x9b, 0x52, 0x46, 0x4f, 0x52, 0x9b,
++ 0x9b, 0x9b, 0x47, 0x4f, 0x45, 0x9a, 0x93, 0x93,
++ 0x3f, 0x93, 0x98, 0x28, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c, 0x26,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x28,
++ 0x36, 0x36, 0x36, 0x22, 0x38, 0x98, 0x44, 0x99,
++ 0x9b, 0x48, 0x48, 0x9b, 0x4c, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x47, 0x52, 0x46, 0x43, 0x93,
++ 0x40, 0x40, 0x43, 0x53, 0x21, 0x23, 0x33, 0x23,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x2f, 0x32,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x24, 0x2b, 0x31, 0x36,
++ 0x36, 0x22, 0x36, 0x24, 0x9e, 0x4f, 0x9b, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x9f, 0x52, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x47,
++ 0x4f, 0x9a, 0x3f, 0x46, 0x38, 0x36, 0x21, 0x30,
++ 0x26, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c,
++ 0x25, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2e, 0x33, 0x36,
++ 0x25, 0x25, 0x36, 0x4d, 0x52, 0x48, 0x48, 0x48,
++ 0x47, 0x9f, 0x48, 0x48, 0x48, 0xa0, 0xa1, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x47, 0x44, 0x93, 0x43, 0x23, 0x36, 0x36,
++ 0x26, 0x24, 0x36, 0x36, 0x36, 0x36, 0x28, 0x2f,
++ 0x2a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x51, 0x24, 0x36,
++ 0x2a, 0x36, 0x28, 0x44, 0x48, 0x48, 0x48, 0x48,
++ 0xa3, 0xa4, 0x48, 0x48, 0x9f, 0xa5, 0xa6, 0x9f,
++ 0x48, 0x48, 0x48, 0xa2, 0xa7, 0x47, 0x48, 0x48,
++ 0x48, 0x48, 0x9b, 0x4b, 0x44, 0x37, 0x36, 0x23,
++ 0x28, 0x30, 0x22, 0x36, 0x36, 0x36, 0x36, 0x2d,
++ 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x28, 0x2b, 0x34, 0x36, 0x25,
++ 0x24, 0x36, 0x4a, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0xa8, 0xa1, 0x48, 0x48, 0x9f, 0xa9, 0xa6, 0x9f,
++ 0x48, 0x48, 0xaa, 0xa1, 0xa5, 0x9f, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x9b, 0x52, 0x3f, 0x21, 0x30,
++ 0x35, 0x25, 0x30, 0x36, 0x36, 0x36, 0x36, 0x32,
++ 0x2d, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x22, 0x26, 0x2e, 0x35, 0x36, 0x2a,
++ 0x36, 0x24, 0x4f, 0x48, 0x52, 0x52, 0x48, 0x48,
++ 0xab, 0xac, 0xa0, 0x48, 0xad, 0xa6, 0xa6, 0x9f,
++ 0x48, 0xa2, 0xa9, 0xa6, 0xa2, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x47, 0x32, 0x30,
++ 0x2a, 0x23, 0x30, 0x23, 0x36, 0x36, 0x36, 0x21,
++ 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x2a, 0x51, 0x28, 0x28, 0x25,
++ 0x36, 0x3a, 0x48, 0x48, 0xae, 0xaf, 0x48, 0x48,
++ 0xad, 0xac, 0xa1, 0x9f, 0xa2, 0xa9, 0xa9, 0xa2,
++ 0x48, 0xab, 0x78, 0xa7, 0x48, 0x48, 0x48, 0x48,
++ 0x9f, 0x48, 0x48, 0x48, 0x48, 0x48, 0x38, 0x21,
++ 0x36, 0x36, 0x22, 0x27, 0x36, 0x36, 0x36, 0x36,
++ 0x2e, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x22, 0x25, 0x2c, 0x34, 0x36, 0x30, 0x21,
++ 0x23, 0x43, 0x48, 0x48, 0xb0, 0xb1, 0xb2, 0x9f,
++ 0x48, 0xb3, 0xa5, 0xb3, 0xab, 0xa9, 0xa9, 0xb3,
++ 0xb4, 0xa9, 0xb5, 0xb0, 0x48, 0x48, 0xa0, 0xa5,
++ 0xa1, 0xad, 0x48, 0x48, 0x48, 0x48, 0x94, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x2a, 0x2e, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x2a, 0x51, 0x25, 0x21, 0x2a, 0x36,
++ 0x2e, 0x9b, 0x48, 0x48, 0x48, 0xb6, 0xb7, 0xa4,
++ 0xa2, 0xa7, 0xb5, 0x78, 0x6f, 0x6f, 0x6e, 0x6f,
++ 0xa9, 0xb5, 0xab, 0x48, 0x9f, 0xab, 0xa9, 0xa1,
++ 0xaa, 0x48, 0x48, 0x48, 0x48, 0x48, 0x98, 0x36,
++ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
++ 0x22, 0x2f, 0x30, 0x22, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x22, 0x25, 0x2c, 0x34, 0x36, 0x24, 0x28, 0x36,
++ 0x54, 0x48, 0x48, 0x48, 0x48, 0xa2, 0xa8, 0xa1,
++ 0xa5, 0xa6, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x6f, 0x78, 0xa5, 0xa0, 0xa0, 0x78, 0xa6, 0xa2,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x36, 0x36, 0x36, 0x30, 0x36, 0x36, 0x36, 0x36,
++ 0x21, 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x32, 0x2f, 0x28, 0x36, 0x27, 0x22, 0x21,
++ 0x43, 0x48, 0x4b, 0xa2, 0x9f, 0x48, 0xa2, 0xa1,
++ 0xb8, 0x6e, 0x6e, 0xb5, 0x78, 0x6f, 0x78, 0x78,
++ 0x6e, 0x6f, 0x78, 0xb5, 0xa6, 0xa1, 0xa0, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4b, 0x21,
++ 0x36, 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x25, 0x2c, 0x39, 0x36, 0x36, 0x30, 0x22, 0x25,
++ 0x52, 0x48, 0xa3, 0xb1, 0xb6, 0xb3, 0xaa, 0xac,
++ 0x68, 0x68, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
++ 0x78, 0x6f, 0x6f, 0xb5, 0xa6, 0xb4, 0x48, 0x9f,
++ 0xb4, 0xb4, 0xa2, 0x9f, 0x48, 0x48, 0x4f, 0x21,
++ 0x36, 0x36, 0x22, 0x26, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x30, 0x2d, 0x21, 0x36, 0x36, 0x32, 0x23, 0x2a,
++ 0x47, 0x48, 0xa2, 0xb6, 0xaf, 0xb9, 0xba, 0x68,
++ 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x78,
++ 0x6f, 0x6f, 0xa6, 0x6f, 0xb5, 0xa0, 0xaa, 0xa6,
++ 0xa6, 0xa9, 0xb2, 0xb3, 0x48, 0x48, 0x4c, 0x22,
++ 0x36, 0x36, 0x24, 0x23, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0x2e, 0x36, 0x36, 0x23, 0x31, 0x27, 0x39,
++ 0x9b, 0x48, 0x48, 0x48, 0xb0, 0xb0, 0xba, 0xb8,
++ 0x68, 0x68, 0x69, 0x78, 0x6f, 0xb5, 0x6f, 0xb5,
++ 0x78, 0x78, 0x78, 0x78, 0x78, 0xa5, 0xbb, 0xa9,
++ 0xa5, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4c, 0x23,
++ 0x36, 0x36, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x2b, 0x39, 0x36, 0x36, 0x36, 0x26, 0x32, 0x31,
++ 0x9b, 0x48, 0x48, 0x48, 0x48, 0x9f, 0xac, 0x68,
++ 0xbc, 0x6e, 0x6e, 0x6e, 0xb5, 0x6f, 0x6e, 0x6f,
++ 0x6f, 0x78, 0x78, 0xb5, 0xb5, 0xa5, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x46, 0x22,
++ 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x39, 0x36, 0x36, 0x36, 0x36, 0x26, 0x2d,
++ 0x9b, 0x48, 0x48, 0xb0, 0xaa, 0xb3, 0xbd, 0xb8,
++ 0xb8, 0x68, 0x6e, 0x6e, 0xb5, 0x6f, 0x78, 0x6e,
++ 0x78, 0x6f, 0x78, 0x78, 0xb5, 0xa9, 0xa2, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
++ 0x24, 0x27, 0xbe, 0x24, 0x25, 0x28, 0x21, 0x36,
++ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x25,
++ 0x39, 0x4d, 0xbf, 0x84, 0x81, 0x57, 0x21, 0x39,
++ 0x52, 0x48, 0x48, 0x62, 0xb1, 0xc0, 0xc1, 0xc1,
++ 0xb8, 0xb8, 0x68, 0xbc, 0x6e, 0x6e, 0x6e, 0x78,
++ 0x78, 0x78, 0x78, 0x6e, 0x78, 0xa9, 0xa0, 0xab,
++ 0xb3, 0xa2, 0x48, 0x48, 0x48, 0x48, 0x53, 0x28,
++ 0x23, 0x36, 0x36, 0x36, 0x21, 0x28, 0x2c, 0x30,
++ 0x21, 0x38, 0x33, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x22, 0x22, 0x28, 0x30,
++ 0x2d, 0xc2, 0x7a, 0xc3, 0xc4, 0xc4, 0x7f, 0x22,
++ 0x51, 0x52, 0x48, 0x48, 0xb0, 0xaa, 0xa8, 0xbd,
++ 0x68, 0xb8, 0xb8, 0x68, 0x68, 0x6e, 0x6e, 0x6f,
++ 0x6e, 0x6e, 0xb5, 0x6e, 0x78, 0xab, 0xab, 0xb5,
++ 0x78, 0xa6, 0xb3, 0xc5, 0xac, 0xac, 0xc6, 0x61,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x30, 0x32,
++ 0x25, 0x4d, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x24, 0x26, 0x30, 0x33, 0x31,
++ 0x4d, 0x91, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0x5a,
++ 0x21, 0x2e, 0x46, 0x48, 0x48, 0x48, 0xb0, 0x64,
++ 0xc1, 0xb8, 0xb8, 0xb8, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6f, 0x71, 0x6f, 0x6f, 0xa6, 0xa0, 0x9f, 0xb4,
++ 0xb4, 0xa0, 0xa1, 0xb7, 0xc7, 0x69, 0x66, 0xc8,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x26, 0x25,
++ 0x83, 0xc9, 0x2c, 0x25, 0x21, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x30, 0x35, 0x2d, 0x2f, 0x37, 0x4a,
++ 0x60, 0x85, 0xca, 0xcb, 0xc4, 0xc4, 0xc4, 0x82,
++ 0x86, 0x36, 0x32, 0x3f, 0xa2, 0xa4, 0xa8, 0xa9,
++ 0xb8, 0xb8, 0xb8, 0xb8, 0x68, 0x6e, 0x6e, 0x6e,
++ 0x6e, 0x71, 0x6f, 0x71, 0xa6, 0xb4, 0x9f, 0x9f,
++ 0x48, 0x48, 0x48, 0xcc, 0xc3, 0xc7, 0xcd, 0xce,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x57,
++ 0x77, 0x66, 0x34, 0x27, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x23, 0x30, 0x31, 0xcf, 0x91, 0x7e, 0x90, 0x90,
++ 0x8b, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0x5d, 0xd0, 0x36, 0x24, 0xd1, 0xb1, 0xaf, 0xaa,
++ 0xba, 0xb8, 0x68, 0x68, 0x68, 0x71, 0x6e, 0x6e,
++ 0x6e, 0x6f, 0x6e, 0x78, 0xa1, 0xa9, 0xa1, 0xb0,
++ 0x9f, 0x9b, 0x99, 0xcc, 0x64, 0x5c, 0x8b, 0xd0,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x73, 0x5d,
++ 0x82, 0x5c, 0xd2, 0x2a, 0x23, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x24, 0x2b, 0xcf, 0x8b, 0x5b, 0x76, 0x5b, 0x5b,
++ 0x7b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc7, 0x5e, 0x22, 0x36, 0x21, 0x3a, 0x99, 0x48,
++ 0xa2, 0xa8, 0xb7, 0xc1, 0xb8, 0x68, 0x68, 0xbc,
++ 0x68, 0x6e, 0xb5, 0xb4, 0xb4, 0xab, 0xb5, 0xa1,
++ 0xb0, 0x4f, 0x3f, 0xd3, 0x7b, 0x7b, 0x85, 0x80,
++ 0xbe, 0x36, 0x36, 0x36, 0x21, 0xd4, 0x7e, 0x7b,
++ 0x64, 0x64, 0xd5, 0x35, 0x24, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x31, 0xd6, 0x5b, 0x64, 0xc3, 0xc3, 0xcb,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x66, 0xd7, 0x36, 0x36, 0x36, 0x2c, 0x4b,
++ 0xd8, 0xd9, 0xb3, 0xa8, 0xbd, 0xbd, 0xbd, 0xbd,
++ 0xa9, 0xab, 0xb3, 0xa5, 0xa2, 0x9f, 0xa2, 0xa1,
++ 0x6a, 0x9a, 0x3f, 0xda, 0x76, 0x76, 0x7a, 0x63,
++ 0xdb, 0xdc, 0x86, 0xdc, 0xdd, 0x90, 0x5b, 0x64,
++ 0xc3, 0xc3, 0xde, 0x2d, 0x27, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x26, 0x2d, 0x91, 0x5b, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc7, 0x83, 0xce, 0x36, 0x36, 0x36, 0x30,
++ 0xb1, 0xd9, 0x48, 0xa1, 0xb2, 0xb0, 0xb0, 0xb3,
++ 0xa2, 0x48, 0xa7, 0xbd, 0xa9, 0xa2, 0x48, 0x9f,
++ 0xaa, 0x9a, 0x3f, 0xb1, 0x5b, 0x7b, 0xdf, 0x85,
++ 0x7e, 0x90, 0x63, 0x90, 0x85, 0x5b, 0xc3, 0xc4,
++ 0xc4, 0xcb, 0x5d, 0xd5, 0x39, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe0, 0xdf, 0x64, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x88, 0x36, 0x36, 0x36, 0x36,
++ 0x2d, 0x9b, 0x48, 0xb9, 0xaf, 0xa2, 0xa2, 0xb9,
++ 0xa8, 0x9f, 0x48, 0xa7, 0xb7, 0xd9, 0x48, 0x48,
++ 0x9b, 0x45, 0x3f, 0xe1, 0x6d, 0x7b, 0xca, 0xdf,
++ 0x7a, 0x8b, 0x8b, 0x7a, 0x5b, 0x64, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc3, 0xe2, 0x37, 0x35, 0x26, 0x23,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2e, 0xe0, 0x7a, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc7, 0x72, 0x73, 0x36, 0x36, 0x36,
++ 0x24, 0x52, 0x48, 0xa3, 0xaf, 0x9f, 0x48, 0xb6,
++ 0xaf, 0xa2, 0x48, 0x9f, 0xe3, 0xd8, 0x48, 0x48,
++ 0x48, 0x46, 0x42, 0xd6, 0x7a, 0x7b, 0x64, 0x7b,
++ 0x76, 0x5b, 0x5b, 0x76, 0x7b, 0xc3, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0x64, 0xe2, 0x4d, 0x2c, 0x27,
++ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x8b, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc7, 0x89, 0xbe, 0x36, 0x36,
++ 0x32, 0x47, 0x48, 0x4f, 0xa0, 0x48, 0x48, 0xe3,
++ 0x92, 0x9f, 0x48, 0x9f, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x4b, 0x2f, 0x8f, 0x7a, 0x7b, 0xc3, 0xcb,
++ 0xc3, 0x64, 0x64, 0xc3, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x5d, 0xe5, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x25, 0x31, 0xe4, 0x85, 0x7b, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x57, 0x27, 0x4d,
++ 0x4b, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x99, 0x34, 0xbe, 0xdb, 0x7a, 0x7b, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xe4,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
++ 0x26, 0x2d, 0xe4, 0x85, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc7, 0x5f, 0x92, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x44,
++ 0x35, 0x36, 0xce, 0xdd, 0x7a, 0x7b, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0xc3, 0xe1,
++ 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x30, 0x2f, 0xd6, 0x8b, 0x7b, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x89, 0x45,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x4e, 0x25,
++ 0x36, 0x36, 0x61, 0xdb, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0xdf, 0xe5,
++ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xe6, 0x63, 0xdf, 0xc3, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x72, 0x81, 0xe7,
++ 0x46, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
++ 0x48, 0x48, 0x48, 0x48, 0x3f, 0x2c, 0x36, 0x36,
++ 0x36, 0x36, 0xe8, 0x8f, 0x6d, 0x64, 0xcb, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc3, 0xca, 0x8b, 0xcf, 0x2c,
++ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x35, 0x96, 0x75, 0xca, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0x81, 0xdb,
++ 0x73, 0x3b, 0x44, 0x9b, 0x48, 0x48, 0x48, 0x9b,
++ 0x99, 0x43, 0x94, 0x2c, 0x21, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x73, 0xdb, 0x7a, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0x64, 0x76, 0x7a, 0x91, 0xd5, 0x31, 0x30,
++ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
++ 0x39, 0x97, 0x75, 0xdf, 0x7b, 0x64, 0xc3, 0xc3,
++ 0xcb, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x7b, 0x7a, 0xe9,
++ 0xea, 0x36, 0x21, 0x26, 0x2b, 0x39, 0x33, 0x30,
++ 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xdd, 0x8b, 0x7b, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x64, 0x64,
++ 0x76, 0x85, 0xe0, 0xd5, 0x34, 0x2b, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
++ 0x33, 0xeb, 0x63, 0x7e, 0x7a, 0x6d, 0xdf, 0x5b,
++ 0x76, 0x7b, 0x64, 0x64, 0xc3, 0xcb, 0xc4, 0xc4,
++ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x76, 0x85, 0xdb,
++ 0x79, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xec, 0xdd, 0x75, 0x76, 0xc3, 0xc4,
++ 0xc4, 0xc4, 0xcb, 0xc3, 0x64, 0x76, 0xdf, 0x8b,
++ 0xd6, 0xd5, 0x2f, 0x35, 0x30, 0x24, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
++ 0x27, 0x31, 0xed, 0xeb, 0xdd, 0x74, 0x63, 0x90,
++ 0x7e, 0x75, 0x8b, 0x6d, 0xdf, 0x76, 0x64, 0xc3,
++ 0xcb, 0xcb, 0xcb, 0xcb, 0x64, 0x7a, 0x84, 0xee,
++ 0x79, 0xbe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
++ 0x36, 0x21, 0xea, 0xee, 0x63, 0x6d, 0x7b, 0x64,
++ 0xcb, 0xc3, 0x64, 0x7b, 0xdf, 0x75, 0x63, 0x96,
++ 0x38, 0x39, 0x2a, 0x24, 0x23, 0x21, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x28, 0x27, 0x35, 0x2d, 0x41, 0xd5, 0xe7, 0x8f,
++ 0xdb, 0xdd, 0xe9, 0x74, 0x84, 0x90, 0x85, 0x6d,
++ 0x5b, 0x7b, 0x7b, 0xca, 0x6d, 0x90, 0xdb, 0xef,
++ 0xec, 0x22, 0x36, 0x36, 0x28, 0x30, 0x30, 0x30,
++ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x25, 0x36,
++ 0x36, 0x21, 0xd4, 0x80, 0xe9, 0x7e, 0x6d, 0x76,
++ 0xca, 0x76, 0x6d, 0x85, 0x63, 0xdb, 0xd5, 0x34,
++ 0x33, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x23, 0x24, 0x27, 0x2a, 0x35, 0x2e, 0x2f,
++ 0x41, 0xf0, 0xf1, 0x6c, 0x80, 0xee, 0xdb, 0x74,
++ 0x84, 0x90, 0x75, 0x7e, 0x74, 0x8f, 0xef, 0x79,
++ 0xe8, 0x2b, 0x9d, 0x41, 0x2f, 0x34, 0x2d, 0x2d,
++ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x34, 0x2f, 0x38,
++ 0x4d, 0x37, 0xf2, 0xf3, 0x8f, 0x74, 0x63, 0x7e,
++ 0x75, 0x7e, 0x63, 0xe9, 0x88, 0xe6, 0x31, 0x2a,
++ 0x24, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x30,
++ 0x33, 0x39, 0x2e, 0x51, 0x41, 0xd2, 0x6c, 0xf3,
++ 0x80, 0xee, 0xee, 0xee, 0xf4, 0xf3, 0xd7, 0xf5,
++ 0x41, 0x34, 0x35, 0x32, 0x30, 0x27, 0x27, 0x27,
++ 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x30, 0x2a,
++ 0x2b, 0x34, 0xf6, 0xec, 0xf7, 0x8f, 0xdd, 0xe9,
++ 0xe9, 0xdd, 0xee, 0x6c, 0x41, 0x39, 0x27, 0x28,
++ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22,
++ 0x28, 0x24, 0x26, 0x2a, 0x33, 0x2c, 0x2f, 0x41,
++ 0xf8, 0xd7, 0x79, 0x79, 0x79, 0xec, 0xf9, 0x51,
++ 0x39, 0x30, 0x24, 0x23, 0x22, 0x22, 0x22, 0x22,
++ 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23,
++ 0x24, 0x2a, 0x31, 0xfa, 0xea, 0x79, 0xf3, 0x80,
++ 0xf7, 0xdc, 0xfb, 0x2f, 0x35, 0x26, 0x23, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x22, 0x23, 0x28, 0x25, 0x30, 0x2b,
++ 0x31, 0x2f, 0xf6, 0xfa, 0xfa, 0x2f, 0x2e, 0x33,
++ 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x21, 0x28, 0x27, 0x35, 0x34, 0xfa, 0xfa, 0xfa,
++ 0xfc, 0xf6, 0x2e, 0x33, 0x25, 0x23, 0x21, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x23, 0x28,
++ 0x26, 0x30, 0x32, 0x2b, 0x33, 0x2a, 0x26, 0x28,
++ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x21, 0x23, 0x25, 0x30, 0x33, 0x35, 0x35,
++ 0x2b, 0x2a, 0x26, 0x28, 0x22, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
++ 0x21, 0x22, 0x23, 0x28, 0x28, 0x23, 0x22, 0x21,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x21, 0x23, 0x28, 0x24, 0x24,
++ 0x28, 0x23, 0x22, 0x21, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
++};
++
++unsigned char linux_logo16[1];
++
++#endif /* INCLUDE_LINUX_LOGO_DATA */
++
++#include <linux/linux_logo.h>
++
+--- linux/include/asm-nios2nommu/local.h
++++ linux/include/asm-nios2nommu/local.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_LOCAL_H
++#define __NIOS2NOMMU_LOCAL_H
++
++#include <asm-generic/local.h>
++
++#endif /* __NIOS2NOMMU_LOCAL_H */
+--- linux/include/asm-nios2nommu/mc146818rtc.h
++++ linux/include/asm-nios2nommu/mc146818rtc.h
+@@ -0,0 +1,29 @@
++/*
++ * Machine dependent access functions for RTC registers.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_MC146818RTC_H
++#define _NIOS2_MC146818RTC_H
++
++/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
++
++#endif /* _NIOS2_MC146818RTC_H */
+--- linux/include/asm-nios2nommu/mman.h
++++ linux/include/asm-nios2nommu/mman.h
+@@ -0,0 +1,68 @@
++/*
++ * Copied from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_MMAN_H__
++#define __NIOS2_MMAN_H__
++
++#define PROT_READ 0x1 /* page can be read */
++#define PROT_WRITE 0x2 /* page can be written */
++#define PROT_EXEC 0x4 /* page can be executed */
++#define PROT_SEM 0x8 /* page may be used for atomic ops */
++#define PROT_NONE 0x0 /* page can not be accessed */
++#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
++#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
++
++#define MAP_SHARED 0x01 /* Share changes */
++#define MAP_PRIVATE 0x02 /* Changes are private */
++#define MAP_TYPE 0x0f /* Mask for type of mapping */
++#define MAP_FIXED 0x10 /* Interpret addr exactly */
++#define MAP_ANONYMOUS 0x20 /* don't use a file */
++
++#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
++#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
++#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
++#define MAP_LOCKED 0x2000 /* pages are locked */
++#define MAP_NORESERVE 0x4000 /* don't check for reservations */
++#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
++#define MAP_NONBLOCK 0x10000 /* do not block on IO */
++
++#define MS_ASYNC 1 /* sync memory asynchronously */
++#define MS_INVALIDATE 2 /* invalidate the caches */
++#define MS_SYNC 4 /* synchronous memory sync */
++
++#define MCL_CURRENT 1 /* lock all current mappings */
++#define MCL_FUTURE 2 /* lock all future mappings */
++
++#define MADV_NORMAL 0x0 /* default page-in behavior */
++#define MADV_RANDOM 0x1 /* page-in minimum required */
++#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
++#define MADV_WILLNEED 0x3 /* pre-fault pages */
++#define MADV_DONTNEED 0x4 /* discard these pages */
++
++/* compatibility flags */
++#define MAP_ANON MAP_ANONYMOUS
++#define MAP_FILE 0
++
++#endif /* __NIOS2_MMAN_H__ */
++
+--- linux/include/asm-nios2nommu/mmu.h
++++ linux/include/asm-nios2nommu/mmu.h
+@@ -0,0 +1,47 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_H
++#define __NIOS2NOMMU_MMU_H
++
++/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
++
++struct mm_rblock_struct {
++ int size;
++ int refcount;
++ void *kblock;
++};
++
++struct mm_tblock_struct {
++ struct mm_rblock_struct *rblock;
++ struct mm_tblock_struct *next;
++};
++
++typedef struct {
++ struct mm_tblock_struct tblock;
++ unsigned long end_brk;
++} mm_context_t;
++
++#endif /* __NIOS2NOMMU_MMU_H */
+--- linux/include/asm-nios2nommu/mmu_context.h
++++ linux/include/asm-nios2nommu/mmu_context.h
+@@ -0,0 +1,58 @@
++/*
++ *
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2NOMMU_MMU_CONTEXT_H
++#define __NIOS2NOMMU_MMU_CONTEXT_H
++
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++#include <asm/pgalloc.h>
++
++static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
++{
++}
++
++extern inline int
++init_new_context(struct task_struct *tsk, struct mm_struct *mm)
++{
++ // mm->context = virt_to_phys(mm->pgd);
++ return(0);
++}
++
++#define destroy_context(mm) do { } while(0)
++
++static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
++{
++}
++
++#define deactivate_mm(tsk,mm) do { } while (0)
++
++extern inline void activate_mm(struct mm_struct *prev_mm,
++ struct mm_struct *next_mm)
++{
++}
++
++#endif
+--- linux/include/asm-nios2nommu/module.h
++++ linux/include/asm-nios2nommu/module.h
+@@ -0,0 +1,36 @@
++#ifndef _NIOS2_MODULE_H
++#define _NIOS2_MODULE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/module.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct mod_arch_specific
++{
++};
++
++#define Elf_Shdr Elf32_Shdr
++#define Elf_Sym Elf32_Sym
++#define Elf_Ehdr Elf32_Ehdr
++
++#endif /* _NIOS_MODULE_H */
+--- linux/include/asm-nios2nommu/msgbuf.h
++++ linux/include/asm-nios2nommu/msgbuf.h
+@@ -0,0 +1,56 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_MSGBUF_H
++#define _NIOS2_MSGBUF_H
++
++/*
++ * The msqid64_ds structure for nios2 architecture.
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct msqid64_ds {
++ struct ipc64_perm msg_perm;
++ __kernel_time_t msg_stime; /* last msgsnd time */
++ unsigned long __unused1;
++ __kernel_time_t msg_rtime; /* last msgrcv time */
++ unsigned long __unused2;
++ __kernel_time_t msg_ctime; /* last change time */
++ unsigned long __unused3;
++ unsigned long msg_cbytes; /* current number of bytes on queue */
++ unsigned long msg_qnum; /* number of messages in queue */
++ unsigned long msg_qbytes; /* max number of bytes on queue */
++ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
++ __kernel_pid_t msg_lrpid; /* last receive pid */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++#endif /* _NIOS2_MSGBUF_H */
++
+--- linux/include/asm-nios2nommu/namei.h
++++ linux/include/asm-nios2nommu/namei.h
+@@ -0,0 +1,36 @@
++/*
++ * linux/include/asm-nios/namei.h
++ * Moved from m68k version
++ * Included from linux/fs/namei.c
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef __NIOS2_NAMEI_H
++#define __NIOS2_NAMEI_H
++
++/* This dummy routine maybe changed to something useful
++ * for /usr/gnemul/ emulation stuff.
++ * Look at asm-sparc/namei.h for details.
++ */
++
++#define __emul_prefix() NULL
++
++#endif
+--- linux/include/asm-nios2nommu/ndma.h
++++ linux/include/asm-nios2nommu/ndma.h
+@@ -0,0 +1,64 @@
++#ifndef __NDMA_H__
++ #define __NDMA_H__
++
++ #ifndef __ASSEMBLY__
++
++// DMA Registers
++typedef volatile struct
++{
++ int np_dmastatus; // status register
++ int np_dmareadaddress; // read address
++ int np_dmawriteaddress; // write address
++ int np_dmalength; // length in bytes
++ int np_dmareserved1; // reserved
++ int np_dmareserved2; // reserved
++ int np_dmacontrol; // control register
++ int np_dmareserved3; // control register alternate
++} np_dma;
++
++// DMA Register Bits
++enum
++{
++ np_dmacontrol_byte_bit = 0, // Byte transaction
++ np_dmacontrol_hw_bit = 1, // Half-word transaction
++ np_dmacontrol_word_bit = 2, // Word transaction
++ np_dmacontrol_go_bit = 3, // enable execution
++ np_dmacontrol_i_en_bit = 4, // enable interrupt
++ np_dmacontrol_reen_bit = 5, // Enable read end-of-packet
++ np_dmacontrol_ween_bit = 6, // Enable write end-of-packet
++ np_dmacontrol_leen_bit = 7, // Enable length=0 transaction end
++ np_dmacontrol_rcon_bit = 8, // Read from a fixed address
++ np_dmacontrol_wcon_bit = 9, // Write to a fixed address
++ np_dmacontrol_doubleword_bit = 10, // Double-word transaction
++ np_dmacontrol_quadword_bit = 11, // Quad-word transaction
++
++ np_dmastatus_done_bit = 0, // 1 when done. Status write clears.
++ np_dmastatus_busy_bit = 1, // 1 when busy.
++ np_dmastatus_reop_bit = 2, // read-eop received
++ np_dmastatus_weop_bit = 3, // write-eop received
++ np_dmastatus_len_bit = 4, // requested length transacted
++
++ np_dmacontrol_byte_mask = (1 << 0), // Byte transaction
++ np_dmacontrol_hw_mask = (1 << 1), // Half-word transaction
++ np_dmacontrol_word_mask = (1 << 2), // Word transaction
++ np_dmacontrol_go_mask = (1 << 3), // enable execution
++ np_dmacontrol_i_en_mask = (1 << 4), // enable interrupt
++ np_dmacontrol_reen_mask = (1 << 5), // Enable read end-of-packet
++ np_dmacontrol_ween_mask = (1 << 6), // Enable write end-of-packet
++ np_dmacontrol_leen_mask = (1 << 7), // Enable length=0 transaction end
++ np_dmacontrol_rcon_mask = (1 << 8), // Read from a fixed address
++ np_dmacontrol_wcon_mask = (1 << 9), // Write to a fixed address
++ np_dmacontrol_doubleword_mask = (1 << 10), // Double-word transaction
++ np_dmacontrol_quadword_mask = (1 << 11), // Quad-word transaction
++
++ np_dmastatus_done_mask = (1 << 0), // 1 when done. Status write clears.
++ np_dmastatus_busy_mask = (1 << 1), // 1 when busy.
++ np_dmastatus_reop_mask = (1 << 2), // read-eop received
++ np_dmastatus_weop_mask = (1 << 3), // write-eop received
++ np_dmastatus_len_mask = (1 << 4), // requested length transacted
++};
++
++ #endif /* __ASSEMBLY__ */
++
++#endif
++/* End of File */
+--- linux/include/asm-nios2nommu/nios.h
++++ linux/include/asm-nios2nommu/nios.h
+@@ -0,0 +1,7 @@
++#ifndef __NIOS_H__
++#define __NIOS_H__
++
++#include "nios2_system.h"
++
++#endif
++
+--- linux/include/asm-nios2nommu/page.h
++++ linux/include/asm-nios2nommu/page.h
+@@ -0,0 +1,135 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_PAGE_H
++#define _NIOS2_PAGE_H
++
++/* copied from m68knommu arch */
++// #include <linux/config.h>
++
++/* PAGE_SHIFT determines the page size */
++
++#define PAGE_SHIFT (12)
++#define PAGE_SIZE (1UL << PAGE_SHIFT)
++#define PAGE_MASK (~(PAGE_SIZE-1))
++
++#ifdef __KERNEL__
++
++#include <asm/setup.h>
++
++#if PAGE_SHIFT < 13
++#define THREAD_SIZE (8192)
++#else
++#define THREAD_SIZE PAGE_SIZE
++#endif
++
++#ifndef __ASSEMBLY__
++
++#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
++#define free_user_page(page, addr) free_page(addr)
++
++#define clear_page(page) memset((page), 0, PAGE_SIZE)
++#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
++
++#define clear_user_page(page, vaddr, pg) clear_page(page)
++#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
++
++/*
++ * These are used to make use of C type-checking..
++ */
++typedef struct { unsigned long pte; } pte_t;
++typedef struct { unsigned long pmd[16]; } pmd_t;
++typedef struct { unsigned long pgd; } pgd_t;
++typedef struct { unsigned long pgprot; } pgprot_t;
++
++#define pte_val(x) ((x).pte)
++#define pmd_val(x) ((&x)->pmd[0])
++#define pgd_val(x) ((x).pgd)
++#define pgprot_val(x) ((x).pgprot)
++
++#define __pte(x) ((pte_t) { (x) } )
++#define __pmd(x) ((pmd_t) { (x) } )
++#define __pgd(x) ((pgd_t) { (x) } )
++#define __pgprot(x) ((pgprot_t) { (x) } )
++
++/* to align the pointer to the (next) page boundary */
++#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
++
++/* Pure 2^n version of get_order */
++extern __inline__ int get_order(unsigned long size)
++{
++ int order;
++
++ size = (size-1) >> (PAGE_SHIFT-1);
++ order = -1;
++ do {
++ size >>= 1;
++ order++;
++ } while (size);
++ return order;
++}
++
++extern unsigned long memory_start;
++extern unsigned long memory_end;
++
++#endif /* !__ASSEMBLY__ */
++#include <asm/nios.h>
++#define PAGE_OFFSET ((int)(nasys_program_mem))
++
++#ifndef __ASSEMBLY__
++
++#define __pa(vaddr) virt_to_phys((void *)vaddr)
++#define __va(paddr) phys_to_virt((unsigned long)paddr)
++
++#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
++
++#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
++#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
++
++#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
++#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
++#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
++
++#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
++#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
++
++#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
++ ((void *)(kaddr) < (void *)memory_end))
++
++#ifdef CONFIG_NO_KERNEL_MSG
++#define BUG_PRINT()
++#else
++#define BUG_PRINT() printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__)
++#endif
++
++#ifdef na_cpu_oci_core
++#define BUG_PANIC() asm volatile ("break") /* drop to debugger */
++#else
++// #define BUG_PANIC() while(1)
++#define BUG_PANIC() panic("BUG!")
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_PAGE_H */
+--- linux/include/asm-nios2nommu/param.h
++++ linux/include/asm-nios2nommu/param.h
+@@ -0,0 +1,49 @@
++#ifndef _NIOS_PARAM_H
++#define _NIOS_PARAM_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/param.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifndef HZ
++#define HZ 100
++#endif
++
++#ifdef __KERNEL__
++#define USER_HZ HZ
++#define CLOCKS_PER_SEC (USER_HZ)
++#endif
++
++#define EXEC_PAGESIZE 4096
++
++#ifndef NGROUPS
++#define NGROUPS 32
++#endif
++
++#ifndef NOGROUP
++#define NOGROUP (-1)
++#endif
++
++#define MAXHOSTNAMELEN 64 /* max length of hostname */
++
++#endif
+--- linux/include/asm-nios2nommu/pci.h
++++ linux/include/asm-nios2nommu/pci.h
+@@ -0,0 +1,75 @@
++#ifndef _ASM_NIOS2NOMMU_PCI_H
++#define _ASM_NIOS2NOMMU_PCI_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pci.h
++ *
++ * Derived from asm-m68k/pci_m68k.h
++ * - m68k specific PCI declarations, by Wout Klaren.
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/scatterlist.h>
++
++struct pci_ops;
++
++/*
++ * Structure with hardware dependent information and functions of the
++ * PCI bus.
++ */
++
++struct pci_bus_info
++{
++ /*
++ * Resources of the PCI bus.
++ */
++
++ struct resource mem_space;
++ struct resource io_space;
++
++ /*
++ * System dependent functions.
++ */
++
++ struct pci_ops *m68k_pci_ops;
++
++ void (*fixup)(int pci_modify);
++ void (*conf_device)(struct pci_dev *dev);
++};
++
++#define pcibios_assign_all_busses() 0
++
++extern inline void pcibios_set_master(struct pci_dev *dev)
++{
++ /* No special bus mastering setup handling */
++}
++
++extern inline void pcibios_penalize_isa_irq(int irq)
++{
++ /* We don't do dynamic PCI IRQ allocation */
++}
++
++/* The PCI address space does equal the physical memory
++ * address space. The networking and block device layers use
++ * this boolean for bounce buffer decisions.
++ */
++#define PCI_DMA_BUS_IS_PHYS (1)
++
++#endif /* _ASM_NIOS2NOMMU_PCI_H */
+--- linux/include/asm-nios2nommu/percpu.h
++++ linux/include/asm-nios2nommu/percpu.h
+@@ -0,0 +1,30 @@
++#ifndef __ARCH_NIOS2NOMMU_PERCPU__
++#define __ARCH_NIOS2NOMMU_PERCPU__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/percpu.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/percpu.h>
++
++#endif /* __ARCH_NIOS2NOMMU_PERCPU__ */
+--- linux/include/asm-nios2nommu/pgalloc.h
++++ linux/include/asm-nios2nommu/pgalloc.h
+@@ -0,0 +1,32 @@
++#ifndef _NIOS2NOMMU_PGALLOC_H
++#define _NIOS2NOMMU_PGALLOC_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgalloc.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/setup.h>
++
++#define check_pgt_cache() do { } while (0)
++
++#endif /* _NIOS2NOMMU_PGALLOC_H */
+--- linux/include/asm-nios2nommu/pgtable.h
++++ linux/include/asm-nios2nommu/pgtable.h
+@@ -0,0 +1,100 @@
++#ifndef _NIOS_PGTABLE_H
++#define _NIOS_PGTABLE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/pgtable.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++//vic - this bit copied from m68knommu version
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/io.h>
++
++typedef pte_t *pte_addr_t;
++
++#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
++#define pgd_none(pgd) (0)
++#define pgd_bad(pgd) (0)
++#define pgd_clear(pgdp)
++#define kern_addr_valid(addr) (1)
++#define pmd_offset(a, b) ((void *)0)
++
++#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
++#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
++//vic - this bit copied from m68knommu version
++
++extern void paging_init(void);
++#define swapper_pg_dir ((pgd_t *) 0)
++
++#define __swp_type(x) (0)
++#define __swp_offset(x) (0)
++#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
++#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
++#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
++
++static inline int pte_file(pte_t pte) { return 0; }
++
++/*
++ * ZERO_PAGE is a global shared page that is always zero: used
++ * for zero-mapped memory areas etc..
++ */
++#define ZERO_PAGE(vaddr) (virt_to_page(0))
++
++extern unsigned int kobjsize(const void *objp);
++
++/*
++ * No page table caches to initialise
++ */
++#define pgtable_cache_init() do { } while (0)
++
++extern inline void flush_cache_mm(struct mm_struct *mm)
++{
++}
++
++extern inline void flush_cache_range(struct mm_struct *mm,
++ unsigned long start,
++ unsigned long end)
++{
++}
++
++/* Push the page at kernel virtual address and clear the icache */
++extern inline void flush_page_to_ram (unsigned long address)
++{
++}
++
++/* Push n pages at kernel virtual address and clear the icache */
++extern inline void flush_pages_to_ram (unsigned long address, int n)
++{
++}
++
++/*
++ * All 32bit addresses are effectively valid for vmalloc...
++ * Sort of meaningless for non-VM targets.
++ */
++#define VMALLOC_START 0
++#define VMALLOC_END 0xffffffff
++
++#endif /* _NIOS_PGTABLE_H */
+--- linux/include/asm-nios2nommu/pio_struct.h
++++ linux/include/asm-nios2nommu/pio_struct.h
+@@ -0,0 +1,14 @@
++// PIO Peripheral
++
++// PIO Registers
++typedef volatile struct
++ {
++ int np_piodata; // read/write, up to 32 bits
++ int np_piodirection; // write/readable, up to 32 bits, 1->output bit
++ int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
++ int np_pioedgecapture; // read, up to 32 bits, cleared by any write
++ } np_pio;
++
++// PIO Routines
++void nr_pio_showhex(int value); // shows low byte on pio named na_seven_seg_pio
++
+--- linux/include/asm-nios2nommu/poll.h
++++ linux/include/asm-nios2nommu/poll.h
+@@ -0,0 +1,46 @@
++#ifndef __NIOS2_POLL_H
++#define __NIOS2_POLL_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/poll.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define POLLIN 1
++#define POLLPRI 2
++#define POLLOUT 4
++#define POLLERR 8
++#define POLLHUP 16
++#define POLLNVAL 32
++#define POLLRDNORM 64
++#define POLLWRNORM POLLOUT
++#define POLLRDBAND 128
++#define POLLWRBAND 256
++#define POLLMSG 0x0400
++
++struct pollfd {
++ int fd;
++ short events;
++ short revents;
++};
++
++#endif
+--- linux/include/asm-nios2nommu/posix_types.h
++++ linux/include/asm-nios2nommu/posix_types.h
+@@ -0,0 +1,89 @@
++#ifndef __ARCH_NIOS2_POSIX_TYPES_H
++#define __ARCH_NIOS2_POSIX_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/posix_types.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is generally used by user-level software, so you need to
++ * be a little careful about namespace pollution etc. Also, we cannot
++ * assume GCC is being used.
++ */
++
++typedef unsigned long __kernel_ino_t;
++typedef unsigned short __kernel_mode_t;
++typedef unsigned short __kernel_nlink_t;
++typedef long __kernel_off_t;
++typedef int __kernel_pid_t;
++typedef unsigned short __kernel_ipc_pid_t;
++typedef unsigned short __kernel_uid_t;
++typedef unsigned short __kernel_gid_t;
++typedef unsigned int __kernel_size_t;
++typedef int __kernel_ssize_t;
++typedef int __kernel_ptrdiff_t;
++typedef long __kernel_time_t;
++typedef long __kernel_suseconds_t;
++typedef long __kernel_clock_t;
++typedef int __kernel_timer_t;
++typedef int __kernel_clockid_t;
++typedef int __kernel_daddr_t;
++typedef char * __kernel_caddr_t;
++typedef unsigned short __kernel_uid16_t;
++typedef unsigned short __kernel_gid16_t;
++typedef unsigned int __kernel_uid32_t;
++typedef unsigned int __kernel_gid32_t;
++
++typedef unsigned short __kernel_old_uid_t;
++typedef unsigned short __kernel_old_gid_t;
++typedef unsigned short __kernel_old_dev_t;
++
++#ifdef __GNUC__
++typedef long long __kernel_loff_t;
++#endif
++
++typedef struct {
++#if defined(__KERNEL__) || defined(__USE_ALL)
++ int val[2];
++#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++ int __val[2];
++#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
++} __kernel_fsid_t;
++
++#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
++
++#undef __FD_SET
++#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
++
++#undef __FD_CLR
++#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
++
++#undef __FD_ISSET
++#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
++
++#undef __FD_ZERO
++#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
++
++#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
++
++#endif
+--- linux/include/asm-nios2nommu/preem_latency.h
++++ linux/include/asm-nios2nommu/preem_latency.h
+@@ -0,0 +1,39 @@
++#ifndef _ASM_PREEM_LATENCY_H
++#define _ASM_PREEM_LATENCY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/preem_latency.h
++ *
++ * timing support for preempt-stats patch
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++#define readclock(low) \
++do {\
++ *(volatile unsigned long *)na_Counter_64_bit=1; \
++ low=*(volatile unsigned long *)na_Counter_64_bit; \
++} while (0)
++#define readclock_init()
++
++#endif /* _ASM_PREEM_LATENCY_H */
+--- linux/include/asm-nios2nommu/processor.h
++++ linux/include/asm-nios2nommu/processor.h
+@@ -0,0 +1,148 @@
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/processor.h
++ *
++ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
++ * Vic Phillips (vic@microtronix.com)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * hacked from:
++ * include/asm-sparc/processor.h
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ * Nov/02/2003 dgt Fix task_size
++ *
++ ---------------------------------------------------------------------*/
++
++#ifndef __ASM_NIOS_PROCESSOR_H
++#define __ASM_NIOS_PROCESSOR_H
++
++#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
++#define NIOS2_FLAG_COPROC 0x00000002 /* Thread used coprocess */
++#define NIOS2_FLAG_DEBUG 0x00000004 /* task is being debugged */
++
++#define NIOS2_OP_NOP 0x1883a
++#define NIOS2_OP_BREAK 0x3da03a
++
++#ifndef __ASSEMBLY__
++
++/*
++ * Default implementation of macro that returns current
++ * instruction pointer ("program counter").
++ */
++#define current_text_addr() ({ __label__ _l; _l: &&_l;})
++
++#include <linux/a.out.h>
++#include <linux/string.h>
++
++#include <asm/ptrace.h>
++#include <asm/signal.h>
++#include <asm/segment.h>
++#include <asm/current.h>
++#include <asm/system.h> /* for get_hi_limit */
++
++/*
++ * Bus types
++ */
++#define EISA_bus 0
++#define EISA_bus__is_a_macro /* for versions in ksyms.c */
++#define MCA_bus 0
++#define MCA_bus__is_a_macro /* for versions in ksyms.c */
++
++/*
++ * The nios has no problems with write protection
++ */
++#define wp_works_ok 1
++#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
++
++/* Whee, this is STACK_TOP and the lowest kernel address too... */
++#if 0
++#define KERNBASE 0x00000000 /* First address the kernel will eventually be */
++#define TASK_SIZE (KERNBASE)
++#define MAX_USER_ADDR TASK_SIZE
++#define MMAP_SEARCH_START (TASK_SIZE/3)
++#endif
++
++#define TASK_SIZE ((unsigned int) nasys_program_mem_end) //...this is better...
++
++/*
++ * This decides where the kernel will search for a free chunk of vm
++ * space during mmap's. We won't be using it
++ */
++#define TASK_UNMAPPED_BASE 0
++
++/* The Nios processor specific thread struct. */
++struct thread_struct {
++ struct pt_regs *kregs;
++
++ /* For signal handling */
++ unsigned long sig_address;
++ unsigned long sig_desc;
++
++ /* Context switch saved kernel state. */
++ unsigned long ksp;
++ unsigned long kpsr;
++ unsigned long kesr;
++
++ /* Flags are defined below */
++
++ unsigned long flags;
++ int current_ds;
++ struct exec core_exec; /* just what it says. */
++};
++
++#define INIT_MMAP { &init_mm, (0), (0), \
++ __pgprot(0x0) , VM_READ | VM_WRITE | VM_EXEC }
++
++#define INIT_THREAD { \
++ .kregs = 0, \
++ .sig_address = 0, \
++ .sig_desc = 0, \
++ .ksp = 0, \
++ .kpsr = 0, \
++ .kesr = PS_S, \
++ .flags = NIOS2_FLAG_KTHREAD, \
++ .current_ds = __KERNEL_DS, \
++ .core_exec = INIT_EXEC \
++}
++
++/* Free all resources held by a thread. */
++extern void release_thread(struct task_struct *);
++
++extern unsigned long thread_saved_pc(struct task_struct *t);
++
++extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
++
++/* Prepare to copy thread state - unlazy all lazy status */
++#define prepare_to_copy(tsk) do { } while (0)
++
++extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
++
++unsigned long get_wchan(struct task_struct *p);
++
++#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
++#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
++
++#ifdef __KERNEL__
++/* Allocation and freeing of basic task resources. */
++
++//;dgt2;#define alloc_task_struct() ((struct task_struct *) xx..see..linux..fork..xx __get_free_pages(GFP_KERNEL,1))
++//;dgt2;#define get_task_struct(tsk) xx..see..linux..sched.h...atomic_inc(&mem_map[MAP_NR(tsk)].count)
++
++#endif
++
++#define cpu_relax() do { } while (0)
++#endif /* __ASSEMBLY__ */
++#endif /* __ASM_NIOS_PROCESSOR_H */
+--- linux/include/asm-nios2nommu/ptrace.h
++++ linux/include/asm-nios2nommu/ptrace.h
+@@ -0,0 +1,141 @@
++/*
++ * Taken from the m68k port.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2NOMMU_PTRACE_H
++#define _NIOS2NOMMU_PTRACE_H
++
++#ifndef __ASSEMBLY__
++
++#define PTR_R0 0
++#define PTR_R1 1
++#define PTR_R2 2
++#define PTR_R3 3
++#define PTR_R4 4
++#define PTR_R5 5
++#define PTR_R6 6
++#define PTR_R7 7
++#define PTR_R8 8
++#define PTR_R9 9
++#define PTR_R10 10
++#define PTR_R11 11
++#define PTR_R12 12
++#define PTR_R13 13
++#define PTR_R14 14
++#define PTR_R15 15
++#define PTR_R16 16
++#define PTR_R17 17
++#define PTR_R18 18
++#define PTR_R19 19
++#define PTR_R20 20
++#define PTR_R21 21
++#define PTR_R22 22
++#define PTR_R23 23
++#define PTR_R24 24
++#define PTR_R25 25
++#define PTR_GP 26
++#define PTR_SP 27
++#define PTR_FP 28
++#define PTR_EA 29
++#define PTR_BA 30
++#define PTR_RA 31
++#define PTR_STATUS 32
++#define PTR_ESTATUS 33
++#define PTR_BSTATUS 34
++#define PTR_IENABLE 35
++#define PTR_IPENDING 36
++
++/* this struct defines the way the registers are stored on the
++ stack during a system call.
++
++ There is a fake_regs in setup.c that has to match pt_regs.*/
++
++struct pt_regs {
++ unsigned long r8;
++ unsigned long r9;
++ unsigned long r10;
++ unsigned long r11;
++ unsigned long r12;
++ unsigned long r13;
++ unsigned long r14;
++ unsigned long r15;
++ unsigned long r1;
++ unsigned long r2;
++ unsigned long r3;
++ unsigned long r4;
++ unsigned long r5;
++ unsigned long r6;
++ unsigned long r7;
++ unsigned long orig_r2;
++ unsigned long ra;
++ unsigned long fp;
++ unsigned long sp;
++ unsigned long gp;
++ unsigned long estatus;
++ unsigned long status_extension;
++ unsigned long ea;
++};
++
++
++/*
++ * This is the extended stack used by signal handlers and the context
++ * switcher: it's pushed after the normal "struct pt_regs".
++ */
++struct switch_stack {
++ unsigned long r16;
++ unsigned long r17;
++ unsigned long r18;
++ unsigned long r19;
++ unsigned long r20;
++ unsigned long r21;
++ unsigned long r22;
++ unsigned long r23;
++ unsigned long fp;
++ unsigned long gp;
++ unsigned long ra;
++};
++
++/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
++#define PTRACE_GETREGS 12
++#define PTRACE_SETREGS 13
++#ifdef CONFIG_FPU
++#define PTRACE_GETFPREGS 14
++#define PTRACE_SETFPREGS 15
++#endif
++
++#ifdef __KERNEL__
++
++#ifndef PS_S
++#define PS_S (0x00000001)
++#endif
++#ifndef PS_T
++#define PS_T (0x00000002)
++#endif
++
++#define user_mode(regs) (!((regs)->status_extension & PS_S))
++#define instruction_pointer(regs) ((regs)->ra)
++#define profile_pc(regs) instruction_pointer(regs)
++extern void show_regs(struct pt_regs *);
++
++#endif /* __KERNEL__ */
++#endif /* __ASSEMBLY__ */
++#endif /* _NIOS2NOMMU_PTRACE_H */
+--- linux/include/asm-nios2nommu/resource.h
++++ linux/include/asm-nios2nommu/resource.h
+@@ -0,0 +1,73 @@
++#ifndef _NIOS2NOMMU_RESOURCE_H
++#define _NIOS2NOMMU_RESOURCE_H
++
++/*--------------------------------------------------------------------
++ *
++ * Resource limits
++ *
++ * include/asm-nios2nommu/resource.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define RLIMIT_CPU 0 /* CPU time in ms */
++#define RLIMIT_FSIZE 1 /* Maximum filesize */
++#define RLIMIT_DATA 2 /* max data size */
++#define RLIMIT_STACK 3 /* max stack size */
++#define RLIMIT_CORE 4 /* max core file size */
++#define RLIMIT_RSS 5 /* max resident set size */
++#define RLIMIT_NPROC 6 /* max number of processes */
++#define RLIMIT_NOFILE 7 /* max number of open files */
++#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
++#define RLIMIT_AS 9 /* address space limit */
++#define RLIMIT_LOCKS 10 /* maximum file locks held */
++#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
++#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
++
++#define RLIM_NLIMITS 13
++
++/*
++ * SuS says limits have to be unsigned.
++ * Which makes a ton more sense anyway.
++ */
++#define RLIM_INFINITY (~0UL)
++
++#ifdef __KERNEL__
++
++#define INIT_RLIMITS \
++{ \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { _STK_LIM, RLIM_INFINITY }, \
++ { 0, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { 0, 0 }, \
++ { INR_OPEN, INR_OPEN }, \
++ { MLOCK_LIMIT, MLOCK_LIMIT }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { RLIM_INFINITY, RLIM_INFINITY }, \
++ { MAX_SIGPENDING, MAX_SIGPENDING }, \
++ { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
++}
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2NOMMU_RESOURCE_H */
+--- linux/include/asm-nios2nommu/rmap.h
++++ linux/include/asm-nios2nommu/rmap.h
+@@ -0,0 +1,2 @@
++/* Do not need anything here */
++
+--- linux/include/asm-nios2nommu/scatterlist.h
++++ linux/include/asm-nios2nommu/scatterlist.h
+@@ -0,0 +1,40 @@
++#ifndef _NIOS2NOMMU_SCATTERLIST_H
++#define _NIOS2NOMMU_SCATTERLIST_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/scatterlist.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct scatterlist {
++ struct page *page;
++ unsigned int offset;
++ dma_addr_t dma_address;
++ unsigned int length;
++};
++
++#define sg_dma_address(sg) ((sg)->dma_address)
++#define sg_dma_len(sg) ((sg)->length)
++
++#define ISA_DMA_THRESHOLD (0xffffffff)
++
++#endif /* !(_NIOS2NOMMU_SCATTERLIST_H) */
+--- linux/include/asm-nios2nommu/sections.h
++++ linux/include/asm-nios2nommu/sections.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_SECTIONS_H
++#define _NIOS2NOMMU_SECTIONS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sections.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/sections.h>
++
++#endif /* _NIOS2NOMMU_SECTIONS_H */
+--- linux/include/asm-nios2nommu/segment.h
++++ linux/include/asm-nios2nommu/segment.h
+@@ -0,0 +1,75 @@
++#ifndef _NIOS2NOMMU_SEGMENT_H
++#define _NIOS2NOMMU_SEGMENT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/segment.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* define constants */
++/* Address spaces (FC0-FC2) */
++#define USER_DATA (1)
++#ifndef __USER_DS
++#define __USER_DS (USER_DATA)
++#endif
++#define USER_PROGRAM (2)
++#define SUPER_DATA (5)
++#ifndef __KERNEL_DS
++#define __KERNEL_DS (SUPER_DATA)
++#endif
++#define SUPER_PROGRAM (6)
++#define CPU_SPACE (7)
++
++#ifndef __ASSEMBLY__
++
++typedef struct {
++ unsigned long seg;
++} mm_segment_t;
++
++#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
++#define USER_DS MAKE_MM_SEG(__USER_DS)
++#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
++
++/*
++ * Get/set the SFC/DFC registers for MOVES instructions
++ */
++
++static inline mm_segment_t get_fs(void)
++{
++ return USER_DS;
++}
++
++static inline mm_segment_t get_ds(void)
++{
++ /* return the supervisor data space code */
++ return KERNEL_DS;
++}
++
++static inline void set_fs(mm_segment_t val)
++{
++}
++
++#define segment_eq(a,b) ((a).seg == (b).seg)
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* _NIOS2NOMMU_SEGMENT_H */
+--- linux/include/asm-nios2nommu/semaphore-helper.h
++++ linux/include/asm-nios2nommu/semaphore-helper.h
+@@ -0,0 +1,101 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_HELPER_H
++#define _NIOS2NOMMU_SEMAPHORE_HELPER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * SMP- and interrupt-safe semaphores helper functions.
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++// #include <linux/config.h>
++
++/*
++ * These two _must_ execute atomically wrt each other.
++ */
++static inline void wake_one_more(struct semaphore * sem)
++{
++ atomic_inc(&sem->waking);
++}
++
++static inline int waking_non_zero(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_interruptible:
++ * 1 got the lock
++ * 0 go to sleep
++ * -EINTR interrupted
++ */
++static inline int waking_non_zero_interruptible(struct semaphore *sem,
++ struct task_struct *tsk)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 0;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 1;
++ } else if (signal_pending(tsk)) {
++ atomic_inc(&sem->count);
++ ret = -EINTR;
++ }
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++/*
++ * waking_non_zero_trylock:
++ * 1 failed to lock
++ * 0 got the lock
++ */
++static inline int waking_non_zero_trylock(struct semaphore *sem)
++{
++ int ret;
++ unsigned long flags;
++
++ spin_lock_irqsave(&semaphore_wake_lock, flags);
++ ret = 1;
++ if (atomic_read(&sem->waking) > 0) {
++ atomic_dec(&sem->waking);
++ ret = 0;
++ } else
++ atomic_inc(&sem->count);
++ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
++ return ret;
++}
++
++#endif
+--- linux/include/asm-nios2nommu/semaphore.h
++++ linux/include/asm-nios2nommu/semaphore.h
+@@ -0,0 +1,155 @@
++#ifndef _NIOS2NOMMU_SEMAPHORE_H
++#define _NIOS2NOMMU_SEMAPHORE_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/semaphore.h
++ *
++ * Interrupt-safe semaphores..
++ *
++ * Derived from M68knommu
++ *
++ * (C) Copyright 1996 Linus Torvalds
++ * m68k version by Andreas Schwab
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define RW_LOCK_BIAS 0x01000000
++
++#ifndef __ASSEMBLY__
++
++#include <linux/linkage.h>
++#include <linux/wait.h>
++#include <linux/spinlock.h>
++#include <linux/rwsem.h>
++
++#include <asm/system.h>
++#include <asm/atomic.h>
++
++struct semaphore {
++ atomic_t count;
++ atomic_t waking;
++ wait_queue_head_t wait;
++};
++
++#define __SEMAPHORE_INITIALIZER(name, n) \
++{ \
++ .count = ATOMIC_INIT(n), \
++ .waking = ATOMIC_INIT(0), \
++ .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
++}
++
++#define __MUTEX_INITIALIZER(name) \
++ __SEMAPHORE_INITIALIZER(name,1)
++
++#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
++ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
++
++#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
++#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
++
++extern inline void sema_init (struct semaphore *sem, int val)
++{
++ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
++}
++
++static inline void init_MUTEX (struct semaphore *sem)
++{
++ sema_init(sem, 1);
++}
++
++static inline void init_MUTEX_LOCKED (struct semaphore *sem)
++{
++ sema_init(sem, 0);
++}
++
++asmlinkage void __down(struct semaphore * sem);
++asmlinkage int __down_interruptible(struct semaphore * sem);
++asmlinkage int __down_trylock(struct semaphore * sem);
++asmlinkage void __up(struct semaphore * sem);
++
++asmlinkage void __down_failed(void /* special register calling convention */);
++asmlinkage int __down_failed_interruptible(void /* params in registers */);
++asmlinkage int __down_failed_trylock(void /* params in registers */);
++asmlinkage void __up_wakeup(void /* special register calling convention */);
++
++extern spinlock_t semaphore_wake_lock;
++
++/*
++ * This is ugly, but we want the default case to fall through.
++ * "down_failed" is a special asm handler that calls the C
++ * routine that actually waits.
++ */
++extern inline void down(struct semaphore * sem)
++{
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if (atomic_dec_return(&sem->count) < 0)
++ __down(sem);
++ #endif
++}
++
++extern inline int down_interruptible(struct semaphore * sem)
++{
++ int ret = 0;
++
++
++ might_sleep();
++
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ if(atomic_dec_return(&sem->count) < 0)
++ ret = __down_interruptible(sem);
++ return ret;
++ #endif
++}
++
++extern inline int down_trylock(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "decrement memory"....
++ #else
++ int ret = 0;
++
++ if (atomic_dec_return (&sem->count) < 0)
++ ret = __down_trylock(sem);
++ return ret;
++ #endif
++}
++
++/*
++ * Note! This is subtle. We jump to wake people up only if
++ * the semaphore was negative (== somebody was waiting on it).
++ * The default case (no contention) will result in NO
++ * jumps for both down() and up().
++ */
++extern inline void up(struct semaphore * sem)
++{
++ #if 0
++ ...Nios2 has no atomic "increment memory"....
++ #else
++ if (atomic_inc_return(&sem->count) <= 0)
++ __up(sem);
++ #endif
++}
++
++#endif /* __ASSEMBLY__ */
++
++#endif
+--- linux/include/asm-nios2nommu/sembuf.h
++++ linux/include/asm-nios2nommu/sembuf.h
+@@ -0,0 +1,48 @@
++#ifndef _NIOS_SEMBUF_H
++#define _NIOS_SEMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sembuf.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct semid64_ds {
++ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
++ __kernel_time_t sem_otime; /* last semop time */
++ unsigned long __unused1;
++ __kernel_time_t sem_ctime; /* last change time */
++ unsigned long __unused2;
++ unsigned long sem_nsems; /* no. of semaphores in array */
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SEMBUF_H */
+--- linux/include/asm-nios2nommu/setup.h
++++ linux/include/asm-nios2nommu/setup.h
+@@ -0,0 +1,31 @@
++/* Copied from i386 port.
++ * Just a place holder. We don't want to have to test x86 before
++ * we include stuff
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SETUP_H
++#define _NIOS2_SETUP_H
++
++#define COMMAND_LINE_SIZE 512
++
++#endif /* _NIOS2_SETUP_H */
+--- linux/include/asm-nios2nommu/shmbuf.h
++++ linux/include/asm-nios2nommu/shmbuf.h
+@@ -0,0 +1,64 @@
++#ifndef _NIOS_SHMBUF_H
++#define _NIOS_SHMBUF_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmbuf.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/* Note extra padding because this structure is passed back and forth
++ * between kernel and user space.
++ *
++ * Pad space is left for:
++ * - 64-bit time_t to solve y2038 problem
++ * - 2 miscellaneous 32-bit values
++ */
++
++struct shmid64_ds {
++ struct ipc64_perm shm_perm; /* operation perms */
++ size_t shm_segsz; /* size of segment (bytes) */
++ __kernel_time_t shm_atime; /* last attach time */
++ unsigned long __unused1;
++ __kernel_time_t shm_dtime; /* last detach time */
++ unsigned long __unused2;
++ __kernel_time_t shm_ctime; /* last change time */
++ unsigned long __unused3;
++ __kernel_pid_t shm_cpid; /* pid of creator */
++ __kernel_pid_t shm_lpid; /* pid of last operator */
++ unsigned long shm_nattch; /* no. of current attaches */
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++struct shminfo64 {
++ unsigned long shmmax;
++ unsigned long shmmin;
++ unsigned long shmmni;
++ unsigned long shmseg;
++ unsigned long shmall;
++ unsigned long __unused1;
++ unsigned long __unused2;
++ unsigned long __unused3;
++ unsigned long __unused4;
++};
++
++#endif /* _NIOS_SHMBUF_H */
+--- linux/include/asm-nios2nommu/shmparam.h
++++ linux/include/asm-nios2nommu/shmparam.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS2NOMMU_SHMPARAM_H__
++#define __NIOS2NOMMU_SHMPARAM_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/shmparam.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
++
++#endif /* __NIOS2NOMMU_SHMPARAM_H__ */
+--- linux/include/asm-nios2nommu/sigcontext.h
++++ linux/include/asm-nios2nommu/sigcontext.h
+@@ -0,0 +1,35 @@
++/*
++ * Taken from the m68knommu.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_NIOS2NOMMU_SIGCONTEXT_H
++#define _ASM_NIOS2NOMMU_SIGCONTEXT_H
++
++#include <asm/ptrace.h>
++
++struct sigcontext {
++ struct pt_regs regs;
++ unsigned long sc_mask; /* old sigmask */
++};
++
++#endif
+--- linux/include/asm-nios2nommu/siginfo.h
++++ linux/include/asm-nios2nommu/siginfo.h
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SIGINFO_H
++#define _NIOS2NOMMU_SIGINFO_H
++
++#include <asm-generic/siginfo.h>
++
++#endif
+--- linux/include/asm-nios2nommu/signal.h
++++ linux/include/asm-nios2nommu/signal.h
+@@ -0,0 +1,207 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2_SIGNAL_H
++#define _NIOS2_SIGNAL_H
++
++#include <linux/types.h>
++
++/* Avoid too many header ordering problems. */
++struct siginfo;
++
++#ifdef __KERNEL__
++/* Most things should be clean enough to redefine this at will, if care
++ is taken to make libc match. */
++
++#define _NSIG 64
++#define _NSIG_BPW 32
++#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
++
++typedef unsigned long old_sigset_t; /* at least 32 bits */
++
++typedef struct {
++ unsigned long sig[_NSIG_WORDS];
++} sigset_t;
++
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++#define NSIG 32
++typedef unsigned long sigset_t;
++
++#endif /* __KERNEL__ */
++
++#define SIGHUP 1
++#define SIGINT 2
++#define SIGQUIT 3
++#define SIGILL 4
++#define SIGTRAP 5
++#define SIGABRT 6
++#define SIGIOT 6
++#define SIGBUS 7
++#define SIGFPE 8
++#define SIGKILL 9
++#define SIGUSR1 10
++#define SIGSEGV 11
++#define SIGUSR2 12
++#define SIGPIPE 13
++#define SIGALRM 14
++#define SIGTERM 15
++#define SIGSTKFLT 16
++#define SIGCHLD 17
++#define SIGCONT 18
++#define SIGSTOP 19
++#define SIGTSTP 20
++#define SIGTTIN 21
++#define SIGTTOU 22
++#define SIGURG 23
++#define SIGXCPU 24
++#define SIGXFSZ 25
++#define SIGVTALRM 26
++#define SIGPROF 27
++#define SIGWINCH 28
++#define SIGIO 29
++#define SIGPOLL SIGIO
++/*
++#define SIGLOST 29
++*/
++#define SIGPWR 30
++#define SIGSYS 31
++#define SIGUNUSED 31
++
++/* These should not be considered constants from userland. */
++#define SIGRTMIN 32
++#define SIGRTMAX _NSIG-1
++
++/*
++ * SA_FLAGS values:
++ *
++ * SA_ONSTACK indicates that a registered stack_t will be used.
++ * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
++ * SA_RESTART flag to get restarting signals (which were the default long ago)
++ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
++ * SA_RESETHAND clears the handler when the signal is delivered.
++ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
++ * SA_NODEFER prevents the current signal from being masked in the handler.
++ *
++ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
++ * Unix names RESETHAND and NODEFER respectively.
++ */
++#define SA_NOCLDSTOP 0x00000001
++#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
++#define SA_SIGINFO 0x00000004
++#define SA_ONSTACK 0x08000000
++#define SA_RESTART 0x10000000
++#define SA_NODEFER 0x40000000
++#define SA_RESETHAND 0x80000000
++
++#define SA_NOMASK SA_NODEFER
++#define SA_ONESHOT SA_RESETHAND
++#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
++
++#define SA_RESTORER 0x04000000
++
++/*
++ * sigaltstack controls
++ */
++#define SS_ONSTACK 1
++#define SS_DISABLE 2
++
++#define MINSIGSTKSZ 2048
++#define SIGSTKSZ 8192
++
++#ifdef __KERNEL__
++/*
++ * These values of sa_flags are used only by the kernel as part of the
++ * irq handling routines.
++ *
++ * SA_INTERRUPT is also used by the irq handling routines.
++ * SA_SHIRQ is for shared interrupt support on PCI and EISA.
++ */
++#define SA_PROBE SA_ONESHOT
++#define SA_SAMPLE_RANDOM SA_RESTART
++#define SA_SHIRQ 0x04000000
++#endif
++
++#define SIG_BLOCK 0 /* for blocking signals */
++#define SIG_UNBLOCK 1 /* for unblocking signals */
++#define SIG_SETMASK 2 /* for setting the signal mask */
++
++/* Type of a signal handler. */
++typedef void (*__sighandler_t)(int);
++
++#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
++#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
++#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
++
++#ifdef __KERNEL__
++struct old_sigaction {
++ __sighandler_t sa_handler;
++ old_sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++struct sigaction {
++ __sighandler_t sa_handler;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++ sigset_t sa_mask; /* mask last for extensibility */
++};
++
++struct k_sigaction {
++ struct sigaction sa;
++};
++#else
++/* Here we must cater to libcs that poke about in kernel headers. */
++
++struct sigaction {
++ union {
++ __sighandler_t _sa_handler;
++ void (*_sa_sigaction)(int, struct siginfo *, void *);
++ } _u;
++ sigset_t sa_mask;
++ unsigned long sa_flags;
++ void (*sa_restorer)(void);
++};
++
++#define sa_handler _u._sa_handler
++#define sa_sigaction _u._sa_sigaction
++
++#endif /* __KERNEL__ */
++
++typedef struct sigaltstack {
++ void *ss_sp;
++ int ss_flags;
++ size_t ss_size;
++} stack_t;
++
++#ifdef __KERNEL__
++
++#include <asm/sigcontext.h>
++#undef __HAVE_ARCH_SIG_BITOPS
++
++#define ptrace_signal_deliver(regs, cookie) do { } while (0)
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS2_SIGNAL_H */
+--- linux/include/asm-nios2nommu/smp.h
++++ linux/include/asm-nios2nommu/smp.h
+@@ -0,0 +1,34 @@
++#ifndef __ASM_SMP_H
++#define __ASM_SMP_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/smp.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++// #include <linux/config.h>
++
++#ifdef CONFIG_SMP
++#error SMP not supported
++#endif
++
++#endif
+--- linux/include/asm-nios2nommu/socket.h
++++ linux/include/asm-nios2nommu/socket.h
+@@ -0,0 +1,74 @@
++#ifndef _ASM_SOCKET_H
++#define _ASM_SOCKET_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/socket.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/sockios.h>
++
++/* For setsockopt(2) */
++#define SOL_SOCKET 1
++
++#define SO_DEBUG 1
++#define SO_REUSEADDR 2
++#define SO_TYPE 3
++#define SO_ERROR 4
++#define SO_DONTROUTE 5
++#define SO_BROADCAST 6
++#define SO_SNDBUF 7
++#define SO_RCVBUF 8
++#define SO_KEEPALIVE 9
++#define SO_OOBINLINE 10
++#define SO_NO_CHECK 11
++#define SO_PRIORITY 12
++#define SO_LINGER 13
++#define SO_BSDCOMPAT 14
++/* To add :#define SO_REUSEPORT 15 */
++#define SO_PASSCRED 16
++#define SO_PEERCRED 17
++#define SO_RCVLOWAT 18
++#define SO_SNDLOWAT 19
++#define SO_RCVTIMEO 20
++#define SO_SNDTIMEO 21
++
++/* Security levels - as per NRL IPv6 - don't actually do anything */
++#define SO_SECURITY_AUTHENTICATION 22
++#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
++#define SO_SECURITY_ENCRYPTION_NETWORK 24
++
++#define SO_BINDTODEVICE 25
++
++/* Socket filtering */
++#define SO_ATTACH_FILTER 26
++#define SO_DETACH_FILTER 27
++
++#define SO_PEERNAME 28
++#define SO_TIMESTAMP 29
++#define SCM_TIMESTAMP SO_TIMESTAMP
++
++#define SO_ACCEPTCONN 30
++
++#define SO_PEERSEC 31 /* ;dgt2;tmp; */
++
++#endif /* _ASM_SOCKET_H */
+--- linux/include/asm-nios2nommu/sockios.h
++++ linux/include/asm-nios2nommu/sockios.h
+@@ -0,0 +1,38 @@
++#ifndef _ASM_NIOS_SOCKIOS_H
++#define _ASM_NIOS_SOCKIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/sockios.h
++ *
++ * Socket-level I/O control calls.
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#define FIOSETOWN 0x8901
++#define SIOCSPGRP 0x8902
++#define FIOGETOWN 0x8903
++#define SIOCGPGRP 0x8904
++#define SIOCATMARK 0x8905
++#define SIOCGSTAMP 0x8906 /* Get stamp */
++
++#endif /* !(_ASM_NIOS_SOCKIOS_H) */
++
+--- linux/include/asm-nios2nommu/spi.h
++++ linux/include/asm-nios2nommu/spi.h
+@@ -0,0 +1,92 @@
++#ifndef _ASM_SPI_H_
++#define _ASM_SPI_H_ 1
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spi.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++int register_NIOS_SPI( void );
++void unregister_NIOS_SPI( void );
++
++#if defined(MODULE)
++void cleanup_module( void );
++int init_module( void );
++#endif
++
++#if defined(__KERNEL__)
++int spi_reset ( void );
++#endif
++
++
++#define clockCS 0x01
++#define temperatureCS 0x02
++
++#define clock_read_base 0x00
++#define clock_write_base 0x80
++#define clock_read_control 0x0F
++#define clock_read_trickle 0x11
++
++#define clock_read_sec 0x00
++#define clock_read_min 0x01
++#define clock_read_hour 0x02
++#define clock_read_day 0x03
++#define clock_read_date 0x04
++#define clock_read_month 0x05
++#define clock_read_year 0x06
++
++#define clock_write_control 0x8F
++#define clock_write_trickle 0x91
++#define clock_write_sec 0x80
++#define clock_write_min 0x81
++#define clock_write_hour 0x82
++#define clock_write_day 0x83
++#define clock_write_date 0x84
++#define clock_write_month 0x85
++#define clock_write_year 0x86
++
++#define clock_write_ram_start 0xA0
++#define clock_write_ram_end 0x100
++#define clock_read_ram_start 0x20
++#define clock_read_ram_end 0x80
++
++
++#define clock_sec_def 0x11
++#define clock_min_def 0x59
++#define clock_hour_def 0x71
++#define clock_day_def 0x00
++#define clock_date_def 0x20
++#define clock_month_def 0x12
++#define clock_year_def 0x34
++
++#define temp_read_base 0x00
++#define temp_write_base 0x80
++#define temp_read_control 0x00
++#define temp_write_control 0x80
++#define temp_read_msb 0x02
++#define temp_read_lsb 0x01
++
++#define MAX_TEMP_VAR 10
++
++#endif /*_ASM_SPI_H_*/
+--- linux/include/asm-nios2nommu/spinlock.h
++++ linux/include/asm-nios2nommu/spinlock.h
+@@ -0,0 +1,30 @@
++#ifndef __NIOS_SPINLOCK_H
++#define __NIOS_SPINLOCK_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/spinlock.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#error "Nios doesn't do SMP yet"
++
++#endif
+--- linux/include/asm-nios2nommu/stat.h
++++ linux/include/asm-nios2nommu/stat.h
+@@ -0,0 +1,102 @@
++#ifndef _ASMNIOS2NOMMU_STAT_H
++#define _ASMNIOS2NOMMU_STAT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/stat.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++struct __old_kernel_stat {
++ unsigned short st_dev;
++ unsigned short st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned long st_size;
++ unsigned long st_atime;
++ unsigned long st_mtime;
++ unsigned long st_ctime;
++};
++
++struct stat {
++ unsigned short st_dev;
++ unsigned short __pad1;
++ unsigned long st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned short st_rdev;
++ unsigned short __pad2;
++ unsigned long st_size;
++ unsigned long st_blksize;
++ unsigned long st_blocks;
++ unsigned long st_atime;
++ unsigned long __unused1;
++ unsigned long st_mtime;
++ unsigned long __unused2;
++ unsigned long st_ctime;
++ unsigned long __unused3;
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++/* This matches struct stat64 in glibc2.1, hence the absolutely
++ * insane amounts of padding around dev_t's.
++ */
++struct stat64 {
++ unsigned long long st_dev;
++ unsigned char __pad1[4];
++
++#define STAT64_HAS_BROKEN_ST_INO 1
++ unsigned long __st_ino;
++
++ unsigned int st_mode;
++ unsigned int st_nlink;
++
++ unsigned long st_uid;
++ unsigned long st_gid;
++
++ unsigned long long st_rdev;
++ unsigned char __pad3[4];
++
++ long long st_size;
++ unsigned long st_blksize;
++
++ unsigned long __pad4; /* future possible st_blocks high bits */
++ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
++
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++
++ unsigned long long st_ino;
++};
++
++#endif
+--- linux/include/asm-nios2nommu/statfs.h
++++ linux/include/asm-nios2nommu/statfs.h
+@@ -0,0 +1,30 @@
++#ifndef _NIOS2NOMMU_STATFS_H
++#define _NIOS2NOMMU_STATFS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/statfs.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/statfs.h>
++
++#endif /* _NIOS2NOMMU_STATFS_H */
+--- linux/include/asm-nios2nommu/string.h
++++ linux/include/asm-nios2nommu/string.h
+@@ -0,0 +1,45 @@
++#ifndef __NIOS_STRING_H__
++#define __NIOS_STRING_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/string.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#ifdef __KERNEL__ /* only set these up for kernel code */
++
++#define __HAVE_ARCH_MEMMOVE
++void * memmove(void * d, const void * s, size_t count);
++#define __HAVE_ARCH_MEMCPY
++extern void * memcpy(void *d, const void *s, size_t count);
++#define __HAVE_ARCH_MEMSET
++extern void * memset(void * s,int c,size_t count);
++
++#if 0
++#define __HAVE_ARCH_BCOPY
++#define __HAVE_ARCH_STRLEN
++#endif
++
++#endif /* KERNEL */
++
++#endif /* !(__NIOS_STRING_H__) */
+--- linux/include/asm-nios2nommu/system.h
++++ linux/include/asm-nios2nommu/system.h
+@@ -0,0 +1,172 @@
++/*
++ * Taken from the m68k.
++ *
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _NIOS2NOMMU_SYSTEM_H
++#define _NIOS2NOMMU_SYSTEM_H
++
++// #include <linux/config.h> /* get configuration macros */
++#include <linux/linkage.h>
++#include <asm/segment.h>
++#include <asm/entry.h>
++#include <asm/nios.h>
++
++/*
++ * switch_to(n) should switch tasks to task ptr, first checking that
++ * ptr isn't the current task, in which case it does nothing. This
++ * also clears the TS-flag if the task we switched to has used the
++ * math co-processor latest.
++ */
++
++/*
++ */
++asmlinkage void resume(void);
++#define switch_to(prev,next,last) \
++{ \
++ void *_last; \
++ __asm__ __volatile__( \
++ "mov r4, %1\n" \
++ "mov r5, %2\n" \
++ "call resume\n" \
++ "mov %0,r4\n" \
++ : "=r" (_last) \
++ : "r" (prev), "r" (next) \
++ : "r4","r5","r7","r8","ra"); \
++ (last) = _last; \
++}
++
++#define local_irq_enable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "ori r8, r8, 1\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_irq_disable() __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "andi r8, r8, 0xfffe\n" \
++ "wrctl status, r8\n" \
++ : : : "r8")
++
++#define local_save_flags(x) __asm__ __volatile__ ( \
++ "rdctl r8, status\n" \
++ "mov %0, r8\n" \
++ :"=r" (x) : : "r8", "memory")
++
++#define local_irq_restore(x) __asm__ __volatile__ ( \
++ "mov r8, %0\n" \
++ "wrctl status, r8\n" \
++ : :"r" (x) : "memory")
++
++/* For spinlocks etc */
++#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
++
++#define irqs_disabled() \
++({ \
++ unsigned long flags; \
++ local_save_flags(flags); \
++ ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
++})
++
++#define iret() __asm__ __volatile__ ("eret": : :"memory", "ea")
++
++/*
++ * Force strict CPU ordering.
++ * Not really required on m68k...
++ */
++#define nop() asm volatile ("nop"::)
++#define mb() asm volatile ("" : : :"memory")
++#define rmb() asm volatile ("" : : :"memory")
++#define wmb() asm volatile ("" : : :"memory")
++#define set_rmb(var, value) do { xchg(&var, value); } while (0)
++#define set_mb(var, value) set_rmb(var, value)
++#define set_wmb(var, value) do { var = value; wmb(); } while (0)
++
++#ifdef CONFIG_SMP
++#define smp_mb() mb()
++#define smp_rmb() rmb()
++#define smp_wmb() wmb()
++#define smp_read_barrier_depends() read_barrier_depends()
++#else
++#define smp_mb() barrier()
++#define smp_rmb() barrier()
++#define smp_wmb() barrier()
++#define smp_read_barrier_depends() do { } while(0)
++#endif
++
++#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
++#define tas(ptr) (xchg((ptr),1))
++
++struct __xchg_dummy { unsigned long a[100]; };
++#define __xg(x) ((volatile struct __xchg_dummy *)(x))
++
++static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
++{
++ unsigned long tmp, flags;
++
++ local_irq_save(flags);
++
++ switch (size) {
++ case 1:
++ __asm__ __volatile__( \
++ "ldb %0, %2\n" \
++ "stb %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 2:
++ __asm__ __volatile__( \
++ "ldh %0, %2\n" \
++ "sth %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ case 4:
++ __asm__ __volatile__( \
++ "ldw %0, %2\n" \
++ "stw %1, %2\n" \
++ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
++ break;
++ }
++ local_irq_restore(flags);
++ return tmp;
++}
++
++/*
++ * Atomic compare and exchange. Compare OLD with MEM, if identical,
++ * store NEW in MEM. Return the initial value in MEM. Success is
++ * indicated by comparing RETURN with OLD.
++ */
++#define __HAVE_ARCH_CMPXCHG 1
++
++static __inline__ unsigned long
++cmpxchg(volatile int *p, int old, int new)
++{
++ unsigned long flags;
++ int prev;
++
++ local_irq_save(flags);
++ if ((prev = *p) == old)
++ *p = new;
++ local_irq_restore(flags);
++ return(prev);
++}
++
++#endif /* _NIOS2NOMMU_SYSTEM_H */
+--- linux/include/asm-nios2nommu/termbits.h
++++ linux/include/asm-nios2nommu/termbits.h
+@@ -0,0 +1,199 @@
++#ifndef __ARCH_NIOS_TERMBITS_H__
++#define __ARCH_NIOS_TERMBITS_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termbits.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/posix_types.h>
++
++typedef unsigned char cc_t;
++typedef unsigned int speed_t;
++typedef unsigned int tcflag_t;
++
++#define NCCS 19
++struct termios {
++ tcflag_t c_iflag; /* input mode flags */
++ tcflag_t c_oflag; /* output mode flags */
++ tcflag_t c_cflag; /* control mode flags */
++ tcflag_t c_lflag; /* local mode flags */
++ cc_t c_line; /* line discipline */
++ cc_t c_cc[NCCS]; /* control characters */
++};
++
++/* c_cc characters */
++#define VINTR 0
++#define VQUIT 1
++#define VERASE 2
++#define VKILL 3
++#define VEOF 4
++#define VTIME 5
++#define VMIN 6
++#define VSWTC 7
++#define VSTART 8
++#define VSTOP 9
++#define VSUSP 10
++#define VEOL 11
++#define VREPRINT 12
++#define VDISCARD 13
++#define VWERASE 14
++#define VLNEXT 15
++#define VEOL2 16
++
++
++/* c_iflag bits */
++#define IGNBRK 0000001
++#define BRKINT 0000002
++#define IGNPAR 0000004
++#define PARMRK 0000010
++#define INPCK 0000020
++#define ISTRIP 0000040
++#define INLCR 0000100
++#define IGNCR 0000200
++#define ICRNL 0000400
++#define IUCLC 0001000
++#define IXON 0002000
++#define IXANY 0004000
++#define IXOFF 0010000
++#define IMAXBEL 0020000
++#define IUTF8 0040000
++
++/* c_oflag bits */
++#define OPOST 0000001
++#define OLCUC 0000002
++#define ONLCR 0000004
++#define OCRNL 0000010
++#define ONOCR 0000020
++#define ONLRET 0000040
++#define OFILL 0000100
++#define OFDEL 0000200
++#define NLDLY 0000400
++#define NL0 0000000
++#define NL1 0000400
++#define CRDLY 0003000
++#define CR0 0000000
++#define CR1 0001000
++#define CR2 0002000
++#define CR3 0003000
++#define TABDLY 0014000
++#define TAB0 0000000
++#define TAB1 0004000
++#define TAB2 0010000
++#define TAB3 0014000
++#define XTABS 0014000
++#define BSDLY 0020000
++#define BS0 0000000
++#define BS1 0020000
++#define VTDLY 0040000
++#define VT0 0000000
++#define VT1 0040000
++#define FFDLY 0100000
++#define FF0 0000000
++#define FF1 0100000
++
++/* c_cflag bit meaning */
++#define CBAUD 0010017
++#define B0 0000000 /* hang up */
++#define B50 0000001
++#define B75 0000002
++#define B110 0000003
++#define B134 0000004
++#define B150 0000005
++#define B200 0000006
++#define B300 0000007
++#define B600 0000010
++#define B1200 0000011
++#define B1800 0000012
++#define B2400 0000013
++#define B4800 0000014
++#define B9600 0000015
++#define B19200 0000016
++#define B38400 0000017
++#define EXTA B19200
++#define EXTB B38400
++#define CSIZE 0000060
++#define CS5 0000000
++#define CS6 0000020
++#define CS7 0000040
++#define CS8 0000060
++#define CSTOPB 0000100
++#define CREAD 0000200
++#define PARENB 0000400
++#define PARODD 0001000
++#define HUPCL 0002000
++#define CLOCAL 0004000
++#define CBAUDEX 0010000
++#define B57600 0010001
++#define B115200 0010002
++#define B230400 0010003
++#define B460800 0010004
++#define B500000 0010005
++#define B576000 0010006
++#define B921600 0010007
++#define B1000000 0010010
++#define B1152000 0010011
++#define B1500000 0010012
++#define B2000000 0010013
++#define B2500000 0010014
++#define B3000000 0010015
++#define B3500000 0010016
++#define B4000000 0010017
++#define CIBAUD 002003600000 /* input baud rate (not used) */
++#define CMSPAR 010000000000 /* mark or space (stick) parity */
++#define CRTSCTS 020000000000 /* flow control */
++
++/* c_lflag bits */
++#define ISIG 0000001
++#define ICANON 0000002
++#define XCASE 0000004
++#define ECHO 0000010
++#define ECHOE 0000020
++#define ECHOK 0000040
++#define ECHONL 0000100
++#define NOFLSH 0000200
++#define TOSTOP 0000400
++#define ECHOCTL 0001000
++#define ECHOPRT 0002000
++#define ECHOKE 0004000
++#define FLUSHO 0010000
++#define PENDIN 0040000
++#define IEXTEN 0100000
++
++
++/* tcflow() and TCXONC use these */
++#define TCOOFF 0
++#define TCOON 1
++#define TCIOFF 2
++#define TCION 3
++
++/* tcflush() and TCFLSH use these */
++#define TCIFLUSH 0
++#define TCOFLUSH 1
++#define TCIOFLUSH 2
++
++/* tcsetattr uses these */
++#define TCSANOW 0
++#define TCSADRAIN 1
++#define TCSAFLUSH 2
++
++#endif /* __ARCH_NIOS_TERMBITS_H__ */
+--- linux/include/asm-nios2nommu/termios.h
++++ linux/include/asm-nios2nommu/termios.h
+@@ -0,0 +1,132 @@
++#ifndef _NIOS_TERMIOS_H
++#define _NIOS_TERMIOS_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/termios.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/termbits.h>
++#include <asm/ioctls.h>
++
++struct winsize {
++ unsigned short ws_row;
++ unsigned short ws_col;
++ unsigned short ws_xpixel;
++ unsigned short ws_ypixel;
++};
++
++#define NCC 8
++struct termio {
++ unsigned short c_iflag; /* input mode flags */
++ unsigned short c_oflag; /* output mode flags */
++ unsigned short c_cflag; /* control mode flags */
++ unsigned short c_lflag; /* local mode flags */
++ unsigned char c_line; /* line discipline */
++ unsigned char c_cc[NCC]; /* control characters */
++};
++
++#ifdef __KERNEL__
++/* intr=^C quit=^| erase=del kill=^U
++ eof=^D vtime=\0 vmin=\1 sxtc=\0
++ start=^Q stop=^S susp=^Z eol=\0
++ reprint=^R discard=^U werase=^W lnext=^V
++ eol2=\0
++*/
++#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
++#endif
++
++/* modem lines */
++#define TIOCM_LE 0x001
++#define TIOCM_DTR 0x002
++#define TIOCM_RTS 0x004
++#define TIOCM_ST 0x008
++#define TIOCM_SR 0x010
++#define TIOCM_CTS 0x020
++#define TIOCM_CAR 0x040
++#define TIOCM_RNG 0x080
++#define TIOCM_DSR 0x100
++#define TIOCM_CD TIOCM_CAR
++#define TIOCM_RI TIOCM_RNG
++#define TIOCM_OUT1 0x2000
++#define TIOCM_OUT2 0x4000
++#define TIOCM_LOOP 0x8000
++
++/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
++
++/* line disciplines */
++#define N_TTY 0
++#define N_SLIP 1
++#define N_MOUSE 2
++#define N_PPP 3
++#define N_STRIP 4
++#define N_AX25 5
++#define N_X25 6 /* X.25 async */
++#define N_6PACK 7
++#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
++#define N_R3964 9 /* Reserved for Simatic R3964 module */
++#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
++#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
++#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
++#define N_HDLC 13 /* synchronous HDLC */
++#define N_SYNC_PPP 14
++#define N_HCI 15 /* Bluetooth HCI UART */
++
++#ifdef __KERNEL__
++
++/*
++ * Translate a "termio" structure into a "termios". Ugh.
++ */
++#define user_termio_to_kernel_termios(termios, termio) \
++({ \
++ unsigned short tmp; \
++ get_user(tmp, &(termio)->c_iflag); \
++ (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
++ get_user(tmp, &(termio)->c_oflag); \
++ (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
++ get_user(tmp, &(termio)->c_cflag); \
++ (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
++ get_user(tmp, &(termio)->c_lflag); \
++ (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
++ get_user((termios)->c_line, &(termio)->c_line); \
++ copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
++})
++
++/*
++ * Translate a "termios" structure into a "termio". Ugh.
++ */
++#define kernel_termios_to_user_termio(termio, termios) \
++({ \
++ put_user((termios)->c_iflag, &(termio)->c_iflag); \
++ put_user((termios)->c_oflag, &(termio)->c_oflag); \
++ put_user((termios)->c_cflag, &(termio)->c_cflag); \
++ put_user((termios)->c_lflag, &(termio)->c_lflag); \
++ put_user((termios)->c_line, &(termio)->c_line); \
++ copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
++})
++
++#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
++#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TERMIOS_H */
+--- linux/include/asm-nios2nommu/thread_info.h
++++ linux/include/asm-nios2nommu/thread_info.h
+@@ -0,0 +1,126 @@
++/* thread_info.h: niosnommu low-level thread information
++ * adapted from the m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd.
++ * Copyright (C) 2002 Microtronix Datacom
++ *
++ * - Incorporating suggestions made by Linus Torvalds and Dave Miller
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++
++#ifndef _ASM_THREAD_INFO_H
++#define _ASM_THREAD_INFO_H
++
++#include <asm/page.h>
++
++#ifdef __KERNEL__
++
++#ifndef __ASSEMBLY__
++
++/*
++ * low level task data.
++ */
++struct thread_info {
++ struct task_struct *task; /* main task structure */
++ struct exec_domain *exec_domain; /* execution domain */
++ unsigned long flags; /* low level flags */
++ int cpu; /* cpu we're on */
++ int preempt_count; /* 0 => preemptable, <0 => BUG*/
++ struct restart_block restart_block;
++};
++
++/*
++ * macros/functions for gaining access to the thread information structure
++ */
++#define INIT_THREAD_INFO(tsk) \
++{ \
++ .task = &tsk, \
++ .exec_domain = &default_exec_domain, \
++ .flags = 0, \
++ .cpu = 0, \
++ .preempt_count = 1, \
++ .restart_block = { \
++ .fn = do_no_restart_syscall, \
++ }, \
++}
++
++#define init_thread_info (init_thread_union.thread_info)
++#define init_stack (init_thread_union.stack)
++
++
++/* how to get the thread information struct from C
++ usable only in supervisor mode */
++static inline struct thread_info *current_thread_info(void)
++{
++ struct thread_info *ti;
++ __asm__ __volatile__(
++ "mov %0, sp\n"
++ "and %0, %0, %1\n"
++ : "=&r"(ti)
++ : "r" (~(THREAD_SIZE-1))
++ );
++ return ti;
++}
++
++/* thread information allocation */
++#define alloc_thread_info(tsk) ((struct thread_info *) \
++ __get_free_pages(GFP_KERNEL, 1))
++#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
++#define put_thread_info(ti) put_task_struct((ti)->task)
++
++#define PREEMPT_ACTIVE 0x4000000
++
++/*
++ * thread information flag bit numbers
++ */
++#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
++#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
++#define TIF_SIGPENDING 2 /* signal pending */
++#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
++#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
++ TIF_NEED_RESCHED */
++
++/* as above, but as bit values */
++#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
++#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
++#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
++#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
++#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
++
++#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
++
++#else /* __ASSEMBLY__ */
++
++/* how to get the thread information struct from ASM
++ usable only in supervisor mode */
++.macro GET_THREAD_INFO reg
++.if THREAD_SIZE & 0xffff0000
++ andhi \reg, sp, %hi(~(THREAD_SIZE-1))
++.else
++ addi \reg, r0, %lo(~(THREAD_SIZE-1))
++ and \reg, \reg, sp
++.endif
++.endm
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _ASM_THREAD_INFO_H */
+--- linux/include/asm-nios2nommu/timer_struct.h
++++ linux/include/asm-nios2nommu/timer_struct.h
+@@ -0,0 +1,38 @@
++
++// ----------------------------------------------
++// Timer Peripheral
++
++// Timer Registers
++typedef volatile struct
++ {
++ int np_timerstatus; // read only, 2 bits (any write to clear TO)
++ int np_timercontrol; // write/readable, 4 bits
++ int np_timerperiodl; // write/readable, 16 bits
++ int np_timerperiodh; // write/readable, 16 bits
++ int np_timersnapl; // read only, 16 bits
++ int np_timersnaph; // read only, 16 bits
++ } np_timer;
++
++// Timer Register Bits
++enum
++ {
++ np_timerstatus_run_bit = 1, // timer is running
++ np_timerstatus_to_bit = 0, // timer has timed out
++
++ np_timercontrol_stop_bit = 3, // stop the timer
++ np_timercontrol_start_bit = 2, // start the timer
++ np_timercontrol_cont_bit = 1, // continous mode
++ np_timercontrol_ito_bit = 0, // enable time out interrupt
++
++ np_timerstatus_run_mask = (1<<1), // timer is running
++ np_timerstatus_to_mask = (1<<0), // timer has timed out
++
++ np_timercontrol_stop_mask = (1<<3), // stop the timer
++ np_timercontrol_start_mask = (1<<2), // start the timer
++ np_timercontrol_cont_mask = (1<<1), // continous mode
++ np_timercontrol_ito_mask = (1<<0) // enable time out interrupt
++ };
++
++// Timer Routines
++int nr_timer_milliseconds(void); // Starts on first call, hogs timer1.
++
+--- linux/include/asm-nios2nommu/timex.h
++++ linux/include/asm-nios2nommu/timex.h
+@@ -0,0 +1,48 @@
++#ifndef _ASMNIOS2NOMMU_TIMEX_H
++#define _ASMNIOS2NOMMU_TIMEX_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/timex.h
++ *
++ * timex specifications
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/nios.h>
++
++
++#define CLOCK_TICK_RATE nasys_clock_freq /* Underlying HZ */
++
++#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
++
++#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
++ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
++ << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
++
++typedef unsigned long cycles_t;
++
++static inline cycles_t get_cycles(void)
++{
++ return 0;
++}
++
++#endif
+--- linux/include/asm-nios2nommu/tlb.h
++++ linux/include/asm-nios2nommu/tlb.h
+@@ -0,0 +1,35 @@
++#ifndef __NIOS_TLB_H__
++#define __NIOS_TLB_H__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlb.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd
++ * Copyright (C) 2002 NEC Corporation
++ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Written by Miles Bader <miles@gnu.org>
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#define tlb_flush(tlb) ((void)0)
++
++#include <asm-generic/tlb.h>
++
++#endif /* __NIOS_TLB_H__ */
++
+--- linux/include/asm-nios2nommu/tlbflush.h
++++ linux/include/asm-nios2nommu/tlbflush.h
+@@ -0,0 +1,86 @@
++#ifndef _NIOS2NOMMU_TLBFLUSH_H
++#define _NIOS2NOMMU_TLBFLUSH_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/tlbflush.h
++ *
++ * Ported from m68knommu.
++ *
++ * Copyright (C) 2003 Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++#include <asm/setup.h>
++
++/*
++ * flush all user-space atc entries.
++ */
++static inline void __flush_tlb(void)
++{
++ BUG();
++}
++
++static inline void __flush_tlb_one(unsigned long addr)
++{
++ BUG();
++}
++
++#define flush_tlb() __flush_tlb()
++
++/*
++ * flush all atc entries (both kernel and user-space entries).
++ */
++static inline void flush_tlb_all(void)
++{
++ BUG();
++}
++
++static inline void flush_tlb_mm(struct mm_struct *mm)
++{
++ BUG();
++}
++
++static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
++{
++ BUG();
++}
++
++static inline void flush_tlb_range(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_kernel_page(unsigned long addr)
++{
++ BUG();
++}
++
++extern inline void flush_tlb_pgtables(struct mm_struct *mm,
++ unsigned long start, unsigned long end)
++{
++ BUG();
++}
++
++#endif /* _NIOS2NOMMU_TLBFLUSH_H */
+--- linux/include/asm-nios2nommu/topology.h
++++ linux/include/asm-nios2nommu/topology.h
+@@ -0,0 +1,30 @@
++#ifndef _ASM_NIOS2NOMMU_TOPOLOGY_H
++#define _ASM_NIOS2NOMMU_TOPOLOGY_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/topology.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm-generic/topology.h>
++
++#endif /* _ASM_NIOS2NOMMU_TOPOLOGY_H */
+--- linux/include/asm-nios2nommu/traps.h
++++ linux/include/asm-nios2nommu/traps.h
+@@ -0,0 +1,27 @@
++/*
++ * Copyright (C) 2004, Microtronix Datacom Ltd.
++ *
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT. See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ *
++ */
++#ifndef _NIOS2_TRAPS_H
++#define _NIOS2_TRAPS_H
++
++#define TRAP_ID_SYSCALL 0
++#define TRAP_ID_APPDEBUG 1
++#endif /* !(_NIOS2_TRAPS_H) */
+--- linux/include/asm-nios2nommu/types.h
++++ linux/include/asm-nios2nommu/types.h
+@@ -0,0 +1,93 @@
++#ifndef _NIOS_TYPES_H
++#define _NIOS_TYPES_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/types.h
++ *
++ * Derived from m68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * This file is never included by application software unless
++ * explicitly requested (e.g., via linux/types.h) in which case the
++ * application is Linux specific so (user-) name space pollution is
++ * not a major issue. However, for interoperability, libraries still
++ * need to be careful to avoid a name clashes.
++ */
++
++#ifndef __ASSEMBLY__
++
++typedef unsigned short umode_t;
++
++/*
++ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
++ * header files exported to user space
++ */
++
++typedef __signed__ char __s8;
++typedef unsigned char __u8;
++
++typedef __signed__ short __s16;
++typedef unsigned short __u16;
++
++typedef __signed__ int __s32;
++typedef unsigned int __u32;
++
++#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
++typedef __signed__ long long __s64;
++typedef unsigned long long __u64;
++#endif
++
++#endif /* __ASSEMBLY__ */
++
++/*
++ * These aren't exported outside the kernel to avoid name space clashes
++ */
++#ifdef __KERNEL__
++
++#define BITS_PER_LONG 32
++
++#ifndef __ASSEMBLY__
++
++typedef signed char s8;
++typedef unsigned char u8;
++
++typedef signed short s16;
++typedef unsigned short u16;
++
++typedef signed int s32;
++typedef unsigned int u32;
++
++typedef signed long long s64;
++typedef unsigned long long u64;
++
++/* DMA addresses are always 32-bits wide */
++
++typedef u32 dma_addr_t;
++typedef u32 dma64_addr_t;
++
++typedef unsigned short kmem_bufctl_t;
++
++#endif /* __ASSEMBLY__ */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NIOS_TYPES_H */
+--- linux/include/asm-nios2nommu/uaccess.h
++++ linux/include/asm-nios2nommu/uaccess.h
+@@ -0,0 +1,183 @@
++#ifndef __NIOS2NOMMU_UACCESS_H
++#define __NIOS2NOMMU_UACCESS_H
++
++/*--------------------------------------------------------------------
++ *
++ * asm-nios2nommu/uaccess.h
++ *
++ * User space memory access functions
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Ported from asm-m68knommu/uaccess.h --wentao
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <linux/sched.h>
++#include <linux/mm.h>
++#include <asm/segment.h>
++#include <asm/nios.h>
++
++#define VERIFY_READ 0
++#define VERIFY_WRITE 1
++
++#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size))
++
++static inline int _access_ok(unsigned long addr, unsigned long size)
++{
++ return (((unsigned long)addr < (unsigned long)nasys_program_mem_end) &&
++ (((unsigned long)addr >= (unsigned long)nasys_program_mem)));
++}
++
++extern inline int verify_area(int type, const void * addr, unsigned long size)
++{
++ return access_ok(type,addr,size)?0:-EFAULT;
++}
++
++/*
++ * The exception table consists of pairs of addresses: the first is the
++ * address of an instruction that is allowed to fault, and the second is
++ * the address at which the program should continue. No registers are
++ * modified, so it is entirely up to the continuation code to figure out
++ * what to do.
++ *
++ * All the routines below use bits of fixup code that are out of line
++ * with the main instruction path. This means when everything is well,
++ * we don't even have to jump over them. Further, they do not intrude
++ * on our cache or tlb entries.
++ */
++
++#define ARCH_HAS_SEARCH_EXTABLE
++//;dgt2;tmp;
++
++struct exception_table_entry
++{
++ unsigned long insn, fixup;
++};
++
++/* Returns 0 if exception not found and fixup otherwise. */
++extern unsigned long search_exception_table(unsigned long);
++
++
++/*
++ * These are the main single-value transfer routines. They automatically
++ * use the right size if we just have the right pointer type.
++ */
++
++#define put_user(x, ptr) \
++({ \
++ int __pu_err = 0; \
++ typeof(*(ptr)) __pu_val = (x); \
++ switch (sizeof (*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __pu_err = __put_user_bad(); \
++ break; \
++ } \
++ __pu_err; \
++})
++#define __put_user(x, ptr) put_user(x, ptr)
++
++extern int __put_user_bad(void);
++
++/*
++ * Tell gcc we read from memory instead of writing: this is because
++ * we do not write to any memory gcc knows about, so there are no
++ * aliasing issues.
++ */
++
++#define __ptr(x) ((unsigned long *)(x))
++
++#define get_user(x, ptr) \
++({ \
++ int __gu_err = 0; \
++ typeof(*(ptr)) __gu_val = 0; \
++ switch (sizeof(*(ptr))) { \
++ case 1: \
++ case 2: \
++ case 4: \
++ case 8: \
++ memcpy(&__gu_val, ptr, sizeof (*(ptr))); \
++ break; \
++ default: \
++ __gu_val = 0; \
++ __gu_err = __get_user_bad(); \
++ break; \
++ } \
++ (x) = __gu_val; \
++ __gu_err; \
++})
++#define __get_user(x, ptr) get_user(x, ptr)
++
++extern int __get_user_bad(void);
++
++#define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
++#define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
++
++#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
++#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
++#define __copy_to_user_inatomic __copy_to_user
++#define __copy_from_user_inatomic __copy_from_user
++
++#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
++
++#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
++
++/*
++ * Copy a null terminated string from userspace.
++ */
++
++static inline long
++strncpy_from_user(char *dst, const char *src, long count)
++{
++ char *tmp;
++ strncpy(dst, src, count);
++ for (tmp = dst; *tmp && count > 0; tmp++, count--)
++ ;
++ return(tmp - dst); /* DAVIDM should we count a NUL ? check getname */
++}
++
++/*
++ * Return the size of a string (including the ending 0)
++ *
++ * Return 0 on exception, a value greater than N if too long
++ */
++static inline long strnlen_user(const char *src, long n)
++{
++ return(strlen(src) + 1); /* DAVIDM make safer */
++}
++
++#define strlen_user(str) strnlen_user(str, 32767)
++
++/*
++ * Zero Userspace
++ */
++
++static inline unsigned long
++clear_user(void *to, unsigned long n)
++{
++ memset(to, 0, n);
++ return(0);
++}
++
++#endif /* _NIOS2NOMMU_UACCESS_H */
+--- linux/include/asm-nios2nommu/uart_struct.h
++++ linux/include/asm-nios2nommu/uart_struct.h
+@@ -0,0 +1,83 @@
++
++// UART Registers
++typedef volatile struct
++ {
++ int np_uartrxdata; // Read-only, 8-bit
++ int np_uarttxdata; // Write-only, 8-bit
++ int np_uartstatus; // Read-only, 8-bit
++ int np_uartcontrol; // Read/Write, 9-bit
++ int np_uartdivisor; // Read/Write, 16-bit, optional
++ int np_uartendofpacket; // Read/Write, end-of-packet character
++ } np_uart;
++
++// UART Status Register Bits
++enum
++ {
++ np_uartstatus_eop_bit = 12,
++ np_uartstatus_cts_bit = 11,
++ np_uartstatus_dcts_bit = 10,
++ np_uartstatus_e_bit = 8,
++ np_uartstatus_rrdy_bit = 7,
++ np_uartstatus_trdy_bit = 6,
++ np_uartstatus_tmt_bit = 5,
++ np_uartstatus_toe_bit = 4,
++ np_uartstatus_roe_bit = 3,
++ np_uartstatus_brk_bit = 2,
++ np_uartstatus_fe_bit = 1,
++ np_uartstatus_pe_bit = 0,
++
++ np_uartstatus_eop_mask = (1<<12),
++ np_uartstatus_cts_mask = (1<<11),
++ np_uartstatus_dcts_mask = (1<<10),
++ np_uartstatus_e_mask = (1<<8),
++ np_uartstatus_rrdy_mask = (1<<7),
++ np_uartstatus_trdy_mask = (1<<6),
++ np_uartstatus_tmt_mask = (1<<5),
++ np_uartstatus_toe_mask = (1<<4),
++ np_uartstatus_roe_mask = (1<<3),
++ np_uartstatus_brk_mask = (1<<2),
++ np_uartstatus_fe_mask = (1<<1),
++ np_uartstatus_pe_mask = (1<<0)
++ };
++
++// UART Control Register Bits
++enum
++ {
++ np_uartcontrol_ieop_bit = 12,
++ np_uartcontrol_rts_bit = 11,
++ np_uartcontrol_idcts_bit = 10,
++ np_uartcontrol_tbrk_bit = 9,
++ np_uartcontrol_ie_bit = 8,
++ np_uartcontrol_irrdy_bit = 7,
++ np_uartcontrol_itrdy_bit = 6,
++ np_uartcontrol_itmt_bit = 5,
++ np_uartcontrol_itoe_bit = 4,
++ np_uartcontrol_iroe_bit = 3,
++ np_uartcontrol_ibrk_bit = 2,
++ np_uartcontrol_ife_bit = 1,
++ np_uartcontrol_ipe_bit = 0,
++
++ np_uartcontrol_ieop_mask = (1<<12),
++ np_uartcontrol_rts_mask = (1<<11),
++ np_uartcontrol_idcts_mask = (1<<10),
++ np_uartcontrol_tbrk_mask = (1<<9),
++ np_uartcontrol_ie_mask = (1<<8),
++ np_uartcontrol_irrdy_mask = (1<<7),
++ np_uartcontrol_itrdy_mask = (1<<6),
++ np_uartcontrol_itmt_mask = (1<<5),
++ np_uartcontrol_itoe_mask = (1<<4),
++ np_uartcontrol_iroe_mask = (1<<3),
++ np_uartcontrol_ibrk_mask = (1<<2),
++ np_uartcontrol_ife_mask = (1<<1),
++ np_uartcontrol_ipe_mask = (1<<0)
++ };
++
++// UART Routines
++int nr_uart_rxchar(np_uart *uartBase); // 0 for default UART
++void nr_uart_txcr(void);
++void nr_uart_txchar(int c,np_uart *uartBase); // 0 for default UART
++void nr_uart_txhex(int x); // 16 or 32 bits
++void nr_uart_txhex16(short x);
++void nr_uart_txhex32(long x);
++void nr_uart_txstring(char *s);
++
+--- linux/include/asm-nios2nommu/ucontext.h
++++ linux/include/asm-nios2nommu/ucontext.h
+@@ -0,0 +1,63 @@
++#ifndef _NIOSKNOMMU_UCONTEXT_H
++#define _NIOSKNOMMU_UCONTEXT_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/ucontext.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++typedef int greg_t;
++#define NGREG 32
++typedef greg_t gregset_t[NGREG];
++
++#ifdef CONFIG_FPU
++typedef struct fpregset {
++ int f_pcr;
++ int f_psr;
++ int f_fpiaddr;
++ int f_fpregs[8][3];
++} fpregset_t;
++#endif
++
++struct mcontext {
++ int version;
++ int status_extension;
++ gregset_t gregs;
++#ifdef CONFIG_FPU
++ fpregset_t fpregs;
++#endif
++};
++
++#define MCONTEXT_VERSION 2
++
++struct ucontext {
++ unsigned long uc_flags;
++ struct ucontext *uc_link;
++ stack_t uc_stack;
++ struct mcontext uc_mcontext;
++#ifdef CONFIG_FPU
++ unsigned long uc_filler[80];
++#endif
++ sigset_t uc_sigmask; /* mask last for extensibility */
++};
++
++#endif
+--- linux/include/asm-nios2nommu/unaligned.h
++++ linux/include/asm-nios2nommu/unaligned.h
+@@ -0,0 +1,43 @@
++#ifndef __NIOS_UNALIGNED_H
++#define __NIOS_UNALIGNED_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/unaligned.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * The nios cannot do unaligned accesses itself.
++ */
++
++#define get_unaligned(ptr) ({ \
++ typeof((*(ptr))) x; \
++ memcpy(&x, (void*)ptr, sizeof(*(ptr))); \
++ x; \
++})
++
++#define put_unaligned(val, ptr) ({ \
++ typeof((*(ptr))) x = val; \
++ memcpy((void*)ptr, &x, sizeof(*(ptr))); \
++})
++
++#endif /* __NIOS_UNALIGNED_H */
+--- linux/include/asm-nios2nommu/unistd.h
++++ linux/include/asm-nios2nommu/unistd.h
+@@ -0,0 +1,686 @@
++#ifndef _ASM_NIOS_UNISTD_H_
++#define _ASM_NIOS_UNISTD_H_
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/unistd.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * //vic - kernel_thread moved to process.c
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/traps.h>
++
++/* TRAP isr expects the trap# (syscall=#TRAP_ID_SYSCALL) in r2,
++ * the syscall # in r3, and arguments in r4, r5, ...
++ * Return argument expected in r2.
++ */
++
++#define __NR_restart_syscall 0
++#define __NR_exit 1
++#define __NR_fork 2
++#define __NR_read 3
++#define __NR_write 4
++#define __NR_open 5
++#define __NR_close 6
++#define __NR_waitpid 7
++#define __NR_creat 8
++#define __NR_link 9
++#define __NR_unlink 10
++#define __NR_execve 11
++#define __NR_chdir 12
++#define __NR_time 13
++#define __NR_mknod 14
++#define __NR_chmod 15
++#define __NR_chown 16
++#define __NR_break 17
++#define __NR_oldstat 18
++#define __NR_lseek 19
++#define __NR_getpid 20
++#define __NR_mount 21
++#define __NR_umount 22
++#define __NR_setuid 23
++#define __NR_getuid 24
++#define __NR_stime 25
++#define __NR_ptrace 26
++#define __NR_alarm 27
++#define __NR_oldfstat 28
++#define __NR_pause 29
++#define __NR_utime 30
++#define __NR_stty 31
++#define __NR_gtty 32
++#define __NR_access 33
++#define __NR_nice 34
++#define __NR_ftime 35
++#define __NR_sync 36
++#define __NR_kill 37
++#define __NR_rename 38
++#define __NR_mkdir 39
++#define __NR_rmdir 40
++#define __NR_dup 41
++#define __NR_pipe 42
++#define __NR_times 43
++#define __NR_prof 44
++#define __NR_brk 45
++#define __NR_setgid 46
++#define __NR_getgid 47
++#define __NR_signal 48
++#define __NR_geteuid 49
++#define __NR_getegid 50
++#define __NR_acct 51
++#define __NR_umount2 52 //vic #define __NR_phys 52
++#define __NR_lock 53
++#define __NR_ioctl 54
++#define __NR_fcntl 55
++#define __NR_mpx 56
++#define __NR_setpgid 57
++#define __NR_ulimit 58
++#define __NR_oldolduname 59
++#define __NR_umask 60
++#define __NR_chroot 61
++#define __NR_ustat 62
++#define __NR_dup2 63
++#define __NR_getppid 64
++#define __NR_getpgrp 65
++#define __NR_setsid 66
++#define __NR_sigaction 67
++#define __NR_sgetmask 68
++#define __NR_ssetmask 69
++#define __NR_setreuid 70
++#define __NR_setregid 71
++#define __NR_sigsuspend 72
++#define __NR_sigpending 73
++#define __NR_sethostname 74
++#define __NR_setrlimit 75
++#define __NR_getrlimit 76
++#define __NR_getrusage 77
++#define __NR_gettimeofday 78
++#define __NR_settimeofday 79
++#define __NR_getgroups 80
++#define __NR_setgroups 81
++#define __NR_select 82
++#define __NR_symlink 83
++#define __NR_oldlstat 84
++#define __NR_readlink 85
++#define __NR_uselib 86
++#define __NR_swapon 87
++#define __NR_reboot 88
++#define __NR_readdir 89
++#define __NR_mmap 90
++#define __NR_munmap 91
++#define __NR_truncate 92
++#define __NR_ftruncate 93
++#define __NR_fchmod 94
++#define __NR_fchown 95
++#define __NR_getpriority 96
++#define __NR_setpriority 97
++#define __NR_profil 98
++#define __NR_statfs 99
++#define __NR_fstatfs 100
++#define __NR_ioperm 101
++#define __NR_socketcall 102
++#define __NR_syslog 103
++#define __NR_setitimer 104
++#define __NR_getitimer 105
++#define __NR_stat 106
++#define __NR_lstat 107
++#define __NR_fstat 108
++#define __NR_olduname 109
++#define __NR_iopl /* 110 */ not supported
++#define __NR_vhangup 111
++#define __NR_idle /* 112 */ Obsolete
++#define __NR_vm86 /* 113 */ not supported
++#define __NR_wait4 114
++#define __NR_swapoff 115
++#define __NR_sysinfo 116
++#define __NR_ipc 117
++#define __NR_fsync 118
++#define __NR_sigreturn 119
++#define __NR_clone 120
++#define __NR_setdomainname 121
++#define __NR_uname 122
++#define __NR_cacheflush 123
++#define __NR_adjtimex 124
++#define __NR_mprotect 125
++#define __NR_sigprocmask 126
++#define __NR_create_module 127
++#define __NR_init_module 128
++#define __NR_delete_module 129
++#define __NR_get_kernel_syms 130
++#define __NR_quotactl 131
++#define __NR_getpgid 132
++#define __NR_fchdir 133
++#define __NR_bdflush 134
++#define __NR_sysfs 135
++#define __NR_personality 136
++#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
++#define __NR_setfsuid 138
++#define __NR_setfsgid 139
++#define __NR__llseek 140
++#define __NR_getdents 141
++#define __NR__newselect 142
++#define __NR_flock 143
++#define __NR_msync 144
++#define __NR_readv 145
++#define __NR_writev 146
++#define __NR_getsid 147
++#define __NR_fdatasync 148
++#define __NR__sysctl 149
++#define __NR_mlock 150
++#define __NR_munlock 151
++#define __NR_mlockall 152
++#define __NR_munlockall 153
++#define __NR_sched_setparam 154
++#define __NR_sched_getparam 155
++#define __NR_sched_setscheduler 156
++#define __NR_sched_getscheduler 157
++#define __NR_sched_yield 158
++#define __NR_sched_get_priority_max 159
++#define __NR_sched_get_priority_min 160
++#define __NR_sched_rr_get_interval 161
++#define __NR_nanosleep 162
++#define __NR_mremap 163
++#define __NR_setresuid 164
++#define __NR_getresuid 165
++#define __NR_getpagesize 166
++#define __NR_query_module 167
++#define __NR_poll 168
++#define __NR_nfsservctl 169
++#define __NR_setresgid 170
++#define __NR_getresgid 171
++#define __NR_prctl 172
++#define __NR_rt_sigreturn 173
++#define __NR_rt_sigaction 174
++#define __NR_rt_sigprocmask 175
++#define __NR_rt_sigpending 176
++#define __NR_rt_sigtimedwait 177
++#define __NR_rt_sigqueueinfo 178
++#define __NR_rt_sigsuspend 179
++#define __NR_pread 180
++#define __NR_pwrite 181
++#define __NR_lchown 182
++#define __NR_getcwd 183
++#define __NR_capget 184
++#define __NR_capset 185
++#define __NR_sigaltstack 186
++#define __NR_sendfile 187
++#define __NR_getpmsg 188 /* some people actually want streams */
++#define __NR_putpmsg 189 /* some people actually want streams */
++#define __NR_vfork 190
++#define __NR_ugetrlimit 191
++#define __NR_mmap2 192
++#define __NR_truncate64 193
++#define __NR_ftruncate64 194
++#define __NR_stat64 195
++#define __NR_lstat64 196
++#define __NR_fstat64 197
++#define __NR_chown32 198
++#define __NR_getuid32 199
++#define __NR_getgid32 200
++#define __NR_geteuid32 201
++#define __NR_getegid32 202
++#define __NR_setreuid32 203
++#define __NR_setregid32 204
++#define __NR_getgroups32 205
++#define __NR_setgroups32 206
++#define __NR_fchown32 207
++#define __NR_setresuid32 208
++#define __NR_getresuid32 209
++#define __NR_setresgid32 210
++#define __NR_getresgid32 211
++#define __NR_lchown32 212
++#define __NR_setuid32 213
++#define __NR_setgid32 214
++#define __NR_setfsuid32 215
++#define __NR_setfsgid32 216
++#define __NR_pivot_root 217
++/* 218 unused */
++/* 219 unused */
++#define __NR_getdents64 220
++#define __NR_gettid 221
++#define __NR_tkill 222
++#define __NR_setxattr 223
++#define __NR_lsetxattr 224
++#define __NR_fsetxattr 225
++#define __NR_getxattr 226
++#define __NR_lgetxattr 227
++#define __NR_fgetxattr 228
++#define __NR_listxattr 229
++#define __NR_llistxattr 230
++#define __NR_flistxattr 231
++#define __NR_removexattr 232
++#define __NR_lremovexattr 233
++#define __NR_fremovexattr 234
++#define __NR_futex 235
++#define __NR_sendfile64 236
++#define __NR_mincore 237
++#define __NR_madvise 238
++#define __NR_fcntl64 239
++#define __NR_readahead 240
++#define __NR_io_setup 241
++#define __NR_io_destroy 242
++#define __NR_io_getevents 243
++#define __NR_io_submit 244
++#define __NR_io_cancel 245
++#define __NR_fadvise64 246
++#define __NR_exit_group 247
++#define __NR_lookup_dcookie 248
++#define __NR_epoll_create 249
++#define __NR_epoll_ctl 250
++#define __NR_epoll_wait 251
++#define __NR_remap_file_pages 252
++#define __NR_set_tid_address 253
++#define __NR_timer_create 254
++#define __NR_timer_settime 255
++#define __NR_timer_gettime 256
++#define __NR_timer_getoverrun 257
++#define __NR_timer_delete 258
++#define __NR_clock_settime 259
++#define __NR_clock_gettime 260
++#define __NR_clock_getres 261
++#define __NR_clock_nanosleep 262
++#define __NR_statfs64 263
++#define __NR_fstatfs64 264
++#define __NR_tgkill 265
++#define __NR_utimes 266
++#define __NR_fadvise64_64 267
++#define __NR_mbind 268
++#define __NR_get_mempolicy 269
++#define __NR_set_mempolicy 270
++#define __NR_mq_open 271
++#define __NR_mq_unlink 272
++#define __NR_mq_timedsend 273
++#define __NR_mq_timedreceive 274
++#define __NR_mq_notify 275
++#define __NR_mq_getsetattr 276
++#define __NR_waitid 277
++#define __NR_sys_setaltroot 278
++#define __NR_add_key 279
++#define __NR_request_key 280
++#define __NR_keyctl 281
++
++#define NR_syscalls 282
++
++/* user-visible error numbers are in the range -1 - -122: see
++ <asm-nios2nommu/errno.h> */
++
++#define __syscall_return(type, res) \
++do { \
++ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
++ \
++ /* avoid using res which is declared to be in \
++ register r2; errno might expand to a function \
++ call and clobber it. */ \
++ \
++ int __err = -(res); \
++ errno = __err; \
++ res = -1; \
++ } \
++ return (type) (res); \
++} while (0)
++
++#define _syscall0(type,name) \
++type name(void) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall1 arg a
++//;dgt2;tmp; already being in r4 ?
++#define _syscall1(type,name,atype,a) \
++type name(atype a) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall2 args a,b
++//;dgt2;tmp; already being in r4,r5 ?
++#define _syscall2(type,name,atype,a,btype,b) \
++type name(atype a,btype b) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall3 args a,b,c
++//;dgt2;tmp; already being in r4,r5,r6 ?
++#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
++type name(atype a,btype b,ctype c) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall4 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
++type name (atype a, btype b, ctype c, dtype d) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) d */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall5 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
++type name (atype a,btype b,ctype c,dtype d,etype e) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) c */ \
++ " mov r8, %7\n\t" /* (long) e */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ , "r" ((long) e) /* %7 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ , "r8" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++//;dgt2;tmp;can we RELY on syscall6 args a,b,c,d
++//;dgt2;tmp; already being in r4,r5,r6,r7 ?
++#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
++type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
++{ \
++ long __res; \
++ \
++ __asm__ __volatile__ ( \
++ \
++ " \n\t" \
++ \
++ " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
++ " movi r3, %1\n\t" /* __NR_##name */ \
++ " mov r4, %3\n\t" /* (long) a */ \
++ " mov r5, %4\n\t" /* (long) b */ \
++ " mov r6, %5\n\t" /* (long) c */ \
++ " mov r7, %6\n\t" /* (long) c */ \
++ " mov r8, %7\n\t" /* (long) e */ \
++ " mov r9, %8\n\t" /* (long) f */ \
++ \
++ " trap\n\t" \
++ " mov %0, r2\n\t" /* syscall rtn */ \
++ \
++ " \n\t" \
++ \
++ : "=r" (__res) /* %0 */ \
++ \
++ : "i" (__NR_##name) /* %1 */ \
++ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
++ , "r" ((long) a) /* %3 */ \
++ , "r" ((long) b) /* %4 */ \
++ , "r" ((long) c) /* %5 */ \
++ , "r" ((long) d) /* %6 */ \
++ , "r" ((long) e) /* %7 */ \
++ , "r" ((long) f) /* %8 */ \
++ \
++ : "r2" /* Clobbered */ \
++ , "r3" /* Clobbered */ \
++ , "r4" /* Clobbered */ \
++ , "r5" /* Clobbered */ \
++ , "r6" /* Clobbered */ \
++ , "r7" /* Clobbered */ \
++ , "r8" /* Clobbered */ \
++ , "r9" /* Clobbered */ \
++ ); \
++ \
++__syscall_return(type,__res); \
++}
++
++#ifdef __KERNEL__
++#define __ARCH_WANT_IPC_PARSE_VERSION
++#define __ARCH_WANT_OLD_READDIR
++#define __ARCH_WANT_OLD_STAT
++#define __ARCH_WANT_STAT64
++#define __ARCH_WANT_SYS_ALARM
++#define __ARCH_WANT_SYS_GETHOSTNAME
++#define __ARCH_WANT_SYS_PAUSE
++#define __ARCH_WANT_SYS_SGETMASK
++#define __ARCH_WANT_SYS_SIGNAL
++#define __ARCH_WANT_SYS_TIME
++#define __ARCH_WANT_SYS_UTIME
++#define __ARCH_WANT_SYS_WAITPID
++#define __ARCH_WANT_SYS_SOCKETCALL
++#define __ARCH_WANT_SYS_FADVISE64
++#define __ARCH_WANT_SYS_GETPGRP
++#define __ARCH_WANT_SYS_LLSEEK
++#define __ARCH_WANT_SYS_NICE
++#define __ARCH_WANT_SYS_OLD_GETRLIMIT
++#define __ARCH_WANT_SYS_OLDUMOUNT
++#define __ARCH_WANT_SYS_SIGPENDING
++#define __ARCH_WANT_SYS_SIGPROCMASK
++#define __ARCH_WANT_SYS_RT_SIGACTION
++#endif
++
++#ifdef __KERNEL_SYSCALLS__
++
++/*
++ * we need this inline - forking from kernel space will result
++ * in NO COPY ON WRITE (!!!), until an execve is executed. This
++ * is no problem, but for the stack. This is handled by not letting
++ * main() use the stack at all after fork(). Thus, no function
++ * calls - which means inline code for fork too, as otherwise we
++ * would use the stack upon exit from 'fork()'.
++ *
++ * Actually only pause and fork are needed inline, so that there
++ * won't be any messing with the stack from main(), but we define
++ * some others too.
++ */
++#define __NR__exit __NR_exit
++static inline _syscall0(int,pause)
++static inline _syscall0(int,sync)
++static inline _syscall0(pid_t,setsid)
++static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
++static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
++static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
++static inline _syscall1(int,dup,int,fd)
++static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
++static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
++static inline _syscall1(int,close,int,fd)
++static inline _syscall1(int,_exit,int,exitcode)
++static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
++static inline _syscall1(int,delete_module,const char *,name)
++
++static inline pid_t wait(int * wait_stat)
++{
++ return waitpid(-1,wait_stat,0);
++}
++
++#endif
++
++/*
++ * "Conditional" syscalls
++ *
++ * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
++ * but it doesn't work on all toolchains, so we just do it by hand
++ */
++#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
++
++#endif /* _ASM_NIOS_UNISTD_H_ */
+--- linux/include/asm-nios2nommu/user.h
++++ linux/include/asm-nios2nommu/user.h
+@@ -0,0 +1,112 @@
++#ifndef _NIOS2NOMMU_USER_H
++#define _NIOS2NOMMU_USER_H
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/user.h
++ *
++ * Derived from M68knommu
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++#include <asm/page.h>
++
++/* Core file format: The core file is written in such a way that gdb
++ can understand it and provide useful information to the user (under
++ linux we use the 'trad-core' bfd). There are quite a number of
++ obstacles to being able to view the contents of the floating point
++ registers, and until these are solved you will not be able to view the
++ contents of them. Actually, you can read in the core file and look at
++ the contents of the user struct to find out what the floating point
++ registers contain.
++ The actual file contents are as follows:
++ UPAGE: 1 page consisting of a user struct that tells gdb what is present
++ in the file. Directly after this is a copy of the task_struct, which
++ is currently not used by gdb, but it may come in useful at some point.
++ All of the registers are stored as part of the upage. The upage should
++ always be only one page.
++ DATA: The data area is stored. We use current->end_text to
++ current->brk to pick up all of the user variables, plus any memory
++ that may have been malloced. No attempt is made to determine if a page
++ is demand-zero or if a page is totally unused, we just cover the entire
++ range. All of the addresses are rounded in such a way that an integral
++ number of pages is written.
++ STACK: We need the stack information in order to get a meaningful
++ backtrace. We need to write the data from (esp) to
++ current->start_stack, so we round each of these off in order to be able
++ to write an integer number of pages.
++ The minimum core file size is 3 pages, or 12288 bytes.
++*/
++
++struct user_m68kfp_struct {
++ unsigned long fpregs[8*3]; /* fp0-fp7 registers */
++ unsigned long fpcntl[3]; /* fp control regs */
++};
++
++/* This is needs more work, probably should look like gdb useage */
++struct user_regs_struct {
++ long r1,r2,r3,r4,r5,r6,r7,r8;
++ long r9,r10,r11,r12,r13,r14,r15;
++ long r16,r17,r18,r19,r20,r21,r22,r23;
++ long gp;
++ long sp;
++ long ra;
++ long fp;
++ long orig_r2;
++ long estatus;
++ long status_extension;
++ long ea;
++};
++
++
++/* When the kernel dumps core, it starts by dumping the user struct -
++ this will be used by gdb to figure out where the data and stack segments
++ are within the file, and what virtual addresses to use. */
++struct user{
++/* We start with the registers, to mimic the way that "memory" is returned
++ from the ptrace(3,...) function. */
++ struct user_regs_struct regs; /* Where the registers are actually stored */
++/* ptrace does not yet supply these. Someday.... */
++ int u_fpvalid; /* True if math co-processor being used. */
++ /* for this mess. Not yet used. */
++ struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
++/* The rest of this junk is to help gdb figure out what goes where */
++ unsigned long int u_tsize; /* Text segment size (pages). */
++ unsigned long int u_dsize; /* Data segment size (pages). */
++ unsigned long int u_ssize; /* Stack segment size (pages). */
++ unsigned long start_code; /* Starting virtual address of text. */
++ unsigned long start_stack; /* Starting virtual address of stack area.
++ This is actually the bottom of the stack,
++ the top of the stack is always found in the
++ esp register. */
++ long int signal; /* Signal that caused the core dump. */
++ int reserved; /* No longer used */
++ struct user_regs_struct *u_ar0;
++ /* Used by gdb to help find the values for */
++ /* the registers. */
++ struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
++ unsigned long magic; /* To uniquely identify a core file */
++ char u_comm[32]; /* User command that was responsible */
++};
++#define NBPG PAGE_SIZE
++#define UPAGES 1
++#define HOST_TEXT_START_ADDR (u.start_code)
++#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
++
++#endif
+--- linux/include/asm-nios2nommu/virtconvert.h
++++ linux/include/asm-nios2nommu/virtconvert.h
+@@ -0,0 +1,47 @@
++#ifndef __NIOS_VIRT_CONVERT__
++#define __NIOS_VIRT_CONVERT__
++
++/*--------------------------------------------------------------------
++ *
++ * include/asm-nios2nommu/virtconvert.h
++ *
++ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
++ *
++ * Copyright (C) 2004 Microtronix Datacom Ltd
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ *
++ * Jan/20/2004 dgt NiosII
++ *
++ ---------------------------------------------------------------------*/
++
++
++/*
++ * Macros used for converting between virtual and physical mappings.
++ */
++
++#ifdef __KERNEL__
++
++// #include <linux/config.h>
++#include <asm/setup.h>
++#include <asm/page.h>
++
++#define mm_ptov(vaddr) ((void *) (vaddr))
++#define mm_vtop(vaddr) ((unsigned long) (vaddr))
++#define phys_to_virt(vaddr) ((void *) (vaddr))
++#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
++
++#define virt_to_bus virt_to_phys
++#define bus_to_virt phys_to_virt
++
++#endif /*__KERNEL__ */
++#endif /*__NIOS_VIRT_CONVERT__*/
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-001-lzma-vmlinuz.00.patch b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-001-lzma-vmlinuz.00.patch
new file mode 100644
index 0000000000..87e50f8be7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-001-lzma-vmlinuz.00.patch
@@ -0,0 +1,27017 @@
+diff --git a/.miniconfig b/.miniconfig
+new file mode 100644
+index 0000000..5686e53
+--- /dev/null
++++ b/.miniconfig
+@@ -0,0 +1,89 @@
++#make allnoconfig KCONFIG_ALLCONFIG=miniconfig
++CONFIG_X86_32=y
++CONFIG_CLOCKSOURCE_WATCHDOG=y
++CONFIG_LOCKDEP_SUPPORT=y
++CONFIG_SEMAPHORE_SLEEPERS=y
++CONFIG_MMU=y
++CONFIG_GENERIC_ISA_DMA=y
++CONFIG_GENERIC_HWEIGHT=y
++CONFIG_DMI=y
++CONFIG_INIT_ENV_ARG_LIMIT=32
++CONFIG_IKCONFIG=y
++CONFIG_IKCONFIG_PROC=y
++CONFIG_SYSFS_DEPRECATED=y
++CONFIG_BLK_DEV_INITRD=y
++CONFIG_SYSCTL=y
++CONFIG_EMBEDDED=y
++CONFIG_PRINTK=y
++CONFIG_BASE_SMALL=1
++CONFIG_BLOCK=y
++CONFIG_IOSCHED_NOOP=y
++CONFIG_DEFAULT_IOSCHED="noop"
++CONFIG_X86_GENERIC=y
++CONFIG_X86_L1_CACHE_SHIFT=7
++CONFIG_GENERIC_CALIBRATE_DELAY=y
++CONFIG_X86_WP_WORKS_OK=y
++CONFIG_X86_BSWAP=y
++CONFIG_X86_CMPXCHG64=y
++CONFIG_X86_INTEL_USERCOPY=y
++CONFIG_X86_TSC=y
++CONFIG_PREEMPT_NONE=y
++CONFIG_VM86=y
++CONFIG_HIGHMEM=y
++CONFIG_FLATMEM=y
++CONFIG_MTRR=y
++CONFIG_HZ_250=y
++CONFIG_PHYSICAL_ALIGN=0x100000
++CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
++CONFIG_PM=y
++CONFIG_ACPI=y
++CONFIG_ACPI_SLEEP=y
++CONFIG_ACPI_BLACKLIST_YEAR=0
++CONFIG_ACPI_EC=y
++CONFIG_ACPI_SYSTEM=y
++CONFIG_PCI=y
++CONFIG_PCI_GOANY=y
++CONFIG_PCI_DIRECT=y
++CONFIG_BINFMT_ELF=y
++CONFIG_STANDALONE=y
++CONFIG_BLK_DEV_LOOP=y
++CONFIG_IDE=y
++CONFIG_IDE_MAX_HWIFS=2
++CONFIG_BLK_DEV_IDE=y
++CONFIG_BLK_DEV_IDEDISK=y
++CONFIG_IDEDISK_MULTI_MODE=y
++CONFIG_BLK_DEV_IDECD=y
++CONFIG_IDE_GENERIC=y
++CONFIG_INPUT_MOUSEDEV=y
++CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
++CONFIG_INPUT_KEYBOARD=y
++CONFIG_KEYBOARD_ATKBD=y
++CONFIG_SERIO=y
++CONFIG_VT=y
++CONFIG_VT_CONSOLE=y
++CONFIG_UNIX98_PTYS=y
++CONFIG_VGA_CONSOLE=y
++CONFIG_USB_ARCH_HAS_HCD=y
++CONFIG_USB_ARCH_HAS_EHCI=y
++CONFIG_EXT2_FS=y
++CONFIG_DNOTIFY=y
++CONFIG_ISO9660_FS=y
++CONFIG_FAT_FS=y
++CONFIG_VFAT_FS=y
++CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
++CONFIG_PROC_FS=y
++CONFIG_PROC_SYSCTL=y
++CONFIG_SYSFS=y
++CONFIG_RAMFS=y
++CONFIG_SQUASHFS=y
++CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
++CONFIG_MSDOS_PARTITION=y
++CONFIG_NLS_DEFAULT="iso8859-1"
++CONFIG_AUFS=y
++CONFIG_AUFS_FAKE_DM=y
++CONFIG_EARLY_PRINTK=y
++CONFIG_DOUBLEFAULT=y
++CONFIG_ZLIB_INFLATE=y
++CONFIG_HAS_IOPORT=y
++CONFIG_GENERIC_IRQ_PROBE=y
++CONFIG_KTIME_SCALAR=y
+diff --git a/Makefile b/Makefile
+index d970cb1..a369204 100644
+--- a/Makefile
++++ b/Makefile
+@@ -188,7 +188,7 @@ CROSS_COMPILE ?=
+ # Architecture as present in compile.h
+ UTS_MACHINE := $(ARCH)
+
+-KCONFIG_CONFIG ?= .config
++KCONFIG_CONFIG ?= .miniconfig
+
+ # SHELL used by kbuild
+ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+diff --git a/arch/i386/boot/compressed/LzmaDecode.c b/arch/i386/boot/compressed/LzmaDecode.c
+new file mode 100644
+index 0000000..21bf40b
+--- /dev/null
++++ b/arch/i386/boot/compressed/LzmaDecode.c
+@@ -0,0 +1,588 @@
++/*
++ LzmaDecode.c
++ LZMA Decoder (optimized for Speed version)
++
++ LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this Code, expressly permits you to
++ statically or dynamically link your Code (or bind by name) to the
++ interfaces of this file without subjecting your linked Code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#include "LzmaDecode.h"
++
++#ifndef Byte
++#define Byte unsigned char
++#endif
++
++#define kNumTopBits 24
++#define kTopValue ((UInt32)1 << kNumTopBits)
++
++#define kNumBitModelTotalBits 11
++#define kBitModelTotal (1 << kNumBitModelTotalBits)
++#define kNumMoveBits 5
++
++#define RC_READ_BYTE (*Buffer++)
++
++#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
++ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
++
++#ifdef _LZMA_IN_CB
++
++#define RC_TEST { if (Buffer == BufferLim) \
++ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
++ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
++
++#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
++
++#else
++
++#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
++
++#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
++
++#endif
++
++#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
++
++#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
++#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
++#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
++
++#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
++ { UpdateBit0(p); mi <<= 1; A0; } else \
++ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
++
++#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
++
++#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
++ { int i = numLevels; res = 1; \
++ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
++ res -= (1 << numLevels); }
++
++
++#define kNumPosBitsMax 4
++#define kNumPosStatesMax (1 << kNumPosBitsMax)
++
++#define kLenNumLowBits 3
++#define kLenNumLowSymbols (1 << kLenNumLowBits)
++#define kLenNumMidBits 3
++#define kLenNumMidSymbols (1 << kLenNumMidBits)
++#define kLenNumHighBits 8
++#define kLenNumHighSymbols (1 << kLenNumHighBits)
++
++#define LenChoice 0
++#define LenChoice2 (LenChoice + 1)
++#define LenLow (LenChoice2 + 1)
++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
++#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
++
++
++#define kNumStates 12
++#define kNumLitStates 7
++
++#define kStartPosModelIndex 4
++#define kEndPosModelIndex 14
++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
++
++#define kNumPosSlotBits 6
++#define kNumLenToPosStates 4
++
++#define kNumAlignBits 4
++#define kAlignTableSize (1 << kNumAlignBits)
++
++#define kMatchMinLen 2
++
++#define IsMatch 0
++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
++#define IsRepG0 (IsRep + kNumStates)
++#define IsRepG1 (IsRepG0 + kNumStates)
++#define IsRepG2 (IsRepG1 + kNumStates)
++#define IsRep0Long (IsRepG2 + kNumStates)
++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
++#define LenCoder (Align + kAlignTableSize)
++#define RepLenCoder (LenCoder + kNumLenProbs)
++#define Literal (RepLenCoder + kNumLenProbs)
++
++#if Literal != LZMA_BASE_SIZE
++StopCompilingDueBUG
++#endif
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
++{
++ unsigned char prop0;
++ if (size < LZMA_PROPERTIES_SIZE)
++ return LZMA_RESULT_DATA_ERROR;
++ prop0 = propsData[0];
++ if (prop0 >= (9 * 5 * 5))
++ return LZMA_RESULT_DATA_ERROR;
++ {
++ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
++ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
++ propsRes->lc = prop0;
++ /*
++ unsigned char remainder = (unsigned char)(prop0 / 9);
++ propsRes->lc = prop0 % 9;
++ propsRes->pb = remainder / 5;
++ propsRes->lp = remainder % 5;
++ */
++ }
++
++ #ifdef _LZMA_OUT_READ
++ {
++ int i;
++ propsRes->DictionarySize = 0;
++ for (i = 0; i < 4; i++)
++ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
++ if (propsRes->DictionarySize == 0)
++ propsRes->DictionarySize = 1;
++ }
++ #endif
++ return LZMA_RESULT_OK;
++}
++
++#define kLzmaStreamWasFinishedId (-1)
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *InCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
++{
++ CProb *p = vs->Probs;
++ SizeT nowPos = 0;
++ Byte previousByte = 0;
++ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
++ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
++ int lc = vs->Properties.lc;
++
++ #ifdef _LZMA_OUT_READ
++
++ UInt32 Range = vs->Range;
++ UInt32 Code = vs->Code;
++ #ifdef _LZMA_IN_CB
++ const Byte *Buffer = vs->Buffer;
++ const Byte *BufferLim = vs->BufferLim;
++ #else
++ const Byte *Buffer = inStream;
++ const Byte *BufferLim = inStream + inSize;
++ #endif
++ int state = vs->State;
++ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
++ int len = vs->RemainLen;
++ UInt32 globalPos = vs->GlobalPos;
++ UInt32 distanceLimit = vs->DistanceLimit;
++
++ Byte *dictionary = vs->Dictionary;
++ UInt32 dictionarySize = vs->Properties.DictionarySize;
++ UInt32 dictionaryPos = vs->DictionaryPos;
++
++ Byte tempDictionary[4];
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++ if (len == kLzmaStreamWasFinishedId)
++ return LZMA_RESULT_OK;
++
++ if (dictionarySize == 0)
++ {
++ dictionary = tempDictionary;
++ dictionarySize = 1;
++ tempDictionary[0] = vs->TempDictionary[0];
++ }
++
++ if (len == kLzmaNeedInitId)
++ {
++ {
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ UInt32 i;
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ rep0 = rep1 = rep2 = rep3 = 1;
++ state = 0;
++ globalPos = 0;
++ distanceLimit = 0;
++ dictionaryPos = 0;
++ dictionary[dictionarySize - 1] = 0;
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++ }
++ len = 0;
++ }
++ while(len != 0 && nowPos < outSize)
++ {
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ len--;
++ }
++ if (dictionaryPos == 0)
++ previousByte = dictionary[dictionarySize - 1];
++ else
++ previousByte = dictionary[dictionaryPos - 1];
++
++ #else /* if !_LZMA_OUT_READ */
++
++ int state = 0;
++ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
++ int len = 0;
++ const Byte *Buffer;
++ const Byte *BufferLim;
++ UInt32 Range;
++ UInt32 Code;
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++
++ {
++ UInt32 i;
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ }
++
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++
++ #endif /* _LZMA_OUT_READ */
++
++ while(nowPos < outSize)
++ {
++ CProb *prob;
++ UInt32 bound;
++ int posState = (int)(
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & posStateMask);
++
++ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ int symbol = 1;
++ UpdateBit0(prob)
++ prob = p + Literal + (LZMA_LIT_SIZE *
++ (((
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
++
++ if (state >= kNumLitStates)
++ {
++ int matchByte;
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ matchByte = dictionary[pos];
++ #else
++ matchByte = outStream[nowPos - rep0];
++ #endif
++ do
++ {
++ int bit;
++ CProb *probLit;
++ matchByte <<= 1;
++ bit = (matchByte & 0x100);
++ probLit = prob + 0x100 + bit + symbol;
++ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
++ }
++ while (symbol < 0x100);
++ }
++ while (symbol < 0x100)
++ {
++ CProb *probLit = prob + symbol;
++ RC_GET_BIT(probLit, symbol)
++ }
++ previousByte = (Byte)symbol;
++
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #endif
++ if (state < 4) state = 0;
++ else if (state < 10) state -= 3;
++ else state -= 6;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRep + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ rep3 = rep2;
++ rep2 = rep1;
++ rep1 = rep0;
++ state = state < kNumLitStates ? 0 : 3;
++ prob = p + LenCoder;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG0 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos;
++ #endif
++ UpdateBit0(prob);
++
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit == 0)
++ #else
++ if (nowPos == 0)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ state = state < kNumLitStates ? 9 : 11;
++ #ifdef _LZMA_OUT_READ
++ pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++ #endif
++
++ continue;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ }
++ }
++ else
++ {
++ UInt32 distance;
++ UpdateBit1(prob);
++ prob = p + IsRepG1 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep1;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG2 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep2;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ distance = rep3;
++ rep3 = rep2;
++ }
++ rep2 = rep1;
++ }
++ rep1 = rep0;
++ rep0 = distance;
++ }
++ state = state < kNumLitStates ? 8 : 11;
++ prob = p + RepLenCoder;
++ }
++ {
++ int numBits, offset;
++ CProb *probLen = prob + LenChoice;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenLow + (posState << kLenNumLowBits);
++ offset = 0;
++ numBits = kLenNumLowBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenChoice2;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenMid + (posState << kLenNumMidBits);
++ offset = kLenNumLowSymbols;
++ numBits = kLenNumMidBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenHigh;
++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
++ numBits = kLenNumHighBits;
++ }
++ }
++ RangeDecoderBitTreeDecode(probLen, numBits, len);
++ len += offset;
++ }
++
++ if (state < 4)
++ {
++ int posSlot;
++ state += kNumLitStates;
++ prob = p + PosSlot +
++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
++ kNumPosSlotBits);
++ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
++ if (posSlot >= kStartPosModelIndex)
++ {
++ int numDirectBits = ((posSlot >> 1) - 1);
++ rep0 = (2 | ((UInt32)posSlot & 1));
++ if (posSlot < kEndPosModelIndex)
++ {
++ rep0 <<= numDirectBits;
++ prob = p + SpecPos + rep0 - posSlot - 1;
++ }
++ else
++ {
++ numDirectBits -= kNumAlignBits;
++ do
++ {
++ RC_NORMALIZE
++ Range >>= 1;
++ rep0 <<= 1;
++ if (Code >= Range)
++ {
++ Code -= Range;
++ rep0 |= 1;
++ }
++ }
++ while (--numDirectBits != 0);
++ prob = p + Align;
++ rep0 <<= kNumAlignBits;
++ numDirectBits = kNumAlignBits;
++ }
++ {
++ int i = 1;
++ int mi = 1;
++ do
++ {
++ CProb *prob3 = prob + mi;
++ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
++ i <<= 1;
++ }
++ while(--numDirectBits != 0);
++ }
++ }
++ else
++ rep0 = posSlot;
++ if (++rep0 == (UInt32)(0))
++ {
++ /* it's for stream version */
++ len = kLzmaStreamWasFinishedId;
++ break;
++ }
++ }
++
++ len += kMatchMinLen;
++ #ifdef _LZMA_OUT_READ
++ if (rep0 > distanceLimit)
++ #else
++ if (rep0 > nowPos)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ #ifdef _LZMA_OUT_READ
++ if (dictionarySize - distanceLimit > (UInt32)len)
++ distanceLimit += len;
++ else
++ distanceLimit = dictionarySize;
++ #endif
++
++ do
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ len--;
++ outStream[nowPos++] = previousByte;
++ }
++ while(len != 0 && nowPos < outSize);
++ }
++ }
++ RC_NORMALIZE;
++
++ #ifdef _LZMA_OUT_READ
++ vs->Range = Range;
++ vs->Code = Code;
++ vs->DictionaryPos = dictionaryPos;
++ vs->GlobalPos = globalPos + (UInt32)nowPos;
++ vs->DistanceLimit = distanceLimit;
++ vs->Reps[0] = rep0;
++ vs->Reps[1] = rep1;
++ vs->Reps[2] = rep2;
++ vs->Reps[3] = rep3;
++ vs->State = state;
++ vs->RemainLen = len;
++ vs->TempDictionary[0] = tempDictionary[0];
++ #endif
++
++ #ifdef _LZMA_IN_CB
++ vs->Buffer = Buffer;
++ vs->BufferLim = BufferLim;
++ #else
++ *inSizeProcessed = (SizeT)(Buffer - inStream);
++ #endif
++ *outSizeProcessed = nowPos;
++ return LZMA_RESULT_OK;
++}
+diff --git a/arch/i386/boot/compressed/LzmaDecode.h b/arch/i386/boot/compressed/LzmaDecode.h
+new file mode 100644
+index 0000000..213062a
+--- /dev/null
++++ b/arch/i386/boot/compressed/LzmaDecode.h
+@@ -0,0 +1,131 @@
++/*
++ LzmaDecode.h
++ LZMA Decoder interface
++
++ LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this code, expressly permits you to
++ statically or dynamically link your code (or bind by name) to the
++ interfaces of this file without subjecting your linked code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#ifndef __LZMADECODE_H
++#define __LZMADECODE_H
++
++/* #define _LZMA_IN_CB */
++/* Use callback for input data */
++
++/* #define _LZMA_OUT_READ */
++/* Use read function for output data */
++
++/* #define _LZMA_PROB32 */
++/* It can increase speed on some 32-bit CPUs,
++ but memory usage will be doubled in that case */
++
++/* #define _LZMA_LOC_OPT */
++/* Enable local speed optimizations inside code */
++
++/* #define _LZMA_SYSTEM_SIZE_T */
++/* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
++
++#ifndef UInt32
++#ifdef _LZMA_UINT32_IS_ULONG
++#define UInt32 unsigned long
++#else
++#define UInt32 unsigned int
++#endif
++#endif
++
++#ifndef SizeT
++#ifdef _LZMA_SYSTEM_SIZE_T
++#include <stddef.h>
++#define SizeT size_t
++#else
++#define SizeT UInt32
++#endif
++#endif
++
++#ifdef _LZMA_PROB32
++#define CProb UInt32
++#else
++#define CProb unsigned short
++#endif
++
++#define LZMA_RESULT_OK 0
++#define LZMA_RESULT_DATA_ERROR 1
++
++#ifdef _LZMA_IN_CB
++typedef struct _ILzmaInCallback
++{
++ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
++} ILzmaInCallback;
++#endif
++
++#define LZMA_BASE_SIZE 1846
++#define LZMA_LIT_SIZE 768
++
++#define LZMA_PROPERTIES_SIZE 5
++
++typedef struct _CLzmaProperties
++{
++ int lc;
++ int lp;
++ int pb;
++ #ifdef _LZMA_OUT_READ
++ UInt32 DictionarySize;
++ #endif
++}CLzmaProperties;
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
++
++#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
++
++#define kLzmaNeedInitId (-2)
++
++typedef struct _CLzmaDecoderState
++{
++ CLzmaProperties Properties;
++ CProb *Probs;
++
++ #ifdef _LZMA_IN_CB
++ const unsigned char *Buffer;
++ const unsigned char *BufferLim;
++ #endif
++
++ #ifdef _LZMA_OUT_READ
++ unsigned char *Dictionary;
++ UInt32 Range;
++ UInt32 Code;
++ UInt32 DictionaryPos;
++ UInt32 GlobalPos;
++ UInt32 DistanceLimit;
++ UInt32 Reps[4];
++ int State;
++ int RemainLen;
++ unsigned char TempDictionary[4];
++ #endif
++} CLzmaDecoderState;
++
++#ifdef _LZMA_OUT_READ
++#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
++#endif
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *inCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
++
++#endif
+diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile
+index a661217..fb40869 100644
+--- a/arch/i386/boot/compressed/Makefile
++++ b/arch/i386/boot/compressed/Makefile
+@@ -4,15 +4,16 @@
+ # create a compressed vmlinux image from the original vmlinux
+ #
+
+-targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o \
+- vmlinux.bin.all vmlinux.relocs
++tragets := head.o lzma_misc.o piggy.o \
++ vmlinux.bin.all vmlinux.relocs \
++ vmlinux vmlinux.bin vmlinux.bin.gz
+ EXTRA_AFLAGS := -traditional
+
+ LDFLAGS_vmlinux := -T
+-CFLAGS_misc.o += -fPIC
++CFLAGS_lzma_misc.o += -fPIC
+ hostprogs-y := relocs
+
+-$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
++$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/lzma_misc.o $(obj)/piggy.o FORCE
+ $(call if_changed,ld)
+ @:
+
+@@ -33,10 +34,10 @@ $(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
+
+ ifdef CONFIG_RELOCATABLE
+ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
+- $(call if_changed,gzip)
++ $(call if_changed,lzma)
+ else
+ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+- $(call if_changed,gzip)
++ $(call if_changed,lzma)
+ endif
+
+ LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
+diff --git a/arch/i386/boot/compressed/lzma_misc.c b/arch/i386/boot/compressed/lzma_misc.c
+new file mode 100644
+index 0000000..4f5f7f9
+--- /dev/null
++++ b/arch/i386/boot/compressed/lzma_misc.c
+@@ -0,0 +1,290 @@
++/*
++ * lzma_misc.c
++ *
++ * Decompress LZMA compressed vmlinuz
++ * Version 0.9 Copyright (c) Ming-Ching Tiew mctiew@yahoo.com
++ * Program adapted from misc.c for 2.6.20.1 kernel
++ * Please refer to misc.c for authorship and copyright.
++ * Date: 25 March 2007
++ * Source released under GPL
++ */
++
++#undef CONFIG_PARAVIRT
++#include <linux/linkage.h>
++#include <linux/vmalloc.h>
++#include <linux/screen_info.h>
++#include <asm/io.h>
++#include <asm/page.h>
++#include <asm/boot.h>
++
++/* WARNING!!
++ * This code is compiled with -fPIC and it is relocated dynamically
++ * at run time, but no relocation processing is performed.
++ * This means that it is not safe to place pointers in static structures.
++ */
++
++#define OF(args) args
++#define STATIC static
++
++#undef memset
++#undef memcpy
++
++typedef unsigned char uch;
++typedef unsigned short ush;
++typedef unsigned long ulg;
++
++#define WSIZE 0x80000000 /* Window size must be at least 32k,
++ * and a power of two
++ * We don't actually have a window just
++ * a huge output buffer so I report
++ * a 2G windows size, as that should
++ * always be larger than our output buffer.
++ */
++
++static uch *inbuf; /* input buffer */
++static uch *window; /* Sliding window buffer, (and final output buffer) */
++
++static unsigned insize; /* valid bytes in inbuf */
++static unsigned inptr; /* index of next byte to be processed in inbuf */
++
++/* gzip flag byte */
++#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
++#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
++#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
++#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
++#define COMMENT 0x10 /* bit 4 set: file comment present */
++#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
++#define RESERVED 0xC0 /* bit 6,7: reserved */
++
++#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
++
++/* Diagnostic functions */
++#ifdef DEBUG
++# define Assert(cond,msg) {if(!(cond)) error(msg);}
++# define Trace(x) fprintf x
++# define Tracev(x) {if (verbose) fprintf x ;}
++# define Tracevv(x) {if (verbose>1) fprintf x ;}
++# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
++# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
++#else
++# define Assert(cond,msg)
++# define Trace(x)
++# define Tracev(x)
++# define Tracevv(x)
++# define Tracec(c,x)
++# define Tracecv(c,x)
++#endif
++
++static int fill_inbuf(void);
++static void error(char *m);
++
++/*
++ * This is set up by the setup-routine at boot-time
++ */
++static unsigned char *real_mode; /* Pointer to real-mode data */
++
++#define RM_EXT_MEM_K (*(unsigned short *)(real_mode + 0x2))
++#ifndef STANDARD_MEMORY_BIOS_CALL
++#define RM_ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0))
++#endif
++#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
++
++extern unsigned char input_data[];
++extern int input_len;
++
++static long bytes_out = 0;
++
++static void *memcpy(void *dest, const void *src, unsigned n);
++
++static void putstr(const char *);
++
++static unsigned long free_mem_ptr;
++static unsigned long free_mem_end_ptr;
++
++#define HEAP_SIZE 0x3000
++
++static char *vidmem = (char *)0xb8000;
++static int vidport;
++static int lines, cols;
++
++#ifdef CONFIG_X86_NUMAQ
++void *xquad_portio;
++#endif
++
++static void scroll(void)
++{
++ int i;
++
++ memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
++ for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
++ vidmem[i] = ' ';
++}
++
++static void putstr(const char *s)
++{
++ int x,y,pos;
++ char c;
++
++ x = RM_SCREEN_INFO.orig_x;
++ y = RM_SCREEN_INFO.orig_y;
++
++ while ( ( c = *s++ ) != '\0' ) {
++ if ( c == '\n' ) {
++ x = 0;
++ if ( ++y >= lines ) {
++ scroll();
++ y--;
++ }
++ } else {
++ vidmem [ ( x + cols * y ) * 2 ] = c;
++ if ( ++x >= cols ) {
++ x = 0;
++ if ( ++y >= lines ) {
++ scroll();
++ y--;
++ }
++ }
++ }
++ }
++
++ RM_SCREEN_INFO.orig_x = x;
++ RM_SCREEN_INFO.orig_y = y;
++
++ pos = (x + cols * y) * 2; /* Update cursor position */
++ outb_p(14, vidport);
++ outb_p(0xff & (pos >> 9), vidport+1);
++ outb_p(15, vidport);
++ outb_p(0xff & (pos >> 1), vidport+1);
++}
++
++static void* memcpy(void* dest, const void* src, unsigned n)
++{
++ int i;
++ char *d = (char *)dest, *s = (char *)src;
++
++ for (i=0;i<n;i++) d[i] = s[i];
++ return dest;
++}
++
++/* ===========================================================================
++ * Fill the input buffer. This is called only when the buffer is empty
++ * and at least one byte is really needed.
++ */
++static int fill_inbuf(void)
++{
++ error("ran out of input data");
++ return 0;
++}
++
++/* ===========================================================================
++ */
++static void error(char *x)
++{
++ putstr("\n\n");
++ putstr(x);
++ putstr("\n\n -- System halted");
++
++ while(1); /* Halt */
++}
++
++#define _LZMA_IN_CB
++#include "LzmaDecode.h"
++#include "LzmaDecode.c"
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize);
++
++/*
++ * Do the lzma decompression
++ */
++static int lzma_unzip(uch* output)
++{
++
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++
++ ILzmaInCallback callback;
++ callback.Read = read_byte;
++
++ // lzma args
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ // skip dictionary size
++ for (i = 0; i < 4; i++)
++ get_byte();
++ // get uncompressed size
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // skip high order bytes
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ // Just point it beyond
++ state.Probs = (CProb*) ( free_mem_ptr );
++ // decompress kernel
++ if (LzmaDecode( &state, &callback,
++ (unsigned char*)output, uncompressedSize, &i) == LZMA_RESULT_OK)
++ {
++ if ( i != uncompressedSize )
++ error( "kernel corrupted!\n");
++ bytes_out = i;
++ return 0;
++ }
++ return 1;
++}
++
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned int i = 0;
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++asmlinkage void decompress_kernel(void *rmode, unsigned long end,
++ uch *input_data, unsigned long input_len, uch *output)
++{
++ real_mode = rmode;
++
++ if (RM_SCREEN_INFO.orig_video_mode == 7) {
++ vidmem = (char *) 0xb0000;
++ vidport = 0x3b4;
++ } else {
++ vidmem = (char *) 0xb8000;
++ vidport = 0x3d4;
++ }
++
++ lines = RM_SCREEN_INFO.orig_video_lines;
++ cols = RM_SCREEN_INFO.orig_video_cols;
++
++ window = output; /* Output buffer (Normally at 1M) */
++ free_mem_ptr = end; /* Heap */
++ free_mem_end_ptr = end + HEAP_SIZE;
++ inbuf = input_data; /* Input buffer */
++ insize = input_len;
++ inptr = 0;
++
++ if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
++ error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
++ if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
++ error("Destination address too large");
++#ifndef CONFIG_RELOCATABLE
++ if ((u32)output != LOAD_PHYSICAL_ADDR)
++ error("Wrong destination address");
++#endif
++ if( lzma_unzip(output) != 0 )
++ {
++ error("inflate error\n");
++ }
++ putstr("Ok, booting the kernel.\n");
++
++ return;
++}
+diff --git a/arch/i386/boot/compressed/vmlinux.scr b/arch/i386/boot/compressed/vmlinux.scr
+index 707a88f..9d67263 100644
+--- a/arch/i386/boot/compressed/vmlinux.scr
++++ b/arch/i386/boot/compressed/vmlinux.scr
+@@ -3,8 +3,8 @@ SECTIONS
+ .data.compressed : {
+ input_len = .;
+ LONG(input_data_end - input_data) input_data = .;
++ output_len = . + 5;
+ *(.data)
+- output_len = . - 4;
+ input_data_end = .;
+ }
+ }
+diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
+index 17ee97f..64b7bda 100644
+--- a/drivers/block/Kconfig
++++ b/drivers/block/Kconfig
+@@ -406,6 +406,47 @@ config BLK_DEV_RAM_BLOCKSIZE
+ setups function - apparently needed by the rd_load_image routine
+ that supposes the filesystem in the image uses a 1024 blocksize.
+
++config LZMA_INITRD
++ boolean "Allow LZMA compression on initrd"
++ depends on BLK_DEV_INITRD=y
++ default "y"
++ help
++ Use lzma compression on initrd, example 'lzma e initrd initrd.7z -d16'.
++ If you have sufficient memory, you could compress using bigger dictionary size,
++ 'lzma e initrd initrd.7z'.
++
++config LZMA_INITRD_KMALLOC_ONLY
++ boolean "Use only kmalloc, do not use vmalloc on lzma initrd"
++ depends on LZMA_INITRD=y
++ default "n"
++ help
++ Set to y if you do not want to use vmalloc, ie use only kmalloc.
++
++config LZMA_INITRAM_FS
++ boolean "Allow LZMA compression on initramfs"
++ depends on BLK_DEV_RAM=y
++ default "y"
++ help
++ Use lzma compression on initramfs, example 'lzma e initramfs.cpio initramfs.cpio.lzma'.
++
++config LZMA_INITRAM_FS_SMALLMEM
++ boolean "Use lzma compression with small dictonary size."
++ depends on LZMA_INITRAM_FS=y
++ default "y"
++ help
++ Use lzma compression on initramfs with small dictionary size, example
++ 'lzma e initramfs.cpio initramfs.cpio.lzma -d16'.
++ Affects only the initramfs.cpio in the ~usr directory, which is compiled into
++ the kernel. If you prepared initramfs.cpio for use with bootloader, you would
++ need to specify the commandline options (-d16) yourself.
++
++config LZMA_INITRAM_FS_KMALLOC_ONLY
++ boolean "Use only kmalloc, do not use vmalloc on lzma initramfs"
++ depends on LZMA_INITRAM_FS=y
++ default "n"
++ help
++ Set to y if you do not want to use vmalloc, ie use only kmalloc.
++
+ config CDROM_PKTCDVD
+ tristate "Packet writing on CD/DVD media"
+ depends on !UML
+diff --git a/fs/Kconfig b/fs/Kconfig
+index 3c4886b..bdcc6fb 100644
+--- a/fs/Kconfig
++++ b/fs/Kconfig
+@@ -1371,6 +1371,71 @@ config CRAMFS
+
+ If unsure, say N.
+
++config SQUASHFS
++ tristate "SquashFS 3.2 - Squashed file system support"
++ select ZLIB_INFLATE
++ help
++ Saying Y here includes support for SquashFS 3.2 (a Compressed Read-Only File
++ System). Squashfs is a highly compressed read-only filesystem for Linux.
++ It uses zlib compression to compress both files, inodes and directories.
++ Inodes in the system are very small and all blocks are packed to minimise
++ data overhead. Block sizes greater than 4K are supported up to a maximum of 64K.
++ SquashFS 3.1 supports 64 bit filesystems and files (larger than 4GB), full
++ uid/gid information, hard links and timestamps.
++
++ Squashfs is intended for general read-only filesystem use, for archival
++ use (i.e. in cases where a .tar.gz file may be used), and in embedded
++ systems where low overhead is needed. Further information and filesystem tools
++ are available from http://squashfs.sourceforge.net.
++
++ If you want to compile this as a module ( = code which can be
++ inserted in and removed from the running kernel whenever you want),
++ say M here and read <file:Documentation/modules.txt>. The module
++ will be called squashfs. Note that the root file system (the one
++ containing the directory /) cannot be compiled as a module.
++
++ If unsure, say N.
++
++config SQUASHFS_EMBEDDED
++
++ bool "Additional options for memory-constrained systems"
++ depends on SQUASHFS
++ default n
++ help
++ Saying Y here allows you to specify cache sizes and how Squashfs
++ allocates memory. This is only intended for memory constrained
++ systems.
++
++ If unsure, say N.
++
++config SQUASHFS_FRAGMENT_CACHE_SIZE
++ int "Number of fragments cached" if SQUASHFS_EMBEDDED
++ depends on SQUASHFS
++ default "3"
++ help
++ By default SquashFS caches the last 3 fragments read from
++ the filesystem. Increasing this amount may mean SquashFS
++ has to re-read fragments less often from disk, at the expense
++ of extra system memory. Decreasing this amount will mean
++ SquashFS uses less memory at the expense of extra reads from disk.
++
++ Note there must be at least one cached fragment. Anything
++ much more than three will probably not make much difference.
++
++config SQUASHFS_VMALLOC
++ bool "Use Vmalloc rather than Kmalloc" if SQUASHFS_EMBEDDED
++ depends on SQUASHFS
++ default n
++ help
++ By default SquashFS uses kmalloc to obtain fragment cache memory.
++ Kmalloc memory is the standard kernel allocator, but it can fail
++ on memory constrained systems. Because of the way Vmalloc works,
++ Vmalloc can succeed when kmalloc fails. Specifying this option
++ will make SquashFS always use Vmalloc to allocate the
++ fragment cache memory.
++
++ If unsure, say N.
++
+ config VXFS_FS
+ tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
+ depends on BLOCK
+@@ -2057,3 +2122,4 @@ source "fs/dlm/Kconfig"
+
+ endmenu
+
++source "fs/aufs/Kconfig"
+diff --git a/fs/Makefile b/fs/Makefile
+index 9edf411..557766f 100644
+--- a/fs/Makefile
++++ b/fs/Makefile
+@@ -68,6 +68,7 @@ obj-$(CONFIG_JBD) += jbd/
+ obj-$(CONFIG_JBD2) += jbd2/
+ obj-$(CONFIG_EXT2_FS) += ext2/
+ obj-$(CONFIG_CRAMFS) += cramfs/
++obj-$(CONFIG_SQUASHFS) += squashfs/
+ obj-$(CONFIG_RAMFS) += ramfs/
+ obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
+ obj-$(CONFIG_CODA_FS) += coda/
+@@ -114,3 +115,4 @@ obj-$(CONFIG_HPPFS) += hppfs/
+ obj-$(CONFIG_DEBUG_FS) += debugfs/
+ obj-$(CONFIG_OCFS2_FS) += ocfs2/
+ obj-$(CONFIG_GFS2_FS) += gfs2/
++obj-$(CONFIG_AUFS) += aufs/
+diff --git a/fs/aufs/Kconfig b/fs/aufs/Kconfig
+new file mode 100644
+index 0000000..3a2121c
+--- /dev/null
++++ b/fs/aufs/Kconfig
+@@ -0,0 +1,73 @@
++config AUFS
++ tristate "Another unionfs"
++ help
++ Aufs is a stackable unification filesystem such as Unionfs,
++ which unifies several directories and provides a merged single
++ directory.
++ In the early days, aufs was entirely re-designed and
++ re-implemented Unionfs Version 1.x series. After many original
++ ideas, approaches and improvements, it becomes totally
++ different from Unionfs while keeping the basic features.
++ See Unionfs for the basic features.
++
++if AUFS
++comment "These options are generated automatically for "#UTS_RELEASE
++
++config AUFS_FAKE_DM
++ bool "Use simplified (fake) nameidata"
++ depends on AUFS
++ default y
++ help
++ Faking nameidata (VFS internal data), you can get better performance
++ in some cases.
++
++choice
++ prompt "Maximum number of branches"
++ depends on AUFS
++ default AUFS_BRANCH_MAX_127
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_127
++ bool "127"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_511
++ bool "511"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_1023
++ bool "1023"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++
++config AUFS_BRANCH_MAX_32767
++ bool "32767"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++endchoice
++config AUFS_DEBUG
++ bool "Debug aufs"
++ depends on AUFS
++ default y
++ help
++ Enable this to compile aufs internal debug code.
++ The performance will be damaged.
++
++config AUFS_COMPAT
++ bool "Compatibility with Unionfs (obsolete)"
++ depends on AUFS
++ default n
++ help
++ This makes aufs compatible with unionfs-style mount options and some
++ behaviours.
++ The dirs= mount option and =nfsro branch permission flag are always
++ interpreted as br: mount option and =ro flag respectively. The
++ 'debug', 'delete' and 'imap' mount options are ignored.
++ If you disable this option, you will get,
++ - aufs issues a warning about the ignored mount options
++ - the default branch permission flag is set. RW for the first branch,
++ and RO for the rests.
++ - the name of a internal file which represents the directory is
++ 'opaque', becomes '.wh..wh..opq'
++ - the 'diropq=w' mount option is set by default
++endif
+diff --git a/fs/aufs/Makefile b/fs/aufs/Makefile
+new file mode 100755
+index 0000000..0ee3cd0
+--- /dev/null
++++ b/fs/aufs/Makefile
+@@ -0,0 +1,18 @@
++# AUFS Makefile for the Linux 2.6.16 and later
++# $Id: Makefile,v 1.29 2007/04/23 00:59:50 sfjro Exp $
++
++obj-$(CONFIG_AUFS) += aufs.o
++aufs-y := module.o super.o sbinfo.o xino.o \
++ branch.o cpup.o whout.o plink.o wkq.o dcsub.o vfsub.o \
++ opts.o \
++ dentry.o dinfo.o \
++ file.o f_op.o finfo.o \
++ dir.o vdir.o \
++ inode.o i_op.o i_op_add.o i_op_del.o i_op_ren.o iinfo.o \
++ misc.o
++#xattr.o
++aufs-$(CONFIG_AUFS_SYSAUFS) += sysaufs.o
++aufs-$(CONFIG_AUFS_HINOTIFY) += hinotify.o
++aufs-$(CONFIG_AUFS_EXPORT) += export.o
++#aufs-$(CONFIG_DEBUGFS) += dbgfs.o
++aufs-$(CONFIG_AUFS_DEBUG) += debug.o
+diff --git a/fs/aufs/aufs.h b/fs/aufs/aufs.h
+new file mode 100755
+index 0000000..79b3b87
+--- /dev/null
++++ b/fs/aufs/aufs.h
+@@ -0,0 +1,64 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: aufs.h,v 1.24 2007/05/14 03:41:51 sfjro Exp $ */
++
++#ifndef __AUFS_H__
++#define __AUFS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/version.h>
++
++/* limited support before 2.6.16, curretly 2.6.15 only. */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
++#define atomic_long_t atomic_t
++#define atomic_long_set atomic_set
++#define timespec_to_ns(ts) ({(long long)(ts)->tv_sec;})
++#define D_CHILD d_child
++#else
++#define D_CHILD d_u.d_child
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++#include "debug.h"
++
++#include "branch.h"
++#include "cpup.h"
++#include "dcsub.h"
++#include "dentry.h"
++#include "dir.h"
++#include "file.h"
++#include "inode.h"
++#include "misc.h"
++#include "module.h"
++#include "opts.h"
++#include "super.h"
++#include "sysaufs.h"
++#include "vfsub.h"
++#include "whout.h"
++#include "wkq.h"
++//#include "xattr.h"
++
++#if defined(CONFIG_AUFS_MODULE) && !defined(CONFIG_AUFS_KSIZE_PATCH)
++#define ksize(p) (-1U)
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_H__ */
+diff --git a/fs/aufs/branch.c b/fs/aufs/branch.c
+new file mode 100755
+index 0000000..f1ce008
+--- /dev/null
++++ b/fs/aufs/branch.c
+@@ -0,0 +1,818 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: branch.c,v 1.49 2007/05/14 03:38:23 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++static void free_branch(struct aufs_branch *br)
++{
++ TraceEnter();
++
++ if (br->br_xino)
++ fput(br->br_xino);
++ dput(br->br_wh);
++ dput(br->br_plink);
++ mntput(br->br_mnt);
++ DEBUG_ON(br_count(br) || atomic_read(&br->br_wh_running));
++ kfree(br);
++}
++
++/*
++ * frees all branches
++ */
++void free_branches(struct aufs_sbinfo *sbinfo)
++{
++ aufs_bindex_t bmax;
++ struct aufs_branch **br;
++
++ TraceEnter();
++ bmax = sbinfo->si_bend + 1;
++ br = sbinfo->si_branch;
++ while (bmax--)
++ free_branch(*br++);
++}
++
++/*
++ * find the index of a branch which is specified by @br_id.
++ */
++int find_brindex(struct super_block *sb, aufs_bindex_t br_id)
++{
++ aufs_bindex_t bindex, bend;
++
++ TraceEnter();
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (sbr_id(sb, bindex) == br_id)
++ return bindex;
++ return -1;
++}
++
++/*
++ * test if the @br is readonly or not.
++ */
++int br_rdonly(struct aufs_branch *br)
++{
++ return ((br->br_mnt->mnt_sb->s_flags & MS_RDONLY)
++ || !br_writable(br->br_perm))
++ ? -EROFS : 0;
++}
++
++/*
++ * returns writable branch index, otherwise an error.
++ * todo: customizable writable-branch-policy
++ */
++static int find_rw_parent(struct dentry *dentry, aufs_bindex_t bend)
++{
++ int err;
++ aufs_bindex_t bindex, candidate;
++ struct super_block *sb;
++ struct dentry *parent, *hidden_parent;
++
++ err = bend;
++ sb = dentry->d_sb;
++ parent = dget_parent(dentry);
++#if 1 // branch policy
++ hidden_parent = au_h_dptr_i(parent, bend);
++ if (hidden_parent && !br_rdonly(stobr(sb, bend)))
++ goto out; /* success */
++#endif
++
++ candidate = -1;
++ for (bindex = dbstart(parent); bindex <= bend; bindex++) {
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ if (hidden_parent && !br_rdonly(stobr(sb, bindex))) {
++#if 0 // branch policy
++ if (candidate == -1)
++ candidate = bindex;
++ if (!au_test_perm(hidden_parent->d_inode, MAY_WRITE))
++ return bindex;
++#endif
++ err = bindex;
++ goto out; /* success */
++ }
++ }
++#if 0 // branch policy
++ err = candidate;
++ if (candidate != -1)
++ goto out; /* success */
++#endif
++ err = -EROFS;
++
++ out:
++ dput(parent);
++ return err;
++}
++
++int find_rw_br(struct super_block *sb, aufs_bindex_t bend)
++{
++ aufs_bindex_t bindex;
++
++ for (bindex = bend; bindex >= 0; bindex--)
++ if (!br_rdonly(stobr(sb, bindex)))
++ return bindex;
++ return -EROFS;
++}
++
++int find_rw_parent_br(struct dentry *dentry, aufs_bindex_t bend)
++{
++ int err;
++
++ err = find_rw_parent(dentry, bend);
++ if (err >= 0)
++ return err;
++ return find_rw_br(dentry->d_sb, bend);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if two hidden_dentries have overlapping branches.
++ */
++//todo: try is_subdir()
++static int do_is_overlap(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ struct dentry *d;
++
++ d = hidden_d1;
++ do {
++ if (unlikely(d == hidden_d2))
++ return 1;
++ d = d->d_parent; // dget_parent()
++ } while (!IS_ROOT(d));
++
++ return (d == hidden_d2);
++}
++
++#if defined(CONFIG_BLK_DEV_LOOP) || defined(CONFIG_BLK_DEV_LOOP_MODULE)
++#include <linux/loop.h>
++static int is_overlap_loopback(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ struct inode *hidden_inode;
++ struct loop_device *l;
++
++ hidden_inode = hidden_d1->d_inode;
++ if (MAJOR(hidden_inode->i_sb->s_dev) != LOOP_MAJOR)
++ return 0;
++
++ l = hidden_inode->i_sb->s_bdev->bd_disk->private_data;
++ hidden_d1 = l->lo_backing_file->f_dentry;
++ if (unlikely(hidden_d1->d_sb == sb))
++ return 1;
++ return do_is_overlap(sb, hidden_d1, hidden_d2);
++}
++#else
++#define is_overlap_loopback(sb, hidden_d1, hidden_d2) 0
++#endif
++
++static int is_overlap(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ LKTRTrace("d1 %.*s, d2 %.*s\n", DLNPair(hidden_d1), DLNPair(hidden_d2));
++ if (unlikely(hidden_d1 == hidden_d2))
++ return 1;
++ return do_is_overlap(sb, hidden_d1, hidden_d2)
++ || do_is_overlap(sb, hidden_d2, hidden_d1)
++ || is_overlap_loopback(sb, hidden_d1, hidden_d2)
++ || is_overlap_loopback(sb, hidden_d2, hidden_d1);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int init_br_wh(struct super_block *sb, aufs_bindex_t bindex,
++ struct aufs_branch *br, int new_perm,
++ struct dentry *h_root, struct vfsmount *h_mnt)
++{
++ int err, old_perm;
++ struct inode *dir = sb->s_root->d_inode,
++ *h_dir = h_root->d_inode;
++ const int new = (bindex < 0);
++
++ LKTRTrace("b%d, new_perm %d\n", bindex, new_perm);
++
++ if (new)
++ hi_lock_parent(h_dir);
++ else
++ hdir_lock(h_dir, dir, bindex);
++
++ br_wh_write_lock(br);
++ old_perm = br->br_perm;
++ br->br_perm = new_perm;
++ err = init_wh(h_root, br, au_do_nfsmnt(h_mnt), sb);
++ br->br_perm = old_perm;
++ br_wh_write_unlock(br);
++
++ if (new)
++ i_unlock(h_dir);
++ else
++ hdir_unlock(h_dir, dir, bindex);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * returns a newly allocated branch. @new_nbranch is a number of branches
++ * after adding a branch.
++ */
++static struct aufs_branch *alloc_addbr(struct super_block *sb, int new_nbranch)
++{
++ struct aufs_branch **branchp, *add_branch;
++ int sz;
++ void *p;
++ struct dentry *root;
++ struct inode *inode;
++ struct aufs_hinode *hinodep;
++ struct aufs_hdentry *hdentryp;
++
++ LKTRTrace("new_nbranch %d\n", new_nbranch);
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ IiMustWriteLock(inode);
++
++ add_branch = kmalloc(sizeof(*add_branch), GFP_KERNEL);
++ //if (LktrCond) {kfree(add_branch); add_branch = NULL;}
++ if (unlikely(!add_branch))
++ goto out;
++
++ sz = sizeof(*branchp) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*branchp);
++ p = stosi(sb)->si_branch;
++ branchp = au_kzrealloc(p, sz, sizeof(*branchp) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) branchp = NULL;
++ if (unlikely(!branchp))
++ goto out;
++ stosi(sb)->si_branch = branchp;
++
++ sz = sizeof(*hdentryp) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*hdentryp);
++ p = dtodi(root)->di_hdentry;
++ hdentryp = au_kzrealloc(p, sz, sizeof(*hdentryp) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) hdentryp = NULL;
++ if (unlikely(!hdentryp))
++ goto out;
++ dtodi(root)->di_hdentry = hdentryp;
++
++ sz = sizeof(*hinodep) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*hinodep);
++ p = itoii(inode)->ii_hinode;
++ hinodep = au_kzrealloc(p, sz, sizeof(*hinodep) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) hinodep = NULL; // unavailable test
++ if (unlikely(!hinodep))
++ goto out;
++ itoii(inode)->ii_hinode = hinodep;
++ return add_branch; /* success */
++
++ out:
++ kfree(add_branch);
++ TraceErr(-ENOMEM);
++ return ERR_PTR(-ENOMEM);
++}
++
++/*
++ * test if the branch permission is legal or not.
++ */
++static int test_br(struct super_block *sb, struct inode *inode, int brperm,
++ char *path)
++{
++ int err;
++
++ err = 0;
++ if (unlikely(br_writable(brperm) && IS_RDONLY(inode))) {
++ Err("write permission for readonly fs or inode, %s\n", path);
++ err = -EINVAL;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * retunrs,,,
++ * 0: success, the caller will add it
++ * plus: success, it is already unified, the caller should ignore it
++ * minus: error
++ */
++static int test_add(struct super_block *sb, struct opt_add *add, int remount)
++{
++ int err;
++ struct dentry *root;
++ struct inode *inode, *hidden_inode;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%s, remo%d\n", add->path, remount);
++
++ root = sb->s_root;
++ if (unlikely(au_find_dbindex(root, add->nd.dentry) != -1)) {
++ err = 1;
++ if (!remount) {
++ err = -EINVAL;
++ Err("%s duplicated\n", add->path);
++ }
++ goto out;
++ }
++
++ err = -ENOSPC; //-E2BIG;
++ bend = sbend(sb);
++ //if (LktrCond) bend = AUFS_BRANCH_MAX;
++ if (unlikely(AUFS_BRANCH_MAX <= add->bindex
++ || AUFS_BRANCH_MAX - 1 <= bend)) {
++ Err("number of branches exceeded %s\n", add->path);
++ goto out;
++ }
++
++ err = -EDOM;
++ if (unlikely(add->bindex < 0 || bend + 1 < add->bindex)) {
++ Err("bad index %d\n", add->bindex);
++ goto out;
++ }
++
++ inode = add->nd.dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++ err = -ENOENT;
++ if (unlikely(!inode->i_nlink)) {
++ Err("no existence %s\n", add->path);
++ goto out;
++ }
++
++ err = -EINVAL;
++ if (unlikely(inode->i_sb == sb)) {
++ Err("%s must be outside\n", add->path);
++ goto out;
++ }
++
++#if 1 //ndef CONFIG_AUFS_ROBR
++ if (unlikely(au_is_aufs(inode->i_sb)
++ || !strcmp(au_sbtype(inode->i_sb), "unionfs"))) {
++ Err("nested " AUFS_NAME " %s\n", add->path);
++ goto out;
++ }
++#endif
++
++#ifdef AuNoNfsBranch
++ if (unlikely(au_is_nfs(inode->i_sb))) {
++ Err(AuNoNfsBranchMsg ". %s\n", add->path);
++ goto out;
++ }
++#endif
++
++ err = test_br(sb, add->nd.dentry->d_inode, add->perm, add->path);
++ if (unlikely(err))
++ goto out;
++
++ if (unlikely(bend == -1))
++ return 0; /* success */
++
++ hidden_inode = au_h_dptr(root)->d_inode;
++ if (unlikely(au_flag_test(sb, AuFlag_WARN_PERM)
++ && ((hidden_inode->i_mode & S_IALLUGO)
++ != (inode->i_mode & S_IALLUGO)
++ || hidden_inode->i_uid != inode->i_uid
++ || hidden_inode->i_gid != inode->i_gid)))
++ Warn("uid/gid/perm %s %u/%u/0%o, %u/%u/0%o\n",
++ add->path,
++ inode->i_uid, inode->i_gid, (inode->i_mode & S_IALLUGO),
++ hidden_inode->i_uid, hidden_inode->i_gid,
++ (hidden_inode->i_mode & S_IALLUGO));
++
++ err = -EINVAL;
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(is_overlap(sb, add->nd.dentry,
++ au_h_dptr_i(root, bindex)))) {
++ Err("%s is overlapped\n", add->path);
++ goto out;
++ }
++ err = 0;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int br_add(struct super_block *sb, struct opt_add *add, int remount)
++{
++ int err, sz;
++ aufs_bindex_t bend, add_bindex;
++ struct dentry *root;
++ struct aufs_iinfo *iinfo;
++ struct aufs_sbinfo *sbinfo;
++ struct aufs_dinfo *dinfo;
++ struct inode *root_inode;
++ unsigned long long maxb;
++ struct aufs_branch **branchp, *add_branch;
++ struct aufs_hdentry *hdentryp;
++ struct aufs_hinode *hinodep;
++
++ LKTRTrace("b%d, %s, 0x%x, %.*s\n", add->bindex, add->path,
++ add->perm, DLNPair(add->nd.dentry));
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ root_inode = root->d_inode;
++ IMustLock(root_inode);
++ IiMustWriteLock(root_inode);
++
++ err = test_add(sb, add, remount);
++ if (unlikely(err < 0))
++ goto out;
++ if (unlikely(err))
++ return 0; /* success */
++
++ bend = sbend(sb);
++ add_branch = alloc_addbr(sb, bend + 2);
++ err = PTR_ERR(add_branch);
++ if (IS_ERR(add_branch))
++ goto out;
++
++ err = 0;
++ rw_init_nolock(&add_branch->br_wh_rwsem);
++ add_branch->br_wh = add_branch->br_plink = NULL;
++ if (unlikely(br_writable(add->perm))) {
++ err = init_br_wh(sb, /*bindex*/-1, add_branch, add->perm,
++ add->nd.dentry, add->nd.mnt);
++ if (unlikely(err)) {
++ kfree(add_branch);
++ goto out;
++ }
++ }
++ add_branch->br_xino = NULL;
++ add_branch->br_mnt = mntget(add->nd.mnt);
++ atomic_set(&add_branch->br_wh_running, 0);
++ add_branch->br_id = new_br_id(sb);
++ add_branch->br_perm = add->perm;
++ atomic_set(&add_branch->br_count, 0);
++
++ sbinfo = stosi(sb);
++ dinfo = dtodi(root);
++ iinfo = itoii(root_inode);
++
++ add_bindex = add->bindex;
++ sz = sizeof(*(sbinfo->si_branch)) * (bend + 1 - add_bindex);
++ branchp = sbinfo->si_branch + add_bindex;
++ memmove(branchp + 1, branchp, sz);
++ *branchp = add_branch;
++ sz = sizeof(*hdentryp) * (bend + 1 - add_bindex);
++ hdentryp = dinfo->di_hdentry + add_bindex;
++ memmove(hdentryp + 1, hdentryp, sz);
++ hdentryp->hd_dentry = NULL;
++ sz = sizeof(*hinodep) * (bend + 1 - add_bindex);
++ hinodep = iinfo->ii_hinode + add_bindex;
++ memmove(hinodep + 1, hinodep, sz);
++ hinodep->hi_inode = NULL;
++ hinodep->hi_notify = NULL;
++
++ sbinfo->si_bend++;
++ dinfo->di_bend++;
++ iinfo->ii_bend++;
++ if (unlikely(bend == -1)) {
++ dinfo->di_bstart = 0;
++ iinfo->ii_bstart = 0;
++ }
++ set_h_dptr(root, add_bindex, dget(add->nd.dentry));
++ set_h_iptr(root_inode, add_bindex, igrab(add->nd.dentry->d_inode), 0);
++ if (!add_bindex)
++ au_cpup_attr_all(root_inode);
++ else
++ au_add_nlink(root_inode, add->nd.dentry->d_inode);
++ maxb = add->nd.dentry->d_sb->s_maxbytes;
++ if (sb->s_maxbytes < maxb)
++ sb->s_maxbytes = maxb;
++
++ if (au_flag_test(sb, AuFlag_XINO)) {
++ struct file *base_file = stobr(sb, 0)->br_xino;
++ if (!add_bindex)
++ base_file = stobr(sb, 1)->br_xino;
++ err = xino_init(sb, add_bindex, base_file, /*do_test*/1);
++ if (unlikely(err)) {
++ DEBUG_ON(add_branch->br_xino);
++ Err("ignored xino err %d, force noxino\n", err);
++ err = 0;
++ au_flag_clr(sb, AuFlag_XINO);
++ }
++ }
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if the branch is deletable or not.
++ */
++static int test_children_busy(struct dentry *root, aufs_bindex_t bindex)
++{
++ int err, i, j, sigen;
++ struct au_dcsub_pages dpages;
++
++ LKTRTrace("b%d\n", bindex);
++ SiMustWriteLock(root->d_sb);
++ DiMustWriteLock(root);
++
++ err = au_dpages_init(&dpages, GFP_KERNEL);
++ if (unlikely(err))
++ goto out;
++ err = au_dcsub_pages(&dpages, root, NULL, NULL);
++ if (unlikely(err))
++ goto out_dpages;
++
++ sigen = au_sigen(root->d_sb);
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++ for (i = 0; !err && i < dpages.ndpage; i++) {
++ struct au_dpage *dpage;
++ dpage = dpages.dpages + i;
++ for (j = 0; !err && j < dpage->ndentry; j++) {
++ struct dentry *d;
++
++ d = dpage->dentries[j];
++ if (au_digen(d) == sigen)
++ di_read_lock_child(d, AUFS_I_RLOCK);
++ else {
++ di_write_lock_child(d);
++ err = au_reval_dpath(d, sigen);
++ if (!err)
++ di_downgrade_lock(d, AUFS_I_RLOCK);
++ else {
++ di_write_unlock(d);
++ break;
++ }
++ }
++
++ if (au_h_dptr_i(d, bindex)
++ && (!S_ISDIR(d->d_inode->i_mode)
++ || dbstart(d) == dbend(d)))
++ err = -EBUSY;
++ di_read_unlock(d, AUFS_I_RLOCK);
++ if (err)
++ LKTRTrace("%.*s\n", DLNPair(d));
++ }
++ }
++ di_write_lock_child(root); /* aufs_write_lock() calls ..._child() */
++
++ out_dpages:
++ au_dpages_free(&dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int br_del(struct super_block *sb, struct opt_del *del, int remount)
++{
++ int err, do_wh, rerr;
++ struct dentry *root;
++ struct inode *inode, *hidden_dir;
++ aufs_bindex_t bindex, bend, br_id;
++ struct aufs_sbinfo *sbinfo;
++ struct aufs_dinfo *dinfo;
++ struct aufs_iinfo *iinfo;
++ struct aufs_branch *br;
++
++ LKTRTrace("%s, %.*s\n", del->path, DLNPair(del->h_root));
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ IiMustWriteLock(inode);
++
++ bindex = au_find_dbindex(root, del->h_root);
++ if (unlikely(bindex < 0)) {
++ if (remount)
++ return 0; /* success */
++ err = -ENOENT;
++ Err("%s no such branch\n", del->path);
++ goto out;
++ }
++ LKTRTrace("bindex b%d\n", bindex);
++
++ err = -EBUSY;
++ bend = sbend(sb);
++ br = stobr(sb, bindex);
++ if (unlikely(!bend || br_count(br))) {
++ LKTRTrace("bend %d, br_count %d\n", bend, br_count(br));
++ goto out;
++ }
++
++ do_wh = 0;
++ hidden_dir = del->h_root->d_inode;
++ if (unlikely(br->br_wh || br->br_plink)) {
++#if 0
++ /* remove whiteout base */
++ err = init_br_wh(sb, bindex, br, AuBr_RO, del->h_root,
++ br->br_mnt);
++ if (unlikely(err))
++ goto out;
++#else
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++#endif
++ do_wh = 1;
++ }
++
++ err = test_children_busy(root, bindex);
++ if (unlikely(err)) {
++ if (unlikely(do_wh))
++ goto out_wh;
++ goto out;
++ }
++
++ err = 0;
++ sbinfo = stosi(sb);
++ dinfo = dtodi(root);
++ iinfo = itoii(inode);
++
++ dput(au_h_dptr_i(root, bindex));
++ aufs_hiput(iinfo->ii_hinode + bindex);
++ br_id = br->br_id;
++ free_branch(br);
++
++ //todo: realloc and shrink memeory
++ if (bindex < bend) {
++ const aufs_bindex_t n = bend - bindex;
++ struct aufs_branch **brp;
++ struct aufs_hdentry *hdp;
++ struct aufs_hinode *hip;
++
++ brp = sbinfo->si_branch + bindex;
++ memmove(brp, brp + 1, sizeof(*brp) * n);
++ hdp = dinfo->di_hdentry + bindex;
++ memmove(hdp, hdp + 1, sizeof(*hdp) * n);
++ hip = iinfo->ii_hinode + bindex;
++ memmove(hip, hip + 1, sizeof(*hip) * n);
++ }
++ sbinfo->si_branch[0 + bend] = NULL;
++ dinfo->di_hdentry[0 + bend].hd_dentry = NULL;
++ iinfo->ii_hinode[0 + bend].hi_inode = NULL;
++ iinfo->ii_hinode[0 + bend].hi_notify = NULL;
++
++ sbinfo->si_bend--;
++ dinfo->di_bend--;
++ iinfo->ii_bend--;
++ if (!bindex)
++ au_cpup_attr_all(inode);
++ else
++ au_sub_nlink(inode, del->h_root->d_inode);
++ if (au_flag_test(sb, AuFlag_PLINK))
++ half_refresh_plink(sb, br_id);
++
++ if (sb->s_maxbytes == del->h_root->d_sb->s_maxbytes) {
++ bend--;
++ sb->s_maxbytes = 0;
++ for (bindex = 0; bindex <= bend; bindex++) {
++ unsigned long long maxb;
++ maxb = sbr_sb(sb, bindex)->s_maxbytes;
++ if (sb->s_maxbytes < maxb)
++ sb->s_maxbytes = maxb;
++ }
++ }
++ goto out; /* success */
++
++ out_wh:
++ /* revert */
++ rerr = init_br_wh(sb, bindex, br, br->br_perm, del->h_root, br->br_mnt);
++ if (rerr)
++ Warn("failed re-creating base whiteout, %s. (%d)\n",
++ del->path, rerr);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int do_need_sigen_inc(int a, int b)
++{
++ return (br_whable(a) && !br_whable(b));
++}
++
++static int need_sigen_inc(int old, int new)
++{
++ return (do_need_sigen_inc(old, new)
++ || do_need_sigen_inc(new, old));
++}
++
++int br_mod(struct super_block *sb, struct opt_mod *mod, int remount,
++ int *do_update)
++{
++ int err;
++ struct dentry *root;
++ aufs_bindex_t bindex;
++ struct aufs_branch *br;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%s, %.*s, 0x%x\n",
++ mod->path, DLNPair(mod->h_root), mod->perm);
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ IiMustWriteLock(root->d_inode);
++
++ bindex = au_find_dbindex(root, mod->h_root);
++ if (unlikely(bindex < 0)) {
++ if (remount)
++ return 0; /* success */
++ err = -ENOENT;
++ Err("%s no such branch\n", mod->path);
++ goto out;
++ }
++ LKTRTrace("bindex b%d\n", bindex);
++
++ hidden_dir = mod->h_root->d_inode;
++ err = test_br(sb, hidden_dir, mod->perm, mod->path);
++ if (unlikely(err))
++ goto out;
++
++ br = stobr(sb, bindex);
++ if (unlikely(br->br_perm == mod->perm))
++ return 0; /* success */
++
++ if (br_writable(br->br_perm)) {
++#if 1
++ /* remove whiteout base */
++ //todo: mod->perm?
++ err = init_br_wh(sb, bindex, br, AuBr_RO, mod->h_root,
++ br->br_mnt);
++ if (unlikely(err))
++ goto out;
++#else
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++#endif
++
++ if (!br_writable(mod->perm)) {
++ /* rw --> ro, file might be mmapped */
++ struct file *file, *hf;
++
++#if 1 // test here
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++
++ // no need file_list_lock() since sbinfo is locked
++ //file_list_lock();
++ list_for_each_entry(file, &sb->s_files, f_u.fu_list) {
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++ fi_read_lock(file);
++ if (!S_ISREG(file->f_dentry->d_inode->i_mode)
++ || !(file->f_mode & FMODE_WRITE)
++ || fbstart(file) != bindex) {
++ FiMustNoWaiters(file);
++ fi_read_unlock(file);
++ continue;
++ }
++
++ // todo: already flushed?
++ hf = au_h_fptr(file);
++ hf->f_flags = au_file_roflags(hf->f_flags);
++ hf->f_mode &= ~FMODE_WRITE;
++ FiMustNoWaiters(file);
++ fi_read_unlock(file);
++ }
++ //file_list_unlock();
++
++ /* aufs_write_lock() calls ..._child() */
++ di_write_lock_child(root);
++#endif
++ }
++ }
++
++ *do_update |= need_sigen_inc(br->br_perm, mod->perm);
++ br->br_perm = mod->perm;
++ return err; /* success */
++
++ out:
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/branch.h b/fs/aufs/branch.h
+new file mode 100755
+index 0000000..2557836
+--- /dev/null
++++ b/fs/aufs/branch.h
+@@ -0,0 +1,235 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: branch.h,v 1.30 2007/05/14 03:41:51 sfjro Exp $ */
++
++#ifndef __AUFS_BRANCH_H__
++#define __AUFS_BRANCH_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/mount.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "super.h"
++
++/* protected by superblock rwsem */
++struct aufs_branch {
++ struct file *br_xino;
++ readf_t br_xino_read;
++ writef_t br_xino_write;
++
++ aufs_bindex_t br_id;
++
++ int br_perm;
++ struct vfsmount *br_mnt;
++ atomic_t br_count;
++
++ /* whiteout base */
++ struct aufs_rwsem br_wh_rwsem;
++ struct dentry *br_wh;
++ atomic_t br_wh_running;
++
++ /* pseudo-link dir */
++ struct dentry *br_plink;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* branch permission and attribute */
++enum {
++ AuBr_RW, /* writable, linkable wh */
++ AuBr_RO, /* readonly, no wh */
++ AuBr_RR, /* natively readonly, no wh */
++
++ AuBr_RWNoLinkWH, /* un-linkable whiteouts */
++
++ AuBr_ROWH,
++ AuBr_RRWH, /* whiteout-able */
++
++ AuBr_Last
++};
++
++static inline int br_writable(int brperm)
++{
++ return (brperm == AuBr_RW
++ || brperm == AuBr_RWNoLinkWH);
++}
++
++static inline int br_whable(int brperm)
++{
++ return (brperm == AuBr_RW
++ || brperm == AuBr_ROWH
++ || brperm == AuBr_RRWH);
++}
++
++static inline int br_linkable_wh(int brperm)
++{
++ return (brperm == AuBr_RW);
++}
++
++/* ---------------------------------------------------------------------- */
++
++#define _AuNoNfsBranchMsg "NFS branch is not supported"
++#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
++#define AuNoNfsBranch
++#define AuNoNfsBranchMsg _AuNoNfsBranchMsg
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) \
++ && !defined(CONFIG_AUFS_LHASH_PATCH)
++#define AuNoNfsBranch
++#define AuNoNfsBranchMsg _AuNoNfsBranchMsg \
++ ", try lhash.patch and CONFIG_AUFS_LHASH_PATCH"
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_sbinfo;
++void free_branches(struct aufs_sbinfo *sinfo);
++int br_rdonly(struct aufs_branch *br);
++int find_brindex(struct super_block *sb, aufs_bindex_t br_id);
++int find_rw_br(struct super_block *sb, aufs_bindex_t bend);
++int find_rw_parent_br(struct dentry *dentry, aufs_bindex_t bend);
++struct opt_add;
++int br_add(struct super_block *sb, struct opt_add *add, int remount);
++struct opt_del;
++int br_del(struct super_block *sb, struct opt_del *del, int remount);
++struct opt_mod;
++int br_mod(struct super_block *sb, struct opt_mod *mod, int remount,
++ int *do_update);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int br_count(struct aufs_branch *br)
++{
++ return atomic_read(&br->br_count);
++}
++
++static inline void br_get(struct aufs_branch *br)
++{
++ atomic_inc(&br->br_count);
++}
++
++static inline void br_put(struct aufs_branch *br)
++{
++ atomic_dec(&br->br_count);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Superblock to branch */
++static inline aufs_bindex_t sbr_id(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_id;
++}
++
++static inline
++struct vfsmount *sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_mnt;
++}
++
++static inline
++struct super_block *sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return sbr_mnt(sb, bindex)->mnt_sb;
++}
++
++#if 0
++static inline int sbr_count(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return br_count(stobr(sb, bindex));
++}
++
++static inline void sbr_get(struct super_block *sb, aufs_bindex_t bindex)
++{
++ br_get(stobr(sb, bindex));
++}
++#endif
++
++static inline void sbr_put(struct super_block *sb, aufs_bindex_t bindex)
++{
++ br_put(stobr(sb, bindex));
++}
++
++static inline int sbr_perm(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_perm;
++}
++
++static inline int sbr_is_whable(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return br_whable(sbr_perm(sb, bindex));
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_LHASH_PATCH
++static inline struct vfsmount *au_do_nfsmnt(struct vfsmount *h_mnt)
++{
++ if (!au_is_nfs(h_mnt->mnt_sb))
++ return NULL;
++ return h_mnt;
++}
++
++/* it doesn't mntget() */
++static inline
++struct vfsmount *au_nfsmnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return au_do_nfsmnt(sbr_mnt(sb, bindex));
++}
++#else
++static inline struct vfsmount *au_do_nfsmnt(struct vfsmount *h_mnt)
++{
++ return NULL;
++}
++
++static inline
++struct vfsmount *au_nfsmnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return NULL;
++}
++#endif /* CONFIG_AUFS_LHASH_PATCH */
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * br_wh_read_lock, br_wh_write_lock
++ * br_wh_read_unlock, br_wh_write_unlock, br_wh_downgrade_lock
++ */
++SimpleRwsemFuncs(br_wh, struct aufs_branch *br, br->br_wh_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define BrWhMustReadLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustReadLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#define BrWhMustWriteLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustWriteLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#define BrWhMustAnyLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustAnyLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_BRANCH_H__ */
+diff --git a/fs/aufs/cpup.c b/fs/aufs/cpup.c
+new file mode 100755
+index 0000000..6636f40
+--- /dev/null
++++ b/fs/aufs/cpup.c
+@@ -0,0 +1,773 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: cpup.c,v 1.37 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++/* violent cpup_attr_*() functions don't care inode lock */
++void au_cpup_attr_timesizes(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++ //IMustLock(!hidden_inode);
++
++ inode->i_atime = hidden_inode->i_atime;
++ inode->i_mtime = hidden_inode->i_mtime;
++ inode->i_ctime = hidden_inode->i_ctime;
++ spin_lock(&inode->i_lock);
++ i_size_write(inode, i_size_read(hidden_inode));
++ inode->i_blocks = hidden_inode->i_blocks;
++ spin_unlock(&inode->i_lock);
++}
++
++void au_cpup_attr_nlink(struct inode *inode)
++{
++ struct inode *h_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ DEBUG_ON(!inode->i_mode);
++
++ h_inode = au_h_iptr(inode);
++ inode->i_nlink = h_inode->i_nlink;
++
++ /*
++ * fewer nlink makes find(1) noisy, but larger nlink doesn't.
++ * it may includes whplink directory.
++ */
++ if (unlikely(S_ISDIR(h_inode->i_mode))) {
++ aufs_bindex_t bindex, bend;
++ bend = ibend(inode);
++ for (bindex = ibstart(inode) + 1; bindex <= bend; bindex++) {
++ h_inode = au_h_iptr_i(inode, bindex);
++ if (h_inode)
++ au_add_nlink(inode, h_inode);
++ }
++ }
++}
++
++void au_cpup_attr_changable(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++
++ inode->i_mode = hidden_inode->i_mode;
++ inode->i_uid = hidden_inode->i_uid;
++ inode->i_gid = hidden_inode->i_gid;
++ au_cpup_attr_timesizes(inode);
++
++ //??
++ inode->i_flags = hidden_inode->i_flags;
++}
++
++void au_cpup_igen(struct inode *inode, struct inode *h_inode)
++{
++ inode->i_generation = h_inode->i_generation;
++ itoii(inode)->ii_hsb1 = h_inode->i_sb;
++}
++
++void au_cpup_attr_all(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++
++ au_cpup_attr_changable(inode);
++ if (inode->i_nlink > 0)
++ au_cpup_attr_nlink(inode);
++
++ switch (inode->i_mode & S_IFMT) {
++ case S_IFBLK:
++ case S_IFCHR:
++ inode->i_rdev = hidden_inode->i_rdev;
++ }
++ inode->i_blkbits = hidden_inode->i_blkbits;
++ au_cpup_attr_blksize(inode, hidden_inode);
++ au_cpup_igen(inode, hidden_inode);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Note: dt_dentry and dt_hidden_dentry are not dget/dput-ed */
++
++/* keep the timestamps of the parent dir when cpup */
++void dtime_store(struct dtime *dt, struct dentry *dentry,
++ struct dentry *hidden_dentry)
++{
++ struct inode *inode;
++
++ TraceEnter();
++ DEBUG_ON(!dentry || !hidden_dentry || !hidden_dentry->d_inode);
++
++ dt->dt_dentry = dentry;
++ dt->dt_h_dentry = hidden_dentry;
++ inode = hidden_dentry->d_inode;
++ dt->dt_atime = inode->i_atime;
++ dt->dt_mtime = inode->i_mtime;
++ //smp_mb();
++}
++
++// todo: remove extra parameter
++void dtime_revert(struct dtime *dt, int h_parent_is_locked)
++{
++ struct iattr attr;
++ int err;
++ struct dentry *dentry;
++
++ LKTRTrace("h_parent locked %d\n", h_parent_is_locked);
++
++ attr.ia_atime = dt->dt_atime;
++ attr.ia_mtime = dt->dt_mtime;
++ attr.ia_valid = ATTR_FORCE | ATTR_MTIME | ATTR_MTIME_SET
++ | ATTR_ATIME | ATTR_ATIME_SET;
++ //smp_mb();
++ dentry = NULL;
++ if (!h_parent_is_locked /* && !IS_ROOT(dt->dt_dentry) */)
++ dentry = dt->dt_dentry;
++ err = vfsub_notify_change(dt->dt_h_dentry, &attr,
++ need_dlgt(dt->dt_dentry->d_sb));
++ if (unlikely(err))
++ Warn("restoring timestamps failed(%d). ignored\n", err);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int cpup_iattr(struct dentry *hidden_dst, struct dentry *hidden_src,
++ int dlgt)
++{
++ int err;
++ struct iattr ia;
++ struct inode *hidden_isrc, *hidden_idst;
++
++ LKTRTrace("%.*s\n", DLNPair(hidden_dst));
++ hidden_idst = hidden_dst->d_inode;
++ //IMustLock(hidden_idst);
++ hidden_isrc = hidden_src->d_inode;
++ //IMustLock(hidden_isrc);
++
++ ia.ia_valid = ATTR_FORCE | ATTR_MODE | ATTR_UID | ATTR_GID
++ | ATTR_ATIME | ATTR_MTIME
++ | ATTR_ATIME_SET | ATTR_MTIME_SET;
++ ia.ia_mode = hidden_isrc->i_mode;
++ ia.ia_uid = hidden_isrc->i_uid;
++ ia.ia_gid = hidden_isrc->i_gid;
++ ia.ia_atime = hidden_isrc->i_atime;
++ ia.ia_mtime = hidden_isrc->i_mtime;
++ err = vfsub_notify_change(hidden_dst, &ia, dlgt);
++ //if (LktrCond) err = -1;
++ if (!err)
++ hidden_idst->i_flags = hidden_isrc->i_flags; //??
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * to support a sparse file which is opened with O_APPEND,
++ * we need to close the file.
++ */
++static int cpup_regular(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len)
++{
++ int err, i, sparse;
++ struct super_block *sb;
++ struct inode *hidden_inode;
++ enum {SRC, DST};
++ struct {
++ aufs_bindex_t bindex;
++ unsigned int flags;
++ struct dentry *dentry;
++ struct file *file;
++ void *label, *label_file;
++ } *h, hidden[] = {
++ {
++ .bindex = bsrc,
++ .flags = O_RDONLY | O_NOATIME | O_LARGEFILE,
++ .file = NULL,
++ .label = &&out,
++ .label_file = &&out_src_file
++ },
++ {
++ .bindex = bdst,
++ .flags = O_WRONLY | O_NOATIME | O_LARGEFILE,
++ .file = NULL,
++ .label = &&out_src_file,
++ .label_file = &&out_dst_file
++ }
++ };
++
++ LKTRTrace("dentry %.*s, bdst %d, bsrc %d, len %lld\n",
++ DLNPair(dentry), bdst, bsrc, len);
++ DEBUG_ON(bsrc <= bdst);
++ DEBUG_ON(!len);
++ sb = dentry->d_sb;
++ DEBUG_ON(test_ro(sb, bdst, dentry->d_inode));
++ // bsrc branch can be ro/rw.
++
++ h = hidden;
++ for (i = 0; i < 2; i++, h++) {
++ h->dentry = au_h_dptr_i(dentry, h->bindex);
++ DEBUG_ON(!h->dentry);
++ hidden_inode = h->dentry->d_inode;
++ DEBUG_ON(!hidden_inode || !S_ISREG(hidden_inode->i_mode));
++ h->file = hidden_open(dentry, h->bindex, h->flags);
++ //if (LktrCond)
++ //{fput(h->file); sbr_put(sb, h->bindex); h->file = ERR_PTR(-1);}
++ err = PTR_ERR(h->file);
++ if (IS_ERR(h->file))
++ goto *h->label;
++ err = -EINVAL;
++ if (unlikely(!h->file->f_op))
++ goto *h->label_file;
++ }
++
++ /* stop updating while we copyup */
++ IMustLock(hidden[SRC].dentry->d_inode);
++ sparse = 0;
++ err = au_copy_file(hidden[DST].file, hidden[SRC].file, len, sb,
++ &sparse);
++
++ /* sparse file: update i_blocks next time */
++ if (unlikely(!err && sparse))
++ d_drop(dentry);
++
++ out_dst_file:
++ fput(hidden[DST].file);
++ sbr_put(sb, hidden[DST].bindex);
++ out_src_file:
++ fput(hidden[SRC].file);
++ sbr_put(sb, hidden[SRC].bindex);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++// unnecessary?
++unsigned int au_flags_cpup(unsigned int init, struct dentry *parent)
++{
++ if (unlikely(parent && IS_ROOT(parent)))
++ init |= CPUP_LOCKED_GHDIR;
++ return init;
++}
++
++/* return with hidden dst inode is locked */
++static int cpup_entry(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
++ int dlgt)
++{
++ int err, isdir, symlen;
++ struct dentry *hidden_src, *hidden_dst, *hidden_parent, *parent;
++ struct inode *hidden_inode, *hidden_dir, *dir;
++ struct dtime dt;
++ umode_t mode;
++ char *sym;
++ mm_segment_t old_fs;
++ const int do_dt = flags & CPUP_DTIME;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++ sb = dentry->d_sb;
++ DEBUG_ON(bdst >= bsrc || test_ro(sb, bdst, NULL));
++ // bsrc branch can be ro/rw.
++
++ hidden_src = au_h_dptr_i(dentry, bsrc);
++ DEBUG_ON(!hidden_src);
++ hidden_inode = hidden_src->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ /* stop refrencing while we are creating */
++ //parent = dget_parent(dentry);
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ hidden_dst = au_h_dptr_i(dentry, bdst);
++ DEBUG_ON(hidden_dst && hidden_dst->d_inode);
++ //hidden_parent = dget_parent(hidden_dst);
++ hidden_parent = hidden_dst->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ if (do_dt)
++ dtime_store(&dt, parent, hidden_parent);
++
++ isdir = 0;
++ mode = hidden_inode->i_mode;
++ switch (mode & S_IFMT) {
++ case S_IFREG:
++ /* stop updating while we are referencing */
++ IMustLock(hidden_inode);
++ err = vfsub_create(hidden_dir, hidden_dst, mode | S_IWUSR, NULL,
++ dlgt);
++ //if (LktrCond) {vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ if (!err) {
++ loff_t l = i_size_read(hidden_inode);
++ if (len == -1 || l < len)
++ len = l;
++ if (len) {
++ err = cpup_regular(dentry, bdst, bsrc, len);
++ //if (LktrCond) err = -1;
++ }
++ if (unlikely(err)) {
++ int rerr;
++ rerr = vfsub_unlink(hidden_dir, hidden_dst,
++ dlgt);
++ if (rerr) {
++ IOErr("failed unlinking cpup-ed %.*s"
++ "(%d, %d)\n",
++ DLNPair(hidden_dst), err, rerr);
++ err = -EIO;
++ }
++ }
++ }
++ break;
++ case S_IFDIR:
++ isdir = 1;
++ err = vfsub_mkdir(hidden_dir, hidden_dst, mode, dlgt);
++ //if (LktrCond) {vfs_rmdir(hidden_dir, hidden_dst); err = -1;}
++ if (!err) {
++ /* setattr case: dir is not locked */
++ if (0 && ibstart(dir) == bdst)
++ au_cpup_attr_nlink(dir);
++ au_cpup_attr_nlink(dentry->d_inode);
++ }
++ break;
++ case S_IFLNK:
++ err = -ENOMEM;
++ sym = __getname();
++ //if (LktrCond) {__putname(sym); sym = NULL;}
++ if (unlikely(!sym))
++ break;
++ old_fs = get_fs();
++ set_fs(KERNEL_DS);
++ err = symlen = hidden_inode->i_op->readlink
++ (hidden_src, (char __user*)sym, PATH_MAX);
++ //if (LktrCond) err = symlen = -1;
++ set_fs(old_fs);
++ if (symlen > 0) {
++ sym[symlen] = 0;
++ err = vfsub_symlink(hidden_dir, hidden_dst, sym, mode,
++ dlgt);
++ //if (LktrCond)
++ //{vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ }
++ __putname(sym);
++ break;
++ case S_IFCHR:
++ case S_IFBLK:
++ DEBUG_ON(!capable(CAP_MKNOD));
++ /*FALLTHROUGH*/
++ case S_IFIFO:
++ case S_IFSOCK:
++ err = vfsub_mknod(hidden_dir, hidden_dst, mode,
++ hidden_inode->i_rdev, dlgt);
++ //if (LktrCond) {vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ break;
++ default:
++ IOErr("Unknown inode type 0%o\n", mode);
++ err = -EIO;
++ }
++
++ if (do_dt)
++ dtime_revert(&dt, flags & CPUP_LOCKED_GHDIR);
++ //dput(parent);
++ //dput(hidden_parent);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the @dentry from @bsrc to @bdst.
++ * the caller must set the both of hidden dentries.
++ * @len is for trucating when it is -1 copyup the entire file.
++ */
++int cpup_single(struct dentry *dentry, aufs_bindex_t bdst, aufs_bindex_t bsrc,
++ loff_t len, unsigned int flags)
++{
++ int err, rerr, isdir, dlgt;
++ struct dentry *hidden_src, *hidden_dst, *parent;//, *h_parent;
++ struct inode *dst_inode, *hidden_dir, *inode, *src_inode;
++ struct super_block *sb;
++ aufs_bindex_t old_ibstart;
++ struct dtime dt;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++ sb = dentry->d_sb;
++ DEBUG_ON(bsrc <= bdst);
++ hidden_dst = au_h_dptr_i(dentry, bdst);
++ DEBUG_ON(!hidden_dst || hidden_dst->d_inode);
++ //h_parent = dget_parent(hidden_dst);
++ //hidden_dir = h_parent->d_inode;
++ hidden_dir = hidden_dst->d_parent->d_inode;
++ IMustLock(hidden_dir);
++ hidden_src = au_h_dptr_i(dentry, bsrc);
++ DEBUG_ON(!hidden_src || !hidden_src->d_inode);
++ inode = dentry->d_inode;
++ IiMustWriteLock(inode);
++
++ dlgt = need_dlgt(sb);
++ dst_inode = au_h_iptr_i(inode, bdst);
++ if (unlikely(dst_inode)) {
++ if (unlikely(!au_flag_test(sb, AuFlag_PLINK))) {
++ err = -EIO;
++ IOErr("i%lu exists on a upper branch "
++ "but plink is disabled\n", inode->i_ino);
++ goto out;
++ }
++
++ if (dst_inode->i_nlink) {
++ hidden_src = lkup_plink(sb, bdst, inode);
++ err = PTR_ERR(hidden_src);
++ if (IS_ERR(hidden_src))
++ goto out;
++ DEBUG_ON(!hidden_src->d_inode);
++ // vfs_link() does lock the inode
++ err = vfsub_link(hidden_src, hidden_dir, hidden_dst, dlgt);
++ dput(hidden_src);
++ goto out;
++ } else
++ /* udba work */
++ au_update_brange(inode, 1);
++ }
++
++ old_ibstart = ibstart(inode);
++ err = cpup_entry(dentry, bdst, bsrc, len, flags, dlgt);
++ if (unlikely(err))
++ goto out;
++ dst_inode = hidden_dst->d_inode;
++ hi_lock_child2(dst_inode);
++
++ //todo: test dlgt
++ err = cpup_iattr(hidden_dst, hidden_src, dlgt);
++ //if (LktrCond) err = -1;
++#if 0 // xattr
++ if (0 && !err)
++ err = cpup_xattrs(hidden_src, hidden_dst);
++#endif
++ isdir = S_ISDIR(dst_inode->i_mode);
++ if (!err) {
++ if (bdst < old_ibstart)
++ set_ibstart(inode, bdst);
++ set_h_iptr(inode, bdst, igrab(dst_inode),
++ au_hi_flags(inode, isdir));
++ i_unlock(dst_inode);
++ src_inode = hidden_src->d_inode;
++ if (!isdir) {
++ if (src_inode->i_nlink > 1
++ && au_flag_test(sb, AuFlag_PLINK))
++ append_plink(sb, inode, hidden_dst, bdst);
++ else {
++ /* braces are added to stop a warning */
++ ;//xino_write0(sb, bsrc, src_inode->i_ino);
++ /* ignore this error */
++ }
++ }
++ //goto out; /* success */
++ return 0; /* success */
++ }
++
++ /* revert */
++ i_unlock(dst_inode);
++ parent = dget_parent(dentry);
++ //dtime_store(&dt, parent, h_parent);
++ dtime_store(&dt, parent, hidden_dst->d_parent);
++ dput(parent);
++ if (!isdir)
++ rerr = vfsub_unlink(hidden_dir, hidden_dst, dlgt);
++ else
++ rerr = vfsub_rmdir(hidden_dir, hidden_dst, dlgt);
++ //rerr = -1;
++ dtime_revert(&dt, flags & CPUP_LOCKED_GHDIR);
++ if (rerr) {
++ IOErr("failed removing broken entry(%d, %d)\n", err, rerr);
++ err = -EIO;
++ }
++
++ out:
++ //dput(h_parent);
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_single_args {
++ int *errp;
++ struct dentry *dentry;
++ aufs_bindex_t bdst, bsrc;
++ loff_t len;
++ unsigned int flags;
++};
++
++static void call_cpup_single(void *args)
++{
++ struct cpup_single_args *a = args;
++ *a->errp = cpup_single(a->dentry, a->bdst, a->bsrc, a->len, a->flags);
++}
++
++int sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags)
++{
++ int err;
++ struct dentry *hidden_dentry;
++ umode_t mode;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++
++ hidden_dentry = au_h_dptr_i(dentry, bsrc);
++ mode = hidden_dentry->d_inode->i_mode & S_IFMT;
++ if ((mode != S_IFCHR && mode != S_IFBLK)
++ || capable(CAP_MKNOD))
++ err = cpup_single(dentry, bdst, bsrc, len, flags);
++ else {
++ struct cpup_single_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bdst,
++ .bsrc = bsrc,
++ .len = len,
++ .flags = flags
++ };
++ au_wkq_wait(call_cpup_single, &args, /*dlgt*/0);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the @dentry from the first active hidden branch to @bdst,
++ * using cpup_single().
++ */
++int cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags)
++{
++ int err;
++ struct inode *inode;
++ aufs_bindex_t bsrc, bend;
++
++ LKTRTrace("%.*s, bdst %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), bdst, len, flags);
++ inode = dentry->d_inode;
++ DEBUG_ON(!S_ISDIR(inode->i_mode) && dbstart(dentry) < bdst);
++
++ bend = dbend(dentry);
++ for (bsrc = bdst + 1; bsrc <= bend; bsrc++)
++ if (au_h_dptr_i(dentry, bsrc))
++ break;
++ DEBUG_ON(!au_h_dptr_i(dentry, bsrc));
++
++ err = lkup_neg(dentry, bdst);
++ //err = -1;
++ if (!err) {
++ err = cpup_single(dentry, bdst, bsrc, len, flags);
++ if (!err)
++ return 0; /* success */
++
++ /* revert */
++ set_h_dptr(dentry, bdst, NULL);
++ set_dbstart(dentry, bsrc);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_simple_args {
++ int *errp;
++ struct dentry *dentry;
++ aufs_bindex_t bdst;
++ loff_t len;
++ unsigned int flags;
++};
++
++static void call_cpup_simple(void *args)
++{
++ struct cpup_simple_args *a = args;
++ *a->errp = cpup_simple(a->dentry, a->bdst, a->len, a->flags);
++}
++
++int sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags)
++{
++ int err, do_sio, dlgt;
++ //struct dentry *parent;
++ struct inode *hidden_dir, *dir;
++
++ LKTRTrace("%.*s, b%d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), bdst, len, flags);
++
++ //parent = dget_parent(dentry);
++ //dir = parent->d_inode;
++ dir = dentry->d_parent->d_inode;
++ hidden_dir = au_h_iptr_i(dir, bdst);
++ dlgt = need_dlgt(dir->i_sb);
++ do_sio = au_test_perm(hidden_dir, MAY_EXEC | MAY_WRITE, dlgt);
++ if (!do_sio) {
++ umode_t mode = dentry->d_inode->i_mode & S_IFMT;
++ do_sio = ((mode == S_IFCHR || mode == S_IFBLK)
++ && !capable(CAP_MKNOD));
++ }
++ if (!do_sio)
++ err = cpup_simple(dentry, bdst, len, flags);
++ else {
++ struct cpup_simple_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bdst,
++ .len = len,
++ .flags = flags
++ };
++ au_wkq_wait(call_cpup_simple, &args, /*dlgt*/0);
++ }
++
++ //dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++//todo: dcsub
++/* cf. revalidate function in file.c */
++int cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst, struct dentry *locked)
++{
++ int err;
++ struct super_block *sb;
++ struct dentry *d, *parent, *hidden_parent;
++ unsigned int udba;
++
++ LKTRTrace("%.*s, b%d, parent i%lu, locked %p\n",
++ DLNPair(dentry), bdst, parent_ino(dentry), locked);
++ sb = dentry->d_sb;
++ DEBUG_ON(test_ro(sb, bdst, NULL));
++ parent = dentry->d_parent;
++ IiMustWriteLock(parent->d_inode);
++ if (unlikely(IS_ROOT(parent)))
++ return 0;
++ if (locked) {
++ DiMustAnyLock(locked);
++ IiMustAnyLock(locked->d_inode);
++ }
++
++ /* slow loop, keep it simple and stupid */
++ err = 0;
++ udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++ while (1) {
++ parent = dentry->d_parent; // dget_parent()
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ if (hidden_parent)
++ return 0; /* success */
++
++ /* find top dir which is needed to cpup */
++ do {
++ d = parent;
++ parent = d->d_parent; // dget_parent()
++ if (parent != locked)
++ di_read_lock_parent3(parent, !AUFS_I_RLOCK);
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ if (parent != locked)
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ } while (!hidden_parent);
++
++ if (d != dentry->d_parent)
++ di_write_lock_child3(d);
++
++ /* somebody else might create while we were sleeping */
++ if (!au_h_dptr_i(d, bdst) || !au_h_dptr_i(d, bdst)->d_inode) {
++ struct inode *h_dir = hidden_parent->d_inode,
++ *dir = parent->d_inode,
++ *h_gdir, *gdir;
++
++ if (au_h_dptr_i(d, bdst))
++ au_update_dbstart(d);
++ //DEBUG_ON(dbstart(d) <= bdst);
++ if (parent != locked)
++ di_read_lock_parent3(parent, AUFS_I_RLOCK);
++ h_gdir = gdir = NULL;
++ if (unlikely(udba && !IS_ROOT(parent))) {
++ gdir = parent->d_parent->d_inode;
++ h_gdir = hidden_parent->d_parent->d_inode;
++ hgdir_lock(h_gdir, gdir, bdst);
++ }
++ hdir_lock(h_dir, dir, bdst);
++ err = sio_cpup_simple(d, bdst, -1,
++ au_flags_cpup(CPUP_DTIME,
++ parent));
++ //if (LktrCond) err = -1;
++ hdir_unlock(h_dir, dir, bdst);
++ if (unlikely(gdir))
++ hdir_unlock(h_gdir, gdir, bdst);
++ if (parent != locked)
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++
++ if (d != dentry->d_parent)
++ di_write_unlock(d);
++ if (unlikely(err))
++ break;
++ }
++
++// out:
++ TraceErr(err);
++ return err;
++}
++
++int test_and_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst,
++ struct dentry *locked)
++{
++ int err;
++ struct dentry *parent;
++ struct inode *dir;
++
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ LKTRTrace("%.*s, b%d, parent i%lu, locked %p\n",
++ DLNPair(dentry), bdst, dir->i_ino, locked);
++ DiMustReadLock(parent);
++ IiMustReadLock(dir);
++
++ if (au_h_iptr_i(dir, bdst))
++ return 0;
++
++ err = 0;
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ di_write_lock_parent(parent);
++ if (au_h_iptr_i(dir, bdst))
++ goto out;
++
++ err = cpup_dirs(dentry, bdst, locked);
++
++ out:
++ di_downgrade_lock(parent, AUFS_I_RLOCK);
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/cpup.h b/fs/aufs/cpup.h
+new file mode 100755
+index 0000000..86557aa
+--- /dev/null
++++ b/fs/aufs/cpup.h
+@@ -0,0 +1,72 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: cpup.h,v 1.15 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_CPUP_H__
++#define __AUFS_CPUP_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++static inline
++void au_cpup_attr_blksize(struct inode *inode, struct inode *h_inode)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
++ inode->i_blksize = h_inode->i_blksize;
++#endif
++}
++
++void au_cpup_attr_timesizes(struct inode *inode);
++void au_cpup_attr_nlink(struct inode *inode);
++void au_cpup_attr_changable(struct inode *inode);
++void au_cpup_igen(struct inode *inode, struct inode *h_inode);
++void au_cpup_attr_all(struct inode *inode);
++
++#define CPUP_DTIME 1 // do dtime_store/revert
++// todo: remove this
++#define CPUP_LOCKED_GHDIR 2 // grand parent hidden dir is locked
++unsigned int au_flags_cpup(unsigned int init, struct dentry *parent);
++
++int cpup_single(struct dentry *dentry, aufs_bindex_t bdst, aufs_bindex_t bsrc,
++ loff_t len, unsigned int flags);
++int sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags);
++int cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags);
++int sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags);
++
++int cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst, struct dentry *locked);
++int test_and_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst,
++ struct dentry *locked);
++
++/* keep timestamps when copyup */
++struct dtime {
++ struct dentry *dt_dentry, *dt_h_dentry;
++ struct timespec dt_atime, dt_mtime;
++};
++void dtime_store(struct dtime *dt, struct dentry *dentry,
++ struct dentry *h_dentry);
++void dtime_revert(struct dtime *dt, int h_parent_is_locked);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_CPUP_H__ */
+diff --git a/fs/aufs/dcsub.c b/fs/aufs/dcsub.c
+new file mode 100755
+index 0000000..6ec29d3
+--- /dev/null
++++ b/fs/aufs/dcsub.c
+@@ -0,0 +1,175 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dcsub.c,v 1.3 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static void au_dpage_free(struct au_dpage *dpage)
++{
++ int i;
++
++ TraceEnter();
++ DEBUG_ON(!dpage);
++
++ for (i = 0; i < dpage->ndentry; i++)
++ dput(dpage->dentries[i]);
++ free_page((unsigned long)dpage->dentries);
++}
++
++int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp)
++{
++ int err;
++ void *p;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ dpages->dpages = kmalloc(sizeof(*dpages->dpages), gfp);
++ if (unlikely(!dpages->dpages))
++ goto out;
++ p = (void*)__get_free_page(gfp);
++ if (unlikely(!p))
++ goto out_dpages;
++ dpages->dpages[0].ndentry = 0;
++ dpages->dpages[0].dentries = p;
++ dpages->ndpage = 1;
++ return 0; /* success */
++
++ out_dpages:
++ kfree(dpages->dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++void au_dpages_free(struct au_dcsub_pages *dpages)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < dpages->ndpage; i++)
++ au_dpage_free(dpages->dpages + i);
++ kfree(dpages->dpages);
++}
++
++static int au_dpages_append(struct au_dcsub_pages *dpages,
++ struct dentry *dentry, gfp_t gfp)
++{
++ int err, sz;
++ struct au_dpage *dpage;
++ void *p;
++
++ //TraceEnter();
++
++ dpage = dpages->dpages + dpages->ndpage - 1;
++ DEBUG_ON(!dpage);
++ sz = PAGE_SIZE/sizeof(dentry);
++ if (unlikely(dpage->ndentry >= sz)) {
++ LKTRLabel(new dpage);
++ err = -ENOMEM;
++ sz = dpages->ndpage * sizeof(*dpages->dpages);
++ p = au_kzrealloc(dpages->dpages, sz,
++ sz + sizeof(*dpages->dpages), gfp);
++ if (unlikely(!p))
++ goto out;
++ dpage = dpages->dpages + dpages->ndpage;
++ p = (void*)__get_free_page(gfp);
++ if (unlikely(!p))
++ goto out;
++ dpage->ndentry = 0;
++ dpage->dentries = p;
++ dpages->ndpage++;
++ }
++
++ dpage->dentries[dpage->ndentry++] = dget(dentry);
++ return 0; /* success */
++
++ out:
++ //TraceErr(err);
++ return err;
++}
++
++int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
++ au_dpages_test test, void *arg)
++{
++ int err;
++ struct dentry *this_parent = root;
++ struct list_head *next;
++ struct super_block *sb = root->d_sb;
++
++ TraceEnter();
++
++ err = 0;
++ spin_lock(&dcache_lock);
++ repeat:
++ next = this_parent->d_subdirs.next;
++ resume:
++ if (this_parent->d_sb == sb
++ && !IS_ROOT(this_parent)
++ && atomic_read(&this_parent->d_count)
++ && this_parent->d_inode
++ && (!test || test(this_parent, arg))) {
++ err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
++ if (unlikely(err))
++ goto out;
++ }
++
++ while (next != &this_parent->d_subdirs) {
++ struct list_head *tmp = next;
++ struct dentry *dentry = list_entry(tmp, struct dentry, D_CHILD);
++ next = tmp->next;
++ if (unlikely(/*d_unhashed(dentry) || */!dentry->d_inode))
++ continue;
++ if (!list_empty(&dentry->d_subdirs)) {
++ this_parent = dentry;
++ goto repeat;
++ }
++ if (dentry->d_sb == sb
++ && atomic_read(&dentry->d_count)
++ && (!test || test(dentry, arg))) {
++ err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
++ if (unlikely(err))
++ goto out;
++ }
++ }
++
++ if (this_parent != root) {
++ next = this_parent->D_CHILD.next;
++ this_parent = this_parent->d_parent;
++ goto resume;
++ }
++ out:
++ spin_unlock(&dcache_lock);
++#if 0
++ if (!err) {
++ int i, j;
++ j = 0;
++ for (i = 0; i < dpages->ndpage; i++) {
++ if ((dpages->dpages + i)->ndentry)
++ Dbg("%d: %d\n", i, (dpages->dpages + i)->ndentry);
++ j += (dpages->dpages + i)->ndentry;
++ }
++ if (j)
++ Dbg("ndpage %d, %d\n", dpages->ndpage, j);
++ }
++#endif
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/dcsub.h b/fs/aufs/dcsub.h
+new file mode 100755
+index 0000000..0ba034b
+--- /dev/null
++++ b/fs/aufs/dcsub.h
+@@ -0,0 +1,47 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dcsub.h,v 1.2 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DCSUB_H__
++#define __AUFS_DCSUB_H__
++
++#ifdef __KERNEL__
++
++#include <linux/dcache.h>
++
++struct au_dpage {
++ int ndentry;
++ struct dentry **dentries;
++};
++
++struct au_dcsub_pages {
++ int ndpage;
++ struct au_dpage *dpages;
++};
++
++/* ---------------------------------------------------------------------- */
++
++int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp);
++void au_dpages_free(struct au_dcsub_pages *dpages);
++typedef int (*au_dpages_test)(struct dentry *dentry, void *arg);
++int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
++ au_dpages_test test, void *arg);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DCSUB_H__ */
+diff --git a/fs/aufs/debug.c b/fs/aufs/debug.c
+new file mode 100755
+index 0000000..99d158b
+--- /dev/null
++++ b/fs/aufs/debug.c
+@@ -0,0 +1,262 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: debug.c,v 1.27 2007/04/30 05:48:23 sfjro Exp $ */
++
++#include "aufs.h"
++
++atomic_t aufs_cond = ATOMIC_INIT(0);
++
++#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
++#define dpri(fmt, arg...) \
++ do {if (LktrCond) printk(KERN_DEBUG fmt, ##arg);} while (0)
++#else
++#define dpri(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++void au_dpri_whlist(struct aufs_nhash *whlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash)
++ dpri("b%d, %.*s, %d\n",
++ tpos->wh_bindex,
++ tpos->wh_str.len, tpos->wh_str.name,
++ tpos->wh_str.len);
++ }
++}
++
++void au_dpri_vdir(struct aufs_vdir *vdir)
++{
++ int i;
++ union aufs_deblk_p p;
++ unsigned char *o;
++
++ if (!vdir || IS_ERR(vdir)) {
++ dpri("err %ld\n", PTR_ERR(vdir));
++ return;
++ }
++
++ dpri("nblk %d, deblk %p %d, last{%d, %p}, ver %lu\n",
++ vdir->vd_nblk, vdir->vd_deblk, ksize(vdir->vd_deblk),
++ vdir->vd_last.i, vdir->vd_last.p.p, vdir->vd_version);
++ for (i = 0; i < vdir->vd_nblk; i++) {
++ p.deblk = vdir->vd_deblk[i];
++ o = p.p;
++ dpri("[%d]: %p %d\n", i, o, ksize(o));
++#if 0 // verbose
++ int j;
++ for (j = 0; j < 8; j++) {
++ dpri("%p(+%d) {%02x %02x %02x %02x %02x %02x %02x %02x "
++ "%02x %02x %02x %02x %02x %02x %02x %02x}\n",
++ p.p, p.p - o,
++ p.p[0], p.p[1], p.p[2], p.p[3],
++ p.p[4], p.p[5], p.p[6], p.p[7],
++ p.p[8], p.p[9], p.p[10], p.p[11],
++ p.p[12], p.p[13], p.p[14], p.p[15]);
++ p.p += 16;
++ }
++#endif
++ }
++}
++
++static int do_pri_inode(aufs_bindex_t bindex, struct inode *inode)
++{
++ if (!inode || IS_ERR(inode)) {
++ dpri("i%d: err %ld\n", bindex, PTR_ERR(inode));
++ return -1;
++ }
++
++ /* the type of i_blocks depends upon CONFIG_LSF */
++ BUILD_BUG_ON(sizeof(inode->i_blocks) != sizeof(unsigned long)
++ && sizeof(inode->i_blocks) != sizeof(u64));
++ dpri("i%d: i%lu, %s, cnt %d, nl %u, 0%o, sz %Lu, blk %Lu,"
++ " ct %Ld, np %lu, st 0x%lx, g %x\n",
++ bindex,
++ inode->i_ino, inode->i_sb ? au_sbtype(inode->i_sb) : "??",
++ atomic_read(&inode->i_count), inode->i_nlink, inode->i_mode,
++ i_size_read(inode), (u64)inode->i_blocks,
++ timespec_to_ns(&inode->i_ctime) & 0x0ffff,
++ inode->i_mapping ? inode->i_mapping->nrpages : 0,
++ inode->i_state, inode->i_generation);
++ return 0;
++}
++
++void au_dpri_inode(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_inode(-1, inode);
++ if (err || !au_is_aufs(inode->i_sb))
++ return;
++
++ iinfo = itoii(inode);
++ if (!iinfo)
++ return;
++ dpri("i-1: bstart %d, bend %d, gen %d\n",
++ iinfo->ii_bstart, iinfo->ii_bend, au_iigen(inode));
++ if (iinfo->ii_bstart < 0)
++ return;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; bindex++)
++ do_pri_inode(bindex, iinfo->ii_hinode[0 + bindex].hi_inode);
++}
++
++static int do_pri_dentry(aufs_bindex_t bindex, struct dentry *dentry)
++{
++ if (!dentry || IS_ERR(dentry)) {
++ dpri("d%d: err %ld\n", bindex, PTR_ERR(dentry));
++ return -1;
++ }
++ dpri("d%d: %.*s/%.*s, %s, cnt %d, flags 0x%x\n",
++ bindex,
++ DLNPair(dentry->d_parent), DLNPair(dentry),
++ dentry->d_sb ? au_sbtype(dentry->d_sb) : "??",
++ atomic_read(&dentry->d_count), dentry->d_flags);
++ do_pri_inode(bindex, dentry->d_inode);
++ return 0;
++}
++
++void au_dpri_dentry(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_dentry(-1, dentry);
++ if (err || !au_is_aufs(dentry->d_sb))
++ return;
++
++ dinfo = dtodi(dentry);
++ if (!dinfo)
++ return;
++ dpri("d-1: bstart %d, bend %d, bwh %d, bdiropq %d, gen %d\n",
++ dinfo->di_bstart, dinfo->di_bend,
++ dinfo->di_bwh, dinfo->di_bdiropq, au_digen(dentry));
++ if (dinfo->di_bstart < 0)
++ return;
++ for (bindex = dinfo->di_bstart; bindex <= dinfo->di_bend; bindex++)
++ do_pri_dentry(bindex, dinfo->di_hdentry[0 + bindex].hd_dentry);
++}
++
++static int do_pri_file(aufs_bindex_t bindex, struct file *file)
++{
++ char a[32];
++
++ if (!file || IS_ERR(file)) {
++ dpri("f%d: err %ld\n", bindex, PTR_ERR(file));
++ return -1;
++ }
++ a[0] = 0;
++ if (bindex == -1 && ftofi(file))
++ snprintf(a, sizeof(a), ", mmapped %d", au_is_mmapped(file));
++ dpri("f%d: mode 0x%x, flags 0%o, cnt %d, pos %Lu%s\n",
++ bindex, file->f_mode, file->f_flags, file_count(file),
++ file->f_pos, a);
++ do_pri_dentry(bindex, file->f_dentry);
++ return 0;
++}
++
++void au_dpri_file(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_file(-1, file);
++ if (err || !file->f_dentry || !au_is_aufs(file->f_dentry->d_sb))
++ return;
++
++ finfo = ftofi(file);
++ if (!finfo)
++ return;
++ if (finfo->fi_bstart < 0)
++ return;
++ for (bindex = finfo->fi_bstart; bindex <= finfo->fi_bend; bindex++) {
++ struct aufs_hfile *hf;
++ //dpri("bindex %d\n", bindex);
++ hf = finfo->fi_hfile + bindex;
++ do_pri_file(bindex, hf ? hf->hf_file : NULL);
++ }
++}
++
++static int do_pri_br(aufs_bindex_t bindex, struct aufs_branch *br)
++{
++ struct vfsmount *mnt;
++ struct super_block *sb;
++
++ if (!br || IS_ERR(br)
++ || !(mnt = br->br_mnt) || IS_ERR(mnt)
++ || !(sb = mnt->mnt_sb) || IS_ERR(sb)) {
++ dpri("s%d: err %ld\n", bindex, PTR_ERR(br));
++ return -1;
++ }
++
++ dpri("s%d: {perm 0x%x, cnt %d}, "
++ "%s, flags 0x%lx, cnt(BIAS) %d, active %d, xino %p %p\n",
++ bindex, br->br_perm, br_count(br),
++ au_sbtype(sb), sb->s_flags, sb->s_count - S_BIAS,
++ atomic_read(&sb->s_active), br->br_xino,
++ br->br_xino ? br->br_xino->f_dentry : NULL);
++ return 0;
++}
++
++void au_dpri_sb(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ aufs_bindex_t bindex;
++ int err;
++ struct vfsmount mnt = {.mnt_sb = sb};
++ struct aufs_branch fake = {
++ .br_perm = 0,
++ .br_mnt = &mnt,
++ .br_count = ATOMIC_INIT(0),
++ .br_xino = NULL
++ };
++
++ atomic_set(&fake.br_count, 0);
++ err = do_pri_br(-1, &fake);
++ dpri("dev 0x%x\n", sb->s_dev);
++ if (err || !au_is_aufs(sb))
++ return;
++
++ sbinfo = stosi(sb);
++ if (!sbinfo)
++ return;
++ for (bindex = 0; bindex <= sbinfo->si_bend; bindex++) {
++ //dpri("bindex %d\n", bindex);
++ do_pri_br(bindex, sbinfo->si_branch[0 + bindex]);
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++void DbgSleep(int sec)
++{
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ Dbg("sleep %d sec\n", sec);
++ wait_event_timeout(wq, 0, sec * HZ);
++}
+diff --git a/fs/aufs/debug.h b/fs/aufs/debug.h
+new file mode 100755
+index 0000000..53f5f6a
+--- /dev/null
++++ b/fs/aufs/debug.h
+@@ -0,0 +1,129 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: debug.h,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DEBUG_H__
++#define __AUFS_DEBUG_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++
++#ifdef CONFIG_AUFS_DEBUG
++#define DEBUG_ON(a) BUG_ON(a)
++extern atomic_t aufs_cond;
++#define au_debug_on() atomic_inc(&aufs_cond)
++#define au_debug_off() atomic_dec(&aufs_cond)
++#define au_is_debug() atomic_read(&aufs_cond)
++#else
++#define DEBUG_ON(a) /* */
++#define au_debug_on() /* */
++#define au_debug_off() /* */
++#define au_is_debug() 0
++#endif
++
++#define MtxMustLock(mtx) DEBUG_ON(!mutex_is_locked(mtx))
++
++/* ---------------------------------------------------------------------- */
++
++/* debug print */
++#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
++#include <linux/lktr.h>
++#ifdef CONFIG_AUFS_DEBUG
++#undef LktrCond
++#define LktrCond unlikely((lktr_cond && lktr_cond()) || au_is_debug())
++#endif
++#else
++#define LktrCond au_is_debug()
++#define LKTRDumpVma(pre, vma, suf) /* */
++#define LKTRDumpStack() /* */
++#define LKTRTrace(fmt, args...) do { \
++ if (LktrCond) \
++ Dbg(fmt, ##args); \
++} while (0)
++#define LKTRLabel(label) LKTRTrace("%s\n", #label)
++#endif /* CONFIG_LKTR */
++
++#define TraceErr(e) do { \
++ if (unlikely((e) < 0)) \
++ LKTRTrace("err %d\n", (int)(e)); \
++} while (0)
++#define TraceErrPtr(p) do { \
++ if (IS_ERR(p)) \
++ LKTRTrace("err %ld\n", PTR_ERR(p)); \
++} while (0)
++#define TraceEnter() LKTRLabel(enter)
++
++/* dirty macros for debug print, use with "%.*s" and caution */
++#define LNPair(qstr) (qstr)->len,(qstr)->name
++#define DLNPair(d) LNPair(&(d)->d_name)
++
++/* ---------------------------------------------------------------------- */
++
++#define Dpri(lvl, fmt, arg...) \
++ printk(lvl AUFS_NAME " %s:%d:%s[%d]: " fmt, \
++ __func__, __LINE__, current->comm, current->pid, ##arg)
++#define Dbg(fmt, arg...) Dpri(KERN_DEBUG, fmt, ##arg)
++#define Warn(fmt, arg...) Dpri(KERN_WARNING, fmt, ##arg)
++#define Warn1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) Warn(fmt, ##arg); \
++ } while (0)
++#define Err(fmt, arg...) Dpri(KERN_ERR, fmt, ##arg)
++#define Err1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) Err(fmt, ##arg); \
++ } while (0)
++#define IOErr(fmt, arg...) Err("I/O Error, " fmt, ##arg)
++#define IOErr1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) IOErr(fmt, ##arg); \
++ } while (0)
++#define IOErrWhck(fmt, arg...) Err("I/O Error, try whck. " fmt, ##arg)
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DEBUG
++struct aufs_nhash;
++void au_dpri_whlist(struct aufs_nhash *whlist);
++struct aufs_vdir;
++void au_dpri_vdir(struct aufs_vdir *vdir);
++void au_dpri_inode(struct inode *inode);
++void au_dpri_dentry(struct dentry *dentry);
++void au_dpri_file(struct file *filp);
++void au_dpri_sb(struct super_block *sb);
++#define DbgWhlist(w) do{LKTRTrace(#w "\n"); au_dpri_whlist(w);}while(0)
++#define DbgVdir(v) do{LKTRTrace(#v "\n"); au_dpri_vdir(v);}while(0)
++#define DbgInode(i) do{LKTRTrace(#i "\n"); au_dpri_inode(i);}while(0)
++#define DbgDentry(d) do{LKTRTrace(#d "\n"); au_dpri_dentry(d);}while(0)
++#define DbgFile(f) do{LKTRTrace(#f "\n"); au_dpri_file(f);}while(0)
++#define DbgSb(sb) do{LKTRTrace(#sb "\n"); au_dpri_sb(sb);}while(0)
++void DbgSleep(int sec);
++#else
++#define DbgWhlist(w) /* */
++#define DbgVdir(v) /* */
++#define DbgInode(i) /* */
++#define DbgDentry(d) /* */
++#define DbgFile(f) /* */
++#define DbgSb(sb) /* */
++#define DbgSleep(sec) /* */
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DEBUG_H__ */
+diff --git a/fs/aufs/dentry.c b/fs/aufs/dentry.c
+new file mode 100755
+index 0000000..2acb89b
+--- /dev/null
++++ b/fs/aufs/dentry.c
+@@ -0,0 +1,946 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dentry.c,v 1.41 2007/05/14 03:38:38 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++#ifdef CONFIG_AUFS_LHASH_PATCH
++
++#ifdef CONFIG_AUFS_DLGT
++struct lookup_hash_args {
++ struct dentry **errp;
++ struct qstr *name;
++ struct dentry *base;
++ struct nameidata *nd;
++};
++
++static void call_lookup_hash(void *args)
++{
++ struct lookup_hash_args *a = args;
++ *a->errp = __lookup_hash(a->name, a->base, a->nd);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++static struct dentry *lkup_hash(const char *name, struct dentry *parent,
++ int len, struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++ char *p;
++ unsigned long hash;
++ struct qstr this;
++ unsigned int c;
++ struct nameidata tmp_nd;
++
++ dentry = ERR_PTR(-EACCES);
++ this.name = name;
++ this.len = len;
++ if (unlikely(!len))
++ goto out;
++
++ p = (void*)name;
++ hash = init_name_hash();
++ while (len--) {
++ c = *p++;
++ if (unlikely(c == '/' || c == '\0'))
++ goto out;
++ hash = partial_name_hash(c, hash);
++ }
++ this.hash = end_name_hash(hash);
++
++ memset(&tmp_nd, 0, sizeof(tmp_nd));
++ tmp_nd.dentry = dget(parent);
++ tmp_nd.mnt = mntget(lkup->nfsmnt);
++#ifndef CONFIG_AUFS_DLGT
++ dentry = __lookup_hash(&this, parent, &tmp_nd);
++#else
++ if (!lkup->dlgt)
++ dentry = __lookup_hash(&this, parent, &tmp_nd);
++ else {
++ struct lookup_hash_args args = {
++ .errp = &dentry,
++ .name = &this,
++ .base = parent,
++ .nd = &tmp_nd
++ };
++ au_wkq_wait(call_lookup_hash, &args, /*dlgt*/1);
++ }
++#endif
++ path_release(&tmp_nd);
++
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++#elif defined(CONFIG_AUFS_DLGT)
++static struct dentry *lkup_hash(const char *name, struct dentry *parent,
++ int len, struct lkup_args *lkup)
++{
++ return ERR_PTR(-ENOSYS);
++}
++#endif
++
++#ifdef CONFIG_AUFS_DLGT
++struct lookup_one_len_args {
++ struct dentry **errp;
++ const char *name;
++ struct dentry *parent;
++ int len;
++};
++
++static void call_lookup_one_len(void *args)
++{
++ struct lookup_one_len_args *a = args;
++ *a->errp = lookup_one_len(a->name, a->parent, a->len);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
++/* cf. lookup_one_len() in linux/fs/namei.c */
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++
++ LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n",
++ DLNPair(parent), len, name, lkup->nfsmnt, lkup->dlgt);
++
++ if (!lkup->nfsmnt) {
++#ifndef CONFIG_AUFS_DLGT
++ dentry = lookup_one_len(name, parent, len);
++#else
++ if (!lkup->dlgt)
++ dentry = lookup_one_len(name, parent, len);
++ else {
++ struct lookup_one_len_args args = {
++ .errp = &dentry,
++ .name = name,
++ .parent = parent,
++ .len = len
++ };
++ au_wkq_wait(call_lookup_one_len, &args, /*dlgt*/1);
++ }
++#endif
++ } else
++ dentry = lkup_hash(name, parent, len, lkup);
++
++ TraceErrPtr(dentry);
++ return dentry;
++}
++#endif
++
++struct lkup_one_args {
++ struct dentry **errp;
++ const char *name;
++ struct dentry *parent;
++ int len;
++ struct lkup_args *lkup;
++};
++
++static void call_lkup_one(void *args)
++{
++ struct lkup_one_args *a = args;
++ *a->errp = lkup_one(a->name, a->parent, a->len, a->lkup);
++}
++
++/*
++ * returns positive/negative dentry, NULL or an error.
++ * NULL means whiteout-ed or not-found.
++ */
++static struct dentry *do_lookup(struct dentry *hidden_parent,
++ struct dentry *dentry, aufs_bindex_t bindex,
++ struct qstr *wh_name, int allow_neg,
++ mode_t type, int dlgt)
++{
++ struct dentry *hidden_dentry;
++ int wh_found, wh_able, opq;
++ struct inode *hidden_dir, *hidden_inode;
++ struct qstr *name;
++ struct super_block *sb;
++ struct lkup_args lkup = {.dlgt = dlgt};
++
++ LKTRTrace("%.*s/%.*s, b%d, allow_neg %d, type 0%o, dlgt %d\n",
++ DLNPair(hidden_parent), DLNPair(dentry), bindex, allow_neg,
++ type, dlgt);
++ DEBUG_ON(IS_ROOT(dentry));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ wh_found = 0;
++ sb = dentry->d_sb;
++ wh_able = sbr_is_whable(sb, bindex);
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ name = &dentry->d_name;
++ if (unlikely(wh_able)) {
++#if 0 //def CONFIG_AUFS_ROBR
++ if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN))
++ wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0,
++ &lkup);
++ else
++ wh_found = -EPERM;
++#else
++ wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0, &lkup);
++#endif
++ }
++ //if (LktrCond) wh_found = -1;
++ hidden_dentry = ERR_PTR(wh_found);
++ if (!wh_found)
++ goto real_lookup;
++ if (unlikely(wh_found < 0))
++ goto out;
++
++ /* We found a whiteout */
++ //set_dbend(dentry, bindex);
++ set_dbwh(dentry, bindex);
++ if (!allow_neg)
++ return NULL; /* success */
++
++ real_lookup:
++ // do not superio.
++ hidden_dentry = lkup_one(name->name, hidden_parent, name->len, &lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ if (IS_ERR(hidden_dentry))
++ goto out;
++ DEBUG_ON(d_unhashed(hidden_dentry));
++ hidden_inode = hidden_dentry->d_inode;
++ if (!hidden_inode) {
++ if (!allow_neg)
++ goto out_neg;
++ } else if (wh_found
++ || (type && type != (hidden_inode->i_mode & S_IFMT)))
++ goto out_neg;
++
++ if (dbend(dentry) <= bindex)
++ set_dbend(dentry, bindex);
++ if (dbstart(dentry) == -1 || bindex < dbstart(dentry))
++ set_dbstart(dentry, bindex);
++ set_h_dptr(dentry, bindex, hidden_dentry);
++
++ if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode) || !wh_able)
++ return hidden_dentry; /* success */
++
++ hi_lock_child(hidden_inode);
++ opq = is_diropq(hidden_dentry, &lkup);
++ //if (LktrCond) opq = -1;
++ i_unlock(hidden_inode);
++ if (opq > 0)
++ set_dbdiropq(dentry, bindex);
++ else if (unlikely(opq < 0)) {
++ set_h_dptr(dentry, bindex, NULL);
++ hidden_dentry = ERR_PTR(opq);
++ }
++ goto out;
++
++ out_neg:
++ dput(hidden_dentry);
++ hidden_dentry = NULL;
++ out:
++ TraceErrPtr(hidden_dentry);
++ return hidden_dentry;
++}
++
++/*
++ * returns the number of hidden positive dentries,
++ * otherwise an error.
++ */
++int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type)
++{
++ int npositive, err, allow_neg, dlgt;
++ struct dentry *parent;
++ aufs_bindex_t bindex, btail;
++ const struct qstr *name = &dentry->d_name;
++ struct qstr whname;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, b%d, type 0%o\n", LNPair(name), bstart, type);
++ DEBUG_ON(bstart < 0 || IS_ROOT(dentry));
++ parent = dget_parent(dentry);
++
++#if 1 //ndef CONFIG_AUFS_ROBR
++ err = -EPERM;
++ if (unlikely(!strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
++ goto out;
++#endif
++
++ err = au_alloc_whname(name->name, name->len, &whname);
++ //if (LktrCond) {au_free_whname(&whname); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ sb = dentry->d_sb;
++ dlgt = need_dlgt(sb);
++ allow_neg = !type;
++ npositive = 0;
++ btail = dbtaildir(parent);
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ struct dentry *hidden_parent, *hidden_dentry;
++ struct inode *hidden_inode;
++ struct inode *hidden_dir;
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry) {
++ if (hidden_dentry->d_inode)
++ npositive++;
++ if (type != S_IFDIR)
++ break;
++ continue;
++ }
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ if (!hidden_parent)
++ continue;
++ hidden_dir = hidden_parent->d_inode;
++ if (!hidden_dir || !S_ISDIR(hidden_dir->i_mode))
++ continue;
++
++ hi_lock_parent(hidden_dir);
++ hidden_dentry = do_lookup(hidden_parent, dentry, bindex,
++ &whname, allow_neg, type, dlgt);
++ // do not dput for testing
++ //if (LktrCond) {hidden_dentry = ERR_PTR(-1);}
++ i_unlock(hidden_dir);
++ err = PTR_ERR(hidden_dentry);
++ if (IS_ERR(hidden_dentry))
++ goto out_wh;
++ allow_neg = 0;
++
++ if (dbwh(dentry) != -1)
++ break;
++ if (!hidden_dentry)
++ continue;
++ hidden_inode = hidden_dentry->d_inode;
++ if (!hidden_inode)
++ continue;
++ npositive++;
++ if (!type)
++ type = hidden_inode->i_mode & S_IFMT;
++ if (type != S_IFDIR)
++ break;
++ else if (dbdiropq(dentry) != -1)
++ break;
++ }
++
++ if (npositive) {
++ LKTRLabel(positive);
++ au_update_dbstart(dentry);
++ }
++ err = npositive;
++
++ out_wh:
++ au_free_whname(&whname);
++ out:
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(parent), len, name);
++ IMustLock(parent->d_inode);
++
++ if (!au_test_perm(parent->d_inode, MAY_EXEC, lkup->dlgt))
++ dentry = lkup_one(name, parent, len, lkup);
++ else {
++ // ugly
++ int dlgt = lkup->dlgt;
++ struct lkup_one_args args = {
++ .errp = &dentry,
++ .name = name,
++ .parent = parent,
++ .len = len,
++ .lkup = lkup
++ };
++
++ lkup->dlgt = 0;
++ au_wkq_wait(call_lkup_one, &args, /*dlgt*/0);
++ lkup->dlgt = dlgt;
++ }
++
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/*
++ * lookup @dentry on @bindex which should be negative.
++ */
++int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ int err;
++ struct dentry *parent, *hidden_parent, *hidden_dentry;
++ struct inode *hidden_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++ parent = dget_parent(dentry);
++ DEBUG_ON(!parent || !parent->d_inode
++ || !S_ISDIR(parent->d_inode->i_mode));
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ DEBUG_ON(!hidden_parent);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bindex);
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ hidden_dentry = sio_lkup_one(dentry->d_name.name, hidden_parent,
++ dentry->d_name.len, &lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(hidden_dentry);
++ if (IS_ERR(hidden_dentry))
++ goto out;
++ if (unlikely(hidden_dentry->d_inode)) {
++ err = -EIO;
++ IOErr("b%d %.*s should be negative.%s\n",
++ bindex, DLNPair(hidden_dentry),
++ au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY) ? "" :
++ " Try udba=inotify.");
++ dput(hidden_dentry);
++ goto out;
++ }
++
++ if (bindex < dbstart(dentry))
++ set_dbstart(dentry, bindex);
++ if (dbend(dentry) < bindex)
++ set_dbend(dentry, bindex);
++ set_h_dptr(dentry, bindex, hidden_dentry);
++ err = 0;
++
++ out:
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns the number of found hidden positive dentries,
++ * otherwise an error.
++ */
++int au_refresh_hdentry(struct dentry *dentry, mode_t type)
++{
++ int npositive, pgen, new_sz, sgen, dgen;
++ struct aufs_dinfo *dinfo;
++ struct super_block *sb;
++ struct dentry *parent;
++ aufs_bindex_t bindex, parent_bend, parent_bstart, bwh, bdiropq, bend;
++ struct aufs_hdentry *p;
++ //struct nameidata nd;
++
++ LKTRTrace("%.*s, type 0%o\n", DLNPair(dentry), type);
++ DiMustWriteLock(dentry);
++ sb = dentry->d_sb;
++ DEBUG_ON(IS_ROOT(dentry));
++ parent = dget_parent(dentry);
++ pgen = au_digen(parent);
++ sgen = au_sigen(sb);
++ dgen = au_digen(dentry);
++ DEBUG_ON(pgen != sgen);
++
++ npositive = -ENOMEM;
++ new_sz = sizeof(*dinfo->di_hdentry) * (sbend(sb) + 1);
++ dinfo = dtodi(dentry);
++ p = au_kzrealloc(dinfo->di_hdentry, sizeof(*p) * (dinfo->di_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++ dinfo->di_hdentry = p;
++
++ bend = dinfo->di_bend;
++ bwh = dinfo->di_bwh;
++ bdiropq = dinfo->di_bdiropq;
++ p += dinfo->di_bstart;
++ for (bindex = dinfo->di_bstart; bindex <= bend; bindex++, p++) {
++ struct dentry *hd, *hdp;
++ struct aufs_hdentry tmp, *q;
++ aufs_bindex_t new_bindex;
++
++ hd = p->hd_dentry;
++ if (!hd)
++ continue;
++ hdp = dget_parent(hd);
++ if (hdp == au_h_dptr_i(parent, bindex)) {
++ dput(hdp);
++ continue;
++ }
++
++ new_bindex = au_find_dbindex(parent, hdp);
++ dput(hdp);
++ DEBUG_ON(new_bindex == bindex);
++ if (dinfo->di_bwh == bindex)
++ bwh = new_bindex;
++ if (dinfo->di_bdiropq == bindex)
++ bdiropq = new_bindex;
++ if (new_bindex < 0) { // test here
++ hdput(p);
++ p->hd_dentry = NULL;
++ continue;
++ }
++ /* swap two hidden dentries, and loop again */
++ q = dinfo->di_hdentry + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hd_dentry) {
++ bindex--;
++ p--;
++ }
++ }
++
++ // test here
++ dinfo->di_bwh = -1;
++ if (unlikely(bwh != -1 && bwh <= sbend(sb) && sbr_is_whable(sb, bwh)))
++ dinfo->di_bwh = bwh;
++ dinfo->di_bdiropq = -1;
++ if (unlikely(bdiropq != -1 && bdiropq <= sbend(sb)
++ && sbr_is_whable(sb, bdiropq)))
++ dinfo->di_bdiropq = bdiropq;
++ parent_bend = dbend(parent);
++ p = dinfo->di_hdentry;
++ for (bindex = 0; bindex <= parent_bend; bindex++, p++)
++ if (p->hd_dentry) {
++ dinfo->di_bstart = bindex;
++ break;
++ }
++ p = dinfo->di_hdentry + parent_bend;
++ //for (bindex = parent_bend; bindex > dinfo->di_bstart; bindex--, p--)
++ for (bindex = parent_bend; bindex >= 0; bindex--, p--)
++ if (p->hd_dentry) {
++ dinfo->di_bend = bindex;
++ break;
++ }
++
++ npositive = 0;
++ parent_bstart = dbstart(parent);
++ if (type != S_IFDIR && dinfo->di_bstart == parent_bstart)
++ goto out_dgen; /* success */
++
++#if 0
++ nd.last_type = LAST_ROOT;
++ nd.flags = LOOKUP_FOLLOW;
++ nd.depth = 0;
++ nd.mnt = mntget(??);
++ nd.dentry = dget(parent);
++#endif
++ npositive = lkup_dentry(dentry, parent_bstart, type);
++ //if (LktrCond) npositive = -1;
++ if (npositive < 0)
++ goto out;
++
++ out_dgen:
++ au_update_digen(dentry);
++ out:
++ dput(parent);
++ TraceErr(npositive);
++ return npositive;
++}
++
++static int h_d_revalidate(struct dentry *dentry, struct nameidata *nd,
++ int do_udba)
++{
++ int err, plus, locked, unhashed, is_root, h_plus, is_nfs;
++ struct nameidata fake_nd, *p;
++ aufs_bindex_t bindex, btail, bstart, ibs, ibe;
++ struct super_block *sb;
++ struct inode *inode, *first, *h_inode, *h_cached_inode;
++ umode_t mode, h_mode;
++ struct dentry *h_dentry;
++ int (*reval)(struct dentry *, struct nameidata *);
++ struct qstr *name;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(inode && au_digen(dentry) != au_iigen(inode));
++ //DbgDentry(dentry);
++ //DbgInode(inode);
++
++ err = 0;
++ sb = dentry->d_sb;
++ plus = 0;
++ mode = 0;
++ first = NULL;
++ ibs = ibe = -1;
++ unhashed = d_unhashed(dentry);
++ is_root = IS_ROOT(dentry);
++ name = &dentry->d_name;
++
++ /*
++ * Theoretically, REVAL test should be unnecessary in case of INOTIFY.
++ * But inotify doesn't fire some necessary events,
++ * IN_ATTRIB for atime/nlink/pageio
++ * IN_DELETE for NFS dentry
++ * Let's do REVAL test too.
++ */
++ if (do_udba && inode) {
++ mode = (inode->i_mode & S_IFMT);
++ plus = (inode->i_nlink > 0);
++ first = au_h_iptr(inode);
++ ibs = ibstart(inode);
++ ibe = ibend(inode);
++ }
++
++ btail = bstart = dbstart(dentry);
++ if (inode && S_ISDIR(inode->i_mode))
++ btail = dbtaildir(dentry);
++ locked = 0;
++ if (nd) {
++ fake_nd = *nd;
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (dentry != nd->dentry) {
++ di_read_lock_parent(nd->dentry, 0);
++ locked = 1;
++ }
++#endif
++ }
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ h_dentry = au_h_dptr_i(dentry, bindex);
++ if (unlikely(!h_dentry))
++ continue;
++ if (unlikely(do_udba
++ && !is_root
++ && (unhashed != d_unhashed(h_dentry)
++#if 1
++ || name->len != h_dentry->d_name.len
++ || memcmp(name->name, h_dentry->d_name.name,
++ name->len)
++#endif
++ ))) {
++ LKTRTrace("unhash 0x%x 0x%x, %.*s %.*s\n",
++ unhashed, d_unhashed(h_dentry),
++ DLNPair(dentry), DLNPair(h_dentry));
++ goto err;
++ }
++
++ reval = NULL;
++ if (h_dentry->d_op)
++ reval = h_dentry->d_op->d_revalidate;
++ if (unlikely(reval)) {
++ //LKTRLabel(hidden reval);
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ DEBUG_ON(IS_ERR(p));
++ err = !reval(h_dentry, p);
++ fake_dm_release(p);
++ if (unlikely(err)) {
++ //Dbg("here\n");
++ goto err;
++ }
++ }
++
++ if (unlikely(!do_udba))
++ continue;
++
++ /* UDBA tests */
++ h_inode = h_dentry->d_inode;
++ if (unlikely(!!inode != !!h_inode)) {
++ //Dbg("here\n");
++ goto err;
++ }
++
++ h_plus = plus;
++ h_mode = mode;
++ h_cached_inode = h_inode;
++ is_nfs = 0;
++ if (h_inode) {
++ h_mode = (h_inode->i_mode & S_IFMT);
++ h_plus = (h_inode->i_nlink > 0);
++ }
++ if (inode && ibs <= bindex && bindex <= ibe) {
++ h_cached_inode = au_h_iptr_i(inode, bindex);
++ //is_nfs = au_is_nfs(h_cached_inode->i_sb);
++ }
++
++ LKTRTrace("{%d, 0%o, %p}, h{%d, 0%o, %p}\n",
++ plus, mode, h_cached_inode,
++ h_plus, h_mode, h_inode);
++ if (unlikely(plus != h_plus || mode != h_mode
++ || (h_cached_inode != h_inode /* && !is_nfs */))) {
++ //Dbg("here\n");
++ goto err;
++ }
++ continue;
++
++ err:
++ err = -EINVAL;
++ break;
++ }
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (unlikely(locked))
++ di_read_unlock(nd->dentry, 0);
++#endif
++
++#if 0
++ // some filesystem uses CURRENT_TIME_SEC instead of CURRENT_TIME.
++ // NFS may stop IN_DELETE because of DCACHE_NFSFS_RENAMED.
++#if 0
++ && (!timespec_equal(&inode->i_ctime, &first->i_ctime)
++ || !timespec_equal(&inode->i_atime, &first->i_atime))
++#endif
++ if (unlikely(!err && udba && first))
++ au_cpup_attr_all(inode);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++static int simple_reval_dpath(struct dentry *dentry, int sgen)
++{
++ int err;
++ mode_t type;
++ struct dentry *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
++ SiMustAnyLock(dentry->d_sb);
++ DiMustWriteLock(dentry);
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode);
++
++ if (au_digen(dentry) == sgen)
++ return 0;
++
++ parent = dget_parent(dentry);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ DEBUG_ON(au_digen(parent) != sgen);
++#ifdef CONFIG_AUFS_DEBUG
++ {
++ struct dentry *d = parent;
++ while (!IS_ROOT(d)) {
++ DEBUG_ON(au_digen(d) != sgen);
++ d = d->d_parent;
++ }
++ }
++#endif
++ type = (inode->i_mode & S_IFMT);
++ /* returns a number of positive dentries */
++ err = au_refresh_hdentry(dentry, type);
++ if (err >= 0)
++ err = au_refresh_hinode(inode, dentry);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++int au_reval_dpath(struct dentry *dentry, int sgen)
++{
++ int err;
++ struct dentry *d, *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
++ DEBUG_ON(!dentry->d_inode);
++ DiMustWriteLock(dentry);
++
++ if (!stosi(dentry->d_sb)->si_failed_refresh_dirs)
++ return simple_reval_dpath(dentry, sgen);
++
++ /* slow loop, keep it simple and stupid */
++ /* cf: cpup_dirs() */
++ err = 0;
++ while (au_digen(dentry) != sgen) {
++ d = dentry;
++ while (1) {
++ parent = d->d_parent; // dget_parent()
++ if (au_digen(parent) == sgen)
++ break;
++ d = parent;
++ }
++
++ inode = d->d_inode;
++ if (d != dentry) {
++ //i_lock(inode);
++ di_write_lock_child(d);
++ }
++
++ /* someone might update our dentry while we were sleeping */
++ if (au_digen(d) != sgen) {
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ /* returns a number of positive dentries */
++ err = au_refresh_hdentry(d, inode->i_mode & S_IFMT);
++ //err = -1;
++ if (err >= 0)
++ err = au_refresh_hinode(inode, d);
++ //err = -1;
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++
++ if (d != dentry) {
++ di_write_unlock(d);
++ //i_unlock(inode);
++ }
++ if (unlikely(err))
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * THIS IS A BOOLEAN FUNCTION: returns 1 if valid, 0 otherwise.
++ * nfsd passes NULL as nameidata.
++ */
++static int aufs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
++{
++ int valid, sgen, err, do_udba;
++ struct super_block *sb;
++ struct inode *inode;
++
++ LKTRTrace("dentry %.*s\n", DLNPair(dentry));
++ if (nd && nd->dentry)
++ LKTRTrace("nd %.*s\n", DLNPair(nd->dentry));
++ //dir case: DEBUG_ON(dentry->d_parent != nd->dentry);
++ //remove failure case: DEBUG_ON(!IS_ROOT(dentry) && d_unhashed(dentry));
++ DEBUG_ON(!dentry->d_fsdata);
++ //DbgDentry(dentry);
++
++ err = -EINVAL;
++ inode = dentry->d_inode;
++ //DbgInode(inode);
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ sgen = au_sigen(sb);
++ if (au_digen(dentry) == sgen)
++ di_read_lock_child(dentry, !AUFS_I_RLOCK);
++ else {
++ DEBUG_ON(IS_ROOT(dentry));
++#ifdef ForceInotify
++ Dbg("UDBA or digen, %.*s\n", DLNPair(dentry));
++#endif
++ //i_lock(inode);
++ di_write_lock_child(dentry);
++ if (inode)
++ err = au_reval_dpath(dentry, sgen);
++ //err = -1;
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ //i_unlock(inode);
++ if (unlikely(err))
++ goto out;
++ ii_read_unlock(inode);
++ DEBUG_ON(au_iigen(inode) != sgen);
++ }
++
++ if (inode) {
++ if (au_iigen(inode) == sgen)
++ ii_read_lock_child(inode);
++ else {
++ DEBUG_ON(IS_ROOT(dentry));
++#ifdef ForceInotify
++ Dbg("UDBA or survived, %.*s\n", DLNPair(dentry));
++#endif
++ ii_write_lock_child(inode);
++ err = au_refresh_hinode(inode, dentry);
++ ii_downgrade_lock(inode);
++ if (unlikely(err))
++ goto out;
++ DEBUG_ON(au_iigen(inode) != sgen);
++ }
++ }
++
++#if 0 // fix it
++ /* parent dir i_nlink is not updated in the case of setattr */
++ if (S_ISDIR(inode->i_mode)) {
++ i_lock(inode);
++ ii_write_lock(inode);
++ au_cpup_attr_nlink(inode);
++ ii_write_unlock(inode);
++ i_unlock(inode);
++ }
++#endif
++
++ err = -EINVAL;
++ do_udba = !au_flag_test(sb, AuFlag_UDBA_NONE);
++ if (do_udba && inode && ibstart(inode) >= 0
++ && au_test_higen(inode, au_h_iptr(inode)))
++ goto out;
++ err = h_d_revalidate(dentry, nd, do_udba);
++ //err = -1;
++
++ out:
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ TraceErr(err);
++ valid = !err;
++ //au_debug_on();
++ if (!valid)
++ LKTRTrace("%.*s invalid\n", DLNPair(dentry));
++ //au_debug_off();
++ return valid;
++}
++
++static void aufs_d_release(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!d_unhashed(dentry));
++
++ dinfo = dentry->d_fsdata;
++ if (unlikely(!dinfo))
++ return;
++
++ /* dentry may not be revalidated */
++ bindex = dinfo->di_bstart;
++ if (bindex >= 0) {
++ struct aufs_hdentry *p;
++ bend = dinfo->di_bend;
++ DEBUG_ON(bend < bindex);
++ p = dinfo->di_hdentry + bindex;
++ while (bindex++ <= bend) {
++ if (p->hd_dentry)
++ hdput(p);
++ p++;
++ }
++ }
++ kfree(dinfo->di_hdentry);
++ cache_free_dinfo(dinfo);
++}
++
++#if 0
++/* it may be called at remount time, too */
++static void aufs_d_iput(struct dentry *dentry, struct inode *inode)
++{
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, i%lu\n", DLNPair(dentry), inode->i_ino);
++
++ sb = dentry->d_sb;
++#if 0
++ si_read_lock(sb);
++ if (unlikely(au_flag_test(sb, AuFlag_PLINK)
++ && au_is_plinked(sb, inode))) {
++ ii_write_lock(inode);
++ au_update_brange(inode, 1);
++ ii_write_unlock(inode);
++ }
++ si_read_unlock(sb);
++#endif
++ iput(inode);
++}
++#endif
++
++struct dentry_operations aufs_dop = {
++ .d_revalidate = aufs_d_revalidate,
++ .d_release = aufs_d_release
++ //.d_iput = aufs_d_iput
++};
+diff --git a/fs/aufs/dentry.h b/fs/aufs/dentry.h
+new file mode 100755
+index 0000000..78049e3
+--- /dev/null
++++ b/fs/aufs/dentry.h
+@@ -0,0 +1,183 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dentry.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DENTRY_H__
++#define __AUFS_DENTRY_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++
++struct aufs_hdentry {
++ struct dentry *hd_dentry;
++};
++
++struct aufs_dinfo {
++ atomic_t di_generation;
++
++ struct aufs_rwsem di_rwsem;
++ aufs_bindex_t di_bstart, di_bend, di_bwh, di_bdiropq;
++ struct aufs_hdentry *di_hdentry;
++};
++
++struct lkup_args {
++ struct vfsmount *nfsmnt;
++ int dlgt;
++ //struct super_block *sb;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* dentry.c */
++#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup);
++#else
++static inline
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ return lookup_one_len(name, parent, len);
++}
++#endif
++
++extern struct dentry_operations aufs_dop;
++struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup);
++int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type);
++int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex);
++int au_refresh_hdentry(struct dentry *dentry, mode_t type);
++int au_reval_dpath(struct dentry *dentry, int sgen);
++
++/* dinfo.c */
++int au_alloc_dinfo(struct dentry *dentry);
++struct aufs_dinfo *dtodi(struct dentry *dentry);
++
++void di_read_lock(struct dentry *d, int flags, unsigned int lsc);
++void di_read_unlock(struct dentry *d, int flags);
++void di_downgrade_lock(struct dentry *d, int flags);
++void di_write_lock(struct dentry *d, unsigned int lsc);
++void di_write_unlock(struct dentry *d);
++void di_write_lock2_child(struct dentry *d1, struct dentry *d2, int isdir);
++void di_write_lock2_parent(struct dentry *d1, struct dentry *d2, int isdir);
++void di_write_unlock2(struct dentry *d1, struct dentry *d2);
++
++aufs_bindex_t dbstart(struct dentry *dentry);
++aufs_bindex_t dbend(struct dentry *dentry);
++aufs_bindex_t dbwh(struct dentry *dentry);
++aufs_bindex_t dbdiropq(struct dentry *dentry);
++struct dentry *au_h_dptr_i(struct dentry *dentry, aufs_bindex_t bindex);
++struct dentry *au_h_dptr(struct dentry *dentry);
++
++aufs_bindex_t dbtail(struct dentry *dentry);
++aufs_bindex_t dbtaildir(struct dentry *dentry);
++aufs_bindex_t dbtail_generic(struct dentry *dentry);
++
++void set_dbstart(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbend(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbwh(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbdiropq(struct dentry *dentry, aufs_bindex_t bindex);
++void hdput(struct aufs_hdentry *hdentry);
++void set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_dentry);
++
++void au_update_digen(struct dentry *dentry);
++void au_update_dbstart(struct dentry *dentry);
++int au_find_dbindex(struct dentry *dentry, struct dentry *h_dentry);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int au_digen(struct dentry *d)
++{
++ return atomic_read(&dtodi(d)->di_generation);
++}
++
++#ifdef CONFIG_AUFS_HINOTIFY
++static inline void au_digen_dec(struct dentry *d)
++{
++ atomic_dec(&dtodi(d)->di_generation);
++}
++#endif /* CONFIG_AUFS_HINOTIFY */
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for dinfo */
++enum {
++ AuLsc_DI_CHILD, /* child first */
++ AuLsc_DI_CHILD2, /* rename(2), link(2), and cpup at hinotify */
++ AuLsc_DI_CHILD3, /* copyup dirs */
++ AuLsc_DI_PARENT,
++ AuLsc_DI_PARENT2,
++ AuLsc_DI_PARENT3
++};
++
++/*
++ * di_read_lock_child, di_write_lock_child,
++ * di_read_lock_child2, di_write_lock_child2,
++ * di_read_lock_child3, di_write_lock_child3,
++ * di_read_lock_parent, di_write_lock_parent,
++ * di_read_lock_parent2, di_write_lock_parent2,
++ * di_read_lock_parent3, di_write_lock_parent3,
++ */
++#define ReadLockFunc(name, lsc) \
++static inline void di_read_lock_##name(struct dentry *d, int flags) \
++{di_read_lock(d, flags, AuLsc_DI_##lsc);}
++
++#define WriteLockFunc(name, lsc) \
++static inline void di_write_lock_##name(struct dentry *d) \
++{di_write_lock(d, AuLsc_DI_##lsc);}
++
++#define RWLockFuncs(name, lsc) \
++ ReadLockFunc(name, lsc); \
++ WriteLockFunc(name, lsc)
++
++RWLockFuncs(child, CHILD);
++RWLockFuncs(child2, CHILD2);
++RWLockFuncs(child3, CHILD3);
++RWLockFuncs(parent, PARENT);
++RWLockFuncs(parent2, PARENT2);
++RWLockFuncs(parent3, PARENT3);
++
++#undef ReadLockFunc
++#undef WriteLockFunc
++#undef RWLockFunc
++
++/* to debug easier, do not make them inlined functions */
++#define DiMustReadLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustReadLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustWriteLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustWriteLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustAnyLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustAnyLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustNoWaiters(d) RwMustNoWaiters(&dtodi(d)->di_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DENTRY_H__ */
+diff --git a/fs/aufs/dinfo.c b/fs/aufs/dinfo.c
+new file mode 100755
+index 0000000..6082149
+--- /dev/null
++++ b/fs/aufs/dinfo.c
+@@ -0,0 +1,419 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dinfo.c,v 1.23 2007/05/07 03:43:36 sfjro Exp $ */
++
++#include "aufs.h"
++
++int au_alloc_dinfo(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ struct super_block *sb;
++ int nbr;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(dentry->d_fsdata);
++
++ dinfo = cache_alloc_dinfo();
++ //if (LktrCond) {cache_free_dinfo(dinfo); dinfo = NULL;}
++ if (dinfo) {
++ sb = dentry->d_sb;
++ nbr = sbend(sb) + 1;
++ if (unlikely(!nbr))
++ nbr++;
++ dinfo->di_hdentry = kcalloc(nbr, sizeof(*dinfo->di_hdentry),
++ GFP_KERNEL);
++ //if (LktrCond)
++ //{kfree(dinfo->di_hdentry); dinfo->di_hdentry = NULL;}
++ if (dinfo->di_hdentry) {
++ rw_init_wlock_nested(&dinfo->di_rwsem, AuLsc_DI_PARENT);
++ dinfo->di_bstart = dinfo->di_bend = -1;
++ dinfo->di_bwh = dinfo->di_bdiropq = -1;
++ atomic_set(&dinfo->di_generation, au_sigen(sb));
++
++ dentry->d_fsdata = dinfo;
++ dentry->d_op = &aufs_dop;
++ return 0; /* success */
++ }
++ cache_free_dinfo(dinfo);
++ }
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
++
++struct aufs_dinfo *dtodi(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo = dentry->d_fsdata;
++ DEBUG_ON(!dinfo
++ || !dinfo->di_hdentry
++ /* || stosi(dentry->d_sb)->si_bend < dinfo->di_bend */
++ || dinfo->di_bend < dinfo->di_bstart
++ /* dbwh can be outside of this range */
++ || (0 <= dinfo->di_bdiropq
++ && (dinfo->di_bdiropq < dinfo->di_bstart
++ /* || dinfo->di_bend < dinfo->di_bdiropq */))
++ );
++ return dinfo;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void do_ii_write_lock(struct inode *inode, unsigned int lsc)
++{
++ switch (lsc) {
++ case AuLsc_DI_CHILD:
++ ii_write_lock_child(inode);
++ break;
++ case AuLsc_DI_CHILD2:
++ ii_write_lock_child2(inode);
++ break;
++ case AuLsc_DI_CHILD3:
++ ii_write_lock_child3(inode);
++ break;
++ case AuLsc_DI_PARENT:
++ ii_write_lock_parent(inode);
++ break;
++ case AuLsc_DI_PARENT2:
++ ii_write_lock_parent2(inode);
++ break;
++ case AuLsc_DI_PARENT3:
++ ii_write_lock_parent3(inode);
++ break;
++ default:
++ BUG();
++ }
++}
++
++static void do_ii_read_lock(struct inode *inode, unsigned int lsc)
++{
++ switch (lsc) {
++ case AuLsc_DI_CHILD:
++ ii_read_lock_child(inode);
++ break;
++ case AuLsc_DI_CHILD2:
++ ii_read_lock_child2(inode);
++ break;
++ case AuLsc_DI_CHILD3:
++ ii_read_lock_child3(inode);
++ break;
++ case AuLsc_DI_PARENT:
++ ii_read_lock_parent(inode);
++ break;
++ case AuLsc_DI_PARENT2:
++ ii_read_lock_parent2(inode);
++ break;
++ case AuLsc_DI_PARENT3:
++ ii_read_lock_parent3(inode);
++ break;
++ default:
++ BUG();
++ }
++}
++
++void di_read_lock(struct dentry *d, int flags, unsigned int lsc)
++{
++ SiMustAnyLock(d->d_sb);
++ // todo: always nested?
++ rw_read_lock_nested(&dtodi(d)->di_rwsem, lsc);
++ if (d->d_inode) {
++ if (flags & AUFS_I_WLOCK)
++ do_ii_write_lock(d->d_inode, lsc);
++ else if (flags & AUFS_I_RLOCK)
++ do_ii_read_lock(d->d_inode, lsc);
++ }
++}
++
++void di_read_unlock(struct dentry *d, int flags)
++{
++ SiMustAnyLock(d->d_sb);
++ if (d->d_inode) {
++ if (flags & AUFS_I_WLOCK)
++ ii_write_unlock(d->d_inode);
++ else if (flags & AUFS_I_RLOCK)
++ ii_read_unlock(d->d_inode);
++ }
++ rw_read_unlock(&dtodi(d)->di_rwsem);
++}
++
++void di_downgrade_lock(struct dentry *d, int flags)
++{
++ SiMustAnyLock(d->d_sb);
++ rw_dgrade_lock(&dtodi(d)->di_rwsem);
++ if (d->d_inode && (flags & AUFS_I_RLOCK))
++ ii_downgrade_lock(d->d_inode);
++}
++
++void di_write_lock(struct dentry *d, unsigned int lsc)
++{
++ SiMustAnyLock(d->d_sb);
++ // todo: always nested?
++ rw_write_lock_nested(&dtodi(d)->di_rwsem, lsc);
++ if (d->d_inode)
++ do_ii_write_lock(d->d_inode, lsc);
++}
++
++void di_write_unlock(struct dentry *d)
++{
++ SiMustAnyLock(d->d_sb);
++ if (d->d_inode)
++ ii_write_unlock(d->d_inode);
++ rw_write_unlock(&dtodi(d)->di_rwsem);
++}
++
++void di_write_lock2_child(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ struct dentry *d;
++
++ TraceEnter();
++ DEBUG_ON(d1 == d2
++ || d1->d_inode == d2->d_inode
++ || d1->d_sb != d2->d_sb);
++
++ if (isdir)
++ for (d = d1; d->d_parent != d; d = d->d_parent) // dget_parent()
++ if (d->d_parent == d2) {
++ di_write_lock_child(d1);
++ di_write_lock_child2(d2);
++ return;
++ }
++
++ di_write_lock_child(d2);
++ di_write_lock_child2(d1);
++}
++
++void di_write_lock2_parent(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ struct dentry *d;
++
++ TraceEnter();
++ DEBUG_ON(d1 == d2
++ || d1->d_inode == d2->d_inode
++ || d1->d_sb != d2->d_sb);
++
++ if (isdir)
++ for (d = d1; d->d_parent != d; d = d->d_parent) // dget_parent()
++ if (d->d_parent == d2) {
++ di_write_lock_parent(d1);
++ di_write_lock_parent2(d2);
++ return;
++ }
++
++ di_write_lock_parent(d2);
++ di_write_lock_parent2(d1);
++}
++
++void di_write_unlock2(struct dentry *d1, struct dentry *d2)
++{
++ di_write_unlock(d1);
++ if (d1->d_inode == d2->d_inode)
++ rw_write_unlock(&dtodi(d2)->di_rwsem);
++ else
++ di_write_unlock(d2);
++}
++
++/* ---------------------------------------------------------------------- */
++
++aufs_bindex_t dbstart(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bstart;
++}
++
++aufs_bindex_t dbend(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bend;
++}
++
++aufs_bindex_t dbwh(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bwh;
++}
++
++aufs_bindex_t dbdiropq(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ DEBUG_ON(dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode));
++ return dtodi(dentry)->di_bdiropq;
++}
++
++struct dentry *au_h_dptr_i(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ struct dentry *d;
++
++ DiMustAnyLock(dentry);
++ if (dbstart(dentry) < 0 || bindex < dbstart(dentry))
++ return NULL;
++ DEBUG_ON(bindex < 0
++ /* || bindex > sbend(dentry->d_sb) */);
++ d = dtodi(dentry)->di_hdentry[0 + bindex].hd_dentry;
++ DEBUG_ON(d && (atomic_read(&d->d_count) <= 0));
++ return d;
++}
++
++struct dentry *au_h_dptr(struct dentry *dentry)
++{
++ return au_h_dptr_i(dentry, dbstart(dentry));
++}
++
++aufs_bindex_t dbtail(struct dentry *dentry)
++{
++ aufs_bindex_t bend, bwh;
++
++ bend = dbend(dentry);
++ if (0 <= bend) {
++ bwh = dbwh(dentry);
++ //DEBUG_ON(bend < bwh);
++ if (!bwh)
++ return bwh;
++ if (0 < bwh && bwh < bend)
++ return bwh - 1;
++ }
++ return bend;
++}
++
++aufs_bindex_t dbtaildir(struct dentry *dentry)
++{
++ aufs_bindex_t bend, bopq;
++
++ DEBUG_ON(dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode));
++
++ bend = dbtail(dentry);
++ if (0 <= bend) {
++ bopq = dbdiropq(dentry);
++ DEBUG_ON(bend < bopq);
++ if (0 <= bopq && bopq < bend)
++ bend = bopq;
++ }
++ return bend;
++}
++
++aufs_bindex_t dbtail_generic(struct dentry *dentry)
++{
++ struct inode *inode;
++
++ inode = dentry->d_inode;
++ if (inode && S_ISDIR(inode->i_mode))
++ return dbtaildir(dentry);
++ else
++ return dbtail(dentry);
++}
++
++/* ---------------------------------------------------------------------- */
++
++// hard/soft set
++void set_dbstart(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ /* */
++ dtodi(dentry)->di_bstart = bindex;
++}
++
++void set_dbend(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex
++ || bindex < dbstart(dentry));
++ dtodi(dentry)->di_bend = bindex;
++}
++
++void set_dbwh(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ /* dbwh can be outside of bstart - bend range */
++ dtodi(dentry)->di_bwh = bindex;
++}
++
++void set_dbdiropq(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ DEBUG_ON((bindex != -1
++ && (bindex < dbstart(dentry) || dbend(dentry) < bindex))
++ || (dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode)));
++ dtodi(dentry)->di_bdiropq = bindex;
++}
++
++void hdput(struct aufs_hdentry *hd)
++{
++ dput(hd->hd_dentry);
++}
++
++void set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_dentry)
++{
++ struct aufs_hdentry *hd = dtodi(dentry)->di_hdentry + bindex;
++ DiMustWriteLock(dentry);
++ DEBUG_ON(bindex < dtodi(dentry)->di_bstart
++ || bindex > dtodi(dentry)->di_bend
++ || (h_dentry && atomic_read(&h_dentry->d_count) <= 0)
++ || (h_dentry && hd->hd_dentry)
++ );
++ if (hd->hd_dentry)
++ hdput(hd);
++ hd->hd_dentry = h_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void au_update_digen(struct dentry *dentry)
++{
++ //DiMustWriteLock(dentry);
++ DEBUG_ON(!dentry->d_sb);
++ atomic_set(&dtodi(dentry)->di_generation, au_sigen(dentry->d_sb));
++}
++
++void au_update_dbstart(struct dentry *dentry)
++{
++ aufs_bindex_t bindex, bstart = dbstart(dentry), bend = dbend(dentry);
++ struct dentry *hidden_dentry;
++
++ DiMustWriteLock(dentry);
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ if (hidden_dentry->d_inode) {
++ set_dbstart(dentry, bindex);
++ return;
++ }
++ set_h_dptr(dentry, bindex, NULL);
++ }
++ //set_dbstart(dentry, -1);
++ //set_dbend(dentry, -1);
++}
++
++int au_find_dbindex(struct dentry *dentry, struct dentry *hidden_dentry)
++{
++ aufs_bindex_t bindex, bend;
++
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++)
++ if (au_h_dptr_i(dentry, bindex) == hidden_dentry)
++ return bindex;
++ return -1;
++}
+diff --git a/fs/aufs/dir.c b/fs/aufs/dir.c
+new file mode 100755
+index 0000000..9afb1a9
+--- /dev/null
++++ b/fs/aufs/dir.c
+@@ -0,0 +1,564 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dir.c,v 1.36 2007/05/14 03:38:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static int reopen_dir(struct file *file)
++{
++ int err;
++ struct dentry *dentry, *hidden_dentry;
++ aufs_bindex_t bindex, btail, bstart;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!S_ISDIR(dentry->d_inode->i_mode));
++
++ /* open all hidden dirs */
++ bstart = dbstart(dentry);
++#if 1
++ for (bindex = fbstart(file); bindex < bstart; bindex++)
++ set_h_fptr(file, bindex, NULL);
++#endif
++ set_fbstart(file, bstart);
++ btail = dbtaildir(dentry);
++#if 1
++ for (bindex = fbend(file); btail < bindex; bindex--)
++ set_h_fptr(file, bindex, NULL);
++#endif
++ set_fbend(file, btail);
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (hidden_file) {
++ DEBUG_ON(hidden_file->f_dentry != hidden_dentry);
++ continue;
++ }
++
++ hidden_file = hidden_open(dentry, bindex, file->f_flags);
++ // unavailable
++ //if (LktrCond) {fput(hidden_file);
++ //br_put(stobr(dentry->d_sb, bindex));hidden_file=ERR_PTR(-1);}
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out; // close all?
++ //cpup_file_flags(hidden_file, file);
++ set_h_fptr(file, bindex, hidden_file);
++ }
++ err = 0;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int do_open_dir(struct file *file, int flags)
++{
++ int err;
++ aufs_bindex_t bindex, btail;
++ struct dentry *dentry, *hidden_dentry;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, 0x%x\n", DLNPair(dentry), flags);
++ DEBUG_ON(!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode));
++
++ err = 0;
++ set_fvdir_cache(file, NULL);
++ file->f_version = dentry->d_inode->i_version;
++ bindex = dbstart(dentry);
++ set_fbstart(file, bindex);
++ btail = dbtaildir(dentry);
++ set_fbend(file, btail);
++ for (; !err && bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++
++ hidden_file = hidden_open(dentry, bindex, flags);
++ //if (LktrCond) {fput(hidden_file);
++ //br_put(stobr(dentry->d_sb, bindex));hidden_file=ERR_PTR(-1);}
++ if (!IS_ERR(hidden_file)) {
++ set_h_fptr(file, bindex, hidden_file);
++ continue;
++ }
++ err = PTR_ERR(hidden_file);
++ }
++ if (!err)
++ return 0; /* success */
++
++ /* close all */
++ for (bindex = fbstart(file); !err && bindex <= btail; bindex++)
++ set_h_fptr(file, bindex, NULL);
++ set_fbstart(file, -1);
++ set_fbend(file, -1);
++ return err;
++}
++
++static int aufs_open_dir(struct inode *inode, struct file *file)
++{
++ return au_do_open(inode, file, do_open_dir);
++}
++
++static int aufs_release_dir(struct inode *inode, struct file *file)
++{
++ struct aufs_vdir *vdir_cache;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(file->f_dentry));
++
++ sb = file->f_dentry->d_sb;
++ si_read_lock(sb);
++ fi_write_lock(file);
++ vdir_cache = fvdir_cache(file);
++ if (vdir_cache)
++ free_vdir(vdir_cache);
++ fi_write_unlock(file);
++ au_fin_finfo(file);
++ si_read_unlock(sb);
++ return 0;
++}
++
++static int fsync_dir(struct dentry *dentry, int datasync)
++{
++ int err;
++ struct inode *inode;
++ struct super_block *sb;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ DiMustAnyLock(dentry);
++ sb = dentry->d_sb;
++ SiMustAnyLock(sb);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++ IiMustAnyLock(inode);
++
++ err = 0;
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); !err && bindex <= bend; bindex++) {
++ struct dentry *h_dentry;
++ struct inode *h_inode;
++ struct file_operations *fop;
++
++ if (test_ro(sb, bindex, inode))
++ continue;
++ h_dentry = au_h_dptr_i(dentry, bindex);
++ if (!h_dentry)
++ continue;
++ h_inode = h_dentry->d_inode;
++ if (!h_inode)
++ continue;
++
++ /* cf. fs/nsfd/vfs.c and fs/nfsd/nfs4recover.c */
++ //hdir_lock(h_inode, inode, bindex);
++ i_lock(h_inode);
++ fop = (void*)h_inode->i_fop;
++ err = filemap_fdatawrite(h_inode->i_mapping);
++ if (!err && fop && fop->fsync)
++ err = fop->fsync(NULL, h_dentry, datasync);
++ if (!err)
++ err = filemap_fdatawrite(h_inode->i_mapping);
++ //hdir_unlock(h_inode, inode, bindex);
++ i_unlock(h_inode);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * @file may be NULL
++ */
++static int aufs_fsync_dir(struct file *file, struct dentry *dentry,
++ int datasync)
++{
++ int err;
++ struct inode *inode;
++ struct file *hidden_file;
++ struct super_block *sb;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ err = 0;
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ if (file) {
++ err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
++ /*locked*/1);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ } else
++ di_read_lock_child(dentry, !AUFS_I_WLOCK);
++
++ ii_write_lock_child(inode);
++ if (file) {
++ bend = fbend(file);
++ for (bindex = fbstart(file); !err && bindex <= bend; bindex++) {
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (!hidden_file || test_ro(sb, bindex, inode))
++ continue;
++
++ err = -EINVAL;
++ if (hidden_file->f_op && hidden_file->f_op->fsync) {
++ // todo: try do_fsync() in fs/sync.c
++#if 0
++ DEBUG_ON(hidden_file->f_dentry->d_inode
++ != au_h_iptr_i(inode, bindex));
++ hdir_lock(hidden_file->f_dentry->d_inode, inode,
++ bindex);
++#else
++ i_lock(hidden_file->f_dentry->d_inode);
++#endif
++ err = hidden_file->f_op->fsync
++ (hidden_file, hidden_file->f_dentry,
++ datasync);
++ //err = -1;
++#if 0
++ hdir_unlock(hidden_file->f_dentry->d_inode,
++ inode, bindex);
++#else
++ i_unlock(hidden_file->f_dentry->d_inode);
++#endif
++ }
++ }
++ } else
++ err = fsync_dir(dentry, datasync);
++ au_cpup_attr_timesizes(inode);
++ ii_write_unlock(inode);
++ if (file)
++ fi_write_unlock(file);
++ else
++ di_read_unlock(dentry, !AUFS_I_WLOCK);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_readdir(struct file *file, void *dirent, filldir_t filldir)
++{
++ int err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ au_nfsd_lockdep_off();
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
++ /*locked*/1);
++ if (unlikely(err))
++ goto out;
++
++ ii_write_lock_child(inode);
++ err = au_init_vdir(file);
++ if (unlikely(err)) {
++ ii_write_unlock(inode);
++ goto out_unlock;
++ }
++ //DbgVdir(fvdir_cache(file));// goto out_unlock;
++
++ /* nfsd filldir calls lookup_one_len(). */
++ ii_downgrade_lock(inode);
++ err = au_fill_de(file, dirent, filldir);
++ //DbgVdir(fvdir_cache(file));// goto out_unlock;
++
++ inode->i_atime = au_h_iptr(inode)->i_atime;
++ ii_read_unlock(inode);
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ au_nfsd_lockdep_on();
++#if 0 // debug
++ if (LktrCond)
++ igrab(inode);
++#endif
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct test_empty_arg {
++ struct aufs_nhash *whlist;
++ int whonly;
++ aufs_bindex_t bindex;
++ int err, called;
++};
++
++static int test_empty_cb(void *__arg, const char *__name, int namelen,
++ loff_t offset, filldir_ino_t ino, unsigned int d_type)
++{
++ struct test_empty_arg *arg = __arg;
++ char *name = (void*)__name;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ arg->err = 0;
++ arg->called++;
++ //smp_mb();
++ if (name[0] == '.'
++ && (namelen == 1 || (name[1] == '.' && namelen == 2)))
++ return 0; /* success */
++
++ if (namelen <= AUFS_WH_PFX_LEN
++ || memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) {
++ if (arg->whonly && !test_known_wh(arg->whlist, name, namelen))
++ arg->err = -ENOTEMPTY;
++ goto out;
++ }
++
++ name += AUFS_WH_PFX_LEN;
++ namelen -= AUFS_WH_PFX_LEN;
++ if (!test_known_wh(arg->whlist, name, namelen))
++ arg->err = append_wh(arg->whlist, name, namelen, arg->bindex);
++
++ out:
++ //smp_mb();
++ TraceErr(arg->err);
++ return arg->err;
++}
++
++static int do_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
++{
++ int err, dlgt;
++ struct file *hidden_file;
++
++ LKTRTrace("%.*s, {%p, %d, %d}\n",
++ DLNPair(dentry), arg->whlist, arg->whonly, arg->bindex);
++
++ hidden_file = hidden_open(dentry, arg->bindex,
++ O_RDONLY | O_NONBLOCK | O_DIRECTORY
++ | O_LARGEFILE);
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out;
++
++ dlgt = need_dlgt(dentry->d_sb);
++ //hidden_file->f_pos = 0;
++ do {
++ arg->err = 0;
++ arg->called = 0;
++ //smp_mb();
++ err = vfsub_readdir(hidden_file, test_empty_cb, arg, dlgt);
++ if (err >= 0)
++ err = arg->err;
++ } while (!err && arg->called);
++ fput(hidden_file);
++ sbr_put(dentry->d_sb, arg->bindex);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct do_test_empty_args {
++ int *errp;
++ struct dentry *dentry;
++ struct test_empty_arg *arg;
++};
++
++static void call_do_test_empty(void *args)
++{
++ struct do_test_empty_args *a = args;
++ *a->errp = do_test_empty(a->dentry, a->arg);
++}
++
++static int sio_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
++{
++ int err;
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ hidden_dentry = au_h_dptr_i(dentry, arg->bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode || !S_ISDIR(hidden_inode->i_mode));
++
++ hi_lock_child(hidden_inode);
++ err = au_test_perm(hidden_inode, MAY_EXEC | MAY_READ,
++ need_dlgt(dentry->d_sb));
++ i_unlock(hidden_inode);
++ if (!err)
++ err = do_test_empty(dentry, arg);
++ else {
++ struct do_test_empty_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .arg = arg
++ };
++ au_wkq_wait(call_do_test_empty, &args, /*dlgt*/0);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++int au_test_empty_lower(struct dentry *dentry)
++{
++ int err;
++ struct inode *inode;
++ struct test_empty_arg arg;
++ struct aufs_nhash *whlist;
++ aufs_bindex_t bindex, bstart, btail;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++
++ bstart = dbstart(dentry);
++ arg.whlist = whlist;
++ arg.whonly = 0;
++ arg.bindex = bstart;
++ err = do_test_empty(dentry, &arg);
++ if (unlikely(err))
++ goto out_whlist;
++
++ arg.whonly = 1;
++ btail = dbtaildir(dentry);
++ for (bindex = bstart + 1; !err && bindex <= btail; bindex++) {
++ struct dentry *hidden_dentry;
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry && hidden_dentry->d_inode) {
++ DEBUG_ON(!S_ISDIR(hidden_dentry->d_inode->i_mode));
++ arg.bindex = bindex;
++ err = do_test_empty(dentry, &arg);
++ }
++ }
++
++ out_whlist:
++ nhash_del(whlist);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int test_empty(struct dentry *dentry, struct aufs_nhash *whlist)
++{
++ int err;
++ struct inode *inode;
++ struct test_empty_arg arg;
++ aufs_bindex_t bindex, btail;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ err = 0;
++ arg.whlist = whlist;
++ arg.whonly = 1;
++ btail = dbtaildir(dentry);
++ for (bindex = dbstart(dentry); !err && bindex <= btail; bindex++) {
++ struct dentry *hidden_dentry;
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry && hidden_dentry->d_inode) {
++ DEBUG_ON(!S_ISDIR(hidden_dentry->d_inode->i_mode));
++ arg.bindex = bindex;
++ err = sio_test_empty(dentry, &arg);
++ }
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void au_add_nlink(struct inode *dir, struct inode *h_dir)
++{
++ DEBUG_ON(!S_ISDIR(dir->i_mode) || !S_ISDIR(h_dir->i_mode));
++ dir->i_nlink += h_dir->i_nlink - 2;
++ if (unlikely(h_dir->i_nlink < 2))
++ dir->i_nlink += 2;
++}
++
++void au_sub_nlink(struct inode *dir, struct inode *h_dir)
++{
++ DEBUG_ON(!S_ISDIR(dir->i_mode) || !S_ISDIR(h_dir->i_mode));
++ dir->i_nlink -= h_dir->i_nlink - 2;
++ if (unlikely(h_dir->i_nlink < 2))
++ dir->i_nlink -= 2;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 // comment
++struct file_operations {
++ struct module *owner;
++ loff_t (*llseek) (struct file *, loff_t, int);
++ ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
++ ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
++ ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
++ ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
++ int (*readdir) (struct file *, void *, filldir_t);
++ unsigned int (*poll) (struct file *, struct poll_table_struct *);
++ int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
++ long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
++ long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
++ int (*mmap) (struct file *, struct vm_area_struct *);
++ int (*open) (struct inode *, struct file *);
++ int (*flush) (struct file *);
++ int (*release) (struct inode *, struct file *);
++ int (*fsync) (struct file *, struct dentry *, int datasync);
++ int (*aio_fsync) (struct kiocb *, int datasync);
++ int (*fasync) (int, struct file *, int);
++ int (*lock) (struct file *, int, struct file_lock *);
++ ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
++ ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
++ unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
++ int (*check_flags)(int);
++ int (*dir_notify)(struct file *file, unsigned long arg);
++ int (*flock) (struct file *, int, struct file_lock *);
++};
++#endif
++
++struct file_operations aufs_dir_fop = {
++ .read = generic_read_dir,
++ .readdir = aufs_readdir,
++ .open = aufs_open_dir,
++ .release = aufs_release_dir,
++ .flush = aufs_flush,
++ .fsync = aufs_fsync_dir,
++};
+diff --git a/fs/aufs/dir.h b/fs/aufs/dir.h
+new file mode 100755
+index 0000000..3ddf309
+--- /dev/null
++++ b/fs/aufs/dir.h
+@@ -0,0 +1,125 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dir.h,v 1.18 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DIR_H__
++#define __AUFS_DIR_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
++#define filldir_ino_t u64
++#else
++#define filldir_ino_t ino_t
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* need to be faster and smaller */
++
++#define AUFS_DEBLK_SIZE 512 // todo: changable
++#define AUFS_NHASH_SIZE 32 // todo: changable
++#if AUFS_DEBLK_SIZE < NAME_MAX || PAGE_SIZE < AUFS_DEBLK_SIZE
++#error invalid size AUFS_DEBLK_SIZE
++#endif
++
++typedef char aufs_deblk_t[AUFS_DEBLK_SIZE];
++
++struct aufs_nhash {
++ struct hlist_head heads[AUFS_NHASH_SIZE];
++};
++
++struct aufs_destr {
++ unsigned char len;
++ char name[0];
++} __attribute__ ((packed));
++
++struct aufs_dehstr {
++ struct hlist_node hash;
++ struct aufs_destr *str;
++};
++
++struct aufs_de {
++ ino_t de_ino;
++ unsigned char de_type;
++ //caution: packed
++ struct aufs_destr de_str;
++} __attribute__ ((packed));
++
++struct aufs_wh {
++ struct hlist_node wh_hash;
++ aufs_bindex_t wh_bindex;
++ struct aufs_destr wh_str;
++} __attribute__ ((packed));
++
++union aufs_deblk_p {
++ unsigned char *p;
++ aufs_deblk_t *deblk;
++ struct aufs_de *de;
++};
++
++struct aufs_vdir {
++ aufs_deblk_t **vd_deblk;
++ int vd_nblk;
++ struct {
++ int i;
++ union aufs_deblk_p p;
++ } vd_last;
++
++ unsigned long vd_version;
++ unsigned long vd_jiffy;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* dir.c */
++extern struct file_operations aufs_dir_fop;
++int au_test_empty_lower(struct dentry *dentry);
++int test_empty(struct dentry *dentry, struct aufs_nhash *whlist);
++void au_add_nlink(struct inode *dir, struct inode *h_dir);
++void au_sub_nlink(struct inode *dir, struct inode *h_dir);
++
++/* vdir.c */
++struct aufs_nhash *nhash_new(gfp_t gfp);
++void nhash_del(struct aufs_nhash *nhash);
++void nhash_init(struct aufs_nhash *nhash);
++void nhash_move(struct aufs_nhash *dst, struct aufs_nhash *src);
++void nhash_fin(struct aufs_nhash *nhash);
++int is_longer_wh(struct aufs_nhash *whlist, aufs_bindex_t btgt, int limit);
++int test_known_wh(struct aufs_nhash *whlist, char *name, int namelen);
++int append_wh(struct aufs_nhash *whlist, char *name, int namelen,
++ aufs_bindex_t bindex);
++void free_vdir(struct aufs_vdir *vdir);
++int au_init_vdir(struct file *file);
++int au_fill_de(struct file *file, void *dirent, filldir_t filldir);
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++unsigned int au_name_hash(const unsigned char *name, unsigned int len)
++{
++ return (full_name_hash(name, len) % AUFS_NHASH_SIZE);
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DIR_H__ */
+diff --git a/fs/aufs/export.c b/fs/aufs/export.c
+new file mode 100755
+index 0000000..7b1c6ac
+--- /dev/null
++++ b/fs/aufs/export.c
+@@ -0,0 +1,585 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: export.c,v 1.7 2007/05/14 03:38:24 sfjro Exp $ */
++
++#include "aufs.h"
++
++extern struct export_operations export_op_default;
++#define CALL(ops, func) (((ops)->func) ? ((ops)->func) : export_op_default.func)
++#define is_anon(d) ((d)->d_flags & DCACHE_DISCONNECTED)
++
++union conv {
++#if BITS_PER_LONG == 32
++ __u32 a[1];
++#else
++ __u32 a[2];
++#endif
++ ino_t ino;
++};
++
++static ino_t decode_ino(__u32 *a)
++{
++ union conv u;
++ u.a[0] = a[0];
++#if BITS_PER_LONG == 64
++ u.a[1] = a[1];
++#endif
++ return u.ino;
++}
++
++static void encode_ino(__u32 *a, ino_t ino)
++{
++ union conv u;
++ u.ino = ino;
++ a[0] = u.a[0];
++#if BITS_PER_LONG == 64
++ a[1] = u.a[1];
++#endif
++}
++
++static void decode_br_id_sigen(__u32 a, aufs_bindex_t *br_id,
++ aufs_bindex_t *sigen)
++{
++ BUILD_BUG_ON((sizeof(*br_id) + sizeof(*sigen)) > sizeof(a));
++ *br_id = a >> 16;
++ DEBUG_ON(*br_id < 0);
++ *sigen = a;
++ DEBUG_ON(*sigen < 0);
++}
++
++static __u32 encode_br_id_sigen(aufs_bindex_t br_id, aufs_bindex_t sigen)
++{
++ DEBUG_ON(br_id < 0 || sigen < 0);
++ return (br_id << 16) | sigen;
++}
++
++/* NFS file handle */
++enum {
++ /* support 64bit inode number */
++ /* but untested */
++ Fh_br_id_sigen,
++ Fh_ino1,
++#if BITS_PER_LONG == 64
++ Fh_ino2,
++#endif
++ Fh_dir_ino1,
++#if BITS_PER_LONG == 64
++ Fh_dir_ino2,
++#endif
++ Fh_h_ino1,
++#if BITS_PER_LONG == 64
++ Fh_h_ino2,
++#endif
++ Fh_h_igen,
++ Fh_h_type,
++ Fh_tail,
++
++ Fh_ino = Fh_ino1,
++ Fh_dir_ino = Fh_dir_ino1,
++ Fh_h_ino = Fh_h_ino1,
++};
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry *decode_by_ino(struct super_block *sb, ino_t ino,
++ ino_t dir_ino)
++{
++ struct dentry *dentry;
++ struct inode *inode;
++
++ LKTRTrace("i%lu, diri%lu\n", ino, dir_ino);
++
++ dentry = NULL;
++ inode = ilookup(sb, ino);
++ if (unlikely(!inode))
++ goto out;
++
++ dentry = ERR_PTR(-ESTALE);
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ dentry = NULL;
++ if (!S_ISDIR(inode->i_mode)) {
++ struct dentry *d;
++ spin_lock(&dcache_lock);
++ list_for_each_entry(d, &inode->i_dentry, d_alias)
++ if (!is_anon(d)
++ && d->d_parent->d_inode->i_ino == dir_ino) {
++ dentry = dget_locked(d);
++ break;
++ }
++ spin_unlock(&dcache_lock);
++ } else {
++ dentry = d_find_alias(inode);
++ if (dentry
++ && !is_anon(dentry)
++ && dentry->d_parent->d_inode->i_ino == dir_ino)
++ goto out_iput; /* success */
++
++ dput(dentry);
++ dentry = NULL;
++ }
++
++ out_iput:
++ iput(inode);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct find_name_by_ino {
++ int called, found;
++ ino_t ino;
++ char *name;
++ int namelen;
++};
++
++static int
++find_name_by_ino(void *arg, const char *name, int namelen, loff_t offset,
++ filldir_ino_t ino, unsigned int d_type)
++{
++ struct find_name_by_ino *a = arg;
++
++ a->called++;
++ if (a->ino != ino)
++ return 0;
++
++ memcpy(a->name, name, namelen);
++ a->namelen = namelen;
++ a->found = 1;
++ return 1;
++}
++
++static struct dentry *decode_by_dir_ino(struct super_block *sb, ino_t ino,
++ ino_t dir_ino)
++{
++ struct dentry *dentry, *parent;
++ struct inode *dir;
++ struct find_name_by_ino arg;
++ struct file *file;
++ int err;
++
++ LKTRTrace("i%lu, diri%lu\n", ino, dir_ino);
++
++ dentry = NULL;
++ dir = ilookup(sb, dir_ino);
++ if (unlikely(!dir))
++ goto out;
++
++ dentry = ERR_PTR(-ESTALE);
++ if (unlikely(is_bad_inode(dir)))
++ goto out_iput;
++
++ dentry = NULL;
++ parent = d_find_alias(dir);
++ if (parent) {
++ if (unlikely(is_anon(parent))) {
++ dput(parent);
++ goto out_iput;
++ }
++ } else
++ goto out_iput;
++
++ file = dentry_open(parent, NULL, au_dir_roflags);
++ dentry = (void*)file;
++ if (IS_ERR(file))
++ goto out_iput;
++
++ dentry = ERR_PTR(-ENOMEM);
++ arg.name = __getname();
++ if (unlikely(!arg.name))
++ goto out_fput;
++ arg.ino = ino;
++ arg.found = 0;
++
++ do {
++ arg.called = 0;
++ //smp_mb();
++ err = vfsub_readdir(file, find_name_by_ino, &arg, /*dlgt*/0);
++ } while (!err && !arg.found && arg.called);
++ dentry = ERR_PTR(err);
++ if (arg.found) {
++ /* do not call lkup_one(), nor dlgt */
++ i_lock(dir);
++ dentry = lookup_one_len(arg.name, parent, arg.namelen);
++ i_unlock(dir);
++ TraceErrPtr(dentry);
++ }
++
++ //out_putname:
++ __putname(arg.name);
++ out_fput:
++ fput(file);
++ out_iput:
++ iput(dir);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct append_name {
++ int found, called, len;
++ char *h_path;
++ ino_t h_ino;
++};
++
++static int append_name(void *arg, const char *name, int len, loff_t pos,
++ filldir_ino_t ino, unsigned int d_type)
++{
++ struct append_name *a = arg;
++ char *p;
++
++ a->called++;
++ if (ino != a->h_ino)
++ return 0;
++
++ DEBUG_ON(len == 1 && *name == '.');
++ DEBUG_ON(len == 2 && name[0] == '.' && name[1] == '.');
++ a->len = strlen(a->h_path);
++ memmove(a->h_path - a->len - 1, a->h_path, a->len);
++ a->h_path -= a->len + 1;
++ p = a->h_path + a->len;
++ *p++ = '/';
++ memcpy(p, name, a->len);
++ a->len += 1 + len;
++ a->found++;
++ return 1;
++}
++
++static int h_acceptable(void *expv, struct dentry *dentry)
++{
++ return 1;
++}
++
++static struct dentry*
++decode_by_path(struct super_block *sb, aufs_bindex_t bindex, __u32 *fh,
++ int fh_len, void *context)
++{
++ struct dentry *dentry, *h_parent, *root, *h_root;
++ struct super_block *h_sb;
++ char *path, *p;
++ struct vfsmount *h_mnt;
++ struct append_name arg;
++ int len, err;
++ struct file *h_file;
++ struct nameidata nd;
++ struct aufs_branch *br;
++
++ LKTRTrace("b%d\n", bindex);
++ SiMustAnyLock(sb);
++
++ br = stobr(sb, bindex);
++ //br_get(br);
++ h_mnt = br->br_mnt;
++ h_sb = h_mnt->mnt_sb;
++ LKTRTrace("%s, h_decode_fh\n", au_sbtype(h_sb));
++ h_parent = CALL(h_sb->s_export_op, decode_fh)
++ (h_sb, fh + Fh_tail, fh_len - Fh_tail, fh[Fh_h_type],
++ h_acceptable, /*context*/NULL);
++ dentry = h_parent;
++ if (unlikely(!h_parent || IS_ERR(h_parent))) {
++ Warn1("%s decode_fh failed\n", au_sbtype(h_sb));
++ goto out;
++ }
++ dentry = NULL;
++ if (unlikely(is_anon(h_parent))) {
++ Warn1("%s decode_fh returned a disconnected dentry\n",
++ au_sbtype(h_sb));
++ dput(h_parent);
++ goto out;
++ }
++
++ dentry = ERR_PTR(-ENOMEM);
++ path = __getname();
++ if (unlikely(!path)) {
++ dput(h_parent);
++ goto out;
++ }
++
++ root = sb->s_root;
++ di_read_lock_parent(root, !AUFS_I_RLOCK);
++ h_root = au_h_dptr_i(root, bindex);
++ di_read_unlock(root, !AUFS_I_RLOCK);
++ arg.h_path = d_path(h_root, h_mnt, path, PATH_MAX);
++ dentry = (void*)arg.h_path;
++ if (unlikely(!arg.h_path || IS_ERR(arg.h_path)))
++ goto out_putname;
++ len = strlen(arg.h_path);
++ arg.h_path = d_path(h_parent, h_mnt, path, PATH_MAX);
++ dentry = (void*)arg.h_path;
++ if (unlikely(!arg.h_path || IS_ERR(arg.h_path)))
++ goto out_putname;
++ LKTRTrace("%s\n", arg.h_path);
++ if (len != 1)
++ arg.h_path += len;
++ LKTRTrace("%s\n", arg.h_path);
++
++ /* cf. fs/exportfs/expfs.c */
++ h_file = dentry_open(h_parent, NULL, au_dir_roflags);
++ dentry = (void*)h_file;
++ if (IS_ERR(h_file))
++ goto out_putname;
++
++ arg.found = 0;
++ arg.h_ino = decode_ino(fh + Fh_h_ino);
++ do {
++ arg.called = 0;
++ err = vfsub_readdir(h_file, append_name, &arg, /*dlgt*/0);
++ } while (!err && !arg.found && arg.called);
++ LKTRTrace("%s, %d\n", arg.h_path, arg.len);
++
++ p = d_path(root, stosi(sb)->si_mnt, path, PATH_MAX - arg.len - 2);
++ dentry = (void*)p;
++ if (unlikely(!p || IS_ERR(p)))
++ goto out_fput;
++ p[strlen(p)] = '/';
++ LKTRTrace("%s\n", p);
++
++ err = path_lookup(p, LOOKUP_FOLLOW, &nd);
++ dentry = ERR_PTR(err);
++ if (!err) {
++ dentry = dget(nd.dentry);
++ if (unlikely(is_anon(dentry))) {
++ dput(dentry);
++ dentry = ERR_PTR(-ESTALE);
++ }
++ path_release(&nd);
++ }
++
++ out_fput:
++ fput(h_file);
++ out_putname:
++ __putname(path);
++ out:
++ //br_put(br);
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry*
++aufs_decode_fh(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context)
++{
++ struct dentry *dentry;
++ ino_t ino, dir_ino;
++ aufs_bindex_t bindex, br_id, sigen_v;
++ struct inode *inode, *h_inode;
++
++ //au_debug_on();
++ LKTRTrace("%d, fh{i%u, br_id_sigen 0x%x, hi%u}\n",
++ fh_type, fh[Fh_ino], fh[Fh_br_id_sigen], fh[Fh_h_ino]);
++ DEBUG_ON(fh_len < Fh_tail);
++
++ si_read_lock(sb);
++ lockdep_off();
++
++ /* branch id may be wrapped around */
++ dentry = ERR_PTR(-ESTALE);
++ decode_br_id_sigen(fh[Fh_br_id_sigen], &br_id, &sigen_v);
++ bindex = find_brindex(sb, br_id);
++ if (unlikely(bindex < 0 || au_sigen(sb) < sigen_v))
++ goto out;
++
++ /* is this inode still cached? */
++ ino = decode_ino(fh + Fh_ino);
++ dir_ino = decode_ino(fh + Fh_dir_ino);
++ dentry = decode_by_ino(sb, ino, dir_ino);
++ if (IS_ERR(dentry))
++ goto out;
++ if (dentry)
++ goto accept;
++
++ /* is the parent dir cached? */
++ dentry = decode_by_dir_ino(sb, ino, dir_ino);
++ if (IS_ERR(dentry))
++ goto out;
++ if (dentry)
++ goto accept;
++
++ /* lookup path */
++ dentry = decode_by_path(sb, bindex, fh, fh_len, context);
++ if (IS_ERR(dentry))
++ goto out;
++ if (unlikely(!dentry))
++ goto out_stale;
++ if (unlikely(dentry->d_inode->i_ino != ino))
++ goto out_dput;
++
++ accept:
++ inode = dentry->d_inode;
++ h_inode = NULL;
++ ii_read_lock_child(inode);
++ if (ibstart(inode) <= bindex && bindex <= ibend(inode))
++ h_inode = au_h_iptr_i(inode, bindex);
++ ii_read_unlock(inode);
++ if (h_inode
++ && h_inode->i_generation == fh[Fh_h_igen]
++ && acceptable(context, dentry))
++ goto out; /* success */
++ out_dput:
++ dput(dentry);
++ out_stale:
++ dentry = ERR_PTR(-ESTALE);
++ out:
++ lockdep_on();
++ si_read_unlock(sb);
++ TraceErrPtr(dentry);
++ //au_debug_off();
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
++ int connectable)
++{
++ int err;
++ struct super_block *sb, *h_sb;
++ struct inode *inode, *h_inode, *dir;
++ aufs_bindex_t bindex;
++ union conv u;
++ struct dentry *parent, *h_parent;
++
++ //au_debug_on();
++ BUILD_BUG_ON(sizeof(u.ino) != sizeof(u.a));
++ LKTRTrace("%.*s, max %d, conn %d\n",
++ DLNPair(dentry), *max_len, connectable);
++ DEBUG_ON(is_anon(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode);
++ parent = dentry->d_parent;
++ DEBUG_ON(is_anon(parent));
++
++ err = -ENOSPC;
++ if (unlikely(*max_len <= Fh_tail)) {
++ Warn1("NFSv2 client (max_len %d)?\n", *max_len);
++ goto out;
++ }
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++#ifdef CONFIG_AUFS_DEBUG
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ Warn1("NFS-exporting requires xino\n");
++#if 0
++ if (unlikely(au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ Warn1("udba=inotify is not recommended when exporting\n");
++#endif
++#endif
++
++ err = -EPERM;
++ bindex = ibstart(inode);
++ h_sb = sbr_sb(sb, bindex);
++ if (unlikely(!h_sb->s_export_op)) {
++ Err1("%s branch is not exportable\n", au_sbtype(h_sb));
++ goto out_unlock;
++ }
++
++#if 0 //def CONFIG_AUFS_ROBR
++ if (unlikely(SB_AUFS(h_sb))) {
++ Err1("aufs branch is not supported\n");
++ goto out_unlock;
++ }
++#endif
++
++ /* doesn't support pseudo-link */
++ if (unlikely(bindex < dbstart(dentry)
++ || dbend(dentry) < bindex
++ || !au_h_dptr_i(dentry, bindex))) {
++ Err("%.*s/%.*s, b%d, pseudo-link?\n",
++ DLNPair(dentry->d_parent), DLNPair(dentry), bindex);
++ goto out_unlock;
++ }
++
++ fh[Fh_br_id_sigen] = encode_br_id_sigen(sbr_id(sb, bindex),
++ au_sigen(sb));
++ encode_ino(fh + Fh_ino, inode->i_ino);
++ dir = parent->d_inode;
++ encode_ino(fh + Fh_dir_ino, dir->i_ino);
++ h_inode = au_h_iptr(inode);
++ encode_ino(fh + Fh_h_ino, h_inode->i_ino);
++ fh[Fh_h_igen] = h_inode->i_generation;
++
++ /* it should be set at exporting time */
++ if (unlikely(!h_sb->s_export_op->find_exported_dentry)) {
++ Warn("set default find_exported_dentry for %s\n",
++ au_sbtype(h_sb));
++ h_sb->s_export_op->find_exported_dentry = find_exported_dentry;
++ }
++
++ *max_len -= Fh_tail;
++ //LKTRTrace("Fh_tail %d, max_len %d\n", Fh_tail, *max_len);
++ h_parent = au_h_dptr_i(parent, bindex);
++ DEBUG_ON(is_anon(h_parent));
++ err = fh[Fh_h_type] = CALL(h_sb->s_export_op, encode_fh)
++ (h_parent, fh + Fh_tail, max_len, connectable);
++ *max_len += Fh_tail;
++ if (err != 255)
++ err = 2; //??
++ else
++ Warn1("%s encode_fh failed\n", au_sbtype(h_sb));
++
++ out_unlock:
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ out:
++ TraceErr(err);
++ //au_debug_off();
++ if (unlikely(err < 0))
++ err = 255;
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0
++struct export_operations {
++ struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context);
++ int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
++ int connectable);
++
++ /* the following are only called from the filesystem itself */
++ int (*get_name)(struct dentry *parent, char *name,
++ struct dentry *child);
++ struct dentry * (*get_parent)(struct dentry *child);
++ struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
++
++ /* This is set by the exporting module to a standard helper */
++ struct dentry * (*find_exported_dentry)(
++ struct super_block *sb, void *obj, void *parent,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context);
++};
++#endif
++
++struct export_operations aufs_export_op = {
++ .decode_fh = aufs_decode_fh,
++ .encode_fh = aufs_encode_fh
++};
+diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
+new file mode 100755
+index 0000000..3cd1081
+--- /dev/null
++++ b/fs/aufs/f_op.c
+@@ -0,0 +1,684 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: f_op.c,v 1.27 2007/05/14 03:38:24 sfjro Exp $ */
++
++#include <linux/fsnotify.h>
++#include <linux/pagemap.h>
++#include <linux/poll.h>
++#include <linux/security.h>
++#include <linux/version.h>
++#include "aufs.h"
++
++/* common function to regular file and dir */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#define FlushArgs hidden_file, id
++int aufs_flush(struct file *file, fl_owner_t id)
++#else
++#define FlushArgs hidden_file
++int aufs_flush(struct file *file)
++#endif
++{
++ int err;
++ struct dentry *dentry;
++ aufs_bindex_t bindex, bend;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ // aufs_read_lock_file()
++ si_read_lock(dentry->d_sb);
++ fi_read_lock(file);
++ di_read_lock_child(dentry, !AUFS_I_RLOCK);
++
++ err = 0;
++ bend = fbend(file);
++ for (bindex = fbstart(file); !err && bindex <= bend; bindex++) {
++ struct file *hidden_file;
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (hidden_file && hidden_file->f_op
++ && hidden_file->f_op->flush)
++ err = hidden_file->f_op->flush(FlushArgs);
++ }
++
++ di_read_unlock(dentry, !AUFS_I_RLOCK);
++ fi_read_unlock(file);
++ si_read_unlock(dentry->d_sb);
++ TraceErr(err);
++ return err;
++}
++#undef FlushArgs
++
++/* ---------------------------------------------------------------------- */
++
++static int do_open_nondir(struct file *file, int flags)
++{
++ int err;
++ aufs_bindex_t bindex;
++ struct super_block *sb;
++ struct file *hidden_file;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_finfo *finfo;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, flags 0%o\n", DLNPair(dentry), flags);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || S_ISDIR(inode->i_mode));
++
++ err = 0;
++ finfo = ftofi(file);
++ finfo->fi_h_vm_ops = NULL;
++ sb = dentry->d_sb;
++ bindex = dbstart(dentry);
++ DEBUG_ON(!au_h_dptr(dentry)->d_inode);
++ /* O_TRUNC is processed already */
++ BUG_ON(test_ro(sb, bindex, inode) && (flags & O_TRUNC));
++
++ hidden_file = hidden_open(dentry, bindex, flags);
++ //if (LktrCond) {fput(hidden_file); br_put(stobr(dentry->d_sb, bindex));
++ //hidden_file = ERR_PTR(-1);}
++ if (!IS_ERR(hidden_file)) {
++ set_fbstart(file, bindex);
++ set_fbend(file, bindex);
++ set_h_fptr(file, bindex, hidden_file);
++ return 0; /* success */
++ }
++ err = PTR_ERR(hidden_file);
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_open_nondir(struct inode *inode, struct file *file)
++{
++ return au_do_open(inode, file, do_open_nondir);
++}
++
++static int aufs_release_nondir(struct inode *inode, struct file *file)
++{
++ struct super_block *sb = file->f_dentry->d_sb;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(file->f_dentry));
++
++ si_read_lock(sb);
++ au_fin_finfo(file);
++ si_read_unlock(sb);
++ return 0;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t aufs_read(struct file *file, char __user *buf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ struct dentry *dentry;
++ struct file *hidden_file;
++ struct super_block *sb;
++ struct inode *h_inode;
++ int dlgt;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(dentry), (unsigned long)count, *ppos);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //if (LktrCond) {fi_read_unlock(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ /* support LSM and notify */
++ dlgt = need_dlgt(sb);
++ hidden_file = au_h_fptr(file);
++ h_inode = hidden_file->f_dentry->d_inode;
++ if (!au_flag_test(sb, AuFlag_UDBA_INOTIFY))
++ err = vfsub_read_u(hidden_file, buf, count, ppos, dlgt);
++ else {
++ struct inode *dir = dentry->d_parent->d_inode,
++ *h_dir = hidden_file->f_dentry->d_parent->d_inode;
++ aufs_bindex_t bstart = fbstart(file);
++ hdir_lock(h_dir, dir, bstart);
++ err = vfsub_read_u(hidden_file, buf, count, ppos, dlgt);
++ hdir_unlock(h_dir, dir, bstart);
++ }
++ memcpy(&file->f_ra, &hidden_file->f_ra, sizeof(file->f_ra)); //??
++ dentry->d_inode->i_atime = hidden_file->f_dentry->d_inode->i_atime;
++
++ fi_read_unlock(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++static ssize_t aufs_write(struct file *file, const char __user *__buf,
++ size_t count, loff_t *ppos)
++{
++ ssize_t err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct super_block *sb;
++ struct file *hidden_file;
++ char __user *buf = (char __user*)__buf;
++ struct inode *h_inode;
++ int dlgt;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(dentry), (unsigned long)count, *ppos);
++
++ inode = dentry->d_inode;
++ i_lock(inode);
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/1,
++ /*locked*/1);
++ //if (LktrCond) {fi_write_unlock(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++ err = au_ready_to_write(file, -1);
++ //if (LktrCond) err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++
++ /* support LSM and notify */
++ dlgt = need_dlgt(sb);
++ hidden_file = au_h_fptr(file);
++ h_inode = hidden_file->f_dentry->d_inode;
++ if (!au_flag_test(sb, AuFlag_UDBA_INOTIFY))
++ err = vfsub_write_u(hidden_file, buf, count, ppos, dlgt);
++ else {
++ struct inode *dir = dentry->d_parent->d_inode,
++ *h_dir = hidden_file->f_dentry->d_parent->d_inode;
++ aufs_bindex_t bstart = fbstart(file);
++ hdir_lock(h_dir, dir, bstart);
++ err = vfsub_write_u(hidden_file, buf, count, ppos, dlgt);
++ hdir_unlock(h_dir, dir, bstart);
++ }
++ ii_write_lock_child(inode);
++ au_cpup_attr_timesizes(inode);
++ ii_write_unlock(inode);
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ i_unlock(inode);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 //def CONFIG_AUFS_ROBR
++struct lvma {
++ struct list_head list;
++ struct vm_area_struct *vma;
++};
++
++static struct file *safe_file(struct vm_area_struct *vma)
++{
++ struct file *file = vma->vm_file;
++ struct super_block *sb = file->f_dentry->d_sb;
++ struct lvma *lvma, *entry;
++ struct aufs_sbinfo *sbinfo;
++ int found, warn;
++
++ TraceEnter();
++ DEBUG_ON(!SB_AUFS(sb));
++
++ warn = 0;
++ found = 0;
++ sbinfo = stosi(sb);
++ spin_lock(&sbinfo->si_lvma_lock);
++ list_for_each_entry(entry, &sbinfo->si_lvma, list) {
++ found = (entry->vma == vma);
++ if (unlikely(found))
++ break;
++ }
++ if (!found) {
++ lvma = kmalloc(sizeof(*lvma), GFP_ATOMIC);
++ if (lvma) {
++ lvma->vma = vma;
++ list_add(&lvma->list, &sbinfo->si_lvma);
++ } else {
++ warn = 1;
++ file = NULL;
++ }
++ } else
++ file = NULL;
++ spin_unlock(&sbinfo->si_lvma_lock);
++
++ if (unlikely(warn))
++ Warn1("no memory for lvma\n");
++ return file;
++}
++
++static void reset_file(struct vm_area_struct *vma, struct file *file)
++{
++ struct super_block *sb = file->f_dentry->d_sb;
++ struct lvma *entry, *found;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ DEBUG_ON(!SB_AUFS(sb));
++
++ vma->vm_file = file;
++
++ found = NULL;
++ sbinfo = stosi(sb);
++ spin_lock(&sbinfo->si_lvma_lock);
++ list_for_each_entry(entry, &sbinfo->si_lvma, list)
++ if (entry->vma == vma){
++ found = entry;
++ break;
++ }
++ DEBUG_ON(!found);
++ list_del(&found->list);
++ spin_unlock(&sbinfo->si_lvma_lock);
++ kfree(found);
++}
++
++#else
++
++static struct file *safe_file(struct vm_area_struct *vma)
++{
++ struct file *file;
++
++ file = vma->vm_file;
++ if (file->private_data && au_is_aufs(file->f_dentry->d_sb))
++ return file;
++ return NULL;
++}
++
++static void reset_file(struct vm_area_struct *vma, struct file *file)
++{
++ vma->vm_file = file;
++ smp_mb();
++}
++#endif /* CONFIG_AUFS_ROBR */
++
++static struct page *aufs_nopage(struct vm_area_struct *vma, unsigned long addr,
++ int *type)
++{
++ struct page *page;
++ struct dentry *dentry;
++ struct file *file, *hidden_file;
++ struct inode *inode;
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ struct aufs_finfo *finfo;
++
++ TraceEnter();
++ DEBUG_ON(!vma || !vma->vm_file);
++ wait_event(wq, (file = safe_file(vma)));
++ DEBUG_ON(!au_is_aufs(file->f_dentry->d_sb));
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, addr %lx\n", DLNPair(dentry), addr);
++ inode = dentry->d_inode;
++ DEBUG_ON(!S_ISREG(inode->i_mode));
++
++ // do not revalidate, nor lock
++ finfo = ftofi(file);
++ hidden_file = finfo->fi_hfile[0 + finfo->fi_bstart].hf_file;
++ DEBUG_ON(!hidden_file || !au_is_mmapped(file));
++ vma->vm_file = hidden_file;
++ //smp_mb();
++ page = finfo->fi_h_vm_ops->nopage(vma, addr, type);
++ reset_file(vma, file);
++#if 0 //def CONFIG_SMP
++ //wake_up_nr(&wq, online_cpu - 1);
++ wake_up_all(&wq);
++#else
++ wake_up(&wq);
++#endif
++ if (!IS_ERR(page)) {
++ //page->mapping = file->f_mapping;
++ //get_page(page);
++ //file->f_mapping = hidden_file->f_mapping;
++ //touch_atime(NULL, dentry);
++ //inode->i_atime = hidden_file->f_dentry->d_inode->i_atime;
++ }
++ TraceErrPtr(page);
++ return page;
++}
++
++static int aufs_populate(struct vm_area_struct *vma, unsigned long addr,
++ unsigned long len, pgprot_t prot, unsigned long pgoff,
++ int nonblock)
++{
++ Err("please report me this application\n");
++ BUG();
++ return ftofi(vma->vm_file)->fi_h_vm_ops->populate
++ (vma, addr, len, prot, pgoff, nonblock);
++}
++
++static struct vm_operations_struct aufs_vm_ops = {
++ //.open = aufs_vmaopen,
++ //.close = aufs_vmaclose,
++ .nopage = aufs_nopage,
++ .populate = aufs_populate,
++ //page_mkwrite(struct vm_area_struct *vma, struct page *page)
++};
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_mmap(struct file *file, struct vm_area_struct *vma)
++{
++ int err, wlock, mmapped;
++ struct dentry *dentry;
++ struct super_block *sb;
++ struct file *h_file;
++ struct vm_operations_struct *vm_ops;
++ unsigned long flags;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, %lx, len %lu\n",
++ DLNPair(dentry), vma->vm_start, vma->vm_end - vma->vm_start);
++ DEBUG_ON(!S_ISREG(dentry->d_inode->i_mode));
++ DEBUG_ON(down_write_trylock(&vma->vm_mm->mmap_sem));
++
++ mmapped = au_is_mmapped(file);
++ wlock = 0;
++ if (file->f_mode & FMODE_WRITE) {
++ flags = VM_SHARED | VM_WRITE;
++ wlock = ((flags & vma->vm_flags) == flags);
++ }
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir,
++ wlock | !mmapped, /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ if (wlock) {
++ err = au_ready_to_write(file, -1);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ }
++
++ h_file = au_h_fptr(file);
++ vm_ops = ftofi(file)->fi_h_vm_ops;
++ if (unlikely(!mmapped)) {
++ // nfs uses some locks
++ lockdep_off();
++ err = h_file->f_op->mmap(h_file, vma);
++ lockdep_on();
++ if (unlikely(err))
++ goto out_unlock;
++ vm_ops = vma->vm_ops;
++ DEBUG_ON(!vm_ops);
++ err = do_munmap(current->mm, vma->vm_start,
++ vma->vm_end - vma->vm_start);
++ if (unlikely(err)) {
++ IOErr("failed internal unmapping %.*s, %d\n",
++ DLNPair(h_file->f_dentry), err);
++ err = -EIO;
++ goto out_unlock;
++ }
++ }
++ DEBUG_ON(!vm_ops);
++
++ err = generic_file_mmap(file, vma);
++ if (!err) {
++ file_accessed(h_file);
++ dentry->d_inode->i_atime = h_file->f_dentry->d_inode->i_atime;
++ vma->vm_ops = &aufs_vm_ops;
++ if (unlikely(!mmapped))
++ ftofi(file)->fi_h_vm_ops = vm_ops;
++ }
++
++ out_unlock:
++ if (!wlock && mmapped)
++ fi_read_unlock(file);
++ else
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++// todo: try do_sendfile() in fs/read_write.c
++static ssize_t aufs_sendfile(struct file *file, loff_t *ppos,
++ size_t count, read_actor_t actor, void *target)
++{
++ ssize_t err;
++ struct file *h_file;
++ const char c = current->comm[4];
++ /* true if a kernel thread named 'loop[0-9].*' accesses a file */
++ const int loopback = (current->mm == NULL
++ && '0' <= c && c <= '9'
++ && strncmp(current->comm, "loop", 4) == 0);
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld, cnt %lu, loopback %d\n",
++ DLNPair(dentry), *ppos, (unsigned long)count, loopback);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ if (unlikely(err))
++ goto out;
++
++ err = -EINVAL;
++ h_file = au_h_fptr(file);
++ if (h_file->f_op && h_file->f_op->sendfile) {
++ if (/* unlikely */(loopback)) {
++ file->f_mapping = h_file->f_mapping;
++ smp_mb(); //??
++ }
++ // nfs uses some locks
++ lockdep_off();
++ err = h_file->f_op->sendfile
++ (h_file, ppos, count, actor, target);
++ lockdep_on();
++ dentry->d_inode->i_atime = h_file->f_dentry->d_inode->i_atime;
++ }
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* copied from linux/fs/select.h, must match */
++#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
++
++static unsigned int aufs_poll(struct file *file, poll_table *wait)
++{
++ unsigned int mask;
++ struct file *hidden_file;
++ int err;
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, wait %p\n", DLNPair(dentry), wait);
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode));
++
++ /* We should pretend an error happend. */
++ mask = POLLERR /* | POLLIN | POLLOUT */;
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ /* it is not an error of hidden_file has no operation */
++ mask = DEFAULT_POLLMASK;
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->poll)
++ mask = hidden_file->f_op->poll(hidden_file, wait);
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr((int)mask);
++ return mask;
++}
++
++static int aufs_fsync_nondir(struct file *file, struct dentry *dentry,
++ int datasync)
++{
++ int err, my_lock;
++ struct inode *inode;
++ struct file *hidden_file;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ inode = dentry->d_inode;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++ IMustLock(inode);
++ my_lock = 0;
++#else
++ /* before 2.6.17,
++ * msync(2) calls me without locking i_sem/i_mutex, but fsync(2).
++ */
++ my_lock = !i_trylock(inode);
++#endif
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = 0; //-EBADF; // posix?
++ if (unlikely(!(file->f_mode & FMODE_WRITE)))
++ goto out;
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/1,
++ /*locked*/1);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ err = au_ready_to_write(file, -1);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++
++ err = -EINVAL;
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->fsync) {
++ // todo: apparmor thread?
++ //file->f_mapping->host->i_mutex
++ ii_write_lock_child(inode);
++ hi_lock_child(hidden_file->f_dentry->d_inode);
++ err = hidden_file->f_op->fsync
++ (hidden_file, hidden_file->f_dentry, datasync);
++ //err = -1;
++ au_cpup_attr_timesizes(inode);
++ i_unlock(hidden_file->f_dentry->d_inode);
++ ii_write_unlock(inode);
++ }
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ if (unlikely(my_lock))
++ i_unlock(inode);
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_fasync(int fd, struct file *file, int flag)
++{
++ int err;
++ struct file *hidden_file;
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), flag);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->fasync)
++ err = hidden_file->f_op->fasync(fd, hidden_file, flag);
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 // comment
++struct file_operations {
++ struct module *owner;
++ loff_t (*llseek) (struct file *, loff_t, int);
++ ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
++ ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
++ ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
++ ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
++ int (*readdir) (struct file *, void *, filldir_t);
++ unsigned int (*poll) (struct file *, struct poll_table_struct *);
++ int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
++ long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
++ long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
++ int (*mmap) (struct file *, struct vm_area_struct *);
++ int (*open) (struct inode *, struct file *);
++ int (*flush) (struct file *);
++ int (*release) (struct inode *, struct file *);
++ int (*fsync) (struct file *, struct dentry *, int datasync);
++ int (*aio_fsync) (struct kiocb *, int datasync);
++ int (*fasync) (int, struct file *, int);
++ int (*lock) (struct file *, int, struct file_lock *);
++ ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
++ ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
++ unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
++ int (*check_flags)(int);
++ int (*dir_notify)(struct file *file, unsigned long arg);
++ int (*flock) (struct file *, int, struct file_lock *);
++};
++#endif
++
++struct file_operations aufs_file_fop = {
++ .read = aufs_read,
++ .write = aufs_write,
++ .poll = aufs_poll,
++ .mmap = aufs_mmap,
++ .open = aufs_open_nondir,
++ .flush = aufs_flush,
++ .release = aufs_release_nondir,
++ .fsync = aufs_fsync_nondir,
++ .fasync = aufs_fasync,
++ .sendfile = aufs_sendfile,
++};
+diff --git a/fs/aufs/file.c b/fs/aufs/file.c
+new file mode 100755
+index 0000000..857a4e8
+--- /dev/null
++++ b/fs/aufs/file.c
+@@ -0,0 +1,832 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: file.c,v 1.42 2007/05/14 03:39:09 sfjro Exp $ */
++
++//#include <linux/fsnotify.h>
++#include <linux/pagemap.h>
++//#include <linux/poll.h>
++//#include <linux/security.h>
++#include "aufs.h"
++
++/* drop flags for writing */
++unsigned int au_file_roflags(unsigned int flags)
++{
++ flags &= ~(O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_TRUNC);
++ flags |= O_RDONLY | O_NOATIME;
++ return flags;
++}
++
++/* common functions to regular file and dir */
++struct file *hidden_open(struct dentry *dentry, aufs_bindex_t bindex, int flags)
++{
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++ struct super_block *sb;
++ struct vfsmount *hidden_mnt;
++ struct file *hidden_file;
++ struct aufs_branch *br;
++ loff_t old_size;
++ int udba;
++
++ LKTRTrace("%.*s, b%d, flags 0%o\n", DLNPair(dentry), bindex, flags);
++ DEBUG_ON(!dentry);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ sb = dentry->d_sb;
++ udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++ if (unlikely(udba)) {
++ // test here?
++ }
++
++ br = stobr(sb, bindex);
++ br_get(br);
++ /* drop flags for writing */
++ if (test_ro(sb, bindex, dentry->d_inode))
++ flags = au_file_roflags(flags);
++ flags &= ~O_CREAT;
++ spin_lock(&hidden_inode->i_lock);
++ old_size = i_size_read(hidden_inode);
++ spin_unlock(&hidden_inode->i_lock);
++
++ //DbgSleep(3);
++
++ dget(hidden_dentry);
++ hidden_mnt = mntget(br->br_mnt);
++ hidden_file = dentry_open(hidden_dentry, hidden_mnt, flags);
++ //if (LktrCond) {fput(hidden_file); hidden_file = ERR_PTR(-1);}
++
++ if (!IS_ERR(hidden_file)) {
++#if 0 // remove this
++ if (/* old_size && */ (flags & O_TRUNC)) {
++ au_direval_dec(dentry);
++ if (!IS_ROOT(dentry))
++ au_direval_dec(dentry->d_parent);
++ }
++#endif
++ return hidden_file;
++ }
++
++ br_put(br);
++ TraceErrPtr(hidden_file);
++ return hidden_file;
++}
++
++static int do_coo(struct dentry *dentry, aufs_bindex_t bstart)
++{
++ int err;
++ struct dentry *parent, *h_parent, *h_dentry;
++ aufs_bindex_t bcpup;
++ struct inode *h_dir, *h_inode, *dir;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(IS_ROOT(dentry));
++ DiMustWriteLock(dentry);
++
++ parent = dentry->d_parent; // dget_parent()
++ di_write_lock_parent(parent);
++ bcpup = err = find_rw_parent_br(dentry, bstart);
++ //bcpup = err = find_rw_br(sb, bstart);
++ if (unlikely(err < 0)) {
++ err = 0; // stop copyup, it is not an error
++ goto out;
++ }
++ err = 0;
++
++ h_parent = au_h_dptr_i(parent, bcpup);
++ if (!h_parent) {
++ err = cpup_dirs(dentry, bcpup, NULL);
++ if (unlikely(err))
++ goto out;
++ h_parent = au_h_dptr_i(parent, bcpup);
++ }
++
++ h_dir = h_parent->d_inode;
++ h_dentry = au_h_dptr_i(dentry, bstart);
++ h_inode = h_dentry->d_inode;
++ dir = parent->d_inode;
++ hdir_lock(h_dir, dir, bcpup);
++ hi_lock_child(h_inode);
++ DEBUG_ON(au_h_dptr_i(dentry, bcpup));
++ err = sio_cpup_simple(dentry, bcpup, -1,
++ au_flags_cpup(CPUP_DTIME, parent));
++ TraceErr(err);
++ i_unlock(h_inode);
++ hdir_unlock(h_dir, dir, bcpup);
++
++ out:
++ di_write_unlock(parent);
++ TraceErr(err);
++ return err;
++}
++
++int au_do_open(struct inode *inode, struct file *file,
++ int (*open)(struct file *file, int flags))
++{
++ int err, coo;
++ struct dentry *dentry;
++ struct super_block *sb;
++ aufs_bindex_t bstart;
++ struct inode *h_dir, *dir;
++
++ dentry = file->f_dentry;
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ coo = 0;
++#if 0
++ switch (au_flag_test_coo(sb)) {
++ case AuFlag_COO_LEAF:
++ coo = !S_ISDIR(inode->i_mode);
++ break;
++ case AuFlag_COO_ALL:
++ coo = 1;
++ break;
++ }
++#endif
++ err = au_init_finfo(file);
++ //if (LktrCond) {fi_write_unlock(file); fin_finfo(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ if (!coo) {
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ bstart = dbstart(dentry);
++ } else {
++ di_write_lock_child(dentry);
++ bstart = dbstart(dentry);
++ if (test_ro(sb, bstart, dentry->d_inode)) {
++ err = do_coo(dentry, bstart);
++ if (err) {
++ di_write_unlock(dentry);
++ goto out_finfo;
++ }
++ bstart = dbstart(dentry);
++ }
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ }
++
++ // todo: remove this extra locks
++ dir = dentry->d_parent->d_inode;
++ if (!IS_ROOT(dentry))
++ ii_read_lock_parent(dir);
++ h_dir = au_h_iptr_i(dir, bstart);
++ hdir_lock(h_dir, dir, bstart);
++ err = open(file, file->f_flags);
++ //if (LktrCond) err = -1;
++ hdir_unlock(h_dir, dir, bstart);
++ if (!IS_ROOT(dentry))
++ ii_read_unlock(dir);
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++
++ out_finfo:
++ fi_write_unlock(file);
++ if (unlikely(err))
++ au_fin_finfo(file);
++ //DbgFile(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++int au_reopen_nondir(struct file *file)
++{
++ int err;
++ struct dentry *dentry;
++ aufs_bindex_t bstart, bindex, bend;
++ struct file *hidden_file, *h_file_tmp;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode)
++ || !au_h_dptr(dentry)->d_inode);
++ bstart = dbstart(dentry);
++
++ h_file_tmp = NULL;
++ if (fbstart(file) == bstart) {
++ hidden_file = au_h_fptr(file);
++ if (file->f_mode == hidden_file->f_mode)
++ return 0; /* success */
++ h_file_tmp = hidden_file;
++ get_file(h_file_tmp);
++ set_h_fptr(file, bstart, NULL);
++ }
++ DEBUG_ON(fbstart(file) < bstart
++ || ftofi(file)->fi_hfile[0 + bstart].hf_file);
++
++ hidden_file = hidden_open(dentry, bstart, file->f_flags & ~O_TRUNC);
++ //if (LktrCond) {fput(hidden_file); br_put(stobr(dentry->d_sb, bstart));
++ //hidden_file = ERR_PTR(-1);}
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out; // close all?
++ err = 0;
++ //cpup_file_flags(hidden_file, file);
++ set_fbstart(file, bstart);
++ set_h_fptr(file, bstart, hidden_file);
++ memcpy(&hidden_file->f_ra, &file->f_ra, sizeof(file->f_ra)); //??
++
++ /* close lower files */
++ bend = fbend(file);
++ for (bindex = bstart + 1; bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++ set_fbend(file, bstart);
++
++ out:
++ if (h_file_tmp)
++ fput(h_file_tmp);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the deleted file for writing.
++ */
++static int cpup_wh_file(struct file *file, aufs_bindex_t bdst, loff_t len)
++{
++ int err;
++ struct dentry *dentry, *parent, *hidden_parent, *tmp_dentry;
++ struct dentry *hidden_dentry_bstart, *hidden_dentry_bdst;
++ struct inode *hidden_dir;
++ aufs_bindex_t bstart;
++ struct aufs_dinfo *dinfo;
++ struct dtime dt;
++ struct lkup_args lkup;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, bdst %d, len %Lu\n", DLNPair(dentry), bdst, len);
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode)
++ || !(file->f_mode & FMODE_WRITE));
++ DiMustWriteLock(dentry);
++ parent = dentry->d_parent;
++ IiMustAnyLock(parent->d_inode);
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ DEBUG_ON(!hidden_parent);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!hidden_dir);
++ IMustLock(hidden_dir);
++
++ sb = parent->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bdst);
++ lkup.dlgt = need_dlgt(sb);
++ tmp_dentry = lkup_whtmp(hidden_parent, &dentry->d_name, &lkup);
++ //if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(tmp_dentry);
++ if (IS_ERR(tmp_dentry))
++ goto out;
++
++ dtime_store(&dt, parent, hidden_parent);
++ dinfo = dtodi(dentry);
++ bstart = dinfo->di_bstart;
++ hidden_dentry_bdst = dinfo->di_hdentry[0 + bdst].hd_dentry;
++ hidden_dentry_bstart = dinfo->di_hdentry[0 + bstart].hd_dentry;
++ dinfo->di_bstart = bdst;
++ dinfo->di_hdentry[0 + bdst].hd_dentry = tmp_dentry;
++ dinfo->di_hdentry[0 + bstart].hd_dentry = au_h_fptr(file)->f_dentry;
++ err = cpup_single(dentry, bdst, bstart, len,
++ au_flags_cpup(!CPUP_DTIME, parent));
++ //if (LktrCond) err = -1;
++ if (!err)
++ err = au_reopen_nondir(file);
++ //err = -1;
++ dinfo->di_hdentry[0 + bstart].hd_dentry = hidden_dentry_bstart;
++ dinfo->di_hdentry[0 + bdst].hd_dentry = hidden_dentry_bdst;
++ dinfo->di_bstart = bstart;
++ if (unlikely(err))
++ goto out_tmp;
++
++ DEBUG_ON(!d_unhashed(dentry));
++ err = vfsub_unlink(hidden_dir, tmp_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1;
++ if (unlikely(err)) {
++ IOErr("failed remove copied-up tmp file %.*s(%d)\n",
++ DLNPair(tmp_dentry), err);
++ err = -EIO;
++ }
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++
++ out_tmp:
++ dput(tmp_dentry);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_wh_file_args {
++ int *errp;
++ struct file *file;
++ aufs_bindex_t bdst;
++ loff_t len;
++};
++
++static void call_cpup_wh_file(void *args)
++{
++ struct cpup_wh_file_args *a = args;
++ *a->errp = cpup_wh_file(a->file, a->bdst, a->len);
++}
++
++/*
++ * prepare the @file for writing.
++ */
++int au_ready_to_write(struct file *file, loff_t len)
++{
++ int err;
++ struct dentry *dentry, *parent, *hidden_dentry, *hidden_parent;
++ struct inode *hidden_inode, *hidden_dir, *inode, *dir;
++ struct super_block *sb;
++ aufs_bindex_t bstart, bcpup;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, len %Ld\n", DLNPair(dentry), len);
++ FiMustWriteLock(file);
++
++ sb = dentry->d_sb;
++ bstart = fbstart(file);
++ DEBUG_ON(ftobr(file, bstart) != stobr(sb, bstart));
++
++ inode = dentry->d_inode;
++ ii_read_lock_child(inode);
++ LKTRTrace("rdonly %d, bstart %d\n", test_ro(sb, bstart, inode), bstart);
++ err = test_ro(sb, bstart, inode);
++ ii_read_unlock(inode);
++ if (!err && (au_h_fptr(file)->f_mode & FMODE_WRITE))
++ return 0;
++
++ /* need to cpup */
++ parent = dentry->d_parent; // dget_parent()
++ di_write_lock_child(dentry);
++ di_write_lock_parent(parent);
++ bcpup = err = find_rw_parent_br(dentry, bstart);
++ //bcpup = err = find_rw_br(sb, bstart);
++ if (unlikely(err < 0))
++ goto out_unlock;
++ err = 0;
++
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ if (!hidden_parent) {
++ err = cpup_dirs(dentry, bcpup, NULL);
++ //if (LktrCond) err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ }
++
++ hidden_dir = hidden_parent->d_inode;
++ hidden_dentry = au_h_fptr(file)->f_dentry;
++ hidden_inode = hidden_dentry->d_inode;
++ dir = parent->d_inode;
++ hdir_lock(hidden_dir, dir, bcpup);
++ hi_lock_child(hidden_inode);
++ if (d_unhashed(dentry) || d_unhashed(hidden_dentry)
++ /* || !hidden_inode->i_nlink */) {
++ if (!au_test_perm(hidden_dir, MAY_EXEC | MAY_WRITE,
++ need_dlgt(sb)))
++ err = cpup_wh_file(file, bcpup, len);
++ else {
++ struct cpup_wh_file_args args = {
++ .errp = &err,
++ .file = file,
++ .bdst = bcpup,
++ .len = len
++ };
++ au_wkq_wait(call_cpup_wh_file, &args, /*dlgt*/0);
++ }
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ } else {
++ if (!au_h_dptr_i(dentry, bcpup))
++ err = sio_cpup_simple(dentry, bcpup, len,
++ au_flags_cpup(CPUP_DTIME,
++ parent));
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ if (!err)
++ err = au_reopen_nondir(file);
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ }
++ i_unlock(hidden_inode);
++ hdir_unlock(hidden_dir, dir, bcpup);
++
++ out_unlock:
++ di_write_unlock(parent);
++ di_write_unlock(dentry);
++// out:
++ TraceErr(err);
++ return err;
++
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * after branch manipulating, refresh the file.
++ */
++static int refresh_file(struct file *file, int (*reopen)(struct file *file))
++{
++ int err, new_sz;
++ struct dentry *dentry;
++ aufs_bindex_t bend, bindex, bstart, brid;
++ struct aufs_hfile *p;
++ struct aufs_finfo *finfo;
++ struct super_block *sb;
++ struct inode *inode;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ FiMustWriteLock(file);
++ DiMustReadLock(dentry);
++ inode = dentry->d_inode;
++ IiMustReadLock(inode);
++ //au_debug_on();
++ //DbgDentry(dentry);
++ //DbgFile(file);
++ //au_debug_off();
++
++ err = -ENOMEM;
++ sb = dentry->d_sb;
++ finfo = ftofi(file);
++ bstart = finfo->fi_bstart;
++ bend = finfo->fi_bstart;
++ new_sz = sizeof(*finfo->fi_hfile) * (sbend(sb) + 1);
++ p = au_kzrealloc(finfo->fi_hfile, sizeof(*p) * (finfo->fi_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++ finfo->fi_hfile = p;
++ hidden_file = p[0 + bstart].hf_file;
++
++ p = finfo->fi_hfile + finfo->fi_bstart;
++ brid = p->hf_br->br_id;
++ bend = finfo->fi_bend;
++ for (bindex = finfo->fi_bstart; bindex <= bend; bindex++, p++) {
++ struct aufs_hfile tmp, *q;
++ aufs_bindex_t new_bindex;
++
++ if (!p->hf_file)
++ continue;
++ new_bindex = find_bindex(sb, p->hf_br);
++ if (new_bindex == bindex)
++ continue;
++ if (new_bindex < 0) { // test here
++ set_h_fptr(file, bindex, NULL);
++ continue;
++ }
++
++ /* swap two hidden inode, and loop again */
++ q = finfo->fi_hfile + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hf_file) {
++ bindex--;
++ p--;
++ }
++ }
++ {
++ aufs_bindex_t s = finfo->fi_bstart, e = finfo->fi_bend;
++ finfo->fi_bstart = 0;
++ finfo->fi_bend = sbend(sb);
++ //au_debug_on();
++ //DbgFile(file);
++ //au_debug_off();
++ finfo->fi_bstart = s;
++ finfo->fi_bend = e;
++ }
++
++ p = finfo->fi_hfile;
++ if (!au_is_mmapped(file) && !d_unhashed(dentry)) {
++ bend = sbend(sb);
++ for (finfo->fi_bstart = 0; finfo->fi_bstart <= bend;
++ finfo->fi_bstart++, p++)
++ if (p->hf_file) {
++ if (p->hf_file->f_dentry
++ && p->hf_file->f_dentry->d_inode)
++ break;
++ else
++ au_hfput(p);
++ }
++ } else {
++ bend = find_brindex(sb, brid);
++ //LKTRTrace("%d\n", bend);
++ for (finfo->fi_bstart = 0; finfo->fi_bstart < bend;
++ finfo->fi_bstart++, p++)
++ if (p->hf_file)
++ au_hfput(p);
++ //LKTRTrace("%d\n", finfo->fi_bstart);
++ bend = sbend(sb);
++ }
++
++ p = finfo->fi_hfile + bend;
++ for (finfo->fi_bend = bend; finfo->fi_bend >= finfo->fi_bstart;
++ finfo->fi_bend--, p--)
++ if (p->hf_file) {
++ if (p->hf_file->f_dentry
++ && p->hf_file->f_dentry->d_inode)
++ break;
++ else
++ au_hfput(p);
++ }
++ //Dbg("%d, %d\n", finfo->fi_bstart, finfo->fi_bend);
++ DEBUG_ON(finfo->fi_bend < finfo->fi_bstart);
++ //DbgFile(file);
++ //DbgDentry(file->f_dentry);
++
++ err = 0;
++#if 0 // todo:
++ if (!au_h_dptr(dentry)->d_inode) {
++ au_update_figen(file);
++ goto out; /* success */
++ }
++#endif
++
++ if (unlikely(au_is_mmapped(file) || d_unhashed(dentry)))
++ goto out_update; /* success */
++
++ again:
++ bstart = ibstart(inode);
++ if (bstart < finfo->fi_bstart
++ && au_flag_test(sb, AuFlag_PLINK)
++ && au_is_plinked(sb, inode)) {
++ struct dentry *parent = dentry->d_parent; // dget_parent()
++ struct inode *dir = parent->d_inode, *h_dir;
++
++ if (test_ro(sb, bstart, inode)) {
++ di_read_lock_parent(parent, !AUFS_I_RLOCK);
++ bstart = err = find_rw_parent_br(dentry, bstart);
++ //bstart = err = find_rw_br(sb, bstart);
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ //todo: err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ di_write_lock_child(dentry);
++ if (bstart != ibstart(inode)) { // todo
++ /* someone changed our inode while we were sleeping */
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ goto again;
++ }
++
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ err = test_and_cpup_dirs(dentry, bstart, NULL);
++
++ // always superio.
++#if 1
++ h_dir = au_h_dptr_i(parent, bstart)->d_inode;
++ hdir_lock(h_dir, dir, bstart);
++ err = sio_cpup_simple(dentry, bstart, -1,
++ au_flags_cpup(CPUP_DTIME, parent));
++ hdir_unlock(h_dir, dir, bstart);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++#else
++ if (!is_au_wkq(current)) {
++ struct cpup_pseudo_link_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bstart,
++ .do_lock = 1
++ };
++ au_wkq_wait(call_cpup_pseudo_link, &args);
++ } else
++ err = cpup_pseudo_link(dentry, bstart, /*do_lock*/1);
++#endif
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ if (unlikely(err))
++ goto out;
++ }
++
++ err = reopen(file);
++ //err = -1;
++ out_update:
++ if (!err) {
++ au_update_figen(file);
++ //DbgFile(file);
++ return 0; /* success */
++ }
++
++ /* error, close all hidden files */
++ bend = fbend(file);
++ for (bindex = fbstart(file); bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* common function to regular file and dir */
++int au_reval_and_lock_finfo(struct file *file, int (*reopen)(struct file *file),
++ int wlock, int locked)
++{
++ int err, sgen, fgen, pseudo_link;
++ struct dentry *dentry;
++ struct super_block *sb;
++ aufs_bindex_t bstart;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, w %d, l %d\n", DLNPair(dentry), wlock, locked);
++ sb = dentry->d_sb;
++ SiMustAnyLock(sb);
++
++ err = 0;
++ sgen = au_sigen(sb);
++ fi_write_lock(file);
++ fgen = au_figen(file);
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ bstart = dbstart(dentry);
++ pseudo_link = (bstart != ibstart(dentry->d_inode));
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ if (sgen == fgen && !pseudo_link && fbstart(file) == bstart) {
++ if (!wlock)
++ fi_downgrade_lock(file);
++ return 0; /* success */
++ }
++
++ LKTRTrace("sgen %d, fgen %d\n", sgen, fgen);
++ if (sgen != au_digen(dentry)) {
++ /*
++ * d_path() and path_lookup() is a simple and good approach
++ * to revalidate. but si_rwsem in DEBUG_RWSEM will cause a
++ * deadlock. removed the code.
++ */
++ di_write_lock_child(dentry);
++ err = au_reval_dpath(dentry, sgen);
++ //if (LktrCond) err = -1;
++ di_write_unlock(dentry);
++ if (unlikely(err < 0))
++ goto out;
++ DEBUG_ON(au_digen(dentry) != sgen);
++ }
++
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ err = refresh_file(file, reopen);
++ //if (LktrCond) err = -1;
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ if (!err) {
++ if (!wlock)
++ fi_downgrade_lock(file);
++ } else
++ fi_write_unlock(file);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++// cf. aufs_nopage()
++// for madvise(2)
++static int aufs_readpage(struct file *file, struct page *page)
++{
++ TraceEnter();
++ unlock_page(page);
++ return 0;
++}
++
++// they will never be called.
++#ifdef CONFIG_AUFS_DEBUG
++static int aufs_prepare_write(struct file *file, struct page *page,
++ unsigned from, unsigned to)
++{BUG();return 0;}
++static int aufs_commit_write(struct file *file, struct page *page,
++ unsigned from, unsigned to)
++{BUG();return 0;}
++static int aufs_writepage(struct page *page, struct writeback_control *wbc)
++{BUG();return 0;}
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++static void aufs_sync_page(struct page *page)
++{BUG();}
++#else
++static int aufs_sync_page(struct page *page)
++{BUG(); return 0;}
++#endif
++
++#if 0 // comment
++static int aufs_writepages(struct address_space *mapping,
++ struct writeback_control *wbc)
++{BUG();return 0;}
++static int aufs_readpages(struct file *filp, struct address_space *mapping,
++ struct list_head *pages, unsigned nr_pages)
++{BUG();return 0;}
++static sector_t aufs_bmap(struct address_space *mapping, sector_t block)
++{BUG();return 0;}
++#endif
++
++static int aufs_set_page_dirty(struct page *page)
++{BUG();return 0;}
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++static void aufs_invalidatepage (struct page *page, unsigned long offset)
++{BUG();}
++#else
++static int aufs_invalidatepage (struct page *page, unsigned long offset)
++{BUG(); return 0;}
++#endif
++static int aufs_releasepage (struct page *page, gfp_t gfp)
++{BUG();return 0;}
++static ssize_t aufs_direct_IO(int rw, struct kiocb *iocb,
++ const struct iovec *iov, loff_t offset,
++ unsigned long nr_segs)
++{BUG();return 0;}
++static struct page* aufs_get_xip_page(struct address_space *mapping,
++ sector_t offset, int create)
++{BUG();return NULL;}
++//static int aufs_migratepage (struct page *newpage, struct page *page)
++//{BUG();return 0;}
++#endif
++
++#if 0 // comment
++struct address_space {
++ struct inode *host; /* owner: inode, block_device */
++ struct radix_tree_root page_tree; /* radix tree of all pages */
++ rwlock_t tree_lock; /* and rwlock protecting it */
++ unsigned int i_mmap_writable;/* count VM_SHARED mappings */
++ struct prio_tree_root i_mmap; /* tree of private and shared mappings */
++ struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
++ spinlock_t i_mmap_lock; /* protect tree, count, list */
++ unsigned int truncate_count; /* Cover race condition with truncate */
++ unsigned long nrpages; /* number of total pages */
++ pgoff_t writeback_index;/* writeback starts here */
++ struct address_space_operations *a_ops; /* methods */
++ unsigned long flags; /* error bits/gfp mask */
++ struct backing_dev_info *backing_dev_info; /* device readahead, etc */
++ spinlock_t private_lock; /* for use by the address_space */
++ struct list_head private_list; /* ditto */
++ struct address_space *assoc_mapping; /* ditto */
++} __attribute__((aligned(sizeof(long))));
++
++struct address_space_operations {
++ int (*writepage)(struct page *page, struct writeback_control *wbc);
++ int (*readpage)(struct file *, struct page *);
++ void (*sync_page)(struct page *);
++
++ /* Write back some dirty pages from this mapping. */
++ int (*writepages)(struct address_space *, struct writeback_control *);
++
++ /* Set a page dirty. Return true if this dirtied it */
++ int (*set_page_dirty)(struct page *page);
++
++ int (*readpages)(struct file *filp, struct address_space *mapping,
++ struct list_head *pages, unsigned nr_pages);
++
++ /*
++ * ext3 requires that a successful prepare_write() call be followed
++ * by a commit_write() call - they must be balanced
++ */
++ int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
++ int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
++ /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
++ sector_t (*bmap)(struct address_space *, sector_t);
++ void (*invalidatepage) (struct page *, unsigned long);
++ int (*releasepage) (struct page *, gfp_t);
++ ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
++ loff_t offset, unsigned long nr_segs);
++ struct page* (*get_xip_page)(struct address_space *, sector_t,
++ int);
++ /* migrate the contents of a page to the specified target */
++ int (*migratepage) (struct page *, struct page *);
++};
++#endif
++
++struct address_space_operations aufs_aop = {
++ .readpage = aufs_readpage,
++#ifdef CONFIG_AUFS_DEBUG
++ .writepage = aufs_writepage,
++ .sync_page = aufs_sync_page,
++ //.writepages = aufs_writepages,
++ .set_page_dirty = aufs_set_page_dirty,
++ //.readpages = aufs_readpages,
++ .prepare_write = aufs_prepare_write,
++ .commit_write = aufs_commit_write,
++ //.bmap = aufs_bmap,
++ .invalidatepage = aufs_invalidatepage,
++ .releasepage = aufs_releasepage,
++ .direct_IO = aufs_direct_IO,
++ .get_xip_page = aufs_get_xip_page,
++ //.migratepage = aufs_migratepage
++#endif
++};
+diff --git a/fs/aufs/file.h b/fs/aufs/file.h
+new file mode 100755
+index 0000000..f0fa448
+--- /dev/null
++++ b/fs/aufs/file.h
+@@ -0,0 +1,140 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: file.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_FILE_H__
++#define __AUFS_FILE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/file.h>
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++// SEEK_xxx are defined in linux/fs.h
++#else
++enum {SEEK_SET, SEEK_CUR, SEEK_END};
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_branch;
++struct aufs_hfile {
++ struct file *hf_file;
++ struct aufs_branch *hf_br;
++};
++
++struct aufs_vdir;
++struct aufs_finfo {
++ atomic_t fi_generation;
++
++ struct aufs_rwsem fi_rwsem;
++ struct aufs_hfile *fi_hfile;
++ aufs_bindex_t fi_bstart, fi_bend;
++
++ union {
++ struct vm_operations_struct *fi_h_vm_ops;
++ struct aufs_vdir *fi_vdir_cache;
++ };
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* file.c */
++extern struct address_space_operations aufs_aop;
++unsigned int au_file_roflags(unsigned int flags);
++struct file *hidden_open(struct dentry *dentry, aufs_bindex_t bindex,
++ int flags);
++int au_do_open(struct inode *inode, struct file *file,
++ int (*open)(struct file *file, int flags));
++int au_reopen_nondir(struct file *file);
++int au_ready_to_write(struct file *file, loff_t len);
++int au_reval_and_lock_finfo(struct file *file, int (*reopen)(struct file *file),
++ int wlock, int locked);
++
++/* f_op.c */
++extern struct file_operations aufs_file_fop;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++int aufs_flush(struct file *file, fl_owner_t id);
++#else
++int aufs_flush(struct file *file);
++#endif
++
++/* finfo.c */
++struct aufs_finfo *ftofi(struct file *file);
++aufs_bindex_t fbstart(struct file *file);
++aufs_bindex_t fbend(struct file *file);
++struct aufs_vdir *fvdir_cache(struct file *file);
++struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex);
++struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex);
++struct file *au_h_fptr(struct file *file);
++
++void set_fbstart(struct file *file, aufs_bindex_t bindex);
++void set_fbend(struct file *file, aufs_bindex_t bindex);
++void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache);
++void au_hfput(struct aufs_hfile *hf);
++void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *h_file);
++void au_update_figen(struct file *file);
++
++void au_fin_finfo(struct file *file);
++int au_init_finfo(struct file *file);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int au_figen(struct file *f)
++{
++ return atomic_read(&ftofi(f)->fi_generation);
++}
++
++static inline int au_is_mmapped(struct file *f)
++{
++ return !!(ftofi(f)->fi_h_vm_ops);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * fi_read_lock, fi_write_lock,
++ * fi_read_unlock, fi_write_unlock, fi_downgrade_lock
++ */
++SimpleRwsemFuncs(fi, struct file *f, ftofi(f)->fi_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define FiMustReadLock(f) do {\
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustReadLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustWriteLock(f) do { \
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustWriteLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustAnyLock(f) do { \
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustAnyLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustNoWaiters(f) RwMustNoWaiters(&ftofi(f)->fi_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_FILE_H__ */
+diff --git a/fs/aufs/finfo.c b/fs/aufs/finfo.c
+new file mode 100755
+index 0000000..1e09da8
+--- /dev/null
++++ b/fs/aufs/finfo.c
+@@ -0,0 +1,211 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: finfo.c,v 1.23 2007/04/30 05:45:21 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct aufs_finfo *ftofi(struct file *file)
++{
++ struct aufs_finfo *finfo = file->private_data;
++ DEBUG_ON(!finfo
++ || !finfo->fi_hfile
++ || (0 < finfo->fi_bend
++ && (/* stosi(file->f_dentry->d_sb)->si_bend
++ < finfo->fi_bend
++ || */ finfo->fi_bend < finfo->fi_bstart)));
++ return finfo;
++}
++
++// hard/soft set
++aufs_bindex_t fbstart(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_bstart;
++}
++
++aufs_bindex_t fbend(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_bend;
++}
++
++struct aufs_vdir *fvdir_cache(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_vdir_cache;
++}
++
++struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustAnyLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_br && br_count(hf->hf_br) <= 0);
++ return hf->hf_br;
++}
++
++struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustAnyLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_file
++ && file_count(hf->hf_file) <= 0
++ && br_count(hf->hf_br) <= 0);
++ return hf->hf_file;
++}
++
++struct file *au_h_fptr(struct file *file)
++{
++ return au_h_fptr_i(file, fbstart(file));
++}
++
++void set_fbstart(struct file *file, aufs_bindex_t bindex)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(sbend(file->f_dentry->d_sb) < bindex);
++ ftofi(file)->fi_bstart = bindex;
++}
++
++void set_fbend(struct file *file, aufs_bindex_t bindex)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(sbend(file->f_dentry->d_sb) < bindex
++ || bindex < fbstart(file));
++ ftofi(file)->fi_bend = bindex;
++}
++
++void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(!S_ISDIR(file->f_dentry->d_inode->i_mode)
++ || (ftofi(file)->fi_vdir_cache && vdir_cache));
++ ftofi(file)->fi_vdir_cache = vdir_cache;
++}
++
++void au_hfput(struct aufs_hfile *hf)
++{
++ fput(hf->hf_file);
++ hf->hf_file = NULL;
++ DEBUG_ON(!hf->hf_br);
++ br_put(hf->hf_br);
++ hf->hf_br = NULL;
++}
++
++void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *val)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustWriteLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ DEBUG_ON(val && file_count(val) <= 0);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(val && hf->hf_file);
++ if (hf->hf_file)
++ au_hfput(hf);
++ if (val) {
++ hf->hf_file = val;
++ hf->hf_br = stobr(file->f_dentry->d_sb, bindex);
++ }
++}
++
++void au_update_figen(struct file *file)
++{
++ atomic_set(&ftofi(file)->fi_generation, au_digen(file->f_dentry));
++}
++
++void au_fin_finfo(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ struct dentry *dentry;
++ aufs_bindex_t bindex, bend;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ SiMustAnyLock(dentry->d_sb);
++
++ fi_write_lock(file);
++ bend = fbend(file);
++ bindex = fbstart(file);
++ if (bindex >= 0)
++ for (; bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++
++ finfo = ftofi(file);
++#ifdef CONFIG_AUFS_DEBUG
++ if (finfo->fi_bstart >= 0) {
++ bend = fbend(file);
++ for (bindex = finfo->fi_bstart; bindex <= bend; bindex++) {
++ struct aufs_hfile *hf;
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_file || hf->hf_br);
++ }
++ }
++#endif
++
++ kfree(finfo->fi_hfile);
++ fi_write_unlock(file);
++ cache_free_finfo(finfo);
++ //file->private_data = NULL;
++}
++
++int au_init_finfo(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ struct dentry *dentry;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!dentry->d_inode);
++
++ finfo = cache_alloc_finfo();
++ if (finfo) {
++ finfo->fi_hfile = kcalloc(sbend(dentry->d_sb) + 1,
++ sizeof(*finfo->fi_hfile), GFP_KERNEL);
++ if (finfo->fi_hfile) {
++ rw_init_wlock(&finfo->fi_rwsem);
++ finfo->fi_bstart = -1;
++ finfo->fi_bend = -1;
++ atomic_set(&finfo->fi_generation, au_digen(dentry));
++
++ file->private_data = finfo;
++ return 0; /* success */
++ }
++ cache_free_finfo(finfo);
++ }
++
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
+diff --git a/fs/aufs/hinotify.c b/fs/aufs/hinotify.c
+new file mode 100755
+index 0000000..3bad3f7
+--- /dev/null
++++ b/fs/aufs/hinotify.c
+@@ -0,0 +1,536 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: hinotify.c,v 1.19 2007/05/14 03:39:21 sfjro Exp $ */
++
++#include "aufs.h"
++
++static struct inotify_handle *in_handle;
++static const __u32 in_mask = (IN_MOVE | IN_DELETE | IN_CREATE /* | IN_ACCESS */
++ | IN_MODIFY | IN_ATTRIB
++ | IN_DELETE_SELF | IN_MOVE_SELF);
++
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *hidden_inode)
++{
++ int err;
++ struct aufs_hinotify *hin;
++ s32 wd;
++
++ LKTRTrace("i%lu, hi%lu\n", inode->i_ino, hidden_inode->i_ino);
++
++ err = -ENOMEM;
++ hin = cache_alloc_hinotify();
++ if (hin) {
++ DEBUG_ON(hinode->hi_notify);
++ hinode->hi_notify = hin;
++ hin->hin_aufs_inode = inode;
++ inotify_init_watch(&hin->hin_watch);
++ wd = inotify_add_watch(in_handle, &hin->hin_watch, hidden_inode,
++ in_mask);
++ if (wd >= 0)
++ return 0; /* success */
++
++ err = wd;
++ put_inotify_watch(&hin->hin_watch);
++ cache_free_hinotify(hin);
++ hinode->hi_notify = NULL;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++void do_free_hinotify(struct aufs_hinode *hinode)
++{
++ int err;
++ struct aufs_hinotify *hin;
++
++ TraceEnter();
++
++ hin = hinode->hi_notify;
++ if (hin) {
++ err = 0;
++ if (atomic_read(&hin->hin_watch.count))
++ err = inotify_rm_watch(in_handle, &hin->hin_watch);
++
++ if (!err) {
++ cache_free_hinotify(hin);
++ hinode->hi_notify = NULL;
++ } else
++ IOErr1("failed inotify_rm_watch() %d\n", err);
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void ctl_hinotify(struct aufs_hinode *hinode, const __u32 mask)
++{
++ struct inode *hi;
++ struct inotify_watch *watch;
++
++ hi = hinode->hi_inode;
++ LKTRTrace("hi%lu, sb %p, 0x%x\n", hi->i_ino, hi->i_sb, mask);
++ if (0 && !strcmp(current->comm, "link"))
++ dump_stack();
++ IMustLock(hi);
++ if (!hinode->hi_notify)
++ return;
++
++ watch = &hinode->hi_notify->hin_watch;
++#if 0
++ {
++ u32 wd;
++ wd = inotify_find_update_watch(in_handle, hi, mask);
++ TraceErr(wd);
++ // ignore an err;
++ }
++#else
++ watch->mask = mask;
++ smp_mb();
++#endif
++ LKTRTrace("watch %p, mask %u\n", watch, watch->mask);
++}
++
++#define suspend_hinotify(hi) ctl_hinotify(hi, 0)
++#define resume_hinotify(hi) ctl_hinotify(hi, in_mask)
++
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("i%lu, b%d, lsc %d\n", dir->i_ino, bindex, lsc);
++ DEBUG_ON(!S_ISDIR(dir->i_mode));
++ hinode = itoii(dir)->ii_hinode + bindex;
++ DEBUG_ON(h_dir != hinode->hi_inode);
++
++ hi_lock(h_dir, lsc);
++ if (1 /* unlikely(au_flag_test(dir->i_sb, AuFlag_UDBA_HINOTIFY) */)
++ suspend_hinotify(hinode);
++}
++
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("i%lu, b%d\n", dir->i_ino, bindex);
++ DEBUG_ON(!S_ISDIR(dir->i_mode));
++ hinode = itoii(dir)->ii_hinode + bindex;
++ DEBUG_ON(h_dir != hinode->hi_inode);
++
++ if (1 /* unlikely(au_flag_test(dir->i_sb, AuFlag_UDBA_HINOTIFY) */)
++ resume_hinotify(hinode);
++ i_unlock(h_dir);
++}
++
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("%.*s, %.*s\n", DLNPair(h_parents[0]), DLNPair(h_parents[1]));
++
++ vfsub_lock_rename(h_parents[0], h_parents[1]);
++ hinode = itoii(dirs[0])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[0]->d_inode != hinode->hi_inode);
++ suspend_hinotify(hinode);
++ if (issamedir)
++ return;
++ hinode = itoii(dirs[1])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[1]->d_inode != hinode->hi_inode);
++ suspend_hinotify(hinode);
++}
++
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("%.*s, %.*s\n", DLNPair(h_parents[0]), DLNPair(h_parents[1]));
++
++ hinode = itoii(dirs[0])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[0]->d_inode != hinode->hi_inode);
++ resume_hinotify(hinode);
++ if (!issamedir) {
++ hinode = itoii(dirs[1])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[1]->d_inode != hinode->hi_inode);
++ resume_hinotify(hinode);
++ }
++ vfsub_unlock_rename(h_parents[0], h_parents[1]);
++}
++
++void au_reset_hinotify(struct inode *inode, unsigned int flags)
++{
++ aufs_bindex_t bindex, bend;
++ struct inode *hi;
++
++ LKTRTrace("i%lu, 0x%x\n", inode->i_ino, flags);
++
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); bindex <= bend; bindex++) {
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi) {
++ //hi_lock(hi, AUFS_LSC_H_CHILD);
++ igrab(hi);
++ set_h_iptr(inode, bindex, NULL, 0);
++ set_h_iptr(inode, bindex, igrab(hi), flags);
++ iput(hi);
++ //i_unlock(hi);
++ }
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DEBUG
++static char *in_name(u32 mask)
++{
++#define test_ret(flag) if (mask & flag) return #flag;
++ test_ret(IN_ACCESS);
++ test_ret(IN_MODIFY);
++ test_ret(IN_ATTRIB);
++ test_ret(IN_CLOSE_WRITE);
++ test_ret(IN_CLOSE_NOWRITE);
++ test_ret(IN_OPEN);
++ test_ret(IN_MOVED_FROM);
++ test_ret(IN_MOVED_TO);
++ test_ret(IN_CREATE);
++ test_ret(IN_DELETE);
++ test_ret(IN_DELETE_SELF);
++ test_ret(IN_MOVE_SELF);
++ test_ret(IN_UNMOUNT);
++ test_ret(IN_Q_OVERFLOW);
++ test_ret(IN_IGNORED);
++ return "";
++#undef test_ret
++}
++#else
++#define in_name(m) "??"
++#endif
++
++static int dec_gen_by_name(struct inode *dir, const char *_name, u32 mask)
++{
++ int err;
++ struct dentry *parent, *child;
++ struct inode *inode;
++ struct qstr *dname;
++ char *name = (void*)_name;
++ unsigned int len;
++
++ LKTRTrace("i%lu, %s, 0x%x %s\n",
++ dir->i_ino, name, mask, in_name(mask));
++
++ err = -1;
++ parent = d_find_alias(dir);
++ if (unlikely(!parent))
++ goto out;
++
++#if 0
++ if (unlikely(!memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
++ name += AUFS_WH_PFX_LEN;
++#endif
++ len = strlen(name);
++ spin_lock(&dcache_lock);
++ list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) {
++ dname = &child->d_name;
++ if (len == dname->len && !memcmp(dname->name, name, len)) {
++ au_digen_dec(child);
++#if 1
++ //todo: why both are needed
++ if (mask & IN_MOVE) {
++ spin_lock(&child->d_lock);
++ __d_drop(child);
++ spin_unlock(&child->d_lock);
++ }
++#endif
++
++ inode = child->d_inode;
++ if (inode)
++ au_iigen_dec(inode);
++ err = !!inode;
++
++ // todo: the i_nlink of newly created name by link(2)
++ // should be updated
++ // todo: some nfs dentry doesn't notified at deleteing
++ break;
++ }
++ }
++ spin_unlock(&dcache_lock);
++ dput(parent);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct postproc_args {
++ struct inode *h_dir, *dir, *h_child_inode;
++ char *h_child_name;
++ u32 mask;
++};
++
++static void dec_gen_by_ino(struct postproc_args *a)
++{
++ struct super_block *sb;
++ aufs_bindex_t bindex, bend, bfound;
++ struct xino xino;
++ struct inode *cinode;
++
++ TraceEnter();
++
++ sb = a->dir->i_sb;
++ DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++
++ bfound = -1;
++ bend = ibend(a->dir);
++ for (bindex = ibstart(a->dir); bfound == -1 && bindex <= bend; bindex++)
++ if (au_h_iptr_i(a->dir, bindex) == a->h_dir)
++ bfound = bindex;
++ if (bfound < 0)
++ return;
++
++ bindex = find_brindex(sb, itoii(a->dir)->ii_hinode[bfound + 0].hi_id);
++ if (bindex < 0)
++ return;
++ if (unlikely(xino_read(sb, bindex, a->h_child_inode->i_ino, &xino)))
++ return;
++ cinode = NULL;
++ if (xino.ino)
++ cinode = ilookup(sb, xino.ino);
++ if (cinode) {
++#if 1
++ if (1 || a->mask & IN_MOVE) {
++ struct dentry *child;
++ spin_lock(&dcache_lock);
++ list_for_each_entry(child, &cinode->i_dentry, d_alias)
++ au_digen_dec(child);
++ spin_unlock(&dcache_lock);
++ }
++#endif
++ au_iigen_dec(cinode);
++ iput(cinode);
++ }
++}
++
++static void reset_ino(struct postproc_args *a)
++{
++ aufs_bindex_t bindex, bend;
++ struct super_block *sb;
++ struct inode *h_dir;
++
++ sb = a->dir->i_sb;
++ bend = ibend(a->dir);
++ for (bindex = ibstart(a->dir); bindex <= bend; bindex++) {
++ h_dir = au_h_iptr_i(a->dir, bindex);
++ if (h_dir && h_dir != a->h_dir)
++ xino_write0(sb, bindex, h_dir->i_ino);
++ /* ignore this error */
++ }
++}
++
++static void postproc(void *args)
++{
++ struct postproc_args *a = args;
++ struct super_block *sb;
++ struct aufs_vdir *vdir;
++
++ //au_debug_on();
++ LKTRTrace("mask 0x%x %s, i%lu, hi%lu, hci%lu\n",
++ a->mask, in_name(a->mask), a->dir->i_ino, a->h_dir->i_ino,
++ a->h_child_inode ? a->h_child_inode->i_ino : 0);
++ DEBUG_ON(!a->dir);
++#if 0//def ForceInotify
++ Dbg("mask 0x%x %s, i%lu, hi%lu, hci%lu\n",
++ a->mask, in_name(a->mask), a->dir->i_ino, a->h_dir->i_ino,
++ a->h_child_inode ? a->h_child_inode->i_ino : 0);
++#endif
++
++ i_lock(a->dir);
++ sb = a->dir->i_sb;
++ si_read_lock(sb); // consider write_lock
++ ii_write_lock_parent(a->dir);
++
++ /* make dir entries obsolete */
++ vdir = ivdir(a->dir);
++ if (vdir)
++ vdir->vd_jiffy = 0;
++ a->dir->i_version++;
++
++ /*
++ * special handling root directory,
++ * sine d_revalidate may not be called later.
++ * main purpose is maintaining i_nlink.
++ */
++ if (unlikely(a->dir->i_ino == AUFS_ROOT_INO))
++ au_cpup_attr_all(a->dir);
++
++ if (a->h_child_inode && au_flag_test(sb, AuFlag_XINO))
++ dec_gen_by_ino(a);
++ else if (a->mask & (IN_MOVE_SELF | IN_DELETE_SELF))
++ reset_ino(a);
++
++ ii_write_unlock(a->dir);
++ si_read_unlock(sb);
++ i_unlock(a->dir);
++
++ au_mntput(a->dir->i_sb);
++ iput(a->h_child_inode);
++ iput(a->h_dir);
++ iput(a->dir);
++#if 0
++ if (atomic_dec_and_test(&stosi(sb)->si_hinotify))
++ wake_up_all(&stosi(sb)->si_hinotify_wq);
++#endif
++ kfree(a);
++ //au_debug_off();
++}
++
++static void aufs_inotify(struct inotify_watch *watch, u32 wd, u32 mask,
++ u32 cookie, const char *h_child_name,
++ struct inode *h_child_inode)
++{
++ struct aufs_hinotify *hinotify;
++ struct postproc_args *args;
++ int len;
++ char *p;
++ struct inode *dir;
++ //static DECLARE_WAIT_QUEUE_HEAD(wq);
++
++ //au_debug_on();
++ LKTRTrace("i%lu, wd %d, mask 0x%x %s, cookie 0x%x, hcname %s, hi%lu\n",
++ watch->inode->i_ino, wd, mask, in_name(mask), cookie,
++ h_child_name ? h_child_name : "",
++ h_child_inode ? h_child_inode->i_ino : 0);
++ //au_debug_off();
++ //IMustLock(h_dir);
++#if 0 //defined(ForceInotify) || defined(DbgInotify)
++ Dbg("i%lu, wd %d, mask 0x%x %s, cookie 0x%x, hcname %s, hi%lu\n",
++ watch->inode->i_ino, wd, mask, in_name(mask), cookie,
++ h_child_name ? h_child_name : "",
++ h_child_inode ? h_child_inode->i_ino : 0);
++#endif
++ /* if IN_UNMOUNT happens, there must be another bug */
++ if (mask & (IN_IGNORED | IN_UNMOUNT)) {
++ put_inotify_watch(watch);
++ return;
++ }
++
++ switch (mask & IN_ALL_EVENTS) {
++ case IN_MODIFY:
++ case IN_ATTRIB:
++ if (h_child_name)
++ return;
++ break;
++
++ case IN_MOVED_FROM:
++ case IN_MOVED_TO:
++ case IN_CREATE:
++ DEBUG_ON(!h_child_name || !h_child_inode);
++ break;
++ case IN_DELETE:
++ /*
++ * aufs never be able to get this child inode.
++ * revalidation should be in d_revalide()
++ * by checking i_nlink, i_generation or d_unhashed().
++ */
++ DEBUG_ON(!h_child_name);
++ break;
++
++ case IN_DELETE_SELF:
++ case IN_MOVE_SELF:
++ DEBUG_ON(h_child_name || h_child_inode);
++ break;
++
++ case IN_ACCESS:
++ default:
++ DEBUG_ON(1);
++ }
++
++#ifdef DbgInotify
++ WARN_ON(1);
++#endif
++
++ /* iput() will be called in postproc() */
++ hinotify = container_of(watch, struct aufs_hinotify, hin_watch);
++ DEBUG_ON(!hinotify || !hinotify->hin_aufs_inode);
++ dir = hinotify->hin_aufs_inode;
++
++ /* force re-lookup in next d_revalidate() */
++ if (dir->i_ino != AUFS_ROOT_INO)
++ au_iigen_dec(dir);
++ len = 0;
++ if (h_child_name && dec_gen_by_name(dir, h_child_name, mask))
++ len = strlen(h_child_name);
++
++ //wait_event(wq, (args = kmalloc(sizeof(*args), GFP_KERNEL)));
++ args = kmalloc(sizeof(*args) + len + 1, GFP_KERNEL);
++ if (unlikely(!args)) {
++ Err("no memory\n");
++ return;
++ }
++ args->mask = mask;
++ args->dir = igrab(dir);
++ args->h_dir = igrab(watch->inode);
++ args->h_child_inode = NULL;
++ if (len) {
++ if (h_child_inode)
++ args->h_child_inode = igrab(h_child_inode);
++ p = (void*)args;
++ args->h_child_name = p + sizeof(*args);
++ memcpy(args->h_child_name, h_child_name, len + 1);
++ }
++ //atomic_inc(&stosi(args->dir->i_sb)->si_hinotify);
++ /* prohibit umount */
++ au_mntget(args->dir->i_sb);
++ au_wkq_nowait(postproc, args, /*dlgt*/0);
++}
++
++#if 0
++void hinotify_flush(struct super_block *sb)
++{
++ atomic_t *p = &stosi(sb)->si_hinotify;
++ wait_event(stosi(sb)->si_hinotify_wq, !atomic_read(p));
++}
++#endif
++
++static void aufs_inotify_destroy(struct inotify_watch *watch)
++{
++ return;
++}
++
++static struct inotify_operations aufs_inotify_ops = {
++ .handle_event = aufs_inotify,
++ .destroy_watch = aufs_inotify_destroy
++};
++
++/* ---------------------------------------------------------------------- */
++
++int __init au_inotify_init(void)
++{
++ in_handle = inotify_init(&aufs_inotify_ops);
++ if (!IS_ERR(in_handle))
++ return 0;
++ TraceErrPtr(in_handle);
++ return PTR_ERR(in_handle);
++}
++
++void au_inotify_fin(void)
++{
++ inotify_destroy(in_handle);
++}
+diff --git a/fs/aufs/i_op.c b/fs/aufs/i_op.c
+new file mode 100755
+index 0000000..1cd0453
+--- /dev/null
++++ b/fs/aufs/i_op.c
+@@ -0,0 +1,641 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op.c,v 1.30 2007/04/23 00:55:05 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include <linux/security.h>
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++#ifdef CONFIG_AUFS_DLGT
++struct security_inode_permission_args {
++ int *errp;
++ struct inode *h_inode;
++ int mask;
++ struct nameidata *fake_nd;
++};
++
++static void call_security_inode_permission(void *args)
++{
++ struct security_inode_permission_args *a = args;
++ LKTRTrace("fsuid %d\n", current->fsuid);
++ *a->errp = security_inode_permission(a->h_inode, a->mask, a->fake_nd);
++}
++#endif
++
++static int hidden_permission(struct inode *hidden_inode, int mask,
++ struct nameidata *fake_nd, int brperm, int dlgt)
++{
++ int err, submask;
++ const int write_mask = (mask & (MAY_WRITE | MAY_APPEND));
++
++ LKTRTrace("ino %lu, mask 0x%x, brperm 0x%x\n",
++ hidden_inode->i_ino, mask, brperm);
++
++ err = -EACCES;
++ if (unlikely(write_mask && IS_IMMUTABLE(hidden_inode)))
++ goto out;
++
++ /* skip hidden fs test in the case of write to ro branch */
++ submask = mask & ~MAY_APPEND;
++ if (unlikely((write_mask && !br_writable(brperm))
++ || !hidden_inode->i_op
++ || !hidden_inode->i_op->permission)) {
++ //LKTRLabel(generic_permission);
++ err = generic_permission(hidden_inode, submask, NULL);
++ } else {
++ //LKTRLabel(h_inode->permission);
++ err = hidden_inode->i_op->permission(hidden_inode, submask,
++ fake_nd);
++ TraceErr(err);
++ }
++
++#if 1
++ if (!err) {
++#ifndef CONFIG_AUFS_DLGT
++ err = security_inode_permission(hidden_inode, mask, fake_nd);
++#else
++ if (!dlgt)
++ err = security_inode_permission(hidden_inode, mask,
++ fake_nd);
++ else {
++ struct security_inode_permission_args args = {
++ .errp = &err,
++ .h_inode = hidden_inode,
++ .mask = mask,
++ .fake_nd = fake_nd
++ };
++ au_wkq_wait(call_security_inode_permission, &args,
++ /*dlgt*/1);
++ }
++#endif
++ }
++#endif
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int silly_lock(struct inode *inode, struct nameidata *nd)
++{
++ int locked = 0;
++ struct super_block *sb = inode->i_sb;
++
++ LKTRTrace("i%lu, nd %p\n", inode->i_ino, nd);
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++#else
++ if (!nd || !nd->dentry) {
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++ } else if (nd->dentry->d_inode != inode) {
++ locked = 1;
++ /* lock child first, then parent */
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++ di_read_lock_parent(nd->dentry, 0);
++ } else {
++ locked = 2;
++ aufs_read_lock(nd->dentry, AUFS_I_RLOCK);
++ }
++#endif
++ return locked;
++}
++
++static void silly_unlock(int locked, struct inode *inode, struct nameidata *nd)
++{
++ struct super_block *sb = inode->i_sb;
++
++ LKTRTrace("locked %d, i%lu, nd %p\n", locked, inode->i_ino, nd);
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++#else
++ switch (locked) {
++ case 0:
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++ break;
++ case 1:
++ di_read_unlock(nd->dentry, 0);
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++ break;
++ case 2:
++ aufs_read_unlock(nd->dentry, AUFS_I_RLOCK);
++ break;
++ default:
++ BUG();
++ }
++#endif
++}
++
++static int aufs_permission(struct inode *inode, int mask, struct nameidata *nd)
++{
++ int err, locked, dlgt;
++ aufs_bindex_t bindex, bend;
++ struct inode *hidden_inode;
++ struct super_block *sb;
++ struct nameidata fake_nd, *p;
++ const int write_mask = (mask & (MAY_WRITE | MAY_APPEND));
++ const int nondir = !S_ISDIR(inode->i_mode);
++
++ LKTRTrace("ino %lu, mask 0x%x, nondir %d, write_mask %d, "
++ "nd %p{%p, %p}\n",
++ inode->i_ino, mask, nondir, write_mask,
++ nd, nd ? nd->dentry : NULL, nd ? nd->mnt : NULL);
++
++ sb = inode->i_sb;
++ locked = silly_lock(inode, nd);
++ dlgt = need_dlgt(sb);
++
++ if (nd)
++ fake_nd = *nd;
++ if (/* unlikely */(nondir || write_mask)) {
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode
++ || ((hidden_inode->i_mode & S_IFMT)
++ != (inode->i_mode & S_IFMT)));
++ err = 0;
++ bindex = ibstart(inode);
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ /* actual test will be delegated to LSM */
++ if (IS_ERR(p))
++ DEBUG_ON(PTR_ERR(p) != -ENOENT);
++ else {
++ err = hidden_permission(hidden_inode, mask, p,
++ sbr_perm(sb, bindex), dlgt);
++ fake_dm_release(p);
++ }
++ if (write_mask && !err) {
++ err = find_rw_br(sb, bindex);
++ if (err >= 0)
++ err = 0;
++ }
++ goto out;
++ }
++
++ /* non-write to dir */
++ err = 0;
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); !err && bindex <= bend; bindex++) {
++ hidden_inode = au_h_iptr_i(inode, bindex);
++ if (!hidden_inode)
++ continue;
++ DEBUG_ON(!S_ISDIR(hidden_inode->i_mode));
++
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ /* actual test will be delegated to LSM */
++ if (IS_ERR(p))
++ DEBUG_ON(PTR_ERR(p) != -ENOENT);
++ else {
++ err = hidden_permission(hidden_inode, mask, p,
++ sbr_perm(sb, bindex), dlgt);
++ fake_dm_release(p);
++ }
++ }
++
++ out:
++ silly_unlock(locked, inode, nd);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry *aufs_lookup(struct inode *dir, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ struct dentry *ret, *parent;
++ int err, npositive;
++ struct inode *inode;
++
++ LKTRTrace("dir %lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ DEBUG_ON(IS_ROOT(dentry));
++ IMustLock(dir);
++
++ parent = dentry->d_parent; // dget_parent()
++ aufs_read_lock(parent, !AUFS_I_RLOCK);
++ err = au_alloc_dinfo(dentry);
++ //if (LktrCond) err = -1;
++ ret = ERR_PTR(err);
++ if (unlikely(err))
++ goto out;
++
++ err = npositive = lkup_dentry(dentry, dbstart(parent), /*type*/0);
++ //err = -1;
++ ret = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out_unlock;
++ inode = NULL;
++ if (npositive) {
++ inode = au_new_inode(dentry);
++ ret = (void*)inode;
++ }
++ if (!IS_ERR(inode)) {
++#if 1
++ /* d_splice_alias() also supports d_add() */
++ ret = d_splice_alias(inode, dentry);
++ if (unlikely(IS_ERR(ret) && inode))
++ ii_write_unlock(inode);
++#else
++ d_add(dentry, inode);
++#endif
++ }
++
++ out_unlock:
++ di_write_unlock(dentry);
++ out:
++ aufs_read_unlock(parent, !AUFS_I_RLOCK);
++ TraceErrPtr(ret);
++ return ret;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * decide the branch and the parent dir where we will create a new entry.
++ * returns new bindex or an error.
++ * copyup the parent dir if needed.
++ */
++int wr_dir(struct dentry *dentry, int add_entry, struct dentry *src_dentry,
++ aufs_bindex_t force_btgt, int do_lock_srcdir)
++{
++ int err;
++ aufs_bindex_t bcpup, bstart, src_bstart;
++ struct dentry *hidden_parent;
++ struct super_block *sb;
++ struct dentry *parent, *src_parent = NULL;
++ struct inode *dir, *src_dir = NULL;
++
++ LKTRTrace("%.*s, add %d, src %p, force %d, lock_srcdir %d\n",
++ DLNPair(dentry), add_entry, src_dentry, force_btgt,
++ do_lock_srcdir);
++
++ sb = dentry->d_sb;
++ parent = dentry->d_parent; // dget_parent()
++ bcpup = bstart = dbstart(dentry);
++ if (force_btgt < 0) {
++ if (src_dentry) {
++ src_bstart = dbstart(src_dentry);
++ if (src_bstart < bstart)
++ bcpup = src_bstart;
++ }
++ if (test_ro(sb, bcpup, dentry->d_inode)) {
++ if (!add_entry)
++ di_read_lock_parent(parent, !AUFS_I_RLOCK);
++ bcpup = err = find_rw_parent_br(dentry, bcpup);
++ //bcpup = err = find_rw_br(sb, bcpup);
++ if (!add_entry)
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ } else {
++ DEBUG_ON(bstart <= force_btgt
++ || test_ro(sb, force_btgt, dentry->d_inode));
++ bcpup = force_btgt;
++ }
++ LKTRTrace("bstart %d, bcpup %d\n", bstart, bcpup);
++
++ err = bcpup;
++ if (bcpup == bstart)
++ goto out; /* success */
++
++ /* copyup the new parent into the branch we process */
++ hidden_parent = au_h_dptr(dentry)->d_parent; // dget_parent()
++ if (src_dentry) {
++ src_parent = src_dentry->d_parent; // dget_parent()
++ src_dir = src_parent->d_inode;
++ if (do_lock_srcdir)
++ di_write_lock_parent2(src_parent);
++ }
++
++ dir = parent->d_inode;
++ if (add_entry) {
++ au_update_dbstart(dentry);
++ IMustLock(dir);
++ DiMustWriteLock(parent);
++ IiMustWriteLock(dir);
++ } else
++ di_write_lock_parent(parent);
++
++ err = 0;
++ if (!au_h_dptr_i(parent, bcpup))
++ err = cpup_dirs(dentry, bcpup, src_parent);
++ //err = -1;
++ if (!err && add_entry) {
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ DEBUG_ON(!hidden_parent || !hidden_parent->d_inode);
++ hi_lock_parent(hidden_parent->d_inode);
++ err = lkup_neg(dentry, bcpup);
++ //err = -1;
++ i_unlock(hidden_parent->d_inode);
++ }
++
++ if (!add_entry)
++ di_write_unlock(parent);
++ if (do_lock_srcdir)
++ di_write_unlock(src_parent);
++ if (!err)
++ err = bcpup; /* success */
++ //err = -EPERM;
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_setattr(struct dentry *dentry, struct iattr *ia)
++{
++ int err, isdir;
++ aufs_bindex_t bstart, bcpup;
++ struct inode *hidden_inode, *inode, *dir, *h_dir, *gh_dir, *gdir;
++ struct dentry *hidden_dentry, *parent;
++ unsigned int udba;
++
++ LKTRTrace("%.*s, ia_valid 0x%x\n", DLNPair(dentry), ia->ia_valid);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ bstart = dbstart(dentry);
++ bcpup = err = wr_dir(dentry, /*add*/0, /*src_dentry*/NULL,
++ /*force_btgt*/-1, /*do_lock_srcdir*/0);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++
++ /* crazy udba locks */
++ udba = au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY);
++ parent = NULL;
++ gdir = gh_dir = dir = h_dir = NULL;
++ if ((udba || bstart != bcpup) && !IS_ROOT(dentry)) {
++ parent = dentry->d_parent; // dget_parent()
++ dir = parent->d_inode;
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ h_dir = au_h_iptr_i(dir, bcpup);
++ }
++ if (parent) {
++ if (unlikely(udba && !IS_ROOT(parent))) {
++ gdir = parent->d_parent->d_inode; // dget_parent()
++ ii_read_lock_parent2(gdir);
++ gh_dir = au_h_iptr_i(gdir, bcpup);
++ hgdir_lock(gh_dir, gdir, bcpup);
++ }
++ hdir_lock(h_dir, dir, bcpup);
++ }
++
++ isdir = S_ISDIR(inode->i_mode);
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++#define HiLock(bindex) do {\
++ if (!isdir) \
++ hi_lock_child(hidden_inode); \
++ else \
++ hdir2_lock(hidden_inode, inode, bindex); \
++ } while (0)
++#define HiUnlock(bindex) do {\
++ if (!isdir) \
++ i_unlock(hidden_inode); \
++ else \
++ hdir_unlock(hidden_inode, inode, bindex); \
++ } while (0)
++
++ if (bstart != bcpup) {
++ loff_t size = -1;
++
++ if ((ia->ia_valid & ATTR_SIZE)
++ && ia->ia_size < i_size_read(inode)) {
++ size = ia->ia_size;
++ ia->ia_valid &= ~ATTR_SIZE;
++ }
++ HiLock(bstart);
++ err = sio_cpup_simple(dentry, bcpup, size,
++ au_flags_cpup(CPUP_DTIME, parent));
++ //err = -1;
++ HiUnlock(bstart);
++ if (unlikely(err || !ia->ia_valid))
++ goto out_unlock;
++
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++ }
++
++ HiLock(bcpup);
++ err = vfsub_notify_change(hidden_dentry, ia, need_dlgt(dentry->d_sb));
++ //err = -1;
++ if (!err)
++ au_cpup_attr_changable(inode);
++ HiUnlock(bcpup);
++#undef HiLock
++#undef HiUnlock
++
++ out_unlock:
++ if (parent) {
++ hdir_unlock(h_dir, dir, bcpup);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++ if (unlikely(gdir)) {
++ hdir_unlock(gh_dir, gdir, bcpup);
++ ii_read_unlock(gdir);
++ }
++ out:
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int hidden_readlink(struct dentry *dentry, int bindex,
++ char __user * buf, int bufsiz)
++{
++ struct super_block *sb;
++ struct dentry *hidden_dentry;
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (unlikely(!hidden_dentry->d_inode->i_op
++ || !hidden_dentry->d_inode->i_op->readlink))
++ return -EINVAL;
++
++ sb = dentry->d_sb;
++ if (!test_ro(sb, bindex, dentry->d_inode)) {
++ touch_atime(sbr_mnt(sb, bindex), hidden_dentry);
++ dentry->d_inode->i_atime = hidden_dentry->d_inode->i_atime;
++ }
++ return hidden_dentry->d_inode->i_op->readlink
++ (hidden_dentry, buf, bufsiz);
++}
++
++static int aufs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
++{
++ int err;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), bufsiz);
++
++ aufs_read_lock(dentry, AUFS_I_RLOCK);
++ err = hidden_readlink(dentry, dbstart(dentry), buf, bufsiz);
++ //err = -1;
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ TraceErr(err);
++ return err;
++}
++
++static void *aufs_follow_link(struct dentry *dentry, struct nameidata *nd)
++{
++ int err;
++ char *buf;
++ mm_segment_t old_fs;
++
++ LKTRTrace("%.*s, nd %.*s\n", DLNPair(dentry), DLNPair(nd->dentry));
++
++ err = -ENOMEM;
++ buf = __getname();
++ //buf = NULL;
++ if (unlikely(!buf))
++ goto out;
++
++ aufs_read_lock(dentry, AUFS_I_RLOCK);
++ old_fs = get_fs();
++ set_fs(KERNEL_DS);
++ err = hidden_readlink(dentry, dbstart(dentry), (char __user *)buf,
++ PATH_MAX);
++ //err = -1;
++ set_fs(old_fs);
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++
++ if (err >= 0) {
++ buf[err] = 0;
++ /* will be freed by put_link */
++ nd_set_link(nd, buf);
++ return NULL; /* success */
++ }
++ __putname(buf);
++
++ out:
++ path_release(nd);
++ TraceErr(err);
++ return ERR_PTR(err);
++}
++
++static void aufs_put_link(struct dentry *dentry, struct nameidata *nd,
++ void *cookie)
++{
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ __putname(nd_get_link(nd));
++}
++
++/* ---------------------------------------------------------------------- */
++#if 0 // comment
++struct inode_operations {
++ int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
++ struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
++ int (*link) (struct dentry *,struct inode *,struct dentry *);
++ int (*unlink) (struct inode *,struct dentry *);
++ int (*symlink) (struct inode *,struct dentry *,const char *);
++ int (*mkdir) (struct inode *,struct dentry *,int);
++ int (*rmdir) (struct inode *,struct dentry *);
++ int (*mknod) (struct inode *,struct dentry *,int,dev_t);
++ int (*rename) (struct inode *, struct dentry *,
++ struct inode *, struct dentry *);
++ int (*readlink) (struct dentry *, char __user *,int);
++ void * (*follow_link) (struct dentry *, struct nameidata *);
++ void (*put_link) (struct dentry *, struct nameidata *, void *);
++ void (*truncate) (struct inode *);
++ int (*permission) (struct inode *, int, struct nameidata *);
++ int (*setattr) (struct dentry *, struct iattr *);
++ int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
++ int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
++ ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
++ ssize_t (*listxattr) (struct dentry *, char *, size_t);
++ int (*removexattr) (struct dentry *, const char *);
++ void (*truncate_range)(struct inode *, loff_t, loff_t);
++};
++#endif
++
++struct inode_operations aufs_symlink_iop = {
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++ .readlink = aufs_readlink,
++ .follow_link = aufs_follow_link,
++ .put_link = aufs_put_link
++};
++
++//i_op_add.c
++int aufs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
++int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
++int aufs_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd);
++int aufs_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry);
++int aufs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
++
++//i_op_del.c
++int aufs_unlink(struct inode *dir, struct dentry *dentry);
++int aufs_rmdir(struct inode *dir, struct dentry *dentry);
++
++// i_op_ren.c
++int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry);
++
++struct inode_operations aufs_dir_iop = {
++ .create = aufs_create,
++ .lookup = aufs_lookup,
++ .link = aufs_link,
++ .unlink = aufs_unlink,
++ .symlink = aufs_symlink,
++ .mkdir = aufs_mkdir,
++ .rmdir = aufs_rmdir,
++ .mknod = aufs_mknod,
++ .rename = aufs_rename,
++
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++#if 0 // xattr
++ .setxattr = aufs_setxattr,
++ .getxattr = aufs_getxattr,
++ .listxattr = aufs_listxattr,
++ .removexattr = aufs_removexattr
++#endif
++};
++
++struct inode_operations aufs_iop = {
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++#if 0 // xattr
++ .setxattr = aufs_setxattr,
++ .getxattr = aufs_getxattr,
++ .listxattr = aufs_listxattr,
++ .removexattr = aufs_removexattr
++#endif
++};
+diff --git a/fs/aufs/i_op_add.c b/fs/aufs/i_op_add.c
+new file mode 100755
+index 0000000..977d773
+--- /dev/null
++++ b/fs/aufs/i_op_add.c
+@@ -0,0 +1,621 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_add.c,v 1.37 2007/05/07 03:46:08 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++/*
++ * final procedure of adding a new entry, except link(2).
++ * remove whiteout, instantiate, copyup the parent dir's times and size
++ * and update version.
++ * if it failed, re-create the removed whiteout.
++ */
++static int epilog(struct dentry *wh_dentry, struct dentry *dentry)
++{
++ int err, rerr;
++ aufs_bindex_t bwh;
++ struct inode *inode, *dir;
++ struct dentry *wh;
++ struct lkup_args lkup;
++
++ LKTRTrace("wh %p, %.*s\n", wh_dentry, DLNPair(dentry));
++
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ bwh = -1;
++ if (wh_dentry) {
++ bwh = dbwh(dentry);
++ err = au_unlink_wh_dentry(wh_dentry->d_parent->d_inode,
++ wh_dentry, dentry, lkup.dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ }
++
++ inode = au_new_inode(dentry);
++ //inode = ERR_PTR(-1);
++ if (!IS_ERR(inode)) {
++ d_instantiate(dentry, inode);
++ dir = dentry->d_parent->d_inode;
++ /* or always cpup dir mtime? */
++ if (ibstart(dir) == dbstart(dentry))
++ au_cpup_attr_timesizes(dir);
++ dir->i_version++;
++ return 0; /* success */
++ }
++
++ err = PTR_ERR(inode);
++ if (!wh_dentry)
++ goto out;
++
++ /* revert */
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bwh);
++ wh = simple_create_wh(dentry, bwh, wh_dentry->d_parent, &lkup);
++ //wh = ERR_PTR(-1);
++ rerr = PTR_ERR(wh);
++ if (!IS_ERR(wh)) {
++ dput(wh);
++ goto out;
++ }
++ IOErr("%.*s reverting whiteout failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * initial procedure of adding a new entry.
++ * prepare writable branch and the parent dir, lock it,
++ * lookup whiteout for the new entry.
++ */
++static struct dentry *
++lock_hdir_lkup_wh(struct dentry *dentry, struct dtime *dt,
++ struct dentry *src_dentry, int do_lock_srcdir)
++{
++ struct dentry *wh_dentry, *parent, *hidden_parent;
++ int err;
++ aufs_bindex_t bstart, bcpup;
++ struct inode *dir, *h_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, src %p\n", DLNPair(dentry), src_dentry);
++
++ parent = dentry->d_parent;
++ bstart = dbstart(dentry);
++ bcpup = err = wr_dir(dentry, 1, src_dentry, -1, do_lock_srcdir);
++ //err = -1;
++ wh_dentry = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out;
++
++ dir = parent->d_inode;
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ h_dir = hidden_parent->d_inode;
++ hdir_lock(h_dir, dir, bcpup);
++ if (dt)
++ dtime_store(dt, parent, hidden_parent);
++ if (/* bcpup != bstart || */ bcpup != dbwh(dentry))
++ return NULL; /* success */
++
++ lkup.nfsmnt = au_nfsmnt(parent->d_sb, bcpup);
++ lkup.dlgt = need_dlgt(parent->d_sb);
++ wh_dentry = lkup_wh(hidden_parent, &dentry->d_name, &lkup);
++ //wh_dentry = ERR_PTR(-1);
++ if (IS_ERR(wh_dentry))
++ hdir_unlock(h_dir, dir, bcpup);
++
++ out:
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++enum {Mknod, Symlink, Creat};
++struct simple_arg {
++ int type;
++ union {
++ struct {
++ int mode;
++ struct nameidata *nd;
++ } c;
++ struct {
++ const char *symname;
++ } s;
++ struct {
++ int mode;
++ dev_t dev;
++ } m;
++ } u;
++};
++
++static int add_simple(struct inode *dir, struct dentry *dentry,
++ struct simple_arg *arg)
++{
++ int err, dlgt;
++ struct dentry *hidden_dentry, *hidden_parent, *wh_dentry, *parent;
++ struct inode *hidden_dir;
++ struct dtime dt;
++
++ LKTRTrace("type %d, %.*s\n", arg->type, DLNPair(dentry));
++ IMustLock(dir);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, /*src_dentry*/NULL,
++ /*do_lock_srcdir*/0);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ dlgt = need_dlgt(dir->i_sb);
++
++#if 1 // partial testing
++ switch (arg->type) {
++ case Creat:
++#if 0
++ if (arg->u.c.nd) {
++ struct nameidata fake_nd;
++ fake_nd = *arg->u.c.nd;
++ fake_nd.dentry = dget(hidden_parent);
++ fake_nd.mnt = sbr_mnt(dentry->d_sb, dbstart(dentry));
++ mntget(fake_nd.mnt);
++ err = vfsub_create(hidden_dir, hidden_dentry,
++ arg->u.c.mode, &fake_nd, dlgt);
++ path_release(&fake_nd);
++ } else
++#endif
++ err = vfsub_create(hidden_dir, hidden_dentry,
++ arg->u.c.mode, NULL, dlgt);
++ break;
++ case Symlink:
++ err = vfsub_symlink(hidden_dir, hidden_dentry,
++ arg->u.s.symname, S_IALLUGO, dlgt);
++ break;
++ case Mknod:
++ err = vfsub_mknod(hidden_dir, hidden_dentry,
++ arg->u.m.mode, arg->u.m.dev, dlgt);
++ break;
++ default:
++ BUG();
++ }
++#else
++ err = -1;
++#endif
++ if (!err)
++ err = epilog(wh_dentry, dentry);
++ //err = -1;
++
++ /* revert */
++ if (unlikely(err && hidden_dentry->d_inode)) {
++ int rerr;
++ rerr = vfsub_unlink(hidden_dir, hidden_dentry, dlgt);
++ //rerr = -1;
++ if (rerr) {
++ IOErr("%.*s revert failure(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++ d_drop(dentry);
++ }
++
++ hdir_unlock(hidden_dir, dir, dbstart(dentry));
++ dput(wh_dentry);
++
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
++{
++ struct simple_arg arg = {
++ .type = Mknod,
++ .u.m = {.mode = mode, .dev = dev}
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
++{
++ struct simple_arg arg = {
++ .type = Symlink,
++ .u.s.symname = symname
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++int aufs_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd)
++{
++ struct simple_arg arg = {
++ .type = Creat,
++ .u.c = {.mode = mode, .nd = nd}
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct link_arg {
++ aufs_bindex_t bdst, bsrc;
++ int issamedir, dlgt;
++ struct dentry *src_parent, *parent, *hidden_dentry;
++ struct inode *hidden_dir, *inode;
++};
++
++static int cpup_before_link(struct dentry *src_dentry, struct inode *dir,
++ struct link_arg *a)
++{
++ int err;
++ unsigned int flags;
++ struct inode *hi, *hdir = NULL, *src_dir;
++
++ TraceEnter();
++
++ err = 0;
++ flags = au_flags_cpup(CPUP_DTIME, a->parent);
++ src_dir = a->src_parent->d_inode;
++ if (!a->issamedir) {
++ // todo: dead lock?
++ di_read_lock_parent2(a->src_parent, AUFS_I_RLOCK);
++ // this temporary unlock/lock is safe
++ hdir_unlock(a->hidden_dir, dir, a->bdst);
++ err = test_and_cpup_dirs(src_dentry, a->bdst, a->parent);
++ //err = -1;
++ if (!err) {
++ hdir = au_h_iptr_i(src_dir, a->bdst);
++ hdir_lock(hdir, src_dir, a->bdst);
++ flags = au_flags_cpup(CPUP_DTIME, a->src_parent);
++ }
++ }
++
++ if (!err) {
++ hi = au_h_dptr(src_dentry)->d_inode;
++ hi_lock_child(hi);
++ err = sio_cpup_simple(src_dentry, a->bdst, -1, flags);
++ //err = -1;
++ i_unlock(hi);
++ }
++
++ if (!a->issamedir) {
++ if (hdir)
++ hdir_unlock(hdir, src_dir, a->bdst);
++ hdir_lock(a->hidden_dir, dir, a->bdst);
++ di_read_unlock(a->src_parent, AUFS_I_RLOCK);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int cpup_or_link(struct dentry *src_dentry, struct link_arg *a)
++{
++ int err;
++ struct inode *inode, *h_inode, *h_dst_inode;
++ struct dentry *h_dentry;
++ aufs_bindex_t bstart;
++ struct super_block *sb;
++
++ TraceEnter();
++
++ sb = src_dentry->d_sb;
++ inode = src_dentry->d_inode;
++ h_dentry = au_h_dptr(src_dentry);
++ h_inode = h_dentry->d_inode;
++ bstart = ibstart(inode);
++ h_dst_inode = NULL;
++ if (bstart <= a->bdst)
++ h_dst_inode = au_h_iptr_i(inode, a->bdst);
++
++ if (!h_dst_inode) {
++ /* copyup src_dentry as the name of dentry. */
++ set_dbstart(src_dentry, a->bdst);
++ set_h_dptr(src_dentry, a->bdst, dget(a->hidden_dentry));
++ hi_lock_child(h_inode);
++ err = sio_cpup_single(src_dentry, a->bdst, a->bsrc, -1,
++ au_flags_cpup(!CPUP_DTIME, a->parent));
++ //err = -1;
++ i_unlock(h_inode);
++ set_h_dptr(src_dentry, a->bdst, NULL);
++ set_dbstart(src_dentry, a->bsrc);
++ } else {
++ /* the inode of src_dentry already exists on a.bdst branch */
++ h_dentry = d_find_alias(h_dst_inode);
++ if (h_dentry) {
++ err = vfsub_link(h_dentry, a->hidden_dir,
++ a->hidden_dentry, a->dlgt);
++ dput(h_dentry);
++ } else {
++ IOErr("no dentry found for i%lu on b%d\n",
++ h_dst_inode->i_ino, a->bdst);
++ err = -EIO;
++ }
++ }
++
++ if (!err)
++ append_plink(sb, a->inode, a->hidden_dentry, a->bdst);
++
++ TraceErr(err);
++ return err;
++}
++
++int aufs_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry)
++{
++ int err, rerr;
++ struct dentry *hidden_parent, *wh_dentry, *hidden_src_dentry;
++ struct dtime dt;
++ struct link_arg a;
++ struct super_block *sb;
++
++ LKTRTrace("src %.*s, i%lu, dst %.*s\n",
++ DLNPair(src_dentry), dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ IMustLock(src_dentry->d_inode);
++
++ aufs_read_and_write_lock2(dentry, src_dentry, /*isdir*/0);
++ a.src_parent = src_dentry->d_parent;
++ a.parent = dentry->d_parent;
++ a.issamedir = (a.src_parent == a.parent);
++ di_write_lock_parent(a.parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, src_dentry, !a.issamedir);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ a.inode = src_dentry->d_inode;
++ a.hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = a.hidden_dentry->d_parent;
++ a.hidden_dir = hidden_parent->d_inode;
++ IMustLock(a.hidden_dir);
++
++ err = 0;
++ sb = dentry->d_sb;
++ a.dlgt = need_dlgt(sb);
++
++ //todo: minor optimize, their sb may be same while their bindex differs.
++ a.bsrc = dbstart(src_dentry);
++ a.bdst = dbstart(dentry);
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ if (unlikely(!au_flag_test(sb, AuFlag_PLINK))) {
++ /*
++ * copyup src_dentry to the branch we process,
++ * and then link(2) to it.
++ * gave up 'pseudo link by cpup' approach,
++ * since nlink may be one and some applications will not work.
++ */
++ if (a.bdst < a.bsrc
++ /* && hidden_src_dentry->d_sb != a.hidden_dentry->d_sb */)
++ err = cpup_before_link(src_dentry, dir, &a);
++ if (!err) {
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ err = vfsub_link(hidden_src_dentry, a.hidden_dir,
++ a.hidden_dentry, a.dlgt);
++ //err = -1;
++ }
++ } else {
++ if (a.bdst < a.bsrc
++ /* && hidden_src_dentry->d_sb != a.hidden_dentry->d_sb */)
++ err = cpup_or_link(src_dentry, &a);
++ else {
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ err = vfsub_link(hidden_src_dentry, a.hidden_dir,
++ a.hidden_dentry, a.dlgt);
++ //err = -1;
++ }
++ }
++ if (unlikely(err))
++ goto out_unlock;
++ if (wh_dentry) {
++ err = au_unlink_wh_dentry(a.hidden_dir, wh_dentry, dentry,
++ a.dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_revert;
++ }
++
++ dir->i_version++;
++ if (ibstart(dir) == dbstart(dentry))
++ au_cpup_attr_timesizes(dir);
++ if (!d_unhashed(a.hidden_dentry)
++ /* || hidden_old_inode->i_nlink <= nlink */
++ /* || SB_NFS(hidden_src_dentry->d_sb) */) {
++ dentry->d_inode = igrab(a.inode);
++ d_instantiate(dentry, a.inode);
++ a.inode->i_nlink++;
++ a.inode->i_ctime = dir->i_ctime;
++ } else
++ /* nfs case (< 2.6.15) */
++ d_drop(dentry);
++#if 0
++ au_debug_on();
++ DbgInode(a.inode);
++ au_debug_off();
++ {
++ aufs_bindex_t i;
++ for (i = ibstart(a.inode); i <= ibend(a.inode); i++) {
++ struct xino xino;
++ struct inode *hi;
++ hi = au_h_iptr_i(a.inode, i);
++ if (hi) {
++ xino_read(sb, i, hi->i_ino, &xino);
++ Dbg("hi%lu, i%lu\n", hi->i_ino, xino.ino);
++ }
++ }
++ }
++#endif
++ goto out_unlock; /* success */
++
++ out_revert:
++#if 0 // remove
++ if (d_unhashed(a.hidden_dentry)) {
++ /* hardlink on nfs (< 2.6.15) */
++ struct dentry *d;
++ const struct qstr *name = &a.hidden_dentry->d_name;
++ DEBUG_ON(a.hidden_dentry->d_parent->d_inode != a.hidden_dir);
++ // do not superio.
++ d = lkup_one(name->name, a.hidden_dentry->d_parent, name->len,
++ au_nfsmnt(sb, a.bdst)??, need_dlgt(sb));
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d))
++ goto out_rerr;
++ dput(a.hidden_dentry);
++ a.hidden_dentry = d;
++ DEBUG_ON(!d->d_inode);
++ }
++#endif
++ rerr = vfsub_unlink(a.hidden_dir, a.hidden_dentry, a.dlgt);
++ //rerr = -1;
++ if (!rerr)
++ goto out_dt;
++// out_rerr:
++ IOErr("%.*s reverting failed(%d, %d)\n", DLNPair(dentry), err, rerr);
++ err = -EIO;
++ out_dt:
++ d_drop(dentry);
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++ out_unlock:
++ hdir_unlock(a.hidden_dir, dir, a.bdst);
++ dput(wh_dentry);
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(a.parent);
++ aufs_read_and_write_unlock2(dentry, src_dentry);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
++{
++ int err, rerr, diropq, dlgt;
++ struct dentry *hidden_dentry, *hidden_parent, *wh_dentry, *parent,
++ *opq_dentry;
++ struct inode *hidden_dir, *hidden_inode;
++ struct dtime dt;
++ aufs_bindex_t bindex;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s, mode 0%o\n", dir->i_ino, DLNPair(dentry), mode);
++ IMustLock(dir);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, /*src_dentry*/NULL,
++ /*do_lock_srcdir*/0);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ sb = dentry->d_sb;
++ bindex = dbstart(dentry);
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ dlgt = need_dlgt(sb);
++
++ err = vfsub_mkdir(hidden_dir, hidden_dentry, mode, dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ hidden_inode = hidden_dentry->d_inode;
++
++ /* make the dir opaque */
++ diropq = 0;
++ if (unlikely(wh_dentry || au_flag_test(sb, AuFlag_ALWAYS_DIROPQ))) {
++ hi_lock_child(hidden_inode);
++ opq_dentry = create_diropq(dentry, bindex, dlgt);
++ //opq_dentry = ERR_PTR(-1);
++ i_unlock(hidden_inode);
++ err = PTR_ERR(opq_dentry);
++ if (IS_ERR(opq_dentry))
++ goto out_dir;
++ dput(opq_dentry);
++ diropq = 1;
++ }
++
++ err = epilog(wh_dentry, dentry);
++ //err = -1;
++ if (!err) {
++ dir->i_nlink++;
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ if (unlikely(diropq)) {
++ LKTRLabel(revert opq);
++ hi_lock_child(hidden_inode);
++ rerr = remove_diropq(dentry, bindex, dlgt);
++ //rerr = -1;
++ i_unlock(hidden_inode);
++ if (rerr) {
++ IOErr("%.*s reverting diropq failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ }
++
++ out_dir:
++ LKTRLabel(revert dir);
++ rerr = vfsub_rmdir(hidden_dir, hidden_dentry, dlgt);
++ //rerr = -1;
++ if (rerr) {
++ IOErr("%.*s reverting dir failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ d_drop(dentry);
++ dtime_revert(&dt, /*fake flag*/CPUP_LOCKED_GHDIR);
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/i_op_del.c b/fs/aufs/i_op_del.c
+new file mode 100755
+index 0000000..f29b204
+--- /dev/null
++++ b/fs/aufs/i_op_del.c
+@@ -0,0 +1,414 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_del.c,v 1.35 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++/* returns,
++ * 0: wh is unnecessary
++ * plus: wh is necessary
++ * minus: error
++ */
++int wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dentry *locked)
++{
++ int need_wh, err;
++ aufs_bindex_t bstart;
++ struct dentry *hidden_dentry;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, isdir %d, *bcpup %d, locked %p\n",
++ DLNPair(dentry), isdir, *bcpup, locked);
++ sb = dentry->d_sb;
++
++ bstart = dbstart(dentry);
++ LKTRTrace("bcpup %d, bstart %d\n", *bcpup, bstart);
++ hidden_dentry = au_h_dptr(dentry);
++ if (*bcpup < 0) {
++ *bcpup = bstart;
++ if (test_ro(sb, bstart, dentry->d_inode)) {
++ *bcpup = err = find_rw_parent_br(dentry, bstart);
++ //*bcpup = err = find_rw_br(sb, bstart);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ } else {
++ /* braces are added to stop a warning */
++ DEBUG_ON(bstart < *bcpup
++ || test_ro(sb, *bcpup, dentry->d_inode));
++ }
++ LKTRTrace("bcpup %d, bstart %d\n", *bcpup, bstart);
++
++ if (*bcpup != bstart) {
++ err = cpup_dirs(dentry, *bcpup, locked);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ need_wh = 1;
++ } else {
++ //struct nameidata nd;
++ aufs_bindex_t old_bend, new_bend, bdiropq = -1;
++ old_bend = dbend(dentry);
++ if (isdir) {
++ bdiropq = dbdiropq(dentry);
++ set_dbdiropq(dentry, -1);
++ }
++ err = need_wh = lkup_dentry(dentry, bstart + 1, /*type*/0);
++ //err = -1;
++ if (isdir)
++ set_dbdiropq(dentry, bdiropq);
++ if (unlikely(err < 0))
++ goto out;
++ new_bend = dbend(dentry);
++ if (!need_wh && old_bend != new_bend) {
++ set_h_dptr(dentry, new_bend, NULL);
++ set_dbend(dentry, old_bend);
++#if 0
++ } else if (!au_h_dptr_i(dentry, new_bend)->d_inode) {
++ LKTRTrace("negative\n");
++ set_h_dptr(dentry, new_bend, NULL);
++ set_dbend(dentry, old_bend);
++ need_wh = 0;
++#endif
++ }
++ }
++ LKTRTrace("need_wh %d\n", need_wh);
++ err = need_wh;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static struct dentry *
++lock_hdir_create_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dtime *dt)
++{
++ struct dentry *wh_dentry;
++ int err, need_wh;
++ struct dentry *hidden_parent, *parent;
++ struct inode *dir, *h_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, isdir %d\n", DLNPair(dentry), isdir);
++
++ err = need_wh = wr_dir_need_wh(dentry, isdir, bcpup, NULL);
++ //err = -1;
++ wh_dentry = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out;
++
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ hidden_parent = au_h_dptr_i(parent, *bcpup);
++ h_dir = hidden_parent->d_inode;
++ hdir_lock(h_dir, dir, *bcpup);
++ dtime_store(dt, parent, hidden_parent);
++ if (!need_wh)
++ return NULL; /* success, no need to create whiteout */
++
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, *bcpup);
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ wh_dentry = simple_create_wh(dentry, *bcpup, hidden_parent, &lkup);
++ //wh_dentry = ERR_PTR(-1);
++ if (!IS_ERR(wh_dentry))
++ goto out; /* success */
++ /* returns with the parent is locked and wh_dentry is DGETed */
++
++ hdir_unlock(h_dir, dir, *bcpup);
++
++ out:
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++static int renwh_and_rmdir(struct dentry *dentry, aufs_bindex_t bindex,
++ struct aufs_nhash *whlist, struct inode *dir)
++{
++ int rmdir_later, err;
++ struct dentry *hidden_dentry;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++
++ err = rename_whtmp(dentry, bindex);
++ //err = -1;
++#if 0
++ //todo: bug
++ if (unlikely(err)) {
++ au_direval_inc(dentry->d_parent);
++ return err;
++ }
++#endif
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!au_is_nfs(hidden_dentry->d_sb)) {
++ const int dirwh = stosi(dentry->d_sb)->si_dirwh;
++ rmdir_later = (dirwh <= 1);
++ if (!rmdir_later)
++ rmdir_later = is_longer_wh(whlist, bindex, dirwh);
++ if (rmdir_later)
++ return rmdir_later;
++ }
++
++ err = rmdir_whtmp(hidden_dentry, whlist, bindex, dir, dentry->d_inode);
++ //err = -1;
++ if (unlikely(err)) {
++ IOErr("rmdir %.*s, b%d failed, %d. ignored\n",
++ DLNPair(hidden_dentry), bindex, err);
++ err = 0;
++ }
++ TraceErr(err);
++ return err;
++}
++
++static void epilog(struct inode *dir, struct dentry *dentry,
++ aufs_bindex_t bindex)
++{
++ d_drop(dentry);
++ dentry->d_inode->i_ctime = dir->i_ctime;
++ if (atomic_read(&dentry->d_count) == 1) {
++ set_h_dptr(dentry, dbstart(dentry), NULL);
++ au_update_dbstart(dentry);
++ }
++ if (ibstart(dir) == bindex)
++ au_cpup_attr_timesizes(dir);
++ dir->i_version++;
++}
++
++static int do_revert(int err, struct dentry *wh_dentry, struct dentry *dentry,
++ aufs_bindex_t bwh, struct dtime *dt, int dlgt)
++{
++ int rerr;
++
++ rerr = au_unlink_wh_dentry(wh_dentry->d_parent->d_inode, wh_dentry,
++ dentry, dlgt);
++ //rerr = -1;
++ if (!rerr) {
++ set_dbwh(dentry, bwh);
++ dtime_revert(dt, !CPUP_LOCKED_GHDIR);
++ return 0;
++ }
++
++ IOErr("%.*s reverting whiteout failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ return -EIO;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int aufs_unlink(struct inode *dir, struct dentry *dentry)
++{
++ int err, dlgt;
++ struct inode *inode, *hidden_dir;
++ struct dentry *parent, *wh_dentry, *hidden_dentry, *hidden_parent;
++ struct dtime dt;
++ aufs_bindex_t bwh, bindex, bstart;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ inode = dentry->d_inode;
++ if (unlikely(!inode))
++ return -ENOENT; // possible?
++ IMustLock(inode);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++
++ bstart = dbstart(dentry);
++ bwh = dbwh(dentry);
++ bindex = -1;
++ wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/0, &bindex, &dt);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ sb = dir->i_sb;
++ dlgt = need_dlgt(sb);
++ hidden_dentry = au_h_dptr(dentry);
++ dget(hidden_dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++
++ if (bindex == bstart) {
++ err = vfsub_unlink(hidden_dir, hidden_dentry, dlgt);
++ //err = -1;
++ } else {
++ DEBUG_ON(!wh_dentry);
++ hidden_parent = wh_dentry->d_parent;
++ DEBUG_ON(hidden_parent != au_h_dptr_i(parent, bindex));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ err = 0;
++ }
++
++ if (!err) {
++ inode->i_nlink--;
++ epilog(dir, dentry, bindex);
++#if 0
++ xino_write0(sb, bstart, hidden_dentry->d_inode->i_ino);
++ /* ignore this error */
++#endif
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ if (wh_dentry) {
++ int rerr;
++ rerr = do_revert(err, wh_dentry, dentry, bwh, &dt, dlgt);
++ if (rerr)
++ err = rerr;
++ }
++
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ dput(hidden_dentry);
++ out:
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_rmdir(struct inode *dir, struct dentry *dentry)
++{
++ int err, rmdir_later;
++ struct inode *inode, *hidden_dir;
++ struct dentry *parent, *wh_dentry, *hidden_dentry, *hidden_parent;
++ struct dtime dt;
++ aufs_bindex_t bwh, bindex, bstart;
++ struct rmdir_whtmp_arg *arg;
++ struct aufs_nhash *whlist;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ inode = dentry->d_inode;
++ if (unlikely(!inode))
++ return -ENOENT; // possible?
++ IMustLock(inode);
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++
++ err = -ENOMEM;
++ arg = kmalloc(sizeof(*arg), GFP_KERNEL);
++ //arg = NULL;
++ if (unlikely(!arg))
++ goto out_whlist;
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ err = test_empty(dentry, whlist);
++ //err = -1;
++ if (unlikely(err))
++ goto out_arg;
++
++ bstart = dbstart(dentry);
++ bwh = dbwh(dentry);
++ bindex = -1;
++ wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/ 1, &bindex, &dt);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out_arg;
++
++ hidden_dentry = au_h_dptr(dentry);
++ dget(hidden_dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++
++ rmdir_later = 0;
++ if (bindex == bstart) {
++ IMustLock(hidden_dir);
++ err = renwh_and_rmdir(dentry, bstart, whlist, dir);
++ //err = -1;
++ if (err > 0) {
++ rmdir_later = err;
++ err = 0;
++ }
++ } else {
++ DEBUG_ON(!wh_dentry);
++ hidden_parent = wh_dentry->d_parent;
++ DEBUG_ON(hidden_parent != au_h_dptr_i(parent, bindex));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ err = 0;
++ }
++
++ sb = dentry->d_sb;
++ if (!err) {
++ //aufs_bindex_t bi, bend;
++
++ au_reset_hinotify(inode, /*flags*/0);
++ inode->i_nlink = 0;
++ set_dbdiropq(dentry, -1);
++ epilog(dir, dentry, bindex);
++
++ if (rmdir_later) {
++ kick_rmdir_whtmp(hidden_dentry, whlist, bstart, dir,
++ inode, arg);
++ arg = NULL;
++ }
++
++#if 0
++ bend = dbend(dentry);
++ for (bi = bstart; bi <= bend; bi++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(dentry, bi);
++ if (hd && hd->d_inode)
++ xino_write0(sb, bi, hd->d_inode->i_ino);
++ /* ignore this error */
++ }
++#endif
++
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ LKTRLabel(revert);
++ if (wh_dentry) {
++ int rerr;
++ rerr = do_revert(err, wh_dentry, dentry, bwh, &dt,
++ need_dlgt(sb));
++ if (rerr)
++ err = rerr;
++ }
++
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ dput(hidden_dentry);
++ out_arg:
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ kfree(arg);
++ out_whlist:
++ nhash_del(whlist);
++ out:
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/i_op_ren.c b/fs/aufs/i_op_ren.c
+new file mode 100755
+index 0000000..08137f9
+--- /dev/null
++++ b/fs/aufs/i_op_ren.c
+@@ -0,0 +1,637 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_ren.c,v 1.39 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++enum {SRC, DST};
++struct rename_args {
++ struct dentry *hidden_dentry[2], *parent[2], *hidden_parent[2];
++ struct aufs_nhash whlist;
++ aufs_bindex_t btgt, bstart[2];
++ struct super_block *sb;
++
++ unsigned int isdir:1;
++ unsigned int issamedir:1;
++ unsigned int whsrc:1;
++ unsigned int whdst:1;
++ unsigned int dlgt:1;
++} __attribute__((aligned(sizeof(long))));
++
++static int do_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry,
++ struct rename_args *a)
++{
++ int err, need_diropq, bycpup, rerr;
++ struct rmdir_whtmp_arg *tharg;
++ struct dentry *wh_dentry[2], *hidden_dst, *hg_parent;
++ struct inode *hidden_dir[2];
++ aufs_bindex_t bindex, bend;
++ unsigned int flags;
++ struct lkup_args lkup = {.dlgt = a->dlgt};
++
++ LKTRTrace("%.*s/%.*s, %.*s/%.*s, "
++ "hd{%p, %p}, hp{%p, %p}, wh %p, btgt %d, bstart{%d, %d}, "
++ "flags{%d, %d, %d, %d}\n",
++ DLNPair(a->parent[SRC]), DLNPair(src_dentry),
++ DLNPair(a->parent[DST]), DLNPair(dentry),
++ a->hidden_dentry[SRC], a->hidden_dentry[DST],
++ a->hidden_parent[SRC], a->hidden_parent[DST],
++ &a->whlist, a->btgt,
++ a->bstart[SRC], a->bstart[DST],
++ a->isdir, a->issamedir, a->whsrc, a->whdst);
++ hidden_dir[SRC] = a->hidden_parent[SRC]->d_inode;
++ hidden_dir[DST] = a->hidden_parent[DST]->d_inode;
++ IMustLock(hidden_dir[SRC]);
++ IMustLock(hidden_dir[DST]);
++
++ /* prepare workqueue arg */
++ hidden_dst = NULL;
++ tharg = NULL;
++ if (a->isdir && a->hidden_dentry[DST]->d_inode) {
++ err = -ENOMEM;
++ tharg = kmalloc(sizeof(*tharg), GFP_KERNEL);
++ //tharg = NULL;
++ if (unlikely(!tharg))
++ goto out;
++ hidden_dst = dget(a->hidden_dentry[DST]);
++ }
++
++ wh_dentry[SRC] = wh_dentry[DST] = NULL;
++ lkup.nfsmnt = au_nfsmnt(a->sb, a->btgt);
++ /* create whiteout for src_dentry */
++ if (a->whsrc) {
++ wh_dentry[SRC] = simple_create_wh(src_dentry, a->btgt,
++ a->hidden_parent[SRC], &lkup);
++ //wh_dentry[SRC] = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry[SRC]);
++ if (IS_ERR(wh_dentry[SRC]))
++ goto out_tharg;
++ }
++
++ /* lookup whiteout for dentry */
++ if (a->whdst) {
++ struct dentry *d;
++ d = lkup_wh(a->hidden_parent[DST], &dentry->d_name, &lkup);
++ //d = ERR_PTR(-1);
++ err = PTR_ERR(d);
++ if (IS_ERR(d))
++ goto out_whsrc;
++ if (!d->d_inode)
++ dput(d);
++ else
++ wh_dentry[DST] = d;
++ }
++
++ /* rename dentry to tmpwh */
++ if (tharg) {
++ err = rename_whtmp(dentry, a->btgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_whdst;
++ set_h_dptr(dentry, a->btgt, NULL);
++ err = lkup_neg(dentry, a->btgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_whtmp;
++ a->hidden_dentry[DST] = au_h_dptr_i(dentry, a->btgt);
++ }
++
++ /* cpup src */
++ if (a->hidden_dentry[DST]->d_inode && a->bstart[SRC] != a->btgt) {
++ flags = au_flags_cpup(!CPUP_DTIME, a->parent[SRC]);
++ hg_parent = a->hidden_parent[SRC]->d_parent;
++ if (!(flags & CPUP_LOCKED_GHDIR)
++ && hg_parent == a->hidden_parent[DST])
++ flags |= CPUP_LOCKED_GHDIR;
++
++ hi_lock_child(a->hidden_dentry[SRC]->d_inode);
++ err = sio_cpup_simple(src_dentry, a->btgt, -1, flags);
++ //err = -1; // untested dir
++ i_unlock(a->hidden_dentry[SRC]->d_inode);
++ if (unlikely(err))
++ goto out_whtmp;
++ }
++
++#if 0
++ /* clear the target ino in xino */
++ LKTRTrace("dir %d, dst inode %p\n", a->isdir, a->hidden_dentry[DST]->d_inode);
++ if (a->isdir && a->hidden_dentry[DST]->d_inode) {
++ Dbg("here\n");
++ err = xino_write(a->sb, a->btgt,
++ a->hidden_dentry[DST]->d_inode->i_ino, 0);
++ if (unlikely(err))
++ goto out_whtmp;
++ }
++#endif
++
++ /* rename by vfs_rename or cpup */
++ need_diropq = a->isdir
++ && (wh_dentry[DST]
++ || dbdiropq(dentry) == a->btgt
++ || au_flag_test(a->sb, AuFlag_ALWAYS_DIROPQ));
++ bycpup = 0;
++ if (dbstart(src_dentry) == a->btgt) {
++ if (need_diropq && dbdiropq(src_dentry) == a->btgt)
++ need_diropq = 0;
++ err = vfsub_rename(hidden_dir[SRC], au_h_dptr(src_dentry),
++ hidden_dir[DST], a->hidden_dentry[DST],
++ a->dlgt);
++ //err = -1;
++ } else {
++ bycpup = 1;
++ flags = au_flags_cpup(!CPUP_DTIME, a->parent[DST]);
++ hg_parent = a->hidden_parent[DST]->d_parent;
++ if (!(flags & CPUP_LOCKED_GHDIR)
++ && hg_parent == a->hidden_parent[SRC])
++ flags |= CPUP_LOCKED_GHDIR;
++
++ hi_lock_child(a->hidden_dentry[SRC]->d_inode);
++ set_dbstart(src_dentry, a->btgt);
++ set_h_dptr(src_dentry, a->btgt, dget(a->hidden_dentry[DST]));
++ //DbgDentry(src_dentry);
++ //DbgInode(src_dentry->d_inode);
++ err = sio_cpup_single(src_dentry, a->btgt, a->bstart[SRC], -1,
++ flags);
++ //err = -1; // untested dir
++ if (unlikely(err)) {
++ set_h_dptr(src_dentry, a->btgt, NULL);
++ set_dbstart(src_dentry, a->bstart[SRC]);
++ }
++ i_unlock(a->hidden_dentry[SRC]->d_inode);
++ }
++ if (unlikely(err))
++ goto out_whtmp;
++
++ /* make dir opaque */
++ if (need_diropq) {
++ struct dentry *diropq;
++ struct inode *h_inode;
++
++ h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
++ hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
++ diropq = create_diropq(src_dentry, a->btgt, a->dlgt);
++ //diropq = ERR_PTR(-1);
++ hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
++ err = PTR_ERR(diropq);
++ if (IS_ERR(diropq))
++ goto out_rename;
++ dput(diropq);
++ }
++
++ /* remove whiteout for dentry */
++ if (wh_dentry[DST]) {
++ err = au_unlink_wh_dentry(hidden_dir[DST], wh_dentry[DST],
++ dentry, a->dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_diropq;
++ }
++
++ /* remove whtmp */
++ if (tharg) {
++ if (au_is_nfs(hidden_dst->d_sb)
++ || !is_longer_wh(&a->whlist, a->btgt,
++ stosi(a->sb)->si_dirwh)) {
++ err = rmdir_whtmp(hidden_dst, &a->whlist, a->btgt, dir,
++ dentry->d_inode);
++ if (unlikely(err))
++ Warn("failed removing whtmp dir %.*s (%d), "
++ "ignored.\n", DLNPair(hidden_dst), err);
++ } else {
++ kick_rmdir_whtmp(hidden_dst, &a->whlist, a->btgt, dir,
++ dentry->d_inode, tharg);
++ dput(hidden_dst);
++ tharg = NULL;
++ }
++ }
++ err = 0;
++ goto out_success;
++
++#define RevertFailure(fmt, args...) do { \
++ IOErrWhck("revert failure: " fmt " (%d, %d)\n", \
++ ##args, err, rerr); \
++ err = -EIO; \
++ } while(0)
++
++ out_diropq:
++ if (need_diropq) {
++ struct inode *h_inode;
++
++ h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
++ // i_lock simplly since inotify is not set to h_inode.
++ hi_lock_parent(h_inode);
++ //hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
++ rerr = remove_diropq(src_dentry, a->btgt, a->dlgt);
++ //rerr = -1;
++ //hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
++ i_unlock(h_inode);
++ if (rerr)
++ RevertFailure("remove diropq %.*s",
++ DLNPair(src_dentry));
++ }
++ out_rename:
++ if (!bycpup) {
++ struct dentry *d;
++ struct qstr *name = &src_dentry->d_name;
++ d = lkup_one(name->name, a->hidden_parent[SRC], name->len,
++ &lkup);
++ //d = ERR_PTR(-1);
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d)) {
++ RevertFailure("lkup_one %.*s", DLNPair(src_dentry));
++ goto out_whtmp;
++ }
++ DEBUG_ON(d->d_inode);
++ rerr = vfsub_rename
++ (hidden_dir[DST], au_h_dptr_i(src_dentry, a->btgt),
++ hidden_dir[SRC], d, a->dlgt);
++ //rerr = -1;
++ d_drop(d);
++ dput(d);
++ //set_h_dptr(src_dentry, a->btgt, NULL);
++ if (rerr)
++ RevertFailure("rename %.*s", DLNPair(src_dentry));
++ } else {
++ rerr = vfsub_unlink(hidden_dir[DST], a->hidden_dentry[DST],
++ a->dlgt);
++ //rerr = -1;
++ set_h_dptr(src_dentry, a->btgt, NULL);
++ set_dbstart(src_dentry, a->bstart[SRC]);
++ if (rerr)
++ RevertFailure("unlink %.*s",
++ DLNPair(a->hidden_dentry[DST]));
++ }
++ out_whtmp:
++ if (tharg) {
++ struct dentry *d;
++ struct qstr *name = &dentry->d_name;
++ LKTRLabel(here);
++ d = lkup_one(name->name, a->hidden_parent[DST], name->len,
++ &lkup);
++ //d = ERR_PTR(-1);
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d)) {
++ RevertFailure("lookup %.*s", LNPair(name));
++ goto out_whdst;
++ }
++ if (d->d_inode) {
++ d_drop(d);
++ dput(d);
++ goto out_whdst;
++ }
++ DEBUG_ON(d->d_inode);
++ rerr = vfsub_rename(hidden_dir[DST], hidden_dst,
++ hidden_dir[DST], d, a->dlgt);
++ //rerr = -1;
++ d_drop(d);
++ dput(d);
++ if (rerr) {
++ RevertFailure("rename %.*s", DLNPair(hidden_dst));
++ goto out_whdst;
++ }
++ set_h_dptr(dentry, a->btgt, NULL);
++ set_h_dptr(dentry, a->btgt, dget(hidden_dst));
++ }
++ out_whdst:
++ dput(wh_dentry[DST]);
++ wh_dentry[DST] = NULL;
++ out_whsrc:
++ if (wh_dentry[SRC]) {
++ LKTRLabel(here);
++ rerr = au_unlink_wh_dentry(hidden_dir[SRC], wh_dentry[SRC],
++ src_dentry, a->dlgt);
++ //rerr = -1;
++ if (rerr)
++ RevertFailure("unlink %.*s", DLNPair(wh_dentry[SRC]));
++ }
++#undef RevertFailure
++ d_drop(src_dentry);
++ bend = dbend(src_dentry);
++ for (bindex = dbstart(src_dentry); bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(src_dentry, bindex);
++ if (hd)
++ d_drop(hd);
++ }
++ d_drop(dentry);
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(dentry, bindex);
++ if (hd)
++ d_drop(hd);
++ }
++ au_update_dbstart(dentry);
++ if (tharg)
++ d_drop(hidden_dst);
++ out_success:
++ dput(wh_dentry[SRC]);
++ dput(wh_dentry[DST]);
++ out_tharg:
++ if (tharg) {
++ dput(hidden_dst);
++ kfree(tharg);
++ }
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * test if @dentry dir can be rename destination or not.
++ * success means, it is a logically empty dir.
++ */
++static int may_rename_dstdir(struct dentry *dentry, aufs_bindex_t btgt,
++ struct aufs_nhash *whlist)
++{
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ return test_empty(dentry, whlist);
++}
++
++/*
++ * test if @dentry dir can be rename source or not.
++ * if it can, return 0 and @children is filled.
++ * success means,
++ * - or, it is a logically empty dir.
++ * - or, it exists on writable branch and has no children including whiteouts
++ * on the lower branch.
++ */
++static int may_rename_srcdir(struct dentry *dentry, aufs_bindex_t btgt)
++{
++ int err;
++ aufs_bindex_t bstart;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ bstart = dbstart(dentry);
++ if (bstart != btgt) {
++ struct aufs_nhash *whlist;
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++ err = test_empty(dentry, whlist);
++ nhash_del(whlist);
++ goto out;
++ }
++
++ if (bstart == dbtaildir(dentry))
++ return 0; /* success */
++
++ err = au_test_empty_lower(dentry);
++
++ out:
++ if (/* unlikely */(err == -ENOTEMPTY))
++ err = -EXDEV;
++ TraceErr(err);
++ return err;
++}
++
++int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry)
++{
++ int err, do_dt_dstdir;
++ aufs_bindex_t bend, bindex;
++ struct inode *inode, *dirs[2];
++ enum {PARENT, CHILD};
++ /* reduce stack space */
++ struct {
++ struct rename_args a;
++ struct dtime dt[2][2];
++ } *p;
++
++ LKTRTrace("i%lu, %.*s, i%lu, %.*s\n",
++ src_dir->i_ino, DLNPair(src_dentry),
++ dir->i_ino, DLNPair(dentry));
++ IMustLock(src_dir);
++ IMustLock(dir);
++ /* braces are added to stop a warning */
++ if (dentry->d_inode) {
++ IMustLock(dentry->d_inode);
++ }
++
++ err = -ENOMEM;
++ BUILD_BUG_ON(sizeof(*p) > PAGE_SIZE);
++ p = kmalloc(sizeof(*p), GFP_KERNEL);
++ if (unlikely(!p))
++ goto out;
++
++ err = -ENOTDIR;
++ p->a.sb = src_dentry->d_sb;
++ inode = src_dentry->d_inode;
++ p->a.isdir = !!S_ISDIR(inode->i_mode);
++ if (unlikely(p->a.isdir && dentry->d_inode
++ && !S_ISDIR(dentry->d_inode->i_mode)))
++ goto out_free;
++
++ aufs_read_and_write_lock2(dentry, src_dentry, p->a.isdir);
++ p->a.dlgt = !!need_dlgt(p->a.sb);
++ p->a.parent[SRC] = p->a.parent[DST] = dentry->d_parent;
++ p->a.issamedir = (src_dir == dir);
++ if (p->a.issamedir)
++ di_write_lock_parent(p->a.parent[DST]);
++ else {
++ p->a.parent[SRC] = src_dentry->d_parent;
++ di_write_lock2_parent(p->a.parent[SRC], p->a.parent[DST],
++ /*isdir*/1);
++ }
++
++ /* which branch we process */
++ p->a.bstart[DST] = dbstart(dentry);
++ p->a.btgt = err = wr_dir(dentry, 1, src_dentry, /*force_btgt*/-1,
++ /*do_lock_srcdir*/0);
++ if (unlikely(err < 0))
++ goto out_unlock;
++
++ /* are they available to be renamed */
++ err = 0;
++ nhash_init(&p->a.whlist);
++ if (p->a.isdir && dentry->d_inode) {
++ set_dbstart(dentry, p->a.bstart[DST]);
++ err = may_rename_dstdir(dentry, p->a.btgt, &p->a.whlist);
++ set_dbstart(dentry, p->a.btgt);
++ }
++ p->a.hidden_dentry[DST] = au_h_dptr(dentry);
++ if (unlikely(err))
++ goto out_unlock;
++ //todo: minor optimize, their sb may be same while their bindex differs.
++ p->a.bstart[SRC] = dbstart(src_dentry);
++ p->a.hidden_dentry[SRC] = au_h_dptr(src_dentry);
++ if (p->a.isdir) {
++ err = may_rename_srcdir(src_dentry, p->a.btgt);
++ if (unlikely(err))
++ goto out_children;
++ }
++
++ /* prepare the writable parent dir on the same branch */
++ err = wr_dir_need_wh(src_dentry, p->a.isdir, &p->a.btgt,
++ p->a.issamedir ? NULL : p->a.parent[DST]);
++ if (unlikely(err < 0))
++ goto out_children;
++ p->a.whsrc = !!err;
++ p->a.whdst = (p->a.bstart[DST] == p->a.btgt);
++ if (!p->a.whdst) {
++ err = cpup_dirs(dentry, p->a.btgt,
++ p->a.issamedir ? NULL : p->a.parent[SRC]);
++ if (unlikely(err))
++ goto out_children;
++ }
++
++ p->a.hidden_parent[SRC] = au_h_dptr_i(p->a.parent[SRC], p->a.btgt);
++ p->a.hidden_parent[DST] = au_h_dptr_i(p->a.parent[DST], p->a.btgt);
++ dirs[0] = src_dir;
++ dirs[1] = dir;
++ hdir_lock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++
++ /* store timestamps to be revertible */
++ dtime_store(p->dt[PARENT] + SRC, p->a.parent[SRC],
++ p->a.hidden_parent[SRC]);
++ if (!p->a.issamedir)
++ dtime_store(p->dt[PARENT] + DST, p->a.parent[DST],
++ p->a.hidden_parent[DST]);
++ do_dt_dstdir = 0;
++ if (p->a.isdir) {
++ dtime_store(p->dt[CHILD] + SRC, src_dentry,
++ p->a.hidden_dentry[SRC]);
++ if (p->a.hidden_dentry[DST]->d_inode) {
++ do_dt_dstdir = 1;
++ dtime_store(p->dt[CHILD] + DST, dentry,
++ p->a.hidden_dentry[DST]);
++ }
++ }
++
++ err = do_rename(src_dir, src_dentry, dir, dentry, &p->a);
++ if (unlikely(err))
++ goto out_dt;
++ hdir_unlock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++
++ /* update dir attributes */
++ dir->i_version++;
++ if (p->a.isdir)
++ au_cpup_attr_nlink(dir);
++ if (ibstart(dir) == p->a.btgt)
++ au_cpup_attr_timesizes(dir);
++
++ if (!p->a.issamedir) {
++ src_dir->i_version++;
++ if (p->a.isdir)
++ au_cpup_attr_nlink(src_dir);
++ if (ibstart(src_dir) == p->a.btgt)
++ au_cpup_attr_timesizes(src_dir);
++ }
++
++ // is this updating defined in POSIX?
++ if (unlikely(p->a.isdir)) {
++ //i_lock(inode);
++ au_cpup_attr_timesizes(inode);
++ //i_unlock(inode);
++ }
++
++#if 0
++ d_drop(src_dentry);
++#else
++ /* dput/iput all lower dentries */
++ set_dbwh(src_dentry, -1);
++ bend = dbend(src_dentry);
++ for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(src_dentry, bindex);
++ if (hd)
++ set_h_dptr(src_dentry, bindex, NULL);
++ }
++ set_dbend(src_dentry, p->a.btgt);
++
++ bend = ibend(inode);
++ for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
++ struct inode *hi;
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi)
++ set_h_iptr(inode, bindex, NULL, 0);
++ }
++ set_ibend(inode, p->a.btgt);
++#endif
++
++#if 0
++ //au_debug_on();
++ //DbgDentry(dentry);
++ //DbgInode(dentry->d_inode);
++ //au_debug_off();
++ inode = dentry->d_inode;
++ if (inode) {
++ aufs_bindex_t bindex, bend;
++ struct dentry *hd;
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ hd = au_h_dptr_i(dentry, bindex);
++ if (hd && hd->d_inode)
++ xino_write0(p->a.sb, bindex, hd->d_inode->i_ino);
++ /* ignore this error */
++ }
++ }
++#endif
++
++ goto out_children; /* success */
++
++ out_dt:
++ dtime_revert(p->dt[PARENT] + SRC,
++ p->a.hidden_parent[SRC]->d_parent
++ == p->a.hidden_parent[DST]);
++ if (!p->a.issamedir)
++ dtime_revert(p->dt[PARENT] + DST,
++ p->a.hidden_parent[DST]->d_parent
++ == p->a.hidden_parent[SRC]);
++ if (p->a.isdir && err != -EIO) {
++ struct dentry *hd;
++
++ hd = p->dt[CHILD][SRC].dt_h_dentry;
++ hi_lock_child(hd->d_inode);
++ dtime_revert(p->dt[CHILD] + SRC, 1);
++ i_unlock(hd->d_inode);
++ if (do_dt_dstdir) {
++ hd = p->dt[CHILD][DST].dt_h_dentry;
++ hi_lock_child(hd->d_inode);
++ dtime_revert(p->dt[CHILD] + DST, 1);
++ i_unlock(hd->d_inode);
++ }
++ }
++ hdir_unlock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++ out_children:
++ nhash_fin(&p->a.whlist);
++ out_unlock:
++ //if (unlikely(err /* && p->a.isdir */)) {
++ if (unlikely(err && p->a.isdir)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ if (p->a.issamedir)
++ di_write_unlock(p->a.parent[DST]);
++ else
++ di_write_unlock2(p->a.parent[SRC], p->a.parent[DST]);
++ aufs_read_and_write_unlock2(dentry, src_dentry);
++ out_free:
++ kfree(p);
++ out:
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/iinfo.c b/fs/aufs/iinfo.c
+new file mode 100755
+index 0000000..9efbd38
+--- /dev/null
++++ b/fs/aufs/iinfo.c
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: iinfo.c,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/mm.h>
++#include "aufs.h"
++
++struct aufs_iinfo *itoii(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++
++ iinfo = &(container_of(inode, struct aufs_icntnr, vfs_inode)->iinfo);
++ /* bad_inode case */
++ if (unlikely(!iinfo->ii_hinode))
++ return NULL;
++ DEBUG_ON(!iinfo->ii_hinode
++ /* || stosi(inode->i_sb)->si_bend < iinfo->ii_bend */
++ || iinfo->ii_bend < iinfo->ii_bstart);
++ return iinfo;
++}
++
++aufs_bindex_t ibstart(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ return itoii(inode)->ii_bstart;
++}
++
++aufs_bindex_t ibend(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ return itoii(inode)->ii_bend;
++}
++
++struct aufs_vdir *ivdir(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++ return itoii(inode)->ii_vdir;
++}
++
++struct inode *au_h_iptr_i(struct inode *inode, aufs_bindex_t bindex)
++{
++ struct inode *hidden_inode;
++
++ IiMustAnyLock(inode);
++ DEBUG_ON(bindex < 0 || ibend(inode) < bindex);
++ hidden_inode = itoii(inode)->ii_hinode[0 + bindex].hi_inode;
++ DEBUG_ON(hidden_inode && atomic_read(&hidden_inode->i_count) <= 0);
++ return hidden_inode;
++}
++
++struct inode *au_h_iptr(struct inode *inode)
++{
++ return au_h_iptr_i(inode, ibstart(inode));
++}
++
++aufs_bindex_t itoid_index(struct inode *inode, aufs_bindex_t bindex)
++{
++ IiMustAnyLock(inode);
++ DEBUG_ON(bindex < 0
++ || ibend(inode) < bindex
++ || !itoii(inode)->ii_hinode[0 + bindex].hi_inode);
++ return itoii(inode)->ii_hinode[0 + bindex].hi_id;
++}
++
++// hard/soft set
++void set_ibstart(struct inode *inode, aufs_bindex_t bindex)
++{
++ struct aufs_iinfo *iinfo = itoii(inode);
++ struct inode *h_inode;
++
++ IiMustWriteLock(inode);
++ DEBUG_ON(sbend(inode->i_sb) < bindex);
++ iinfo->ii_bstart = bindex;
++ h_inode = iinfo->ii_hinode[bindex + 0].hi_inode;
++ if (h_inode)
++ au_cpup_igen(inode, h_inode);
++}
++
++void set_ibend(struct inode *inode, aufs_bindex_t bindex)
++{
++ IiMustWriteLock(inode);
++ DEBUG_ON(sbend(inode->i_sb) < bindex
++ || bindex < ibstart(inode));
++ itoii(inode)->ii_bend = bindex;
++}
++
++void set_ivdir(struct inode *inode, struct aufs_vdir *vdir)
++{
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode)
++ || (itoii(inode)->ii_vdir && vdir));
++ itoii(inode)->ii_vdir = vdir;
++}
++
++void aufs_hiput(struct aufs_hinode *hinode)
++{
++ if (unlikely(hinode->hi_notify))
++ do_free_hinotify(hinode);
++ if (hinode->hi_inode)
++ iput(hinode->hi_inode);
++}
++
++unsigned int au_hi_flags(struct inode *inode, int isdir)
++{
++ unsigned int flags;
++ struct super_block *sb = inode->i_sb;
++
++ flags = 0;
++ if (au_flag_test(sb, AuFlag_XINO))
++ flags = AUFS_HI_XINO;
++ if (unlikely(isdir && au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ flags |= AUFS_HI_NOTIFY;
++ return flags;
++}
++
++void set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode, unsigned int flags)
++{
++ struct aufs_hinode *hinode;
++ struct inode *hi;
++ struct aufs_iinfo *iinfo = itoii(inode);
++
++ LKTRTrace("i%lu, b%d, hi%lu, flags 0x%x\n",
++ inode->i_ino, bindex, h_inode ? h_inode->i_ino : 0, flags);
++ IiMustWriteLock(inode);
++ hinode = iinfo->ii_hinode + bindex;
++ hi = hinode->hi_inode;
++ DEBUG_ON(bindex < ibstart(inode) || ibend(inode) < bindex
++ || (h_inode && atomic_read(&h_inode->i_count) <= 0)
++ || (h_inode && hi));
++
++ if (hi)
++ aufs_hiput(hinode);
++ hinode->hi_inode = h_inode;
++ if (h_inode) {
++ int err;
++ struct super_block *sb = inode->i_sb;
++
++ if (bindex == iinfo->ii_bstart)
++ au_cpup_igen(inode, h_inode);
++ hinode->hi_id = sbr_id(sb, bindex);
++ if (flags & AUFS_HI_XINO) {
++ struct xino xino = {
++ .ino = inode->i_ino,
++ //.h_gen = h_inode->i_generation
++ };
++ //WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ err = xino_write(sb, bindex, h_inode->i_ino, &xino);
++ if (unlikely(err)) {
++ IOErr1("failed xino_write() %d, force noxino\n",
++ err);
++ au_flag_clr(sb, AuFlag_XINO);
++ }
++ }
++ if (flags & AUFS_HI_NOTIFY) {
++ err = alloc_hinotify(hinode, inode, h_inode);
++ if (unlikely(err))
++ IOErr1("alloc_hinotify() %d\n", err);
++ else {
++ /* braces are added to stop a warning */
++ DEBUG_ON(!hinode->hi_notify);
++ }
++ }
++ }
++}
++
++void au_update_iigen(struct inode *inode)
++{
++ //IiMustWriteLock(inode);
++ DEBUG_ON(!inode->i_sb);
++ atomic_set(&itoii(inode)->ii_generation, au_sigen(inode->i_sb));
++}
++
++/* it may be called at remount time, too */
++void au_update_brange(struct inode *inode, int do_put_zero)
++{
++ struct aufs_iinfo *iinfo;
++
++ LKTRTrace("i%lu, %d\n", inode->i_ino, do_put_zero);
++ IiMustWriteLock(inode);
++
++ iinfo = itoii(inode);
++ if (unlikely(!iinfo) || iinfo->ii_bstart < 0)
++ return;
++
++ if (do_put_zero) {
++ aufs_bindex_t bindex;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend;
++ bindex++) {
++ struct inode *h_i;
++ h_i = iinfo->ii_hinode[0 + bindex].hi_inode;
++ if (h_i && !h_i->i_nlink)
++ set_h_iptr(inode, bindex, NULL, 0);
++ }
++ }
++
++ iinfo->ii_bstart = -1;
++ while (++iinfo->ii_bstart <= iinfo->ii_bend)
++ if (iinfo->ii_hinode[0 + iinfo->ii_bstart].hi_inode)
++ break;
++ if (iinfo->ii_bstart > iinfo->ii_bend) {
++ iinfo->ii_bend = iinfo->ii_bstart = -1;
++ return;
++ }
++
++ iinfo->ii_bend++;
++ while (0 <= --iinfo->ii_bend)
++ if (iinfo->ii_hinode[0 + iinfo->ii_bend].hi_inode)
++ break;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_iinfo_init(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++ struct super_block *sb;
++ int nbr, i;
++
++ sb = inode->i_sb;
++ DEBUG_ON(!sb);
++ iinfo = &(container_of(inode, struct aufs_icntnr, vfs_inode)->iinfo);
++ DEBUG_ON(iinfo->ii_hinode);
++ nbr = sbend(sb) + 1;
++ if (unlikely(!nbr))
++ nbr++;
++ iinfo->ii_hinode = kcalloc(nbr, sizeof(*iinfo->ii_hinode), GFP_KERNEL);
++ //iinfo->ii_hinode = NULL;
++ if (iinfo->ii_hinode) {
++ for (i = 0; i < nbr; i++)
++ iinfo->ii_hinode[i].hi_id = -1;
++ atomic_set(&iinfo->ii_generation, au_sigen(sb));
++ rw_init_nolock(&iinfo->ii_rwsem);
++ iinfo->ii_bstart = -1;
++ iinfo->ii_bend = -1;
++ iinfo->ii_vdir = NULL;
++ return 0;
++ }
++ return -ENOMEM;
++}
++
++void au_iinfo_fin(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++
++ iinfo = itoii(inode);
++ /* bad_inode case */
++ if (unlikely(!iinfo))
++ return;
++
++ if (unlikely(iinfo->ii_vdir))
++ free_vdir(iinfo->ii_vdir);
++
++ if (iinfo->ii_bstart >= 0) {
++ aufs_bindex_t bend;
++ struct aufs_hinode *hi;
++ hi = iinfo->ii_hinode + iinfo->ii_bstart;
++ bend = iinfo->ii_bend;
++ while (iinfo->ii_bstart++ <= bend) {
++ if (hi->hi_inode)
++ aufs_hiput(hi);
++ hi++;
++ }
++ //iinfo->ii_bstart = iinfo->ii_bend = -1;
++ }
++
++ kfree(iinfo->ii_hinode);
++ //iinfo->ii_hinode = NULL;
++}
+diff --git a/fs/aufs/inode.c b/fs/aufs/inode.c
+new file mode 100755
+index 0000000..f18b5d8
+--- /dev/null
++++ b/fs/aufs/inode.c
+@@ -0,0 +1,339 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: inode.c,v 1.22 2007/05/07 03:44:35 sfjro Exp $ */
++
++#include "aufs.h"
++
++int au_refresh_hinode(struct inode *inode, struct dentry *dentry)
++{
++ int err, new_sz, update, isdir;
++ struct inode *first;
++ struct aufs_hinode *p, *q, tmp;
++ struct super_block *sb;
++ struct aufs_iinfo *iinfo;
++ aufs_bindex_t bindex, bend, new_bindex;
++ unsigned int flags;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ IiMustWriteLock(inode);
++
++ err = -ENOMEM;
++ sb = dentry->d_sb;
++ bend = sbend(sb);
++ new_sz = sizeof(*iinfo->ii_hinode) * (bend + 1);
++ iinfo = itoii(inode);
++ p = au_kzrealloc(iinfo->ii_hinode, sizeof(*p) * (iinfo->ii_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++
++ iinfo->ii_hinode = p;
++ err = 0;
++ update = 0;
++ p = iinfo->ii_hinode + iinfo->ii_bstart;
++ first = p->hi_inode;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend;
++ bindex++, p++) {
++ if (unlikely(!p->hi_inode))
++ continue;
++
++ new_bindex = find_brindex(sb, p->hi_id);
++ if (new_bindex == bindex)
++ continue;
++ if (new_bindex < 0) {
++ update++;
++ aufs_hiput(p);
++ p->hi_inode = NULL;
++ continue;
++ }
++
++ if (new_bindex < iinfo->ii_bstart)
++ iinfo->ii_bstart = new_bindex;
++ if (iinfo->ii_bend < new_bindex)
++ iinfo->ii_bend = new_bindex;
++ /* swap two hidden inode, and loop again */
++ q = iinfo->ii_hinode + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hi_inode) {
++ bindex--;
++ p--;
++ }
++ }
++
++ isdir = S_ISDIR(inode->i_mode);
++ flags = au_hi_flags(inode, isdir);
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ struct inode *hi;
++ struct dentry *hd;
++
++ hd = au_h_dptr_i(dentry, bindex);
++ if (!hd || !hd->d_inode)
++ continue;
++
++ if (iinfo->ii_bstart <= bindex && bindex <= iinfo->ii_bend) {
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi) {
++ if (hi == hd->d_inode)
++ continue;
++ //Dbg("here\n");
++ err = -ESTALE;
++ break;
++ }
++ }
++ if (bindex < iinfo->ii_bstart)
++ iinfo->ii_bstart = bindex;
++ if (iinfo->ii_bend < bindex)
++ iinfo->ii_bend = bindex;
++ set_h_iptr(inode, bindex, igrab(hd->d_inode), flags);
++ update++;
++ }
++
++ bend = iinfo->ii_bend;
++ p = iinfo->ii_hinode;
++ for (bindex = 0; bindex <= bend; bindex++, p++)
++ if (p->hi_inode) {
++ iinfo->ii_bstart = bindex;
++ break;
++ }
++ p = iinfo->ii_hinode + bend;
++ for (bindex = bend; bindex > iinfo->ii_bstart; bindex--, p--)
++ if (p->hi_inode) {
++ iinfo->ii_bend = bindex;
++ break;
++ }
++ DEBUG_ON(iinfo->ii_bstart > bend || iinfo->ii_bend < 0);
++
++ if (unlikely(err))
++ goto out;
++
++ if (1 || first != au_h_iptr(inode))
++ au_cpup_attr_all(inode);
++ if (update && isdir)
++ inode->i_version++;
++ au_update_iigen(inode);
++
++ out:
++ //au_debug_on();
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++static int set_inode(struct inode *inode, struct dentry *dentry)
++{
++ int err, isdir;
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++ umode_t mode;
++ aufs_bindex_t bindex, bstart, btail;
++ struct aufs_iinfo *iinfo;
++ unsigned int flags;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++ DEBUG_ON(!(inode->i_state & I_NEW));
++ IiMustWriteLock(inode);
++ hidden_dentry = au_h_dptr(dentry);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ err = 0;
++ isdir = 0;
++ bstart = dbstart(dentry);
++ mode = hidden_inode->i_mode;
++ switch (mode & S_IFMT) {
++ case S_IFREG:
++ btail = dbtail(dentry);
++ break;
++ case S_IFDIR:
++ isdir = 1;
++ btail = dbtaildir(dentry);
++ inode->i_op = &aufs_dir_iop;
++ inode->i_fop = &aufs_dir_fop;
++ break;
++ case S_IFLNK:
++ btail = dbtail(dentry);
++ inode->i_op = &aufs_symlink_iop;
++ break;
++ case S_IFBLK:
++ case S_IFCHR:
++ case S_IFIFO:
++ case S_IFSOCK:
++ btail = dbtail(dentry);
++ init_special_inode(inode, mode, hidden_inode->i_rdev);
++ break;
++ default:
++ IOErr("Unknown file type 0%o\n", mode);
++ err = -EIO;
++ goto out;
++ }
++
++ flags = au_hi_flags(inode, isdir);
++ iinfo = itoii(inode);
++ iinfo->ii_bstart = bstart;
++ iinfo->ii_bend = btail;
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ DEBUG_ON(!hidden_dentry->d_inode);
++ set_h_iptr(inode, bindex, igrab(hidden_dentry->d_inode), flags);
++ }
++ au_cpup_attr_all(inode);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* successful returns with iinfo write_locked */
++//todo: return with unlocked?
++static int reval_inode(struct inode *inode, struct dentry *dentry, int *matched)
++{
++ int err;
++ struct inode *h_inode, *h_dinode;
++ aufs_bindex_t bindex, bend;
++ //const int udba = !au_flag_test(inode->i_sb, AuFlag_UDBA_NONE);
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++
++ *matched = 0;
++
++ /*
++ * before this function, if aufs got any iinfo lock, it must be only
++ * one, the parent dir.
++ * it can happen by UDBA and the obsoleted inode number.
++ */
++ err = -EIO;
++ if (unlikely(inode->i_ino == parent_ino(dentry)))
++ goto out;
++
++ h_dinode = au_h_dptr(dentry)->d_inode;
++ hi_lock_child(inode); // bad name, this is not a hidden inode.
++ ii_write_lock_new(inode);
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); bindex <= bend; bindex++) {
++ h_inode = au_h_iptr_i(inode, bindex);
++ if (h_inode && h_inode == h_dinode) {
++ //&& (ibs != bstart || !au_test_higen(inode, h_inode)));
++ *matched = 1;
++ err = 0;
++ if (unlikely(au_iigen(inode) != au_digen(dentry)))
++ err = au_refresh_hinode(inode, dentry);
++ break;
++ }
++ }
++ i_unlock(inode);
++ if (unlikely(err))
++ ii_write_unlock(inode);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* successful returns with iinfo write_locked */
++//todo: return with unlocked?
++struct inode *au_new_inode(struct dentry *dentry)
++{
++ struct inode *inode, *h_inode;
++ struct dentry *h_dentry;
++ ino_t h_ino;
++ struct super_block *sb;
++ int err, match;
++ aufs_bindex_t bstart;
++ struct xino xino;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ sb = dentry->d_sb;
++ h_dentry = au_h_dptr(dentry);
++ DEBUG_ON(!h_dentry);
++ h_inode = h_dentry->d_inode;
++ DEBUG_ON(!h_inode);
++
++ bstart = dbstart(dentry);
++ h_ino = h_inode->i_ino;
++ err = xino_read(sb, bstart, h_ino, &xino);
++ //err = -1;
++ inode = ERR_PTR(err);
++ if (unlikely(err))
++ goto out;
++ new_ino:
++ if (!xino.ino) {
++ xino.ino = xino_new_ino(sb);
++ if (!xino.ino) {
++ inode = ERR_PTR(-EIO);
++ goto out;
++ }
++ }
++
++ LKTRTrace("i%lu\n", xino.ino);
++ err = -ENOMEM;
++ inode = iget_locked(sb, xino.ino);
++ if (unlikely(!inode))
++ goto out;
++ err = PTR_ERR(inode);
++ if (IS_ERR(inode))
++ goto out;
++ err = -ENOMEM;
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ LKTRTrace("%lx, new %d\n", inode->i_state, !!(inode->i_state & I_NEW));
++ if (inode->i_state & I_NEW) {
++ sb->s_op->read_inode(inode);
++ if (!is_bad_inode(inode)) {
++ ii_write_lock_new(inode);
++ err = set_inode(inode, dentry);
++ //err = -1;
++ }
++ unlock_new_inode(inode);
++ if (!err)
++ goto out; /* success */
++ ii_write_unlock(inode);
++ goto out_iput;
++ } else {
++ err = reval_inode(inode, dentry, &match);
++ if (!err)
++ goto out; /* success */
++ else if (match)
++ goto out_iput;
++ }
++
++ Warn1("broken ino, b%d, %.*s/%.*s, hi%lu, i%lu. Try udba=inotify.\n",
++ bstart, DLNPair(dentry->d_parent), DLNPair(dentry), h_ino,
++ xino.ino);
++ xino.ino = 0;
++ err = xino_write0(sb, bstart, h_ino);
++ if (!err) {
++ iput(inode);
++ goto new_ino;
++ }
++
++ out_iput:
++ iput(inode);
++ inode = ERR_PTR(err);
++ out:
++ TraceErrPtr(inode);
++ return inode;
++}
+diff --git a/fs/aufs/inode.h b/fs/aufs/inode.h
+new file mode 100755
+index 0000000..b001ac3
+--- /dev/null
++++ b/fs/aufs/inode.h
+@@ -0,0 +1,377 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: inode.h,v 1.32 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_INODE_H__
++#define __AUFS_INODE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/inotify.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "vfsub.h"
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#else
++struct inotify_watch {};
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_hinotify {
++ struct inotify_watch hin_watch;
++ struct inode *hin_aufs_inode; /* no get/put */
++};
++
++struct aufs_hinode {
++ struct inode *hi_inode;
++ aufs_bindex_t hi_id;
++ struct aufs_hinotify *hi_notify;
++};
++
++struct aufs_vdir;
++struct aufs_iinfo {
++ atomic_t ii_generation;
++ struct super_block *ii_hsb1; /* no get/put */
++
++ struct aufs_rwsem ii_rwsem;
++ aufs_bindex_t ii_bstart, ii_bend;
++ struct aufs_hinode *ii_hinode;
++ struct aufs_vdir *ii_vdir;
++};
++
++struct aufs_icntnr {
++ struct aufs_iinfo iinfo;
++ struct inode vfs_inode;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* inode.c */
++int au_refresh_hinode(struct inode *inode, struct dentry *dentry);
++struct inode *au_new_inode(struct dentry *dentry);
++
++/* i_op.c */
++extern struct inode_operations aufs_iop, aufs_symlink_iop, aufs_dir_iop;
++int wr_dir(struct dentry *dentry, int negative, struct dentry *src_dentry,
++ aufs_bindex_t force_btgt, int do_lock_srcdir);
++
++/* i_op_del.c */
++int wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dentry *locked);
++
++/* iinfo.c */
++struct aufs_iinfo *itoii(struct inode *inode);
++aufs_bindex_t ibstart(struct inode *inode);
++aufs_bindex_t ibend(struct inode *inode);
++struct aufs_vdir *ivdir(struct inode *inode);
++struct inode *au_h_iptr_i(struct inode *inode, aufs_bindex_t bindex);
++struct inode *au_h_iptr(struct inode *inode);
++aufs_bindex_t itoid_index(struct inode *inode, aufs_bindex_t bindex);
++
++void set_ibstart(struct inode *inode, aufs_bindex_t bindex);
++void set_ibend(struct inode *inode, aufs_bindex_t bindex);
++void set_ivdir(struct inode *inode, struct aufs_vdir *vdir);
++void aufs_hiput(struct aufs_hinode *hinode);
++#define AUFS_HI_XINO 1
++#define AUFS_HI_NOTIFY 2
++unsigned int au_hi_flags(struct inode *inode, int isdir);
++void set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode, unsigned int flags);
++void au_update_iigen(struct inode *inode);
++void au_update_brange(struct inode *inode, int do_put_zero);
++
++int au_iinfo_init(struct inode *inode);
++void au_iinfo_fin(struct inode *inode);
++
++/* plink.c */
++#ifdef CONFIG_AUFS_DEBUG
++void au_list_plink(struct super_block *sb);
++#else
++static inline void au_list_plink(struct super_block *sb)
++{
++ /* nothing */
++}
++#endif
++int au_is_plinked(struct super_block *sb, struct inode *inode);
++struct dentry *lkup_plink(struct super_block *sb, aufs_bindex_t bindex,
++ struct inode *inode);
++void append_plink(struct super_block *sb, struct inode *inode,
++ struct dentry *h_dentry, aufs_bindex_t bindex);
++void au_put_plink(struct super_block *sb);
++void half_refresh_plink(struct super_block *sb, aufs_bindex_t br_id);
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for hidden inode */
++/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
++// todo: reduce it by dcsub.
++enum {
++ AuLsc_Begin = I_MUTEX_QUOTA,
++ AuLsc_HI_GPARENT, /* setattr with inotify */
++ AuLsc_HI_PARENT, /* hidden inode, parent first */
++ AuLsc_HI_CHILD,
++ AuLsc_HI_PARENT2, /* copyup dirs */
++ AuLsc_HI_CHILD2,
++ AuLsc_End
++};
++
++/* simple abstraction */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
++static inline void i_lock(struct inode *i)
++{
++ down(&i->i_sem);
++}
++
++static inline void i_unlock(struct inode *i)
++{
++ up(&i->i_sem);
++}
++
++static inline int i_trylock(struct inode *i)
++{
++ return down_trylock(&i->i_sem);
++}
++
++static inline void hi_lock(struct inode *i, unsigned int lsc)
++{
++ i_lock(i);
++}
++
++#define IMustLock(i) DEBUG_ON(!down_trylock(&(i)->i_sem))
++#else
++static inline void i_lock(struct inode *i)
++{
++ mutex_lock(&i->i_mutex);
++}
++
++static inline void i_unlock(struct inode *i)
++{
++ mutex_unlock(&i->i_mutex);
++}
++
++static inline int i_trylock(struct inode *i)
++{
++ return mutex_trylock(&i->i_mutex);
++}
++
++static inline void hi_lock(struct inode *i, unsigned int lsc)
++{
++ mutex_lock_nested(&i->i_mutex, lsc);
++}
++
++#define IMustLock(i) MtxMustLock(&(i)->i_mutex)
++#endif
++
++/*
++ * hi_lock_gparent, hi_lock_parent, hi_lock_parent2, hi_lock_child,
++ * hi_lock_child2, hi_lock_whplink
++ */
++#define LockFunc(name, lsc) \
++static inline void hi_lock_##name(struct inode *h_i) \
++{hi_lock(h_i, AuLsc_HI_##lsc);}
++
++LockFunc(gparent, GPARENT);
++LockFunc(parent, PARENT);
++LockFunc(parent2, PARENT2);
++LockFunc(child, CHILD);
++LockFunc(child2, CHILD2);
++LockFunc(whplink, CHILD2); /* sharing lock-subclass */
++
++#undef LockFunc
++
++/* ---------------------------------------------------------------------- */
++
++/* tiny test for inode number */
++/* tmpfs generation is too rough */
++static inline int au_test_higen(struct inode *inode, struct inode *h_inode)
++{
++ //IiMustAnyLock(inode);
++ return !(itoii(inode)->ii_hsb1 == h_inode->i_sb
++ && inode->i_generation == h_inode->i_generation);
++}
++
++static inline int au_iigen(struct inode *inode)
++{
++ return atomic_read(&itoii(inode)->ii_generation);
++}
++
++#ifdef CONFIG_AUFS_HINOTIFY
++static inline void au_iigen_dec(struct inode *inode)
++{
++ //Dbg("i%lu\n", inode->i_ino);
++ atomic_dec(&itoii(inode)->ii_generation);
++}
++
++/* hinotify.c */
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *h_inode);
++void do_free_hinotify(struct aufs_hinode *hinode);
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc);
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex);
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir);
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir);
++void au_reset_hinotify(struct inode *inode, unsigned int flags);
++int __init au_inotify_init(void);
++void au_inotify_fin(void);
++#else
++static inline
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *h_inode)
++{
++ return -EOPNOTSUPP;
++}
++
++static inline void do_free_hinotify(struct aufs_hinode *hinode)
++{
++ /* nothing */
++}
++
++static inline
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc)
++{
++ hi_lock(h_dir, lsc);
++}
++
++static inline
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
++{
++ i_unlock(h_dir);
++}
++
++static inline
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ vfsub_lock_rename(h_parents[0], h_parents[1]);
++}
++
++static inline
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ vfsub_unlock_rename(h_parents[0], h_parents[1]);
++}
++
++static inline void au_reset_hinotify(struct inode *inode, unsigned int flags)
++{
++ /* nothing */
++}
++
++#define au_inotify_init() 0
++#define au_inotify_fin() /* */
++#endif /* CONFIG_AUFS_HINOTIFY */
++
++static inline void free_hinotify(struct inode *inode, aufs_bindex_t bindex)
++{
++ do_free_hinotify(itoii(inode)->ii_hinode + bindex);
++}
++
++/*
++ * hgdir_lock, hdir_lock, hdir2_lock
++ */
++#define LockFunc(name, lsc) \
++static inline \
++void name##_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex) \
++{do_hdir_lock(h_dir, dir, bindex, AuLsc_HI_##lsc);}
++
++LockFunc(hgdir, GPARENT);
++LockFunc(hdir, PARENT);
++LockFunc(hdir2, PARENT2);
++
++#undef LockFunc
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for iinfo */
++enum {
++ AuLsc_II_CHILD, /* child first */
++ AuLsc_II_CHILD2, /* rename(2), link(2), and cpup at hinotify */
++ AuLsc_II_CHILD3, /* copyup dirs */
++ AuLsc_II_PARENT,
++ AuLsc_II_PARENT2,
++ AuLsc_II_PARENT3,
++ AuLsc_II_NEW /* new inode */
++};
++
++/*
++ * ii_read_lock_child, ii_write_lock_child,
++ * ii_read_lock_child2, ii_write_lock_child2,
++ * ii_read_lock_child3, ii_write_lock_child3,
++ * ii_read_lock_parent, ii_write_lock_parent,
++ * ii_read_lock_parent2, ii_write_lock_parent2,
++ * ii_read_lock_parent3, ii_write_lock_parent3,
++ * ii_read_lock_new, ii_write_lock_new
++ */
++#define ReadLockFunc(name, lsc) \
++static inline void ii_read_lock_##name(struct inode *i) \
++{rw_read_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc);}
++
++#define WriteLockFunc(name, lsc) \
++static inline void ii_write_lock_##name(struct inode *i) \
++{rw_write_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc);}
++
++#define RWLockFuncs(name, lsc) \
++ ReadLockFunc(name, lsc); \
++ WriteLockFunc(name, lsc)
++
++RWLockFuncs(child, CHILD);
++RWLockFuncs(child2, CHILD2);
++RWLockFuncs(child3, CHILD3);
++RWLockFuncs(parent, PARENT);
++RWLockFuncs(parent2, PARENT2);
++RWLockFuncs(parent3, PARENT3);
++RWLockFuncs(new, NEW);
++
++#undef ReadLockFunc
++#undef WriteLockFunc
++#undef RWLockFunc
++
++/*
++ * ii_read_unlock, ii_write_unlock, ii_downgrade_lock
++ */
++SimpleUnlockRwsemFuncs(ii, struct inode *i, itoii(i)->ii_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define IiMustReadLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustReadLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustWriteLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustWriteLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustAnyLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustAnyLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustNoWaiters(i) RwMustNoWaiters(&itoii(i)->ii_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_INODE_H__ */
+diff --git a/fs/aufs/misc.c b/fs/aufs/misc.c
+new file mode 100755
+index 0000000..32e0549
+--- /dev/null
++++ b/fs/aufs/misc.c
+@@ -0,0 +1,228 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: misc.c,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++//#include <linux/mm.h>
++//#include <asm/uaccess.h>
++#include "aufs.h"
++
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp)
++{
++ void *q;
++
++ LKTRTrace("p %p, nused %d, sz %d, ksize %d\n",
++ p, nused, new_sz, ksize(p));
++ DEBUG_ON(new_sz <= 0);
++ if (new_sz <= nused)
++ return p;
++ if (new_sz <= ksize(p)) {
++ memset(p + nused, 0, new_sz - nused);
++ return p;
++ }
++
++ q = kmalloc(new_sz, gfp);
++ //q = NULL;
++ if (unlikely(!q))
++ return NULL;
++ memcpy(q, p, nused);
++ memset(q + nused, 0, new_sz - nused);
++ //smp_mb();
++ kfree(p);
++ return q;
++}
++
++/* ---------------------------------------------------------------------- */
++
++// todo: make it inline
++struct nameidata *fake_dm(struct nameidata *fake_nd, struct nameidata *nd,
++ struct super_block *sb, aufs_bindex_t bindex)
++{
++ LKTRTrace("nd %p, b%d\n", nd, bindex);
++
++ if (!nd)
++ return NULL;
++
++ fake_nd->dentry = NULL;
++ fake_nd->mnt = NULL;
++
++#ifndef CONFIG_AUFS_FAKE_DM
++ DiMustAnyLock(nd->dentry);
++
++ if (bindex <= dbend(nd->dentry))
++ fake_nd->dentry = au_h_dptr_i(nd->dentry, bindex);
++ if (fake_nd->dentry) {
++ dget(fake_nd->dentry);
++ fake_nd->mnt = sbr_mnt(sb, bindex);
++ DEBUG_ON(!fake_nd->mnt);
++ mntget(fake_nd->mnt);
++ } else
++ fake_nd = ERR_PTR(-ENOENT);
++#endif
++
++ TraceErrPtr(fake_nd);
++ return fake_nd;
++}
++
++void fake_dm_release(struct nameidata *fake_nd)
++{
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (fake_nd) {
++ mntput(fake_nd->mnt);
++ dput(fake_nd->dentry);
++ }
++#endif
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_copy_file(struct file *dst, struct file *src, loff_t len,
++ struct super_block *sb, int *sparse)
++{
++ int err, all_zero, dlgt;
++ unsigned long blksize;
++ char *buf;
++ /* reduce stack space */
++ struct iattr *ia;
++
++ LKTRTrace("%.*s, %.*s\n",
++ DLNPair(dst->f_dentry), DLNPair(src->f_dentry));
++ DEBUG_ON(!(dst->f_mode & FMODE_WRITE));
++ IMustLock(dst->f_dentry->d_parent->d_inode);
++
++ err = -ENOMEM;
++ blksize = dst->f_dentry->d_sb->s_blocksize;
++ if (!blksize || PAGE_SIZE < blksize)
++ blksize = PAGE_SIZE;
++ LKTRTrace("blksize %lu\n", blksize);
++ buf = kmalloc(blksize, GFP_KERNEL);
++ //buf = NULL;
++ if (unlikely(!buf))
++ goto out;
++ ia = kmalloc(sizeof(*ia), GFP_KERNEL);
++ if (unlikely(!ia))
++ goto out_buf;
++
++ dlgt = need_dlgt(sb);
++ err = all_zero = 0;
++ dst->f_pos = src->f_pos = 0;
++ while (len) {
++ size_t sz, rbytes, wbytes, i;
++ char *p;
++
++ LKTRTrace("len %lld\n", len);
++ sz = blksize;
++ if (len < blksize)
++ sz = len;
++
++ /* support LSM and notify */
++ rbytes = 0;
++ while (!rbytes || err == -EAGAIN || err == -EINTR)
++ err = rbytes = vfsub_read_k(src, buf, sz, &src->f_pos,
++ dlgt);
++ if (unlikely(err < 0))
++ break;
++
++ all_zero = 0;
++ if (len >= rbytes && rbytes == blksize) {
++ all_zero = 1;
++ p = buf;
++ for (i = 0; all_zero && i < rbytes; i++)
++ all_zero = !*p++;
++ }
++ if (!all_zero) {
++ wbytes = rbytes;
++ p = buf;
++ while (wbytes) {
++ size_t b;
++ /* support LSM and notify */
++ err = b = vfsub_write_k(dst, p, wbytes,
++ &dst->f_pos, dlgt);
++ if (unlikely(err == -EAGAIN || err == -EINTR))
++ continue;
++ if (unlikely(err < 0))
++ break;
++ wbytes -= b;
++ p += b;
++ }
++ } else {
++ loff_t res;
++ LKTRLabel(hole);
++ *sparse = 1;
++ err = res = vfsub_llseek(dst, rbytes, SEEK_CUR);
++ if (unlikely(res < 0))
++ break;
++ }
++ len -= rbytes;
++ err = 0;
++ }
++
++ /* the last block may be a hole */
++ if (unlikely(!err && all_zero)) {
++ struct dentry *h_d = dst->f_dentry;
++ struct inode *h_i = h_d->d_inode;
++
++ LKTRLabel(last hole);
++ do {
++ err = vfsub_write_k(dst, "\0", 1, &dst->f_pos, dlgt);
++ } while (err == -EAGAIN || err == -EINTR);
++ if (err == 1) {
++ ia->ia_size = dst->f_pos;
++ ia->ia_valid = ATTR_SIZE | ATTR_FILE;
++ ia->ia_file = dst;
++ hi_lock_child2(h_i);
++ err = vfsub_notify_change(h_d, ia, dlgt);
++ i_unlock(h_i);
++ }
++ }
++
++ kfree(ia);
++ out_buf:
++ kfree(buf);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int test_ro(struct super_block *sb, aufs_bindex_t bindex, struct inode *inode)
++{
++ int err;
++
++ err = br_rdonly(stobr(sb, bindex));
++ if (!err && inode) {
++ struct inode *hi = au_h_iptr_i(inode, bindex);
++ if (hi)
++ err = IS_IMMUTABLE(hi) ? -EROFS : 0;
++ }
++ return err;
++}
++
++int au_test_perm(struct inode *hidden_inode, int mask, int dlgt)
++{
++ if (!current->fsuid)
++ return 0;
++ if (unlikely(au_is_nfs(hidden_inode->i_sb)
++ && (mask & MAY_WRITE)
++ && S_ISDIR(hidden_inode->i_mode)))
++ mask |= MAY_READ; /* force permission check */
++ return vfsub_permission(hidden_inode, mask, NULL, dlgt);
++}
+diff --git a/fs/aufs/misc.h b/fs/aufs/misc.h
+new file mode 100755
+index 0000000..fea4a2c
+--- /dev/null
++++ b/fs/aufs/misc.h
+@@ -0,0 +1,187 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: misc.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_MISC_H__
++#define __AUFS_MISC_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/sched.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#define I_MUTEX_QUOTA 0
++#define lockdep_off() /* */
++#define lockdep_on() /* */
++#define mutex_lock_nested(mtx, lsc) mutex_lock(mtx)
++#define down_write_nested(rw, lsc) down_write(rw)
++#define down_read_nested(rw, lsc) down_read(rw)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_rwsem {
++ struct rw_semaphore rwsem;
++#ifdef CONFIG_AUFS_DEBUG
++ atomic_t rcnt;
++#endif
++};
++
++#ifdef CONFIG_AUFS_DEBUG
++#define DbgRcntInit(rw) atomic_set(&(rw)->rcnt, 0)
++#define DbgRcntInc(rw) atomic_inc(&(rw)->rcnt)
++#define DbgRcntDec(rw) WARN_ON(atomic_dec_return(&(rw)->rcnt) < 0)
++#else
++#define DbgRcntInit(rw) /* */
++#define DbgRcntInc(rw) /* */
++#define DbgRcntDec(rw) /* */
++#endif
++
++static inline void rw_init_nolock(struct aufs_rwsem *rw)
++{
++ DbgRcntInit(rw);
++ init_rwsem(&rw->rwsem);
++}
++
++static inline void rw_init_wlock(struct aufs_rwsem *rw)
++{
++ rw_init_nolock(rw);
++ down_write(&rw->rwsem);
++}
++
++static inline void rw_init_wlock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ rw_init_nolock(rw);
++ down_write_nested(&rw->rwsem, lsc);
++}
++
++static inline void rw_read_lock(struct aufs_rwsem *rw)
++{
++ down_read(&rw->rwsem);
++ DbgRcntInc(rw);
++}
++
++static inline void rw_read_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ down_read_nested(&rw->rwsem, lsc);
++ DbgRcntInc(rw);
++}
++
++static inline void rw_read_unlock(struct aufs_rwsem *rw)
++{
++ DbgRcntDec(rw);
++ up_read(&rw->rwsem);
++}
++
++static inline void rw_dgrade_lock(struct aufs_rwsem *rw)
++{
++ DbgRcntInc(rw);
++ downgrade_write(&rw->rwsem);
++}
++
++static inline void rw_write_lock(struct aufs_rwsem *rw)
++{
++ down_write(&rw->rwsem);
++}
++
++static inline void rw_write_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ down_write_nested(&rw->rwsem, lsc);
++}
++
++static inline void rw_write_unlock(struct aufs_rwsem *rw)
++{
++ up_write(&rw->rwsem);
++}
++
++#if 0 // why is not _nested version defined
++static inline int rw_read_trylock(struct aufs_rwsem *rw)
++{
++ int ret = down_read_trylock(&rw->rwsem);
++ if (ret)
++ DbgRcntInc(rw);
++ return ret;
++}
++
++static inline int rw_write_trylock(struct aufs_rwsem *rw)
++{
++ return down_write_trylock(&rw->rwsem);
++}
++#endif
++
++#undef DbgRcntInit
++#undef DbgRcntInc
++#undef DbgRcntDec
++
++/* to debug easier, do not make them inlined functions */
++#define RwMustNoWaiters(rw) DEBUG_ON(!list_empty(&(rw)->rwsem.wait_list))
++#define RwMustAnyLock(rw) DEBUG_ON(down_write_trylock(&(rw)->rwsem))
++#ifdef CONFIG_AUFS_DEBUG
++#define RwMustReadLock(rw) do { \
++ RwMustAnyLock(rw); \
++ DEBUG_ON(!atomic_read(&(rw)->rcnt)); \
++} while (0)
++#define RwMustWriteLock(rw) do { \
++ RwMustAnyLock(rw); \
++ DEBUG_ON(atomic_read(&(rw)->rcnt)); \
++} while (0)
++#else
++#define RwMustReadLock(rw) RwMustAnyLock(rw)
++#define RwMustWriteLock(rw) RwMustAnyLock(rw)
++#endif
++
++#define SimpleLockRwsemFuncs(prefix, param, rwsem) \
++static inline void prefix##_read_lock(param) {rw_read_lock(&(rwsem));} \
++static inline void prefix##_write_lock(param) {rw_write_lock(&(rwsem));}
++//static inline void prefix##_read_trylock(param) {rw_read_trylock(&(rwsem));}
++//static inline void prefix##_write_trylock(param) {rw_write_trylock(&(rwsem));}
++//static inline void prefix##_read_trylock_nested(param, lsc)
++//{rw_read_trylock_nested(&(rwsem, lsc));}
++//static inline void prefix##_write_trylock_nestd(param, lsc)
++//{rw_write_trylock_nested(&(rwsem), nested);}
++
++#define SimpleUnlockRwsemFuncs(prefix, param, rwsem) \
++static inline void prefix##_read_unlock(param) {rw_read_unlock(&(rwsem));} \
++static inline void prefix##_write_unlock(param) {rw_write_unlock(&(rwsem));} \
++static inline void prefix##_downgrade_lock(param) {rw_dgrade_lock(&(rwsem));}
++
++#define SimpleRwsemFuncs(prefix, param, rwsem) \
++ SimpleLockRwsemFuncs(prefix, param, rwsem); \
++ SimpleUnlockRwsemFuncs(prefix, param, rwsem)
++
++/* ---------------------------------------------------------------------- */
++
++typedef ssize_t (*readf_t)(struct file*, char __user*, size_t, loff_t*);
++typedef ssize_t (*writef_t)(struct file*, const char __user*, size_t, loff_t*);
++
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp);
++struct nameidata *fake_dm(struct nameidata *fake_nd, struct nameidata *nd,
++ struct super_block *sb, aufs_bindex_t bindex);
++void fake_dm_release(struct nameidata *fake_nd);
++int au_copy_file(struct file *dst, struct file *src, loff_t len,
++ struct super_block *sb, int *sparse);
++int test_ro(struct super_block *sb, aufs_bindex_t bindex, struct inode *inode);
++int au_test_perm(struct inode *h_inode, int mask, int dlgt);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_MISC_H__ */
+diff --git a/fs/aufs/module.c b/fs/aufs/module.c
+new file mode 100755
+index 0000000..06c563e
+--- /dev/null
++++ b/fs/aufs/module.c
+@@ -0,0 +1,334 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: module.c,v 1.9 2007/04/30 05:46:32 sfjro Exp $ */
++
++//#include <linux/init.h>
++//#include <linux/kobject.h>
++#include <linux/module.h>
++//#include <linux/seq_file.h>
++//#include <linux/sysfs.h>
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * aufs caches
++ */
++struct kmem_cache *aufs_cachep[AuCache_Last];
++static int __init create_cache(void)
++{
++#define Cache(type) kmem_cache_create(#type, sizeof(struct type), 0, \
++ SLAB_RECLAIM_ACCOUNT, NULL, NULL)
++
++ if ((aufs_cachep[AuCache_DINFO] = Cache(aufs_dinfo))
++ && (aufs_cachep[AuCache_ICNTNR] = Cache(aufs_icntnr))
++ && (aufs_cachep[AuCache_FINFO] = Cache(aufs_finfo))
++ //&& (aufs_cachep[AuCache_FINFO] = NULL)
++ && (aufs_cachep[AuCache_VDIR] = Cache(aufs_vdir))
++ && (aufs_cachep[AuCache_DEHSTR] = Cache(aufs_dehstr))
++ && (aufs_cachep[AuCache_HINOTIFY] = Cache(aufs_hinotify)))
++ return 0;
++ return -ENOMEM;
++
++#undef Cache
++}
++
++static void destroy_cache(void)
++{
++ int i;
++ for (i = 0; i < AuCache_Last; i++)
++ if (aufs_cachep[i])
++ kmem_cache_destroy(aufs_cachep[i]);
++}
++
++/* ---------------------------------------------------------------------- */
++
++char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
++int au_dir_roflags;
++extern struct file_system_type aufs_fs_type;
++
++#ifdef DbgDlgt
++#include <linux/security.h>
++#include "dbg_dlgt.c"
++#else
++#define dbg_dlgt_init() 0
++#define dbg_dlgt_fin() /* */
++#endif
++
++/*
++ * functions for module interface.
++ */
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Junjiro Okajima");
++MODULE_DESCRIPTION(AUFS_NAME " -- Another unionfs");
++MODULE_VERSION(AUFS_VERSION);
++
++/* it should be 'byte', but param_set_byte() prints by "%c" */
++short aufs_nwkq = AUFS_NWKQ_DEF;
++MODULE_PARM_DESC(nwkq, "the number of workqueue thread, " AUFS_WKQ_NAME);
++module_param_named(nwkq, aufs_nwkq, short, 0444);
++
++int sysaufs_brs = 0;
++MODULE_PARM_DESC(brs, "use <sysfs>/fs/aufs/brs");
++module_param_named(brs, sysaufs_brs, int, 0444);
++
++static int __init aufs_init(void)
++{
++ int err, i;
++ char *p;
++
++ //sbinfo->si_xino is atomic_long_t
++ BUILD_BUG_ON(sizeof(ino_t) != sizeof(long));
++
++#ifdef CONFIG_AUFS_DEBUG
++ {
++ struct aufs_destr destr;
++ destr.len = -1;
++ DEBUG_ON(destr.len < NAME_MAX);
++ }
++
++#ifdef CONFIG_4KSTACKS
++ printk("CONFIG_4KSTACKS is defined.\n");
++#endif
++#if 0 // verbose debug
++ {
++ union {
++ struct aufs_branch *br;
++ struct aufs_dinfo *di;
++ struct aufs_finfo *fi;
++ struct aufs_iinfo *ii;
++ struct aufs_hinode *hi;
++ struct aufs_sbinfo *si;
++ struct aufs_destr *destr;
++ struct aufs_de *de;
++ struct aufs_wh *wh;
++ struct aufs_vdir *vd;
++ } u;
++
++ printk("br{"
++ "xino %d, readf %d, writef %d, "
++ "id %d, perm %d, mnt %d, count %d, "
++ "wh_sem %d, wh %d, run %d} %d\n",
++ offsetof(typeof(*u.br), br_xino),
++ offsetof(typeof(*u.br), br_xino_read),
++ offsetof(typeof(*u.br), br_xino_write),
++ offsetof(typeof(*u.br), br_id),
++ offsetof(typeof(*u.br), br_perm),
++ offsetof(typeof(*u.br), br_mnt),
++ offsetof(typeof(*u.br), br_count),
++ offsetof(typeof(*u.br), br_wh_rwsem),
++ offsetof(typeof(*u.br), br_wh),
++ offsetof(typeof(*u.br), br_wh_running),
++ sizeof(*u.br));
++ printk("di{gen %d, rwsem %d, bstart %d, bend %d, bwh %d, "
++ "bdiropq %d, hdentry %d, reval %d} %d\n",
++ offsetof(typeof(*u.di), di_generation),
++ offsetof(typeof(*u.di), di_rwsem),
++ offsetof(typeof(*u.di), di_bstart),
++ offsetof(typeof(*u.di), di_bend),
++ offsetof(typeof(*u.di), di_bwh),
++ offsetof(typeof(*u.di), di_bdiropq),
++ offsetof(typeof(*u.di), di_hdentry),
++ offsetof(typeof(*u.di), di_reval),
++ sizeof(*u.di));
++ printk("fi{gen %d, rwsem %d, hfile %d, bstart %d, bend %d, "
++ "h_vm_ops %d, vdir_cach %d} %d\n",
++ offsetof(typeof(*u.fi), fi_generation),
++ offsetof(typeof(*u.fi), fi_rwsem),
++ offsetof(typeof(*u.fi), fi_hfile),
++ offsetof(typeof(*u.fi), fi_bstart),
++ offsetof(typeof(*u.fi), fi_bend),
++ offsetof(typeof(*u.fi), fi_h_vm_ops),
++ offsetof(typeof(*u.fi), fi_vdir_cache),
++ sizeof(*u.fi));
++ printk("ii{rwsem %d, bstart %d, bend %d, hinode %d, vdir %d} "
++ "%d\n",
++ offsetof(typeof(*u.ii), ii_rwsem),
++ offsetof(typeof(*u.ii), ii_bstart),
++ offsetof(typeof(*u.ii), ii_bend),
++ offsetof(typeof(*u.ii), ii_hinode),
++ offsetof(typeof(*u.ii), ii_vdir),
++ sizeof(*u.ii));
++ printk("hi{inode %d, id %d, notify %d} %d\n",
++ offsetof(typeof(*u.hi), hi_inode),
++ offsetof(typeof(*u.hi), hi_id),
++ offsetof(typeof(*u.hi), hi_notify),
++ sizeof(*u.hi));
++ printk("si{rwsem %d, gen %d, "
++ "failed_refresh %d, "
++ "bend %d, last id %d, br %d, "
++ "flags %d, "
++ "xino %d, "
++ "rdcache %d, "
++ "dirwh %d, "
++ "pl_lock %d, pl %d, "
++ "kobj %d} %d\n",
++ offsetof(typeof(*u.si), si_rwsem),
++ offsetof(typeof(*u.si), si_generation),
++ -1,//offsetof(typeof(*u.si), si_failed_refresh_dirs),
++ offsetof(typeof(*u.si), si_bend),
++ offsetof(typeof(*u.si), si_last_br_id),
++ offsetof(typeof(*u.si), si_branch),
++ offsetof(typeof(*u.si), si_flags),
++ offsetof(typeof(*u.si), si_xino),
++ offsetof(typeof(*u.si), si_rdcache),
++ offsetof(typeof(*u.si), si_dirwh),
++ offsetof(typeof(*u.si), si_plink_lock),
++ offsetof(typeof(*u.si), si_plink),
++ offsetof(typeof(*u.si), si_kobj),
++ sizeof(*u.si));
++ printk("destr{len %d, name %d} %d\n",
++ offsetof(typeof(*u.destr), len),
++ offsetof(typeof(*u.destr), name),
++ sizeof(*u.destr));
++ printk("de{ino %d, type %d, str %d} %d\n",
++ offsetof(typeof(*u.de), de_ino),
++ offsetof(typeof(*u.de), de_type),
++ offsetof(typeof(*u.de), de_str),
++ sizeof(*u.de));
++ printk("wh{hash %d, bindex %d, str %d} %d\n",
++ offsetof(typeof(*u.wh), wh_hash),
++ offsetof(typeof(*u.wh), wh_bindex),
++ offsetof(typeof(*u.wh), wh_str),
++ sizeof(*u.wh));
++ printk("vd{deblk %d, nblk %d, last %d, ver %d, jiffy %d} %d\n",
++ offsetof(typeof(*u.vd), vd_deblk),
++ offsetof(typeof(*u.vd), vd_nblk),
++ offsetof(typeof(*u.vd), vd_last),
++ offsetof(typeof(*u.vd), vd_version),
++ offsetof(typeof(*u.vd), vd_jiffy),
++ sizeof(*u.vd));
++ }
++#endif
++#endif
++
++ p = au_esc_chars;
++ for (i = 1; i <= ' '; i++)
++ *p++ = i;
++ *p++ = '\\';
++ *p++ = '\x7f';
++ *p = 0;
++
++ au_dir_roflags = au_file_roflags(O_DIRECTORY | O_LARGEFILE);
++#ifndef CONFIG_AUFS_SYSAUFS
++ sysaufs_brs = 0;
++#endif
++
++ err = -EINVAL;
++ if (unlikely(aufs_nwkq <= 0))
++ goto out;
++ err = create_cache();
++ if (unlikely(err))
++ goto out;
++ err = sysaufs_init();
++ if (unlikely(err))
++ goto out_cache;
++ err = au_wkq_init();
++ if (unlikely(err))
++ goto out_kobj;
++ err = au_inotify_init();
++ if (unlikely(err))
++ goto out_wkq;
++ err = dbg_dlgt_init();
++ if (unlikely(err))
++ goto out_inotify;
++ err = register_filesystem(&aufs_fs_type);
++ if (unlikely(err))
++ goto out_dlgt;
++ printk(AUFS_NAME " " AUFS_VERSION "\n");
++ return 0; /* success */
++
++ out_dlgt:
++ dbg_dlgt_fin();
++ out_inotify:
++ au_inotify_fin();
++ out_wkq:
++ au_wkq_fin();
++ out_kobj:
++ sysaufs_fin();
++ out_cache:
++ destroy_cache();
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static void __exit aufs_exit(void)
++{
++ unregister_filesystem(&aufs_fs_type);
++ dbg_dlgt_fin();
++ au_inotify_fin();
++ au_wkq_fin();
++ sysaufs_fin();
++ destroy_cache();
++}
++
++module_init(aufs_init);
++module_exit(aufs_exit);
++
++/* ---------------------------------------------------------------------- */
++
++// fake Kconfig
++#if 1
++#ifdef CONFIG_AUFS_HINOTIFY
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_HINOTIFY is supported in linux-2.6.18 and later.
++#endif
++#ifndef CONFIG_INOTIFY
++#error enable CONFIG_INOTIFY to use CONFIG_AUFS_HINOTIFY.
++#endif
++#endif
++
++#if AUFS_BRANCH_MAX > 511 && BITS_PER_LONG == 64 && PAGE_SIZE == 4096
++#warning For 4k pagesize and 64bit environment, \
++ CONFIG_AUFS_BRANCH_MAX_511 or smaller is recommended.
++#endif
++
++#ifdef CONFIG_AUFS_SYSAUFS
++#ifndef CONFIG_SYSFS
++#error CONFIG_AUFS_SYSAUFS requires CONFIG_SYSFS.
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_SYSAUFS requires linux-2.6.18 and later.
++#endif
++#endif
++
++#ifdef CONFIG_AUFS_EXPORT
++#if !defined(CONFIG_EXPORTFS) && !defined(CONFIG_EXPORTFS_MODULE)
++#error CONFIG_AUFS_EXPORT requires CONFIG_EXPORTFS
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_EXPORT requires linux-2.6.18 and later.
++#endif
++#if defined(CONFIG_EXPORTFS_MODULE) && defined(CONFIG_AUFS)
++#error need CONFIG_EXPORTFS=y to link aufs statically with CONFIG_AUFS_EXPORT
++#endif
++#endif
++
++#ifdef CONFIG_DEBUG_PROVE_LOCKING
++#if MAX_LOCKDEP_SUBCLASSES < AuLsc_End
++#warning lockdep will not work since aufs uses deeper locks.
++#endif
++#endif
++
++#ifdef CONFIG_AUFS_COMPAT
++#warning CONFIG_AUFS_COMPAT will be removed in the near future.
++#endif
++
++#endif
+diff --git a/fs/aufs/module.h b/fs/aufs/module.h
+new file mode 100755
+index 0000000..3769861
+--- /dev/null
++++ b/fs/aufs/module.h
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: module.h,v 1.8 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_MODULE_H__
++#define __AUFS_MODULE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/slab.h>
++
++/* ---------------------------------------------------------------------- */
++
++/* module parameters */
++extern short aufs_nwkq;
++extern int sysaufs_brs;
++
++/* ---------------------------------------------------------------------- */
++
++extern char au_esc_chars[];
++extern int au_dir_roflags;
++
++/* kmem cache */
++enum {AuCache_DINFO, AuCache_ICNTNR, AuCache_FINFO, AuCache_VDIR,
++ AuCache_DEHSTR, AuCache_HINOTIFY, AuCache_Last};
++extern struct kmem_cache *aufs_cachep[];
++
++#define CacheFuncs(name, index) \
++static inline void *cache_alloc_##name(void) \
++{return kmem_cache_alloc(aufs_cachep[index], GFP_KERNEL);} \
++static inline void cache_free_##name(void *p) \
++{kmem_cache_free(aufs_cachep[index], p);}
++
++CacheFuncs(dinfo, AuCache_DINFO);
++CacheFuncs(icntnr, AuCache_ICNTNR);
++CacheFuncs(finfo, AuCache_FINFO);
++CacheFuncs(vdir, AuCache_VDIR);
++CacheFuncs(dehstr, AuCache_DEHSTR);
++CacheFuncs(hinotify, AuCache_HINOTIFY);
++
++#undef CacheFuncs
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_MODULE_H__ */
+diff --git a/fs/aufs/opts.c b/fs/aufs/opts.c
+new file mode 100755
+index 0000000..c1a9445
+--- /dev/null
++++ b/fs/aufs/opts.c
+@@ -0,0 +1,1043 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: opts.c,v 1.34 2007/05/14 03:40:27 sfjro Exp $ */
++
++#include <asm/types.h> // a distribution requires
++#include <linux/parser.h>
++#include "aufs.h"
++
++enum {
++ Opt_br,
++ Opt_add, Opt_del, Opt_mod, Opt_append, Opt_prepend,
++ Opt_idel, Opt_imod,
++ Opt_dirwh, Opt_rdcache, Opt_deblk, Opt_nhash,
++ Opt_xino, Opt_zxino, Opt_noxino,
++ Opt_plink, Opt_noplink, Opt_list_plink, Opt_clean_plink,
++ Opt_udba,
++ Opt_diropq_a, Opt_diropq_w,
++ Opt_warn_perm, Opt_nowarn_perm,
++ Opt_findrw_dir, Opt_findrw_br,
++ Opt_coo,
++ Opt_dlgt, Opt_nodlgt,
++ Opt_tail, Opt_ignore, Opt_err
++};
++
++static match_table_t options = {
++ {Opt_br, "br=%s"},
++ {Opt_br, "br:%s"},
++
++ {Opt_add, "add=%d:%s"},
++ {Opt_add, "add:%d:%s"},
++ {Opt_add, "ins=%d:%s"},
++ {Opt_add, "ins:%d:%s"},
++ {Opt_append, "append=%s"},
++ {Opt_append, "append:%s"},
++ {Opt_prepend, "prepend=%s"},
++ {Opt_prepend, "prepend:%s"},
++
++ {Opt_del, "del=%s"},
++ {Opt_del, "del:%s"},
++ //{Opt_idel, "idel:%d"},
++ {Opt_mod, "mod=%s"},
++ {Opt_mod, "mod:%s"},
++ //{Opt_imod, "imod:%d:%s"},
++
++ {Opt_dirwh, "dirwh=%d"},
++ {Opt_dirwh, "dirwh:%d"},
++
++ {Opt_xino, "xino=%s"},
++ {Opt_xino, "xino:%s"},
++ {Opt_noxino, "noxino"},
++ //{Opt_zxino, "zxino=%s"},
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
++ {Opt_plink, "plink"},
++ {Opt_noplink, "noplink"},
++#ifdef CONFIG_AUFS_DEBUG
++ {Opt_list_plink, "list_plink"},
++#endif
++ {Opt_clean_plink, "clean_plink"},
++#endif
++
++ {Opt_udba, "udba=%s"},
++
++ {Opt_diropq_a, "diropq=always"},
++ {Opt_diropq_a, "diropq=a"},
++ {Opt_diropq_w, "diropq=whiteouted"},
++ {Opt_diropq_w, "diropq=w"},
++
++ {Opt_warn_perm, "warn_perm"},
++ {Opt_nowarn_perm, "nowarn_perm"},
++
++#ifdef CONFIG_AUFS_DLGT
++ {Opt_dlgt, "dlgt"},
++ {Opt_nodlgt, "nodlgt"},
++#endif
++
++ {Opt_rdcache, "rdcache=%d"},
++ {Opt_rdcache, "rdcache:%d"},
++#if 0
++ {Opt_findrw_dir, "findrw=dir"},
++ {Opt_findrw_br, "findrw=br"},
++
++ {Opt_coo, "coo=%s"},
++
++ {Opt_deblk, "deblk=%d"},
++ {Opt_deblk, "deblk:%d"},
++ {Opt_nhash, "nhash=%d"},
++ {Opt_nhash, "nhash:%d"},
++#endif
++
++ {Opt_br, "dirs=%s"},
++ {Opt_ignore, "debug=%d"},
++ {Opt_ignore, "delete=whiteout"},
++ {Opt_ignore, "delete=all"},
++ {Opt_ignore, "imap=%s"},
++
++ {Opt_err, NULL}
++};
++
++/* ---------------------------------------------------------------------- */
++
++#define RW "rw"
++#define RO "ro"
++#define WH "wh"
++#define RR "rr"
++#define NoLinkWH "nolwh"
++
++static match_table_t brperms = {
++ {AuBr_RR, RR},
++ {AuBr_RO, RO},
++ {AuBr_RW, RW},
++
++ {AuBr_RRWH, RR "+" WH},
++ {AuBr_ROWH, RO "+" WH},
++ {AuBr_RWNoLinkWH, RW "+" NoLinkWH},
++
++ {AuBr_ROWH, "nfsro"},
++ {AuBr_RO, NULL}
++};
++
++static int br_perm_val(char *perm)
++{
++ int val;
++ substring_t args[MAX_OPT_ARGS];
++
++ DEBUG_ON(!perm || !*perm);
++ LKTRTrace("perm %s\n", perm);
++ val = match_token(perm, brperms, args);
++ TraceErr(val);
++ return val;
++}
++
++int br_perm_str(char *p, unsigned int len, int brperm)
++{
++ struct match_token *bp = brperms;
++
++ LKTRTrace("len %d, 0x%x\n", len, brperm);
++
++ while (bp->pattern) {
++ if (bp->token == brperm) {
++ if (strlen(bp->pattern) < len) {
++ strcpy(p, bp->pattern);
++ return 0;
++ } else
++ return -E2BIG;
++ }
++ bp++;
++ }
++
++ return -EIO;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static match_table_t udbalevel = {
++ {AuFlag_UDBA_REVAL, "reval"},
++#ifdef CONFIG_AUFS_HINOTIFY
++ {AuFlag_UDBA_INOTIFY, "inotify"},
++#endif
++ {AuFlag_UDBA_NONE, "none"},
++ {-1, NULL}
++};
++
++static int udba_val(char *str)
++{
++ substring_t args[MAX_OPT_ARGS];
++ return match_token(str, udbalevel, args);
++}
++
++au_parser_pattern_t udba_str(int udba)
++{
++ struct match_token *p = udbalevel;
++ while (p->pattern) {
++ if (p->token == udba)
++ return p->pattern;
++ p++;
++ }
++ BUG();
++ return "??";
++}
++
++void udba_set(struct super_block *sb, unsigned int flg)
++{
++ au_flag_clr(sb, AuMask_UDBA);
++ au_flag_set(sb, flg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static match_table_t coolevel = {
++ {AuFlag_COO_LEAF, "leaf"},
++ {AuFlag_COO_ALL, "all"},
++ {AuFlag_COO_NONE, "none"},
++ {-1, NULL}
++};
++
++#if 0
++static int coo_val(char *str)
++{
++ substring_t args[MAX_OPT_ARGS];
++ return match_token(str, coolevel, args);
++}
++#endif
++
++au_parser_pattern_t coo_str(int coo)
++{
++ struct match_token *p = coolevel;
++ while (p->pattern) {
++ if (p->token == coo)
++ return p->pattern;
++ p++;
++ }
++ BUG();
++ return "??";
++}
++static void coo_set(struct super_block *sb, unsigned int flg)
++{
++ au_flag_clr(sb, AuMask_COO);
++ au_flag_set(sb, flg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static const int lkup_dirflags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
++
++#ifdef CONFIG_AUFS_DEBUG
++static void dump_opts(struct opts *opts)
++{
++ /* reduce stack space */
++ union {
++ struct opt_add *add;
++ struct opt_del *del;
++ struct opt_mod *mod;
++ struct opt_xino *xino;
++ } u;
++ struct opt *opt;
++
++ TraceEnter();
++
++ opt = opts->opt;
++ while (/* opt < opts_tail && */ opt->type != Opt_tail) {
++ switch (opt->type) {
++ case Opt_add:
++ u.add = &opt->add;
++ LKTRTrace("add {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_del:
++ case Opt_idel:
++ u.del = &opt->del;
++ LKTRTrace("del {%s, %p}\n", u.del->path, u.del->h_root);
++ break;
++ case Opt_mod:
++ case Opt_imod:
++ u.mod = &opt->mod;
++ LKTRTrace("mod {%s, 0x%x, %p}\n",
++ u.mod->path, u.mod->perm, u.mod->h_root);
++ break;
++ case Opt_append:
++ u.add = &opt->add;
++ LKTRTrace("append {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_prepend:
++ u.add = &opt->add;
++ LKTRTrace("prepend {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_dirwh:
++ LKTRTrace("dirwh %d\n", opt->dirwh);
++ break;
++ case Opt_rdcache:
++ LKTRTrace("rdcache %d\n", opt->rdcache);
++ break;
++ case Opt_xino:
++ u.xino = &opt->xino;
++ LKTRTrace("xino {%s %.*s}\n",
++ u.xino->path, DLNPair(u.xino->file->f_dentry));
++ break;
++ case Opt_noxino:
++ LKTRLabel(noxino);
++ break;
++ case Opt_plink:
++ LKTRLabel(plink);
++ break;
++ case Opt_noplink:
++ LKTRLabel(noplink);
++ break;
++ case Opt_list_plink:
++ LKTRLabel(list_plink);
++ break;
++ case Opt_clean_plink:
++ LKTRLabel(clean_plink);
++ break;
++ case Opt_udba:
++ LKTRTrace("udba %d, %s\n",
++ opt->udba, udba_str(opt->udba));
++ break;
++ case Opt_diropq_a:
++ LKTRLabel(diropq_a);
++ break;
++ case Opt_diropq_w:
++ LKTRLabel(diropq_w);
++ break;
++ case Opt_warn_perm:
++ LKTRLabel(warn_perm);
++ break;
++ case Opt_nowarn_perm:
++ LKTRLabel(nowarn_perm);
++ break;
++ case Opt_dlgt:
++ LKTRLabel(dlgt);
++ break;
++ case Opt_nodlgt:
++ LKTRLabel(nodlgt);
++ break;
++ case Opt_coo:
++ LKTRTrace("coo %d, %s\n", opt->coo, coo_str(opt->coo));
++ break;
++ default:
++ BUG();
++ }
++ opt++;
++ }
++}
++#else
++#define dump_opts(opts) /* */
++#endif
++
++void au_free_opts(struct opts *opts)
++{
++ struct opt *opt;
++
++ TraceEnter();
++
++ opt = opts->opt;
++ while (opt->type != Opt_tail) {
++ switch (opt->type) {
++ case Opt_add:
++ case Opt_append:
++ case Opt_prepend:
++ path_release(&opt->add.nd);
++ break;
++ case Opt_del:
++ case Opt_idel:
++ dput(opt->del.h_root);
++ break;
++ case Opt_mod:
++ case Opt_imod:
++ dput(opt->mod.h_root);
++ break;
++ case Opt_xino:
++ fput(opt->xino.file);
++ break;
++ }
++ opt++;
++ }
++}
++
++static int opt_add(struct opt *opt, char *opt_str, struct super_block *sb,
++ aufs_bindex_t bindex)
++{
++ int err;
++ struct opt_add *add = &opt->add;
++ char *p;
++
++ LKTRTrace("%s, b%d\n", opt_str, bindex);
++
++ add->bindex = bindex;
++ add->perm = AuBr_RO;
++ if (!bindex && !(sb->s_flags & MS_RDONLY))
++ add->perm = AuBr_RW;
++#ifdef CONFIG_AUFS_COMPAT
++ add->perm = AuBr_RW;
++#endif
++ add->path = opt_str;
++ p = strchr(opt_str, '=');
++ if (unlikely(p)) {
++ *p++ = 0;
++ if (*p)
++ add->perm = br_perm_val(p);
++ }
++
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(add->path, lkup_dirflags, &add->nd);
++ //err = -1;
++ if (!err) {
++ opt->type = Opt_add;
++ goto out;
++ }
++ Err("lookup failed %s (%d)\n", add->path, err);
++ err = -EINVAL;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* called without aufs lock */
++int au_parse_opts(struct super_block *sb, char *str, struct opts *opts)
++{
++ int err, n;
++ struct dentry *root;
++ struct opt *opt, *opt_tail;
++ char *opt_str;
++ substring_t args[MAX_OPT_ARGS];
++ aufs_bindex_t bindex;
++ struct nameidata nd;
++ /* reduce stack space */
++ union {
++ struct opt_del *del;
++ struct opt_mod *mod;
++ struct opt_xino *xino;
++ } u;
++ struct file *file;
++
++ LKTRTrace("%s, nopts %d\n", str, opts->max_opt);
++
++ root = sb->s_root;
++ err = 0;
++ bindex = 0;
++ opt = opts->opt;
++ opt_tail = opt + opts->max_opt - 1;
++ opt->type = Opt_tail;
++ while (!err && (opt_str = strsep(&str, ",")) && *opt_str) {
++ int token, skipped;
++ char *p;
++ err = -EINVAL;
++ token = match_token(opt_str, options, args);
++ LKTRTrace("%s, token %d, args[0]{%p, %p}\n",
++ opt_str, token, args[0].from, args[0].to);
++
++ skipped = 0;
++ switch (token) {
++ case Opt_br:
++ err = 0;
++ while (!err && (opt_str = strsep(&args[0].from, ":"))
++ && *opt_str) {
++ err = opt_add(opt, opt_str, sb, bindex++);
++ //if (LktrCond) err = -1;
++ if (unlikely(!err && ++opt > opt_tail)) {
++ err = -E2BIG;
++ break;
++ }
++ opt->type = Opt_tail;
++ skipped = 1;
++ }
++ break;
++ case Opt_add:
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ err = opt_add(opt, args[1].from, sb, bindex);
++ break;
++ case Opt_append:
++ case Opt_prepend:
++ err = opt_add(opt, args[0].from, sb, /*dummy bindex*/1);
++ if (!err)
++ opt->type = token;
++ break;
++ case Opt_del:
++ u.del = &opt->del;
++ u.del->path = args[0].from;
++ LKTRTrace("del path %s\n", u.del->path);
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(u.del->path, lkup_dirflags, &nd);
++ if (unlikely(err)) {
++ Err("lookup failed %s (%d)\n", u.del->path, err);
++ break;
++ }
++ u.del->h_root = dget(nd.dentry);
++ path_release(&nd);
++ opt->type = token;
++ break;
++#if 0
++ case Opt_idel:
++ u.del = &opt->del;
++ u.del->path = "(indexed)";
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (bindex < 0 || sbend(sb) < bindex) {
++ Err("out of bounds, %d\n", bindex);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++ }
++ err = 0;
++ u.del->h_root = dget(au_h_dptr_i(root, bindex));
++ opt->type = token;
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++#endif
++
++ case Opt_mod:
++ u.mod = &opt->mod;
++ u.mod->path = args[0].from;
++ p = strchr(u.mod->path, '=');
++ if (unlikely(!p)) {
++ Err("no permssion %s\n", opt_str);
++ break;
++ }
++ *p++ = 0;
++ u.mod->perm = br_perm_val(p);
++ LKTRTrace("mod path %s, perm 0x%x, %s\n",
++ u.mod->path, u.mod->perm, p);
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(u.mod->path, lkup_dirflags, &nd);
++ if (unlikely(err)) {
++ Err("lookup failed %s (%d)\n", u.mod->path, err);
++ break;
++ }
++ u.mod->h_root = dget(nd.dentry);
++ path_release(&nd);
++ opt->type = token;
++ break;
++#if 0
++ case Opt_imod:
++ u.mod = &opt->mod;
++ u.mod->path = "(indexed)";
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (bindex < 0 || sbend(sb) < bindex) {
++ Err("out of bounds, %d\n", bindex);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++ }
++ u.mod->perm = br_perm_val(args[1].from);
++ LKTRTrace("mod path %s, perm 0x%x, %s\n",
++ u.mod->path, u.mod->perm, args[1].from);
++ err = 0;
++ u.mod->h_root = dget(au_h_dptr_i(root, bindex));
++ opt->type = token;
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++#endif
++ case Opt_xino:
++ u.xino = &opt->xino;
++ file = xino_create(sb, args[0].from, /*silent*/0,
++ /*parent*/NULL);
++ err = PTR_ERR(file);
++ if (IS_ERR(file))
++ break;
++ err = -EINVAL;
++ if (unlikely(file->f_dentry->d_sb == sb)) {
++ fput(file);
++ Err("%s must be outside\n", args[0].from);
++ break;
++ }
++ err = 0;
++ u.xino->file = file;
++ u.xino->path = args[0].from;
++ opt->type = token;
++ break;
++
++ case Opt_dirwh:
++ if (unlikely(match_int(&args[0], &opt->dirwh)))
++ break;
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_rdcache:
++ if (unlikely(match_int(&args[0], &opt->rdcache)))
++ break;
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_noxino:
++ case Opt_plink:
++ case Opt_noplink:
++ case Opt_list_plink:
++ case Opt_clean_plink:
++ case Opt_diropq_a:
++ case Opt_diropq_w:
++ case Opt_warn_perm:
++ case Opt_nowarn_perm:
++ case Opt_dlgt:
++ case Opt_nodlgt:
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_udba:
++ opt->udba = udba_val(args[0].from);
++ if (opt->udba >= 0) {
++ err = 0;
++ opt->type = token;
++ }
++ break;
++
++#if 0
++ case Opt_coo:
++ opt->coo = coo_val(args[0].from);
++ if (opt->coo >= 0) {
++ err = 0;
++ opt->type = token;
++ }
++ break;
++#endif
++
++ case Opt_ignore:
++#ifndef CONFIG_AUFS_COMPAT
++ Warn("ignored %s\n", opt_str);
++#endif
++ skipped = 1;
++ err = 0;
++ break;
++ case Opt_err:
++ Err("unknown option %s\n", opt_str);
++ break;
++ }
++
++ if (!err && !skipped) {
++ if (unlikely(++opt > opt_tail)) {
++ err = -E2BIG;
++ opt--;
++ opt->type = Opt_tail;
++ break;
++ }
++ opt->type = Opt_tail;
++ }
++ }
++
++ dump_opts(opts);
++ if (unlikely(err))
++ au_free_opts(opts);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns,
++ * plus: processed without an error
++ * zero: unprocessed
++ */
++static int au_do_opt_simple(struct super_block *sb, struct opt *opt,
++ int remount, unsigned int *given)
++{
++ int err;
++ struct aufs_sbinfo *sbinfo = stosi(sb);
++
++ TraceEnter();
++
++ err = 1; /* handled */
++ switch (opt->type) {
++ case Opt_udba:
++ udba_set(sb, opt->udba);
++ *given |= opt->udba;
++ break;
++
++ case Opt_plink:
++ au_flag_set(sb, AuFlag_PLINK);
++ *given |= AuFlag_PLINK;
++ break;
++ case Opt_noplink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_put_plink(sb);
++ au_flag_clr(sb, AuFlag_PLINK);
++ *given |= AuFlag_PLINK;
++ break;
++ case Opt_list_plink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_list_plink(sb);
++ break;
++ case Opt_clean_plink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_put_plink(sb);
++ break;
++
++ case Opt_diropq_a:
++ au_flag_set(sb, AuFlag_ALWAYS_DIROPQ);
++ *given |= AuFlag_ALWAYS_DIROPQ;
++ break;
++ case Opt_diropq_w:
++ au_flag_clr(sb, AuFlag_ALWAYS_DIROPQ);
++ *given |= AuFlag_ALWAYS_DIROPQ;
++ break;
++
++ case Opt_dlgt:
++ au_flag_set(sb, AuFlag_DLGT);
++ *given |= AuFlag_DLGT;
++ break;
++ case Opt_nodlgt:
++ au_flag_clr(sb, AuFlag_DLGT);
++ *given |= AuFlag_DLGT;
++ break;
++
++ case Opt_warn_perm:
++ au_flag_set(sb, AuFlag_WARN_PERM);
++ *given |= AuFlag_WARN_PERM;
++ break;
++ case Opt_nowarn_perm:
++ au_flag_clr(sb, AuFlag_WARN_PERM);
++ *given |= AuFlag_WARN_PERM;
++ break;
++
++ case Opt_coo:
++ coo_set(sb, opt->coo);
++ *given |= opt->coo;
++ break;
++
++ case Opt_dirwh:
++ sbinfo->si_dirwh = opt->dirwh;
++ break;
++
++ case Opt_rdcache:
++ sbinfo->si_rdcache = opt->rdcache * HZ;
++ break;
++
++ default:
++ err = 0;
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns tri-state.
++ * plus: processed without an error
++ * zero: unprocessed
++ * minus: error
++ */
++static int au_do_opt_br(struct super_block *sb, struct opt *opt, int remount,
++ int *do_refresh)
++{
++ int err;
++
++ TraceEnter();
++
++ err = 0;
++ switch (opt->type) {
++ case Opt_append:
++ opt->add.bindex = sbend(sb) + 1;
++ goto add;
++ case Opt_prepend:
++ opt->add.bindex = 0;
++ add:
++ case Opt_add:
++ err = br_add(sb, &opt->add, remount);
++ if (!err)
++ *do_refresh = err = 1;
++ break;
++
++ case Opt_del:
++ case Opt_idel:
++ err = br_del(sb, &opt->del, remount);
++ if (!err)
++ *do_refresh = err = 1;
++ break;
++
++ case Opt_mod:
++ case Opt_imod:
++ err = br_mod(sb, &opt->mod, remount, do_refresh);
++ if (!err)
++ err = 1;
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int au_do_opt_xino(struct super_block *sb, struct opt *opt, int remount,
++ struct opt_xino **opt_xino)
++{
++ int err;
++
++ TraceEnter();
++
++ err = 0;
++ switch (opt->type) {
++ case Opt_xino:
++ err = xino_set(sb, &opt->xino, remount);
++ if (!err)
++ *opt_xino = &opt->xino;
++ break;
++ case Opt_noxino:
++ err = xino_clr(sb);
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int verify_opts(struct super_block *sb, int remount)
++{
++ int err;
++ aufs_bindex_t bindex, bend;
++ struct aufs_branch *br;
++ struct dentry *root;
++ struct inode *dir;
++ unsigned int do_plink;
++
++ TraceEnter();
++
++ if (unlikely(!(sb->s_flags & MS_RDONLY)
++ && !br_writable(sbr_perm(sb, 0))))
++ Warn("first branch should be rw\n");
++
++ err = 0;
++ root = sb->s_root;
++ dir = sb->s_root->d_inode;
++ do_plink = au_flag_test(sb, AuFlag_PLINK);
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ struct inode *h_dir;
++ int skip;
++
++ skip = 0;
++ h_dir = au_h_iptr_i(dir, bindex);
++ br = stobr(sb, bindex);
++ br_wh_read_lock(br);
++ switch (br->br_perm) {
++ case AuBr_RR:
++ case AuBr_RO:
++ case AuBr_RRWH:
++ case AuBr_ROWH:
++ skip = (!br->br_wh && !br->br_plink);
++ break;
++
++ case AuBr_RWNoLinkWH:
++ skip = !br->br_wh;
++ if (skip) {
++ if (do_plink)
++ skip = !!br->br_plink;
++ else
++ skip = !br->br_plink;
++ }
++ break;
++
++ case AuBr_RW:
++ skip = !!br->br_wh;
++ if (skip) {
++ if (do_plink)
++ skip = !!br->br_plink;
++ else
++ skip = !br->br_plink;
++ }
++ break;
++
++ default:
++ BUG();
++ }
++ br_wh_read_unlock(br);
++
++ if (skip)
++ continue;
++
++ hdir_lock(h_dir, dir, bindex);
++ br_wh_write_lock(br);
++ err = init_wh(au_h_dptr_i(root, bindex), br,
++ au_nfsmnt(sb, bindex), sb);
++ br_wh_write_unlock(br);
++ hdir_unlock(h_dir, dir, bindex);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++int au_do_opts_mount(struct super_block *sb, struct opts *opts)
++{
++ int err, do_refresh;
++ struct inode *dir;
++ struct opt *opt;
++ unsigned int flags, given;
++ struct opt_xino *opt_xino;
++ aufs_bindex_t bend, bindex;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DiMustWriteLock(sb->s_root);
++ dir = sb->s_root->d_inode;
++ IiMustWriteLock(dir);
++
++ err = 0;
++ given = 0;
++ opt_xino = NULL;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail)
++ err = au_do_opt_simple(sb, opt++, /*remount*/0, &given);
++ if (err > 0)
++ err = 0;
++ else if (unlikely(err < 0))
++ goto out;
++
++ /* disable them temporary */
++ flags = au_flag_test(sb, AuFlag_XINO | AuMask_UDBA | AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_XINO | AuFlag_DLGT);
++ udba_set(sb, AuFlag_UDBA_REVAL);
++
++ do_refresh = 0;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail)
++ err = au_do_opt_br(sb, opt++, /*remount*/0, &do_refresh);
++ if (err > 0)
++ err = 0;
++ else if (unlikely(err < 0))
++ goto out;
++
++ bend = sbend(sb);
++ if (unlikely(bend < 0)) {
++ err = -EINVAL;
++ Err("no branches\n");
++ goto out;
++ }
++
++ if (flags & AuFlag_XINO)
++ au_flag_set(sb, AuFlag_XINO);
++ opt = opts->opt;
++ while (!err && opt->type != Opt_tail)
++ err = au_do_opt_xino(sb, opt++, /*remount*/0, &opt_xino);
++ if (unlikely(err))
++ goto out;
++
++ //todo: test this error case.
++ err = verify_opts(sb, /*remount*/0);
++ DEBUG_ON(err);
++ if (unlikely(err))
++ goto out;
++
++ /* enable xino */
++ if (au_flag_test(sb, AuFlag_XINO) && !opt_xino) {
++ struct file *xino_file = xino_def(sb);
++ err = PTR_ERR(xino_file);
++ if (IS_ERR(xino_file))
++ goto out;
++
++ err = 0;
++ for (bindex = 0; !err && bindex <= bend; bindex++)
++ err = xino_init(sb, bindex, xino_file,
++ /*do_test*/bindex);
++ fput(xino_file);
++ if (unlikely(err))
++ goto out;
++ }
++
++ /* restore hinotify */
++ udba_set(sb, flags & AuMask_UDBA);
++ if (flags & AuFlag_UDBA_INOTIFY)
++ au_reset_hinotify(dir, au_hi_flags(dir, 1) & ~AUFS_HI_XINO);
++
++ /* restore dlgt */
++ if (flags & AuFlag_DLGT)
++ au_flag_set(sb, AuFlag_DLGT);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int au_do_opts_remount(struct super_block *sb, struct opts *opts,
++ int *do_refresh, unsigned int *given)
++{
++ int err, rerr;
++ struct inode *dir;
++ struct opt_xino *opt_xino;
++ struct opt *opt;
++ unsigned int dlgt;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DiMustWriteLock(sb->s_root);
++ dir = sb->s_root->d_inode;
++ IiMustWriteLock(dir);
++ //DEBUG_ON(au_flag_test(sb, AuFlag_UDBA_INOTIFY));
++
++ err = 0;
++ *do_refresh = 0;
++ *given = 0;
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ opt_xino = NULL;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail) {
++ err = au_do_opt_simple(sb, opt, /*remount*/1, given);
++
++ /* disable it temporary */
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_DLGT);
++
++ if (!err)
++ err = au_do_opt_br(sb, opt, /*remount*/1, do_refresh);
++ if (!err)
++ err = au_do_opt_xino(sb, opt, /*remount*/1, &opt_xino);
++
++ /* restore it */
++ au_flag_set(sb, dlgt);
++ opt++;
++ }
++ if (err > 0)
++ err = 0;
++ TraceErr(err);
++
++ /* go on if err */
++
++ //todo: test this error case.
++ au_flag_clr(sb, AuFlag_DLGT);
++ rerr = verify_opts(sb, /*remount*/1);
++ au_flag_set(sb, dlgt);
++
++ /* they are handled by the caller */
++ if (!*do_refresh)
++ *do_refresh = !!((*given & AuMask_UDBA)
++ || au_flag_test(sb, AuFlag_XINO));
++
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/opts.h b/fs/aufs/opts.h
+new file mode 100755
+index 0000000..16c1a6a
+--- /dev/null
++++ b/fs/aufs/opts.h
+@@ -0,0 +1,96 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: opts.h,v 1.13 2007/05/14 06:27:18 sfjro Exp $ */
++
++#ifndef __AUFS_OPTS_H__
++#define __AUFS_OPTS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
++typedef const char* au_parser_pattern_t;
++#else
++typedef char* au_parser_pattern_t;
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct opt_add {
++ aufs_bindex_t bindex;
++ char *path;
++ int perm;
++ struct nameidata nd;
++};
++
++struct opt_del {
++ char *path;
++ struct dentry *h_root;
++};
++
++struct opt_mod {
++ char *path;
++ int perm;
++ struct dentry *h_root;
++};
++
++struct opt_xino {
++ char *path;
++ struct file *file;
++};
++
++struct opt {
++ int type;
++ union {
++ struct opt_xino xino;
++ struct opt_add add;
++ struct opt_del del;
++ struct opt_mod mod;
++ int dirwh;
++ int rdcache;
++ int deblk;
++ int nhash;
++ int udba;
++ int coo;
++ };
++};
++
++struct opts {
++ struct opt *opt;
++ int max_opt;
++};
++
++/* ---------------------------------------------------------------------- */
++
++int br_perm_str(char *p, unsigned int len, int brperm);
++au_parser_pattern_t udba_str(int udba);
++void udba_set(struct super_block *sb, unsigned int flg);
++//au_parser_pattern_t coo_str(int coo);
++void au_free_opts(struct opts *opts);
++int au_parse_opts(struct super_block *sb, char *str, struct opts *opts);
++int au_do_opts_mount(struct super_block *sb, struct opts *opts);
++int au_do_opts_remount(struct super_block *sb, struct opts *opts,
++ int *do_refresh, unsigned int *given);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_OPTS_H__ */
+diff --git a/fs/aufs/plink.c b/fs/aufs/plink.c
+new file mode 100755
+index 0000000..0e520af
+--- /dev/null
++++ b/fs/aufs/plink.c
+@@ -0,0 +1,331 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: plink.c,v 1.4 2007/05/14 03:39:10 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct pseudo_link {
++ struct list_head list;
++ struct inode *inode;
++};
++
++#ifdef CONFIG_AUFS_DEBUG
++void au_list_plink(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++
++ TraceEnter();
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list)
++ Dbg("%lu\n", plink->inode->i_ino);
++ spin_unlock(&sbinfo->si_plink_lock);
++}
++#endif
++
++int au_is_plinked(struct super_block *sb, struct inode *inode)
++{
++ int found;
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ found = 0;
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list)
++ if (plink->inode == inode) {
++ found = 1;
++ break;
++ }
++ spin_unlock(&sbinfo->si_plink_lock);
++ return found;
++}
++
++// 20 is max digits length of ulong 64
++#define PLINK_NAME_LEN ((20 + 1) * 2)
++
++static int plink_name(char *name, int len, struct inode *inode,
++ aufs_bindex_t bindex)
++{
++ int rlen;
++ struct inode *h_inode;
++
++ LKTRTrace("i%lu, b%d\n", inode->i_ino, bindex);
++ DEBUG_ON(len != PLINK_NAME_LEN);
++ h_inode = au_h_iptr_i(inode, bindex);
++ DEBUG_ON(!h_inode);
++ rlen = snprintf(name, len, "%lu.%lu", inode->i_ino, h_inode->i_ino);
++ DEBUG_ON(rlen >= len);
++ return rlen;
++}
++
++struct dentry *lkup_plink(struct super_block *sb, aufs_bindex_t bindex,
++ struct inode *inode)
++{
++ struct dentry *h_dentry, *h_parent;
++ struct aufs_branch *br;
++ struct inode *h_dir;
++ char tgtname[PLINK_NAME_LEN];
++ int len;
++ struct lkup_args lkup;
++
++ LKTRTrace("b%d, i%lu\n", bindex, inode->i_ino);
++ br = stobr(sb, bindex);
++ h_parent = br->br_plink;
++ DEBUG_ON(!h_parent);
++ h_dir = h_parent->d_inode;
++ DEBUG_ON(!h_dir);
++
++ len = plink_name(tgtname, sizeof(tgtname), inode, bindex);
++
++ // always superio.
++ lkup.nfsmnt = au_do_nfsmnt(br->br_mnt);
++ lkup.dlgt = need_dlgt(sb);
++ hi_lock_whplink(h_dir);
++ h_dentry = sio_lkup_one(tgtname, h_parent, len, &lkup);
++ i_unlock(h_dir);
++ return h_dentry;
++}
++
++static int do_whplink(char *tgt, int len, struct dentry *h_parent,
++ struct dentry *h_dentry, struct vfsmount *nfsmnt,
++ struct super_block *sb)
++{
++ int err;
++ struct dentry *h_tgt;
++ struct inode *h_dir;
++ struct lkup_args lkup = {
++ .nfsmnt = nfsmnt,
++ .dlgt = need_dlgt(sb)
++ };
++
++ h_tgt = lkup_one(tgt, h_parent, len, &lkup);
++ err = PTR_ERR(h_tgt);
++ if (IS_ERR(h_tgt))
++ goto out;
++
++ err = 0;
++ h_dir = h_parent->d_inode;
++ if (unlikely(h_tgt->d_inode && h_tgt->d_inode != h_dentry->d_inode))
++ err = vfsub_unlink(h_dir, h_tgt, lkup.dlgt);
++ if (!err && !h_tgt->d_inode) {
++ err = vfsub_link(h_dentry, h_dir, h_tgt, lkup.dlgt);
++ //inode->i_nlink++;
++ }
++ dput(h_tgt);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct do_whplink_args {
++ int *errp;
++ char *tgt;
++ int len;
++ struct dentry *h_parent;
++ struct dentry *h_dentry;
++ struct vfsmount *nfsmnt;
++ struct super_block *sb;
++};
++
++static void call_do_whplink(void *args)
++{
++ struct do_whplink_args *a = args;
++ *a->errp = do_whplink(a->tgt, a->len, a->h_parent, a->h_dentry,
++ a->nfsmnt, a->sb);
++}
++
++static int whplink(struct dentry *h_dentry, struct inode *inode,
++ aufs_bindex_t bindex, struct super_block *sb)
++{
++ int err, len;
++ struct aufs_branch *br;
++ struct dentry *h_parent;
++ struct inode *h_dir;
++ char tgtname[PLINK_NAME_LEN];
++
++ LKTRTrace("%.*s\n", DLNPair(h_dentry));
++ br = stobr(inode->i_sb, bindex);
++ h_parent = br->br_plink;
++ DEBUG_ON(!h_parent);
++ h_dir = h_parent->d_inode;
++ DEBUG_ON(!h_dir);
++
++ len = plink_name(tgtname, sizeof(tgtname), inode, bindex);
++
++ // always superio.
++ hi_lock_whplink(h_dir);
++ if (!is_au_wkq(current)) {
++ struct do_whplink_args args = {
++ .errp = &err,
++ .tgt = tgtname,
++ .len = len,
++ .h_parent = h_parent,
++ .h_dentry = h_dentry,
++ .nfsmnt = au_do_nfsmnt(br->br_mnt),
++ .sb = sb
++ };
++ au_wkq_wait(call_do_whplink, &args, /*dlgt*/0);
++ } else
++ err = do_whplink(tgtname, len, h_parent, h_dentry,
++ au_do_nfsmnt(br->br_mnt), sb);
++ i_unlock(h_dir);
++
++ TraceErr(err);
++ return err;
++}
++
++void append_plink(struct super_block *sb, struct inode *inode,
++ struct dentry *h_dentry, aufs_bindex_t bindex)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++ int found, err, cnt;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ cnt = 0;
++ found = 0;
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list) {
++ cnt++;
++ if (plink->inode == inode) {
++ found = 1;
++ break;
++ }
++ }
++
++ err = 0;
++ if (!found) {
++ struct pseudo_link *plink;
++
++ plink = kmalloc(sizeof(*plink), GFP_ATOMIC);
++ if (plink) {
++ plink->inode = igrab(inode);
++ list_add(&plink->list, plink_list);
++ cnt++;
++ } else
++ err = -ENOMEM;
++ }
++ spin_unlock(&sbinfo->si_plink_lock);
++
++ if (!err)
++ err = whplink(h_dentry, inode, bindex, sb);
++
++ if (unlikely(cnt > 100))
++ Warn1("unexpectedly many pseudo links, %d\n", cnt);
++ if (unlikely(err))
++ Warn("err %d, damaged pseudo link. ignored.\n", err);
++}
++
++static void do_put_plink(struct pseudo_link *plink, int do_del)
++{
++ TraceEnter();
++
++ iput(plink->inode);
++ if (do_del)
++ list_del(&plink->list);
++ kfree(plink);
++}
++
++void au_put_plink(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink, *tmp;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ //spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry_safe(plink, tmp, plink_list, list)
++ do_put_plink(plink, 0);
++ INIT_LIST_HEAD(plink_list);
++ //spin_unlock(&sbinfo->si_plink_lock);
++}
++
++void half_refresh_plink(struct super_block *sb, aufs_bindex_t br_id)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink, *tmp;
++ struct inode *inode;
++ aufs_bindex_t bstart, bend, bindex;
++ int do_put;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ //spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry_safe(plink, tmp, plink_list, list) {
++ do_put = 0;
++ inode = igrab(plink->inode);
++ ii_write_lock_child(inode);
++ bstart = ibstart(inode);
++ bend = ibend(inode);
++ if (bstart >= 0) {
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ if (!au_h_iptr_i(inode, bindex)
++ || itoid_index(inode, bindex) != br_id)
++ continue;
++ set_h_iptr(inode, bindex, NULL, 0);
++ do_put = 1;
++ break;
++ }
++ } else
++ do_put_plink(plink, 1);
++
++ if (do_put) {
++ for (bindex = bstart; bindex <= bend; bindex++)
++ if (au_h_iptr_i(inode, bindex)) {
++ do_put = 0;
++ break;
++ }
++ if (do_put)
++ do_put_plink(plink, 1);
++ }
++ ii_write_unlock(inode);
++ iput(inode);
++ }
++ //spin_unlock(&sbinfo->si_plink_lock);
++}
+diff --git a/fs/aufs/sbinfo.c b/fs/aufs/sbinfo.c
+new file mode 100755
+index 0000000..55cb64c
+--- /dev/null
++++ b/fs/aufs/sbinfo.c
+@@ -0,0 +1,173 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sbinfo.c,v 1.30 2007/05/14 03:39:31 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct aufs_sbinfo *stosi(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ sbinfo = sb->s_fs_info;
++ //DEBUG_ON(sbinfo->si_bend < 0);
++ return sbinfo;
++}
++
++aufs_bindex_t sbend(struct super_block *sb)
++{
++ SiMustAnyLock(sb);
++ return stosi(sb)->si_bend;
++}
++
++struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex)
++{
++ SiMustAnyLock(sb);
++ DEBUG_ON(bindex < 0 || sbend(sb) < bindex
++ || !stosi(sb)->si_branch[0 + bindex]);
++ return stosi(sb)->si_branch[0 + bindex];
++}
++
++int au_sigen(struct super_block *sb)
++{
++ SiMustAnyLock(sb);
++ return stosi(sb)->si_generation;
++}
++
++int au_sigen_inc(struct super_block *sb)
++{
++ int gen;
++
++ SiMustWriteLock(sb);
++ gen = ++stosi(sb)->si_generation;
++ au_update_digen(sb->s_root);
++ au_update_iigen(sb->s_root->d_inode);
++ sb->s_root->d_inode->i_version++;
++ return gen;
++}
++
++int find_bindex(struct super_block *sb, struct aufs_branch *br)
++{
++ aufs_bindex_t bindex, bend;
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (stobr(sb, bindex) == br)
++ return bindex;
++ return -1;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* dentry and super_block lock. call at entry point */
++void aufs_read_lock(struct dentry *dentry, int flags)
++{
++ si_read_lock(dentry->d_sb);
++ if (flags & AUFS_D_WLOCK)
++ di_write_lock_child(dentry);
++ else
++ di_read_lock_child(dentry, flags);
++}
++
++void aufs_read_unlock(struct dentry *dentry, int flags)
++{
++ if (flags & AUFS_D_WLOCK)
++ di_write_unlock(dentry);
++ else
++ di_read_unlock(dentry, flags);
++ si_read_unlock(dentry->d_sb);
++}
++
++void aufs_write_lock(struct dentry *dentry)
++{
++ //au_wkq_wait_nwtask();
++ si_write_lock(dentry->d_sb);
++ di_write_lock_child(dentry);
++}
++
++void aufs_write_unlock(struct dentry *dentry)
++{
++ di_write_unlock(dentry);
++ si_write_unlock(dentry->d_sb);
++ //au_wkq_wait_nwtask();
++}
++
++void aufs_read_and_write_lock2(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ DEBUG_ON(d1 == d2 || d1->d_sb != d2->d_sb);
++ si_read_lock(d1->d_sb);
++ di_write_lock2_child(d1, d2, isdir);
++}
++
++void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2)
++{
++ DEBUG_ON(d1 == d2 || d1->d_sb != d2->d_sb);
++ di_write_unlock2(d1, d2);
++ si_read_unlock(d1->d_sb);
++}
++
++/* ---------------------------------------------------------------------- */
++
++aufs_bindex_t new_br_id(struct super_block *sb)
++{
++ aufs_bindex_t br_id;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++
++ while (1) {
++ br_id = ++stosi(sb)->si_last_br_id;
++ if (br_id && find_brindex(sb, br_id) < 0)
++ return br_id;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_SYSAUFS
++static int make_xino(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++ struct super_block *sb = args->sb;
++ aufs_bindex_t bindex, bend;
++ struct file *xf;
++ struct inode *xi;
++
++ TraceEnter();
++ DEBUG_ON(args->index != SysaufsSb_XINO);
++ SiMustReadLock(sb);
++
++ *do_size = 0;
++ err = seq_printf(seq, "%d %lu\n", sizeof(struct xino),
++ atomic_long_read(&stosi(sb)->si_xino));
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ xf = stobr(sb, bindex)->br_xino;
++ xi = xf->f_dentry->d_inode;
++ err = seq_printf(seq, "%d: %d, %Lux%d %Ld\n",
++ bindex, file_count(xf),
++ (u64)xi->i_blocks, 1 << xi->i_blkbits,
++ i_size_read(xi));
++ }
++ return err;
++}
++
++sysaufs_op au_si_ops[] = {
++ [SysaufsSb_XINO] = make_xino
++};
++#endif
+diff --git a/fs/aufs/super.c b/fs/aufs/super.c
+new file mode 100755
+index 0000000..c1123f8
+--- /dev/null
++++ b/fs/aufs/super.c
+@@ -0,0 +1,716 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: super.c,v 1.50 2007/05/14 03:39:42 sfjro Exp $ */
++
++#include <linux/module.h>
++#include <linux/seq_file.h>
++#include <linux/statfs.h>
++#include "aufs.h"
++
++/*
++ * super_operations
++ */
++static struct inode *aufs_alloc_inode(struct super_block *sb)
++{
++ struct aufs_icntnr *c;
++
++ TraceEnter();
++
++ c = cache_alloc_icntnr();
++ //if (LktrCond) {cache_free_icntnr(c); c = NULL;}
++ if (c) {
++ inode_init_once(&c->vfs_inode);
++ c->vfs_inode.i_version = 1; //sigen(sb);
++ c->iinfo.ii_hinode = NULL;
++ return &c->vfs_inode;
++ }
++ return NULL;
++}
++
++static void aufs_destroy_inode(struct inode *inode)
++{
++ LKTRTrace("i%lu\n", inode->i_ino);
++ au_iinfo_fin(inode);
++ cache_free_icntnr(container_of(inode, struct aufs_icntnr, vfs_inode));
++}
++
++//todo: how about merge with alloc_inode()?
++static void aufs_read_inode(struct inode *inode)
++{
++ int err;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++
++ err = au_iinfo_init(inode);
++ //if (LktrCond) err = -1;
++ if (!err) {
++ inode->i_version++;
++ inode->i_op = &aufs_iop;
++ inode->i_fop = &aufs_file_fop;
++ inode->i_mapping->a_ops = &aufs_aop;
++ return; /* success */
++ }
++
++ LKTRTrace("intializing inode info failed(%d)\n", err);
++ make_bad_inode(inode);
++}
++
++int au_show_brs(struct seq_file *seq, struct super_block *sb)
++{
++ int err;
++ aufs_bindex_t bindex, bend;
++ char a[16];
++ struct dentry *root;
++
++ TraceEnter();
++ SiMustAnyLock(sb);
++ root = sb->s_root;
++ DiMustAnyLock(root);
++
++ err = 0;
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ err = br_perm_str(a, sizeof(a), sbr_perm(sb, bindex));
++ if (!err)
++ err = seq_path(seq, sbr_mnt(sb, bindex),
++ au_h_dptr_i(root, bindex), au_esc_chars);
++ if (err > 0)
++ err = seq_printf(seq, "=%s", a);
++ if (!err && bindex != bend)
++ err = seq_putc(seq, ':');
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_show_options(struct seq_file *m, struct vfsmount *mnt)
++{
++ int err, n;
++ struct super_block *sb;
++ struct aufs_sbinfo *sbinfo;
++ struct dentry *root;
++ struct file *xino;
++
++ TraceEnter();
++
++ sb = mnt->mnt_sb;
++ root = sb->s_root;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (au_flag_test(sb, AuFlag_XINO)) {
++ err = seq_puts(m, ",xino=");
++ if (unlikely(err))
++ goto out;
++ xino = stobr(sb, 0)->br_xino;
++ err = seq_path(m, xino->f_vfsmnt, xino->f_dentry, au_esc_chars);
++ if (unlikely(err <= 0))
++ goto out;
++ err = 0;
++
++#define Deleted "\\040(deleted)"
++ m->count -= sizeof(Deleted) - 1;
++ DEBUG_ON(memcmp(m->buf + m->count, Deleted,
++ sizeof(Deleted) - 1));
++#undef Deleted
++ } else
++ err = seq_puts(m, ",noxino");
++
++ n = au_flag_test(sb, AuFlag_PLINK);
++ if (unlikely(!err && (AuDefFlags & AuFlag_PLINK) != n))
++ err = seq_printf(m, ",%splink", n ? "" : "no");
++ n = au_flag_test_udba(sb);
++ if (unlikely(!err && (AuDefFlags & AuMask_UDBA) != n))
++ err = seq_printf(m, ",udba=%s", udba_str(n));
++ n = au_flag_test(sb, AuFlag_ALWAYS_DIROPQ);
++ if (unlikely(!err && (AuDefFlags & AuFlag_ALWAYS_DIROPQ) != n))
++ err = seq_printf(m, ",diropq=%c", n ? 'a' : 'w');
++ n = au_flag_test(sb, AuFlag_DLGT);
++ if (unlikely(!err && (AuDefFlags & AuFlag_DLGT) != n))
++ err = seq_printf(m, ",%sdlgt", n ? "" : "no");
++ n = au_flag_test(sb, AuFlag_WARN_PERM);
++ if (unlikely(!err && (AuDefFlags & AuFlag_WARN_PERM) != n))
++ err = seq_printf(m, ",%swarn_perm", n ? "" : "no");
++
++ sbinfo = stosi(sb);
++ n = sbinfo->si_dirwh;
++ if (unlikely(!err && n != AUFS_DIRWH_DEF))
++ err = seq_printf(m, ",dirwh=%d", n);
++ n = sbinfo->si_rdcache / HZ;
++ if (unlikely(!err && n != AUFS_RDCACHE_DEF))
++ err = seq_printf(m, ",rdcache=%d", n);
++#if 0
++ n = au_flag_test_coo(sb);
++ if (unlikely(!err && (AuDefFlags & AuMask_COO) != n))
++ err = seq_printf(m, ",coo=%s", coo_str(n));
++#endif
++
++ if (!err && !sysaufs_brs) {
++#ifdef CONFIG_AUFS_COMPAT
++ err = seq_puts(m, ",dirs=");
++#else
++ err = seq_puts(m, ",br:");
++#endif
++ if (!err)
++ err = au_show_brs(m, sb);
++ }
++
++ out:
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ TraceErr(err);
++ if (err)
++ err = -E2BIG;
++ TraceErr(err);
++ return err;
++}
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#define StatfsLock(d) aufs_read_lock((d)->d_sb->s_root, 0)
++#define StatfsUnlock(d) aufs_read_unlock((d)->d_sb->s_root, 0)
++#define StatfsArg(d) au_h_dptr((d)->d_sb->s_root)
++#define StatfsHInode(d) (StatfsArg(d)->d_inode)
++#define StatfsSb(d) ((d)->d_sb)
++static int aufs_statfs(struct dentry *arg, struct kstatfs *buf)
++#else
++#define StatfsLock(s) si_read_lock(s)
++#define StatfsUnlock(s) si_read_unlock(s)
++#define StatfsArg(s) sbr_sb(s, 0)
++#define StatfsHInode(s) (StatfsArg(s)->s_root->d_inode)
++#define StatfsSb(s) (s)
++static int aufs_statfs(struct super_block *arg, struct kstatfs *buf)
++#endif
++{
++ int err;
++
++ TraceEnter();
++
++ StatfsLock(arg);
++ err = vfsub_statfs(StatfsArg(arg), buf, need_dlgt(StatfsSb(arg)));
++ //if (LktrCond) err = -1;
++ StatfsUnlock(arg);
++ if (!err) {
++ //buf->f_type = AUFS_SUPER_MAGIC;
++ buf->f_type = 0;
++ buf->f_namelen -= AUFS_WH_PFX_LEN;
++ memset(&buf->f_fsid, 0, sizeof(buf->f_fsid));
++ }
++ //buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1;
++
++ TraceErr(err);
++ return err;
++}
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) || defined(UbuntuEdgy17Umount18)
++#define UmountBeginSb(mnt) (mnt)->mnt_sb
++static void aufs_umount_begin(struct vfsmount *arg, int flags)
++#else
++#define UmountBeginSb(sb) sb
++static void aufs_umount_begin(struct super_block *arg)
++#endif
++{
++ struct super_block *sb = UmountBeginSb(arg);
++
++ if (unlikely(!stosi(sb)))
++ return;
++
++ //au_wkq_wait_nwtask();
++ si_write_lock(sb);
++ if (au_flag_test(sb, AuFlag_PLINK)) {
++ au_put_plink(sb);
++ //kobj_umount(stosi(sb));
++ }
++#if 0
++ if (unlikely(au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ shrink_dcache_sb(sb);
++#endif
++ si_write_unlock(sb);
++}
++
++static void free_sbinfo(struct aufs_sbinfo *sbinfo)
++{
++ TraceEnter();
++ DEBUG_ON(!sbinfo
++ || !list_empty(&sbinfo->si_plink));
++
++ free_branches(sbinfo);
++ kfree(sbinfo->si_branch);
++ kfree(sbinfo);
++}
++
++/* final actions when unmounting a file system */
++static void aufs_put_super(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++
++ sbinfo = stosi(sb);
++ if (unlikely(!sbinfo))
++ return;
++
++ sysaufs_del(sbinfo);
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && !defined(UbuntuEdgy17Umount18)
++ // umount_begin() may not be called.
++ aufs_umount_begin(sb);
++#endif
++ free_sbinfo(sbinfo);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * refresh directories at remount time.
++ */
++static int do_refresh_dir(struct dentry *dentry, unsigned int flags)
++{
++ int err;
++ struct dentry *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ di_write_lock_child(dentry);
++ parent = dget_parent(dentry);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ err = au_refresh_hdentry(dentry, S_IFDIR);
++ if (err >= 0) {
++ err = au_refresh_hinode(inode, dentry);
++ if (!err)
++ au_reset_hinotify(inode, flags);
++ }
++ if (unlikely(err))
++ Err("unrecoverable error %d\n", err);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ dput(parent);
++ di_write_unlock(dentry);
++
++ TraceErr(err);
++ return err;
++}
++
++static int test_dir(struct dentry *dentry, void *arg)
++{
++ return S_ISDIR(dentry->d_inode->i_mode);
++}
++
++static int refresh_dir(struct dentry *root, int sgen)
++{
++ int err, i, j, ndentry;
++ const unsigned int flags = au_hi_flags(root->d_inode, /*isdir*/1);
++ struct au_dcsub_pages dpages;
++ struct au_dpage *dpage;
++ struct dentry **dentries;
++
++ LKTRTrace("sgen %d\n", sgen);
++ SiMustWriteLock(root->d_sb);
++ DEBUG_ON(au_digen(root) != sgen);
++ DiMustWriteLock(root);
++
++ err = au_dpages_init(&dpages, GFP_KERNEL);
++ if (unlikely(err))
++ goto out;
++ err = au_dcsub_pages(&dpages, root, test_dir, NULL);
++ if (unlikely(err))
++ goto out_dpages;
++
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++ for (i = 0; !err && i < dpages.ndpage; i++) {
++ dpage = dpages.dpages + i;
++ dentries = dpage->dentries;
++ ndentry = dpage->ndentry;
++ for (j = 0; !err && j < ndentry; j++) {
++ struct dentry *d;
++ d = dentries[j];
++ DEBUG_ON(!S_ISDIR(d->d_inode->i_mode)
++ || IS_ROOT(d)
++ || au_digen(d->d_parent) != sgen);
++ if (au_digen(d) != sgen)
++ err = do_refresh_dir(d, flags);
++ }
++ }
++ di_write_lock_child(root); /* aufs_write_lock() calls ..._child() */
++
++ out_dpages:
++ au_dpages_free(&dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* stop extra interpretation of errno in mount(8), and strange error messages */
++static int cvt_err(int err)
++{
++ TraceErr(err);
++
++ switch (err) {
++ case -ENOENT:
++ case -ENOTDIR:
++ case -EEXIST:
++ case -EIO:
++ err = -EINVAL;
++ }
++ return err;
++}
++
++/* protected by s_umount */
++static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
++{
++ int err, do_refresh;
++ struct dentry *root;
++ struct inode *inode;
++ struct opts opts;
++ unsigned int given, dlgt;
++
++ //au_debug_on();
++ LKTRTrace("flags 0x%x, data %s, len %d\n",
++ *flags, data ? data : "NULL", data ? strlen(data) : 0);
++
++ err = 0;
++ if (unlikely(!data || !*data))
++ goto out; /* success */
++
++ err = -ENOMEM;
++ memset(&opts, 0, sizeof(opts));
++ opts.opt = (void*)__get_free_page(GFP_KERNEL);
++ //if (LktrCond) {free_page((unsigned long)opts.opt); opts.opt = NULL;}
++ if (unlikely(!opts.opt))
++ goto out;
++ opts.max_opt = PAGE_SIZE / sizeof(*opts.opt);
++
++ /* parse it before aufs lock */
++ err = au_parse_opts(sb, data, &opts);
++ //if (LktrCond) {au_free_opts(&opts); err = -1;}
++ if (unlikely(err))
++ goto out_opts;
++
++ root = sb->s_root;
++ inode = root->d_inode;
++ i_lock(inode);
++ aufs_write_lock(root);
++
++ //DbgSleep(3);
++
++ /* au_do_opts() may return an error */
++ do_refresh = 0;
++ given = 0;
++ err = au_do_opts_remount(sb, &opts, &do_refresh, &given);
++ //if (LktrCond) err = -1;
++ au_free_opts(&opts);
++
++ if (do_refresh) {
++ int rerr;
++ struct aufs_sbinfo *sbinfo;
++
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_DLGT);
++ au_sigen_inc(sb);
++ au_reset_hinotify(inode, au_hi_flags(inode, /*isdir*/1));
++ sbinfo = stosi(sb);
++ sbinfo->si_failed_refresh_dirs = 0;
++ rerr = refresh_dir(root, au_sigen(sb));
++ if (unlikely(rerr)) {
++ sbinfo->si_failed_refresh_dirs = 1;
++ Warn("Refreshing directories failed, ignores (%d)\n",
++ rerr);
++ }
++ au_cpup_attr_all(inode);
++ au_flag_set(sb, dlgt);
++ }
++
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ /* braces are added to stop a warning */
++ if (do_refresh) {
++ sysaufs_notify_remount();
++ }
++
++ out_opts:
++ free_page((unsigned long)opts.opt);
++ out:
++ err = cvt_err(err);
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++static struct super_operations aufs_sop = {
++ .alloc_inode = aufs_alloc_inode,
++ .destroy_inode = aufs_destroy_inode,
++ .read_inode = aufs_read_inode,
++ //.dirty_inode = aufs_dirty_inode,
++ //.write_inode = aufs_write_inode,
++ //void (*put_inode) (struct inode *);
++ .drop_inode = generic_delete_inode,
++ //.delete_inode = aufs_delete_inode,
++ //.clear_inode = aufs_clear_inode,
++
++ .show_options = aufs_show_options,
++ .statfs = aufs_statfs,
++
++ .put_super = aufs_put_super,
++ //void (*write_super) (struct super_block *);
++ //int (*sync_fs)(struct super_block *sb, int wait);
++ //void (*write_super_lockfs) (struct super_block *);
++ //void (*unlockfs) (struct super_block *);
++ .remount_fs = aufs_remount_fs,
++ // depends upon umount flags. also use put_super() (< 2.6.18)
++ .umount_begin = aufs_umount_begin
++};
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * at first mount time.
++ */
++
++static int alloc_sbinfo(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++
++ sbinfo = kmalloc(sizeof(*sbinfo), GFP_KERNEL);
++ //if (LktrCond) {kfree(sbinfo); sbinfo = NULL;}
++ if (unlikely(!sbinfo))
++ goto out;
++ sbinfo->si_branch = kzalloc(sizeof(*sbinfo->si_branch), GFP_KERNEL);
++ //if (LktrCond) {kfree(sbinfo->si_branch); sbinfo->si_branch = NULL;}
++ if (unlikely(!sbinfo->si_branch)) {
++ kfree(sbinfo);
++ goto out;
++ }
++ rw_init_wlock(&sbinfo->si_rwsem);
++ sbinfo->si_bend = -1;
++ atomic_long_set(&sbinfo->si_xino, AUFS_FIRST_INO);
++ spin_lock_init(&sbinfo->si_plink_lock);
++ INIT_LIST_HEAD(&sbinfo->si_plink);
++ init_lvma(sbinfo);
++ sbinfo->si_generation = 0;
++ sbinfo->si_last_br_id = 0;
++ sbinfo->si_failed_refresh_dirs = 0;
++ sbinfo->si_flags = 0;
++ sbinfo->si_dirwh = AUFS_DIRWH_DEF;
++ sbinfo->si_rdcache = AUFS_RDCACHE_DEF * HZ;
++ //atomic_set(&sbinfo->si_hinotify, 0);
++ //init_waitqueue_head(&sbinfo->si_hinotify_wq);
++
++ sb->s_fs_info = sbinfo;
++ au_flag_set(sb, AuDefFlags);
++#ifdef ForceInotify
++ udba_set(sb, AuFlag_UDBA_INOTIFY);
++#endif
++#ifdef ForceDlgt
++ au_flag_set(sb, AuFlag_DLGT);
++#endif
++#ifdef ForceNoPlink
++ au_flag_clr(sb, AuFlag_PLINK);
++#endif
++ return 0; /* success */
++
++ out:
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
++
++static int alloc_root(struct super_block *sb)
++{
++ int err;
++ struct inode *inode;
++ struct dentry *root;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ inode = iget(sb, AUFS_ROOT_INO);
++ //if (LktrCond) {iput(inode); inode = NULL;}
++ if (unlikely(!inode))
++ goto out;
++ err = PTR_ERR(inode);
++ if (IS_ERR(inode))
++ goto out;
++ err = -ENOMEM;
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ root = d_alloc_root(inode);
++ //if (LktrCond) {igrab(inode); dput(root); root = NULL;}
++ if (unlikely(!root))
++ goto out_iput;
++ err = PTR_ERR(root);
++ if (IS_ERR(root))
++ goto out_iput;
++
++ err = au_alloc_dinfo(root);
++ //if (LktrCond){rw_write_unlock(&dtodi(root)->di_rwsem);err=-1;}
++ if (!err) {
++ sb->s_root = root;
++ return 0; /* success */
++ }
++ dput(root);
++ goto out; /* do not iput */
++
++ out_iput:
++ iput(inode);
++ out:
++ TraceErr(err);
++ return err;
++
++}
++
++static int aufs_fill_super(struct super_block *sb, void *raw_data, int silent)
++{
++ int err;
++ struct dentry *root;
++ struct inode *inode;
++ struct opts opts;
++ char *arg = raw_data;
++
++ //au_debug_on();
++ if (unlikely(!arg || !*arg)) {
++ err = -EINVAL;
++ Err("no arg\n");
++ goto out;
++ }
++ LKTRTrace("%s, silent %d\n", arg, silent);
++
++ err = -ENOMEM;
++ memset(&opts, 0, sizeof(opts));
++ opts.opt = (void*)__get_free_page(GFP_KERNEL);
++ //if (LktrCond) {free_page((unsigned long)opts.opt); opts.opt = NULL;}
++ if (unlikely(!opts.opt))
++ goto out;
++ opts.max_opt = PAGE_SIZE / sizeof(*opts.opt);
++
++ err = alloc_sbinfo(sb);
++ //if (LktrCond) {si_write_unlock(sb);free_sbinfo(stosi(sb));err=-1;}
++ if (unlikely(err))
++ goto out_opts;
++ SiMustWriteLock(sb);
++ /* all timestamps always follow the ones on the branch */
++ sb->s_flags |= MS_NOATIME | MS_NODIRATIME;
++ sb->s_op = &aufs_sop;
++ au_init_export_op(sb);
++ //err = kobj_mount(stosi(sb));
++ //if (err)
++ //goto out_info;
++
++ err = alloc_root(sb);
++ //if (LktrCond) {rw_write_unlock(&dtodi(sb->s_root)->di_rwsem);
++ //dput(sb->s_root);sb->s_root=NULL;err=-1;}
++ if (unlikely(err)) {
++ DEBUG_ON(sb->s_root);
++ si_write_unlock(sb);
++ goto out_info;
++ }
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ inode->i_nlink = 2;
++
++ /*
++ * actually we can parse options regardless aufs lock here.
++ * but at remount time, parsing must be done before aufs lock.
++ * so we follow the same rule.
++ */
++ ii_write_lock_parent(inode);
++ aufs_write_unlock(root);
++ err = au_parse_opts(sb, arg, &opts);
++ //if (LktrCond) {au_free_opts(&opts); err = -1;}
++ if (unlikely(err))
++ goto out_root;
++
++ /* lock vfs_inode first, then aufs. */
++ i_lock(inode);
++ inode->i_op = &aufs_dir_iop;
++ inode->i_fop = &aufs_dir_fop;
++ aufs_write_lock(root);
++
++ sb->s_maxbytes = 0;
++ err = au_do_opts_mount(sb, &opts);
++ //if (LktrCond) err = -1;
++ au_free_opts(&opts);
++ if (unlikely(err))
++ goto out_unlock;
++ DEBUG_ON(!sb->s_maxbytes);
++
++ //DbgDentry(root);
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ //DbgSb(sb);
++ goto out_opts; /* success */
++
++ out_unlock:
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ out_root:
++ dput(root);
++ sb->s_root = NULL;
++ out_info:
++ free_sbinfo(stosi(sb));
++ sb->s_fs_info = NULL;
++ out_opts:
++ free_page((unsigned long)opts.opt);
++ out:
++ TraceErr(err);
++ err = cvt_err(err);
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++static int aufs_get_sb(struct file_system_type *fs_type, int flags,
++ const char *dev_name, void *raw_data,
++ struct vfsmount *mnt)
++{
++ int err;
++
++ /* all timestamps always follow the ones on the branch */
++ //mnt->mnt_flags |= MNT_NOATIME | MNT_NODIRATIME;
++ err = get_sb_nodev(fs_type, flags, raw_data, aufs_fill_super, mnt);
++ if (!err) {
++ struct aufs_sbinfo *sbinfo = stosi(mnt->mnt_sb);
++ sbinfo->si_mnt = mnt;
++ sysaufs_add(sbinfo);
++ }
++ return err;
++}
++#else
++static struct super_block *aufs_get_sb(struct file_system_type *fs_type,
++ int flags, const char *dev_name,
++ void *raw_data)
++{
++ return get_sb_nodev(fs_type, flags, raw_data, aufs_fill_super);
++}
++#endif
++
++struct file_system_type aufs_fs_type = {
++ .name = AUFS_FSTYPE,
++ .fs_flags = FS_REVAL_DOT, // for UDBA and NFS branch
++ .get_sb = aufs_get_sb,
++ .kill_sb = generic_shutdown_super,
++ //no need to __module_get() and module_put().
++ .owner = THIS_MODULE,
++};
+diff --git a/fs/aufs/super.h b/fs/aufs/super.h
+new file mode 100755
+index 0000000..56ddee1
+--- /dev/null
++++ b/fs/aufs/super.h
+@@ -0,0 +1,339 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: super.h,v 1.44 2007/05/14 03:39:54 sfjro Exp $ */
++
++#ifndef __AUFS_SUPER_H__
++#define __AUFS_SUPER_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "sysaufs.h"
++
++#ifdef CONFIG_AUFS_SYSAUFS
++/* entries under sysfs per mount-point */
++enum {SysaufsSb_XINO, /* SysaufsSb_PLINK, */ SysaufsSb_Last};
++struct sysaufs_sbinfo {
++ au_subsys_t subsys;
++ struct sysaufs_entry array[SysaufsSb_Last];
++};
++extern sysaufs_op au_si_ops[];
++#else
++struct sysaufs_sbinfo {};
++#endif
++
++struct aufs_sbinfo {
++ struct aufs_rwsem si_rwsem;
++
++ /* branch management */
++ /* wrap around attack by superuser? No. */
++ int si_generation;
++
++ /*
++ * set true when refresh_dirs() at remount time failed.
++ * then try refreshing dirs at access time again.
++ * if it is false, refreshing dirs at access time is unnecesary
++ */
++ unsigned int si_failed_refresh_dirs:1;
++
++ aufs_bindex_t si_bend;
++ aufs_bindex_t si_last_br_id;
++ struct aufs_branch **si_branch;
++
++ /* mount flags */
++ unsigned int si_flags;
++
++ /* external inode number table */
++ atomic_long_t si_xino; // time bomb
++ //struct file *si_xino_bmap;
++
++ /* readdir cache time, max, in HZ */
++ unsigned long si_rdcache;
++
++ /*
++ * If the number of whiteouts are larger than si_dirwh, leave all of
++ * them after rename_whtmp to reduce the cost of rmdir(2).
++ * future fsck.aufs or kernel thread will remove them later.
++ * Otherwise, remove all whiteouts and the dir in rmdir(2).
++ */
++ unsigned int si_dirwh;
++
++ /* pseudo_link list */ // dirty
++ spinlock_t si_plink_lock;
++ struct list_head si_plink;
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++ /* super_blocks list is not exported */
++ struct list_head si_list;
++ struct vfsmount *si_mnt; /* no get/put */
++#endif
++
++ /* sysfs */
++ struct sysaufs_sbinfo si_sysaufs;
++
++#ifdef CONFIG_AUFS_HINOTIFY
++ /* hinotify */
++ //atomic_t si_hinotify;
++ //wait_queue_head_t si_hinotify_wq;
++#endif
++
++#ifdef CONFIG_AUFS_ROBR
++ /* locked vma list for mmap() */ // very dirty
++ spinlock_t si_lvma_lock;
++ struct list_head si_lvma;
++#endif
++};
++
++/* an entry in a xino file */
++struct xino {
++ ino_t ino;
++ //__u32 h_gen;
++} __attribute__ ((packed));
++
++//#define AuXino_INVALID_HGEN (-1)
++
++/* ---------------------------------------------------------------------- */
++
++/* Mount flags */
++#define AuFlag_XINO 1
++#define AuFlag_ZXINO (1 << 1)
++#define AuFlag_PLINK (1 << 2)
++#define AuFlag_UDBA_NONE (1 << 3)
++#define AuFlag_UDBA_REVAL (1 << 4)
++#define AuFlag_UDBA_INOTIFY (1 << 5)
++#define AuFlag_WARN_PERM (1 << 6)
++#define AuFlag_COO_NONE (1 << 7)
++#define AuFlag_COO_LEAF (1 << 8)
++#define AuFlag_COO_ALL (1 << 9)
++#define AuFlag_ALWAYS_DIROPQ (1 << 10)
++#define AuFlag_DLGT (1 << 11)
++
++#define AuMask_UDBA (AuFlag_UDBA_NONE | AuFlag_UDBA_REVAL \
++ | AuFlag_UDBA_INOTIFY)
++#define AuMask_COO (AuFlag_COO_NONE | AuFlag_COO_LEAF \
++ | AuFlag_COO_ALL)
++
++#ifdef CONFIG_AUFS_COMPAT
++#define AuDefFlag_DIROPQ AuFlag_ALWAYS_DIROPQ
++#else
++#define AuDefFlag_DIROPQ 0
++#endif
++
++#define AuDefFlags_COMM (AuFlag_XINO | AuFlag_UDBA_REVAL | AuFlag_WARN_PERM \
++ | AuFlag_COO_NONE | AuDefFlag_DIROPQ)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
++#define AuDefFlags (AuDefFlags_COMM | AuFlag_PLINK)
++#else
++#define AuDefFlags AuDefFlags_COMM
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* flags for aufs_read_lock()/di_read_lock() */
++#define AUFS_D_WLOCK 1
++#define AUFS_I_RLOCK 2
++#define AUFS_I_WLOCK 4
++
++/* ---------------------------------------------------------------------- */
++
++/* super.c */
++int au_show_brs(struct seq_file *seq, struct super_block *sb);
++
++/* xino.c */
++struct file *xino_create(struct super_block *sb, char *fname, int silent,
++ struct dentry *parent);
++ino_t xino_new_ino(struct super_block *sb);
++int xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino);
++int xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino);
++int xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino);
++int xino_init(struct super_block *sb, aufs_bindex_t bindex,
++ struct file *base_file, int do_test);
++struct opt_xino;
++int xino_set(struct super_block *sb, struct opt_xino *xino, int remount);
++int xino_clr(struct super_block *sb);
++struct file *xino_def(struct super_block *sb);
++
++/* sbinfo.c */
++struct aufs_sbinfo *stosi(struct super_block *sb);
++aufs_bindex_t sbend(struct super_block *sb);
++struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex);
++int au_sigen(struct super_block *sb);
++int au_sigen_inc(struct super_block *sb);
++int find_bindex(struct super_block *sb, struct aufs_branch *br);
++
++void aufs_read_lock(struct dentry *dentry, int flags);
++void aufs_read_unlock(struct dentry *dentry, int flags);
++void aufs_write_lock(struct dentry *dentry);
++void aufs_write_unlock(struct dentry *dentry);
++void aufs_read_and_write_lock2(struct dentry *d1, struct dentry *d2, int isdir);
++void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2);
++
++aufs_bindex_t new_br_id(struct super_block *sb);
++
++/* ---------------------------------------------------------------------- */
++
++static inline const char *au_sbtype(struct super_block *sb)
++{
++ return sb->s_type->name;
++}
++
++static inline int au_is_aufs(struct super_block *sb)
++{
++ return !strcmp(au_sbtype(sb), AUFS_FSTYPE);
++}
++
++static inline int au_is_nfs(struct super_block *sb)
++{
++#if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
++ return !strcmp(au_sbtype(sb), "nfs");
++#else
++ return 0;
++#endif
++}
++
++static inline int au_is_remote(struct super_block *sb)
++{
++ return au_is_nfs(sb);
++}
++
++#ifdef CONFIG_AUFS_EXPORT
++static inline void au_init_export_op(struct super_block *sb)
++{
++ extern struct export_operations aufs_export_op;
++ sb->s_export_op = &aufs_export_op;
++}
++
++static inline int au_is_nfsd(struct task_struct *tsk)
++{
++ return (!tsk->mm && !strcmp(tsk->comm, "nfsd"));
++}
++
++static inline void au_nfsd_lockdep_off(void)
++{
++ /* braces are added to stop a warning */
++ if (au_is_nfsd(current)) {
++ lockdep_off();
++ }
++}
++
++static inline void au_nfsd_lockdep_on(void)
++{
++ /* braces are added to stop a warning */
++ if (au_is_nfsd(current)) {
++ lockdep_on();
++ }
++}
++#else
++static inline int au_is_nfsd(struct task_struct *tsk)
++{
++ return 0;
++}
++static inline void au_init_export_op(struct super_block *sb)
++{
++ /* nothing */
++}
++#define au_nfsd_lockdep_off() /* */
++#define au_nfsd_lockdep_on() /* */
++#endif /* CONFIG_AUFS_EXPORT */
++
++static inline void init_lvma(struct aufs_sbinfo *sbinfo)
++{
++#ifdef CONFIG_AUFS_ROBR
++ spin_lock_init(&sbinfo->si_lvma_lock);
++ INIT_LIST_HEAD(&sbinfo->si_lvma);
++#else
++ /* nothing */
++#endif
++}
++
++/* limited support before 2.6.18 */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++static inline void au_mntget(struct super_block *sb)
++{
++ mntget(stosi(sb)->si_mnt);
++}
++
++static inline void au_mntput(struct super_block *sb)
++{
++ mntput(stosi(sb)->si_mnt);
++}
++#else
++static inline void au_mntget(struct super_block *sb)
++{
++ /* empty */
++}
++
++static inline void au_mntput(struct super_block *sb)
++{
++ /* empty */
++}
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++static inline void au_flag_set(struct super_block *sb, unsigned int flag)
++{
++ //SiMustWriteLock(sb);
++ stosi(sb)->si_flags |= flag;
++}
++
++static inline void au_flag_clr(struct super_block *sb, unsigned int flag)
++{
++ //SiMustWriteLock(sb);
++ stosi(sb)->si_flags &= ~flag;
++}
++
++static inline
++unsigned int au_flag_test(struct super_block *sb, unsigned int flag)
++{
++ //SiMustAnyLock(sb);
++ return stosi(sb)->si_flags & flag;
++}
++
++static inline unsigned int au_flag_test_udba(struct super_block *sb)
++{
++ return au_flag_test(sb, AuMask_UDBA);
++}
++
++static inline unsigned int au_flag_test_coo(struct super_block *sb)
++{
++ return au_flag_test(sb, AuMask_COO);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* lock superblock. mainly for entry point functions */
++/*
++ * si_read_lock, si_write_lock,
++ * si_read_unlock, si_write_unlock, si_downgrade_lock
++ */
++SimpleRwsemFuncs(si, struct super_block *sb, stosi(sb)->si_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define SiMustReadLock(sb) RwMustReadLock(&stosi(sb)->si_rwsem)
++#define SiMustWriteLock(sb) RwMustWriteLock(&stosi(sb)->si_rwsem)
++#define SiMustAnyLock(sb) RwMustAnyLock(&stosi(sb)->si_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_SUPER_H__ */
+diff --git a/fs/aufs/sysaufs.c b/fs/aufs/sysaufs.c
+new file mode 100755
+index 0000000..d686862
+--- /dev/null
++++ b/fs/aufs/sysaufs.c
+@@ -0,0 +1,620 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sysaufs.c,v 1.6 2007/05/14 03:40:10 sfjro Exp $ */
++
++#include <linux/module.h>
++#include <linux/seq_file.h>
++#include <linux/sysfs.h>
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++/* super_blocks list is not exported */
++static DEFINE_MUTEX(aufs_sbilist_mtx);
++static LIST_HEAD(aufs_sbilist);
++
++/* ---------------------------------------------------------------------- */
++
++typedef ssize_t (*rwfunc_t)(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args);
++static ssize_t sysaufs_read(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args);
++static ssize_t sysaufs_free_write(struct kobject *kobj, char *buf, loff_t
++ offset, size_t sz, struct sysaufs_args *args);
++
++#define GFunc(name, _index, func) \
++static ssize_t name(struct kobject *kobj, char *buf, loff_t offset, size_t sz) \
++{ \
++ struct sysaufs_args args = { \
++ .index = (_index), \
++ .mtx = &aufs_sbilist_mtx, \
++ .sb = NULL \
++ }; \
++ return func(kobj, buf, offset, sz, &args); \
++}
++
++#define GFuncs(name, _index) \
++ GFunc(read_##name, _index, sysaufs_read); \
++ GFunc(write_##name, _index, sysaufs_free_write);
++
++static struct super_block *find_sb_locked(struct kobject *kobj)
++{
++ struct super_block *sb;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ sb = NULL;
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ if (&au_subsys_to_kset(sbinfo->si_sysaufs.subsys).kobj != kobj)
++ continue;
++ sb = sbinfo->si_mnt->mnt_sb;
++ si_read_lock(sb);
++ break;
++ }
++ return sb;
++}
++
++static ssize_t sb_func(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args, rwfunc_t func)
++{
++ ssize_t err;
++
++ err = -ENOENT;
++ mutex_lock(&aufs_sbilist_mtx);
++ args->sb = find_sb_locked(kobj);
++ if (args->sb) {
++ err = func(kobj, buf, offset, sz, args);
++ si_read_unlock(args->sb);
++ }
++ mutex_unlock(&aufs_sbilist_mtx);
++ return err;
++}
++
++#define SbFunc(name, _index, func) \
++static ssize_t name(struct kobject *kobj, char *buf, loff_t offset, size_t sz) \
++{ \
++ struct sysaufs_args args = { \
++ .index = (_index), \
++ .mtx = NULL \
++ }; \
++ return sb_func(kobj, buf, offset, sz, &args, func); \
++}
++
++#define SbFuncs(name, index) \
++ SbFunc(read_##name, index, sysaufs_read); \
++ SbFunc(write_##name, index, sysaufs_free_write)
++
++static decl_subsys(aufs, NULL, NULL);
++enum {Brs, Stat, Config, _Last};
++static struct sysaufs_entry g_array[_Last];
++GFuncs(brs, Brs);
++GFuncs(stat, Stat);
++GFuncs(config, Config);
++
++SbFuncs(xino, SysaufsSb_XINO);
++
++#define SetEntry(e, _name, init_size, _ops) \
++ do { \
++ (e)->attr.attr.name = #_name; \
++ (e)->attr.attr.owner = THIS_MODULE; \
++ (e)->attr.attr.mode = S_IRUGO | S_IWUSR; \
++ (e)->attr.read = read_##_name; \
++ (e)->attr.write = write_##_name; \
++ (e)->allocated = init_size; \
++ (e)->err = -1; \
++ (e)->ops = _ops; \
++ } while (0)
++
++#define Priv(e) (e)->attr.private
++#define Allocated(e) (e)->allocated
++#define Len(e) (e)->attr.size
++#define Name(e) attr_name((e)->attr)
++
++/* ---------------------------------------------------------------------- */
++
++static void free_entry(struct sysaufs_entry *e)
++{
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(!Priv(e));
++
++ if (Allocated(e) > 0)
++ kfree(Priv(e));
++ else
++ free_pages((unsigned long)Priv(e), -Allocated(e));
++ Priv(e) = NULL;
++ Len(e) = 0;
++}
++
++static void free_entries(void)
++{
++ static int a[] = {Brs, -1};
++ int *p = a;
++
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ while (*p >= 0) {
++ if (Priv(g_array + *p))
++ free_entry(g_array + *p);
++ p++;
++ }
++}
++
++static int alloc_entry(struct sysaufs_entry *e)
++{
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(Priv(e));
++ //Dbg("%d\n", Allocated(e));
++
++ if (Allocated(e) > 0)
++ Priv(e) = kmalloc(Allocated(e), GFP_KERNEL);
++ else
++ Priv(e) = (void*)__get_free_pages(GFP_KERNEL, -Allocated(e));
++ if (Priv(e))
++ return 0;
++ return -ENOMEM;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void unreg(au_subsys_t *subsys, struct sysaufs_entry *a, int n,
++ au_subsys_t *parent)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < n; i++, a++)
++ if (!a->err) {
++ sysfs_remove_bin_file
++ (&au_subsys_to_kset(*subsys).kobj, &a->attr);
++ if (Priv(a))
++ free_entry(a);
++ }
++
++ subsystem_unregister(subsys);
++ subsys_put(parent);
++}
++
++static int reg(au_subsys_t *subsys, struct sysaufs_entry *a, int n,
++ au_subsys_t *parent)
++{
++ int err, i;
++
++ TraceEnter();
++
++ subsys_get(parent);
++ kobj_set_kset_s(&au_subsys_to_kset(*subsys), *parent);
++ err = subsystem_register(subsys);
++ if (unlikely(err))
++ goto out;
++
++ for (i = 0; !err && i < n; i++)
++ err = a[i].err = sysfs_create_bin_file
++ (&au_subsys_to_kset(*subsys).kobj, &a[i].attr);
++ if (unlikely(err))
++ unreg(subsys, a, n, parent);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#define SbSetEntry(index, name, init_size) \
++ SetEntry(sa->array + index, name, init_size, au_si_ops);
++
++void sysaufs_add(struct aufs_sbinfo *sbinfo)
++{
++ int err;
++ struct sysaufs_sbinfo *sa = &sbinfo->si_sysaufs;
++
++ TraceEnter();
++
++ mutex_lock(&aufs_sbilist_mtx);
++ list_add_tail(&sbinfo->si_list, &aufs_sbilist);
++ free_entries();
++
++ memset(sa, 0, sizeof(*sa));
++ SbSetEntry(SysaufsSb_XINO, xino, 128);
++ err = kobject_set_name(&au_subsys_to_kset(sa->subsys).kobj, "%p",
++ sbinfo->si_mnt->mnt_sb);
++ if (!err)
++ err = reg(&sa->subsys, sa->array, ARRAY_SIZE(sa->array),
++ &aufs_subsys);
++ if (unlikely(err))
++ Warn("failed adding sysfs (%d)\n", err);
++
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++void sysaufs_del(struct aufs_sbinfo *sbinfo)
++{
++ struct sysaufs_sbinfo *sa = &sbinfo->si_sysaufs;
++
++ TraceEnter();
++
++ mutex_lock(&aufs_sbilist_mtx);
++ unreg(&sa->subsys, sa->array, ARRAY_SIZE(sa->array), &aufs_subsys);
++ list_del(&sbinfo->si_list);
++ free_entries();
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++void sysaufs_notify_remount(void)
++{
++ mutex_lock(&aufs_sbilist_mtx);
++ free_entries();
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int make_brs(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(args->index != Brs);
++
++ err = 0;
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ struct super_block *sb;
++ struct dentry *root;
++ struct vfsmount *mnt;
++
++ sb = sbinfo->si_mnt->mnt_sb;
++ root = sb->s_root;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ mnt = sbinfo->si_mnt;
++ err = seq_escape
++ (seq, mnt->mnt_devname ? mnt->mnt_devname : "none",
++ au_esc_chars);
++ if (!err)
++ err = seq_putc(seq, ' ');
++ if (!err)
++ err = seq_path(seq, mnt, root, au_esc_chars);
++ if (err > 0)
++ err = seq_printf(seq, " %p br:", sb);
++ if (!err)
++ err = au_show_brs(seq, sb);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ if (!err)
++ err = seq_putc(seq, '\n');
++ else
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int make_config(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++
++ TraceEnter();
++ DEBUG_ON(args->index != Config);
++
++#ifdef CONFIG_AUFS
++ err = seq_puts(seq, "CONFIG_AUFS=y\n");
++#else
++ err = seq_puts(seq, "CONFIG_AUFS=m\n");
++#endif
++
++#define puts(m, v) \
++ if (!err) err = seq_puts(seq, "CONFIG_AUFS_" #m "=" #v "\n")
++#define puts_bool(m) puts(m, y)
++#define puts_mod(m) puts(m, m)
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ puts_bool(FAKE_DM);
++#endif
++#ifdef CONFIG_AUFS_BRANCH_MAX_127
++ puts_bool(BRANCH_MAX_127);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_511)
++ puts_bool(BRANCH_MAX_511);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
++ puts_bool(BRANCH_MAX_1023);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
++ puts_bool(BRANCH_MAX_32767);
++#endif
++ puts_bool(SYSAUFS);
++#ifdef CONFIG_AUFS_HINOTIFY
++ puts_bool(HINOTIFY);
++#endif
++#ifdef CONFIG_AUFS_EXPORT
++ puts_bool(EXPORT);
++#endif
++#ifdef CONFIG_AUFS_ROBR
++ puts_bool(ROBR);
++#endif
++#ifdef CONFIG_AUFS_DLGT
++ puts_bool(DLGT);
++#endif
++#ifdef CONFIG_AUFS_LHASH_PATCH
++ puts_bool(LHASH_PATCH);
++#endif
++#ifdef CONFIG_AUFS_KSIZE_PATCH
++ puts_bool(KSIZE_PATCH);
++#endif
++#ifdef CONFIG_AUFS_DEBUG
++ puts_bool(DEBUG);
++#endif
++#ifdef CONFIG_AUFS_COMPAT
++ puts_bool(COMPAT);
++#endif
++
++#undef puts_bool
++#undef puts
++
++ TraceErr(err);
++ return err;
++}
++
++static int make_stat(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err, i;
++
++ TraceEnter();
++ DEBUG_ON(args->index != Stat);
++
++ *do_size = 0;
++ err = seq_puts(seq, "wkq max_busy:");
++ for (i = 0; !err && i < aufs_nwkq; i++)
++ err = seq_printf(seq, " %u", au_wkq[i].max_busy);
++ if (!err)
++ err = seq_printf(seq, ", %u(generic)\n",
++ au_wkq[aufs_nwkq].max_busy);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int make(struct sysaufs_entry *e, struct sysaufs_args *args,
++ int *do_size)
++
++{
++ int err;
++ struct seq_file *seq;
++
++ TraceEnter();
++ DEBUG_ON(Priv(e));
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ err = -ENOMEM;
++ seq = kzalloc(sizeof(*seq), GFP_KERNEL);
++ if (unlikely(!seq))
++ goto out;
++
++ Len(e) = 0;
++ while (1) {
++ err = alloc_entry(e);
++ if (unlikely(err))
++ break;
++
++ //mutex_init(&seq.lock);
++ seq->buf = Priv(e);
++ seq->count = 0;
++ seq->size = Allocated(e);
++ if (unlikely(Allocated(e) <= 0))
++ seq->size = PAGE_SIZE << -Allocated(e);
++
++ err = e->ops[args->index](seq, args, do_size);
++ if (!err) {
++ Len(e) = seq->count;
++ break; /* success */
++ }
++
++ free_entry(e);
++ if (Allocated(e) > 0) {
++ Allocated(e) <<= 1;
++ if (unlikely(Allocated(e) >= (int)PAGE_SIZE))
++ Allocated(e) = 0;
++ } else
++ Allocated(e)--;
++ //Dbg("%d\n", Allocated(e));
++ }
++ kfree(seq);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* why does sysfs pass my parent kobject? */
++static struct dentry *find_me(struct dentry *parent, struct sysaufs_entry *e)
++{
++#if 1
++ struct dentry *dentry;
++ const char *name = Name(e);
++ const unsigned int len = strlen(name);
++
++ //Dbg("%.*s\n", DLNPair(parent));
++ spin_lock(&dcache_lock);
++ list_for_each_entry(dentry, &parent->d_subdirs, D_CHILD) {
++ //Dbg("%.*s\n", DLNPair(dentry));
++ if (len == dentry->d_name.len
++ && !strcmp(dentry->d_name.name, name)) {
++ spin_unlock(&dcache_lock);
++ return dentry;
++ }
++ }
++ spin_unlock(&dcache_lock);
++#endif
++ return NULL;
++}
++
++static ssize_t sysaufs_read(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args)
++{
++ ssize_t err;
++ loff_t len;
++ struct dentry *d;
++ struct sysaufs_entry *e;
++ int do_size;
++
++ LKTRTrace("{%d, %p}, offset %Ld, sz %lu\n",
++ args->index, args->sb, offset, (unsigned long)sz);
++
++ if (unlikely(!sz))
++ return 0;
++
++ err = 0;
++ d = NULL;
++ e = g_array + args->index;
++ if (args->sb)
++ e = stosi(args->sb)->si_sysaufs.array + args->index;
++
++ do_size = 1;
++ if (args->mtx)
++ mutex_lock(args->mtx);
++ if (unlikely(!Priv(e))) {
++ err = make(e, args, &do_size);
++ DEBUG_ON(Len(e) > INT_MAX);
++ if (do_size) {
++ d = find_me(kobj->dentry, e);
++ if (d)
++ i_size_write(d->d_inode, Len(e));
++ }
++ }
++
++ if (!err) {
++ err = len = Len(e) - offset;
++ LKTRTrace("%Ld\n", len);
++ if (len > 0) {
++ if (len > sz)
++ err = sz;
++ memcpy(buf, Priv(e) + offset, err);
++ }
++
++ if (!do_size)
++ free_entry(e);
++ }
++ if (args->mtx)
++ mutex_unlock(args->mtx);
++
++ TraceErr(err);
++ return err;
++}
++
++static ssize_t sysaufs_free_write(struct kobject *kobj, char *buf,
++ loff_t offset, size_t sz,
++ struct sysaufs_args *args)
++{
++ struct dentry *d;
++ int allocated, len;
++ struct sysaufs_entry *e;
++
++ LKTRTrace("{%d, %p}\n", args->index, args->sb);
++
++ e = g_array + args->index;
++ if (args->sb)
++ e = stosi(args->sb)->si_sysaufs.array + args->index;
++
++ if (args->mtx)
++ mutex_lock(args->mtx);
++ if (Priv(e)) {
++ allocated = Allocated(e);
++ if (unlikely(allocated <= 0))
++ allocated = PAGE_SIZE << -allocated;
++ allocated >>= 1;
++ len = Len(e);
++
++ free_entry(e);
++ if (unlikely(len <= allocated)) {
++ if (Allocated(e) >= 0)
++ Allocated(e) = allocated;
++ else
++ Allocated(e)++;
++ }
++
++ d = find_me(kobj->dentry, e);
++ if (d && i_size_read(d->d_inode))
++ i_size_write(d->d_inode, 0);
++ }
++ if (args->mtx)
++ mutex_unlock(args->mtx);
++
++ return sz;
++}
++
++static sysaufs_op g_ops[] = {
++ [Brs] = make_brs,
++ [Stat] = make_stat,
++ [Config] = make_config
++};
++
++/* ---------------------------------------------------------------------- */
++
++#define GSetEntry(index, name, init_size) \
++ SetEntry(g_array + index, name, init_size, g_ops)
++
++int __init sysaufs_init(void)
++{
++ int err;
++
++ GSetEntry(Brs, brs, 128);
++ GSetEntry(Stat, stat, 32);
++ GSetEntry(Config, config, 256);
++ err = reg(&aufs_subsys, g_array, ARRAY_SIZE(g_array), &fs_subsys);
++ TraceErr(err);
++ return err;
++}
++
++void __exit sysaufs_fin(void)
++{
++ mutex_lock(&aufs_sbilist_mtx);
++ unreg(&aufs_subsys, g_array, ARRAY_SIZE(g_array), &fs_subsys);
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef DbgDlgt
++int is_branch(struct super_block *h_sb)
++{
++ int found = 0;
++ struct aufs_sbinfo *sbinfo;
++
++ //Dbg("here\n");
++ mutex_lock(&aufs_sbilist_mtx);
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ aufs_bindex_t bindex, bend;
++ struct super_block *sb;
++
++ sb = sbinfo->si_mnt->mnt_sb;
++ si_read_lock(sb);
++ bend = sbend(sb);
++ for (bindex = 0; !found && bindex <= bend; bindex++)
++ found = (h_sb == sbr_sb(sb, bindex));
++ si_read_unlock(sb);
++ }
++ mutex_unlock(&aufs_sbilist_mtx);
++ return found;
++}
++#endif
+diff --git a/fs/aufs/sysaufs.h b/fs/aufs/sysaufs.h
+new file mode 100755
+index 0000000..cf0247f
+--- /dev/null
++++ b/fs/aufs/sysaufs.h
+@@ -0,0 +1,83 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sysaufs.h,v 1.3 2007/05/14 06:27:18 sfjro Exp $ */
++
++#ifndef __SYSAUFS_H__
++#define __SYSAUFS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/seq_file.h>
++#include <linux/sysfs.h>
++#include <linux/version.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
++typedef struct kset au_subsys_t;
++#define au_subsys_to_kset(subsys) (subsys)
++#else
++typedef struct subsystem au_subsys_t;
++#define au_subsys_to_kset(subsys) ((subsys).kset)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* arguments for an entry under sysfs */
++struct sysaufs_args {
++ int index;
++ struct mutex *mtx;
++ struct super_block *sb;
++};
++
++typedef int (*sysaufs_op)(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size);
++
++/* an entry under sysfs */
++struct sysaufs_entry {
++ struct bin_attribute attr;
++ int allocated; /* zero minus means pages */
++ int err;
++ sysaufs_op *ops;
++};
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_sbinfo;
++#ifdef CONFIG_AUFS_SYSAUFS
++void sysaufs_add(struct aufs_sbinfo *sbinfo);
++void sysaufs_del(struct aufs_sbinfo *sbinfo);
++int __init sysaufs_init(void);
++void sysaufs_fin(void);
++void sysaufs_notify_remount(void);
++#else
++static inline void sysaufs_add(struct aufs_sbinfo *sbinfo)
++{
++ /* nothing */
++}
++
++static inline void sysaufs_del(struct aufs_sbinfo *sbinfo)
++{
++ /* nothing */
++}
++#define sysaufs_init() 0
++#define sysaufs_fin() /* */
++#define sysaufs_notify_remount() /* */
++#endif /* CONFIG_AUFS_SYSAUFS */
++
++#endif /* __KERNEL__ */
++#endif /* __SYSAUFS_H__ */
+diff --git a/fs/aufs/vdir.c b/fs/aufs/vdir.c
+new file mode 100755
+index 0000000..8e99b7d
+--- /dev/null
++++ b/fs/aufs/vdir.c
+@@ -0,0 +1,802 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vdir.c,v 1.22 2007/05/14 03:38:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static int calc_size(int namelen)
++{
++ int sz;
++
++ sz = sizeof(struct aufs_de) + namelen;
++ if (sizeof(ino_t) == sizeof(long)) {
++ const int mask = sizeof(ino_t) - 1;
++ if (sz & mask) {
++ sz += sizeof(ino_t);
++ sz &= ~mask;
++ }
++ } else {
++#if 0 // remove
++ BUG();
++ // this block will be discarded by optimizer.
++ int m;
++ m = sz % sizeof(ino_t);
++ if (m)
++ sz += sizeof(ino_t) - m;
++#endif
++ }
++
++ DEBUG_ON(sz % sizeof(ino_t));
++ return sz;
++}
++
++static int set_deblk_end(union aufs_deblk_p *p, union aufs_deblk_p *deblk_end)
++{
++ if (calc_size(0) <= deblk_end->p - p->p) {
++ p->de->de_str.len = 0;
++ //smp_mb();
++ return 0;
++ }
++ return -1; // error
++}
++
++/* returns true or false */
++static int is_deblk_end(union aufs_deblk_p *p, union aufs_deblk_p *deblk_end)
++{
++ if (calc_size(0) <= deblk_end->p - p->p)
++ return !p->de->de_str.len;
++ return 1;
++}
++
++static aufs_deblk_t *last_deblk(struct aufs_vdir *vdir)
++{
++ return vdir->vd_deblk[vdir->vd_nblk - 1];
++}
++
++void nhash_init(struct aufs_nhash *nhash)
++{
++ int i;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++)
++ INIT_HLIST_HEAD(nhash->heads + i);
++}
++
++struct aufs_nhash *nhash_new(gfp_t gfp)
++{
++ struct aufs_nhash *nhash;
++
++ nhash = kmalloc(sizeof(*nhash), gfp);
++ if (nhash) {
++ nhash_init(nhash);
++ return nhash;
++ }
++ return ERR_PTR(-ENOMEM);
++}
++
++void nhash_del(struct aufs_nhash *nhash)
++{
++ nhash_fin(nhash);
++ kfree(nhash);
++}
++
++void nhash_move(struct aufs_nhash *dst, struct aufs_nhash *src)
++{
++ int i;
++
++ TraceEnter();
++
++ //DbgWhlist(src);
++ *dst = *src;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ struct hlist_head *h;
++ h = dst->heads + i;
++ if (h->first)
++ h->first->pprev = &h->first;
++ INIT_HLIST_HEAD(src->heads + i);
++ }
++ //DbgWhlist(src);
++ //DbgWhlist(dst);
++ //smp_mb();
++}
++
++/* ---------------------------------------------------------------------- */
++
++void nhash_fin(struct aufs_nhash *whlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos, *n;
++
++ TraceEnter();
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry_safe(tpos, pos, n, head, wh_hash) {
++ //hlist_del(pos);
++ kfree(tpos);
++ }
++ }
++}
++
++int is_longer_wh(struct aufs_nhash *whlist, aufs_bindex_t btgt, int limit)
++{
++ int n, i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++
++ LKTRTrace("limit %d\n", limit);
++ //return 1;
++
++ n = 0;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash)
++ if (tpos->wh_bindex == btgt && ++n > limit)
++ return 1;
++ }
++ return 0;
++}
++
++/* returns found(true) or not */
++int test_known_wh(struct aufs_nhash *whlist, char *name, int namelen)
++{
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ head = whlist->heads + au_name_hash(name, namelen);
++ hlist_for_each_entry(tpos, pos, head, wh_hash) {
++ str = &tpos->wh_str;
++ LKTRTrace("%.*s\n", str->len, str->name);
++ if (str->len == namelen && !memcmp(str->name, name, namelen))
++ return 1;
++ }
++ return 0;
++}
++
++int append_wh(struct aufs_nhash *whlist, char *name, int namelen,
++ aufs_bindex_t bindex)
++{
++ int err;
++ struct aufs_destr *str;
++ struct aufs_wh *wh;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ err = -ENOMEM;
++ wh = kmalloc(sizeof(*wh) + namelen, GFP_KERNEL);
++ if (unlikely(!wh))
++ goto out;
++ err = 0;
++ wh->wh_bindex = bindex;
++ str = &wh->wh_str;
++ str->len = namelen;
++ memcpy(str->name, name, namelen);
++ hlist_add_head(&wh->wh_hash,
++ whlist->heads + au_name_hash(name, namelen));
++ //smp_mb();
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void free_vdir(struct aufs_vdir *vdir)
++{
++ aufs_deblk_t **deblk;
++
++ TraceEnter();
++
++ deblk = vdir->vd_deblk;
++ while (vdir->vd_nblk--) {
++ kfree(*deblk);
++ deblk++;
++ }
++ kfree(vdir->vd_deblk);
++ cache_free_vdir(vdir);
++}
++
++static int append_deblk(struct aufs_vdir *vdir)
++{
++ int err, sz, i;
++ aufs_deblk_t **o;
++ union aufs_deblk_p p, deblk_end;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ sz = sizeof(*o) * vdir->vd_nblk;
++ o = au_kzrealloc(vdir->vd_deblk, sz, sz + sizeof(*o), GFP_KERNEL);
++ if (unlikely(!o))
++ goto out;
++ vdir->vd_deblk = o;
++ p.deblk = kmalloc(sizeof(*p.deblk), GFP_KERNEL);
++ if (p.deblk) {
++ i = vdir->vd_nblk++;
++ vdir->vd_deblk[i] = p.deblk;
++ vdir->vd_last.i = i;
++ vdir->vd_last.p.p = p.p;
++ deblk_end.deblk = p.deblk + 1;
++ err = set_deblk_end(&p, &deblk_end);
++ DEBUG_ON(err);
++ }
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static struct aufs_vdir *alloc_vdir(void)
++{
++ struct aufs_vdir *vdir;
++ int err;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ vdir = cache_alloc_vdir();
++ if (unlikely(!vdir))
++ goto out;
++ vdir->vd_deblk = kzalloc(sizeof(*vdir->vd_deblk), GFP_KERNEL);
++ if (unlikely(!vdir->vd_deblk))
++ goto out_free;
++
++ vdir->vd_nblk = 0;
++ vdir->vd_version = 0;
++ vdir->vd_jiffy = 0;
++ err = append_deblk(vdir);
++ if (!err)
++ return vdir; /* success */
++
++ kfree(vdir->vd_deblk);
++
++ out_free:
++ cache_free_vdir(vdir);
++ out:
++ vdir = ERR_PTR(err);
++ TraceErrPtr(vdir);
++ return vdir;
++}
++
++static int reinit_vdir(struct aufs_vdir *vdir)
++{
++ int err;
++ union aufs_deblk_p p, deblk_end;
++
++ TraceEnter();
++
++ while (vdir->vd_nblk > 1) {
++ kfree(vdir->vd_deblk[vdir->vd_nblk - 1]);
++ vdir->vd_deblk[vdir->vd_nblk - 1] = NULL;
++ vdir->vd_nblk--;
++ }
++ p.deblk = vdir->vd_deblk[0];
++ deblk_end.deblk = p.deblk + 1;
++ err = set_deblk_end(&p, &deblk_end);
++ DEBUG_ON(err);
++ vdir->vd_version = 0;
++ vdir->vd_jiffy = 0;
++ vdir->vd_last.i = 0;
++ vdir->vd_last.p.deblk = vdir->vd_deblk[0];
++ //smp_mb();
++ //DbgVdir(vdir);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void free_dehlist(struct aufs_nhash *dehlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_dehstr *tpos;
++ struct hlist_node *pos, *n;
++
++ TraceEnter();
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = dehlist->heads + i;
++ hlist_for_each_entry_safe(tpos, pos, n, head, hash) {
++ //hlist_del(pos);
++ cache_free_dehstr(tpos);
++ }
++ }
++}
++
++/* returns found(true) or not */
++static int test_known(struct aufs_nhash *delist, char *name, int namelen)
++{
++ struct hlist_head *head;
++ struct aufs_dehstr *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ head = delist->heads + au_name_hash(name, namelen);
++ hlist_for_each_entry(tpos, pos, head, hash) {
++ str = tpos->str;
++ LKTRTrace("%.*s\n", str->len, str->name);
++ if (str->len == namelen && !memcmp(str->name, name, namelen))
++ return 1;
++ }
++ return 0;
++
++}
++
++static int append_de(struct aufs_vdir *vdir, char *name, int namelen, ino_t ino,
++ unsigned int d_type, struct aufs_nhash *delist)
++{
++ int err, sz;
++ union aufs_deblk_p p, *room, deblk_end;
++ struct aufs_dehstr *dehstr;
++
++ LKTRTrace("%.*s %d, i%lu, dt%u\n", namelen, name, namelen, ino, d_type);
++
++ p.deblk = last_deblk(vdir);
++ deblk_end.deblk = p.deblk + 1;
++ room = &vdir->vd_last.p;
++ DEBUG_ON(room->p < p.p || deblk_end.p <= room->p
++ || !is_deblk_end(room, &deblk_end));
++
++ sz = calc_size(namelen);
++ if (unlikely(sz > deblk_end.p - room->p)) {
++ err = append_deblk(vdir);
++ if (unlikely(err))
++ goto out;
++ p.deblk = last_deblk(vdir);
++ deblk_end.deblk = p.deblk + 1;
++ //smp_mb();
++ DEBUG_ON(room->p != p.p);
++ }
++
++ err = -ENOMEM;
++ dehstr = cache_alloc_dehstr();
++ if (unlikely(!dehstr))
++ goto out;
++ dehstr->str = &room->de->de_str;
++ hlist_add_head(&dehstr->hash,
++ delist->heads + au_name_hash(name, namelen));
++
++ room->de->de_ino = ino;
++ room->de->de_type = d_type;
++ room->de->de_str.len = namelen;
++ memcpy(room->de->de_str.name, name, namelen);
++
++ err = 0;
++ room->p += sz;
++ if (unlikely(set_deblk_end(room, &deblk_end)))
++ err = append_deblk(vdir);
++ //smp_mb();
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct fillvdir_arg {
++ struct file *file;
++ struct aufs_vdir *vdir;
++ struct aufs_nhash *delist;
++ struct aufs_nhash *whlist;
++ aufs_bindex_t bindex;
++ int err;
++ int called;
++};
++
++static int fillvdir(void *__arg, const char *__name, int namelen, loff_t offset,
++ filldir_ino_t h_ino, unsigned int d_type)
++{
++ struct fillvdir_arg *arg = __arg;
++ char *name = (void*)__name;
++ aufs_bindex_t bindex, bend;
++ struct xino xino;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, namelen %d, i%Lu, dt%u\n",
++ namelen, name, namelen, (u64)h_ino, d_type);
++
++ sb = arg->file->f_dentry->d_sb;
++ bend = arg->bindex;
++ arg->err = 0;
++ arg->called++;
++ //smp_mb();
++ if (namelen <= AUFS_WH_PFX_LEN
++ || memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) {
++ for (bindex = 0; bindex < bend; bindex++)
++ if (test_known(arg->delist + bindex, name, namelen)
++ || test_known_wh(arg->whlist + bindex, name,
++ namelen))
++ goto out; /* already exists or whiteouted */
++
++ arg->err = xino_read(sb, bend, h_ino, &xino);
++ if (!arg->err && !xino.ino) {
++ //struct inode *h_inode;
++ xino.ino = xino_new_ino(sb);
++ if (unlikely(!xino.ino))
++ arg->err = -EIO;
++#if 0
++ //xino.h_gen = AuXino_INVALID_HGEN;
++ h_inode = ilookup(sbr_sb(sb, bend), h_ino);
++ if (h_inode) {
++ if (!is_bad_inode(h_inode)) {
++ xino.h_gen = h_inode->i_generation;
++ WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ }
++ iput(h_inode);
++ }
++#endif
++ arg->err = xino_write(sb, bend, h_ino, &xino);
++ }
++ if (!arg->err)
++ arg->err = append_de(arg->vdir, name, namelen, xino.ino,
++ d_type, arg->delist + bend);
++ } else {
++ name += AUFS_WH_PFX_LEN;
++ namelen -= AUFS_WH_PFX_LEN;
++ for (bindex = 0; bindex < bend; bindex++)
++ if (test_known_wh(arg->whlist + bend, name, namelen))
++ goto out; /* already whiteouted */
++ arg->err = append_wh(arg->whlist + bend, name, namelen, bend);
++ }
++
++ out:
++ if (!arg->err)
++ arg->vdir->vd_jiffy = jiffies;
++ //smp_mb();
++ TraceErr(arg->err);
++ return arg->err;
++}
++
++static int read_vdir(struct file *file, int may_read)
++{
++ int err, do_read, dlgt;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_vdir *vdir, *allocated;
++ unsigned long expire;
++ struct fillvdir_arg arg;
++ aufs_bindex_t bindex, bend, bstart;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, may %d\n", DLNPair(dentry), may_read);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++
++ err = 0;
++ allocated = NULL;
++ do_read = 0;
++ sb = inode->i_sb;
++ expire = stosi(sb)->si_rdcache;
++ vdir = ivdir(inode);
++ if (!vdir) {
++ DEBUG_ON(fvdir_cache(file));
++ do_read = 1;
++ vdir = alloc_vdir();
++ err = PTR_ERR(vdir);
++ if (IS_ERR(vdir))
++ goto out;
++ err = 0;
++ allocated = vdir;
++ } else if (may_read
++ && (inode->i_version != vdir->vd_version
++ || time_after(jiffies, vdir->vd_jiffy + expire))) {
++ LKTRTrace("iver %lu, vdver %lu, exp %lu\n",
++ inode->i_version, vdir->vd_version,
++ vdir->vd_jiffy + expire);
++ do_read = 1;
++ err = reinit_vdir(vdir);
++ if (unlikely(err))
++ goto out;
++ }
++ //DbgVdir(vdir); goto out;
++
++ if (!do_read)
++ return 0; /* success */
++
++ err = -ENOMEM;
++ bend = fbend(file);
++ arg.delist = kmalloc(sizeof(*arg.delist) * (bend + 1), GFP_KERNEL);
++ if (unlikely(!arg.delist))
++ goto out_vdir;
++ arg.whlist = kmalloc(sizeof(*arg.whlist) * (bend + 1), GFP_KERNEL);
++ if (unlikely(!arg.whlist))
++ goto out_delist;
++ err = 0;
++ for (bindex = 0; bindex <= bend; bindex++) {
++ nhash_init(arg.delist + bindex);
++ nhash_init(arg.whlist + bindex);
++ }
++
++ dlgt = need_dlgt(sb);
++ arg.file = file;
++ arg.vdir = vdir;
++ bstart = fbstart(file);
++ for (bindex = bstart; !err && bindex <= bend; bindex++) {
++ struct file *hf;
++ struct inode *h_inode;
++
++ hf = au_h_fptr_i(file, bindex);
++ if (!hf)
++ continue;
++
++ h_inode = hf->f_dentry->d_inode;
++ //hf->f_pos = 0;
++ arg.bindex = bindex;
++ do {
++ arg.err = 0;
++ arg.called = 0;
++ //smp_mb();
++ err = vfsub_readdir(hf, fillvdir, &arg, dlgt);
++ if (err >= 0)
++ err = arg.err;
++ } while (!err && arg.called);
++ }
++
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ free_dehlist(arg.delist + bindex);
++ nhash_fin(arg.whlist + bindex);
++ }
++ kfree(arg.whlist);
++
++ out_delist:
++ kfree(arg.delist);
++ out_vdir:
++ if (!err) {
++ //file->f_pos = 0;
++ vdir->vd_version = inode->i_version;
++ vdir->vd_last.i = 0;
++ vdir->vd_last.p.deblk = vdir->vd_deblk[0];
++ if (allocated)
++ set_ivdir(inode, allocated);
++ } else if (allocated)
++ free_vdir(allocated);
++ //DbgVdir(vdir); goto out;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int copy_vdir(struct aufs_vdir *tgt, struct aufs_vdir *src)
++{
++ int err, i, rerr, n;
++
++ TraceEnter();
++ DEBUG_ON(tgt->vd_nblk != 1);
++ //DbgVdir(tgt);
++
++ err = -ENOMEM;
++ if (tgt->vd_nblk < src->vd_nblk) {
++ aufs_deblk_t **p;
++ p = au_kzrealloc(tgt->vd_deblk, sizeof(*p) * tgt->vd_nblk,
++ sizeof(*p) * src->vd_nblk, GFP_KERNEL);
++ if (unlikely(!p))
++ goto out;
++ tgt->vd_deblk = p;
++ }
++
++ n = tgt->vd_nblk = src->vd_nblk;
++ memcpy(tgt->vd_deblk[0], src->vd_deblk[0], AUFS_DEBLK_SIZE);
++ //tgt->vd_last.i = 0;
++ //tgt->vd_last.p.deblk = tgt->vd_deblk[0];
++ tgt->vd_version = src->vd_version;
++ tgt->vd_jiffy = src->vd_jiffy;
++
++ for (i = 1; i < n; i++) {
++ tgt->vd_deblk[i] = kmalloc(AUFS_DEBLK_SIZE, GFP_KERNEL);
++ if (tgt->vd_deblk[i])
++ memcpy(tgt->vd_deblk[i], src->vd_deblk[i],
++ AUFS_DEBLK_SIZE);
++ else
++ goto out;
++ }
++ //smp_mb();
++ //DbgVdir(tgt);
++ return 0; /* success */
++
++ out:
++ rerr = reinit_vdir(tgt);
++ BUG_ON(rerr);
++ TraceErr(err);
++ return err;
++}
++
++int au_init_vdir(struct file *file)
++{
++ int err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_vdir *vdir_cache, *allocated;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++
++ err = read_vdir(file, !file->f_pos);
++ if (unlikely(err))
++ goto out;
++ //DbgVdir(ivdir(inode)); goto out;
++
++ allocated = NULL;
++ vdir_cache = fvdir_cache(file);
++ if (!vdir_cache) {
++ vdir_cache = alloc_vdir();
++ err = PTR_ERR(vdir_cache);
++ if (IS_ERR(vdir_cache))
++ goto out;
++ allocated = vdir_cache;
++ } else if (!file->f_pos && vdir_cache->vd_version != file->f_version) {
++ err = reinit_vdir(vdir_cache);
++ if (unlikely(err))
++ goto out;
++ } else
++ return 0; /* success */
++ //err = 0; DbgVdir(vdir_cache); goto out;
++
++ err = copy_vdir(vdir_cache, ivdir(inode));
++ if (!err) {
++ file->f_version = inode->i_version;
++ if (allocated)
++ set_fvdir_cache(file, allocated);
++ } else if (allocated)
++ free_vdir(allocated);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static loff_t calc_offset(struct aufs_vdir *vdir)
++{
++ loff_t offset;
++ union aufs_deblk_p p;
++
++ p.deblk = vdir->vd_deblk[vdir->vd_last.i];
++ offset = vdir->vd_last.p.p - p.p;
++ offset += sizeof(*p.deblk) * vdir->vd_last.i;
++ return offset;
++}
++
++/* returns true or false */
++static int seek_vdir(struct file *file)
++{
++ int valid, i, n;
++ struct dentry *dentry;
++ struct aufs_vdir *vdir_cache;
++ loff_t offset;
++ union aufs_deblk_p p, deblk_end;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ vdir_cache = fvdir_cache(file);
++ DEBUG_ON(!vdir_cache);
++ //DbgVdir(vdir_cache);
++
++ valid = 1;
++ offset = calc_offset(vdir_cache);
++ LKTRTrace("offset %Ld\n", offset);
++ if (file->f_pos == offset)
++ goto out;
++
++ vdir_cache->vd_last.i = 0;
++ vdir_cache->vd_last.p.deblk = vdir_cache->vd_deblk[0];
++ if (!file->f_pos)
++ goto out;
++
++ valid = 0;
++ i = file->f_pos / AUFS_DEBLK_SIZE;
++ LKTRTrace("i %d\n", i);
++ if (i >= vdir_cache->vd_nblk)
++ goto out;
++
++ n = vdir_cache->vd_nblk;
++ //DbgVdir(vdir_cache);
++ for (; i < n; i++) {
++ p.deblk = vdir_cache->vd_deblk[i];
++ deblk_end.deblk = p.deblk + 1;
++ offset = i * AUFS_DEBLK_SIZE;
++ while (!is_deblk_end(&p, &deblk_end) && offset < file->f_pos) {
++ int l;
++ l = calc_size(p.de->de_str.len);
++ offset += l;
++ p.p += l;
++ }
++ if (!is_deblk_end(&p, &deblk_end)) {
++ valid = 1;
++ vdir_cache->vd_last.i = i;
++ vdir_cache->vd_last.p = p;
++ break;
++ }
++ }
++
++ out:
++ //smp_mb();
++ //DbgVdir(vdir_cache);
++ TraceErr(!valid);
++ return valid;
++}
++
++int au_fill_de(struct file *file, void *dirent, filldir_t filldir)
++{
++ int err, l;
++ struct dentry *dentry;
++ struct aufs_vdir *vdir_cache;
++ struct aufs_de *de;
++ union aufs_deblk_p deblk_end;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ vdir_cache = fvdir_cache(file);
++ DEBUG_ON(!vdir_cache);
++ //DbgVdir(vdir_cache);
++
++ if (!seek_vdir(file))
++ return 0;
++
++ while (1) {
++ deblk_end.deblk
++ = vdir_cache->vd_deblk[vdir_cache->vd_last.i] + 1;
++ while (!is_deblk_end(&vdir_cache->vd_last.p, &deblk_end)) {
++ de = vdir_cache->vd_last.p.de;
++ LKTRTrace("%.*s, off%Ld, i%lu, dt%d\n",
++ de->de_str.len, de->de_str.name,
++ file->f_pos, de->de_ino, de->de_type);
++ err = filldir(dirent, de->de_str.name, de->de_str.len,
++ file->f_pos, de->de_ino, de->de_type);
++ if (unlikely(err)) {
++ TraceErr(err);
++ //return err;
++ //todo: ignore the error caused by udba.
++ return 0;
++ }
++
++ l = calc_size(de->de_str.len);
++ vdir_cache->vd_last.p.p += l;
++ file->f_pos += l;
++ }
++ if (vdir_cache->vd_last.i < vdir_cache->vd_nblk - 1) {
++ vdir_cache->vd_last.i++;
++ vdir_cache->vd_last.p.deblk
++ = vdir_cache->vd_deblk[vdir_cache->vd_last.i];
++ file->f_pos = sizeof(*vdir_cache->vd_last.p.deblk)
++ * vdir_cache->vd_last.i;
++ continue;
++ }
++ break;
++ }
++
++ //smp_mb();
++ return 0;
++}
+diff --git a/fs/aufs/vfsub.c b/fs/aufs/vfsub.c
+new file mode 100755
+index 0000000..8571d21
+--- /dev/null
++++ b/fs/aufs/vfsub.c
+@@ -0,0 +1,665 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vfsub.c,v 1.5 2007/04/23 00:55:06 sfjro Exp $ */
++// I'm going to slightly mad
++
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++struct permission_args {
++ int *errp;
++ struct inode *inode;
++ int mask;
++ struct nameidata *nd;
++};
++
++static void call_permission(void *args)
++{
++ struct permission_args *a = args;
++ *a->errp = do_vfsub_permission(a->inode, a->mask, a->nd);
++}
++
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_permission(inode, mask, nd);
++ else {
++ int err;
++ struct permission_args args = {
++ .errp = &err,
++ .inode = inode,
++ .mask = mask,
++ .nd = nd
++ };
++ au_wkq_wait(call_permission, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct create_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++ struct nameidata *nd;
++};
++
++static void call_create(void *args)
++{
++ struct create_args *a = args;
++ *a->errp = do_vfsub_create(a->dir, a->dentry, a->mode, a->nd);
++}
++
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_create(dir, dentry, mode, nd);
++ else {
++ int err;
++ struct create_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode,
++ .nd = nd
++ };
++ au_wkq_wait(call_create, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct symlink_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ const char *symname;
++ int mode;
++};
++
++static void call_symlink(void *args)
++{
++ struct symlink_args *a = args;
++ *a->errp = do_vfsub_symlink(a->dir, a->dentry, a->symname, a->mode);
++}
++
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_symlink(dir, dentry, symname, mode);
++ else {
++ int err;
++ struct symlink_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .symname = symname,
++ .mode = mode
++ };
++ au_wkq_wait(call_symlink, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct mknod_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++ dev_t dev;
++};
++
++static void call_mknod(void *args)
++{
++ struct mknod_args *a = args;
++ *a->errp = do_vfsub_mknod(a->dir, a->dentry, a->mode, a->dev);
++}
++
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_mknod(dir, dentry, mode, dev);
++ else {
++ int err;
++ struct mknod_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode,
++ .dev = dev
++ };
++ au_wkq_wait(call_mknod, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct mkdir_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++};
++
++static void call_mkdir(void *args)
++{
++ struct mkdir_args *a = args;
++ *a->errp = do_vfsub_mkdir(a->dir, a->dentry, a->mode);
++}
++
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_mkdir(dir, dentry, mode);
++ else {
++ int err;
++ struct mkdir_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode
++ };
++ au_wkq_wait(call_mkdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct link_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *src_dentry, *dentry;
++};
++
++static void call_link(void *args)
++{
++ struct link_args *a = args;
++ *a->errp = do_vfsub_link(a->src_dentry, a->dir, a->dentry);
++}
++
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_link(src_dentry, dir, dentry);
++ else {
++ int err;
++ struct link_args args = {
++ .errp = &err,
++ .src_dentry = src_dentry,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_link, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct rename_args {
++ int *errp;
++ struct inode *src_dir, *dir;
++ struct dentry *src_dentry, *dentry;
++};
++
++static void call_rename(void *args)
++{
++ struct rename_args *a = args;
++ *a->errp = do_vfsub_rename(a->src_dir, a->src_dentry, a->dir,
++ a->dentry);
++}
++
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_rename(src_dir, src_dentry, dir, dentry);
++ else {
++ int err;
++ struct rename_args args = {
++ .errp = &err,
++ .src_dir = src_dir,
++ .src_dentry = src_dentry,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_rename, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct rmdir_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++};
++
++static void call_rmdir(void *args)
++{
++ struct rmdir_args *a = args;
++ *a->errp = do_vfsub_rmdir(a->dir, a->dentry);
++}
++
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_rmdir(dir, dentry);
++ else {
++ int err;
++ struct rmdir_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_rmdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct read_args {
++ ssize_t *errp;
++ struct file *file;
++ union {
++ void *kbuf;
++ char __user *ubuf;
++ };
++ size_t count;
++ loff_t *ppos;
++};
++
++static void call_read_k(void *args)
++{
++ struct read_args *a = args;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(a->file->f_dentry), (unsigned long)a->count,
++ *a->ppos);
++ *a->errp = do_vfsub_read_k(a->file, a->kbuf, a->count, a->ppos);
++}
++
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_read_u(file, ubuf, count, ppos);
++ else {
++ ssize_t err, read;
++ struct read_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++
++ if (unlikely(!count))
++ return 0;
++
++ /*
++ * workaround an application bug.
++ * generally, read(2) or write(2) may return the value shorter
++ * than requested. But many applications don't support it,
++ * for example bash.
++ */
++ err = -ENOMEM;
++ if (args.count > PAGE_SIZE)
++ args.count = PAGE_SIZE;
++ args.kbuf = kmalloc(args.count, GFP_KERNEL);
++ if (unlikely(!args.kbuf))
++ goto out;
++
++ read = 0;
++ do {
++ au_wkq_wait(call_read_k, &args, /*dlgt*/1);
++ if (unlikely(err > 0
++ && copy_to_user(ubuf, args.kbuf, err))) {
++ err = -EFAULT;
++ goto out_free;
++ } else if (!err)
++ break;
++ else if (unlikely(err < 0))
++ goto out_free;
++ count -= err;
++ /* do not read too much because of file i/o pointer */
++ if (unlikely(count < args.count))
++ args.count = count;
++ ubuf += err;
++ read += err;
++ } while (count);
++ smp_mb();
++ err = read;
++
++ out_free:
++ kfree(args.kbuf);
++ out:
++ return err;
++ }
++}
++
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_read_k(file, kbuf, count, ppos);
++ else {
++ ssize_t err;
++ struct read_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++ args.kbuf = kbuf;
++ au_wkq_wait(call_read_k, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct write_args {
++ ssize_t *errp;
++ struct file *file;
++ union {
++ void *kbuf;
++ const char __user *ubuf;
++ };
++ void *buf;
++ size_t count;
++ loff_t *ppos;
++};
++
++static void call_write_k(void *args)
++{
++ struct write_args *a = args;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(a->file->f_dentry), (unsigned long)a->count,
++ *a->ppos);
++ *a->errp = do_vfsub_write_k(a->file, a->kbuf, a->count, a->ppos);
++}
++
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_write_u(file, ubuf, count, ppos);
++ else {
++ ssize_t err, written;
++ struct write_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++
++ if (unlikely(!count))
++ return 0;
++
++ /*
++ * workaround an application bug.
++ * generally, read(2) or write(2) may return the value shorter
++ * than requested. But many applications don't support it,
++ * for example bash.
++ */
++ err = -ENOMEM;
++ if (args.count > PAGE_SIZE)
++ args.count = PAGE_SIZE;
++ args.kbuf = kmalloc(args.count, GFP_KERNEL);
++ if (unlikely(!args.kbuf))
++ goto out;
++
++ written = 0;
++ do {
++ if (unlikely(copy_from_user(args.kbuf, ubuf, args.count))) {
++ err = -EFAULT;
++ goto out_free;
++ }
++
++ au_wkq_wait(call_write_k, &args, /*dlgt*/1);
++ if (err > 0) {
++ count -= err;
++ if (count < args.count)
++ args.count = count;
++ ubuf += err;
++ written += err;
++ } else if (!err)
++ break;
++ else if (unlikely(err < 0))
++ goto out_free;
++ } while (count);
++ err = written;
++
++ out_free:
++ kfree(args.kbuf);
++ out:
++ return err;
++ }
++}
++
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_write_k(file, kbuf, count, ppos);
++ else {
++ ssize_t err;
++ struct write_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++ args.kbuf = kbuf;
++ au_wkq_wait(call_write_k, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct readdir_args {
++ int *errp;
++ struct file *file;
++ filldir_t filldir;
++ void *arg;
++};
++
++static void call_readdir(void *args)
++{
++ struct readdir_args *a = args;
++ *a->errp = do_vfsub_readdir(a->file, a->filldir, a->arg);
++}
++
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_readdir(file, filldir, arg);
++ else {
++ int err;
++ struct readdir_args args = {
++ .errp = &err,
++ .file = file,
++ .filldir = filldir,
++ .arg = arg
++ };
++ au_wkq_wait(call_readdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++/* ---------------------------------------------------------------------- */
++
++struct notify_change_args {
++ int *errp;
++ struct dentry *h_dentry;
++ struct iattr *ia;
++};
++
++static void call_notify_change(void *args)
++{
++ struct notify_change_args *a = args;
++ struct inode *h_inode;
++
++ LKTRTrace("%.*s, ia_valid 0x%x\n",
++ DLNPair(a->h_dentry), a->ia->ia_valid);
++ h_inode = a->h_dentry->d_inode;
++ IMustLock(h_inode);
++
++ *a->errp = -EPERM;
++ if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
++ lockdep_off();
++ *a->errp = notify_change(a->h_dentry, a->ia);
++ lockdep_on();
++ }
++ TraceErr(*a->errp);
++}
++
++int vfsub_notify_change(struct dentry *dentry, struct iattr *ia, int dlgt)
++{
++ int err;
++ struct notify_change_args args = {
++ .errp = &err,
++ .h_dentry = dentry,
++ .ia = ia
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_notify_change(&args);
++#else
++ if (!dlgt)
++ call_notify_change(&args);
++ else
++ au_wkq_wait(call_notify_change, &args, /*dlgt*/1);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct unlink_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++};
++
++static void call_unlink(void *args)
++{
++ struct unlink_args *a = args;
++ struct inode *h_inode;
++ const int stop_sillyrename = (au_is_nfs(a->dentry->d_sb)
++ && atomic_read(&a->dentry->d_count) == 1);
++
++ LKTRTrace("%.*s, stop_silly %d, cnt %d\n",
++ DLNPair(a->dentry), stop_sillyrename,
++ atomic_read(&a->dentry->d_count));
++ IMustLock(a->dir);
++
++ if (!stop_sillyrename)
++ dget(a->dentry);
++ h_inode = a->dentry->d_inode;
++ if (h_inode)
++ atomic_inc(&h_inode->i_count);
++#if 0 // partial testing
++ {
++ struct qstr *name = &a->dentry->d_name;
++ if (name->len == sizeof(AUFS_XINO_FNAME) - 1
++ && !strncmp(name->name, AUFS_XINO_FNAME, name->len)) {
++ lockdep_off();
++ *a->errp = vfs_unlink(a->dir, a->dentry);
++ lockdep_on();
++ } else
++ err = -1;
++ }
++#else
++ // vfs_unlink() locks inode
++ lockdep_off();
++ *a->errp = vfs_unlink(a->dir, a->dentry);
++ lockdep_on();
++#endif
++
++ if (!stop_sillyrename)
++ dput(a->dentry);
++ if (h_inode)
++ iput(h_inode);
++
++ TraceErr(*a->errp);
++}
++
++/*
++ * @dir: must be locked.
++ * @dentry: target dentry.
++ */
++int vfsub_unlink(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ int err;
++ struct unlink_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_unlink(&args);
++#else
++ if (!dlgt)
++ call_unlink(&args);
++ else
++ au_wkq_wait(call_unlink, &args, /*dlgt*/1);
++#endif
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct statfs_args {
++ int *errp;
++ void *arg;
++ struct kstatfs *buf;
++};
++
++static void call_statfs(void *args)
++{
++ struct statfs_args *a = args;
++ *a->errp = vfs_statfs(a->arg, a->buf);
++}
++
++int vfsub_statfs(void *arg, struct kstatfs *buf, int dlgt)
++{
++ int err;
++ struct statfs_args args = {
++ .errp = &err,
++ .arg = arg,
++ .buf = buf
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_statfs(&args);
++#else
++ if (!dlgt)
++ call_statfs(&args);
++ else
++ au_wkq_wait(call_statfs, &args, /*dlgt*/1);
++#endif
++ return err;
++}
+diff --git a/fs/aufs/vfsub.h b/fs/aufs/vfsub.h
+new file mode 100755
+index 0000000..52f15cc
+--- /dev/null
++++ b/fs/aufs/vfsub.h
+@@ -0,0 +1,427 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vfsub.h,v 1.8 2007/05/14 03:39:10 sfjro Exp $ */
++
++#ifndef __AUFS_VFSUB_H__
++#define __AUFS_VFSUB_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <asm/uaccess.h>
++#include "wkq.h"
++
++/* ---------------------------------------------------------------------- */
++
++/* simple abstractions, for future use */
++static inline
++int do_vfsub_permission(struct inode *inode, int mask, struct nameidata *nd)
++{
++ LKTRTrace("i%lu, mask 0x%x, nd %p\n", inode->i_ino, mask, nd);
++#if 0
++#else
++ return permission(inode, mask, nd);
++#endif
++}
++
++static inline
++struct file *vfsub_filp_open(const char *path, int oflags, int mode)
++{
++ struct file *err;
++
++ LKTRTrace("%s\n", path);
++
++ lockdep_off();
++ err = filp_open(path, oflags, mode);
++ lockdep_on();
++ return err;
++}
++
++static inline
++int vfsub_path_lookup(const char *name, unsigned int flags,
++ struct nameidata *nd)
++{
++ int err;
++
++ LKTRTrace("%s\n", name);
++
++ //lockdep_off();
++ err = path_lookup(name, flags, nd);
++ //lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++int do_vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_create(dir, dentry, mode, nd);
++#endif
++}
++
++static inline
++int do_vfsub_symlink(struct inode *dir, struct dentry *dentry,
++ const char *symname, int mode)
++{
++ LKTRTrace("i%lu, %.*s, %s, 0x%x\n",
++ dir->i_ino, DLNPair(dentry), symname, mode);
++#if 0
++#else
++ return vfs_symlink(dir, dentry, symname, mode);
++#endif
++}
++
++static inline
++int do_vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode,
++ dev_t dev)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_mknod(dir, dentry, mode, dev);
++#endif
++}
++
++static inline
++int do_vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("%.*s, i%lu, %.*s\n",
++ DLNPair(src_dentry), dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_link(src_dentry, dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++int do_vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("i%lu, %.*s, i%lu, %.*s\n",
++ src_dir->i_ino, DLNPair(src_dentry),
++ dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_rename(src_dir, src_dentry, dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++int do_vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_mkdir(dir, dentry, mode);
++#endif
++}
++
++static inline int do_vfsub_rmdir(struct inode *dir, struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_rmdir(dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++ssize_t do_vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)count, *ppos);
++
++ /* nfs uses some locks */
++ lockdep_off();
++#if 0
++#else
++ err = vfs_read(file, ubuf, count, ppos);
++#endif
++ lockdep_on();
++ return err;
++}
++
++// kernel_read() ??
++static inline
++ssize_t do_vfsub_read_k(struct file *file, void *kbuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ err = do_vfsub_read_u(file, (char __user*)kbuf, count, ppos);
++ set_fs(oldfs);
++ return err;
++}
++
++static inline
++ssize_t do_vfsub_write_u(struct file *file, const char __user *ubuf,
++ size_t count, loff_t *ppos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)count, *ppos);
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_write(file, ubuf, count, ppos);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++ssize_t do_vfsub_write_k(struct file *file, void *kbuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ err = do_vfsub_write_u(file, (const char __user*)kbuf, count, ppos);
++ set_fs(oldfs);
++ return err;
++}
++
++static inline
++int do_vfsub_readdir(struct file *file, filldir_t filldir, void *arg)
++{
++ int err;
++
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_readdir(file, filldir, arg);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline loff_t vfsub_llseek(struct file *file, loff_t offset, int origin)
++{
++ loff_t err;
++
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_llseek(file, offset, origin);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++static inline int need_dlgt(struct super_block *sb)
++{
++ return (au_flag_test(sb, AuFlag_DLGT) && !is_au_wkq(current));
++}
++
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt);
++
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt);
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt);
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt);
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt);
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt);
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt);
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt);
++
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt);
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt);
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt);
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt);
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt);
++
++#else
++
++static inline int need_dlgt(struct super_block *sb)
++{
++ return 0;
++}
++
++static inline
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt)
++{
++ return do_vfsub_permission(inode, mask, nd);
++}
++
++static inline
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt)
++{
++ return do_vfsub_create(dir, dentry, mode, nd);
++}
++
++static inline
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt)
++{
++ return do_vfsub_symlink(dir, dentry, symname, mode);
++}
++
++static inline
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt)
++{
++ return do_vfsub_mknod(dir, dentry, mode, dev);
++}
++
++static inline
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_link(src_dentry, dir, dentry);
++}
++
++static inline
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_rename(src_dir, src_dentry, dir, dentry);
++}
++
++static inline
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode,
++ int dlgt)
++{
++ return do_vfsub_mkdir(dir, dentry, mode);
++}
++
++static inline
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_rmdir(dir, dentry);
++}
++
++static inline
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ return do_vfsub_read_u(file, ubuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ return do_vfsub_read_k(file, kbuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ return do_vfsub_write_u(file, ubuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ return do_vfsub_write_k(file, kbuf, count, ppos);
++}
++
++static inline
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
++{
++ return do_vfsub_readdir(file, filldir, arg);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++struct dentry *vfsub_lock_rename(struct dentry *d1, struct dentry *d2)
++{
++ struct dentry *d;
++
++ lockdep_off();
++ d = lock_rename(d1, d2);
++ lockdep_on();
++ return d;
++}
++
++static inline void vfsub_unlock_rename(struct dentry *d1, struct dentry *d2)
++{
++ lockdep_off();
++ unlock_rename(d1, d2);
++ lockdep_on();
++}
++
++/* ---------------------------------------------------------------------- */
++
++int vfsub_notify_change(struct dentry *dentry, struct iattr *ia, int dlgt);
++int vfsub_unlink(struct inode *dir, struct dentry *dentry, int dlgt);
++int vfsub_statfs(void *arg, struct kstatfs *buf, int dlgt);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_VFSUB_H__ */
+diff --git a/fs/aufs/whout.c b/fs/aufs/whout.c
+new file mode 100755
+index 0000000..b7f874c
+--- /dev/null
++++ b/fs/aufs/whout.c
+@@ -0,0 +1,933 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: whout.c,v 1.14 2007/05/14 03:40:40 sfjro Exp $ */
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/random.h>
++#include <linux/security.h>
++#include "aufs.h"
++
++#define WH_MASK S_IRUGO
++
++/* If a directory contains this file, then it is opaque. We start with the
++ * .wh. flag so that it is blocked by lookup.
++ */
++static struct qstr diropq_name = {
++ .name = AUFS_WH_DIROPQ,
++ .len = sizeof(AUFS_WH_DIROPQ) - 1
++};
++
++/*
++ * generate whiteout name, which is NOT terminated by NULL.
++ * @name: original d_name.name
++ * @len: original d_name.len
++ * @wh: whiteout qstr
++ * returns zero when succeeds, otherwise error.
++ * succeeded value as wh->name should be freed by au_free_whname().
++ */
++int au_alloc_whname(const char *name, int len, struct qstr *wh)
++{
++ char *p;
++
++ DEBUG_ON(!name || !len || !wh);
++
++ if (unlikely(len > PATH_MAX - AUFS_WH_PFX_LEN))
++ return -ENAMETOOLONG;
++
++ wh->len = len + AUFS_WH_PFX_LEN;
++ wh->name = p = kmalloc(wh->len, GFP_KERNEL);
++ //if (LktrCond) {kfree(p); wh->name = p = NULL;}
++ if (p) {
++ memcpy(p, AUFS_WH_PFX, AUFS_WH_PFX_LEN);
++ memcpy(p + AUFS_WH_PFX_LEN, name, len);
++ //smp_mb();
++ return 0;
++ }
++ return -ENOMEM;
++}
++
++void au_free_whname(struct qstr *wh)
++{
++ DEBUG_ON(!wh || !wh->name);
++ kfree(wh->name);
++#ifdef CONFIG_AUFS_DEBUG
++ wh->name = NULL;
++#endif
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if the @wh_name exists under @hidden_parent.
++ * @try_sio specifies the necessary of super-io.
++ */
++int is_wh(struct dentry *hidden_parent, struct qstr *wh_name, int try_sio,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct dentry *wh_dentry;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n", DLNPair(hidden_parent),
++ wh_name->len, wh_name->name, lkup->nfsmnt, lkup->dlgt);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ if (!try_sio)
++ wh_dentry = lkup_one(wh_name->name, hidden_parent,
++ wh_name->len, lkup);
++ else
++ wh_dentry = sio_lkup_one(wh_name->name, hidden_parent,
++ wh_name->len, lkup);
++ //if (LktrCond) {dput(wh_dentry); wh_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ err = 0;
++ if (!wh_dentry->d_inode)
++ goto out_wh; /* success */
++
++ err = 1;
++ if (S_ISREG(wh_dentry->d_inode->i_mode))
++ goto out_wh; /* success */
++
++ err = -EIO;
++ IOErr("%.*s Invalid whiteout entry type 0%o.\n",
++ DLNPair(wh_dentry), wh_dentry->d_inode->i_mode);
++
++ out_wh:
++ dput(wh_dentry);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * test if the @hidden_dentry sets opaque or not.
++ */
++int is_diropq(struct dentry *hidden_dentry, struct lkup_args *lkup)
++{
++ int err;
++ struct inode *hidden_dir;
++
++ LKTRTrace("dentry %.*s\n", DLNPair(hidden_dentry));
++ hidden_dir = hidden_dentry->d_inode;
++ DEBUG_ON(!S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ err = is_wh(hidden_dentry, &diropq_name, /*try_sio*/1, lkup);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns a negative dentry whose name is unique and temporary.
++ */
++struct dentry *lkup_whtmp(struct dentry *hidden_parent, struct qstr *prefix,
++ struct lkup_args *lkup)
++{
++#define HEX_LEN 4
++ struct dentry *dentry;
++ int len, i;
++ char defname[AUFS_WH_PFX_LEN * 2 + DNAME_INLINE_LEN_MIN + 1
++ + HEX_LEN + 1], *name, *p;
++ static unsigned char cnt;
++
++ LKTRTrace("hp %.*s, prefix %.*s\n",
++ DLNPair(hidden_parent), prefix->len, prefix->name);
++ DEBUG_ON(!hidden_parent->d_inode);
++ IMustLock(hidden_parent->d_inode);
++
++ name = defname;
++ len = sizeof(defname) - DNAME_INLINE_LEN_MIN + prefix->len - 1;
++ if (unlikely(prefix->len > DNAME_INLINE_LEN_MIN)) {
++ dentry = ERR_PTR(-ENAMETOOLONG);
++ if (unlikely(len >= PATH_MAX))
++ goto out;
++ dentry = ERR_PTR(-ENOMEM);
++ name = kmalloc(len + 1, GFP_KERNEL);
++ //if (LktrCond) {kfree(name); name = NULL;}
++ if (unlikely(!name))
++ goto out;
++ }
++
++ // doubly whiteout-ed
++ memcpy(name, AUFS_WH_PFX AUFS_WH_PFX, AUFS_WH_PFX_LEN * 2);
++ p = name + AUFS_WH_PFX_LEN * 2;
++ memcpy(p, prefix->name, prefix->len);
++ p += prefix->len;
++ *p++ = '.';
++ DEBUG_ON(name + len + 1 - p <= HEX_LEN);
++
++ for (i = 0; i < 3; i++) {
++ sprintf(p, "%.*d", HEX_LEN, cnt++);
++ dentry = sio_lkup_one(name, hidden_parent, len, lkup);
++ //if (LktrCond) {dput(dentry); dentry = ERR_PTR(-1);}
++ if (unlikely(IS_ERR(dentry) || !dentry->d_inode))
++ goto out_name;
++ dput(dentry);
++ }
++ //Warn("could not get random name\n");
++ dentry = ERR_PTR(-EEXIST);
++ Dbg("%.*s\n", len, name);
++ BUG();
++
++ out_name:
++ if (unlikely(name != defname))
++ kfree(name);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++#undef HEX_LEN
++}
++
++/*
++ * rename the @dentry of @bindex to the whiteouted temporary name.
++ */
++int rename_whtmp(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ int err;
++ struct inode *hidden_dir;
++ struct dentry *hidden_dentry, *hidden_parent, *tmp_dentry;
++ struct super_block *sb;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry || !hidden_dentry->d_inode);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ sb = dentry->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = need_dlgt(sb);
++ tmp_dentry = lkup_whtmp(hidden_parent, &hidden_dentry->d_name, &lkup);
++ //if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(tmp_dentry);
++ if (!IS_ERR(tmp_dentry)) {
++ /* under the same dir, no need to lock_rename() */
++ err = vfsub_rename(hidden_dir, hidden_dentry,
++ hidden_dir, tmp_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1; //unavailable
++ TraceErr(err);
++ dput(tmp_dentry);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_unlink_wh_dentry(struct inode *hidden_dir, struct dentry *wh_dentry,
++ struct dentry *dentry, int dlgt)
++{
++ int err;
++
++ LKTRTrace("hi%lu, wh %.*s, d %p\n", hidden_dir->i_ino,
++ DLNPair(wh_dentry), dentry);
++ DEBUG_ON((dentry && dbwh(dentry) == -1)
++ || !wh_dentry->d_inode
++ || !S_ISREG(wh_dentry->d_inode->i_mode));
++ IMustLock(hidden_dir);
++
++ err = vfsub_unlink(hidden_dir, wh_dentry, dlgt);
++ //if (LktrCond) err = -1; // unavailable
++ if (!err && dentry)
++ set_dbwh(dentry, -1);
++
++ TraceErr(err);
++ return err;
++}
++
++static int unlink_wh_name(struct dentry *hidden_parent, struct qstr *wh,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct inode *hidden_dir;
++ struct dentry *hidden_dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(hidden_parent), LNPair(wh));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ // au_test_perm() is already done
++ hidden_dentry = lkup_one(wh->name, hidden_parent, wh->len, lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ if (!IS_ERR(hidden_dentry)) {
++ err = 0;
++ if (hidden_dentry->d_inode)
++ err = vfsub_unlink(hidden_dir, hidden_dentry,
++ lkup->dlgt);
++ dput(hidden_dentry);
++ } else
++ err = PTR_ERR(hidden_dentry);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void clean_wh(struct inode *h_dir, struct dentry *wh)
++{
++ TraceEnter();
++ if (wh->d_inode) {
++ int err = vfsub_unlink(h_dir, wh, /*dlgt*/0);
++ if (unlikely(err))
++ Warn("failed unlink %.*s (%d), ignored.\n",
++ DLNPair(wh), err);
++ }
++}
++
++static void clean_plink(struct inode *h_dir, struct dentry *plink)
++{
++ TraceEnter();
++ if (plink->d_inode) {
++ int err = vfsub_rmdir(h_dir, plink, /*dlgt*/0);
++ if (unlikely(err))
++ Warn("failed rmdir %.*s (%d), ignored.\n",
++ DLNPair(plink), err);
++ }
++}
++
++static int test_linkable(struct inode *h_dir)
++{
++ if (h_dir->i_op && h_dir->i_op->link)
++ return 0;
++ return -ENOSYS;
++}
++
++static int plink_dir(struct inode *h_dir, struct dentry *plink)
++{
++ int err;
++
++ err = -EEXIST;
++ if (!plink->d_inode) {
++ int mode = S_IRWXU;
++ if (unlikely(au_is_nfs(plink->d_sb)))
++ mode |= S_IXUGO;
++ err = vfsub_mkdir(h_dir, plink, mode, /*dlgt*/0);
++ } else if (S_ISDIR(plink->d_inode->i_mode))
++ err = 0;
++ else
++ Err("unknown %.*s exists\n", DLNPair(plink));
++
++ return err;
++}
++
++/*
++ * initialize the whiteout base file/dir for @br.
++ */
++int init_wh(struct dentry *h_root, struct aufs_branch *br,
++ struct vfsmount *nfsmnt, struct super_block *sb)
++{
++ int err;
++ struct dentry *wh, *plink;
++ struct inode *h_dir;
++ static struct qstr base_name[] = {
++ {.name = AUFS_WH_BASENAME, .len = sizeof(AUFS_WH_BASENAME) - 1},
++ {.name = AUFS_WH_PLINKDIR, .len = sizeof(AUFS_WH_PLINKDIR) - 1}
++ };
++ struct lkup_args lkup = {
++ .nfsmnt = nfsmnt,
++ .dlgt = 0 // always no dlgt
++ };
++ const int do_plink = au_flag_test(sb, AuFlag_PLINK);
++
++ LKTRTrace("nfsmnt %p\n", nfsmnt);
++ BrWhMustWriteLock(br);
++ SiMustWriteLock(sb);
++ h_dir = h_root->d_inode;
++ IMustLock(h_dir);
++
++ // doubly whiteouted
++ wh = lkup_wh(h_root, base_name + 0, &lkup);
++ //if (LktrCond) {dput(wh); wh = ERR_PTR(-1);}
++ err = PTR_ERR(wh);
++ if (IS_ERR(wh))
++ goto out;
++ DEBUG_ON(br->br_wh && br->br_wh != wh);
++
++ plink = lkup_wh(h_root, base_name + 1, &lkup);
++ err = PTR_ERR(plink);
++ if (IS_ERR(plink))
++ goto out_dput_wh;
++ DEBUG_ON(br->br_plink && br->br_plink != plink);
++
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++
++ err = 0;
++ switch (br->br_perm) {
++ case AuBr_RR:
++ case AuBr_RO:
++ case AuBr_RRWH:
++ case AuBr_ROWH:
++ clean_wh(h_dir, wh);
++ clean_plink(h_dir, plink);
++ break;
++
++ case AuBr_RWNoLinkWH:
++ clean_wh(h_dir, wh);
++ if (do_plink) {
++ err = test_linkable(h_dir);
++ if (unlikely(err))
++ goto out_nolink;
++
++ err = plink_dir(h_dir, plink);
++ if (unlikely(err))
++ goto out_err;
++ br->br_plink = dget(plink);
++ } else
++ clean_plink(h_dir, plink);
++ break;
++
++ case AuBr_RW:
++ /*
++ * for the moment, aufs supports the branch filesystem
++ * which does not support link(2).
++ * testing on FAT which does not support i_op->setattr() fully either,
++ * copyup failed.
++ * finally, such filesystem will not be used as the writable branch.
++ */
++ err = test_linkable(h_dir);
++ if (unlikely(err))
++ goto out_nolink;
++
++ err = -EEXIST;
++ if (!wh->d_inode)
++ err = vfsub_create(h_dir, wh, WH_MASK, NULL, /*dlgt*/0);
++ else if (S_ISREG(wh->d_inode->i_mode))
++ err = 0;
++ else
++ Err("unknown %.*s/%.*s exists\n",
++ DLNPair(h_root), DLNPair(wh));
++ if (unlikely(err))
++ goto out_err;
++
++ if (do_plink) {
++ err = plink_dir(h_dir, plink);
++ if (unlikely(err))
++ goto out_err;
++ br->br_plink = dget(plink);
++ } else
++ clean_plink(h_dir, plink);
++ br->br_wh = dget(wh);
++ break;
++
++ default:
++ BUG();
++ }
++
++ out_dput:
++ dput(plink);
++ out_dput_wh:
++ dput(wh);
++ out:
++ TraceErr(err);
++ return err;
++ out_nolink:
++ Err("%.*s doesn't support link(2), use noplink and rw+nolwh\n",
++ DLNPair(h_root));
++ goto out_dput;
++ out_err:
++ Err("an error(%d) on the writable branch %.*s(%s)\n",
++ err, DLNPair(h_root), au_sbtype(h_root->d_sb));
++ goto out_dput;
++}
++
++struct reinit_br_wh {
++ struct super_block *sb;
++ struct aufs_branch *br;
++};
++
++static void reinit_br_wh(void *arg)
++{
++ int err;
++ struct reinit_br_wh *a = arg;
++ struct inode *hidden_dir, *dir;
++ struct dentry *hidden_root;
++ aufs_bindex_t bindex;
++
++ TraceEnter();
++ DEBUG_ON(!a->br->br_wh || !a->br->br_wh->d_inode || current->fsuid);
++
++ err = 0;
++ /* big lock */
++ si_write_lock(a->sb);
++ if (unlikely(!br_writable(a->br->br_perm)))
++ goto out;
++ bindex = find_brindex(a->sb, a->br->br_id);
++ if (unlikely(bindex < 0))
++ goto out;
++
++ dir = a->sb->s_root->d_inode;
++ hidden_root = a->br->br_wh->d_parent;
++ hidden_dir = hidden_root->d_inode;
++ DEBUG_ON(!hidden_dir->i_op || !hidden_dir->i_op->link);
++ hdir_lock(hidden_dir, dir, bindex);
++ br_wh_write_lock(a->br);
++ err = vfsub_unlink(hidden_dir, a->br->br_wh, /*dlgt*/0);
++ //if (LktrCond) err = -1;
++ dput(a->br->br_wh);
++ a->br->br_wh = NULL;
++ if (!err)
++ err = init_wh(hidden_root, a->br, au_do_nfsmnt(a->br->br_mnt),
++ a->sb);
++ br_wh_write_unlock(a->br);
++ hdir_unlock(hidden_dir, dir, bindex);
++
++ out:
++ atomic_dec(&a->br->br_wh_running);
++ br_put(a->br);
++ si_write_unlock(a->sb);
++ au_mntput(a->sb);
++ kfree(arg);
++ if (unlikely(err))
++ IOErr("err %d\n", err);
++}
++
++static void kick_reinit_br_wh(struct super_block *sb, struct aufs_branch *br)
++{
++ int do_dec;
++ struct reinit_br_wh *arg;
++
++ do_dec = 1;
++ if (atomic_inc_return(&br->br_wh_running) != 1)
++ goto out;
++
++ // ignore ENOMEM
++ arg = kmalloc(sizeof(*arg), GFP_KERNEL);
++ if (arg) {
++ // dec(wh_running), kfree(arg) and br_put() in reinit function
++ arg->sb = sb;
++ arg->br = br;
++ br_get(br);
++ /* prohibit umount */
++ au_mntget(sb);
++ au_wkq_nowait(reinit_br_wh, arg, /*dlgt*/0);
++ do_dec = 0;
++ }
++
++ out:
++ if (do_dec)
++ atomic_dec(&br->br_wh_running);
++}
++
++/*
++ * create the whiteoute @wh.
++ */
++static int link_or_create_wh(struct dentry *wh, struct super_block *sb,
++ aufs_bindex_t bindex)
++{
++ int err, dlgt;
++ struct aufs_branch *br;
++ struct dentry *hidden_parent;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%.*s\n", DLNPair(wh));
++ SiMustReadLock(sb);
++ hidden_parent = wh->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ dlgt = need_dlgt(sb);
++ br = stobr(sb, bindex);
++ br_wh_read_lock(br);
++ if (br->br_wh) {
++ err = vfsub_link(br->br_wh, hidden_dir, wh, dlgt);
++ if (!err || err != -EMLINK)
++ goto out;
++
++ // link count full. re-initialize br_wh.
++ kick_reinit_br_wh(sb, br);
++ }
++
++ // return this error in this context
++ err = vfsub_create(hidden_dir, wh, WH_MASK, NULL, dlgt);
++
++ out:
++ br_wh_read_unlock(br);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * create or remove the diropq.
++ */
++static struct dentry *do_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt)
++{
++ struct dentry *opq_dentry, *hidden_dentry;
++ struct inode *hidden_dir;
++ int err;
++ struct super_block *sb;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, bindex %d, do_create %d\n", DLNPair(dentry),
++ bindex, do_create);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_dir = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ // already checked by au_test_perm().
++ sb = dentry->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = dlgt;
++ opq_dentry = lkup_one(diropq_name.name, hidden_dentry, diropq_name.len,
++ &lkup);
++ //if (LktrCond) {dput(opq_dentry); opq_dentry = ERR_PTR(-1);}
++ if (IS_ERR(opq_dentry))
++ goto out;
++
++ if (do_create) {
++ DEBUG_ON(opq_dentry->d_inode);
++ err = link_or_create_wh(opq_dentry, sb, bindex);
++ //if (LktrCond) {vfs_unlink(hidden_dir, opq_dentry); err = -1;}
++ if (!err) {
++ set_dbdiropq(dentry, bindex);
++ goto out; /* success */
++ }
++ } else {
++ DEBUG_ON(/* !S_ISDIR(dentry->d_inode->i_mode)
++ * || */!opq_dentry->d_inode);
++ err = vfsub_unlink(hidden_dir, opq_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1;
++ if (!err)
++ set_dbdiropq(dentry, -1);
++ }
++ dput(opq_dentry);
++ opq_dentry = ERR_PTR(err);
++
++ out:
++ TraceErrPtr(opq_dentry);
++ return opq_dentry;
++}
++
++struct do_diropq_args {
++ struct dentry **errp;
++ struct dentry *dentry;
++ aufs_bindex_t bindex;
++ int do_create, dlgt;
++};
++
++static void call_do_diropq(void *args)
++{
++ struct do_diropq_args *a = args;
++ *a->errp = do_diropq(a->dentry, a->bindex, a->do_create, a->dlgt);
++}
++
++struct dentry *sio_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt)
++{
++ struct dentry *diropq, *hidden_dentry;
++
++ LKTRTrace("%.*s, bindex %d, do_create %d\n",
++ DLNPair(dentry), bindex, do_create);
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!au_test_perm(hidden_dentry->d_inode, MAY_EXEC | MAY_WRITE, dlgt))
++ diropq = do_diropq(dentry, bindex, do_create, dlgt);
++ else {
++ struct do_diropq_args args = {
++ .errp = &diropq,
++ .dentry = dentry,
++ .bindex = bindex,
++ .do_create = do_create,
++ .dlgt = dlgt
++ };
++ au_wkq_wait(call_do_diropq, &args, /*dlgt*/0);
++ }
++
++ TraceErrPtr(diropq);
++ return diropq;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * lookup whiteout dentry.
++ * @hidden_parent: hidden parent dentry which must exist and be locked
++ * @base_name: name of dentry which will be whiteouted
++ * returns dentry for whiteout.
++ */
++struct dentry *lkup_wh(struct dentry *hidden_parent, struct qstr *base_name,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct qstr wh_name;
++ struct dentry *wh_dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(hidden_parent), LNPair(base_name));
++ IMustLock(hidden_parent->d_inode);
++
++ err = au_alloc_whname(base_name->name, base_name->len, &wh_name);
++ //if (LktrCond) {au_free_whname(&wh_name); err = -1;}
++ wh_dentry = ERR_PTR(err);
++ if (!err) {
++ // do not superio.
++ wh_dentry = lkup_one(wh_name.name, hidden_parent, wh_name.len,
++ lkup);
++ au_free_whname(&wh_name);
++ }
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/*
++ * link/create a whiteout for @dentry on @bindex.
++ */
++struct dentry *simple_create_wh(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *hidden_parent,
++ struct lkup_args *lkup)
++{
++ struct dentry *wh_dentry;
++ int err;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s/%.*s on b%d\n", DLNPair(hidden_parent),
++ DLNPair(dentry), bindex);
++
++ sb = dentry->d_sb;
++ wh_dentry = lkup_wh(hidden_parent, &dentry->d_name, lkup);
++ //au_nfsmnt(sb, bindex), need_dlgt(sb));
++ //if (LktrCond) {dput(wh_dentry); wh_dentry = ERR_PTR(-1);}
++ if (!IS_ERR(wh_dentry) && !wh_dentry->d_inode) {
++ IMustLock(hidden_parent->d_inode);
++ err = link_or_create_wh(wh_dentry, sb, bindex);
++ if (!err)
++ set_dbwh(dentry, bindex);
++ else {
++ dput(wh_dentry);
++ wh_dentry = ERR_PTR(err);
++ }
++ }
++
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Delete all whiteouts in this directory in branch bindex. */
++static int del_wh_children(struct aufs_nhash *whlist,
++ struct dentry *hidden_parent, aufs_bindex_t bindex,
++ struct lkup_args *lkup)
++{
++ int err, i;
++ struct qstr wh_name;
++ char *p;
++ struct inode *hidden_dir;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", DLNPair(hidden_parent));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ DEBUG_ON(IS_RDONLY(hidden_dir));
++ //SiMustReadLock(??);
++
++ err = -ENOMEM;
++ wh_name.name = p = __getname();
++ //if (LktrCond) {__putname(p); wh_name.name = p = NULL;}
++ if (unlikely(!wh_name.name))
++ goto out;
++ memcpy(p, AUFS_WH_PFX, AUFS_WH_PFX_LEN);
++ p += AUFS_WH_PFX_LEN;
++
++ // already checked by au_test_perm().
++ err = 0;
++ for (i = 0; !err && i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash) {
++ if (tpos->wh_bindex != bindex)
++ continue;
++ str = &tpos->wh_str;
++ if (str->len + AUFS_WH_PFX_LEN <= PATH_MAX) {
++ memcpy(p, str->name, str->len);
++ wh_name.len = AUFS_WH_PFX_LEN + str->len;
++ err = unlink_wh_name(hidden_parent, &wh_name,
++ lkup);
++ //if (LktrCond) err = -1;
++ if (!err)
++ continue;
++ break;
++ }
++ IOErr("whiteout name too long %.*s\n",
++ str->len, str->name);
++ err = -EIO;
++ break;
++ }
++ }
++ __putname(wh_name.name);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct del_wh_children_args {
++ int *errp;
++ struct aufs_nhash *whlist;
++ struct dentry *hidden_parent;
++ aufs_bindex_t bindex;
++ struct lkup_args *lkup;
++};
++
++static void call_del_wh_children(void *args)
++{
++ struct del_wh_children_args *a = args;
++ *a->errp = del_wh_children(a->whlist, a->hidden_parent, a->bindex,
++ a->lkup);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * rmdir the whiteouted temporary named dir @hidden_dentry.
++ * @whlist: whiteouted children.
++ */
++int rmdir_whtmp(struct dentry *hidden_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir, struct inode *inode)
++{
++ int err;
++ struct inode *hidden_inode, *hidden_dir;
++ struct lkup_args lkup;
++ struct super_block *sb;
++
++ LKTRTrace("hd %.*s, b%d, i%lu\n",
++ DLNPair(hidden_dentry), bindex, dir->i_ino);
++ IMustLock(dir);
++ IiMustAnyLock(dir);
++ hidden_dir = hidden_dentry->d_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ sb = inode->i_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = need_dlgt(sb);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(hidden_inode != au_h_iptr_i(inode, bindex));
++ hdir2_lock(hidden_inode, inode, bindex);
++ if (!au_test_perm(hidden_inode, MAY_EXEC | MAY_WRITE, lkup.dlgt))
++ err = del_wh_children(whlist, hidden_dentry, bindex, &lkup);
++ else {
++ // ugly
++ int dlgt = lkup.dlgt;
++ struct del_wh_children_args args = {
++ .errp = &err,
++ .whlist = whlist,
++ .hidden_parent = hidden_dentry,
++ .bindex = bindex,
++ .lkup = &lkup
++ };
++
++ lkup.dlgt = 0;
++ au_wkq_wait(call_del_wh_children, &args, /*dlgt*/0);
++ lkup.dlgt = dlgt;
++ }
++ hdir_unlock(hidden_inode, inode, bindex);
++
++ if (!err) {
++ err = vfsub_rmdir(hidden_dir, hidden_dentry, lkup.dlgt);
++ //d_drop(hidden_dentry);
++ //if (LktrCond) err = -1;
++ }
++
++ if (!err) {
++ if (ibstart(dir) == bindex) {
++ au_cpup_attr_timesizes(dir);
++ //au_cpup_attr_nlink(dir);
++ dir->i_nlink--;
++ }
++ return 0; /* success */
++ }
++
++ Warn("failed removing %.*s(%d), ignored\n",
++ DLNPair(hidden_dentry), err);
++ return err;
++}
++
++static void do_rmdir_whtmp(void *arg)
++{
++ int err;
++ struct rmdir_whtmp_arg *a = arg;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, b%d, dir i%lu\n",
++ DLNPair(a->h_dentry), a->bindex, a->dir->i_ino);
++
++ i_lock(a->dir);
++ sb = a->dir->i_sb;
++ si_read_lock(sb);
++ err = test_ro(sb, a->bindex, NULL);
++ if (!err) {
++ struct inode *hidden_dir = a->h_dentry->d_parent->d_inode;
++
++ ii_write_lock_child(a->inode);
++ ii_write_lock_parent(a->dir);
++ hdir_lock(hidden_dir, a->dir, a->bindex);
++ err = rmdir_whtmp(a->h_dentry, &a->whlist, a->bindex,
++ a->dir, a->inode);
++ hdir_unlock(hidden_dir, a->dir, a->bindex);
++ ii_write_unlock(a->dir);
++ ii_write_unlock(a->inode);
++ }
++ dput(a->h_dentry);
++ nhash_fin(&a->whlist);
++ iput(a->inode);
++ si_read_unlock(sb);
++ au_mntput(sb);
++ i_unlock(a->dir);
++ iput(a->dir);
++ kfree(arg);
++ if (unlikely(err))
++ IOErr("err %d\n", err);
++}
++
++void kick_rmdir_whtmp(struct dentry *hidden_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir,
++ struct inode *inode, struct rmdir_whtmp_arg *arg)
++{
++ LKTRTrace("%.*s\n", DLNPair(hidden_dentry));
++ IMustLock(dir);
++
++ // all post-process will be done in do_rmdir_whtmp().
++ arg->h_dentry = dget(hidden_dentry);
++ nhash_init(&arg->whlist);
++ nhash_move(&arg->whlist, whlist);
++ arg->bindex = bindex;
++ arg->dir = igrab(dir);
++ arg->inode = igrab(inode);
++ /* prohibit umount */
++ au_mntget(dir->i_sb);
++
++ au_wkq_nowait(do_rmdir_whtmp, arg, /*dlgt*/0);
++}
+diff --git a/fs/aufs/whout.h b/fs/aufs/whout.h
+new file mode 100755
+index 0000000..d44c3cd
+--- /dev/null
++++ b/fs/aufs/whout.h
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: whout.h,v 1.8 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_WHOUT_H__
++#define __AUFS_WHOUT_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/aufs_type.h>
++
++int au_alloc_whname(const char *name, int len, struct qstr *wh);
++void au_free_whname(struct qstr *wh);
++
++struct lkup_args;
++int is_wh(struct dentry *h_parent, struct qstr *wh_name, int try_sio,
++ struct lkup_args *lkup);
++int is_diropq(struct dentry *h_dentry, struct lkup_args *lkup);
++
++struct dentry *lkup_whtmp(struct dentry *h_parent, struct qstr *prefix,
++ struct lkup_args *lkup);
++int rename_whtmp(struct dentry *dentry, aufs_bindex_t bindex);
++int au_unlink_wh_dentry(struct inode *h_dir, struct dentry *wh_dentry,
++ struct dentry *dentry, int dlgt);
++
++struct aufs_branch;
++int init_wh(struct dentry *h_parent, struct aufs_branch *br,
++ struct vfsmount *nfsmnt, struct super_block *sb);
++
++struct dentry *sio_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt);
++
++struct dentry *lkup_wh(struct dentry *h_parent, struct qstr *base_name,
++ struct lkup_args *lkup);
++struct dentry *simple_create_wh(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_parent,
++ struct lkup_args *lkup);
++
++/* real rmdir the whiteout-ed dir */
++struct rmdir_whtmp_arg {
++ struct dentry *h_dentry;
++ struct aufs_nhash whlist;
++ aufs_bindex_t bindex;
++ struct inode *dir, *inode;
++};
++
++struct aufs_nhash;
++int rmdir_whtmp(struct dentry *h_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir, struct inode *inode);
++void kick_rmdir_whtmp(struct dentry *h_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir,
++ struct inode *inode, struct rmdir_whtmp_arg *arg);
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++struct dentry *create_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int dlgt)
++{
++ return sio_diropq(dentry, bindex, 1, dlgt);
++}
++
++static inline
++int remove_diropq(struct dentry *dentry, aufs_bindex_t bindex, int dlgt)
++{
++ return PTR_ERR(sio_diropq(dentry, bindex, 0, dlgt));
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_WHOUT_H__ */
+diff --git a/fs/aufs/wkq.c b/fs/aufs/wkq.c
+new file mode 100755
+index 0000000..b5ab023
+--- /dev/null
++++ b/fs/aufs/wkq.c
+@@ -0,0 +1,283 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: wkq.c,v 1.14 2007/05/14 03:39:10 sfjro Exp $ */
++
++#include <linux/module.h>
++#include "aufs.h"
++
++struct au_wkq *au_wkq;
++
++struct au_cred {
++#ifdef CONFIG_AUFS_DLGT
++ uid_t fsuid;
++ gid_t fsgid;
++ kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
++ //unsigned keep_capabilities:1;
++ //struct user_struct *user;
++ //struct fs_struct *fs;
++ //struct nsproxy *nsproxy;
++#endif
++};
++
++struct au_wkinfo {
++ struct work_struct wk;
++
++ unsigned int wait:1;
++ unsigned int dlgt:1;
++ struct au_cred cred;
++
++ au_wkq_func_t func;
++ void *args;
++
++ atomic_t *busyp;
++ struct completion *comp;
++};
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++static void cred_store(struct au_cred *cred)
++{
++ cred->fsuid = current->fsuid;
++ cred->fsgid = current->fsgid;
++ cred->cap_effective = current->cap_effective;
++ cred->cap_inheritable = current->cap_inheritable;
++ cred->cap_permitted = current->cap_permitted;
++}
++
++static void cred_revert(struct au_cred *cred)
++{
++ DEBUG_ON(!is_au_wkq(current));
++ current->fsuid = cred->fsuid;
++ current->fsgid = cred->fsgid;
++ current->cap_effective = cred->cap_effective;
++ current->cap_inheritable = cred->cap_inheritable;
++ current->cap_permitted = cred->cap_permitted;
++}
++
++static void cred_switch(struct au_cred *old, struct au_cred *new)
++{
++ cred_store(old);
++ cred_revert(new);
++}
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++static void update_busy(struct au_wkq *wkq, struct au_wkinfo *wkinfo)
++{
++#ifdef CONFIG_AUFS_SYSAUFS
++ unsigned int new, old;
++
++ do {
++ new = atomic_read(wkinfo->busyp);
++ old = wkq->max_busy;
++ if (new <= old)
++ break;
++ } while (cmpxchg(&wkq->max_busy, old, new) == old);
++#endif
++}
++
++static int enqueue(struct au_wkq *wkq, struct au_wkinfo *wkinfo)
++{
++ wkinfo->busyp = &wkq->busy;
++ update_busy(wkq, wkinfo);
++ if (wkinfo->wait)
++ return !queue_work(wkq->q, &wkinfo->wk);
++ else
++ return !schedule_work(&wkinfo->wk);
++}
++
++static void do_wkq(struct au_wkinfo *wkinfo)
++{
++ unsigned int idle, n;
++ int i, idle_idx;
++
++ TraceEnter();
++
++ while (1) {
++ if (wkinfo->wait) {
++ idle_idx = 0;
++ idle = UINT_MAX;
++ for (i = 0; i < aufs_nwkq; i++) {
++ n = atomic_inc_return(&au_wkq[i].busy);
++ if (n == 1 && !enqueue(au_wkq + i, wkinfo))
++ return; /* success */
++
++ if (n < idle) {
++ idle_idx = i;
++ idle = n;
++ }
++ atomic_dec(&au_wkq[i].busy);
++ }
++ } else
++ idle_idx = aufs_nwkq;
++
++ atomic_inc(&au_wkq[idle_idx].busy);
++ if (!enqueue(au_wkq + idle_idx, wkinfo))
++ return; /* success */
++
++ /* impossible? */
++ Warn1("failed to queue_work()\n");
++ yield();
++ }
++}
++
++static AuWkqFunc(wkq_func, wk)
++{
++ struct au_wkinfo *wkinfo = container_of(wk, struct au_wkinfo, wk);
++
++ LKTRTrace("wkinfo{%u, %u, %p, %p, %p}\n",
++ wkinfo->wait, wkinfo->dlgt, wkinfo->func, wkinfo->busyp,
++ wkinfo->comp);
++#ifdef CONFIG_AUFS_DLGT
++ if (!wkinfo->dlgt)
++ wkinfo->func(wkinfo->args);
++ else {
++ struct au_cred cred;
++ cred_switch(&cred, &wkinfo->cred);
++ wkinfo->func(wkinfo->args);
++ cred_revert(&cred);
++ }
++#else
++ wkinfo->func(wkinfo->args);
++#endif
++ atomic_dec(wkinfo->busyp);
++ if (wkinfo->wait)
++ complete(wkinfo->comp);
++ else {
++ kfree(wkinfo);
++ module_put(THIS_MODULE);
++ }
++}
++
++void au_wkq_run(au_wkq_func_t func, void *args, int dlgt, int do_wait)
++{
++ DECLARE_COMPLETION_ONSTACK(comp);
++ struct au_wkinfo _wkinfo = {
++ .wait = 1,
++ .dlgt = !!dlgt,
++ .func = func,
++ .args = args,
++ .comp = &comp
++ }, *wkinfo = &_wkinfo;
++
++ LKTRTrace("dlgt %d, do_wait %d\n", dlgt, do_wait);
++ DEBUG_ON(is_au_wkq(current));
++
++ if (unlikely(!do_wait)) {
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ /*
++ * never fail.
++ * wkq_func() must free this wkinfo.
++ * it highly depends upon the implementation of workqueue.
++ */
++ wait_event(wq, (wkinfo = kmalloc(sizeof(*wkinfo), GFP_KERNEL)));
++ wkinfo->wait = 0;
++ wkinfo->dlgt = !!dlgt;
++ wkinfo->func = func;
++ wkinfo->args = args;
++ wkinfo->comp = NULL;
++ __module_get(THIS_MODULE);
++ }
++
++ AuInitWkq(&wkinfo->wk, wkq_func);
++#ifdef CONFIG_AUFS_DLGT
++ if (dlgt)
++ cred_store(&wkinfo->cred);
++#endif
++ do_wkq(wkinfo);
++ if (do_wait)
++ wait_for_completion(wkinfo->comp);
++}
++
++#if 0
++void au_wkq_wait_nwtask(void)
++{
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ wait_event(wq, !atomic_read(&au_wkq[aufs_nwkq].busy));
++}
++#endif
++
++void au_wkq_fin(void)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < aufs_nwkq; i++)
++ if (au_wkq[i].q && !IS_ERR(au_wkq[i].q))
++ destroy_workqueue(au_wkq[i].q);
++ kfree(au_wkq);
++}
++
++int __init au_wkq_init(void)
++{
++ int err, i;
++ struct au_wkq *nowaitq;
++
++ LKTRTrace("%d\n", aufs_nwkq);
++
++ /* '+1' is for accounting of nowait queue */
++ err = -ENOMEM;
++ au_wkq = kcalloc(aufs_nwkq + 1, sizeof(*au_wkq), GFP_KERNEL);
++ if (unlikely(!au_wkq))
++ goto out;
++
++ err = 0;
++ for (i = 0; i < aufs_nwkq; i++) {
++ au_wkq[i].q = create_singlethread_workqueue(AUFS_WKQ_NAME);
++ if (au_wkq[i].q && !IS_ERR(au_wkq[i].q)) {
++ atomic_set(&au_wkq[i].busy, 0);
++ au_wkq[i].max_busy = 0;
++ continue;
++ }
++
++ err = PTR_ERR(au_wkq[i].q);
++ au_wkq_fin();
++ break;
++ }
++
++ /* nowait accounting */
++ nowaitq = au_wkq + aufs_nwkq;
++ atomic_set(&nowaitq->busy, 0);
++ nowaitq->max_busy = 0;
++ nowaitq->q = NULL;
++
++#if 0 // test accouting
++ if (!err) {
++ static void f(void *args) {
++ DbgSleep(1);
++ }
++ int i;
++ //au_debug_on();
++ LKTRTrace("f %p\n", f);
++ for (i = 0; i < 10; i++)
++ au_wkq_nowait(f, NULL, 0);
++ for (i = 0; i < aufs_nwkq; i++)
++ au_wkq_wait(f, NULL, 0);
++ DbgSleep(11);
++ //au_debug_off();
++ }
++#endif
++
++ out:
++ TraceErr(err);
++ return err;
++}
+diff --git a/fs/aufs/wkq.h b/fs/aufs/wkq.h
+new file mode 100755
+index 0000000..cc1bb25
+--- /dev/null
++++ b/fs/aufs/wkq.h
+@@ -0,0 +1,81 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: wkq.h,v 1.9 2007/05/14 03:39:10 sfjro Exp $ */
++
++#ifndef __AUFS_WKQ_H__
++#define __AUFS_WKQ_H__
++
++#ifdef __KERNEL__
++
++#include <linux/sched.h>
++#include <linux/version.h>
++#include <linux/workqueue.h>
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* internal workqueue named AUFS_WKQ_NAME */
++struct au_wkq {
++ struct workqueue_struct *q;
++
++ /* accounting */
++ atomic_t busy;
++ unsigned int max_busy;
++} ;//__attribute__ ((aligned));
++
++typedef void (*au_wkq_func_t)(void *args);
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
++#define AuInitWkq(wk, func) INIT_WORK(wk, func)
++#define AuWkqFunc(name, arg) void name(struct work_struct *arg)
++#else
++typedef void (*work_func_t)(void *arg);
++#define AuInitWkq(wk, func) INIT_WORK(wk, func, wk)
++#define AuWkqFunc(name, arg) void name(void *arg)
++#endif
++
++extern struct au_wkq *au_wkq;
++
++void au_wkq_run(au_wkq_func_t func, void *args, int dlgt, int do_wait);
++//void au_wkq_wait_nwtask(void);
++int __init au_wkq_init(void);
++void au_wkq_fin(void);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int is_au_wkq(struct task_struct *tsk)
++{
++ return (!tsk->mm && !strcmp(current->comm, AUFS_WKQ_NAME));
++}
++
++static inline void au_wkq_wait(au_wkq_func_t func, void *args, int dlgt)
++{
++ au_wkq_run(func, args, dlgt, /*do_wait*/1);
++}
++
++static inline void au_wkq_nowait(au_wkq_func_t func, void *args, int dlgt)
++{
++ au_wkq_run(func, args, dlgt, /*do_wait*/0);
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_WKQ_H__ */
+diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c
+new file mode 100755
+index 0000000..145491e
+--- /dev/null
++++ b/fs/aufs/xino.c
+@@ -0,0 +1,644 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: xino.c,v 1.27 2007/05/14 03:39:10 sfjro Exp $ */
++
++//#include <linux/fs.h>
++#include <linux/fsnotify.h>
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++static readf_t find_readf(struct file *h_file)
++{
++ const struct file_operations *fop = h_file->f_op;
++
++ if (fop) {
++ if (fop->read)
++ return fop->read;
++ if (fop->aio_read)
++ return do_sync_read;
++ }
++ return ERR_PTR(-ENOSYS);
++}
++
++static writef_t find_writef(struct file *h_file)
++{
++ const struct file_operations *fop = h_file->f_op;
++
++ if (fop) {
++ if (fop->write)
++ return fop->write;
++ if (fop->aio_write)
++ return do_sync_write;
++ }
++ return ERR_PTR(-ENOSYS);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t xino_fread(readf_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ LKTRTrace("%.*s, sz %lu, *pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)size, *pos);
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ do {
++ err = func(file, (char __user*)buf, size, pos);
++ } while (err == -EAGAIN || err == -EINTR);
++ set_fs(oldfs);
++
++#if 0
++ if (err > 0)
++ fsnotify_access(file->f_dentry);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t do_xino_fwrite(writef_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ lockdep_off();
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ do {
++ err = func(file, (const char __user*)buf, size, pos);
++ } while (err == -EAGAIN || err == -EINTR);
++ set_fs(oldfs);
++ lockdep_on();
++
++#if 0
++ if (err > 0)
++ fsnotify_modify(file->f_dentry);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++struct do_xino_fwrite_args {
++ ssize_t *errp;
++ writef_t func;
++ struct file *file;
++ void *buf;
++ size_t size;
++ loff_t *pos;
++};
++
++static void call_do_xino_fwrite(void *args)
++{
++ struct do_xino_fwrite_args *a = args;
++ *a->errp = do_xino_fwrite(a->func, a->file, a->buf, a->size, a->pos);
++}
++
++static ssize_t xino_fwrite(writef_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, sz %lu, *pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)size, *pos);
++
++ // signal block and no wkq?
++ /*
++ * it breaks RLIMIT_FSIZE and normal user's limit,
++ * users should care about quota and real 'filesystem full.'
++ */
++ if (!is_au_wkq(current)) {
++ struct do_xino_fwrite_args args = {
++ .errp = &err,
++ .func = func,
++ .file = file,
++ .buf = buf,
++ .size = size,
++ .pos = pos
++ };
++ au_wkq_wait(call_do_xino_fwrite, &args, /*dlgt*/0);
++ } else
++ err = do_xino_fwrite(func, file, buf, size, pos);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * write @ino to the xinofile for the specified branch{@sb, @bindex}
++ * at the position of @_ino.
++ * when @ino is zero, it is written to the xinofile and means no entry.
++ */
++int xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino)
++{
++ struct aufs_branch *br;
++ loff_t pos;
++ ssize_t sz;
++
++ LKTRTrace("b%d, hi%lu, i%lu\n", bindex, h_ino, xino->ino);
++ //DEBUG_ON(!xino->ino /* || !xino->h_gen */);
++ //WARN_ON(bindex == 0 && h_ino == 31);
++
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ return 0;
++
++ br = stobr(sb, bindex);
++ DEBUG_ON(!br || !br->br_xino);
++ pos = h_ino * sizeof(*xino);
++ sz = xino_fwrite(br->br_xino_write, br->br_xino, xino, sizeof(*xino),
++ &pos);
++ //if (LktrCond) sz = 1;
++ if (sz == sizeof(*xino))
++ return 0; /* success */
++
++ IOErr("write failed (%ld)\n", (long)sz);
++ return -EIO;
++}
++
++int xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino)
++{
++ struct xino xino = {
++ .ino = 0
++ };
++ return xino_write(sb, bindex, h_ino, &xino);
++}
++
++// why is not atomic_long_inc_return defined?
++static DEFINE_SPINLOCK(alir_lock);
++static long atomic_long_inc_return(atomic_long_t *a)
++{
++ long l;
++
++ spin_lock(&alir_lock);
++ atomic_long_inc(a);
++ l = atomic_long_read(a);
++ spin_unlock(&alir_lock);
++ return l;
++}
++
++ino_t xino_new_ino(struct super_block *sb)
++{
++ ino_t ino;
++
++ TraceEnter();
++ ino = atomic_long_inc_return(&stosi(sb)->si_xino);
++ BUILD_BUG_ON(AUFS_FIRST_INO < AUFS_ROOT_INO);
++ if (ino >= AUFS_ROOT_INO)
++ return ino;
++ else {
++ atomic_long_dec(&stosi(sb)->si_xino);
++ IOErr1("inode number overflow\n");
++ return 0;
++ }
++}
++
++/*
++ * read @ino from xinofile for the specified branch{@sb, @bindex}
++ * at the position of @h_ino.
++ * if @ino does not exist and @do_new is true, get new one.
++ */
++int xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino)
++{
++ int err;
++ struct aufs_branch *br;
++ struct file *file;
++ loff_t pos;
++ ssize_t sz;
++
++ LKTRTrace("b%d, hi%lu\n", bindex, h_ino);
++
++ err = 0;
++ xino->ino = 0;
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ return 0; /* no ino */
++
++ br = stobr(sb, bindex);
++ file = br->br_xino;
++ DEBUG_ON(!file);
++ pos = h_ino * sizeof(*xino);
++ if (i_size_read(file->f_dentry->d_inode) < pos + sizeof(*xino))
++ return 0; /* no ino */
++
++ sz = xino_fread(br->br_xino_read, file, xino, sizeof(*xino), &pos);
++ if (sz == sizeof(*xino))
++ return 0; /* success */
++
++ err = sz;
++ if (unlikely(sz >= 0)) {
++ err = -EIO;
++ IOErr("xino read error (%ld)\n", (long)sz);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct file *xino_create(struct super_block *sb, char *fname, int silent,
++ struct dentry *parent)
++{
++ struct file *file;
++ int err;
++ struct dentry *hidden_parent;
++ struct inode *hidden_dir;
++ //const int udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++
++ LKTRTrace("%s\n", fname);
++ //DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++
++ // LSM may detect it
++ // use sio?
++ file = vfsub_filp_open(fname, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE,
++ S_IRUGO | S_IWUGO);
++ //file = ERR_PTR(-1);
++ if (IS_ERR(file)) {
++ if (!silent)
++ Err("open %s(%ld)\n", fname, PTR_ERR(file));
++ return file;
++ }
++#if 0
++ if (unlikely(udba && parent))
++ au_direval_dec(parent);
++#endif
++
++ /* keep file count */
++ hidden_parent = dget_parent(file->f_dentry);
++ hidden_dir = hidden_parent->d_inode;
++ hi_lock_parent(hidden_dir);
++ err = vfsub_unlink(hidden_dir, file->f_dentry, /*dlgt*/0);
++#if 0
++ if (unlikely(!err && udba && parent))
++ au_direval_dec(parent);
++#endif
++ i_unlock(hidden_dir);
++ dput(hidden_parent);
++ if (unlikely(err)) {
++ if (!silent)
++ Err("unlink %s(%d)\n", fname, err);
++ goto out;
++ }
++ if (sb != file->f_dentry->d_sb)
++ return file; /* success */
++
++ if (!silent)
++ Err("%s must be outside\n", fname);
++ err = -EINVAL;
++
++ out:
++ fput(file);
++ file = ERR_PTR(err);
++ return file;
++}
++
++/*
++ * find another branch who is on the same filesystem of the specified
++ * branch{@btgt}. search until @bend.
++ */
++static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt,
++ aufs_bindex_t bend)
++{
++ aufs_bindex_t bindex;
++ struct super_block *tgt_sb = sbr_sb(sb, btgt);
++
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(btgt != bindex && tgt_sb == sbr_sb(sb, bindex)))
++ return bindex;
++ return -1;
++}
++
++/*
++ * create a new xinofile at the same place/path as @base_file.
++ */
++static struct file *xino_create2(struct file *base_file)
++{
++ struct file *file;
++ int err;
++ struct dentry *base, *dentry, *parent;
++ struct inode *dir;
++ struct qstr *name;
++ struct lkup_args lkup = {
++ .nfsmnt = NULL,
++ .dlgt = 0
++ };
++
++ base = base_file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(base));
++ parent = dget_parent(base);
++ dir = parent->d_inode;
++ IMustLock(dir);
++
++ file = ERR_PTR(-EINVAL);
++ if (unlikely(au_is_nfs(parent->d_sb)))
++ goto out;
++
++ // do not superio, nor NFS.
++ name = &base->d_name;
++ dentry = lkup_one(name->name, parent, name->len, &lkup);
++ //if (LktrCond) {dput(dentry); dentry = ERR_PTR(-1);}
++ if (IS_ERR(dentry)) {
++ file = (void*)dentry;
++ Err("%.*s lookup err %ld\n", LNPair(name), PTR_ERR(dentry));
++ goto out;
++ }
++ err = vfsub_create(dir, dentry, S_IRUGO | S_IWUGO, NULL, /*dlgt*/0);
++ //if (LktrCond) {vfs_unlink(dir, dentry); err = -1;}
++ if (unlikely(err)) {
++ file = ERR_PTR(err);
++ Err("%.*s create err %d\n", LNPair(name), err);
++ goto out_dput;
++ }
++ file = dentry_open(dget(dentry), mntget(base_file->f_vfsmnt),
++ O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ if (IS_ERR(file)) {
++ Err("%.*s open err %ld\n", LNPair(name), PTR_ERR(file));
++ goto out_dput;
++ }
++ err = vfsub_unlink(dir, dentry, /*dlgt*/0);
++ //if (LktrCond) err = -1;
++ if (!err)
++ goto out_dput; /* success */
++
++ Err("%.*s unlink err %d\n", LNPair(name), err);
++ fput(file);
++ file = ERR_PTR(err);
++
++ out_dput:
++ dput(dentry);
++ out:
++ dput(parent);
++ TraceErrPtr(file);
++ return file;
++}
++
++/*
++ * initialize the xinofile for the specified branch{@sb, @bindex}
++ * at the place/path where @base_file indicates.
++ * test whether another branch is on the same filesystem or not,
++ * if @do_test is true.
++ */
++int xino_init(struct super_block *sb, aufs_bindex_t bindex,
++ struct file *base_file, int do_test)
++{
++ int err;
++ struct aufs_branch *br;
++ aufs_bindex_t bshared, bend;
++ struct file *file;
++ struct inode *inode, *hidden_inode;
++ struct xino xino;
++
++ LKTRTrace("b%d, base_file %p, do_test %d\n",
++ bindex, base_file, do_test);
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++ br = stobr(sb, bindex);
++ DEBUG_ON(br->br_xino);
++
++ file = NULL;
++ bshared = -1;
++ bend = sbend(sb);
++ if (do_test)
++ bshared = is_sb_shared(sb, bindex, bend);
++ if (unlikely(bshared >= 0)) {
++ struct aufs_branch *shared_br = stobr(sb, bshared);
++ if (shared_br->br_xino) {
++ file = shared_br->br_xino;
++ get_file(file);
++ }
++ }
++
++ if (!file) {
++ struct dentry *parent = dget_parent(base_file->f_dentry);
++ struct inode *dir = parent->d_inode;
++
++ hi_lock_parent(dir);
++ file = xino_create2(base_file);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ i_unlock(dir);
++ dput(parent);
++ err = PTR_ERR(file);
++ if (IS_ERR(file))
++ goto out;
++ }
++ br->br_xino_read = find_readf(file);
++ err = PTR_ERR(br->br_xino_read);
++ if (IS_ERR(br->br_xino_read))
++ goto out_put;
++ br->br_xino_write = find_writef(file);
++ err = PTR_ERR(br->br_xino_write);
++ if (IS_ERR(br->br_xino_write))
++ goto out_put;
++ br->br_xino = file;
++
++ inode = sb->s_root->d_inode;
++ hidden_inode = au_h_iptr_i(inode, bindex);
++ xino.ino = inode->i_ino;
++ //xino.h_gen = hidden_inode->i_generation;
++ //WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ err = xino_write(sb, bindex, hidden_inode->i_ino, &xino);
++ //if (LktrCond) err = -1;
++ if (!err)
++ return 0; /* success */
++
++ br->br_xino = NULL;
++
++ out_put:
++ fput(file);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * set xino mount option.
++ */
++int xino_set(struct super_block *sb, struct opt_xino *xino, int remount)
++{
++ int err, sparse;
++ aufs_bindex_t bindex, bend;
++ struct aufs_branch *br;
++ struct dentry *parent;
++ struct qstr *name;
++ struct file *cur_xino;
++ struct inode *dir;
++
++ LKTRTrace("%s\n", xino->path);
++
++ err = 0;
++ name = &xino->file->f_dentry->d_name;
++ parent = dget_parent(xino->file->f_dentry);
++ dir = parent->d_inode;
++ cur_xino = stobr(sb, 0)->br_xino;
++ if (remount
++ && cur_xino
++ && cur_xino->f_dentry->d_parent == parent
++ && name->len == cur_xino->f_dentry->d_name.len
++ && !memcmp(name->name, cur_xino->f_dentry->d_name.name, name->len))
++ goto out;
++
++ au_flag_set(sb, AuFlag_XINO);
++ bend = sbend(sb);
++ for (bindex = bend; bindex >= 0; bindex--) {
++ br = stobr(sb, bindex);
++ if (unlikely(br->br_xino && file_count(br->br_xino) > 1)) {
++ fput(br->br_xino);
++ br->br_xino = NULL;
++ }
++ }
++
++ for (bindex = 0; bindex <= bend; bindex++) {
++ struct file *file;
++ struct inode *inode;
++
++ br = stobr(sb, bindex);
++ if (unlikely(!br->br_xino))
++ continue;
++
++ DEBUG_ON(file_count(br->br_xino) != 1);
++ hi_lock_parent(dir);
++ file = xino_create2(xino->file);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ err = PTR_ERR(file);
++ if (IS_ERR(file)) {
++ i_unlock(dir);
++ break;
++ }
++ inode = br->br_xino->f_dentry->d_inode;
++ err = au_copy_file(file, br->br_xino, i_size_read(inode), sb,
++ &sparse);
++ //if (LktrCond) err = -1;
++ i_unlock(dir);
++ if (unlikely(err)) {
++ fput(file);
++ break;
++ }
++ fput(br->br_xino);
++ br->br_xino = file;
++ br->br_xino_read = find_readf(file);
++ DEBUG_ON(IS_ERR(br->br_xino_read));
++ br->br_xino_write = find_writef(file);
++ DEBUG_ON(IS_ERR(br->br_xino_write));
++ }
++
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(!stobr(sb, bindex)->br_xino)) {
++ err = xino_init(sb, bindex, xino->file, /*do_test*/1);
++ //if (LktrCond) {fput(stobr(sb, bindex)->br_xino);
++ //stobr(sb, bindex)->br_xino = NULL; err = -1;}
++ if (!err)
++ continue;
++ IOErr("creating xino for branch %d(%d), "
++ "forcing noxino\n", bindex, err);
++ err = -EIO;
++ break;
++ }
++ out:
++ dput(parent);
++ if (!err)
++ au_flag_set(sb, AuFlag_XINO);
++ else
++ au_flag_clr(sb, AuFlag_XINO);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * clear xino mount option
++ */
++int xino_clr(struct super_block *sb)
++{
++ aufs_bindex_t bindex, bend;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++) {
++ struct aufs_branch *br;
++ br = stobr(sb, bindex);
++ if (br->br_xino) {
++ fput(br->br_xino);
++ br->br_xino = NULL;
++ }
++ }
++
++ //todo: need to make iunique() to return the larger inode number
++
++ au_flag_clr(sb, AuFlag_XINO);
++ return 0;
++}
++
++/*
++ * create a xinofile at the default place/path.
++ */
++struct file *xino_def(struct super_block *sb)
++{
++ struct file *file;
++ aufs_bindex_t bend, bindex, bwr;
++ char *page, *p;
++
++ bend = sbend(sb);
++ bwr = -1;
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (br_writable(sbr_perm(sb, bindex))
++ && !au_is_nfs(au_h_dptr_i(sb->s_root, bindex)->d_sb)) {
++ bwr = bindex;
++ break;
++ }
++
++ if (bwr != -1) {
++ // todo: rewrite with lkup_one()
++ file = ERR_PTR(-ENOMEM);
++ page = __getname();
++ //if (LktrCond) {__putname(page); page = NULL;}
++ if (unlikely(!page))
++ goto out;
++ p = d_path(au_h_dptr_i(sb->s_root, bwr), sbr_mnt(sb, bwr), page,
++ PATH_MAX - sizeof(AUFS_XINO_FNAME));
++ //if (LktrCond) p = ERR_PTR(-1);
++ file = (void*)p;
++ if (p && !IS_ERR(p)) {
++ strcat(p, "/" AUFS_XINO_FNAME);
++ LKTRTrace("%s\n", p);
++ file = xino_create(sb, p, /*silent*/0, sb->s_root);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ }
++ __putname(page);
++ } else {
++ file = xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0,
++ /*parent*/NULL);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ }
++
++ out:
++ TraceErrPtr(file);
++ return file;
++}
+diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
+new file mode 100644
+index 0000000..1bc7b06
+--- /dev/null
++++ b/fs/squashfs/Makefile
+@@ -0,0 +1,7 @@
++#
++# Makefile for the linux squashfs routines.
++#
++
++obj-$(CONFIG_SQUASHFS) += squashfs.o
++squashfs-y += inode.o
++squashfs-y += squashfs2_0.o
+diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
+new file mode 100644
+index 0000000..895b699
+--- /dev/null
++++ b/fs/squashfs/inode.c
+@@ -0,0 +1,2329 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * inode.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++#include <linux/buffer_head.h>
++#include <linux/vfs.h>
++#include <linux/vmalloc.h>
++#include <linux/smp_lock.h>
++
++#include "squashfs.h"
++
++static void vfs_read_inode(struct inode *i);
++static struct dentry *squashfs_get_parent(struct dentry *child);
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode);
++static int squashfs_statfs(struct dentry *, struct kstatfs *);
++static int squashfs_symlink_readpage(struct file *file, struct page *page);
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize);
++static int squashfs_readpage(struct file *file, struct page *page);
++static int squashfs_readpage4K(struct file *file, struct page *page);
++static int squashfs_readdir(struct file *, void *, filldir_t);
++static struct dentry *squashfs_lookup(struct inode *, struct dentry *,
++ struct nameidata *);
++static int squashfs_remount(struct super_block *s, int *flags, char *data);
++static void squashfs_put_super(struct super_block *);
++static int squashfs_get_sb(struct file_system_type *,int, const char *, void *,
++ struct vfsmount *);
++static struct inode *squashfs_alloc_inode(struct super_block *sb);
++static void squashfs_destroy_inode(struct inode *inode);
++static int init_inodecache(void);
++static void destroy_inodecache(void);
++
++static struct file_system_type squashfs_fs_type = {
++ .owner = THIS_MODULE,
++ .name = "squashfs",
++ .get_sb = squashfs_get_sb,
++ .kill_sb = kill_block_super,
++ .fs_flags = FS_REQUIRES_DEV
++};
++
++static const unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static struct super_operations squashfs_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .remount_fs = squashfs_remount
++};
++
++static struct super_operations squashfs_export_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .read_inode = vfs_read_inode
++};
++
++static struct export_operations squashfs_export_ops = {
++ .get_parent = squashfs_get_parent
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_symlink_aops = {
++ .readpage = squashfs_symlink_readpage
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_aops = {
++ .readpage = squashfs_readpage
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_aops_4K = {
++ .readpage = squashfs_readpage4K
++};
++
++static const struct file_operations squashfs_dir_ops = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir
++};
++
++SQSH_EXTERN struct inode_operations squashfs_dir_inode_ops = {
++ .lookup = squashfs_lookup
++};
++
++
++static struct buffer_head *get_block_length(struct super_block *s,
++ int *cur_index, int *offset, int *c_byte)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned short temp;
++ struct buffer_head *bh;
++
++ if (!(bh = sb_bread(s, *cur_index)))
++ goto out;
++
++ if (msblk->devblksize - *offset == 1) {
++ if (msblk->swap)
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ else
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ if (msblk->swap)
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ bh->b_data);
++ else
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ bh->b_data);
++ *c_byte = temp;
++ *offset = 1;
++ } else {
++ if (msblk->swap) {
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ } else {
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ }
++ *c_byte = temp;
++ *offset += 2;
++ }
++
++ if (SQUASHFS_CHECK_DATA(msblk->sblk.flags)) {
++ if (*offset == msblk->devblksize) {
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ *offset = 0;
++ }
++ if (*((unsigned char *) (bh->b_data + *offset)) !=
++ SQUASHFS_MARKER_BYTE) {
++ ERROR("Metadata block marker corrupt @ %x\n",
++ *cur_index);
++ brelse(bh);
++ goto out;
++ }
++ (*offset)++;
++ }
++ return bh;
++
++out:
++ return NULL;
++}
++
++
++SQSH_EXTERN unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >>
++ msblk->devblksize_log2) + 2];
++ unsigned int offset = index & ((1 << msblk->devblksize_log2) - 1);
++ unsigned int cur_index = index >> msblk->devblksize_log2;
++ int bytes, avail_bytes, b = 0, k = 0;
++ unsigned int compressed;
++ unsigned int c_byte = length;
++
++ if (c_byte) {
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d, src size %d\n", index, compressed
++ ? "" : "un", (unsigned int) c_byte, srclength);
++
++ if (c_byte > srclength || index < 0 || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ if (!(bh[0] = sb_getblk(s, cur_index)))
++ goto block_release;
++
++ for (b = 1; bytes < c_byte; b++) {
++ if (!(bh[b] = sb_getblk(s, ++cur_index)))
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b, bh);
++ } else {
++ if (index < 0 || (index + 2) > sblk->bytes_used)
++ goto read_failure;
++
++ if (!(bh[0] = get_block_length(s, &cur_index, &offset,
++ &c_byte)))
++ goto read_failure;
++
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed
++ ? "" : "un", (unsigned int) c_byte);
++
++ if (c_byte > srclength || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ for (b = 1; bytes < c_byte; b++) {
++ if (!(bh[b] = sb_getblk(s, ++cur_index)))
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b - 1, bh + 1);
++ }
++
++ if (compressed) {
++ int zlib_err = 0;
++
++ /*
++ * uncompress block
++ */
++
++ mutex_lock(&msblk->read_data_mutex);
++
++ msblk->stream.next_out = buffer;
++ msblk->stream.avail_out = srclength;
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ?
++ msblk->devblksize - offset :
++ c_byte - bytes;
++ wait_on_buffer(bh[k]);
++ if (!buffer_uptodate(bh[k]))
++ goto release_mutex;
++
++ msblk->stream.next_in = bh[k]->b_data + offset;
++ msblk->stream.avail_in = avail_bytes;
++
++ if (k == 0) {
++ zlib_err = zlib_inflateInit(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateInit returned unexpected result 0x%x, srclength %d\n",
++ zlib_err, srclength);
++ goto release_mutex;
++ }
++
++ if (avail_bytes == 0) {
++ offset = 0;
++ brelse(bh[k]);
++ continue;
++ }
++ }
++
++ zlib_err = zlib_inflate(&msblk->stream, Z_NO_FLUSH);
++ if (zlib_err != Z_OK && zlib_err != Z_STREAM_END) {
++ ERROR("zlib_inflate returned unexpected result 0x%x, srclength %d, avail_in %d, avail_out %d\n",
++ zlib_err, srclength, msblk->stream.avail_in, msblk->stream.avail_out);
++ goto release_mutex;
++ }
++
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++
++ if (zlib_err != Z_STREAM_END)
++ goto release_mutex;
++
++ zlib_err = zlib_inflateEnd(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateEnd returned unexpected result 0x%x, srclength %d\n",
++ zlib_err, srclength);
++ goto release_mutex;
++ }
++ bytes = msblk->stream.total_out;
++ mutex_unlock(&msblk->read_data_mutex);
++ } else {
++ int i;
++
++ for(i = 0; i < b; i++) {
++ wait_on_buffer(bh[i]);
++ if(!buffer_uptodate(bh[i]))
++ goto block_release;
++ }
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ?
++ msblk->devblksize - offset :
++ c_byte - bytes;
++ memcpy(buffer + bytes, bh[k]->b_data + offset, avail_bytes);
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++ }
++
++ if (next_index)
++ *next_index = index + c_byte + (length ? 0 :
++ (SQUASHFS_CHECK_DATA(msblk->sblk.flags)
++ ? 3 : 2));
++ return bytes;
++
++release_mutex:
++ mutex_unlock(&msblk->read_data_mutex);
++
++block_release:
++ for (; k < b; k++)
++ brelse(bh[k]);
++
++read_failure:
++ ERROR("sb_bread failed reading block 0x%x\n", cur_index);
++ return 0;
++}
++
++
++SQSH_EXTERN int squashfs_get_cached_block(struct super_block *s, char *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ int n, i, bytes, return_length = length;
++ long long next_index;
++
++ TRACE("Entered squashfs_get_cached_block [%llx:%x]\n", block, offset);
++
++ while ( 1 ) {
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ if (msblk->block_cache[i].block == block)
++ break;
++
++ mutex_lock(&msblk->block_cache_mutex);
++
++ if (i == SQUASHFS_CACHED_BLKS) {
++ /* read inode header block */
++ for (i = msblk->next_cache, n = SQUASHFS_CACHED_BLKS;
++ n ; n --, i = (i + 1) %
++ SQUASHFS_CACHED_BLKS)
++ if (msblk->block_cache[i].block !=
++ SQUASHFS_USED_BLK)
++ break;
++
++ if (n == 0) {
++ wait_queue_t wait;
++
++ init_waitqueue_entry(&wait, current);
++ add_wait_queue(&msblk->waitq, &wait);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ mutex_unlock(&msblk->block_cache_mutex);
++ schedule();
++ set_current_state(TASK_RUNNING);
++ remove_wait_queue(&msblk->waitq, &wait);
++ continue;
++ }
++ msblk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
++
++ if (msblk->block_cache[i].block ==
++ SQUASHFS_INVALID_BLK) {
++ if (!(msblk->block_cache[i].data =
++ kmalloc(SQUASHFS_METADATA_SIZE,
++ GFP_KERNEL))) {
++ ERROR("Failed to allocate cache"
++ "block\n");
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++ }
++
++ msblk->block_cache[i].block = SQUASHFS_USED_BLK;
++ mutex_unlock(&msblk->block_cache_mutex);
++
++ msblk->block_cache[i].length = squashfs_read_data(s,
++ msblk->block_cache[i].data, block, 0, &next_index, SQUASHFS_METADATA_SIZE);
++ if (msblk->block_cache[i].length == 0) {
++ ERROR("Unable to read cache block [%llx:%x]\n",
++ block, offset);
++ mutex_lock(&msblk->block_cache_mutex);
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++ kfree(msblk->block_cache[i].data);
++ wake_up(&msblk->waitq);
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++
++ mutex_lock(&msblk->block_cache_mutex);
++ wake_up(&msblk->waitq);
++ msblk->block_cache[i].block = block;
++ msblk->block_cache[i].next_index = next_index;
++ TRACE("Read cache block [%llx:%x]\n", block, offset);
++ }
++
++ if (msblk->block_cache[i].block != block) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ continue;
++ }
++
++ bytes = msblk->block_cache[i].length - offset;
++
++ if (bytes < 1) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ } else if (bytes >= length) {
++ if (buffer)
++ memcpy(buffer, msblk->block_cache[i].data +
++ offset, length);
++ if (msblk->block_cache[i].length - offset == length) {
++ *next_block = msblk->block_cache[i].next_index;
++ *next_offset = 0;
++ } else {
++ *next_block = block;
++ *next_offset = offset + length;
++ }
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto finish;
++ } else {
++ if (buffer) {
++ memcpy(buffer, msblk->block_cache[i].data +
++ offset, bytes);
++ buffer += bytes;
++ }
++ block = msblk->block_cache[i].next_index;
++ mutex_unlock(&msblk->block_cache_mutex);
++ length -= bytes;
++ offset = 0;
++ }
++ }
++
++finish:
++ return return_length;
++out:
++ return 0;
++}
++
++
++static int get_fragment_location(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
++ struct squashfs_fragment_entry fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry,
++ start_block, offset,
++ sizeof(sfragment_entry), &start_block,
++ &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, (char *) &fragment_entry,
++ start_block, offset,
++ sizeof(fragment_entry), &start_block,
++ &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++SQSH_EXTERN void release_cached_fragment(struct squashfs_sb_info *msblk, struct
++ squashfs_fragment_cache *fragment)
++{
++ mutex_lock(&msblk->fragment_mutex);
++ fragment->locked --;
++ wake_up(&msblk->fragment_wait_queue);
++ mutex_unlock(&msblk->fragment_mutex);
++}
++
++
++SQSH_EXTERN struct squashfs_fragment_cache *get_cached_fragment(struct super_block
++ *s, long long start_block,
++ int length)
++{
++ int i, n;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ while ( 1 ) {
++ mutex_lock(&msblk->fragment_mutex);
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS &&
++ msblk->fragment[i].block != start_block; i++);
++
++ if (i == SQUASHFS_CACHED_FRAGMENTS) {
++ for (i = msblk->next_fragment, n =
++ SQUASHFS_CACHED_FRAGMENTS; n &&
++ msblk->fragment[i].locked; n--, i = (i + 1) %
++ SQUASHFS_CACHED_FRAGMENTS);
++
++ if (n == 0) {
++ wait_queue_t wait;
++
++ init_waitqueue_entry(&wait, current);
++ add_wait_queue(&msblk->fragment_wait_queue,
++ &wait);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ mutex_unlock(&msblk->fragment_mutex);
++ schedule();
++ set_current_state(TASK_RUNNING);
++ remove_wait_queue(&msblk->fragment_wait_queue,
++ &wait);
++ continue;
++ }
++ msblk->next_fragment = (msblk->next_fragment + 1) %
++ SQUASHFS_CACHED_FRAGMENTS;
++
++ if (msblk->fragment[i].data == NULL)
++ if (!(msblk->fragment[i].data = SQUASHFS_ALLOC
++ (SQUASHFS_FILE_MAX_SIZE))) {
++ ERROR("Failed to allocate fragment "
++ "cache block\n");
++ mutex_unlock(&msblk->fragment_mutex);
++ goto out;
++ }
++
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ msblk->fragment[i].locked = 1;
++ mutex_unlock(&msblk->fragment_mutex);
++
++ if (!(msblk->fragment[i].length = squashfs_read_data(s,
++ msblk->fragment[i].data,
++ start_block, length, NULL, sblk->block_size))) {
++ ERROR("Unable to read fragment cache block "
++ "[%llx]\n", start_block);
++ msblk->fragment[i].locked = 0;
++ smp_mb();
++ goto out;
++ }
++
++ mutex_lock(&msblk->fragment_mutex);
++ msblk->fragment[i].block = start_block;
++ TRACE("New fragment %d, start block %lld, locked %d\n",
++ i, msblk->fragment[i].block,
++ msblk->fragment[i].locked);
++ mutex_unlock(&msblk->fragment_mutex);
++ break;
++ }
++
++ msblk->fragment[i].locked++;
++ mutex_unlock(&msblk->fragment_mutex);
++ TRACE("Got fragment %d, start block %lld, locked %d\n", i,
++ msblk->fragment[i].block,
++ msblk->fragment[i].locked);
++ break;
++ }
++
++ return &msblk->fragment[i];
++
++out:
++ return NULL;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header *inodeb)
++{
++ i->i_ino = inodeb->inode_number;
++ i->i_mtime.tv_sec = inodeb->mtime;
++ i->i_atime.tv_sec = inodeb->mtime;
++ i->i_ctime.tv_sec = inodeb->mtime;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_size = 0;
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static squashfs_inode_t squashfs_inode_lookup(struct super_block *s, int ino)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start = msblk->inode_lookup_table[SQUASHFS_LOOKUP_BLOCK(ino - 1)];
++ int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino - 1);
++ squashfs_inode_t inode;
++
++ TRACE("Entered squashfs_inode_lookup, inode_number = %d\n", ino);
++
++ if (msblk->swap) {
++ squashfs_inode_t sinode;
++
++ if (!squashfs_get_cached_block(s, (char *) &sinode, start, offset,
++ sizeof(sinode), &start, &offset))
++ goto out;
++ SQUASHFS_SWAP_INODE_T((&inode), &sinode);
++ } else if (!squashfs_get_cached_block(s, (char *) &inode, start, offset,
++ sizeof(inode), &start, &offset))
++ goto out;
++
++ TRACE("squashfs_inode_lookup, inode = 0x%llx\n", inode);
++
++ return inode;
++
++out:
++ return SQUASHFS_INVALID_BLK;
++}
++
++
++static void vfs_read_inode(struct inode *i)
++{
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ squashfs_inode_t inode = squashfs_inode_lookup(i->i_sb, i->i_ino);
++
++ TRACE("Entered vfs_read_inode\n");
++
++ if(inode != SQUASHFS_INVALID_BLK)
++ (msblk->read_inode)(i, inode);
++}
++
++
++static struct dentry *squashfs_get_parent(struct dentry *child)
++{
++ struct inode *i = child->d_inode;
++ struct inode *parent = iget(i->i_sb, SQUASHFS_I(i)->u.s2.parent_inode);
++ struct dentry *rv;
++
++ TRACE("Entered squashfs_get_parent\n");
++
++ if(parent == NULL) {
++ rv = ERR_PTR(-EACCES);
++ goto out;
++ }
++
++ rv = d_alloc_anon(parent);
++ if(rv == NULL)
++ rv = ERR_PTR(-ENOMEM);
++
++out:
++ return rv;
++}
++
++
++SQSH_EXTERN struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode, unsigned int inode_number)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct inode *i = iget_locked(s, inode_number);
++
++ TRACE("Entered squashfs_iget\n");
++
++ if(i && (i->i_state & I_NEW)) {
++ (msblk->read_inode)(i, inode);
++ unlock_new_inode(i);
++ }
++
++ return i;
++}
++
++
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long block = SQUASHFS_INODE_BLK(inode) +
++ sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header id, sid;
++ struct squashfs_base_inode_header *inodeb = &id.base,
++ *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_read_inode\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *) sinodeb, block,
++ offset, sizeof(*sinodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER(inodeb, sinodeb,
++ sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, (char *) inodeb, block,
++ offset, sizeof(*inodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_reg_inode_header *inodep = &id.reg;
++ struct squashfs_reg_inode_header *sinodep = &sid.reg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_nlink = 1;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_LREG_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_lreg_inode_header *inodep = &id.lreg;
++ struct squashfs_lreg_inode_header *sinodep = &sid.lreg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LREG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header *inodep = &id.dir;
++ struct squashfs_dir_inode_header *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset =
++ next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count =
++ inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Long directory inode %x:%x, start_block %x, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header *inodep =
++ &id.symlink;
++ struct squashfs_symlink_inode_header *sinodep =
++ &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header *inodep = &id.dev;
++ struct squashfs_dev_inode_header *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type ==
++ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR :
++ S_IFBLK;
++ init_special_inode(i, i->i_mode,
++ old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++ struct squashfs_ipc_inode_header *inodep = &id.ipc;
++ struct squashfs_ipc_inode_header *sinodep = &sid.ipc;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_IPC_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%llx:%x]\n", block, offset);
++
++failed_read1:
++ make_bad_inode(i);
++ return 0;
++}
++
++
++static int read_inode_lookup_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(sblk->inodes);
++
++ TRACE("In read_inode_lookup_table, length %d\n", length);
++
++ /* Allocate inode lookup table */
++ if (!(msblk->inode_lookup_table = kmalloc(length, GFP_KERNEL))) {
++ ERROR("Failed to allocate inode lookup table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->inode_lookup_table,
++ sblk->lookup_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read inode lookup table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long block;
++
++ for (i = 0; i < SQUASHFS_LOOKUP_BLOCKS(sblk->inodes); i++) {
++ SQUASHFS_SWAP_LOOKUP_BLOCKS((&block),
++ &msblk->inode_lookup_table[i], 1);
++ msblk->inode_lookup_table[i] = block;
++ }
++ }
++
++ return 1;
++}
++
++
++static int read_fragment_index_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_FRAGMENT_INDEX_BYTES(sblk->fragments);
++
++ if(length == 0)
++ return 1;
++
++ /* Allocate fragment index table */
++ if (!(msblk->fragment_index = kmalloc(length, GFP_KERNEL))) {
++ ERROR("Failed to allocate fragment index table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->fragment_index,
++ sblk->fragment_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sblk->fragments); i++) {
++ SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment),
++ &msblk->fragment_index[i], 1);
++ msblk->fragment_index[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int supported_squashfs_filesystem(struct squashfs_sb_info *msblk, int silent)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode;
++ msblk->read_blocklist = read_blocklist;
++ msblk->read_fragment_index_table = read_fragment_index_table;
++
++ if (sblk->s_major == 1) {
++ if (!squashfs_1_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 1.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with "
++ "Squashfs 1.0 support enabled\n");
++ return 0;
++ }
++ } else if (sblk->s_major == 2) {
++ if (!squashfs_2_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 2.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with "
++ "Squashfs 2.0 support enabled\n");
++ return 0;
++ }
++ } else if(sblk->s_major != SQUASHFS_MAJOR || sblk->s_minor >
++ SQUASHFS_MINOR) {
++ SERROR("Major/Minor mismatch, trying to mount newer %d.%d "
++ "filesystem\n", sblk->s_major, sblk->s_minor);
++ SERROR("Please update your kernel\n");
++ return 0;
++ }
++
++ return 1;
++}
++
++
++static int squashfs_fill_super(struct super_block *s, void *data, int silent)
++{
++ struct squashfs_sb_info *msblk;
++ struct squashfs_super_block *sblk;
++ int i;
++ char b[BDEVNAME_SIZE];
++ struct inode *root;
++
++ TRACE("Entered squashfs_read_superblock\n");
++
++ if (!(s->s_fs_info = kmalloc(sizeof(struct squashfs_sb_info),
++ GFP_KERNEL))) {
++ ERROR("Failed to allocate superblock\n");
++ goto failure;
++ }
++ memset(s->s_fs_info, 0, sizeof(struct squashfs_sb_info));
++ msblk = s->s_fs_info;
++ if (!(msblk->stream.workspace = vmalloc(zlib_inflate_workspacesize()))) {
++ ERROR("Failed to allocate zlib workspace\n");
++ goto failure;
++ }
++ sblk = &msblk->sblk;
++
++ msblk->devblksize = sb_min_blocksize(s, BLOCK_SIZE);
++ msblk->devblksize_log2 = ffz(~msblk->devblksize);
++
++ mutex_init(&msblk->read_data_mutex);
++ mutex_init(&msblk->read_page_mutex);
++ mutex_init(&msblk->block_cache_mutex);
++ mutex_init(&msblk->fragment_mutex);
++ mutex_init(&msblk->meta_index_mutex);
++
++ init_waitqueue_head(&msblk->waitq);
++ init_waitqueue_head(&msblk->fragment_wait_queue);
++
++ sblk->bytes_used = sizeof(struct squashfs_super_block);
++ if (!squashfs_read_data(s, (char *) sblk, SQUASHFS_START,
++ sizeof(struct squashfs_super_block) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, sizeof(struct squashfs_super_block))) {
++ SERROR("unable to read superblock\n");
++ goto failed_mount;
++ }
++
++ /* Check it is a SQUASHFS superblock */
++ msblk->swap = 0;
++ if ((s->s_magic = sblk->s_magic) != SQUASHFS_MAGIC) {
++ if (sblk->s_magic == SQUASHFS_MAGIC_SWAP) {
++ struct squashfs_super_block ssblk;
++
++ WARNING("Mounting a different endian SQUASHFS "
++ "filesystem on %s\n", bdevname(s->s_bdev, b));
++
++ SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk);
++ memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block));
++ msblk->swap = 1;
++ } else {
++ SERROR("Can't find a SQUASHFS superblock on %s\n",
++ bdevname(s->s_bdev, b));
++ goto failed_mount;
++ }
++ }
++
++ /* Check the MAJOR & MINOR versions */
++ if(!supported_squashfs_filesystem(msblk, silent))
++ goto failed_mount;
++
++ /* Check the filesystem does not extend beyond the end of the
++ block device */
++ if(sblk->bytes_used < 0 || sblk->bytes_used > i_size_read(s->s_bdev->bd_inode))
++ goto failed_mount;
++
++ /* Check the root inode for sanity */
++ if (SQUASHFS_INODE_OFFSET(sblk->root_inode) > SQUASHFS_METADATA_SIZE)
++ goto failed_mount;
++
++ TRACE("Found valid superblock on %s\n", bdevname(s->s_bdev, b));
++ TRACE("Inodes are %scompressed\n",
++ SQUASHFS_UNCOMPRESSED_INODES
++ (sblk->flags) ? "un" : "");
++ TRACE("Data is %scompressed\n",
++ SQUASHFS_UNCOMPRESSED_DATA(sblk->flags)
++ ? "un" : "");
++ TRACE("Check data is %s present in the filesystem\n",
++ SQUASHFS_CHECK_DATA(sblk->flags) ?
++ "" : "not");
++ TRACE("Filesystem size %lld bytes\n", sblk->bytes_used);
++ TRACE("Block size %d\n", sblk->block_size);
++ TRACE("Number of inodes %d\n", sblk->inodes);
++ if (sblk->s_major > 1)
++ TRACE("Number of fragments %d\n", sblk->fragments);
++ TRACE("Number of uids %d\n", sblk->no_uids);
++ TRACE("Number of gids %d\n", sblk->no_guids);
++ TRACE("sblk->inode_table_start %llx\n", sblk->inode_table_start);
++ TRACE("sblk->directory_table_start %llx\n", sblk->directory_table_start);
++ if (sblk->s_major > 1)
++ TRACE("sblk->fragment_table_start %llx\n",
++ sblk->fragment_table_start);
++ TRACE("sblk->uid_start %llx\n", sblk->uid_start);
++
++ s->s_flags |= MS_RDONLY;
++ s->s_op = &squashfs_super_ops;
++
++ /* Init inode_table block pointer array */
++ if (!(msblk->block_cache = kmalloc(sizeof(struct squashfs_cache) *
++ SQUASHFS_CACHED_BLKS, GFP_KERNEL))) {
++ ERROR("Failed to allocate block cache\n");
++ goto failed_mount;
++ }
++
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++
++ msblk->next_cache = 0;
++
++ /* Allocate read_page block */
++ if (!(msblk->read_page = kmalloc(sblk->block_size, GFP_KERNEL))) {
++ ERROR("Failed to allocate read_page block\n");
++ goto failed_mount;
++ }
++
++ /* Allocate uid and gid tables */
++ if (!(msblk->uid = kmalloc((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int), GFP_KERNEL))) {
++ ERROR("Failed to allocate uid/gid table\n");
++ goto failed_mount;
++ }
++ msblk->guid = msblk->uid + sblk->no_uids;
++
++ if (msblk->swap) {
++ unsigned int suid[sblk->no_uids + sblk->no_guids];
++
++ if (!squashfs_read_data(s, (char *) &suid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++ SQUASHFS_SWAP_DATA(msblk->uid, suid, (sblk->no_uids +
++ sblk->no_guids), (sizeof(unsigned int) * 8));
++ } else
++ if (!squashfs_read_data(s, (char *) msblk->uid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++
++ if (sblk->s_major == 1 && squashfs_1_0_supported(msblk))
++ goto allocate_root;
++
++ if (!(msblk->fragment = kmalloc(sizeof(struct squashfs_fragment_cache) *
++ SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) {
++ ERROR("Failed to allocate fragment block cache\n");
++ goto failed_mount;
++ }
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) {
++ msblk->fragment[i].locked = 0;
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ msblk->fragment[i].data = NULL;
++ }
++
++ msblk->next_fragment = 0;
++
++ /* Allocate and read fragment index table */
++ if (msblk->read_fragment_index_table(s) == 0)
++ goto failed_mount;
++
++ if(sblk->s_major < 3 || sblk->lookup_table_start == SQUASHFS_INVALID_BLK)
++ goto allocate_root;
++
++ /* Allocate and read inode lookup table */
++ if (read_inode_lookup_table(s) == 0)
++ goto failed_mount;
++
++ s->s_op = &squashfs_export_super_ops;
++ s->s_export_op = &squashfs_export_ops;
++
++allocate_root:
++ root = new_inode(s);
++ if ((msblk->read_inode)(root, sblk->root_inode) == 0)
++ goto failed_mount;
++ insert_inode_hash(root);
++
++ if ((s->s_root = d_alloc_root(root)) == NULL) {
++ ERROR("Root inode create failed\n");
++ iput(root);
++ goto failed_mount;
++ }
++
++ TRACE("Leaving squashfs_read_super\n");
++ return 0;
++
++failed_mount:
++ kfree(msblk->inode_lookup_table);
++ kfree(msblk->fragment_index);
++ kfree(msblk->fragment);
++ kfree(msblk->uid);
++ kfree(msblk->read_page);
++ kfree(msblk->block_cache);
++ kfree(msblk->fragment_index_2);
++ vfree(msblk->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ return -EINVAL;
++
++failure:
++ return -ENOMEM;
++}
++
++
++static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
++{
++ struct squashfs_sb_info *msblk = dentry->d_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ TRACE("Entered squashfs_statfs\n");
++
++ buf->f_type = SQUASHFS_MAGIC;
++ buf->f_bsize = sblk->block_size;
++ buf->f_blocks = ((sblk->bytes_used - 1) >> sblk->block_log) + 1;
++ buf->f_bfree = buf->f_bavail = 0;
++ buf->f_files = sblk->inodes;
++ buf->f_ffree = 0;
++ buf->f_namelen = SQUASHFS_NAME_LEN;
++
++ return 0;
++}
++
++
++static int squashfs_symlink_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ int index = page->index << PAGE_CACHE_SHIFT, length, bytes;
++ long long block = SQUASHFS_I(inode)->start_block;
++ int offset = SQUASHFS_I(inode)->offset;
++ void *pageaddr = kmap(page);
++
++ TRACE("Entered squashfs_symlink_readpage, page index %ld, start block "
++ "%llx, offset %x\n", page->index,
++ SQUASHFS_I(inode)->start_block,
++ SQUASHFS_I(inode)->offset);
++
++ for (length = 0; length < index; length += bytes) {
++ if (!(bytes = squashfs_get_cached_block(inode->i_sb, NULL,
++ block, offset, PAGE_CACHE_SIZE, &block,
++ &offset))) {
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block,
++ offset);
++ goto skip_read;
++ }
++ }
++
++ if (length != index) {
++ ERROR("(squashfs_symlink_readpage) length != index\n");
++ bytes = 0;
++ goto skip_read;
++ }
++
++ bytes = (i_size_read(inode) - length) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE :
++ i_size_read(inode) - length;
++
++ if (!(bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block,
++ offset, bytes, &block, &offset)))
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block, offset);
++
++skip_read:
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap(page);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ return 0;
++}
++
++
++struct meta_index *locate_meta_index(struct inode *inode, int index, int offset)
++{
++ struct meta_index *meta = NULL;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("locate_meta_index: index %d, offset %d\n", index, offset);
++
++ if(msblk->meta_index == NULL)
++ goto not_allocated;
++
++ for (i = 0; i < SQUASHFS_META_NUMBER; i ++)
++ if (msblk->meta_index[i].inode_number == inode->i_ino &&
++ msblk->meta_index[i].offset >= offset &&
++ msblk->meta_index[i].offset <= index &&
++ msblk->meta_index[i].locked == 0) {
++ TRACE("locate_meta_index: entry %d, offset %d\n", i,
++ msblk->meta_index[i].offset);
++ meta = &msblk->meta_index[i];
++ offset = meta->offset;
++ }
++
++ if (meta)
++ meta->locked = 1;
++
++not_allocated:
++ mutex_unlock(&msblk->meta_index_mutex);
++
++ return meta;
++}
++
++
++struct meta_index *empty_meta_index(struct inode *inode, int offset, int skip)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct meta_index *meta = NULL;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("empty_meta_index: offset %d, skip %d\n", offset, skip);
++
++ if(msblk->meta_index == NULL) {
++ if (!(msblk->meta_index = kmalloc(sizeof(struct meta_index) *
++ SQUASHFS_META_NUMBER, GFP_KERNEL))) {
++ ERROR("Failed to allocate meta_index\n");
++ goto failed;
++ }
++ for(i = 0; i < SQUASHFS_META_NUMBER; i++) {
++ msblk->meta_index[i].inode_number = 0;
++ msblk->meta_index[i].locked = 0;
++ }
++ msblk->next_meta_index = 0;
++ }
++
++ for(i = SQUASHFS_META_NUMBER; i &&
++ msblk->meta_index[msblk->next_meta_index].locked; i --)
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ if(i == 0) {
++ TRACE("empty_meta_index: failed!\n");
++ goto failed;
++ }
++
++ TRACE("empty_meta_index: returned meta entry %d, %p\n",
++ msblk->next_meta_index,
++ &msblk->meta_index[msblk->next_meta_index]);
++
++ meta = &msblk->meta_index[msblk->next_meta_index];
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ meta->inode_number = inode->i_ino;
++ meta->offset = offset;
++ meta->skip = skip;
++ meta->entries = 0;
++ meta->locked = 1;
++
++failed:
++ mutex_unlock(&msblk->meta_index_mutex);
++ return meta;
++}
++
++
++void release_meta_index(struct inode *inode, struct meta_index *meta)
++{
++ meta->locked = 0;
++ smp_mb();
++}
++
++
++static int read_block_index(struct super_block *s, int blocks, char *block_list,
++ long long *start_block, int *offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned int *block_listp;
++ int block = 0;
++
++ if (msblk->swap) {
++ char sblock_list[blocks << 2];
++
++ if (!squashfs_get_cached_block(s, sblock_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Unable to read block list [%llx:%x]\n",
++ *start_block, *offset);
++ goto failure;
++ }
++ SQUASHFS_SWAP_INTS(((unsigned int *)block_list),
++ ((unsigned int *)sblock_list), blocks);
++ } else
++ if (!squashfs_get_cached_block(s, block_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Unable to read block list [%llx:%x]\n",
++ *start_block, *offset);
++ goto failure;
++ }
++
++ for (block_listp = (unsigned int *) block_list; blocks;
++ block_listp++, blocks --)
++ block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp);
++
++ return block;
++
++failure:
++ return -1;
++}
++
++
++#define SIZE 256
++
++static inline int calculate_skip(int blocks) {
++ int skip = (blocks - 1) / ((SQUASHFS_SLOTS * SQUASHFS_META_ENTRIES + 1) * SQUASHFS_META_INDEXES);
++ return skip >= 7 ? 7 : skip + 1;
++}
++
++
++static int get_meta_index(struct inode *inode, int index,
++ long long *index_block, int *index_offset,
++ long long *data_block, char *block_list)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int skip = calculate_skip(i_size_read(inode) >> sblk->block_log);
++ int offset = 0;
++ struct meta_index *meta;
++ struct meta_entry *meta_entry;
++ long long cur_index_block = SQUASHFS_I(inode)->u.s1.block_list_start;
++ int cur_offset = SQUASHFS_I(inode)->offset;
++ long long cur_data_block = SQUASHFS_I(inode)->start_block;
++ int i;
++
++ index /= SQUASHFS_META_INDEXES * skip;
++
++ while ( offset < index ) {
++ meta = locate_meta_index(inode, index, offset + 1);
++
++ if (meta == NULL) {
++ if ((meta = empty_meta_index(inode, offset + 1,
++ skip)) == NULL)
++ goto all_done;
++ } else {
++ if(meta->entries == 0)
++ goto failed;
++ offset = index < meta->offset + meta->entries ? index :
++ meta->offset + meta->entries - 1;
++ meta_entry = &meta->meta_entry[offset - meta->offset];
++ cur_index_block = meta_entry->index_block + sblk->inode_table_start;
++ cur_offset = meta_entry->offset;
++ cur_data_block = meta_entry->data_block;
++ TRACE("get_meta_index: offset %d, meta->offset %d, "
++ "meta->entries %d\n", offset, meta->offset,
++ meta->entries);
++ TRACE("get_meta_index: index_block 0x%llx, offset 0x%x"
++ " data_block 0x%llx\n", cur_index_block,
++ cur_offset, cur_data_block);
++ }
++
++ for (i = meta->offset + meta->entries; i <= index &&
++ i < meta->offset + SQUASHFS_META_ENTRIES; i++) {
++ int blocks = skip * SQUASHFS_META_INDEXES;
++
++ while (blocks) {
++ int block = blocks > (SIZE >> 2) ? (SIZE >> 2) :
++ blocks;
++ int res = read_block_index(inode->i_sb, block,
++ block_list, &cur_index_block,
++ &cur_offset);
++
++ if (res == -1)
++ goto failed;
++
++ cur_data_block += res;
++ blocks -= block;
++ }
++
++ meta_entry = &meta->meta_entry[i - meta->offset];
++ meta_entry->index_block = cur_index_block - sblk->inode_table_start;
++ meta_entry->offset = cur_offset;
++ meta_entry->data_block = cur_data_block;
++ meta->entries ++;
++ offset ++;
++ }
++
++ TRACE("get_meta_index: meta->offset %d, meta->entries %d\n",
++ meta->offset, meta->entries);
++
++ release_meta_index(inode, meta);
++ }
++
++all_done:
++ *index_block = cur_index_block;
++ *index_offset = cur_offset;
++ *data_block = cur_data_block;
++
++ return offset * SQUASHFS_META_INDEXES * skip;
++
++failed:
++ release_meta_index(inode, meta);
++ return -1;
++}
++
++
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize)
++{
++ long long block_ptr;
++ int offset;
++ long long block;
++ int res = get_meta_index(inode, index, &block_ptr, &offset, &block,
++ block_list);
++
++ TRACE("read_blocklist: res %d, index %d, block_ptr 0x%llx, offset"
++ " 0x%x, block 0x%llx\n", res, index, block_ptr, offset,
++ block);
++
++ if(res == -1)
++ goto failure;
++
++ index -= res;
++
++ while ( index ) {
++ int blocks = index > (SIZE >> 2) ? (SIZE >> 2) : index;
++ int res = read_block_index(inode->i_sb, blocks, block_list,
++ &block_ptr, &offset);
++ if (res == -1)
++ goto failure;
++ block += res;
++ index -= blocks;
++ }
++
++ if (read_block_index(inode->i_sb, 1, block_list,
++ &block_ptr, &offset) == -1)
++ goto failure;
++ *bsize = *((unsigned int *) block_list);
++
++ return block;
++
++failure:
++ return 0;
++}
++
++
++static int squashfs_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned char *block_list;
++ long long block;
++ unsigned int bsize, i = 0, bytes = 0, byte_offset = 0;
++ int index = page->index >> (sblk->block_log - PAGE_CACHE_SHIFT);
++ void *pageaddr;
++ struct squashfs_fragment_cache *fragment = NULL;
++ char *data_ptr = msblk->read_page;
++
++ int mask = (1 << (sblk->block_log - PAGE_CACHE_SHIFT)) - 1;
++ int start_index = page->index & ~mask;
++ int end_index = start_index | mask;
++
++ TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
++ page->index,
++ SQUASHFS_I(inode)->start_block);
++
++ if (!(block_list = kmalloc(SIZE, GFP_KERNEL))) {
++ ERROR("Failed to allocate block_list\n");
++ goto skip_read;
++ }
++
++ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
++ PAGE_CACHE_SHIFT))
++ goto skip_read;
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < (i_size_read(inode) >>
++ sblk->block_log)) {
++ if ((block = (msblk->read_blocklist)(inode, index, 1,
++ block_list, NULL, &bsize)) == 0)
++ goto skip_read;
++
++ mutex_lock(&msblk->read_page_mutex);
++
++ if (!(bytes = squashfs_read_data(inode->i_sb, msblk->read_page,
++ block, bsize, NULL, sblk->block_size))) {
++ ERROR("Unable to read page, block %llx, size %x\n", block,
++ bsize);
++ mutex_unlock(&msblk->read_page_mutex);
++ goto skip_read;
++ }
++ } else {
++ if ((fragment = get_cached_fragment(inode->i_sb,
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ SQUASHFS_I(inode)->u.s1.fragment_size))
++ == NULL) {
++ ERROR("Unable to read page, block %llx, size %x\n",
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ (int) SQUASHFS_I(inode)->
++ u.s1.fragment_size);
++ goto skip_read;
++ }
++ bytes = SQUASHFS_I(inode)->u.s1.fragment_offset +
++ (i_size_read(inode) & (sblk->block_size
++ - 1));
++ byte_offset = SQUASHFS_I(inode)->u.s1.fragment_offset;
++ data_ptr = fragment->data;
++ }
++
++ for (i = start_index; i <= end_index && byte_offset < bytes;
++ i++, byte_offset += PAGE_CACHE_SIZE) {
++ struct page *push_page;
++ int avail = (bytes - byte_offset) > PAGE_CACHE_SIZE ?
++ PAGE_CACHE_SIZE : bytes - byte_offset;
++
++ TRACE("bytes %d, i %d, byte_offset %d, available_bytes %d\n",
++ bytes, i, byte_offset, avail);
++
++ push_page = (i == page->index) ? page :
++ grab_cache_page_nowait(page->mapping, i);
++
++ if (!push_page)
++ continue;
++
++ if (PageUptodate(push_page))
++ goto skip_page;
++
++ pageaddr = kmap_atomic(push_page, KM_USER0);
++ memcpy(pageaddr, data_ptr + byte_offset, avail);
++ memset(pageaddr + avail, 0, PAGE_CACHE_SIZE - avail);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(push_page);
++ SetPageUptodate(push_page);
++skip_page:
++ unlock_page(push_page);
++ if(i != page->index)
++ page_cache_release(push_page);
++ }
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < (i_size_read(inode) >>
++ sblk->block_log))
++ mutex_unlock(&msblk->read_page_mutex);
++ else
++ release_cached_fragment(msblk, fragment);
++
++ kfree(block_list);
++ return 0;
++
++skip_read:
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ kfree(block_list);
++ return 0;
++}
++
++
++static int squashfs_readpage4K(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned char *block_list;
++ long long block;
++ unsigned int bsize, bytes = 0;
++ void *pageaddr;
++
++ TRACE("Entered squashfs_readpage4K, page index %lx, start block %llx\n",
++ page->index,
++ SQUASHFS_I(inode)->start_block);
++
++ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
++ PAGE_CACHE_SHIFT)) {
++ block_list = NULL;
++ goto skip_read;
++ }
++
++ if (!(block_list = kmalloc(SIZE, GFP_KERNEL))) {
++ ERROR("Failed to allocate block_list\n");
++ goto skip_read;
++ }
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || page->index < (i_size_read(inode) >>
++ sblk->block_log)) {
++ block = (msblk->read_blocklist)(inode, page->index, 1,
++ block_list, NULL, &bsize);
++ if(block == 0)
++ goto skip_read;
++
++ mutex_lock(&msblk->read_page_mutex);
++ bytes = squashfs_read_data(inode->i_sb, msblk->read_page, block,
++ bsize, NULL, sblk->block_size);
++ if (bytes) {
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memcpy(pageaddr, msblk->read_page, bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ } else
++ ERROR("Unable to read page, block %llx, size %x\n",
++ block, bsize);
++ mutex_unlock(&msblk->read_page_mutex);
++ } else {
++ struct squashfs_fragment_cache *fragment =
++ get_cached_fragment(inode->i_sb,
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ SQUASHFS_I(inode)-> u.s1.fragment_size);
++ if (fragment) {
++ bytes = i_size_read(inode) & (sblk->block_size - 1);
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memcpy(pageaddr, fragment->data + SQUASHFS_I(inode)->
++ u.s1.fragment_offset, bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ release_cached_fragment(msblk, fragment);
++ } else
++ ERROR("Unable to read page, block %llx, size %x\n",
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block, (int)
++ SQUASHFS_I(inode)-> u.s1.fragment_size);
++ }
++
++skip_read:
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ kfree(block_list);
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ f_pos =- 3;
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) &index,
++ index_start, index_offset,
++ sizeof(index), &index_start,
++ &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start,
++ &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length + 3;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ if (!(str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) index,
++ index_start, index_offset,
++ sizeof(struct squashfs_dir_index),
++ &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start,
++ index_offset, index->size + 1,
++ &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++failure:
++ return length + 3;
++}
++
++
++static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_readdir [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ while(file->f_pos < 3) {
++ char *name;
++ int size, i_ino;
++
++ if(file->f_pos == 0) {
++ name = ".";
++ size = 1;
++ i_ino = i->i_ino;
++ } else {
++ name = "..";
++ size = 2;
++ i_ino = SQUASHFS_I(i)->u.s2.parent_inode;
++ }
++ TRACE("Calling filldir(%x, %s, %d, %d, %d, %d)\n",
++ (unsigned int) dirent, name, size, (int)
++ file->f_pos, i_ino,
++ squashfs_filetype_table[1]);
++
++ if (filldir(dirent, name, size,
++ file->f_pos, i_ino,
++ squashfs_filetype_table[1]) < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos += size;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count,
++ file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block, next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block, next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset,
++ dire->size + 1, &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d, %d)\n",
++ (unsigned int) dirent, dire->name,
++ dire->size + 1, (int) file->f_pos,
++ dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1,
++ file->f_pos,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type])
++ < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_lookup [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_lookup;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_lookup;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name,
++ len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block,next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block,next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset, dire->size + 1,
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (name[0] < dire->name[0])
++ goto exit_lookup;
++
++ if ((len == dire->size + 1) && !strncmp(name, dire->name, len)) {
++ squashfs_inode_t ino = SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory "
++ "entry %s, inode %x:%x, %d\n", name,
++ dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number);
++
++ inode = squashfs_iget(i->i_sb, ino, dirh.inode_number + dire->inode_number);
++
++ goto exit_lookup;
++ }
++ }
++ }
++
++exit_lookup:
++ kfree(dire);
++ if (inode)
++ return d_splice_alias(inode, dentry);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_lookup;
++}
++
++
++static int squashfs_remount(struct super_block *s, int *flags, char *data)
++{
++ *flags |= MS_RDONLY;
++ return 0;
++}
++
++
++static void squashfs_put_super(struct super_block *s)
++{
++ int i;
++
++ if (s->s_fs_info) {
++ struct squashfs_sb_info *sbi = s->s_fs_info;
++ if (sbi->block_cache)
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ if (sbi->block_cache[i].block !=
++ SQUASHFS_INVALID_BLK)
++ kfree(sbi->block_cache[i].data);
++ if (sbi->fragment)
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++)
++ SQUASHFS_FREE(sbi->fragment[i].data);
++ kfree(sbi->fragment);
++ kfree(sbi->block_cache);
++ kfree(sbi->read_page);
++ kfree(sbi->uid);
++ kfree(sbi->fragment_index);
++ kfree(sbi->fragment_index_2);
++ kfree(sbi->meta_index);
++ vfree(sbi->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ }
++}
++
++
++static int squashfs_get_sb(struct file_system_type *fs_type, int flags,
++ const char *dev_name, void *data,
++ struct vfsmount *mnt)
++{
++ return get_sb_bdev(fs_type, flags, dev_name, data, squashfs_fill_super,
++ mnt);
++}
++
++
++static int __init init_squashfs_fs(void)
++{
++ int err = init_inodecache();
++ if (err)
++ goto out;
++
++ printk(KERN_INFO "squashfs: version 3.2-r2 (2007/01/15) "
++ "Phillip Lougher\n");
++
++ if ((err = register_filesystem(&squashfs_fs_type)))
++ destroy_inodecache();
++
++out:
++ return err;
++}
++
++
++static void __exit exit_squashfs_fs(void)
++{
++ unregister_filesystem(&squashfs_fs_type);
++ destroy_inodecache();
++}
++
++
++static struct kmem_cache * squashfs_inode_cachep;
++
++
++static struct inode *squashfs_alloc_inode(struct super_block *sb)
++{
++ struct squashfs_inode_info *ei;
++ ei = kmem_cache_alloc(squashfs_inode_cachep, GFP_KERNEL);
++ if (!ei)
++ return NULL;
++ return &ei->vfs_inode;
++}
++
++
++static void squashfs_destroy_inode(struct inode *inode)
++{
++ kmem_cache_free(squashfs_inode_cachep, SQUASHFS_I(inode));
++}
++
++
++static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
++{
++ struct squashfs_inode_info *ei = foo;
++
++ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
++ SLAB_CTOR_CONSTRUCTOR)
++ inode_init_once(&ei->vfs_inode);
++}
++
++
++static int __init init_inodecache(void)
++{
++ squashfs_inode_cachep = kmem_cache_create("squashfs_inode_cache",
++ sizeof(struct squashfs_inode_info),
++ 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
++ init_once, NULL);
++ if (squashfs_inode_cachep == NULL)
++ return -ENOMEM;
++ return 0;
++}
++
++
++static void destroy_inodecache(void)
++{
++ kmem_cache_destroy(squashfs_inode_cachep);
++}
++
++
++module_init(init_squashfs_fs);
++module_exit(exit_squashfs_fs);
++MODULE_DESCRIPTION("squashfs 3.2-r2, a compressed read-only filesystem");
++MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>");
++MODULE_LICENSE("GPL");
+diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
+new file mode 100644
+index 0000000..6f863f0
+--- /dev/null
++++ b/fs/squashfs/squashfs.h
+@@ -0,0 +1,87 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs.h
++ */
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#undef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#endif
++
++#ifdef SQUASHFS_TRACE
++#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
++#else
++#define TRACE(s, args...) {}
++#endif
++
++#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args)
++
++#define SERROR(s, args...) do { \
++ if (!silent) \
++ printk(KERN_ERR "SQUASHFS error: "s, ## args);\
++ } while(0)
++
++#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args)
++
++static inline struct squashfs_inode_info *SQUASHFS_I(struct inode *inode)
++{
++ return list_entry(inode, struct squashfs_inode_info, vfs_inode);
++}
++
++#if defined(CONFIG_SQUASHFS_1_0_COMPATIBILITY ) || defined(CONFIG_SQUASHFS_2_0_COMPATIBILITY)
++#define SQSH_EXTERN
++extern unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength);
++extern int squashfs_get_cached_block(struct super_block *s, char *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset);
++extern void release_cached_fragment(struct squashfs_sb_info *msblk, struct
++ squashfs_fragment_cache *fragment);
++extern struct squashfs_fragment_cache *get_cached_fragment(struct super_block
++ *s, long long start_block,
++ int length);
++extern struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode, unsigned int inode_number);
++extern const struct address_space_operations squashfs_symlink_aops;
++extern const struct address_space_operations squashfs_aops;
++extern const struct address_space_operations squashfs_aops_4K;
++extern struct inode_operations squashfs_dir_inode_ops;
++#else
++#define SQSH_EXTERN static
++#endif
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++extern int squashfs_1_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_1_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++extern int squashfs_2_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
+diff --git a/fs/squashfs/squashfs2_0.c b/fs/squashfs/squashfs2_0.c
+new file mode 100644
+index 0000000..d8d9d55
+--- /dev/null
++++ b/fs/squashfs/squashfs2_0.c
+@@ -0,0 +1,742 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs2_0.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++
++#include "squashfs.h"
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir);
++static struct dentry *squashfs_lookup_2(struct inode *, struct dentry *,
++ struct nameidata *);
++
++static struct file_operations squashfs_dir_ops_2 = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir_2
++};
++
++static struct inode_operations squashfs_dir_inode_ops_2 = {
++ .lookup = squashfs_lookup_2
++};
++
++static unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static int read_fragment_index_table_2(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ if (!(msblk->fragment_index_2 = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments), GFP_KERNEL))) {
++ ERROR("Failed to allocate uid/gid table\n");
++ return 0;
++ }
++
++ if (SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments) &&
++ !squashfs_read_data(s, (char *)
++ msblk->fragment_index_2,
++ sblk->fragment_table_start,
++ SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments))) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ unsigned int fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES_2(sblk->fragments);
++ i++) {
++ SQUASHFS_SWAP_FRAGMENT_INDEXES_2((&fragment),
++ &msblk->fragment_index_2[i], 1);
++ msblk->fragment_index_2[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int get_fragment_location_2(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index_2[SQUASHFS_FRAGMENT_INDEX_2(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET_2(fragment);
++ struct squashfs_fragment_entry_2 fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry_2 sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry,
++ start_block, offset,
++ sizeof(sfragment_entry), &start_block,
++ &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY_2(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, (char *) &fragment_entry,
++ start_block, offset,
++ sizeof(fragment_entry), &start_block,
++ &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header_2 *inodeb, unsigned int ino)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ i->i_ino = ino;
++ i->i_mtime.tv_sec = sblk->mkfs_time;
++ i->i_atime.tv_sec = sblk->mkfs_time;
++ i->i_ctime.tv_sec = sblk->mkfs_time;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_nlink = 1;
++ i->i_size = 0;
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static int squashfs_read_inode_2(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int block = SQUASHFS_INODE_BLK(inode) +
++ sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ unsigned int ino = i->i_ino;
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header_2 id, sid;
++ struct squashfs_base_inode_header_2 *inodeb = &id.base,
++ *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_iget\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *) sinodeb, block,
++ offset, sizeof(*sinodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(inodeb, sinodeb,
++ sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, (char *) inodeb, block,
++ offset, sizeof(*inodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb, ino);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ struct squashfs_reg_inode_header_2 *inodep = &id.reg;
++ struct squashfs_reg_inode_header_2 *sinodep = &sid.reg;
++ long long frag_blk;
++ unsigned int frag_size = 0;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location_2(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %x, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header_2 *inodep = &id.dir;
++ struct squashfs_dir_inode_header_2 *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header_2 *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header_2 *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset =
++ next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count =
++ inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Long directory inode %x:%x, start_block %x, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header_2 *inodep =
++ &id.symlink;
++ struct squashfs_symlink_inode_header_2 *sinodep =
++ &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header_2 *inodep = &id.dev;
++ struct squashfs_dev_inode_header_2 *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_mode |= (inodeb->inode_type ==
++ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR :
++ S_IFBLK;
++ init_special_inode(i, i->i_mode,
++ old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%x:%x]\n", block, offset);
++
++failed_read1:
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) &index,
++ index_start, index_offset,
++ sizeof(index), &index_start,
++ &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start,
++ &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ if (!(str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index_2 *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) index,
++ index_start, index_offset,
++ sizeof(struct squashfs_dir_index_2),
++ &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start,
++ index_offset, index->size + 1,
++ &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++failure:
++ return length;
++}
++
++
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++
++ TRACE("Entered squashfs_readdir_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count,
++ file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block, next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block, next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset,
++ dire->size + 1, &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n",
++ (unsigned int) dirent, dire->name,
++ dire->size + 1, (int) file->f_pos,
++ dirh.start_block, dire->offset,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1,
++ file->f_pos, SQUASHFS_MK_VFS_INODE(
++ dirh.start_block, dire->offset),
++ squashfs_filetype_table[dire->type])
++ < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup_2(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++ int sorted = sblk->s_major == 2 && sblk->s_minor >= 1;
++
++ TRACE("Entered squashfs_lookup_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_loop;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_loop;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name,
++ len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block,next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block,next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset, dire->size + 1,
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (sorted && name[0] < dire->name[0])
++ goto exit_loop;
++
++ if ((len == dire->size + 1) && !strncmp(name,
++ dire->name, len)) {
++ squashfs_inode_t ino =
++ SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++ unsigned int inode_number = SQUASHFS_MK_VFS_INODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory "
++ "entry %s, inode %x:%x, %lld\n", name,
++ dirh.start_block, dire->offset, ino);
++
++ inode = squashfs_iget(i->i_sb, ino, inode_number);
++
++ goto exit_loop;
++ }
++ }
++ }
++
++exit_loop:
++ kfree(dire);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_loop;
++}
++
++
++int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode_2;
++ msblk->read_fragment_index_table = read_fragment_index_table_2;
++
++ sblk->bytes_used = sblk->bytes_used_2;
++ sblk->uid_start = sblk->uid_start_2;
++ sblk->guid_start = sblk->guid_start_2;
++ sblk->inode_table_start = sblk->inode_table_start_2;
++ sblk->directory_table_start = sblk->directory_table_start_2;
++ sblk->fragment_table_start = sblk->fragment_table_start_2;
++
++ return 1;
++}
+diff --git a/include/linux/aufs_type.h b/include/linux/aufs_type.h
+new file mode 100755
+index 0000000..8b4629e
+--- /dev/null
++++ b/include/linux/aufs_type.h
+@@ -0,0 +1,97 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: aufs_type.h,v 1.55 2007/05/14 03:40:57 sfjro Exp $ */
++
++#include <linux/ioctl.h>
++
++#ifndef __AUFS_TYPE_H__
++#define __AUFS_TYPE_H__
++
++#define AUFS_VERSION "20070514"
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_BRANCH_MAX_127
++typedef char aufs_bindex_t;
++#define AUFS_BRANCH_MAX 127
++#else
++typedef short aufs_bindex_t;
++#ifdef CONFIG_AUFS_BRANCH_MAX_511
++#define AUFS_BRANCH_MAX 511
++#elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
++#define AUFS_BRANCH_MAX 1023
++#elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
++#define AUFS_BRANCH_MAX 32767
++#else
++#error unknown CONFIG_AUFS_BRANCH_MAX value
++#endif
++#endif
++
++#define AUFS_NAME "aufs"
++#define AUFS_FSTYPE AUFS_NAME
++
++#define AUFS_ROOT_INO 2
++#define AUFS_FIRST_INO 11
++
++#define AUFS_WH_PFX ".wh."
++#define AUFS_WH_PFX_LEN ((int)sizeof(AUFS_WH_PFX) - 1)
++#define AUFS_XINO_FNAME "." AUFS_NAME ".xino"
++#define AUFS_XINO_DEFPATH "/tmp/" AUFS_XINO_FNAME
++#define AUFS_DIRWH_DEF 3
++#define AUFS_RDCACHE_DEF 10 /* seconds */
++#define AUFS_WKQ_NAME AUFS_NAME "d"
++#define AUFS_NWKQ_DEF 4
++
++#ifdef CONFIG_AUFS_COMPAT
++#define AUFS_DIROPQ_NAME "__dir_opaque"
++#else
++#define AUFS_DIROPQ_NAME AUFS_WH_PFX ".opq" /* whiteouted doubly */
++#endif
++#define AUFS_WH_DIROPQ AUFS_WH_PFX AUFS_DIROPQ_NAME
++
++/* will be whiteouted doubly */
++#define AUFS_WH_BASENAME AUFS_WH_PFX AUFS_NAME
++#define AUFS_WH_PLINKDIR AUFS_WH_PFX "plink"
++
++/* ---------------------------------------------------------------------- */
++
++/* ioctl */
++enum {AuCtlErr, AuCtlErr_Last};
++enum {
++ AuCtl_REFRESH, //AuCtl_REFRESHV,
++ //AuCtl_FLUSH_PLINK,
++ //AuCtl_CPUP,
++ AuCtl_CPDOWN, AuCtl_MVDOWN
++};
++
++struct aufs_ctl_cp {
++ int bsrc, bdst;
++ int err;
++};
++
++#define Type 'A'
++#define AUFS_CTL_REFRESH _IO(Type, AuCtl_REFRESH)
++//#define AUFS_CTL_REFRESHV _IO(Type, AuCtl_REFRESHV)
++//#define AUFS_CTL_FLUSH_PLINK _IOR(Type, AuCtl_FLUSH_PLINK)
++//#define AUFS_CTL_CPUP _IOWR(Type, AuCtl_CPUP, struct aufs_ctl_cp)
++#define AUFS_CTL_CPDOWN _IOWR(Type, AuCtl_CPDOWN, struct aufs_ctl_cp)
++#define AUFS_CTL_MVDOWN _IOWR(Type, AuCtl_MVDOWN, struct aufs_ctl_cp)
++#undef Type
++
++#endif /* __AUFS_TYPE_H__ */
+diff --git a/include/linux/squashfs_fs.h b/include/linux/squashfs_fs.h
+new file mode 100644
+index 0000000..a9380ad
+--- /dev/null
++++ b/include/linux/squashfs_fs.h
+@@ -0,0 +1,934 @@
++#ifndef SQUASHFS_FS
++#define SQUASHFS_FS
++
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs.h
++ */
++
++#ifndef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#define CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#endif
++
++#ifdef CONFIG_SQUASHFS_VMALLOC
++#define SQUASHFS_ALLOC(a) vmalloc(a)
++#define SQUASHFS_FREE(a) vfree(a)
++#else
++#define SQUASHFS_ALLOC(a) kmalloc(a, GFP_KERNEL)
++#define SQUASHFS_FREE(a) kfree(a)
++#endif
++#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
++#define SQUASHFS_MAJOR 3
++#define SQUASHFS_MINOR 0
++#define SQUASHFS_MAGIC 0x73717368
++#define SQUASHFS_MAGIC_SWAP 0x68737173
++#define SQUASHFS_START 0
++
++/* size of metadata (inode and directory) blocks */
++#define SQUASHFS_METADATA_SIZE 8192
++#define SQUASHFS_METADATA_LOG 13
++
++/* default size of data blocks */
++#define SQUASHFS_FILE_SIZE 65536
++#define SQUASHFS_FILE_LOG 16
++
++#define SQUASHFS_FILE_MAX_SIZE 65536
++
++/* Max number of uids and gids */
++#define SQUASHFS_UIDS 256
++#define SQUASHFS_GUIDS 255
++
++/* Max length of filename (not 255) */
++#define SQUASHFS_NAME_LEN 256
++
++#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
++#define SQUASHFS_INVALID_FRAG ((unsigned int) 0xffffffff)
++#define SQUASHFS_INVALID_BLK ((long long) -1)
++#define SQUASHFS_USED_BLK ((long long) -2)
++
++/* Filesystem flags */
++#define SQUASHFS_NOI 0
++#define SQUASHFS_NOD 1
++#define SQUASHFS_CHECK 2
++#define SQUASHFS_NOF 3
++#define SQUASHFS_NO_FRAG 4
++#define SQUASHFS_ALWAYS_FRAG 5
++#define SQUASHFS_DUPLICATE 6
++#define SQUASHFS_EXPORT 7
++
++#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
++
++#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOI)
++
++#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOD)
++
++#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOF)
++
++#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NO_FRAG)
++
++#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_ALWAYS_FRAG)
++
++#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_DUPLICATE)
++
++#define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_EXPORT)
++
++#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_CHECK)
++
++#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, \
++ duplicate_checking, exortable) (noi | (nod << 1) | (check_data << 2) \
++ | (nof << 3) | (no_frag << 4) | (always_frag << 5) | \
++ (duplicate_checking << 6) | (exportable << 7))
++
++/* Max number of types and file types */
++#define SQUASHFS_DIR_TYPE 1
++#define SQUASHFS_FILE_TYPE 2
++#define SQUASHFS_SYMLINK_TYPE 3
++#define SQUASHFS_BLKDEV_TYPE 4
++#define SQUASHFS_CHRDEV_TYPE 5
++#define SQUASHFS_FIFO_TYPE 6
++#define SQUASHFS_SOCKET_TYPE 7
++#define SQUASHFS_LDIR_TYPE 8
++#define SQUASHFS_LREG_TYPE 9
++
++/* 1.0 filesystem type definitions */
++#define SQUASHFS_TYPES 5
++#define SQUASHFS_IPC_TYPE 0
++
++/* Flag whether block is compressed or uncompressed, bit is set if block is
++ * uncompressed */
++#define SQUASHFS_COMPRESSED_BIT (1 << 15)
++
++#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
++ (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
++
++#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
++
++#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
++
++#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & \
++ ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? (B) & \
++ ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
++
++#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
++
++/*
++ * Inode number ops. Inodes consist of a compressed block number, and an
++ * uncompressed offset within that block
++ */
++#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
++
++#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
++
++#define SQUASHFS_MKINODE(A, B) ((squashfs_inode_t)(((squashfs_inode_t) (A)\
++ << 16) + (B)))
++
++/* Compute 32 bit VFS inode number from squashfs inode number */
++#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + \
++ ((b) >> 2) + 1))
++/* XXX */
++
++/* Translate between VFS mode and squashfs mode */
++#define SQUASHFS_MODE(a) ((a) & 0xfff)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES(A) ((A) * sizeof(struct squashfs_fragment_entry))
++
++#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\
++ sizeof(long long))
++
++/* inode lookup table defines */
++#define SQUASHFS_LOOKUP_BYTES(A) ((A) * sizeof(squashfs_inode_t))
++
++#define SQUASHFS_LOOKUP_BLOCK(A) (SQUASHFS_LOOKUP_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_OFFSET(A) (SQUASHFS_LOOKUP_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCKS(A) ((SQUASHFS_LOOKUP_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_BYTES(A) (SQUASHFS_LOOKUP_BLOCKS(A) *\
++ sizeof(long long))
++
++/* cached data constants for filesystem */
++#define SQUASHFS_CACHED_BLKS 8
++
++#define SQUASHFS_MAX_FILE_SIZE_LOG 64
++
++#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << \
++ (SQUASHFS_MAX_FILE_SIZE_LOG - 2))
++
++#define SQUASHFS_MARKER_BYTE 0xff
++
++/* meta index cache */
++#define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int))
++#define SQUASHFS_META_ENTRIES 31
++#define SQUASHFS_META_NUMBER 8
++#define SQUASHFS_SLOTS 4
++
++struct meta_entry {
++ long long data_block;
++ unsigned int index_block;
++ unsigned short offset;
++ unsigned short pad;
++};
++
++struct meta_index {
++ unsigned int inode_number;
++ unsigned int offset;
++ unsigned short entries;
++ unsigned short skip;
++ unsigned short locked;
++ unsigned short pad;
++ struct meta_entry meta_entry[SQUASHFS_META_ENTRIES];
++};
++
++
++/*
++ * definitions for structures on disk
++ */
++
++typedef long long squashfs_block_t;
++typedef long long squashfs_inode_t;
++
++struct squashfs_super_block {
++ unsigned int s_magic;
++ unsigned int inodes;
++ unsigned int bytes_used_2;
++ unsigned int uid_start_2;
++ unsigned int guid_start_2;
++ unsigned int inode_table_start_2;
++ unsigned int directory_table_start_2;
++ unsigned int s_major:16;
++ unsigned int s_minor:16;
++ unsigned int block_size_1:16;
++ unsigned int block_log:16;
++ unsigned int flags:8;
++ unsigned int no_uids:8;
++ unsigned int no_guids:8;
++ unsigned int mkfs_time /* time of filesystem creation */;
++ squashfs_inode_t root_inode;
++ unsigned int block_size;
++ unsigned int fragments;
++ unsigned int fragment_table_start_2;
++ long long bytes_used;
++ long long uid_start;
++ long long guid_start;
++ long long inode_table_start;
++ long long directory_table_start;
++ long long fragment_table_start;
++ long long lookup_table_start;
++} __attribute__ ((packed));
++
++struct squashfs_dir_index {
++ unsigned int index;
++ unsigned int start_block;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++#define SQUASHFS_BASE_INODE_HEADER \
++ unsigned int inode_type:4; \
++ unsigned int mode:12; \
++ unsigned int uid:8; \
++ unsigned int guid:8; \
++ unsigned int mtime; \
++ unsigned int inode_number;
++
++struct squashfs_base_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_lreg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ long long file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int parent_inode;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int i_count:16;
++ unsigned int parent_inode;
++ struct squashfs_dir_index index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header {
++ struct squashfs_base_inode_header base;
++ struct squashfs_dev_inode_header dev;
++ struct squashfs_symlink_inode_header symlink;
++ struct squashfs_reg_inode_header reg;
++ struct squashfs_lreg_inode_header lreg;
++ struct squashfs_dir_inode_header dir;
++ struct squashfs_ldir_inode_header ldir;
++ struct squashfs_ipc_inode_header ipc;
++};
++
++struct squashfs_dir_entry {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ int inode_number:16;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_header {
++ unsigned int count:8;
++ unsigned int start_block;
++ unsigned int inode_number;
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry {
++ long long start_block;
++ unsigned int size;
++ unsigned int pending;
++} __attribute__ ((packed));
++
++extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
++extern int squashfs_uncompress_init(void);
++extern int squashfs_uncompress_exit(void);
++
++/*
++ * macros to convert each packed bitfield structure from little endian to big
++ * endian and vice versa. These are needed when creating or using a filesystem
++ * on a machine with different byte ordering to the target architecture.
++ *
++ */
++
++#define SQUASHFS_SWAP_START \
++ int bits;\
++ int b_pos;\
++ unsigned long long val;\
++ unsigned char *s;\
++ unsigned char *d;
++
++#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_super_block));\
++ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
++ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
++ SQUASHFS_SWAP((s)->bytes_used_2, d, 64, 32);\
++ SQUASHFS_SWAP((s)->uid_start_2, d, 96, 32);\
++ SQUASHFS_SWAP((s)->guid_start_2, d, 128, 32);\
++ SQUASHFS_SWAP((s)->inode_table_start_2, d, 160, 32);\
++ SQUASHFS_SWAP((s)->directory_table_start_2, d, 192, 32);\
++ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
++ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
++ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
++ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
++ SQUASHFS_SWAP((s)->flags, d, 288, 8);\
++ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
++ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
++ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
++ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
++ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
++ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
++ SQUASHFS_SWAP((s)->fragment_table_start_2, d, 472, 32);\
++ SQUASHFS_SWAP((s)->bytes_used, d, 504, 64);\
++ SQUASHFS_SWAP((s)->uid_start, d, 568, 64);\
++ SQUASHFS_SWAP((s)->guid_start, d, 632, 64);\
++ SQUASHFS_SWAP((s)->inode_table_start, d, 696, 64);\
++ SQUASHFS_SWAP((s)->directory_table_start, d, 760, 64);\
++ SQUASHFS_SWAP((s)->fragment_table_start, d, 824, 64);\
++ SQUASHFS_SWAP((s)->lookup_table_start, d, 888, 64);\
++}
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 64, 32);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ipc_inode_header))\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dev_inode_header)); \
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->rdev, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_symlink_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->symlink_size, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_reg_inode_header));\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 160, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 192, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 224, 32);\
++}
++
++#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_lreg_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 128, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 192, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 224, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 256, 64);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 147, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 160, 32);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 192, 32);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ldir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 155, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 168, 32);\
++ SQUASHFS_SWAP((s)->i_count, d, 200, 16);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 216, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index));\
++ SQUASHFS_SWAP((s)->index, d, 0, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 32, 32);\
++ SQUASHFS_SWAP((s)->size, d, 64, 8);\
++}
++
++#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 40, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++ SQUASHFS_SWAP((s)->inode_number, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 64);\
++ SQUASHFS_SWAP((s)->size, d, 64, 32);\
++}
++
++#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
++
++#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 2);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 16)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
++}
++
++#define SQUASHFS_SWAP_INTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 4);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 32)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
++}
++
++#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 64)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 64);\
++}
++
++#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * bits / 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ bits)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++
++struct squashfs_base_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int type:4;
++ unsigned int offset:4;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n) \
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 4);\
++ SQUASHFS_SWAP((s)->guid, d, 20, 4);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_ipc_inode_header_1));\
++ SQUASHFS_SWAP((s)->type, d, 24, 4);\
++ SQUASHFS_SWAP((s)->offset, d, 28, 4);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dev_inode_header_1));\
++ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_1));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_reg_inode_header_1));\
++ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 88, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dir_inode_header_1));\
++ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 43, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
++}
++
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++
++struct squashfs_dir_index_2 {
++ unsigned int index:27;
++ unsigned int start_block:29;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_base_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++ unsigned int i_count:16;
++ struct squashfs_dir_index_2 index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header_2 {
++ struct squashfs_base_inode_header_2 base;
++ struct squashfs_dev_inode_header_2 dev;
++ struct squashfs_symlink_inode_header_2 symlink;
++ struct squashfs_reg_inode_header_2 reg;
++ struct squashfs_dir_inode_header_2 dir;
++ struct squashfs_ldir_inode_header_2 ldir;
++ struct squashfs_ipc_inode_header_2 ipc;
++};
++
++struct squashfs_dir_header_2 {
++ unsigned int count:8;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_dir_entry_2 {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry_2 {
++ unsigned int start_block;
++ unsigned int size;
++} __attribute__ ((packed));
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_2(s, d) \
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, sizeof(struct squashfs_ipc_inode_header_2))
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dev_inode_header_2)); \
++ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_2));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_reg_inode_header_2));\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
++ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 128, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 160, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 51, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_ldir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 59, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
++ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index_2));\
++ SQUASHFS_SWAP((s)->index, d, 0, 27);\
++ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
++ SQUASHFS_SWAP((s)->size, d, 56, 8);\
++}
++#define SQUASHFS_SWAP_DIR_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header_2));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry_2));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry_2));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
++ SQUASHFS_SWAP((s)->size, d, 32, 32);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES_2(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES_2(A) (A * sizeof(struct squashfs_fragment_entry_2))
++
++#define SQUASHFS_FRAGMENT_INDEX_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES_2(A) ((SQUASHFS_FRAGMENT_BYTES_2(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES_2(A) (SQUASHFS_FRAGMENT_INDEXES_2(A) *\
++ sizeof(int))
++
++#endif
++
++#ifdef __KERNEL__
++
++/*
++ * macros used to swap each structure entry, taking into account
++ * bitfields and different bitfield placing conventions on differing
++ * architectures
++ */
++
++#include <asm/byteorder.h>
++
++#ifdef __BIG_ENDIAN
++ /* convert from little endian to big endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, b_pos)
++#else
++ /* convert from big endian to little endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, 64 - tbits - b_pos)
++#endif
++
++#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
++ b_pos = pos % 8;\
++ val = 0;\
++ s = (unsigned char *)p + (pos / 8);\
++ d = ((unsigned char *) &val) + 7;\
++ for(bits = 0; bits < (tbits + b_pos); bits += 8) \
++ *d-- = *s++;\
++ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
++}
++
++#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);
++
++#endif
++#endif
+diff --git a/include/linux/squashfs_fs_i.h b/include/linux/squashfs_fs_i.h
+new file mode 100644
+index 0000000..798891a
+--- /dev/null
++++ b/include/linux/squashfs_fs_i.h
+@@ -0,0 +1,45 @@
++#ifndef SQUASHFS_FS_I
++#define SQUASHFS_FS_I
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_i.h
++ */
++
++struct squashfs_inode_info {
++ long long start_block;
++ unsigned int offset;
++ union {
++ struct {
++ long long fragment_start_block;
++ unsigned int fragment_size;
++ unsigned int fragment_offset;
++ long long block_list_start;
++ } s1;
++ struct {
++ long long directory_index_start;
++ unsigned int directory_index_offset;
++ unsigned int directory_index_count;
++ unsigned int parent_inode;
++ } s2;
++ } u;
++ struct inode vfs_inode;
++};
++#endif
+diff --git a/include/linux/squashfs_fs_sb.h b/include/linux/squashfs_fs_sb.h
+new file mode 100644
+index 0000000..8f3bf99
+--- /dev/null
++++ b/include/linux/squashfs_fs_sb.h
+@@ -0,0 +1,74 @@
++#ifndef SQUASHFS_FS_SB
++#define SQUASHFS_FS_SB
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_sb.h
++ */
++
++#include <linux/squashfs_fs.h>
++
++struct squashfs_cache {
++ long long block;
++ int length;
++ long long next_index;
++ char *data;
++};
++
++struct squashfs_fragment_cache {
++ long long block;
++ int length;
++ unsigned int locked;
++ char *data;
++};
++
++struct squashfs_sb_info {
++ struct squashfs_super_block sblk;
++ int devblksize;
++ int devblksize_log2;
++ int swap;
++ struct squashfs_cache *block_cache;
++ struct squashfs_fragment_cache *fragment;
++ int next_cache;
++ int next_fragment;
++ int next_meta_index;
++ unsigned int *uid;
++ unsigned int *guid;
++ long long *fragment_index;
++ unsigned int *fragment_index_2;
++ char *read_page;
++ struct mutex read_data_mutex;
++ struct mutex read_page_mutex;
++ struct mutex block_cache_mutex;
++ struct mutex fragment_mutex;
++ struct mutex meta_index_mutex;
++ wait_queue_head_t waitq;
++ wait_queue_head_t fragment_wait_queue;
++ struct meta_index *meta_index;
++ z_stream stream;
++ long long *inode_lookup_table;
++ int (*read_inode)(struct inode *i, squashfs_inode_t \
++ inode);
++ long long (*read_blocklist)(struct inode *inode, int \
++ index, int readahead_blks, char *block_list, \
++ unsigned short **block_p, unsigned int *bsize);
++ int (*read_fragment_index_table)(struct super_block *s);
++};
++#endif
+diff --git a/init/Kconfig b/init/Kconfig
+index b170aa1..bcfc3b4 100644
+--- a/init/Kconfig
++++ b/init/Kconfig
+@@ -244,23 +244,21 @@ config AUDITSYSCALL
+ ensure that INOTIFY is configured.
+
+ config IKCONFIG
+- tristate "Kernel .config support"
++ tristate "Kernel .miniconfig support"
+ ---help---
+- This option enables the complete Linux kernel ".config" file
++ This option enables the mini Linux kernel ".miniconfig" file
+ contents to be saved in the kernel. It provides documentation
+ of which kernel options are used in a running kernel or in an
+- on-disk kernel. This information can be extracted from the kernel
+- image file with the script scripts/extract-ikconfig and used as
+- input to rebuild the current kernel or to build another kernel.
+- It can also be extracted from a running kernel by reading
+- /proc/config.gz if enabled (below).
++ on-disk kernel.
++ It can be extracted from a running kernel by reading
++ /proc/miniconfig.gz if enabled (below).
+
+ config IKCONFIG_PROC
+- bool "Enable access to .config through /proc/config.gz"
++ bool "Enable access to .miniconfig through /proc/miniconfig.gz"
+ depends on IKCONFIG && PROC_FS
+ ---help---
+ This option enables access to the kernel configuration file
+- through /proc/config.gz.
++ through /proc/miniconfig.gz.
+
+ config CPUSETS
+ bool "Cpuset support"
+diff --git a/init/LzmaDecode.c b/init/LzmaDecode.c
+new file mode 100644
+index 0000000..21bf40b
+--- /dev/null
++++ b/init/LzmaDecode.c
+@@ -0,0 +1,588 @@
++/*
++ LzmaDecode.c
++ LZMA Decoder (optimized for Speed version)
++
++ LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this Code, expressly permits you to
++ statically or dynamically link your Code (or bind by name) to the
++ interfaces of this file without subjecting your linked Code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#include "LzmaDecode.h"
++
++#ifndef Byte
++#define Byte unsigned char
++#endif
++
++#define kNumTopBits 24
++#define kTopValue ((UInt32)1 << kNumTopBits)
++
++#define kNumBitModelTotalBits 11
++#define kBitModelTotal (1 << kNumBitModelTotalBits)
++#define kNumMoveBits 5
++
++#define RC_READ_BYTE (*Buffer++)
++
++#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
++ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
++
++#ifdef _LZMA_IN_CB
++
++#define RC_TEST { if (Buffer == BufferLim) \
++ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
++ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
++
++#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
++
++#else
++
++#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
++
++#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
++
++#endif
++
++#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
++
++#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
++#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
++#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
++
++#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
++ { UpdateBit0(p); mi <<= 1; A0; } else \
++ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
++
++#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
++
++#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
++ { int i = numLevels; res = 1; \
++ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
++ res -= (1 << numLevels); }
++
++
++#define kNumPosBitsMax 4
++#define kNumPosStatesMax (1 << kNumPosBitsMax)
++
++#define kLenNumLowBits 3
++#define kLenNumLowSymbols (1 << kLenNumLowBits)
++#define kLenNumMidBits 3
++#define kLenNumMidSymbols (1 << kLenNumMidBits)
++#define kLenNumHighBits 8
++#define kLenNumHighSymbols (1 << kLenNumHighBits)
++
++#define LenChoice 0
++#define LenChoice2 (LenChoice + 1)
++#define LenLow (LenChoice2 + 1)
++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
++#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
++
++
++#define kNumStates 12
++#define kNumLitStates 7
++
++#define kStartPosModelIndex 4
++#define kEndPosModelIndex 14
++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
++
++#define kNumPosSlotBits 6
++#define kNumLenToPosStates 4
++
++#define kNumAlignBits 4
++#define kAlignTableSize (1 << kNumAlignBits)
++
++#define kMatchMinLen 2
++
++#define IsMatch 0
++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
++#define IsRepG0 (IsRep + kNumStates)
++#define IsRepG1 (IsRepG0 + kNumStates)
++#define IsRepG2 (IsRepG1 + kNumStates)
++#define IsRep0Long (IsRepG2 + kNumStates)
++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
++#define LenCoder (Align + kAlignTableSize)
++#define RepLenCoder (LenCoder + kNumLenProbs)
++#define Literal (RepLenCoder + kNumLenProbs)
++
++#if Literal != LZMA_BASE_SIZE
++StopCompilingDueBUG
++#endif
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
++{
++ unsigned char prop0;
++ if (size < LZMA_PROPERTIES_SIZE)
++ return LZMA_RESULT_DATA_ERROR;
++ prop0 = propsData[0];
++ if (prop0 >= (9 * 5 * 5))
++ return LZMA_RESULT_DATA_ERROR;
++ {
++ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
++ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
++ propsRes->lc = prop0;
++ /*
++ unsigned char remainder = (unsigned char)(prop0 / 9);
++ propsRes->lc = prop0 % 9;
++ propsRes->pb = remainder / 5;
++ propsRes->lp = remainder % 5;
++ */
++ }
++
++ #ifdef _LZMA_OUT_READ
++ {
++ int i;
++ propsRes->DictionarySize = 0;
++ for (i = 0; i < 4; i++)
++ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
++ if (propsRes->DictionarySize == 0)
++ propsRes->DictionarySize = 1;
++ }
++ #endif
++ return LZMA_RESULT_OK;
++}
++
++#define kLzmaStreamWasFinishedId (-1)
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *InCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
++{
++ CProb *p = vs->Probs;
++ SizeT nowPos = 0;
++ Byte previousByte = 0;
++ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
++ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
++ int lc = vs->Properties.lc;
++
++ #ifdef _LZMA_OUT_READ
++
++ UInt32 Range = vs->Range;
++ UInt32 Code = vs->Code;
++ #ifdef _LZMA_IN_CB
++ const Byte *Buffer = vs->Buffer;
++ const Byte *BufferLim = vs->BufferLim;
++ #else
++ const Byte *Buffer = inStream;
++ const Byte *BufferLim = inStream + inSize;
++ #endif
++ int state = vs->State;
++ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
++ int len = vs->RemainLen;
++ UInt32 globalPos = vs->GlobalPos;
++ UInt32 distanceLimit = vs->DistanceLimit;
++
++ Byte *dictionary = vs->Dictionary;
++ UInt32 dictionarySize = vs->Properties.DictionarySize;
++ UInt32 dictionaryPos = vs->DictionaryPos;
++
++ Byte tempDictionary[4];
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++ if (len == kLzmaStreamWasFinishedId)
++ return LZMA_RESULT_OK;
++
++ if (dictionarySize == 0)
++ {
++ dictionary = tempDictionary;
++ dictionarySize = 1;
++ tempDictionary[0] = vs->TempDictionary[0];
++ }
++
++ if (len == kLzmaNeedInitId)
++ {
++ {
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ UInt32 i;
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ rep0 = rep1 = rep2 = rep3 = 1;
++ state = 0;
++ globalPos = 0;
++ distanceLimit = 0;
++ dictionaryPos = 0;
++ dictionary[dictionarySize - 1] = 0;
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++ }
++ len = 0;
++ }
++ while(len != 0 && nowPos < outSize)
++ {
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ len--;
++ }
++ if (dictionaryPos == 0)
++ previousByte = dictionary[dictionarySize - 1];
++ else
++ previousByte = dictionary[dictionaryPos - 1];
++
++ #else /* if !_LZMA_OUT_READ */
++
++ int state = 0;
++ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
++ int len = 0;
++ const Byte *Buffer;
++ const Byte *BufferLim;
++ UInt32 Range;
++ UInt32 Code;
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++
++ {
++ UInt32 i;
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ }
++
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++
++ #endif /* _LZMA_OUT_READ */
++
++ while(nowPos < outSize)
++ {
++ CProb *prob;
++ UInt32 bound;
++ int posState = (int)(
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & posStateMask);
++
++ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ int symbol = 1;
++ UpdateBit0(prob)
++ prob = p + Literal + (LZMA_LIT_SIZE *
++ (((
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
++
++ if (state >= kNumLitStates)
++ {
++ int matchByte;
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ matchByte = dictionary[pos];
++ #else
++ matchByte = outStream[nowPos - rep0];
++ #endif
++ do
++ {
++ int bit;
++ CProb *probLit;
++ matchByte <<= 1;
++ bit = (matchByte & 0x100);
++ probLit = prob + 0x100 + bit + symbol;
++ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
++ }
++ while (symbol < 0x100);
++ }
++ while (symbol < 0x100)
++ {
++ CProb *probLit = prob + symbol;
++ RC_GET_BIT(probLit, symbol)
++ }
++ previousByte = (Byte)symbol;
++
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #endif
++ if (state < 4) state = 0;
++ else if (state < 10) state -= 3;
++ else state -= 6;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRep + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ rep3 = rep2;
++ rep2 = rep1;
++ rep1 = rep0;
++ state = state < kNumLitStates ? 0 : 3;
++ prob = p + LenCoder;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG0 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos;
++ #endif
++ UpdateBit0(prob);
++
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit == 0)
++ #else
++ if (nowPos == 0)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ state = state < kNumLitStates ? 9 : 11;
++ #ifdef _LZMA_OUT_READ
++ pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++ #endif
++
++ continue;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ }
++ }
++ else
++ {
++ UInt32 distance;
++ UpdateBit1(prob);
++ prob = p + IsRepG1 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep1;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG2 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep2;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ distance = rep3;
++ rep3 = rep2;
++ }
++ rep2 = rep1;
++ }
++ rep1 = rep0;
++ rep0 = distance;
++ }
++ state = state < kNumLitStates ? 8 : 11;
++ prob = p + RepLenCoder;
++ }
++ {
++ int numBits, offset;
++ CProb *probLen = prob + LenChoice;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenLow + (posState << kLenNumLowBits);
++ offset = 0;
++ numBits = kLenNumLowBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenChoice2;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenMid + (posState << kLenNumMidBits);
++ offset = kLenNumLowSymbols;
++ numBits = kLenNumMidBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenHigh;
++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
++ numBits = kLenNumHighBits;
++ }
++ }
++ RangeDecoderBitTreeDecode(probLen, numBits, len);
++ len += offset;
++ }
++
++ if (state < 4)
++ {
++ int posSlot;
++ state += kNumLitStates;
++ prob = p + PosSlot +
++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
++ kNumPosSlotBits);
++ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
++ if (posSlot >= kStartPosModelIndex)
++ {
++ int numDirectBits = ((posSlot >> 1) - 1);
++ rep0 = (2 | ((UInt32)posSlot & 1));
++ if (posSlot < kEndPosModelIndex)
++ {
++ rep0 <<= numDirectBits;
++ prob = p + SpecPos + rep0 - posSlot - 1;
++ }
++ else
++ {
++ numDirectBits -= kNumAlignBits;
++ do
++ {
++ RC_NORMALIZE
++ Range >>= 1;
++ rep0 <<= 1;
++ if (Code >= Range)
++ {
++ Code -= Range;
++ rep0 |= 1;
++ }
++ }
++ while (--numDirectBits != 0);
++ prob = p + Align;
++ rep0 <<= kNumAlignBits;
++ numDirectBits = kNumAlignBits;
++ }
++ {
++ int i = 1;
++ int mi = 1;
++ do
++ {
++ CProb *prob3 = prob + mi;
++ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
++ i <<= 1;
++ }
++ while(--numDirectBits != 0);
++ }
++ }
++ else
++ rep0 = posSlot;
++ if (++rep0 == (UInt32)(0))
++ {
++ /* it's for stream version */
++ len = kLzmaStreamWasFinishedId;
++ break;
++ }
++ }
++
++ len += kMatchMinLen;
++ #ifdef _LZMA_OUT_READ
++ if (rep0 > distanceLimit)
++ #else
++ if (rep0 > nowPos)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ #ifdef _LZMA_OUT_READ
++ if (dictionarySize - distanceLimit > (UInt32)len)
++ distanceLimit += len;
++ else
++ distanceLimit = dictionarySize;
++ #endif
++
++ do
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ len--;
++ outStream[nowPos++] = previousByte;
++ }
++ while(len != 0 && nowPos < outSize);
++ }
++ }
++ RC_NORMALIZE;
++
++ #ifdef _LZMA_OUT_READ
++ vs->Range = Range;
++ vs->Code = Code;
++ vs->DictionaryPos = dictionaryPos;
++ vs->GlobalPos = globalPos + (UInt32)nowPos;
++ vs->DistanceLimit = distanceLimit;
++ vs->Reps[0] = rep0;
++ vs->Reps[1] = rep1;
++ vs->Reps[2] = rep2;
++ vs->Reps[3] = rep3;
++ vs->State = state;
++ vs->RemainLen = len;
++ vs->TempDictionary[0] = tempDictionary[0];
++ #endif
++
++ #ifdef _LZMA_IN_CB
++ vs->Buffer = Buffer;
++ vs->BufferLim = BufferLim;
++ #else
++ *inSizeProcessed = (SizeT)(Buffer - inStream);
++ #endif
++ *outSizeProcessed = nowPos;
++ return LZMA_RESULT_OK;
++}
+diff --git a/init/LzmaDecode.h b/init/LzmaDecode.h
+new file mode 100644
+index 0000000..213062a
+--- /dev/null
++++ b/init/LzmaDecode.h
+@@ -0,0 +1,131 @@
++/*
++ LzmaDecode.h
++ LZMA Decoder interface
++
++ LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this code, expressly permits you to
++ statically or dynamically link your code (or bind by name) to the
++ interfaces of this file without subjecting your linked code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#ifndef __LZMADECODE_H
++#define __LZMADECODE_H
++
++/* #define _LZMA_IN_CB */
++/* Use callback for input data */
++
++/* #define _LZMA_OUT_READ */
++/* Use read function for output data */
++
++/* #define _LZMA_PROB32 */
++/* It can increase speed on some 32-bit CPUs,
++ but memory usage will be doubled in that case */
++
++/* #define _LZMA_LOC_OPT */
++/* Enable local speed optimizations inside code */
++
++/* #define _LZMA_SYSTEM_SIZE_T */
++/* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
++
++#ifndef UInt32
++#ifdef _LZMA_UINT32_IS_ULONG
++#define UInt32 unsigned long
++#else
++#define UInt32 unsigned int
++#endif
++#endif
++
++#ifndef SizeT
++#ifdef _LZMA_SYSTEM_SIZE_T
++#include <stddef.h>
++#define SizeT size_t
++#else
++#define SizeT UInt32
++#endif
++#endif
++
++#ifdef _LZMA_PROB32
++#define CProb UInt32
++#else
++#define CProb unsigned short
++#endif
++
++#define LZMA_RESULT_OK 0
++#define LZMA_RESULT_DATA_ERROR 1
++
++#ifdef _LZMA_IN_CB
++typedef struct _ILzmaInCallback
++{
++ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
++} ILzmaInCallback;
++#endif
++
++#define LZMA_BASE_SIZE 1846
++#define LZMA_LIT_SIZE 768
++
++#define LZMA_PROPERTIES_SIZE 5
++
++typedef struct _CLzmaProperties
++{
++ int lc;
++ int lp;
++ int pb;
++ #ifdef _LZMA_OUT_READ
++ UInt32 DictionarySize;
++ #endif
++}CLzmaProperties;
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
++
++#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
++
++#define kLzmaNeedInitId (-2)
++
++typedef struct _CLzmaDecoderState
++{
++ CLzmaProperties Properties;
++ CProb *Probs;
++
++ #ifdef _LZMA_IN_CB
++ const unsigned char *Buffer;
++ const unsigned char *BufferLim;
++ #endif
++
++ #ifdef _LZMA_OUT_READ
++ unsigned char *Dictionary;
++ UInt32 Range;
++ UInt32 Code;
++ UInt32 DictionaryPos;
++ UInt32 GlobalPos;
++ UInt32 DistanceLimit;
++ UInt32 Reps[4];
++ int State;
++ int RemainLen;
++ unsigned char TempDictionary[4];
++ #endif
++} CLzmaDecoderState;
++
++#ifdef _LZMA_OUT_READ
++#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
++#endif
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *inCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
++
++#endif
+diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
+index ed652f4..5fd1ec5 100644
+--- a/init/do_mounts_rd.c
++++ b/init/do_mounts_rd.c
+@@ -5,7 +5,9 @@
+ #include <linux/ext2_fs.h>
+ #include <linux/romfs_fs.h>
+ #include <linux/cramfs_fs.h>
++#include <linux/squashfs_fs.h>
+ #include <linux/initrd.h>
++#include <linux/vmalloc.h>
+ #include <linux/string.h>
+
+ #include "do_mounts.h"
+@@ -31,6 +33,9 @@ static int __init ramdisk_start_setup(char *str)
+ __setup("ramdisk_start=", ramdisk_start_setup);
+
+ static int __init crd_load(int in_fd, int out_fd);
++#ifdef CONFIG_LZMA_INITRD
++static int __init lzma_rd_load(int in_fd, int out_fd);
++#endif
+
+ /*
+ * This routine tries to find a RAM disk image to load, and returns the
+@@ -39,6 +44,7 @@ static int __init crd_load(int in_fd, int out_fd);
+ * numbers could not be found.
+ *
+ * We currently check for the following magic numbers:
++ * squashfs
+ * minix
+ * ext2
+ * romfs
+@@ -53,6 +59,7 @@ identify_ramdisk_image(int fd, int start_block)
+ struct ext2_super_block *ext2sb;
+ struct romfs_super_block *romfsb;
+ struct cramfs_super *cramfsb;
++ struct squashfs_super_block *squashfsb;
+ int nblocks = -1;
+ unsigned char *buf;
+
+@@ -64,6 +71,7 @@ identify_ramdisk_image(int fd, int start_block)
+ ext2sb = (struct ext2_super_block *) buf;
+ romfsb = (struct romfs_super_block *) buf;
+ cramfsb = (struct cramfs_super *) buf;
++ squashfsb = (struct squashfs_super_block *) buf;
+ memset(buf, 0xe5, size);
+
+ /*
+@@ -82,6 +90,17 @@ identify_ramdisk_image(int fd, int start_block)
+ nblocks = 0;
+ goto done;
+ }
++ /*
++ * handle lzma compressed initrd, returns nblocks=1 as indication
++ */
++ if( buf[0] < 9 * 5 * 5 && buf[9] == 0 && buf[10] == 0 && buf[11] == 0
++ && buf[12] == 0 )
++ {
++ printk( KERN_NOTICE "RAMDISK: LZMA image found at block %d\n",
++ start_block);
++ nblocks = 1; // just a convenient return flag
++ goto done;
++ }
+
+ /* romfs is at block zero too */
+ if (romfsb->word0 == ROMSB_WORD0 &&
+@@ -101,6 +120,18 @@ identify_ramdisk_image(int fd, int start_block)
+ goto done;
+ }
+
++ /* squashfs is at block zero too */
++ if (squashfsb->s_magic == SQUASHFS_MAGIC) {
++ printk(KERN_NOTICE
++ "RAMDISK: squashfs filesystem found at block %d\n",
++ start_block);
++ if (squashfsb->s_major < 3)
++ nblocks = (squashfsb->bytes_used_2+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ else
++ nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ goto done;
++ }
++
+ /*
+ * Read block 1 to test for minix and ext2 superblock
+ */
+@@ -172,7 +203,22 @@ int __init rd_load_image(char *from)
+ #endif
+ goto done;
+ }
+-
++#ifdef CONFIG_LZMA_INITRD
++ /*
++ * handle lzma compressed image
++ */
++ if ( nblocks == 1 )
++ {
++ nblocks = 0;
++ if ( lzma_rd_load(in_fd, out_fd) == 0 )
++ {
++ printk("\nLZMA initrd loaded successfully\n");
++ goto successful_load;
++ }
++ printk(KERN_NOTICE "LZMA initrd is not in the correct format\n");
++ goto done;
++ }
++#endif
+ /*
+ * NOTE NOTE: nblocks is not actually blocks but
+ * the number of kibibytes of data to load into a ramdisk.
+@@ -393,6 +439,134 @@ static void __init error(char *x)
+ unzip_error = 1;
+ }
+
++#ifdef CONFIG_LZMA_INITRD
++#define _LZMA_IN_CB
++#define _LZMA_OUT_READ
++#include "LzmaDecode.h"
++#include "LzmaDecode.c"
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize);
++
++/*
++ * Do the lzma decompression
++ */
++static int __init lzma_rd_load(int in_fd, int out_fd)
++{
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned char* outputbuffer;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++ unsigned int kBlockSize = 0x10000;
++ unsigned int nowPos = 0;
++ unsigned int outsizeProcessed = 0;
++ int res;
++ ILzmaInCallback callback;
++
++ insize = 0; /* valid bytes in inbuf */
++ inptr = 0; /* index of next byte to be processed in inbuf */
++ exit_code = 0;
++ crd_infd = in_fd;
++ inbuf = kmalloc(INBUFSIZ, GFP_KERNEL);
++ if (inbuf == 0)
++ {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma input buffer\n");
++ return -1;
++ }
++
++ callback.Read = read_byte;
++
++ /* lzma args */
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ /* read dictionary size */
++ p = (char*)&state.Properties.DictionarySize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ /* get uncompressedSize */
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ /* skip big file */
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ printk( KERN_NOTICE "RAMDISK: LZMA lc=%d,lp=%d,pb=%d,dictSize=%d,origSize=%d\n",
++ state.Properties.lc, state.Properties.lp, state.Properties.pb, state.Properties.DictionarySize, uncompressedSize);
++ outputbuffer = kmalloc(kBlockSize, GFP_KERNEL);
++ if (outputbuffer == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma output buffer\n");
++ return -1;
++ }
++
++ state.Probs = (CProb*)kmalloc( LzmaGetNumProbs(&state.Properties)*sizeof(CProb), GFP_KERNEL);
++ if ( state.Probs == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma workspace\n");
++ return -1;
++ }
++
++#ifdef CONFIG_LZMA_INITRD_KMALLOC_ONLY
++ state.Dictionary = kmalloc( state.Properties.DictionarySize, GFP_KERNEL);
++#else
++ state.Dictionary = vmalloc( state.Properties.DictionarySize);
++#endif
++ if ( state.Dictionary == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma dictionary\n");
++ return -1;
++ }
++
++ printk( KERN_NOTICE "LZMA initrd by Ming-Ching Tiew <mctiew@yahoo.com> " );
++
++ LzmaDecoderInit( &state );
++
++ for( nowPos =0; nowPos < uncompressedSize ; )
++ {
++ UInt32 blockSize = uncompressedSize - nowPos;
++ if( blockSize > kBlockSize)
++ blockSize = kBlockSize;
++ res = LzmaDecode( &state, &callback, outputbuffer, blockSize, &outsizeProcessed);
++ if( res != 0 ) {
++ printk( KERN_ERR "RAMDISK: Lzma decode failure\n");
++ return -1;
++ }
++ if( outsizeProcessed == 0 )
++ {
++ uncompressedSize = nowPos;
++ printk( KERN_NOTICE "RAMDISK nowPos=%d, uncompressedSize=%d\n",
++ nowPos, uncompressedSize );
++ break;
++ }
++ sys_write(out_fd, outputbuffer, outsizeProcessed );
++ nowPos += outsizeProcessed;
++ printk( ".");
++ }
++
++#ifdef CONFIG_LZMA_INITRD_KMALLOC_ONLY
++ kfree(state.Dictionary);
++#else
++ vfree(state.Dictionary);
++#endif
++ kfree(inbuf);
++ kfree(outputbuffer);
++ kfree(state.Probs);
++ return 0;
++}
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++#endif /*CONFIG_LZMA_INITRD*/
++
+ static int __init crd_load(int in_fd, int out_fd)
+ {
+ int result;
+diff --git a/init/initramfs.c b/init/initramfs.c
+index 00eff7a..30d32a2 100644
+--- a/init/initramfs.c
++++ b/init/initramfs.c
+@@ -6,6 +6,7 @@
+ #include <linux/delay.h>
+ #include <linux/string.h>
+ #include <linux/syscalls.h>
++#include <linux/vmalloc.h>
+
+ static __initdata char *message;
+ static void __init error(char *x)
+@@ -441,6 +442,118 @@ static void __init flush_window(void)
+ outcnt = 0;
+ }
+
++#ifdef CONFIG_LZMA_INITRAM_FS
++#define _LZMA_IN_CB
++#define _LZMA_OUT_READ
++#include "LzmaDecode.h"
++#ifndef CONFIG_LZMA_INITRD
++ #include "LzmaDecode.c"
++#endif
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++static int __init lzma_unzip(void)
++{
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned char* outputbuffer;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++ unsigned int kBlockSize = 0x10000;
++ unsigned int nowPos = 0;
++ unsigned int outsizeProcessed = 0;
++ int res;
++ ILzmaInCallback callback;
++
++ callback.Read = read_byte;
++
++ // lzma args
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ // read dictionary size
++ p = (char*)&state.Properties.DictionarySize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // get uncompressedSize
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // skip big file
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ printk( KERN_NOTICE "initramfs: LZMA lc=%d,lp=%d,pb=%d,dictSize=%d,origSize=%d\n",
++ state.Properties.lc,state.Properties.lp,state.Properties.pb,state.Properties.DictionarySize, uncompressedSize);
++ outputbuffer = kmalloc(kBlockSize, GFP_KERNEL);
++ if (outputbuffer == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma output buffer\n");
++ return -1;
++ }
++
++ state.Probs = (CProb*) kmalloc( LzmaGetNumProbs(&state.Properties)*sizeof(CProb), GFP_KERNEL);
++ if ( state.Probs == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma workspace\n");
++ return -1;
++ }
++
++#ifdef CONFIG_LZMA_INITRAM_FS_KMALLOC_ONLY
++ state.Dictionary = kmalloc( state.Properties.DictionarySize, GFP_KERNEL);
++#else
++ state.Dictionary = vmalloc( state.Properties.DictionarySize);
++#endif
++ if ( state.Dictionary == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma dictionary\n");
++ return -1;
++ }
++
++ printk( KERN_NOTICE "LZMA initramfs by Ming-Ching Tiew <mctiew@yahoo.com> " );
++
++ LzmaDecoderInit( &state );
++
++ for( nowPos =0; nowPos < uncompressedSize ; )
++ {
++ UInt32 blockSize = uncompressedSize - nowPos;
++ if( blockSize > kBlockSize)
++ blockSize = kBlockSize;
++ res = LzmaDecode( &state, &callback, outputbuffer, blockSize, &outsizeProcessed);
++ if( res != 0 ) {
++ panic( KERN_ERR "initramfs: Lzma decode failure\n");
++ return -1;
++ }
++ if( outsizeProcessed == 0 )
++ {
++ uncompressedSize = nowPos;
++ printk( KERN_NOTICE "initramfs: nowPos=%d, uncompressedSize=%d\n",
++ nowPos, uncompressedSize );
++ break;
++ }
++ flush_buffer(outputbuffer, outsizeProcessed);
++ nowPos += outsizeProcessed;
++ printk( ".");
++ }
++
++#ifdef CONFIG_LZMA_INITRAM_FS_KMALLOC_ONLY
++ kfree(state.Dictionary);
++#else
++ vfree(state.Dictionary);
++#endif
++ kfree(outputbuffer);
++ kfree(state.Probs);
++ return 0;
++}
++
++#endif /*CONFIG LZMA_INITRAM_FS*/
++
+ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
+ {
+ int written;
+@@ -475,12 +588,31 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
+ inptr = 0;
+ outcnt = 0; /* bytes in output buffer */
+ bytes_out = 0;
+- crc = (ulg)0xffffffffL; /* shift register contents */
+- makecrc();
+- gunzip();
+- if (state != Reset)
++ if( inbuf[0] == 037 && ((inbuf[1] == 0213) || (inbuf[1] == 0236)))
++ {
++ printk( KERN_NOTICE "detected gzip initramfs\n");
++ crc = (ulg)0xffffffffL; /* shift register contents */
++ makecrc();
++ gunzip();
++ if (state != Reset)
+ error("junk in gzipped archive");
+- this_header = saved_offset + inptr;
++ }
++#ifdef CONFIG_LZMA_INITRAM_FS
++ else if( inbuf[0] < 9 * 5 * 5 && buf[9] == 0 && buf[10] == 0
++ && buf[11] == 0 && buf[12] == 0 )
++ {
++ printk( KERN_NOTICE "detected lzma initramfs\n");
++ lzma_unzip();
++ }
++#endif
++ else
++ {
++ // skip forward ?
++ crc = (ulg)0xffffffffL; /* shift register contents */
++ makecrc();
++ gunzip();
++ }
++ this_header = saved_offset + inptr;
+ buf += inptr;
+ len -= inptr;
+ }
+diff --git a/kernel/Makefile b/kernel/Makefile
+index ac6b27a..bd498a2 100644
+--- a/kernel/Makefile
++++ b/kernel/Makefile
+@@ -66,7 +66,7 @@ $(obj)/configs.o: $(obj)/config_data.h
+ # config_data.h contains the same information as ikconfig.h but gzipped.
+ # Info from config_data can be extracted from /proc/config*
+ targets += config_data.gz
+-$(obj)/config_data.gz: .config FORCE
++$(obj)/config_data.gz: .miniconfig FORCE
+ $(call if_changed,gzip)
+
+ quiet_cmd_ikconfiggz = IKCFG $@
+diff --git a/kernel/configs.c b/kernel/configs.c
+index 8fa1fb2..c8407eb 100644
+--- a/kernel/configs.c
++++ b/kernel/configs.c
+@@ -88,7 +88,7 @@ static int __init ikconfig_init(void)
+ struct proc_dir_entry *entry;
+
+ /* create the current config file */
+- entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO,
++ entry = create_proc_entry("miniconfig.gz", S_IFREG | S_IRUGO,
+ &proc_root);
+ if (!entry)
+ return -ENOMEM;
+@@ -104,7 +104,7 @@ static int __init ikconfig_init(void)
+
+ static void __exit ikconfig_cleanup(void)
+ {
+- remove_proc_entry("config.gz", &proc_root);
++ remove_proc_entry("miniconfig.gz", &proc_root);
+ }
+
+ module_init(ikconfig_init);
+diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
+index fe5c7db..a5150e6 100644
+--- a/kernel/time/clocksource.c
++++ b/kernel/time/clocksource.c
+@@ -85,8 +85,8 @@ static void clocksource_ratewd(struct clocksource *cs, int64_t delta)
+ if (delta > -WATCHDOG_TRESHOLD && delta < WATCHDOG_TRESHOLD)
+ return;
+
+- printk(KERN_WARNING "Clocksource %s unstable (delta = %Ld ns)\n",
+- cs->name, delta);
++/* printk(KERN_WARNING "Clocksource %s unstable (delta = %Ld ns)\n",
++ cs->name, delta); */
+ cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
+ clocksource_change_rating(cs, 0);
+ cs->flags &= ~CLOCK_SOURCE_WATCHDOG;
+diff --git a/kernel/timer.c b/kernel/timer.c
+index dd6c2c1..3a8f485 100644
+--- a/kernel/timer.c
++++ b/kernel/timer.c
+@@ -916,8 +916,8 @@ static void change_clocksource(void)
+
+ tick_clock_notify();
+
+- printk(KERN_INFO "Time: %s clocksource has been installed.\n",
+- clock->name);
++/* printk(KERN_INFO "Time: %s clocksource has been installed.\n",
++ clock->name); */
+ }
+ #else
+ static inline void change_clocksource(void) { }
+diff --git a/miniconfig.sh b/miniconfig.sh
+new file mode 100755
+index 0000000..28e7433
+--- /dev/null
++++ b/miniconfig.sh
+@@ -0,0 +1,2 @@
++#!/bin/sh -f
++make allnoconfig KCONFIG_ALLCONFIG=.miniconfig
+diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
+index fc498fe..e98172c 100644
+--- a/scripts/Makefile.lib
++++ b/scripts/Makefile.lib
+@@ -162,4 +162,9 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+ quiet_cmd_gzip = GZIP $@
+ cmd_gzip = gzip -f -9 < $< > $@
+
++# LZMA
++#
++quiet_cmd_lzma = LZMA $@
++cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++
+
+diff --git a/scripts/gen_lzma_initramfs_list.sh b/scripts/gen_lzma_initramfs_list.sh
+new file mode 100644
+index 0000000..be3ed6a
+--- /dev/null
++++ b/scripts/gen_lzma_initramfs_list.sh
+@@ -0,0 +1,292 @@
++#!/bin/bash
++# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
++# Copyright (c) 2006 Sam Ravnborg <sam@ravnborg.org>
++#
++# Released under the terms of the GNU GPL
++#
++# Generate a cpio packed initramfs. It uses gen_init_cpio to generate
++# the cpio archive, and gzip to pack it.
++# The script may also be used to generate the inputfile used for gen_init_cpio
++# This script assumes that gen_init_cpio is located in usr/ directory
++
++# error out on errors
++set -e
++
++usage() {
++cat << EOF
++Usage:
++$0 [-o <file>] [-u <uid>] [-g <gid>] { -s | -d | <cpio_source>} ...
++ -o <file> Create lzma initramfs file named <file> using
++ gen_init_cpio and lzma
++ -u <uid> User ID to map to user ID 0 (root).
++ <uid> is only meaningful if <cpio_source>
++ is a directory.
++ -g <gid> Group ID to map to group ID 0 (root).
++ <gid> is only meaningful if <cpio_source>
++ is a directory.
++ <cpio_source> File list or directory for cpio archive.
++ If <cpio_source> is a .cpio file it will be used
++ as direct input to initramfs.
++ -s Create lzma file with small dictionary size
++ -d Output the default cpio list.
++
++All options except -o and -l may be repeated and are interpreted
++sequentially and immediately. -u and -g states are preserved across
++<cpio_source> options so an explicit "-u 0 -g 0" is required
++to reset the root/group mapping.
++EOF
++}
++
++list_default_initramfs() {
++ # echo usr/kinit/kinit
++ :
++}
++
++default_initramfs() {
++ cat <<-EOF >> ${output}
++ # This is a very simple, default initramfs
++
++ dir /dev 0755 0 0
++ nod /dev/console 0600 0 0 c 5 1
++ dir /root 0700 0 0
++ # file /kinit usr/kinit/kinit 0755 0 0
++ # slink /init kinit 0755 0 0
++ EOF
++}
++
++filetype() {
++ local argv1="$1"
++
++ # symlink test must come before file test
++ if [ -L "${argv1}" ]; then
++ echo "slink"
++ elif [ -f "${argv1}" ]; then
++ echo "file"
++ elif [ -d "${argv1}" ]; then
++ echo "dir"
++ elif [ -b "${argv1}" -o -c "${argv1}" ]; then
++ echo "nod"
++ elif [ -p "${argv1}" ]; then
++ echo "pipe"
++ elif [ -S "${argv1}" ]; then
++ echo "sock"
++ else
++ echo "invalid"
++ fi
++ return 0
++}
++
++list_print_mtime() {
++ :
++}
++
++print_mtime() {
++ local my_mtime="0"
++
++ if [ -e "$1" ]; then
++ my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1)
++ fi
++
++ echo "# Last modified: ${my_mtime}" >> ${output}
++ echo "" >> ${output}
++}
++
++list_parse() {
++ echo "$1 \\"
++}
++
++# for each file print a line in following format
++# <filetype> <name> <path to file> <octal mode> <uid> <gid>
++# for links, devices etc the format differs. See gen_init_cpio for details
++parse() {
++ local location="$1"
++ local name="${location/${srcdir}//}"
++ # change '//' into '/'
++ name="${name//\/\///}"
++ local mode="$2"
++ local uid="$3"
++ local gid="$4"
++ local ftype=$(filetype "${location}")
++ # remap uid/gid to 0 if necessary
++ [ "$uid" -eq "$root_uid" ] && uid=0
++ [ "$gid" -eq "$root_gid" ] && gid=0
++ local str="${mode} ${uid} ${gid}"
++
++ [ "${ftype}" == "invalid" ] && return 0
++ [ "${location}" == "${srcdir}" ] && return 0
++
++ case "${ftype}" in
++ "file")
++ str="${ftype} ${name} ${location} ${str}"
++ ;;
++ "nod")
++ local dev_type=
++ local maj=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{sub(/,/, "", $5); print $5}')
++ local min=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{print $6}')
++
++ if [ -b "${location}" ]; then
++ dev_type="b"
++ else
++ dev_type="c"
++ fi
++ str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
++ ;;
++ "slink")
++ local target=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{print $11}')
++ str="${ftype} ${name} ${target} ${str}"
++ ;;
++ *)
++ str="${ftype} ${name} ${str}"
++ ;;
++ esac
++
++ echo "${str}" >> ${output}
++
++ return 0
++}
++
++unknown_option() {
++ printf "ERROR: unknown option \"$arg\"\n" >&2
++ printf "If the filename validly begins with '-', " >&2
++ printf "then it must be prefixed\n" >&2
++ printf "by './' so that it won't be interpreted as an option." >&2
++ printf "\n" >&2
++ usage >&2
++ exit 1
++}
++
++list_header() {
++ :
++}
++
++header() {
++ printf "\n#####################\n# $1\n" >> ${output}
++}
++
++# process one directory (incl sub-directories)
++dir_filelist() {
++ ${dep_list}header "$1"
++
++ srcdir=$(echo "$1" | sed -e 's://*:/:g')
++ dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
++
++ # If $dirlist is only one line, then the directory is empty
++ if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
++ ${dep_list}print_mtime "$1"
++
++ echo "${dirlist}" | \
++ while read x; do
++ ${dep_list}parse ${x}
++ done
++ fi
++}
++
++# if only one file is specified and it is .cpio file then use it direct as fs
++# if a directory is specified then add all files in given direcotry to fs
++# if a regular file is specified assume it is in gen_initramfs format
++input_file() {
++ source="$1"
++ if [ -f "$1" ]; then
++ ${dep_list}header "$1"
++ is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')"
++ if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
++ cpio_file=$1
++ [ ! -z ${dep_list} ] && echo "$1"
++ return 0
++ fi
++ if [ -z ${dep_list} ]; then
++ print_mtime "$1" >> ${output}
++ cat "$1" >> ${output}
++ else
++ cat "$1" | while read type dir file perm ; do
++ if [ "$type" == "file" ]; then
++ echo "$file \\";
++ fi
++ done
++ fi
++ elif [ -d "$1" ]; then
++ dir_filelist "$1"
++ else
++ echo " ${prog}: Cannot open '$1'" >&2
++ exit 1
++ fi
++}
++
++prog=$0
++root_uid=0
++root_gid=0
++dep_list=
++cpio_file=
++cpio_list=
++output="/dev/stdout"
++output_file=""
++opt=""
++
++arg="$1"
++case "$arg" in
++ "-l") # files included in initramfs - used by kbuild
++ dep_list="list_"
++ echo "deps_initramfs := \\"
++ shift
++ ;;
++ "-o") # generate lzma-ed cpio image named $1
++ shift
++ output_file="$1"
++ cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
++ output=${cpio_list}
++ shift
++ ;;
++esac
++while [ $# -gt 0 ]; do
++ arg="$1"
++ shift
++ case "$arg" in
++ "-u") # map $1 to uid=0 (root)
++ root_uid="$1"
++ shift
++ ;;
++ "-g") # map $1 to gid=0 (root)
++ root_gid="$1"
++ shift
++ ;;
++ "-s")
++ opt="-d16"
++ ;;
++ "-d") # display default initramfs list
++ default_list="$arg"
++ ${dep_list}default_initramfs
++ ;;
++ "-h")
++ usage
++ exit 0
++ ;;
++ *)
++ case "$arg" in
++ "-"*)
++ unknown_option
++ ;;
++ *) # input file/dir - process it
++ input_file "$arg" "$#"
++ ;;
++ esac
++ ;;
++ esac
++done
++
++# If output_file is set we will generate cpio archive and lzma it
++# we are carefull to delete tmp files
++if [ ! -z ${output_file} ]; then
++ if [ -z ${cpio_file} ]; then
++ cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)"
++ usr/gen_init_cpio ${cpio_list} > ${cpio_tfile}
++ else
++ cpio_tfile=${cpio_file}
++ fi
++ rm ${cpio_list}
++ lzma e ${cpio_tfile} ${output_file} ${opt}
++ [ -z ${cpio_file} ] && rm ${cpio_tfile}
++fi
++exit 0
+diff --git a/shrinkconfig.sh b/shrinkconfig.sh
+new file mode 100755
+index 0000000..e7a3df7
+--- /dev/null
++++ b/shrinkconfig.sh
+@@ -0,0 +1,79 @@
++#! /bin/bash
++
++# shrinkconfig copyright 2006 by Rob Landley <rob@landley.net>
++# Licensed under the GNU General Public License version 2.
++
++if [ $# -ne 1 ]
++then
++ echo "Turns current .config into a miniconfig file."
++ echo "Usage: shrinkconfig mini.config"
++ exit 1
++fi
++
++if [ ! -f .config ]
++then
++ echo "Need a .config file to shrink."
++ exit 1
++fi
++LENGTH=$(wc -l < .config)
++
++OUTPUT="$1"
++cp .config "$OUTPUT"
++if [ $? -ne 0 ]
++then
++ echo "Couldn't create $OUTPUT"
++ exit 1
++fi
++
++# If we get interrupted, clean up the mess
++
++KERNELOUTPUT=""
++
++function cleanup
++{
++ echo
++ echo "Interrupted."
++ [ ! -z "$KERNELOUTPUT" ] && rm -rf "$KERNELOUTPUT"
++ rm "$OUTPUT"
++ exit 1
++}
++
++trap cleanup HUP INT QUIT TERM
++
++# Since the "O=" argument to make doesn't work recursively, we need to jump
++# through a few hoops to avoid overwriting the .config that we're shrinking.
++
++# If we're building out of tree, we'll have absolute paths to source and build
++# directories in the Makefile.
++
++KERNELSRC=$(sed -n -e 's/KERNELSRC[^/]*:=[^/]*//p' Makefile)
++[ -z "$KERNELSRC" ] && KERNELSRC=$(pwd)
++KERNELOUTPUT=`pwd`/.config.minitemp
++
++mkdir -p "$KERNELOUTPUT" || exit 1
++
++echo "Shrinking .config to $OUTPUT..."
++
++for I in $(seq 1 $LENGTH)
++do
++ echo -n -e "\r"$I/$LENGTH lines $(wc -c < "$OUTPUT") bytes
++
++ sed -n "${I}!p" "$OUTPUT" > "$KERNELOUTPUT"/.config.test
++ # Do a config with this file
++ make -C "$KERNELSRC" O="$KERNELOUTPUT" allnoconfig KCONFIG_ALLCONFIG="$KERNELOUTPUT"/.config.test > /dev/null
++
++ # Compare. The date changes, so expect a small difference each time.
++ D=$(diff "$KERNELOUTPUT"/.config .config | wc -l)
++ if [ $D -eq 4 ]
++ then
++ mv "$KERNELOUTPUT"/.config.test "$OUTPUT"
++ LENGTH=$[$LENGTH-1]
++ else
++ I=$[$I + 1]
++ fi
++done
++
++rm -rf "$KERNELOUTPUT"
++
++# One extra echo to preserve status line.
++echo
+diff --git a/usr/Makefile b/usr/Makefile
+index 201f27f..8e1f6ea 100644
+--- a/usr/Makefile
++++ b/usr/Makefile
+@@ -19,6 +19,7 @@ $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE
+
+ hostprogs-y := gen_init_cpio
+ initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
++lzma_initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_lzma_initramfs_list.sh
+ ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
+ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
+ ramfs-args := \
+@@ -36,6 +37,14 @@ endif
+ quiet_cmd_initfs = GEN $@
+ cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
+
++ifdef CONFIG_LZMA_INITRAM_FS_SMALLMEM
++quiet_cmd_lzma_initfs = LZRAMFS $@
++ cmd_lzma_initfs = $(lzma_initramfs) -o $@ $(ramfs-args) -s $(ramfs-input)
++else
++quiet_cmd_lzma_initfs = LZRAMFS $@
++ cmd_lzma_initfs = $(lzma_initramfs) -o $@ $(ramfs-args) $(ramfs-input)
++endif
++
+ targets := initramfs_data.cpio.gz
+ # do not try to update files included in initramfs
+ $(deps_initramfs): ;
+@@ -48,5 +57,9 @@ $(deps_initramfs): klibcdirs
+ # 4) arguments to gen_initramfs.sh changes
+ $(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
+ $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
++ifdef CONFIG_LZMA_INITRAM_FS
++ $(call if_changed,lzma_initfs)
++else
+ $(call if_changed,initfs)
++endif
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-002-lzma-vmlinuz.01.patch b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-002-lzma-vmlinuz.01.patch
new file mode 100644
index 0000000000..05361ff9d4
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.21.5-002-lzma-vmlinuz.01.patch
@@ -0,0 +1,54 @@
+diff -rdup linux-2.6.21.5.oorig/arch/i386/boot/compressed/Makefile linux-2.6.21.5/arch/i386/boot/compressed/Makefile
+--- linux-2.6.21.5.oorig/arch/i386/boot/compressed/Makefile 2007-07-24 13:08:51.000000000 +0200
++++ linux-2.6.21.5/arch/i386/boot/compressed/Makefile 2007-07-24 14:54:38.000000000 +0200
+@@ -4,7 +4,7 @@
+ # create a compressed vmlinux image from the original vmlinux
+ #
+
+-tragets := head.o lzma_misc.o piggy.o \
++targets := head.o lzma_misc.o piggy.o \
+ vmlinux.bin.all vmlinux.relocs \
+ vmlinux vmlinux.bin vmlinux.bin.gz
+ EXTRA_AFLAGS := -traditional
+diff -rdup linux-2.6.21.5.oorig/scripts/gen_lzma_initramfs_list.sh linux-2.6.21.5/scripts/gen_lzma_initramfs_list.sh
+--- linux-2.6.21.5.oorig/scripts/gen_lzma_initramfs_list.sh 2007-07-24 13:08:51.000000000 +0200
++++ linux-2.6.21.5/scripts/gen_lzma_initramfs_list.sh 2007-07-24 15:12:10.000000000 +0200
+@@ -253,7 +253,7 @@ while [ $# -gt 0 ]; do
+ shift
+ ;;
+ "-s")
+- opt="-d16"
++ #opt="-d16" ? what was that supposed to do?
+ ;;
+ "-d") # display default initramfs list
+ default_list="$arg"
+@@ -286,7 +286,7 @@ if [ ! -z ${output_file} ]; then
+ cpio_tfile=${cpio_file}
+ fi
+ rm ${cpio_list}
+- lzma e ${cpio_tfile} ${output_file} ${opt}
++ lzma -z ${cpio_tfile} ${opt} -c > ${output_file}
+ [ -z ${cpio_file} ] && rm ${cpio_tfile}
+ fi
+ exit 0
+--- linux-2.6.21.5.oorig/arch/i386/boot/compressed/lzma_misc.c 2007-07-24 15:24:44.000000000 +0200
++++ linux-2.6.21.5/arch/i386/boot/compressed/lzma_misc.c 2007-07-24 17:09:40.000000000 +0200
+@@ -241,7 +241,6 @@ static int lzma_unzip(uch* output)
+
+ static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
+ {
+- static unsigned int i = 0;
+ static unsigned char val;
+ *bufferSize = 1;
+ val = get_byte();
+--- linux-2.6.21.5.oorig/scripts/Makefile.lib 2007-07-24 15:24:44.000000000 +0200
++++ linux-2.6.21.5/scripts/Makefile.lib 2007-07-24 18:03:57.000000000 +0200
+@@ -165,6 +165,7 @@ cmd_gzip = gzip -f -9 < $< > $@
+ # LZMA
+ #
+ quiet_cmd_lzma = LZMA $@
+-cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++#cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++cmd_lzma = lzma -z $< -c > $@
+
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-001-lzma-vmlinuz.00.patch b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-001-lzma-vmlinuz.00.patch
new file mode 100644
index 0000000000..16f9ef7417
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-001-lzma-vmlinuz.00.patch
@@ -0,0 +1,26856 @@
+diff -rduNp linux-2.6.22.1.oorig/.miniconfig linux-2.6.22.1/.miniconfig
+--- linux-2.6.22.1.oorig/.miniconfig 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/.miniconfig 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,89 @@
++#make allnoconfig KCONFIG_ALLCONFIG=miniconfig
++CONFIG_X86_32=y
++CONFIG_CLOCKSOURCE_WATCHDOG=y
++CONFIG_LOCKDEP_SUPPORT=y
++CONFIG_SEMAPHORE_SLEEPERS=y
++CONFIG_MMU=y
++CONFIG_GENERIC_ISA_DMA=y
++CONFIG_GENERIC_HWEIGHT=y
++CONFIG_DMI=y
++CONFIG_INIT_ENV_ARG_LIMIT=32
++CONFIG_IKCONFIG=y
++CONFIG_IKCONFIG_PROC=y
++CONFIG_SYSFS_DEPRECATED=y
++CONFIG_BLK_DEV_INITRD=y
++CONFIG_SYSCTL=y
++CONFIG_EMBEDDED=y
++CONFIG_PRINTK=y
++CONFIG_BASE_SMALL=1
++CONFIG_BLOCK=y
++CONFIG_IOSCHED_NOOP=y
++CONFIG_DEFAULT_IOSCHED="noop"
++CONFIG_X86_GENERIC=y
++CONFIG_X86_L1_CACHE_SHIFT=7
++CONFIG_GENERIC_CALIBRATE_DELAY=y
++CONFIG_X86_WP_WORKS_OK=y
++CONFIG_X86_BSWAP=y
++CONFIG_X86_CMPXCHG64=y
++CONFIG_X86_INTEL_USERCOPY=y
++CONFIG_X86_TSC=y
++CONFIG_PREEMPT_NONE=y
++CONFIG_VM86=y
++CONFIG_HIGHMEM=y
++CONFIG_FLATMEM=y
++CONFIG_MTRR=y
++CONFIG_HZ_250=y
++CONFIG_PHYSICAL_ALIGN=0x100000
++CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
++CONFIG_PM=y
++CONFIG_ACPI=y
++CONFIG_ACPI_SLEEP=y
++CONFIG_ACPI_BLACKLIST_YEAR=0
++CONFIG_ACPI_EC=y
++CONFIG_ACPI_SYSTEM=y
++CONFIG_PCI=y
++CONFIG_PCI_GOANY=y
++CONFIG_PCI_DIRECT=y
++CONFIG_BINFMT_ELF=y
++CONFIG_STANDALONE=y
++CONFIG_BLK_DEV_LOOP=y
++CONFIG_IDE=y
++CONFIG_IDE_MAX_HWIFS=2
++CONFIG_BLK_DEV_IDE=y
++CONFIG_BLK_DEV_IDEDISK=y
++CONFIG_IDEDISK_MULTI_MODE=y
++CONFIG_BLK_DEV_IDECD=y
++CONFIG_IDE_GENERIC=y
++CONFIG_INPUT_MOUSEDEV=y
++CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
++CONFIG_INPUT_KEYBOARD=y
++CONFIG_KEYBOARD_ATKBD=y
++CONFIG_SERIO=y
++CONFIG_VT=y
++CONFIG_VT_CONSOLE=y
++CONFIG_UNIX98_PTYS=y
++CONFIG_VGA_CONSOLE=y
++CONFIG_USB_ARCH_HAS_HCD=y
++CONFIG_USB_ARCH_HAS_EHCI=y
++CONFIG_EXT2_FS=y
++CONFIG_DNOTIFY=y
++CONFIG_ISO9660_FS=y
++CONFIG_FAT_FS=y
++CONFIG_VFAT_FS=y
++CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
++CONFIG_PROC_FS=y
++CONFIG_PROC_SYSCTL=y
++CONFIG_SYSFS=y
++CONFIG_RAMFS=y
++CONFIG_SQUASHFS=y
++CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
++CONFIG_MSDOS_PARTITION=y
++CONFIG_NLS_DEFAULT="iso8859-1"
++CONFIG_AUFS=y
++CONFIG_AUFS_FAKE_DM=y
++CONFIG_EARLY_PRINTK=y
++CONFIG_DOUBLEFAULT=y
++CONFIG_ZLIB_INFLATE=y
++CONFIG_HAS_IOPORT=y
++CONFIG_GENERIC_IRQ_PROBE=y
++CONFIG_KTIME_SCALAR=y
+diff -rduNp linux-2.6.22.1.oorig/Makefile linux-2.6.22.1/Makefile
+--- linux-2.6.22.1.oorig/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -188,7 +188,7 @@ CROSS_COMPILE ?=
+ # Architecture as present in compile.h
+ UTS_MACHINE := $(ARCH)
+
+-KCONFIG_CONFIG ?= .config
++KCONFIG_CONFIG ?= .miniconfig
+
+ # SHELL used by kbuild
+ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+diff -rduNp linux-2.6.22.1.oorig/arch/i386/boot/compressed/LzmaDecode.c linux-2.6.22.1/arch/i386/boot/compressed/LzmaDecode.c
+--- linux-2.6.22.1.oorig/arch/i386/boot/compressed/LzmaDecode.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/arch/i386/boot/compressed/LzmaDecode.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,588 @@
++/*
++ LzmaDecode.c
++ LZMA Decoder (optimized for Speed version)
++
++ LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this Code, expressly permits you to
++ statically or dynamically link your Code (or bind by name) to the
++ interfaces of this file without subjecting your linked Code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#include "LzmaDecode.h"
++
++#ifndef Byte
++#define Byte unsigned char
++#endif
++
++#define kNumTopBits 24
++#define kTopValue ((UInt32)1 << kNumTopBits)
++
++#define kNumBitModelTotalBits 11
++#define kBitModelTotal (1 << kNumBitModelTotalBits)
++#define kNumMoveBits 5
++
++#define RC_READ_BYTE (*Buffer++)
++
++#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
++ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
++
++#ifdef _LZMA_IN_CB
++
++#define RC_TEST { if (Buffer == BufferLim) \
++ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
++ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
++
++#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
++
++#else
++
++#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
++
++#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
++
++#endif
++
++#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
++
++#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
++#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
++#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
++
++#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
++ { UpdateBit0(p); mi <<= 1; A0; } else \
++ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
++
++#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
++
++#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
++ { int i = numLevels; res = 1; \
++ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
++ res -= (1 << numLevels); }
++
++
++#define kNumPosBitsMax 4
++#define kNumPosStatesMax (1 << kNumPosBitsMax)
++
++#define kLenNumLowBits 3
++#define kLenNumLowSymbols (1 << kLenNumLowBits)
++#define kLenNumMidBits 3
++#define kLenNumMidSymbols (1 << kLenNumMidBits)
++#define kLenNumHighBits 8
++#define kLenNumHighSymbols (1 << kLenNumHighBits)
++
++#define LenChoice 0
++#define LenChoice2 (LenChoice + 1)
++#define LenLow (LenChoice2 + 1)
++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
++#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
++
++
++#define kNumStates 12
++#define kNumLitStates 7
++
++#define kStartPosModelIndex 4
++#define kEndPosModelIndex 14
++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
++
++#define kNumPosSlotBits 6
++#define kNumLenToPosStates 4
++
++#define kNumAlignBits 4
++#define kAlignTableSize (1 << kNumAlignBits)
++
++#define kMatchMinLen 2
++
++#define IsMatch 0
++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
++#define IsRepG0 (IsRep + kNumStates)
++#define IsRepG1 (IsRepG0 + kNumStates)
++#define IsRepG2 (IsRepG1 + kNumStates)
++#define IsRep0Long (IsRepG2 + kNumStates)
++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
++#define LenCoder (Align + kAlignTableSize)
++#define RepLenCoder (LenCoder + kNumLenProbs)
++#define Literal (RepLenCoder + kNumLenProbs)
++
++#if Literal != LZMA_BASE_SIZE
++StopCompilingDueBUG
++#endif
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
++{
++ unsigned char prop0;
++ if (size < LZMA_PROPERTIES_SIZE)
++ return LZMA_RESULT_DATA_ERROR;
++ prop0 = propsData[0];
++ if (prop0 >= (9 * 5 * 5))
++ return LZMA_RESULT_DATA_ERROR;
++ {
++ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
++ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
++ propsRes->lc = prop0;
++ /*
++ unsigned char remainder = (unsigned char)(prop0 / 9);
++ propsRes->lc = prop0 % 9;
++ propsRes->pb = remainder / 5;
++ propsRes->lp = remainder % 5;
++ */
++ }
++
++ #ifdef _LZMA_OUT_READ
++ {
++ int i;
++ propsRes->DictionarySize = 0;
++ for (i = 0; i < 4; i++)
++ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
++ if (propsRes->DictionarySize == 0)
++ propsRes->DictionarySize = 1;
++ }
++ #endif
++ return LZMA_RESULT_OK;
++}
++
++#define kLzmaStreamWasFinishedId (-1)
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *InCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
++{
++ CProb *p = vs->Probs;
++ SizeT nowPos = 0;
++ Byte previousByte = 0;
++ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
++ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
++ int lc = vs->Properties.lc;
++
++ #ifdef _LZMA_OUT_READ
++
++ UInt32 Range = vs->Range;
++ UInt32 Code = vs->Code;
++ #ifdef _LZMA_IN_CB
++ const Byte *Buffer = vs->Buffer;
++ const Byte *BufferLim = vs->BufferLim;
++ #else
++ const Byte *Buffer = inStream;
++ const Byte *BufferLim = inStream + inSize;
++ #endif
++ int state = vs->State;
++ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
++ int len = vs->RemainLen;
++ UInt32 globalPos = vs->GlobalPos;
++ UInt32 distanceLimit = vs->DistanceLimit;
++
++ Byte *dictionary = vs->Dictionary;
++ UInt32 dictionarySize = vs->Properties.DictionarySize;
++ UInt32 dictionaryPos = vs->DictionaryPos;
++
++ Byte tempDictionary[4];
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++ if (len == kLzmaStreamWasFinishedId)
++ return LZMA_RESULT_OK;
++
++ if (dictionarySize == 0)
++ {
++ dictionary = tempDictionary;
++ dictionarySize = 1;
++ tempDictionary[0] = vs->TempDictionary[0];
++ }
++
++ if (len == kLzmaNeedInitId)
++ {
++ {
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ UInt32 i;
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ rep0 = rep1 = rep2 = rep3 = 1;
++ state = 0;
++ globalPos = 0;
++ distanceLimit = 0;
++ dictionaryPos = 0;
++ dictionary[dictionarySize - 1] = 0;
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++ }
++ len = 0;
++ }
++ while(len != 0 && nowPos < outSize)
++ {
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ len--;
++ }
++ if (dictionaryPos == 0)
++ previousByte = dictionary[dictionarySize - 1];
++ else
++ previousByte = dictionary[dictionaryPos - 1];
++
++ #else /* if !_LZMA_OUT_READ */
++
++ int state = 0;
++ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
++ int len = 0;
++ const Byte *Buffer;
++ const Byte *BufferLim;
++ UInt32 Range;
++ UInt32 Code;
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++
++ {
++ UInt32 i;
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ }
++
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++
++ #endif /* _LZMA_OUT_READ */
++
++ while(nowPos < outSize)
++ {
++ CProb *prob;
++ UInt32 bound;
++ int posState = (int)(
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & posStateMask);
++
++ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ int symbol = 1;
++ UpdateBit0(prob)
++ prob = p + Literal + (LZMA_LIT_SIZE *
++ (((
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
++
++ if (state >= kNumLitStates)
++ {
++ int matchByte;
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ matchByte = dictionary[pos];
++ #else
++ matchByte = outStream[nowPos - rep0];
++ #endif
++ do
++ {
++ int bit;
++ CProb *probLit;
++ matchByte <<= 1;
++ bit = (matchByte & 0x100);
++ probLit = prob + 0x100 + bit + symbol;
++ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
++ }
++ while (symbol < 0x100);
++ }
++ while (symbol < 0x100)
++ {
++ CProb *probLit = prob + symbol;
++ RC_GET_BIT(probLit, symbol)
++ }
++ previousByte = (Byte)symbol;
++
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #endif
++ if (state < 4) state = 0;
++ else if (state < 10) state -= 3;
++ else state -= 6;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRep + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ rep3 = rep2;
++ rep2 = rep1;
++ rep1 = rep0;
++ state = state < kNumLitStates ? 0 : 3;
++ prob = p + LenCoder;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG0 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos;
++ #endif
++ UpdateBit0(prob);
++
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit == 0)
++ #else
++ if (nowPos == 0)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ state = state < kNumLitStates ? 9 : 11;
++ #ifdef _LZMA_OUT_READ
++ pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++ #endif
++
++ continue;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ }
++ }
++ else
++ {
++ UInt32 distance;
++ UpdateBit1(prob);
++ prob = p + IsRepG1 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep1;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG2 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep2;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ distance = rep3;
++ rep3 = rep2;
++ }
++ rep2 = rep1;
++ }
++ rep1 = rep0;
++ rep0 = distance;
++ }
++ state = state < kNumLitStates ? 8 : 11;
++ prob = p + RepLenCoder;
++ }
++ {
++ int numBits, offset;
++ CProb *probLen = prob + LenChoice;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenLow + (posState << kLenNumLowBits);
++ offset = 0;
++ numBits = kLenNumLowBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenChoice2;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenMid + (posState << kLenNumMidBits);
++ offset = kLenNumLowSymbols;
++ numBits = kLenNumMidBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenHigh;
++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
++ numBits = kLenNumHighBits;
++ }
++ }
++ RangeDecoderBitTreeDecode(probLen, numBits, len);
++ len += offset;
++ }
++
++ if (state < 4)
++ {
++ int posSlot;
++ state += kNumLitStates;
++ prob = p + PosSlot +
++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
++ kNumPosSlotBits);
++ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
++ if (posSlot >= kStartPosModelIndex)
++ {
++ int numDirectBits = ((posSlot >> 1) - 1);
++ rep0 = (2 | ((UInt32)posSlot & 1));
++ if (posSlot < kEndPosModelIndex)
++ {
++ rep0 <<= numDirectBits;
++ prob = p + SpecPos + rep0 - posSlot - 1;
++ }
++ else
++ {
++ numDirectBits -= kNumAlignBits;
++ do
++ {
++ RC_NORMALIZE
++ Range >>= 1;
++ rep0 <<= 1;
++ if (Code >= Range)
++ {
++ Code -= Range;
++ rep0 |= 1;
++ }
++ }
++ while (--numDirectBits != 0);
++ prob = p + Align;
++ rep0 <<= kNumAlignBits;
++ numDirectBits = kNumAlignBits;
++ }
++ {
++ int i = 1;
++ int mi = 1;
++ do
++ {
++ CProb *prob3 = prob + mi;
++ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
++ i <<= 1;
++ }
++ while(--numDirectBits != 0);
++ }
++ }
++ else
++ rep0 = posSlot;
++ if (++rep0 == (UInt32)(0))
++ {
++ /* it's for stream version */
++ len = kLzmaStreamWasFinishedId;
++ break;
++ }
++ }
++
++ len += kMatchMinLen;
++ #ifdef _LZMA_OUT_READ
++ if (rep0 > distanceLimit)
++ #else
++ if (rep0 > nowPos)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ #ifdef _LZMA_OUT_READ
++ if (dictionarySize - distanceLimit > (UInt32)len)
++ distanceLimit += len;
++ else
++ distanceLimit = dictionarySize;
++ #endif
++
++ do
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ len--;
++ outStream[nowPos++] = previousByte;
++ }
++ while(len != 0 && nowPos < outSize);
++ }
++ }
++ RC_NORMALIZE;
++
++ #ifdef _LZMA_OUT_READ
++ vs->Range = Range;
++ vs->Code = Code;
++ vs->DictionaryPos = dictionaryPos;
++ vs->GlobalPos = globalPos + (UInt32)nowPos;
++ vs->DistanceLimit = distanceLimit;
++ vs->Reps[0] = rep0;
++ vs->Reps[1] = rep1;
++ vs->Reps[2] = rep2;
++ vs->Reps[3] = rep3;
++ vs->State = state;
++ vs->RemainLen = len;
++ vs->TempDictionary[0] = tempDictionary[0];
++ #endif
++
++ #ifdef _LZMA_IN_CB
++ vs->Buffer = Buffer;
++ vs->BufferLim = BufferLim;
++ #else
++ *inSizeProcessed = (SizeT)(Buffer - inStream);
++ #endif
++ *outSizeProcessed = nowPos;
++ return LZMA_RESULT_OK;
++}
+diff -rduNp linux-2.6.22.1.oorig/arch/i386/boot/compressed/LzmaDecode.h linux-2.6.22.1/arch/i386/boot/compressed/LzmaDecode.h
+--- linux-2.6.22.1.oorig/arch/i386/boot/compressed/LzmaDecode.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/arch/i386/boot/compressed/LzmaDecode.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,131 @@
++/*
++ LzmaDecode.h
++ LZMA Decoder interface
++
++ LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this code, expressly permits you to
++ statically or dynamically link your code (or bind by name) to the
++ interfaces of this file without subjecting your linked code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#ifndef __LZMADECODE_H
++#define __LZMADECODE_H
++
++/* #define _LZMA_IN_CB */
++/* Use callback for input data */
++
++/* #define _LZMA_OUT_READ */
++/* Use read function for output data */
++
++/* #define _LZMA_PROB32 */
++/* It can increase speed on some 32-bit CPUs,
++ but memory usage will be doubled in that case */
++
++/* #define _LZMA_LOC_OPT */
++/* Enable local speed optimizations inside code */
++
++/* #define _LZMA_SYSTEM_SIZE_T */
++/* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
++
++#ifndef UInt32
++#ifdef _LZMA_UINT32_IS_ULONG
++#define UInt32 unsigned long
++#else
++#define UInt32 unsigned int
++#endif
++#endif
++
++#ifndef SizeT
++#ifdef _LZMA_SYSTEM_SIZE_T
++#include <stddef.h>
++#define SizeT size_t
++#else
++#define SizeT UInt32
++#endif
++#endif
++
++#ifdef _LZMA_PROB32
++#define CProb UInt32
++#else
++#define CProb unsigned short
++#endif
++
++#define LZMA_RESULT_OK 0
++#define LZMA_RESULT_DATA_ERROR 1
++
++#ifdef _LZMA_IN_CB
++typedef struct _ILzmaInCallback
++{
++ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
++} ILzmaInCallback;
++#endif
++
++#define LZMA_BASE_SIZE 1846
++#define LZMA_LIT_SIZE 768
++
++#define LZMA_PROPERTIES_SIZE 5
++
++typedef struct _CLzmaProperties
++{
++ int lc;
++ int lp;
++ int pb;
++ #ifdef _LZMA_OUT_READ
++ UInt32 DictionarySize;
++ #endif
++}CLzmaProperties;
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
++
++#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
++
++#define kLzmaNeedInitId (-2)
++
++typedef struct _CLzmaDecoderState
++{
++ CLzmaProperties Properties;
++ CProb *Probs;
++
++ #ifdef _LZMA_IN_CB
++ const unsigned char *Buffer;
++ const unsigned char *BufferLim;
++ #endif
++
++ #ifdef _LZMA_OUT_READ
++ unsigned char *Dictionary;
++ UInt32 Range;
++ UInt32 Code;
++ UInt32 DictionaryPos;
++ UInt32 GlobalPos;
++ UInt32 DistanceLimit;
++ UInt32 Reps[4];
++ int State;
++ int RemainLen;
++ unsigned char TempDictionary[4];
++ #endif
++} CLzmaDecoderState;
++
++#ifdef _LZMA_OUT_READ
++#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
++#endif
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *inCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
++
++#endif
+diff -rduNp linux-2.6.22.1.oorig/arch/i386/boot/compressed/Makefile linux-2.6.22.1/arch/i386/boot/compressed/Makefile
+--- linux-2.6.22.1.oorig/arch/i386/boot/compressed/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/arch/i386/boot/compressed/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -4,15 +4,16 @@
+ # create a compressed vmlinux image from the original vmlinux
+ #
+
+-targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o \
+- vmlinux.bin.all vmlinux.relocs
++tragets := head.o lzma_misc.o piggy.o \
++ vmlinux.bin.all vmlinux.relocs \
++ vmlinux vmlinux.bin vmlinux.bin.gz
+ EXTRA_AFLAGS := -traditional
+
+ LDFLAGS_vmlinux := -T
+-CFLAGS_misc.o += -fPIC
++CFLAGS_lzma_misc.o += -fPIC
+ hostprogs-y := relocs
+
+-$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
++$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/lzma_misc.o $(obj)/piggy.o FORCE
+ $(call if_changed,ld)
+ @:
+
+@@ -33,10 +34,10 @@ $(obj)/vmlinux.bin.all: $(vmlinux.bin.al
+
+ ifdef CONFIG_RELOCATABLE
+ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
+- $(call if_changed,gzip)
++ $(call if_changed,lzma)
+ else
+ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+- $(call if_changed,gzip)
++ $(call if_changed,lzma)
+ endif
+
+ LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
+diff -rduNp linux-2.6.22.1.oorig/arch/i386/boot/compressed/lzma_misc.c linux-2.6.22.1/arch/i386/boot/compressed/lzma_misc.c
+--- linux-2.6.22.1.oorig/arch/i386/boot/compressed/lzma_misc.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/arch/i386/boot/compressed/lzma_misc.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,290 @@
++/*
++ * lzma_misc.c
++ *
++ * Decompress LZMA compressed vmlinuz
++ * Version 0.9 Copyright (c) Ming-Ching Tiew mctiew@yahoo.com
++ * Program adapted from misc.c for 2.6.20.1 kernel
++ * Please refer to misc.c for authorship and copyright.
++ * Date: 25 March 2007
++ * Source released under GPL
++ */
++
++#undef CONFIG_PARAVIRT
++#include <linux/linkage.h>
++#include <linux/vmalloc.h>
++#include <linux/screen_info.h>
++#include <asm/io.h>
++#include <asm/page.h>
++#include <asm/boot.h>
++
++/* WARNING!!
++ * This code is compiled with -fPIC and it is relocated dynamically
++ * at run time, but no relocation processing is performed.
++ * This means that it is not safe to place pointers in static structures.
++ */
++
++#define OF(args) args
++#define STATIC static
++
++#undef memset
++#undef memcpy
++
++typedef unsigned char uch;
++typedef unsigned short ush;
++typedef unsigned long ulg;
++
++#define WSIZE 0x80000000 /* Window size must be at least 32k,
++ * and a power of two
++ * We don't actually have a window just
++ * a huge output buffer so I report
++ * a 2G windows size, as that should
++ * always be larger than our output buffer.
++ */
++
++static uch *inbuf; /* input buffer */
++static uch *window; /* Sliding window buffer, (and final output buffer) */
++
++static unsigned insize; /* valid bytes in inbuf */
++static unsigned inptr; /* index of next byte to be processed in inbuf */
++
++/* gzip flag byte */
++#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
++#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
++#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
++#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
++#define COMMENT 0x10 /* bit 4 set: file comment present */
++#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
++#define RESERVED 0xC0 /* bit 6,7: reserved */
++
++#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
++
++/* Diagnostic functions */
++#ifdef DEBUG
++# define Assert(cond,msg) {if(!(cond)) error(msg);}
++# define Trace(x) fprintf x
++# define Tracev(x) {if (verbose) fprintf x ;}
++# define Tracevv(x) {if (verbose>1) fprintf x ;}
++# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
++# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
++#else
++# define Assert(cond,msg)
++# define Trace(x)
++# define Tracev(x)
++# define Tracevv(x)
++# define Tracec(c,x)
++# define Tracecv(c,x)
++#endif
++
++static int fill_inbuf(void);
++static void error(char *m);
++
++/*
++ * This is set up by the setup-routine at boot-time
++ */
++static unsigned char *real_mode; /* Pointer to real-mode data */
++
++#define RM_EXT_MEM_K (*(unsigned short *)(real_mode + 0x2))
++#ifndef STANDARD_MEMORY_BIOS_CALL
++#define RM_ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0))
++#endif
++#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
++
++extern unsigned char input_data[];
++extern int input_len;
++
++static long bytes_out = 0;
++
++static void *memcpy(void *dest, const void *src, unsigned n);
++
++static void putstr(const char *);
++
++static unsigned long free_mem_ptr;
++static unsigned long free_mem_end_ptr;
++
++#define HEAP_SIZE 0x3000
++
++static char *vidmem = (char *)0xb8000;
++static int vidport;
++static int lines, cols;
++
++#ifdef CONFIG_X86_NUMAQ
++void *xquad_portio;
++#endif
++
++static void scroll(void)
++{
++ int i;
++
++ memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
++ for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
++ vidmem[i] = ' ';
++}
++
++static void putstr(const char *s)
++{
++ int x,y,pos;
++ char c;
++
++ x = RM_SCREEN_INFO.orig_x;
++ y = RM_SCREEN_INFO.orig_y;
++
++ while ( ( c = *s++ ) != '\0' ) {
++ if ( c == '\n' ) {
++ x = 0;
++ if ( ++y >= lines ) {
++ scroll();
++ y--;
++ }
++ } else {
++ vidmem [ ( x + cols * y ) * 2 ] = c;
++ if ( ++x >= cols ) {
++ x = 0;
++ if ( ++y >= lines ) {
++ scroll();
++ y--;
++ }
++ }
++ }
++ }
++
++ RM_SCREEN_INFO.orig_x = x;
++ RM_SCREEN_INFO.orig_y = y;
++
++ pos = (x + cols * y) * 2; /* Update cursor position */
++ outb_p(14, vidport);
++ outb_p(0xff & (pos >> 9), vidport+1);
++ outb_p(15, vidport);
++ outb_p(0xff & (pos >> 1), vidport+1);
++}
++
++static void* memcpy(void* dest, const void* src, unsigned n)
++{
++ int i;
++ char *d = (char *)dest, *s = (char *)src;
++
++ for (i=0;i<n;i++) d[i] = s[i];
++ return dest;
++}
++
++/* ===========================================================================
++ * Fill the input buffer. This is called only when the buffer is empty
++ * and at least one byte is really needed.
++ */
++static int fill_inbuf(void)
++{
++ error("ran out of input data");
++ return 0;
++}
++
++/* ===========================================================================
++ */
++static void error(char *x)
++{
++ putstr("\n\n");
++ putstr(x);
++ putstr("\n\n -- System halted");
++
++ while(1); /* Halt */
++}
++
++#define _LZMA_IN_CB
++#include "LzmaDecode.h"
++#include "LzmaDecode.c"
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize);
++
++/*
++ * Do the lzma decompression
++ */
++static int lzma_unzip(uch* output)
++{
++
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++
++ ILzmaInCallback callback;
++ callback.Read = read_byte;
++
++ // lzma args
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ // skip dictionary size
++ for (i = 0; i < 4; i++)
++ get_byte();
++ // get uncompressed size
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // skip high order bytes
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ // Just point it beyond
++ state.Probs = (CProb*) ( free_mem_ptr );
++ // decompress kernel
++ if (LzmaDecode( &state, &callback,
++ (unsigned char*)output, uncompressedSize, &i) == LZMA_RESULT_OK)
++ {
++ if ( i != uncompressedSize )
++ error( "kernel corrupted!\n");
++ bytes_out = i;
++ return 0;
++ }
++ return 1;
++}
++
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned int i = 0;
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++asmlinkage void decompress_kernel(void *rmode, unsigned long end,
++ uch *input_data, unsigned long input_len, uch *output)
++{
++ real_mode = rmode;
++
++ if (RM_SCREEN_INFO.orig_video_mode == 7) {
++ vidmem = (char *) 0xb0000;
++ vidport = 0x3b4;
++ } else {
++ vidmem = (char *) 0xb8000;
++ vidport = 0x3d4;
++ }
++
++ lines = RM_SCREEN_INFO.orig_video_lines;
++ cols = RM_SCREEN_INFO.orig_video_cols;
++
++ window = output; /* Output buffer (Normally at 1M) */
++ free_mem_ptr = end; /* Heap */
++ free_mem_end_ptr = end + HEAP_SIZE;
++ inbuf = input_data; /* Input buffer */
++ insize = input_len;
++ inptr = 0;
++
++ if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
++ error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
++ if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
++ error("Destination address too large");
++#ifndef CONFIG_RELOCATABLE
++ if ((u32)output != LOAD_PHYSICAL_ADDR)
++ error("Wrong destination address");
++#endif
++ if( lzma_unzip(output) != 0 )
++ {
++ error("inflate error\n");
++ }
++ putstr("Ok, booting the kernel.\n");
++
++ return;
++}
+diff -rduNp linux-2.6.22.1.oorig/arch/i386/boot/compressed/vmlinux.scr linux-2.6.22.1/arch/i386/boot/compressed/vmlinux.scr
+--- linux-2.6.22.1.oorig/arch/i386/boot/compressed/vmlinux.scr 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/arch/i386/boot/compressed/vmlinux.scr 2007-07-24 14:17:46.000000000 +0200
+@@ -3,8 +3,8 @@ SECTIONS
+ .data.compressed : {
+ input_len = .;
+ LONG(input_data_end - input_data) input_data = .;
++ output_len = . + 5;
+ *(.data)
+- output_len = . - 4;
+ input_data_end = .;
+ }
+ }
+diff -rduNp linux-2.6.22.1.oorig/drivers/block/Kconfig linux-2.6.22.1/drivers/block/Kconfig
+--- linux-2.6.22.1.oorig/drivers/block/Kconfig 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/block/Kconfig 2007-07-24 14:17:46.000000000 +0200
+@@ -406,6 +406,47 @@ config BLK_DEV_RAM_BLOCKSIZE
+ setups function - apparently needed by the rd_load_image routine
+ that supposes the filesystem in the image uses a 1024 blocksize.
+
++config LZMA_INITRD
++ boolean "Allow LZMA compression on initrd"
++ depends on BLK_DEV_INITRD=y
++ default "y"
++ help
++ Use lzma compression on initrd, example 'lzma e initrd initrd.7z -d16'.
++ If you have sufficient memory, you could compress using bigger dictionary size,
++ 'lzma e initrd initrd.7z'.
++
++config LZMA_INITRD_KMALLOC_ONLY
++ boolean "Use only kmalloc, do not use vmalloc on lzma initrd"
++ depends on LZMA_INITRD=y
++ default "n"
++ help
++ Set to y if you do not want to use vmalloc, ie use only kmalloc.
++
++config LZMA_INITRAM_FS
++ boolean "Allow LZMA compression on initramfs"
++ depends on BLK_DEV_RAM=y
++ default "y"
++ help
++ Use lzma compression on initramfs, example 'lzma e initramfs.cpio initramfs.cpio.lzma'.
++
++config LZMA_INITRAM_FS_SMALLMEM
++ boolean "Use lzma compression with small dictonary size."
++ depends on LZMA_INITRAM_FS=y
++ default "y"
++ help
++ Use lzma compression on initramfs with small dictionary size, example
++ 'lzma e initramfs.cpio initramfs.cpio.lzma -d16'.
++ Affects only the initramfs.cpio in the ~usr directory, which is compiled into
++ the kernel. If you prepared initramfs.cpio for use with bootloader, you would
++ need to specify the commandline options (-d16) yourself.
++
++config LZMA_INITRAM_FS_KMALLOC_ONLY
++ boolean "Use only kmalloc, do not use vmalloc on lzma initramfs"
++ depends on LZMA_INITRAM_FS=y
++ default "n"
++ help
++ Set to y if you do not want to use vmalloc, ie use only kmalloc.
++
+ config CDROM_PKTCDVD
+ tristate "Packet writing on CD/DVD media"
+ depends on !UML
+diff -rduNp linux-2.6.22.1.oorig/fs/Kconfig linux-2.6.22.1/fs/Kconfig
+--- linux-2.6.22.1.oorig/fs/Kconfig 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/fs/Kconfig 2007-07-24 14:17:46.000000000 +0200
+@@ -1367,6 +1367,71 @@ config CRAMFS
+
+ If unsure, say N.
+
++config SQUASHFS
++ tristate "SquashFS 3.2 - Squashed file system support"
++ select ZLIB_INFLATE
++ help
++ Saying Y here includes support for SquashFS 3.2 (a Compressed Read-Only File
++ System). Squashfs is a highly compressed read-only filesystem for Linux.
++ It uses zlib compression to compress both files, inodes and directories.
++ Inodes in the system are very small and all blocks are packed to minimise
++ data overhead. Block sizes greater than 4K are supported up to a maximum of 64K.
++ SquashFS 3.1 supports 64 bit filesystems and files (larger than 4GB), full
++ uid/gid information, hard links and timestamps.
++
++ Squashfs is intended for general read-only filesystem use, for archival
++ use (i.e. in cases where a .tar.gz file may be used), and in embedded
++ systems where low overhead is needed. Further information and filesystem tools
++ are available from http://squashfs.sourceforge.net.
++
++ If you want to compile this as a module ( = code which can be
++ inserted in and removed from the running kernel whenever you want),
++ say M here and read <file:Documentation/modules.txt>. The module
++ will be called squashfs. Note that the root file system (the one
++ containing the directory /) cannot be compiled as a module.
++
++ If unsure, say N.
++
++config SQUASHFS_EMBEDDED
++
++ bool "Additional options for memory-constrained systems"
++ depends on SQUASHFS
++ default n
++ help
++ Saying Y here allows you to specify cache sizes and how Squashfs
++ allocates memory. This is only intended for memory constrained
++ systems.
++
++ If unsure, say N.
++
++config SQUASHFS_FRAGMENT_CACHE_SIZE
++ int "Number of fragments cached" if SQUASHFS_EMBEDDED
++ depends on SQUASHFS
++ default "3"
++ help
++ By default SquashFS caches the last 3 fragments read from
++ the filesystem. Increasing this amount may mean SquashFS
++ has to re-read fragments less often from disk, at the expense
++ of extra system memory. Decreasing this amount will mean
++ SquashFS uses less memory at the expense of extra reads from disk.
++
++ Note there must be at least one cached fragment. Anything
++ much more than three will probably not make much difference.
++
++config SQUASHFS_VMALLOC
++ bool "Use Vmalloc rather than Kmalloc" if SQUASHFS_EMBEDDED
++ depends on SQUASHFS
++ default n
++ help
++ By default SquashFS uses kmalloc to obtain fragment cache memory.
++ Kmalloc memory is the standard kernel allocator, but it can fail
++ on memory constrained systems. Because of the way Vmalloc works,
++ Vmalloc can succeed when kmalloc fails. Specifying this option
++ will make SquashFS always use Vmalloc to allocate the
++ fragment cache memory.
++
++ If unsure, say N.
++
+ config VXFS_FS
+ tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
+ depends on BLOCK
+@@ -2072,3 +2137,4 @@ source "fs/dlm/Kconfig"
+
+ endmenu
+
++source "fs/aufs/Kconfig"
+diff -rduNp linux-2.6.22.1.oorig/fs/Makefile linux-2.6.22.1/fs/Makefile
+--- linux-2.6.22.1.oorig/fs/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/fs/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -72,6 +72,7 @@ obj-$(CONFIG_JBD) += jbd/
+ obj-$(CONFIG_JBD2) += jbd2/
+ obj-$(CONFIG_EXT2_FS) += ext2/
+ obj-$(CONFIG_CRAMFS) += cramfs/
++obj-$(CONFIG_SQUASHFS) += squashfs/
+ obj-$(CONFIG_RAMFS) += ramfs/
+ obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
+ obj-$(CONFIG_CODA_FS) += coda/
+@@ -118,3 +119,4 @@ obj-$(CONFIG_HPPFS) += hppfs/
+ obj-$(CONFIG_DEBUG_FS) += debugfs/
+ obj-$(CONFIG_OCFS2_FS) += ocfs2/
+ obj-$(CONFIG_GFS2_FS) += gfs2/
++obj-$(CONFIG_AUFS) += aufs/
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/Kconfig linux-2.6.22.1/fs/aufs/Kconfig
+--- linux-2.6.22.1.oorig/fs/aufs/Kconfig 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/Kconfig 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,73 @@
++config AUFS
++ tristate "Another unionfs"
++ help
++ Aufs is a stackable unification filesystem such as Unionfs,
++ which unifies several directories and provides a merged single
++ directory.
++ In the early days, aufs was entirely re-designed and
++ re-implemented Unionfs Version 1.x series. After many original
++ ideas, approaches and improvements, it becomes totally
++ different from Unionfs while keeping the basic features.
++ See Unionfs for the basic features.
++
++if AUFS
++comment "These options are generated automatically for "#UTS_RELEASE
++
++config AUFS_FAKE_DM
++ bool "Use simplified (fake) nameidata"
++ depends on AUFS
++ default y
++ help
++ Faking nameidata (VFS internal data), you can get better performance
++ in some cases.
++
++choice
++ prompt "Maximum number of branches"
++ depends on AUFS
++ default AUFS_BRANCH_MAX_127
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_127
++ bool "127"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_511
++ bool "511"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++config AUFS_BRANCH_MAX_1023
++ bool "1023"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++
++config AUFS_BRANCH_MAX_32767
++ bool "32767"
++ help
++ Specifies the maximum number of branches (or member directories) in a single aufs. The larger value consumes more system resources and has an impact to performance.
++endchoice
++config AUFS_DEBUG
++ bool "Debug aufs"
++ depends on AUFS
++ default y
++ help
++ Enable this to compile aufs internal debug code.
++ The performance will be damaged.
++
++config AUFS_COMPAT
++ bool "Compatibility with Unionfs (obsolete)"
++ depends on AUFS
++ default n
++ help
++ This makes aufs compatible with unionfs-style mount options and some
++ behaviours.
++ The dirs= mount option and =nfsro branch permission flag are always
++ interpreted as br: mount option and =ro flag respectively. The
++ 'debug', 'delete' and 'imap' mount options are ignored.
++ If you disable this option, you will get,
++ - aufs issues a warning about the ignored mount options
++ - the default branch permission flag is set. RW for the first branch,
++ and RO for the rests.
++ - the name of a internal file which represents the directory is
++ 'opaque', becomes '.wh..wh..opq'
++ - the 'diropq=w' mount option is set by default
++endif
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/Makefile linux-2.6.22.1/fs/aufs/Makefile
+--- linux-2.6.22.1.oorig/fs/aufs/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,18 @@
++# AUFS Makefile for the Linux 2.6.16 and later
++# $Id: Makefile,v 1.29 2007/04/23 00:59:50 sfjro Exp $
++
++obj-$(CONFIG_AUFS) += aufs.o
++aufs-y := module.o super.o sbinfo.o xino.o \
++ branch.o cpup.o whout.o plink.o wkq.o dcsub.o vfsub.o \
++ opts.o \
++ dentry.o dinfo.o \
++ file.o f_op.o finfo.o \
++ dir.o vdir.o \
++ inode.o i_op.o i_op_add.o i_op_del.o i_op_ren.o iinfo.o \
++ misc.o
++#xattr.o
++aufs-$(CONFIG_AUFS_SYSAUFS) += sysaufs.o
++aufs-$(CONFIG_AUFS_HINOTIFY) += hinotify.o
++aufs-$(CONFIG_AUFS_EXPORT) += export.o
++#aufs-$(CONFIG_DEBUGFS) += dbgfs.o
++aufs-$(CONFIG_AUFS_DEBUG) += debug.o
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/aufs.h linux-2.6.22.1/fs/aufs/aufs.h
+--- linux-2.6.22.1.oorig/fs/aufs/aufs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/aufs.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,64 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: aufs.h,v 1.24 2007/05/14 03:41:51 sfjro Exp $ */
++
++#ifndef __AUFS_H__
++#define __AUFS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/version.h>
++
++/* limited support before 2.6.16, curretly 2.6.15 only. */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
++#define atomic_long_t atomic_t
++#define atomic_long_set atomic_set
++#define timespec_to_ns(ts) ({(long long)(ts)->tv_sec;})
++#define D_CHILD d_child
++#else
++#define D_CHILD d_u.d_child
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++#include "debug.h"
++
++#include "branch.h"
++#include "cpup.h"
++#include "dcsub.h"
++#include "dentry.h"
++#include "dir.h"
++#include "file.h"
++#include "inode.h"
++#include "misc.h"
++#include "module.h"
++#include "opts.h"
++#include "super.h"
++#include "sysaufs.h"
++#include "vfsub.h"
++#include "whout.h"
++#include "wkq.h"
++//#include "xattr.h"
++
++#if defined(CONFIG_AUFS_MODULE) && !defined(CONFIG_AUFS_KSIZE_PATCH)
++#define ksize(p) (-1U)
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/branch.c linux-2.6.22.1/fs/aufs/branch.c
+--- linux-2.6.22.1.oorig/fs/aufs/branch.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/branch.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,818 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: branch.c,v 1.49 2007/05/14 03:38:23 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++static void free_branch(struct aufs_branch *br)
++{
++ TraceEnter();
++
++ if (br->br_xino)
++ fput(br->br_xino);
++ dput(br->br_wh);
++ dput(br->br_plink);
++ mntput(br->br_mnt);
++ DEBUG_ON(br_count(br) || atomic_read(&br->br_wh_running));
++ kfree(br);
++}
++
++/*
++ * frees all branches
++ */
++void free_branches(struct aufs_sbinfo *sbinfo)
++{
++ aufs_bindex_t bmax;
++ struct aufs_branch **br;
++
++ TraceEnter();
++ bmax = sbinfo->si_bend + 1;
++ br = sbinfo->si_branch;
++ while (bmax--)
++ free_branch(*br++);
++}
++
++/*
++ * find the index of a branch which is specified by @br_id.
++ */
++int find_brindex(struct super_block *sb, aufs_bindex_t br_id)
++{
++ aufs_bindex_t bindex, bend;
++
++ TraceEnter();
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (sbr_id(sb, bindex) == br_id)
++ return bindex;
++ return -1;
++}
++
++/*
++ * test if the @br is readonly or not.
++ */
++int br_rdonly(struct aufs_branch *br)
++{
++ return ((br->br_mnt->mnt_sb->s_flags & MS_RDONLY)
++ || !br_writable(br->br_perm))
++ ? -EROFS : 0;
++}
++
++/*
++ * returns writable branch index, otherwise an error.
++ * todo: customizable writable-branch-policy
++ */
++static int find_rw_parent(struct dentry *dentry, aufs_bindex_t bend)
++{
++ int err;
++ aufs_bindex_t bindex, candidate;
++ struct super_block *sb;
++ struct dentry *parent, *hidden_parent;
++
++ err = bend;
++ sb = dentry->d_sb;
++ parent = dget_parent(dentry);
++#if 1 // branch policy
++ hidden_parent = au_h_dptr_i(parent, bend);
++ if (hidden_parent && !br_rdonly(stobr(sb, bend)))
++ goto out; /* success */
++#endif
++
++ candidate = -1;
++ for (bindex = dbstart(parent); bindex <= bend; bindex++) {
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ if (hidden_parent && !br_rdonly(stobr(sb, bindex))) {
++#if 0 // branch policy
++ if (candidate == -1)
++ candidate = bindex;
++ if (!au_test_perm(hidden_parent->d_inode, MAY_WRITE))
++ return bindex;
++#endif
++ err = bindex;
++ goto out; /* success */
++ }
++ }
++#if 0 // branch policy
++ err = candidate;
++ if (candidate != -1)
++ goto out; /* success */
++#endif
++ err = -EROFS;
++
++ out:
++ dput(parent);
++ return err;
++}
++
++int find_rw_br(struct super_block *sb, aufs_bindex_t bend)
++{
++ aufs_bindex_t bindex;
++
++ for (bindex = bend; bindex >= 0; bindex--)
++ if (!br_rdonly(stobr(sb, bindex)))
++ return bindex;
++ return -EROFS;
++}
++
++int find_rw_parent_br(struct dentry *dentry, aufs_bindex_t bend)
++{
++ int err;
++
++ err = find_rw_parent(dentry, bend);
++ if (err >= 0)
++ return err;
++ return find_rw_br(dentry->d_sb, bend);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if two hidden_dentries have overlapping branches.
++ */
++//todo: try is_subdir()
++static int do_is_overlap(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ struct dentry *d;
++
++ d = hidden_d1;
++ do {
++ if (unlikely(d == hidden_d2))
++ return 1;
++ d = d->d_parent; // dget_parent()
++ } while (!IS_ROOT(d));
++
++ return (d == hidden_d2);
++}
++
++#if defined(CONFIG_BLK_DEV_LOOP) || defined(CONFIG_BLK_DEV_LOOP_MODULE)
++#include <linux/loop.h>
++static int is_overlap_loopback(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ struct inode *hidden_inode;
++ struct loop_device *l;
++
++ hidden_inode = hidden_d1->d_inode;
++ if (MAJOR(hidden_inode->i_sb->s_dev) != LOOP_MAJOR)
++ return 0;
++
++ l = hidden_inode->i_sb->s_bdev->bd_disk->private_data;
++ hidden_d1 = l->lo_backing_file->f_dentry;
++ if (unlikely(hidden_d1->d_sb == sb))
++ return 1;
++ return do_is_overlap(sb, hidden_d1, hidden_d2);
++}
++#else
++#define is_overlap_loopback(sb, hidden_d1, hidden_d2) 0
++#endif
++
++static int is_overlap(struct super_block *sb, struct dentry *hidden_d1,
++ struct dentry *hidden_d2)
++{
++ LKTRTrace("d1 %.*s, d2 %.*s\n", DLNPair(hidden_d1), DLNPair(hidden_d2));
++ if (unlikely(hidden_d1 == hidden_d2))
++ return 1;
++ return do_is_overlap(sb, hidden_d1, hidden_d2)
++ || do_is_overlap(sb, hidden_d2, hidden_d1)
++ || is_overlap_loopback(sb, hidden_d1, hidden_d2)
++ || is_overlap_loopback(sb, hidden_d2, hidden_d1);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int init_br_wh(struct super_block *sb, aufs_bindex_t bindex,
++ struct aufs_branch *br, int new_perm,
++ struct dentry *h_root, struct vfsmount *h_mnt)
++{
++ int err, old_perm;
++ struct inode *dir = sb->s_root->d_inode,
++ *h_dir = h_root->d_inode;
++ const int new = (bindex < 0);
++
++ LKTRTrace("b%d, new_perm %d\n", bindex, new_perm);
++
++ if (new)
++ hi_lock_parent(h_dir);
++ else
++ hdir_lock(h_dir, dir, bindex);
++
++ br_wh_write_lock(br);
++ old_perm = br->br_perm;
++ br->br_perm = new_perm;
++ err = init_wh(h_root, br, au_do_nfsmnt(h_mnt), sb);
++ br->br_perm = old_perm;
++ br_wh_write_unlock(br);
++
++ if (new)
++ i_unlock(h_dir);
++ else
++ hdir_unlock(h_dir, dir, bindex);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * returns a newly allocated branch. @new_nbranch is a number of branches
++ * after adding a branch.
++ */
++static struct aufs_branch *alloc_addbr(struct super_block *sb, int new_nbranch)
++{
++ struct aufs_branch **branchp, *add_branch;
++ int sz;
++ void *p;
++ struct dentry *root;
++ struct inode *inode;
++ struct aufs_hinode *hinodep;
++ struct aufs_hdentry *hdentryp;
++
++ LKTRTrace("new_nbranch %d\n", new_nbranch);
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ IiMustWriteLock(inode);
++
++ add_branch = kmalloc(sizeof(*add_branch), GFP_KERNEL);
++ //if (LktrCond) {kfree(add_branch); add_branch = NULL;}
++ if (unlikely(!add_branch))
++ goto out;
++
++ sz = sizeof(*branchp) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*branchp);
++ p = stosi(sb)->si_branch;
++ branchp = au_kzrealloc(p, sz, sizeof(*branchp) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) branchp = NULL;
++ if (unlikely(!branchp))
++ goto out;
++ stosi(sb)->si_branch = branchp;
++
++ sz = sizeof(*hdentryp) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*hdentryp);
++ p = dtodi(root)->di_hdentry;
++ hdentryp = au_kzrealloc(p, sz, sizeof(*hdentryp) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) hdentryp = NULL;
++ if (unlikely(!hdentryp))
++ goto out;
++ dtodi(root)->di_hdentry = hdentryp;
++
++ sz = sizeof(*hinodep) * (new_nbranch - 1);
++ if (unlikely(!sz))
++ sz = sizeof(*hinodep);
++ p = itoii(inode)->ii_hinode;
++ hinodep = au_kzrealloc(p, sz, sizeof(*hinodep) * new_nbranch,
++ GFP_KERNEL);
++ //if (LktrCond) hinodep = NULL; // unavailable test
++ if (unlikely(!hinodep))
++ goto out;
++ itoii(inode)->ii_hinode = hinodep;
++ return add_branch; /* success */
++
++ out:
++ kfree(add_branch);
++ TraceErr(-ENOMEM);
++ return ERR_PTR(-ENOMEM);
++}
++
++/*
++ * test if the branch permission is legal or not.
++ */
++static int test_br(struct super_block *sb, struct inode *inode, int brperm,
++ char *path)
++{
++ int err;
++
++ err = 0;
++ if (unlikely(br_writable(brperm) && IS_RDONLY(inode))) {
++ Err("write permission for readonly fs or inode, %s\n", path);
++ err = -EINVAL;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * retunrs,,,
++ * 0: success, the caller will add it
++ * plus: success, it is already unified, the caller should ignore it
++ * minus: error
++ */
++static int test_add(struct super_block *sb, struct opt_add *add, int remount)
++{
++ int err;
++ struct dentry *root;
++ struct inode *inode, *hidden_inode;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%s, remo%d\n", add->path, remount);
++
++ root = sb->s_root;
++ if (unlikely(au_find_dbindex(root, add->nd.dentry) != -1)) {
++ err = 1;
++ if (!remount) {
++ err = -EINVAL;
++ Err("%s duplicated\n", add->path);
++ }
++ goto out;
++ }
++
++ err = -ENOSPC; //-E2BIG;
++ bend = sbend(sb);
++ //if (LktrCond) bend = AUFS_BRANCH_MAX;
++ if (unlikely(AUFS_BRANCH_MAX <= add->bindex
++ || AUFS_BRANCH_MAX - 1 <= bend)) {
++ Err("number of branches exceeded %s\n", add->path);
++ goto out;
++ }
++
++ err = -EDOM;
++ if (unlikely(add->bindex < 0 || bend + 1 < add->bindex)) {
++ Err("bad index %d\n", add->bindex);
++ goto out;
++ }
++
++ inode = add->nd.dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++ err = -ENOENT;
++ if (unlikely(!inode->i_nlink)) {
++ Err("no existence %s\n", add->path);
++ goto out;
++ }
++
++ err = -EINVAL;
++ if (unlikely(inode->i_sb == sb)) {
++ Err("%s must be outside\n", add->path);
++ goto out;
++ }
++
++#if 1 //ndef CONFIG_AUFS_ROBR
++ if (unlikely(au_is_aufs(inode->i_sb)
++ || !strcmp(au_sbtype(inode->i_sb), "unionfs"))) {
++ Err("nested " AUFS_NAME " %s\n", add->path);
++ goto out;
++ }
++#endif
++
++#ifdef AuNoNfsBranch
++ if (unlikely(au_is_nfs(inode->i_sb))) {
++ Err(AuNoNfsBranchMsg ". %s\n", add->path);
++ goto out;
++ }
++#endif
++
++ err = test_br(sb, add->nd.dentry->d_inode, add->perm, add->path);
++ if (unlikely(err))
++ goto out;
++
++ if (unlikely(bend == -1))
++ return 0; /* success */
++
++ hidden_inode = au_h_dptr(root)->d_inode;
++ if (unlikely(au_flag_test(sb, AuFlag_WARN_PERM)
++ && ((hidden_inode->i_mode & S_IALLUGO)
++ != (inode->i_mode & S_IALLUGO)
++ || hidden_inode->i_uid != inode->i_uid
++ || hidden_inode->i_gid != inode->i_gid)))
++ Warn("uid/gid/perm %s %u/%u/0%o, %u/%u/0%o\n",
++ add->path,
++ inode->i_uid, inode->i_gid, (inode->i_mode & S_IALLUGO),
++ hidden_inode->i_uid, hidden_inode->i_gid,
++ (hidden_inode->i_mode & S_IALLUGO));
++
++ err = -EINVAL;
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(is_overlap(sb, add->nd.dentry,
++ au_h_dptr_i(root, bindex)))) {
++ Err("%s is overlapped\n", add->path);
++ goto out;
++ }
++ err = 0;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int br_add(struct super_block *sb, struct opt_add *add, int remount)
++{
++ int err, sz;
++ aufs_bindex_t bend, add_bindex;
++ struct dentry *root;
++ struct aufs_iinfo *iinfo;
++ struct aufs_sbinfo *sbinfo;
++ struct aufs_dinfo *dinfo;
++ struct inode *root_inode;
++ unsigned long long maxb;
++ struct aufs_branch **branchp, *add_branch;
++ struct aufs_hdentry *hdentryp;
++ struct aufs_hinode *hinodep;
++
++ LKTRTrace("b%d, %s, 0x%x, %.*s\n", add->bindex, add->path,
++ add->perm, DLNPair(add->nd.dentry));
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ root_inode = root->d_inode;
++ IMustLock(root_inode);
++ IiMustWriteLock(root_inode);
++
++ err = test_add(sb, add, remount);
++ if (unlikely(err < 0))
++ goto out;
++ if (unlikely(err))
++ return 0; /* success */
++
++ bend = sbend(sb);
++ add_branch = alloc_addbr(sb, bend + 2);
++ err = PTR_ERR(add_branch);
++ if (IS_ERR(add_branch))
++ goto out;
++
++ err = 0;
++ rw_init_nolock(&add_branch->br_wh_rwsem);
++ add_branch->br_wh = add_branch->br_plink = NULL;
++ if (unlikely(br_writable(add->perm))) {
++ err = init_br_wh(sb, /*bindex*/-1, add_branch, add->perm,
++ add->nd.dentry, add->nd.mnt);
++ if (unlikely(err)) {
++ kfree(add_branch);
++ goto out;
++ }
++ }
++ add_branch->br_xino = NULL;
++ add_branch->br_mnt = mntget(add->nd.mnt);
++ atomic_set(&add_branch->br_wh_running, 0);
++ add_branch->br_id = new_br_id(sb);
++ add_branch->br_perm = add->perm;
++ atomic_set(&add_branch->br_count, 0);
++
++ sbinfo = stosi(sb);
++ dinfo = dtodi(root);
++ iinfo = itoii(root_inode);
++
++ add_bindex = add->bindex;
++ sz = sizeof(*(sbinfo->si_branch)) * (bend + 1 - add_bindex);
++ branchp = sbinfo->si_branch + add_bindex;
++ memmove(branchp + 1, branchp, sz);
++ *branchp = add_branch;
++ sz = sizeof(*hdentryp) * (bend + 1 - add_bindex);
++ hdentryp = dinfo->di_hdentry + add_bindex;
++ memmove(hdentryp + 1, hdentryp, sz);
++ hdentryp->hd_dentry = NULL;
++ sz = sizeof(*hinodep) * (bend + 1 - add_bindex);
++ hinodep = iinfo->ii_hinode + add_bindex;
++ memmove(hinodep + 1, hinodep, sz);
++ hinodep->hi_inode = NULL;
++ hinodep->hi_notify = NULL;
++
++ sbinfo->si_bend++;
++ dinfo->di_bend++;
++ iinfo->ii_bend++;
++ if (unlikely(bend == -1)) {
++ dinfo->di_bstart = 0;
++ iinfo->ii_bstart = 0;
++ }
++ set_h_dptr(root, add_bindex, dget(add->nd.dentry));
++ set_h_iptr(root_inode, add_bindex, igrab(add->nd.dentry->d_inode), 0);
++ if (!add_bindex)
++ au_cpup_attr_all(root_inode);
++ else
++ au_add_nlink(root_inode, add->nd.dentry->d_inode);
++ maxb = add->nd.dentry->d_sb->s_maxbytes;
++ if (sb->s_maxbytes < maxb)
++ sb->s_maxbytes = maxb;
++
++ if (au_flag_test(sb, AuFlag_XINO)) {
++ struct file *base_file = stobr(sb, 0)->br_xino;
++ if (!add_bindex)
++ base_file = stobr(sb, 1)->br_xino;
++ err = xino_init(sb, add_bindex, base_file, /*do_test*/1);
++ if (unlikely(err)) {
++ DEBUG_ON(add_branch->br_xino);
++ Err("ignored xino err %d, force noxino\n", err);
++ err = 0;
++ au_flag_clr(sb, AuFlag_XINO);
++ }
++ }
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if the branch is deletable or not.
++ */
++static int test_children_busy(struct dentry *root, aufs_bindex_t bindex)
++{
++ int err, i, j, sigen;
++ struct au_dcsub_pages dpages;
++
++ LKTRTrace("b%d\n", bindex);
++ SiMustWriteLock(root->d_sb);
++ DiMustWriteLock(root);
++
++ err = au_dpages_init(&dpages, GFP_KERNEL);
++ if (unlikely(err))
++ goto out;
++ err = au_dcsub_pages(&dpages, root, NULL, NULL);
++ if (unlikely(err))
++ goto out_dpages;
++
++ sigen = au_sigen(root->d_sb);
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++ for (i = 0; !err && i < dpages.ndpage; i++) {
++ struct au_dpage *dpage;
++ dpage = dpages.dpages + i;
++ for (j = 0; !err && j < dpage->ndentry; j++) {
++ struct dentry *d;
++
++ d = dpage->dentries[j];
++ if (au_digen(d) == sigen)
++ di_read_lock_child(d, AUFS_I_RLOCK);
++ else {
++ di_write_lock_child(d);
++ err = au_reval_dpath(d, sigen);
++ if (!err)
++ di_downgrade_lock(d, AUFS_I_RLOCK);
++ else {
++ di_write_unlock(d);
++ break;
++ }
++ }
++
++ if (au_h_dptr_i(d, bindex)
++ && (!S_ISDIR(d->d_inode->i_mode)
++ || dbstart(d) == dbend(d)))
++ err = -EBUSY;
++ di_read_unlock(d, AUFS_I_RLOCK);
++ if (err)
++ LKTRTrace("%.*s\n", DLNPair(d));
++ }
++ }
++ di_write_lock_child(root); /* aufs_write_lock() calls ..._child() */
++
++ out_dpages:
++ au_dpages_free(&dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int br_del(struct super_block *sb, struct opt_del *del, int remount)
++{
++ int err, do_wh, rerr;
++ struct dentry *root;
++ struct inode *inode, *hidden_dir;
++ aufs_bindex_t bindex, bend, br_id;
++ struct aufs_sbinfo *sbinfo;
++ struct aufs_dinfo *dinfo;
++ struct aufs_iinfo *iinfo;
++ struct aufs_branch *br;
++
++ LKTRTrace("%s, %.*s\n", del->path, DLNPair(del->h_root));
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ IiMustWriteLock(inode);
++
++ bindex = au_find_dbindex(root, del->h_root);
++ if (unlikely(bindex < 0)) {
++ if (remount)
++ return 0; /* success */
++ err = -ENOENT;
++ Err("%s no such branch\n", del->path);
++ goto out;
++ }
++ LKTRTrace("bindex b%d\n", bindex);
++
++ err = -EBUSY;
++ bend = sbend(sb);
++ br = stobr(sb, bindex);
++ if (unlikely(!bend || br_count(br))) {
++ LKTRTrace("bend %d, br_count %d\n", bend, br_count(br));
++ goto out;
++ }
++
++ do_wh = 0;
++ hidden_dir = del->h_root->d_inode;
++ if (unlikely(br->br_wh || br->br_plink)) {
++#if 0
++ /* remove whiteout base */
++ err = init_br_wh(sb, bindex, br, AuBr_RO, del->h_root,
++ br->br_mnt);
++ if (unlikely(err))
++ goto out;
++#else
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++#endif
++ do_wh = 1;
++ }
++
++ err = test_children_busy(root, bindex);
++ if (unlikely(err)) {
++ if (unlikely(do_wh))
++ goto out_wh;
++ goto out;
++ }
++
++ err = 0;
++ sbinfo = stosi(sb);
++ dinfo = dtodi(root);
++ iinfo = itoii(inode);
++
++ dput(au_h_dptr_i(root, bindex));
++ aufs_hiput(iinfo->ii_hinode + bindex);
++ br_id = br->br_id;
++ free_branch(br);
++
++ //todo: realloc and shrink memeory
++ if (bindex < bend) {
++ const aufs_bindex_t n = bend - bindex;
++ struct aufs_branch **brp;
++ struct aufs_hdentry *hdp;
++ struct aufs_hinode *hip;
++
++ brp = sbinfo->si_branch + bindex;
++ memmove(brp, brp + 1, sizeof(*brp) * n);
++ hdp = dinfo->di_hdentry + bindex;
++ memmove(hdp, hdp + 1, sizeof(*hdp) * n);
++ hip = iinfo->ii_hinode + bindex;
++ memmove(hip, hip + 1, sizeof(*hip) * n);
++ }
++ sbinfo->si_branch[0 + bend] = NULL;
++ dinfo->di_hdentry[0 + bend].hd_dentry = NULL;
++ iinfo->ii_hinode[0 + bend].hi_inode = NULL;
++ iinfo->ii_hinode[0 + bend].hi_notify = NULL;
++
++ sbinfo->si_bend--;
++ dinfo->di_bend--;
++ iinfo->ii_bend--;
++ if (!bindex)
++ au_cpup_attr_all(inode);
++ else
++ au_sub_nlink(inode, del->h_root->d_inode);
++ if (au_flag_test(sb, AuFlag_PLINK))
++ half_refresh_plink(sb, br_id);
++
++ if (sb->s_maxbytes == del->h_root->d_sb->s_maxbytes) {
++ bend--;
++ sb->s_maxbytes = 0;
++ for (bindex = 0; bindex <= bend; bindex++) {
++ unsigned long long maxb;
++ maxb = sbr_sb(sb, bindex)->s_maxbytes;
++ if (sb->s_maxbytes < maxb)
++ sb->s_maxbytes = maxb;
++ }
++ }
++ goto out; /* success */
++
++ out_wh:
++ /* revert */
++ rerr = init_br_wh(sb, bindex, br, br->br_perm, del->h_root, br->br_mnt);
++ if (rerr)
++ Warn("failed re-creating base whiteout, %s. (%d)\n",
++ del->path, rerr);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int do_need_sigen_inc(int a, int b)
++{
++ return (br_whable(a) && !br_whable(b));
++}
++
++static int need_sigen_inc(int old, int new)
++{
++ return (do_need_sigen_inc(old, new)
++ || do_need_sigen_inc(new, old));
++}
++
++int br_mod(struct super_block *sb, struct opt_mod *mod, int remount,
++ int *do_update)
++{
++ int err;
++ struct dentry *root;
++ aufs_bindex_t bindex;
++ struct aufs_branch *br;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%s, %.*s, 0x%x\n",
++ mod->path, DLNPair(mod->h_root), mod->perm);
++ SiMustWriteLock(sb);
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ IiMustWriteLock(root->d_inode);
++
++ bindex = au_find_dbindex(root, mod->h_root);
++ if (unlikely(bindex < 0)) {
++ if (remount)
++ return 0; /* success */
++ err = -ENOENT;
++ Err("%s no such branch\n", mod->path);
++ goto out;
++ }
++ LKTRTrace("bindex b%d\n", bindex);
++
++ hidden_dir = mod->h_root->d_inode;
++ err = test_br(sb, hidden_dir, mod->perm, mod->path);
++ if (unlikely(err))
++ goto out;
++
++ br = stobr(sb, bindex);
++ if (unlikely(br->br_perm == mod->perm))
++ return 0; /* success */
++
++ if (br_writable(br->br_perm)) {
++#if 1
++ /* remove whiteout base */
++ //todo: mod->perm?
++ err = init_br_wh(sb, bindex, br, AuBr_RO, mod->h_root,
++ br->br_mnt);
++ if (unlikely(err))
++ goto out;
++#else
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++#endif
++
++ if (!br_writable(mod->perm)) {
++ /* rw --> ro, file might be mmapped */
++ struct file *file, *hf;
++
++#if 1 // test here
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++
++ // no need file_list_lock() since sbinfo is locked
++ //file_list_lock();
++ list_for_each_entry(file, &sb->s_files, f_u.fu_list) {
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++ fi_read_lock(file);
++ if (!S_ISREG(file->f_dentry->d_inode->i_mode)
++ || !(file->f_mode & FMODE_WRITE)
++ || fbstart(file) != bindex) {
++ FiMustNoWaiters(file);
++ fi_read_unlock(file);
++ continue;
++ }
++
++ // todo: already flushed?
++ hf = au_h_fptr(file);
++ hf->f_flags = au_file_roflags(hf->f_flags);
++ hf->f_mode &= ~FMODE_WRITE;
++ FiMustNoWaiters(file);
++ fi_read_unlock(file);
++ }
++ //file_list_unlock();
++
++ /* aufs_write_lock() calls ..._child() */
++ di_write_lock_child(root);
++#endif
++ }
++ }
++
++ *do_update |= need_sigen_inc(br->br_perm, mod->perm);
++ br->br_perm = mod->perm;
++ return err; /* success */
++
++ out:
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/branch.h linux-2.6.22.1/fs/aufs/branch.h
+--- linux-2.6.22.1.oorig/fs/aufs/branch.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/branch.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,235 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: branch.h,v 1.30 2007/05/14 03:41:51 sfjro Exp $ */
++
++#ifndef __AUFS_BRANCH_H__
++#define __AUFS_BRANCH_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/mount.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "super.h"
++
++/* protected by superblock rwsem */
++struct aufs_branch {
++ struct file *br_xino;
++ readf_t br_xino_read;
++ writef_t br_xino_write;
++
++ aufs_bindex_t br_id;
++
++ int br_perm;
++ struct vfsmount *br_mnt;
++ atomic_t br_count;
++
++ /* whiteout base */
++ struct aufs_rwsem br_wh_rwsem;
++ struct dentry *br_wh;
++ atomic_t br_wh_running;
++
++ /* pseudo-link dir */
++ struct dentry *br_plink;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* branch permission and attribute */
++enum {
++ AuBr_RW, /* writable, linkable wh */
++ AuBr_RO, /* readonly, no wh */
++ AuBr_RR, /* natively readonly, no wh */
++
++ AuBr_RWNoLinkWH, /* un-linkable whiteouts */
++
++ AuBr_ROWH,
++ AuBr_RRWH, /* whiteout-able */
++
++ AuBr_Last
++};
++
++static inline int br_writable(int brperm)
++{
++ return (brperm == AuBr_RW
++ || brperm == AuBr_RWNoLinkWH);
++}
++
++static inline int br_whable(int brperm)
++{
++ return (brperm == AuBr_RW
++ || brperm == AuBr_ROWH
++ || brperm == AuBr_RRWH);
++}
++
++static inline int br_linkable_wh(int brperm)
++{
++ return (brperm == AuBr_RW);
++}
++
++/* ---------------------------------------------------------------------- */
++
++#define _AuNoNfsBranchMsg "NFS branch is not supported"
++#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
++#define AuNoNfsBranch
++#define AuNoNfsBranchMsg _AuNoNfsBranchMsg
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) \
++ && !defined(CONFIG_AUFS_LHASH_PATCH)
++#define AuNoNfsBranch
++#define AuNoNfsBranchMsg _AuNoNfsBranchMsg \
++ ", try lhash.patch and CONFIG_AUFS_LHASH_PATCH"
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_sbinfo;
++void free_branches(struct aufs_sbinfo *sinfo);
++int br_rdonly(struct aufs_branch *br);
++int find_brindex(struct super_block *sb, aufs_bindex_t br_id);
++int find_rw_br(struct super_block *sb, aufs_bindex_t bend);
++int find_rw_parent_br(struct dentry *dentry, aufs_bindex_t bend);
++struct opt_add;
++int br_add(struct super_block *sb, struct opt_add *add, int remount);
++struct opt_del;
++int br_del(struct super_block *sb, struct opt_del *del, int remount);
++struct opt_mod;
++int br_mod(struct super_block *sb, struct opt_mod *mod, int remount,
++ int *do_update);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int br_count(struct aufs_branch *br)
++{
++ return atomic_read(&br->br_count);
++}
++
++static inline void br_get(struct aufs_branch *br)
++{
++ atomic_inc(&br->br_count);
++}
++
++static inline void br_put(struct aufs_branch *br)
++{
++ atomic_dec(&br->br_count);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Superblock to branch */
++static inline aufs_bindex_t sbr_id(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_id;
++}
++
++static inline
++struct vfsmount *sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_mnt;
++}
++
++static inline
++struct super_block *sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return sbr_mnt(sb, bindex)->mnt_sb;
++}
++
++#if 0
++static inline int sbr_count(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return br_count(stobr(sb, bindex));
++}
++
++static inline void sbr_get(struct super_block *sb, aufs_bindex_t bindex)
++{
++ br_get(stobr(sb, bindex));
++}
++#endif
++
++static inline void sbr_put(struct super_block *sb, aufs_bindex_t bindex)
++{
++ br_put(stobr(sb, bindex));
++}
++
++static inline int sbr_perm(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return stobr(sb, bindex)->br_perm;
++}
++
++static inline int sbr_is_whable(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return br_whable(sbr_perm(sb, bindex));
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_LHASH_PATCH
++static inline struct vfsmount *au_do_nfsmnt(struct vfsmount *h_mnt)
++{
++ if (!au_is_nfs(h_mnt->mnt_sb))
++ return NULL;
++ return h_mnt;
++}
++
++/* it doesn't mntget() */
++static inline
++struct vfsmount *au_nfsmnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return au_do_nfsmnt(sbr_mnt(sb, bindex));
++}
++#else
++static inline struct vfsmount *au_do_nfsmnt(struct vfsmount *h_mnt)
++{
++ return NULL;
++}
++
++static inline
++struct vfsmount *au_nfsmnt(struct super_block *sb, aufs_bindex_t bindex)
++{
++ return NULL;
++}
++#endif /* CONFIG_AUFS_LHASH_PATCH */
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * br_wh_read_lock, br_wh_write_lock
++ * br_wh_read_unlock, br_wh_write_unlock, br_wh_downgrade_lock
++ */
++SimpleRwsemFuncs(br_wh, struct aufs_branch *br, br->br_wh_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define BrWhMustReadLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustReadLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#define BrWhMustWriteLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustWriteLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#define BrWhMustAnyLock(br) do { \
++ /* SiMustAnyLock(sb); */ \
++ RwMustAnyLock(&(br)->br_wh_rwsem); \
++} while (0)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_BRANCH_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/cpup.c linux-2.6.22.1/fs/aufs/cpup.c
+--- linux-2.6.22.1.oorig/fs/aufs/cpup.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/cpup.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,773 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: cpup.c,v 1.37 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++/* violent cpup_attr_*() functions don't care inode lock */
++void au_cpup_attr_timesizes(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++ //IMustLock(!hidden_inode);
++
++ inode->i_atime = hidden_inode->i_atime;
++ inode->i_mtime = hidden_inode->i_mtime;
++ inode->i_ctime = hidden_inode->i_ctime;
++ spin_lock(&inode->i_lock);
++ i_size_write(inode, i_size_read(hidden_inode));
++ inode->i_blocks = hidden_inode->i_blocks;
++ spin_unlock(&inode->i_lock);
++}
++
++void au_cpup_attr_nlink(struct inode *inode)
++{
++ struct inode *h_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ DEBUG_ON(!inode->i_mode);
++
++ h_inode = au_h_iptr(inode);
++ inode->i_nlink = h_inode->i_nlink;
++
++ /*
++ * fewer nlink makes find(1) noisy, but larger nlink doesn't.
++ * it may includes whplink directory.
++ */
++ if (unlikely(S_ISDIR(h_inode->i_mode))) {
++ aufs_bindex_t bindex, bend;
++ bend = ibend(inode);
++ for (bindex = ibstart(inode) + 1; bindex <= bend; bindex++) {
++ h_inode = au_h_iptr_i(inode, bindex);
++ if (h_inode)
++ au_add_nlink(inode, h_inode);
++ }
++ }
++}
++
++void au_cpup_attr_changable(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++
++ inode->i_mode = hidden_inode->i_mode;
++ inode->i_uid = hidden_inode->i_uid;
++ inode->i_gid = hidden_inode->i_gid;
++ au_cpup_attr_timesizes(inode);
++
++ //??
++ inode->i_flags = hidden_inode->i_flags;
++}
++
++void au_cpup_igen(struct inode *inode, struct inode *h_inode)
++{
++ inode->i_generation = h_inode->i_generation;
++ itoii(inode)->ii_hsb1 = h_inode->i_sb;
++}
++
++void au_cpup_attr_all(struct inode *inode)
++{
++ struct inode *hidden_inode;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ //IMustLock(inode);
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode);
++
++ au_cpup_attr_changable(inode);
++ if (inode->i_nlink > 0)
++ au_cpup_attr_nlink(inode);
++
++ switch (inode->i_mode & S_IFMT) {
++ case S_IFBLK:
++ case S_IFCHR:
++ inode->i_rdev = hidden_inode->i_rdev;
++ }
++ inode->i_blkbits = hidden_inode->i_blkbits;
++ au_cpup_attr_blksize(inode, hidden_inode);
++ au_cpup_igen(inode, hidden_inode);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Note: dt_dentry and dt_hidden_dentry are not dget/dput-ed */
++
++/* keep the timestamps of the parent dir when cpup */
++void dtime_store(struct dtime *dt, struct dentry *dentry,
++ struct dentry *hidden_dentry)
++{
++ struct inode *inode;
++
++ TraceEnter();
++ DEBUG_ON(!dentry || !hidden_dentry || !hidden_dentry->d_inode);
++
++ dt->dt_dentry = dentry;
++ dt->dt_h_dentry = hidden_dentry;
++ inode = hidden_dentry->d_inode;
++ dt->dt_atime = inode->i_atime;
++ dt->dt_mtime = inode->i_mtime;
++ //smp_mb();
++}
++
++// todo: remove extra parameter
++void dtime_revert(struct dtime *dt, int h_parent_is_locked)
++{
++ struct iattr attr;
++ int err;
++ struct dentry *dentry;
++
++ LKTRTrace("h_parent locked %d\n", h_parent_is_locked);
++
++ attr.ia_atime = dt->dt_atime;
++ attr.ia_mtime = dt->dt_mtime;
++ attr.ia_valid = ATTR_FORCE | ATTR_MTIME | ATTR_MTIME_SET
++ | ATTR_ATIME | ATTR_ATIME_SET;
++ //smp_mb();
++ dentry = NULL;
++ if (!h_parent_is_locked /* && !IS_ROOT(dt->dt_dentry) */)
++ dentry = dt->dt_dentry;
++ err = vfsub_notify_change(dt->dt_h_dentry, &attr,
++ need_dlgt(dt->dt_dentry->d_sb));
++ if (unlikely(err))
++ Warn("restoring timestamps failed(%d). ignored\n", err);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int cpup_iattr(struct dentry *hidden_dst, struct dentry *hidden_src,
++ int dlgt)
++{
++ int err;
++ struct iattr ia;
++ struct inode *hidden_isrc, *hidden_idst;
++
++ LKTRTrace("%.*s\n", DLNPair(hidden_dst));
++ hidden_idst = hidden_dst->d_inode;
++ //IMustLock(hidden_idst);
++ hidden_isrc = hidden_src->d_inode;
++ //IMustLock(hidden_isrc);
++
++ ia.ia_valid = ATTR_FORCE | ATTR_MODE | ATTR_UID | ATTR_GID
++ | ATTR_ATIME | ATTR_MTIME
++ | ATTR_ATIME_SET | ATTR_MTIME_SET;
++ ia.ia_mode = hidden_isrc->i_mode;
++ ia.ia_uid = hidden_isrc->i_uid;
++ ia.ia_gid = hidden_isrc->i_gid;
++ ia.ia_atime = hidden_isrc->i_atime;
++ ia.ia_mtime = hidden_isrc->i_mtime;
++ err = vfsub_notify_change(hidden_dst, &ia, dlgt);
++ //if (LktrCond) err = -1;
++ if (!err)
++ hidden_idst->i_flags = hidden_isrc->i_flags; //??
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * to support a sparse file which is opened with O_APPEND,
++ * we need to close the file.
++ */
++static int cpup_regular(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len)
++{
++ int err, i, sparse;
++ struct super_block *sb;
++ struct inode *hidden_inode;
++ enum {SRC, DST};
++ struct {
++ aufs_bindex_t bindex;
++ unsigned int flags;
++ struct dentry *dentry;
++ struct file *file;
++ void *label, *label_file;
++ } *h, hidden[] = {
++ {
++ .bindex = bsrc,
++ .flags = O_RDONLY | O_NOATIME | O_LARGEFILE,
++ .file = NULL,
++ .label = &&out,
++ .label_file = &&out_src_file
++ },
++ {
++ .bindex = bdst,
++ .flags = O_WRONLY | O_NOATIME | O_LARGEFILE,
++ .file = NULL,
++ .label = &&out_src_file,
++ .label_file = &&out_dst_file
++ }
++ };
++
++ LKTRTrace("dentry %.*s, bdst %d, bsrc %d, len %lld\n",
++ DLNPair(dentry), bdst, bsrc, len);
++ DEBUG_ON(bsrc <= bdst);
++ DEBUG_ON(!len);
++ sb = dentry->d_sb;
++ DEBUG_ON(test_ro(sb, bdst, dentry->d_inode));
++ // bsrc branch can be ro/rw.
++
++ h = hidden;
++ for (i = 0; i < 2; i++, h++) {
++ h->dentry = au_h_dptr_i(dentry, h->bindex);
++ DEBUG_ON(!h->dentry);
++ hidden_inode = h->dentry->d_inode;
++ DEBUG_ON(!hidden_inode || !S_ISREG(hidden_inode->i_mode));
++ h->file = hidden_open(dentry, h->bindex, h->flags);
++ //if (LktrCond)
++ //{fput(h->file); sbr_put(sb, h->bindex); h->file = ERR_PTR(-1);}
++ err = PTR_ERR(h->file);
++ if (IS_ERR(h->file))
++ goto *h->label;
++ err = -EINVAL;
++ if (unlikely(!h->file->f_op))
++ goto *h->label_file;
++ }
++
++ /* stop updating while we copyup */
++ IMustLock(hidden[SRC].dentry->d_inode);
++ sparse = 0;
++ err = au_copy_file(hidden[DST].file, hidden[SRC].file, len, sb,
++ &sparse);
++
++ /* sparse file: update i_blocks next time */
++ if (unlikely(!err && sparse))
++ d_drop(dentry);
++
++ out_dst_file:
++ fput(hidden[DST].file);
++ sbr_put(sb, hidden[DST].bindex);
++ out_src_file:
++ fput(hidden[SRC].file);
++ sbr_put(sb, hidden[SRC].bindex);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++// unnecessary?
++unsigned int au_flags_cpup(unsigned int init, struct dentry *parent)
++{
++ if (unlikely(parent && IS_ROOT(parent)))
++ init |= CPUP_LOCKED_GHDIR;
++ return init;
++}
++
++/* return with hidden dst inode is locked */
++static int cpup_entry(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
++ int dlgt)
++{
++ int err, isdir, symlen;
++ struct dentry *hidden_src, *hidden_dst, *hidden_parent, *parent;
++ struct inode *hidden_inode, *hidden_dir, *dir;
++ struct dtime dt;
++ umode_t mode;
++ char *sym;
++ mm_segment_t old_fs;
++ const int do_dt = flags & CPUP_DTIME;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++ sb = dentry->d_sb;
++ DEBUG_ON(bdst >= bsrc || test_ro(sb, bdst, NULL));
++ // bsrc branch can be ro/rw.
++
++ hidden_src = au_h_dptr_i(dentry, bsrc);
++ DEBUG_ON(!hidden_src);
++ hidden_inode = hidden_src->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ /* stop refrencing while we are creating */
++ //parent = dget_parent(dentry);
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ hidden_dst = au_h_dptr_i(dentry, bdst);
++ DEBUG_ON(hidden_dst && hidden_dst->d_inode);
++ //hidden_parent = dget_parent(hidden_dst);
++ hidden_parent = hidden_dst->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ if (do_dt)
++ dtime_store(&dt, parent, hidden_parent);
++
++ isdir = 0;
++ mode = hidden_inode->i_mode;
++ switch (mode & S_IFMT) {
++ case S_IFREG:
++ /* stop updating while we are referencing */
++ IMustLock(hidden_inode);
++ err = vfsub_create(hidden_dir, hidden_dst, mode | S_IWUSR, NULL,
++ dlgt);
++ //if (LktrCond) {vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ if (!err) {
++ loff_t l = i_size_read(hidden_inode);
++ if (len == -1 || l < len)
++ len = l;
++ if (len) {
++ err = cpup_regular(dentry, bdst, bsrc, len);
++ //if (LktrCond) err = -1;
++ }
++ if (unlikely(err)) {
++ int rerr;
++ rerr = vfsub_unlink(hidden_dir, hidden_dst,
++ dlgt);
++ if (rerr) {
++ IOErr("failed unlinking cpup-ed %.*s"
++ "(%d, %d)\n",
++ DLNPair(hidden_dst), err, rerr);
++ err = -EIO;
++ }
++ }
++ }
++ break;
++ case S_IFDIR:
++ isdir = 1;
++ err = vfsub_mkdir(hidden_dir, hidden_dst, mode, dlgt);
++ //if (LktrCond) {vfs_rmdir(hidden_dir, hidden_dst); err = -1;}
++ if (!err) {
++ /* setattr case: dir is not locked */
++ if (0 && ibstart(dir) == bdst)
++ au_cpup_attr_nlink(dir);
++ au_cpup_attr_nlink(dentry->d_inode);
++ }
++ break;
++ case S_IFLNK:
++ err = -ENOMEM;
++ sym = __getname();
++ //if (LktrCond) {__putname(sym); sym = NULL;}
++ if (unlikely(!sym))
++ break;
++ old_fs = get_fs();
++ set_fs(KERNEL_DS);
++ err = symlen = hidden_inode->i_op->readlink
++ (hidden_src, (char __user*)sym, PATH_MAX);
++ //if (LktrCond) err = symlen = -1;
++ set_fs(old_fs);
++ if (symlen > 0) {
++ sym[symlen] = 0;
++ err = vfsub_symlink(hidden_dir, hidden_dst, sym, mode,
++ dlgt);
++ //if (LktrCond)
++ //{vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ }
++ __putname(sym);
++ break;
++ case S_IFCHR:
++ case S_IFBLK:
++ DEBUG_ON(!capable(CAP_MKNOD));
++ /*FALLTHROUGH*/
++ case S_IFIFO:
++ case S_IFSOCK:
++ err = vfsub_mknod(hidden_dir, hidden_dst, mode,
++ hidden_inode->i_rdev, dlgt);
++ //if (LktrCond) {vfs_unlink(hidden_dir, hidden_dst); err = -1;}
++ break;
++ default:
++ IOErr("Unknown inode type 0%o\n", mode);
++ err = -EIO;
++ }
++
++ if (do_dt)
++ dtime_revert(&dt, flags & CPUP_LOCKED_GHDIR);
++ //dput(parent);
++ //dput(hidden_parent);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the @dentry from @bsrc to @bdst.
++ * the caller must set the both of hidden dentries.
++ * @len is for trucating when it is -1 copyup the entire file.
++ */
++int cpup_single(struct dentry *dentry, aufs_bindex_t bdst, aufs_bindex_t bsrc,
++ loff_t len, unsigned int flags)
++{
++ int err, rerr, isdir, dlgt;
++ struct dentry *hidden_src, *hidden_dst, *parent;//, *h_parent;
++ struct inode *dst_inode, *hidden_dir, *inode, *src_inode;
++ struct super_block *sb;
++ aufs_bindex_t old_ibstart;
++ struct dtime dt;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++ sb = dentry->d_sb;
++ DEBUG_ON(bsrc <= bdst);
++ hidden_dst = au_h_dptr_i(dentry, bdst);
++ DEBUG_ON(!hidden_dst || hidden_dst->d_inode);
++ //h_parent = dget_parent(hidden_dst);
++ //hidden_dir = h_parent->d_inode;
++ hidden_dir = hidden_dst->d_parent->d_inode;
++ IMustLock(hidden_dir);
++ hidden_src = au_h_dptr_i(dentry, bsrc);
++ DEBUG_ON(!hidden_src || !hidden_src->d_inode);
++ inode = dentry->d_inode;
++ IiMustWriteLock(inode);
++
++ dlgt = need_dlgt(sb);
++ dst_inode = au_h_iptr_i(inode, bdst);
++ if (unlikely(dst_inode)) {
++ if (unlikely(!au_flag_test(sb, AuFlag_PLINK))) {
++ err = -EIO;
++ IOErr("i%lu exists on a upper branch "
++ "but plink is disabled\n", inode->i_ino);
++ goto out;
++ }
++
++ if (dst_inode->i_nlink) {
++ hidden_src = lkup_plink(sb, bdst, inode);
++ err = PTR_ERR(hidden_src);
++ if (IS_ERR(hidden_src))
++ goto out;
++ DEBUG_ON(!hidden_src->d_inode);
++ // vfs_link() does lock the inode
++ err = vfsub_link(hidden_src, hidden_dir, hidden_dst, dlgt);
++ dput(hidden_src);
++ goto out;
++ } else
++ /* udba work */
++ au_update_brange(inode, 1);
++ }
++
++ old_ibstart = ibstart(inode);
++ err = cpup_entry(dentry, bdst, bsrc, len, flags, dlgt);
++ if (unlikely(err))
++ goto out;
++ dst_inode = hidden_dst->d_inode;
++ hi_lock_child2(dst_inode);
++
++ //todo: test dlgt
++ err = cpup_iattr(hidden_dst, hidden_src, dlgt);
++ //if (LktrCond) err = -1;
++#if 0 // xattr
++ if (0 && !err)
++ err = cpup_xattrs(hidden_src, hidden_dst);
++#endif
++ isdir = S_ISDIR(dst_inode->i_mode);
++ if (!err) {
++ if (bdst < old_ibstart)
++ set_ibstart(inode, bdst);
++ set_h_iptr(inode, bdst, igrab(dst_inode),
++ au_hi_flags(inode, isdir));
++ i_unlock(dst_inode);
++ src_inode = hidden_src->d_inode;
++ if (!isdir) {
++ if (src_inode->i_nlink > 1
++ && au_flag_test(sb, AuFlag_PLINK))
++ append_plink(sb, inode, hidden_dst, bdst);
++ else {
++ /* braces are added to stop a warning */
++ ;//xino_write0(sb, bsrc, src_inode->i_ino);
++ /* ignore this error */
++ }
++ }
++ //goto out; /* success */
++ return 0; /* success */
++ }
++
++ /* revert */
++ i_unlock(dst_inode);
++ parent = dget_parent(dentry);
++ //dtime_store(&dt, parent, h_parent);
++ dtime_store(&dt, parent, hidden_dst->d_parent);
++ dput(parent);
++ if (!isdir)
++ rerr = vfsub_unlink(hidden_dir, hidden_dst, dlgt);
++ else
++ rerr = vfsub_rmdir(hidden_dir, hidden_dst, dlgt);
++ //rerr = -1;
++ dtime_revert(&dt, flags & CPUP_LOCKED_GHDIR);
++ if (rerr) {
++ IOErr("failed removing broken entry(%d, %d)\n", err, rerr);
++ err = -EIO;
++ }
++
++ out:
++ //dput(h_parent);
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_single_args {
++ int *errp;
++ struct dentry *dentry;
++ aufs_bindex_t bdst, bsrc;
++ loff_t len;
++ unsigned int flags;
++};
++
++static void call_cpup_single(void *args)
++{
++ struct cpup_single_args *a = args;
++ *a->errp = cpup_single(a->dentry, a->bdst, a->bsrc, a->len, a->flags);
++}
++
++int sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags)
++{
++ int err;
++ struct dentry *hidden_dentry;
++ umode_t mode;
++
++ LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
++ flags);
++
++ hidden_dentry = au_h_dptr_i(dentry, bsrc);
++ mode = hidden_dentry->d_inode->i_mode & S_IFMT;
++ if ((mode != S_IFCHR && mode != S_IFBLK)
++ || capable(CAP_MKNOD))
++ err = cpup_single(dentry, bdst, bsrc, len, flags);
++ else {
++ struct cpup_single_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bdst,
++ .bsrc = bsrc,
++ .len = len,
++ .flags = flags
++ };
++ au_wkq_wait(call_cpup_single, &args, /*dlgt*/0);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the @dentry from the first active hidden branch to @bdst,
++ * using cpup_single().
++ */
++int cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags)
++{
++ int err;
++ struct inode *inode;
++ aufs_bindex_t bsrc, bend;
++
++ LKTRTrace("%.*s, bdst %d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), bdst, len, flags);
++ inode = dentry->d_inode;
++ DEBUG_ON(!S_ISDIR(inode->i_mode) && dbstart(dentry) < bdst);
++
++ bend = dbend(dentry);
++ for (bsrc = bdst + 1; bsrc <= bend; bsrc++)
++ if (au_h_dptr_i(dentry, bsrc))
++ break;
++ DEBUG_ON(!au_h_dptr_i(dentry, bsrc));
++
++ err = lkup_neg(dentry, bdst);
++ //err = -1;
++ if (!err) {
++ err = cpup_single(dentry, bdst, bsrc, len, flags);
++ if (!err)
++ return 0; /* success */
++
++ /* revert */
++ set_h_dptr(dentry, bdst, NULL);
++ set_dbstart(dentry, bsrc);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_simple_args {
++ int *errp;
++ struct dentry *dentry;
++ aufs_bindex_t bdst;
++ loff_t len;
++ unsigned int flags;
++};
++
++static void call_cpup_simple(void *args)
++{
++ struct cpup_simple_args *a = args;
++ *a->errp = cpup_simple(a->dentry, a->bdst, a->len, a->flags);
++}
++
++int sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags)
++{
++ int err, do_sio, dlgt;
++ //struct dentry *parent;
++ struct inode *hidden_dir, *dir;
++
++ LKTRTrace("%.*s, b%d, len %Ld, flags 0x%x\n",
++ DLNPair(dentry), bdst, len, flags);
++
++ //parent = dget_parent(dentry);
++ //dir = parent->d_inode;
++ dir = dentry->d_parent->d_inode;
++ hidden_dir = au_h_iptr_i(dir, bdst);
++ dlgt = need_dlgt(dir->i_sb);
++ do_sio = au_test_perm(hidden_dir, MAY_EXEC | MAY_WRITE, dlgt);
++ if (!do_sio) {
++ umode_t mode = dentry->d_inode->i_mode & S_IFMT;
++ do_sio = ((mode == S_IFCHR || mode == S_IFBLK)
++ && !capable(CAP_MKNOD));
++ }
++ if (!do_sio)
++ err = cpup_simple(dentry, bdst, len, flags);
++ else {
++ struct cpup_simple_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bdst,
++ .len = len,
++ .flags = flags
++ };
++ au_wkq_wait(call_cpup_simple, &args, /*dlgt*/0);
++ }
++
++ //dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++//todo: dcsub
++/* cf. revalidate function in file.c */
++int cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst, struct dentry *locked)
++{
++ int err;
++ struct super_block *sb;
++ struct dentry *d, *parent, *hidden_parent;
++ unsigned int udba;
++
++ LKTRTrace("%.*s, b%d, parent i%lu, locked %p\n",
++ DLNPair(dentry), bdst, parent_ino(dentry), locked);
++ sb = dentry->d_sb;
++ DEBUG_ON(test_ro(sb, bdst, NULL));
++ parent = dentry->d_parent;
++ IiMustWriteLock(parent->d_inode);
++ if (unlikely(IS_ROOT(parent)))
++ return 0;
++ if (locked) {
++ DiMustAnyLock(locked);
++ IiMustAnyLock(locked->d_inode);
++ }
++
++ /* slow loop, keep it simple and stupid */
++ err = 0;
++ udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++ while (1) {
++ parent = dentry->d_parent; // dget_parent()
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ if (hidden_parent)
++ return 0; /* success */
++
++ /* find top dir which is needed to cpup */
++ do {
++ d = parent;
++ parent = d->d_parent; // dget_parent()
++ if (parent != locked)
++ di_read_lock_parent3(parent, !AUFS_I_RLOCK);
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ if (parent != locked)
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ } while (!hidden_parent);
++
++ if (d != dentry->d_parent)
++ di_write_lock_child3(d);
++
++ /* somebody else might create while we were sleeping */
++ if (!au_h_dptr_i(d, bdst) || !au_h_dptr_i(d, bdst)->d_inode) {
++ struct inode *h_dir = hidden_parent->d_inode,
++ *dir = parent->d_inode,
++ *h_gdir, *gdir;
++
++ if (au_h_dptr_i(d, bdst))
++ au_update_dbstart(d);
++ //DEBUG_ON(dbstart(d) <= bdst);
++ if (parent != locked)
++ di_read_lock_parent3(parent, AUFS_I_RLOCK);
++ h_gdir = gdir = NULL;
++ if (unlikely(udba && !IS_ROOT(parent))) {
++ gdir = parent->d_parent->d_inode;
++ h_gdir = hidden_parent->d_parent->d_inode;
++ hgdir_lock(h_gdir, gdir, bdst);
++ }
++ hdir_lock(h_dir, dir, bdst);
++ err = sio_cpup_simple(d, bdst, -1,
++ au_flags_cpup(CPUP_DTIME,
++ parent));
++ //if (LktrCond) err = -1;
++ hdir_unlock(h_dir, dir, bdst);
++ if (unlikely(gdir))
++ hdir_unlock(h_gdir, gdir, bdst);
++ if (parent != locked)
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++
++ if (d != dentry->d_parent)
++ di_write_unlock(d);
++ if (unlikely(err))
++ break;
++ }
++
++// out:
++ TraceErr(err);
++ return err;
++}
++
++int test_and_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst,
++ struct dentry *locked)
++{
++ int err;
++ struct dentry *parent;
++ struct inode *dir;
++
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ LKTRTrace("%.*s, b%d, parent i%lu, locked %p\n",
++ DLNPair(dentry), bdst, dir->i_ino, locked);
++ DiMustReadLock(parent);
++ IiMustReadLock(dir);
++
++ if (au_h_iptr_i(dir, bdst))
++ return 0;
++
++ err = 0;
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ di_write_lock_parent(parent);
++ if (au_h_iptr_i(dir, bdst))
++ goto out;
++
++ err = cpup_dirs(dentry, bdst, locked);
++
++ out:
++ di_downgrade_lock(parent, AUFS_I_RLOCK);
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/cpup.h linux-2.6.22.1/fs/aufs/cpup.h
+--- linux-2.6.22.1.oorig/fs/aufs/cpup.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/cpup.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,72 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: cpup.h,v 1.15 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_CPUP_H__
++#define __AUFS_CPUP_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++static inline
++void au_cpup_attr_blksize(struct inode *inode, struct inode *h_inode)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
++ inode->i_blksize = h_inode->i_blksize;
++#endif
++}
++
++void au_cpup_attr_timesizes(struct inode *inode);
++void au_cpup_attr_nlink(struct inode *inode);
++void au_cpup_attr_changable(struct inode *inode);
++void au_cpup_igen(struct inode *inode, struct inode *h_inode);
++void au_cpup_attr_all(struct inode *inode);
++
++#define CPUP_DTIME 1 // do dtime_store/revert
++// todo: remove this
++#define CPUP_LOCKED_GHDIR 2 // grand parent hidden dir is locked
++unsigned int au_flags_cpup(unsigned int init, struct dentry *parent);
++
++int cpup_single(struct dentry *dentry, aufs_bindex_t bdst, aufs_bindex_t bsrc,
++ loff_t len, unsigned int flags);
++int sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
++ aufs_bindex_t bsrc, loff_t len, unsigned int flags);
++int cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags);
++int sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
++ unsigned int flags);
++
++int cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst, struct dentry *locked);
++int test_and_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst,
++ struct dentry *locked);
++
++/* keep timestamps when copyup */
++struct dtime {
++ struct dentry *dt_dentry, *dt_h_dentry;
++ struct timespec dt_atime, dt_mtime;
++};
++void dtime_store(struct dtime *dt, struct dentry *dentry,
++ struct dentry *h_dentry);
++void dtime_revert(struct dtime *dt, int h_parent_is_locked);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_CPUP_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dcsub.c linux-2.6.22.1/fs/aufs/dcsub.c
+--- linux-2.6.22.1.oorig/fs/aufs/dcsub.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dcsub.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,175 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dcsub.c,v 1.3 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static void au_dpage_free(struct au_dpage *dpage)
++{
++ int i;
++
++ TraceEnter();
++ DEBUG_ON(!dpage);
++
++ for (i = 0; i < dpage->ndentry; i++)
++ dput(dpage->dentries[i]);
++ free_page((unsigned long)dpage->dentries);
++}
++
++int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp)
++{
++ int err;
++ void *p;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ dpages->dpages = kmalloc(sizeof(*dpages->dpages), gfp);
++ if (unlikely(!dpages->dpages))
++ goto out;
++ p = (void*)__get_free_page(gfp);
++ if (unlikely(!p))
++ goto out_dpages;
++ dpages->dpages[0].ndentry = 0;
++ dpages->dpages[0].dentries = p;
++ dpages->ndpage = 1;
++ return 0; /* success */
++
++ out_dpages:
++ kfree(dpages->dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++void au_dpages_free(struct au_dcsub_pages *dpages)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < dpages->ndpage; i++)
++ au_dpage_free(dpages->dpages + i);
++ kfree(dpages->dpages);
++}
++
++static int au_dpages_append(struct au_dcsub_pages *dpages,
++ struct dentry *dentry, gfp_t gfp)
++{
++ int err, sz;
++ struct au_dpage *dpage;
++ void *p;
++
++ //TraceEnter();
++
++ dpage = dpages->dpages + dpages->ndpage - 1;
++ DEBUG_ON(!dpage);
++ sz = PAGE_SIZE/sizeof(dentry);
++ if (unlikely(dpage->ndentry >= sz)) {
++ LKTRLabel(new dpage);
++ err = -ENOMEM;
++ sz = dpages->ndpage * sizeof(*dpages->dpages);
++ p = au_kzrealloc(dpages->dpages, sz,
++ sz + sizeof(*dpages->dpages), gfp);
++ if (unlikely(!p))
++ goto out;
++ dpage = dpages->dpages + dpages->ndpage;
++ p = (void*)__get_free_page(gfp);
++ if (unlikely(!p))
++ goto out;
++ dpage->ndentry = 0;
++ dpage->dentries = p;
++ dpages->ndpage++;
++ }
++
++ dpage->dentries[dpage->ndentry++] = dget(dentry);
++ return 0; /* success */
++
++ out:
++ //TraceErr(err);
++ return err;
++}
++
++int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
++ au_dpages_test test, void *arg)
++{
++ int err;
++ struct dentry *this_parent = root;
++ struct list_head *next;
++ struct super_block *sb = root->d_sb;
++
++ TraceEnter();
++
++ err = 0;
++ spin_lock(&dcache_lock);
++ repeat:
++ next = this_parent->d_subdirs.next;
++ resume:
++ if (this_parent->d_sb == sb
++ && !IS_ROOT(this_parent)
++ && atomic_read(&this_parent->d_count)
++ && this_parent->d_inode
++ && (!test || test(this_parent, arg))) {
++ err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
++ if (unlikely(err))
++ goto out;
++ }
++
++ while (next != &this_parent->d_subdirs) {
++ struct list_head *tmp = next;
++ struct dentry *dentry = list_entry(tmp, struct dentry, D_CHILD);
++ next = tmp->next;
++ if (unlikely(/*d_unhashed(dentry) || */!dentry->d_inode))
++ continue;
++ if (!list_empty(&dentry->d_subdirs)) {
++ this_parent = dentry;
++ goto repeat;
++ }
++ if (dentry->d_sb == sb
++ && atomic_read(&dentry->d_count)
++ && (!test || test(dentry, arg))) {
++ err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
++ if (unlikely(err))
++ goto out;
++ }
++ }
++
++ if (this_parent != root) {
++ next = this_parent->D_CHILD.next;
++ this_parent = this_parent->d_parent;
++ goto resume;
++ }
++ out:
++ spin_unlock(&dcache_lock);
++#if 0
++ if (!err) {
++ int i, j;
++ j = 0;
++ for (i = 0; i < dpages->ndpage; i++) {
++ if ((dpages->dpages + i)->ndentry)
++ Dbg("%d: %d\n", i, (dpages->dpages + i)->ndentry);
++ j += (dpages->dpages + i)->ndentry;
++ }
++ if (j)
++ Dbg("ndpage %d, %d\n", dpages->ndpage, j);
++ }
++#endif
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dcsub.h linux-2.6.22.1/fs/aufs/dcsub.h
+--- linux-2.6.22.1.oorig/fs/aufs/dcsub.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dcsub.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,47 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dcsub.h,v 1.2 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DCSUB_H__
++#define __AUFS_DCSUB_H__
++
++#ifdef __KERNEL__
++
++#include <linux/dcache.h>
++
++struct au_dpage {
++ int ndentry;
++ struct dentry **dentries;
++};
++
++struct au_dcsub_pages {
++ int ndpage;
++ struct au_dpage *dpages;
++};
++
++/* ---------------------------------------------------------------------- */
++
++int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp);
++void au_dpages_free(struct au_dcsub_pages *dpages);
++typedef int (*au_dpages_test)(struct dentry *dentry, void *arg);
++int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
++ au_dpages_test test, void *arg);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DCSUB_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/debug.c linux-2.6.22.1/fs/aufs/debug.c
+--- linux-2.6.22.1.oorig/fs/aufs/debug.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/debug.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,262 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: debug.c,v 1.27 2007/04/30 05:48:23 sfjro Exp $ */
++
++#include "aufs.h"
++
++atomic_t aufs_cond = ATOMIC_INIT(0);
++
++#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
++#define dpri(fmt, arg...) \
++ do {if (LktrCond) printk(KERN_DEBUG fmt, ##arg);} while (0)
++#else
++#define dpri(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++void au_dpri_whlist(struct aufs_nhash *whlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash)
++ dpri("b%d, %.*s, %d\n",
++ tpos->wh_bindex,
++ tpos->wh_str.len, tpos->wh_str.name,
++ tpos->wh_str.len);
++ }
++}
++
++void au_dpri_vdir(struct aufs_vdir *vdir)
++{
++ int i;
++ union aufs_deblk_p p;
++ unsigned char *o;
++
++ if (!vdir || IS_ERR(vdir)) {
++ dpri("err %ld\n", PTR_ERR(vdir));
++ return;
++ }
++
++ dpri("nblk %d, deblk %p %d, last{%d, %p}, ver %lu\n",
++ vdir->vd_nblk, vdir->vd_deblk, ksize(vdir->vd_deblk),
++ vdir->vd_last.i, vdir->vd_last.p.p, vdir->vd_version);
++ for (i = 0; i < vdir->vd_nblk; i++) {
++ p.deblk = vdir->vd_deblk[i];
++ o = p.p;
++ dpri("[%d]: %p %d\n", i, o, ksize(o));
++#if 0 // verbose
++ int j;
++ for (j = 0; j < 8; j++) {
++ dpri("%p(+%d) {%02x %02x %02x %02x %02x %02x %02x %02x "
++ "%02x %02x %02x %02x %02x %02x %02x %02x}\n",
++ p.p, p.p - o,
++ p.p[0], p.p[1], p.p[2], p.p[3],
++ p.p[4], p.p[5], p.p[6], p.p[7],
++ p.p[8], p.p[9], p.p[10], p.p[11],
++ p.p[12], p.p[13], p.p[14], p.p[15]);
++ p.p += 16;
++ }
++#endif
++ }
++}
++
++static int do_pri_inode(aufs_bindex_t bindex, struct inode *inode)
++{
++ if (!inode || IS_ERR(inode)) {
++ dpri("i%d: err %ld\n", bindex, PTR_ERR(inode));
++ return -1;
++ }
++
++ /* the type of i_blocks depends upon CONFIG_LSF */
++ BUILD_BUG_ON(sizeof(inode->i_blocks) != sizeof(unsigned long)
++ && sizeof(inode->i_blocks) != sizeof(u64));
++ dpri("i%d: i%lu, %s, cnt %d, nl %u, 0%o, sz %Lu, blk %Lu,"
++ " ct %Ld, np %lu, st 0x%lx, g %x\n",
++ bindex,
++ inode->i_ino, inode->i_sb ? au_sbtype(inode->i_sb) : "??",
++ atomic_read(&inode->i_count), inode->i_nlink, inode->i_mode,
++ i_size_read(inode), (u64)inode->i_blocks,
++ timespec_to_ns(&inode->i_ctime) & 0x0ffff,
++ inode->i_mapping ? inode->i_mapping->nrpages : 0,
++ inode->i_state, inode->i_generation);
++ return 0;
++}
++
++void au_dpri_inode(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_inode(-1, inode);
++ if (err || !au_is_aufs(inode->i_sb))
++ return;
++
++ iinfo = itoii(inode);
++ if (!iinfo)
++ return;
++ dpri("i-1: bstart %d, bend %d, gen %d\n",
++ iinfo->ii_bstart, iinfo->ii_bend, au_iigen(inode));
++ if (iinfo->ii_bstart < 0)
++ return;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; bindex++)
++ do_pri_inode(bindex, iinfo->ii_hinode[0 + bindex].hi_inode);
++}
++
++static int do_pri_dentry(aufs_bindex_t bindex, struct dentry *dentry)
++{
++ if (!dentry || IS_ERR(dentry)) {
++ dpri("d%d: err %ld\n", bindex, PTR_ERR(dentry));
++ return -1;
++ }
++ dpri("d%d: %.*s/%.*s, %s, cnt %d, flags 0x%x\n",
++ bindex,
++ DLNPair(dentry->d_parent), DLNPair(dentry),
++ dentry->d_sb ? au_sbtype(dentry->d_sb) : "??",
++ atomic_read(&dentry->d_count), dentry->d_flags);
++ do_pri_inode(bindex, dentry->d_inode);
++ return 0;
++}
++
++void au_dpri_dentry(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_dentry(-1, dentry);
++ if (err || !au_is_aufs(dentry->d_sb))
++ return;
++
++ dinfo = dtodi(dentry);
++ if (!dinfo)
++ return;
++ dpri("d-1: bstart %d, bend %d, bwh %d, bdiropq %d, gen %d\n",
++ dinfo->di_bstart, dinfo->di_bend,
++ dinfo->di_bwh, dinfo->di_bdiropq, au_digen(dentry));
++ if (dinfo->di_bstart < 0)
++ return;
++ for (bindex = dinfo->di_bstart; bindex <= dinfo->di_bend; bindex++)
++ do_pri_dentry(bindex, dinfo->di_hdentry[0 + bindex].hd_dentry);
++}
++
++static int do_pri_file(aufs_bindex_t bindex, struct file *file)
++{
++ char a[32];
++
++ if (!file || IS_ERR(file)) {
++ dpri("f%d: err %ld\n", bindex, PTR_ERR(file));
++ return -1;
++ }
++ a[0] = 0;
++ if (bindex == -1 && ftofi(file))
++ snprintf(a, sizeof(a), ", mmapped %d", au_is_mmapped(file));
++ dpri("f%d: mode 0x%x, flags 0%o, cnt %d, pos %Lu%s\n",
++ bindex, file->f_mode, file->f_flags, file_count(file),
++ file->f_pos, a);
++ do_pri_dentry(bindex, file->f_dentry);
++ return 0;
++}
++
++void au_dpri_file(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ aufs_bindex_t bindex;
++ int err;
++
++ err = do_pri_file(-1, file);
++ if (err || !file->f_dentry || !au_is_aufs(file->f_dentry->d_sb))
++ return;
++
++ finfo = ftofi(file);
++ if (!finfo)
++ return;
++ if (finfo->fi_bstart < 0)
++ return;
++ for (bindex = finfo->fi_bstart; bindex <= finfo->fi_bend; bindex++) {
++ struct aufs_hfile *hf;
++ //dpri("bindex %d\n", bindex);
++ hf = finfo->fi_hfile + bindex;
++ do_pri_file(bindex, hf ? hf->hf_file : NULL);
++ }
++}
++
++static int do_pri_br(aufs_bindex_t bindex, struct aufs_branch *br)
++{
++ struct vfsmount *mnt;
++ struct super_block *sb;
++
++ if (!br || IS_ERR(br)
++ || !(mnt = br->br_mnt) || IS_ERR(mnt)
++ || !(sb = mnt->mnt_sb) || IS_ERR(sb)) {
++ dpri("s%d: err %ld\n", bindex, PTR_ERR(br));
++ return -1;
++ }
++
++ dpri("s%d: {perm 0x%x, cnt %d}, "
++ "%s, flags 0x%lx, cnt(BIAS) %d, active %d, xino %p %p\n",
++ bindex, br->br_perm, br_count(br),
++ au_sbtype(sb), sb->s_flags, sb->s_count - S_BIAS,
++ atomic_read(&sb->s_active), br->br_xino,
++ br->br_xino ? br->br_xino->f_dentry : NULL);
++ return 0;
++}
++
++void au_dpri_sb(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ aufs_bindex_t bindex;
++ int err;
++ struct vfsmount mnt = {.mnt_sb = sb};
++ struct aufs_branch fake = {
++ .br_perm = 0,
++ .br_mnt = &mnt,
++ .br_count = ATOMIC_INIT(0),
++ .br_xino = NULL
++ };
++
++ atomic_set(&fake.br_count, 0);
++ err = do_pri_br(-1, &fake);
++ dpri("dev 0x%x\n", sb->s_dev);
++ if (err || !au_is_aufs(sb))
++ return;
++
++ sbinfo = stosi(sb);
++ if (!sbinfo)
++ return;
++ for (bindex = 0; bindex <= sbinfo->si_bend; bindex++) {
++ //dpri("bindex %d\n", bindex);
++ do_pri_br(bindex, sbinfo->si_branch[0 + bindex]);
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++void DbgSleep(int sec)
++{
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ Dbg("sleep %d sec\n", sec);
++ wait_event_timeout(wq, 0, sec * HZ);
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/debug.h linux-2.6.22.1/fs/aufs/debug.h
+--- linux-2.6.22.1.oorig/fs/aufs/debug.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/debug.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,129 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: debug.h,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DEBUG_H__
++#define __AUFS_DEBUG_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++
++#ifdef CONFIG_AUFS_DEBUG
++#define DEBUG_ON(a) BUG_ON(a)
++extern atomic_t aufs_cond;
++#define au_debug_on() atomic_inc(&aufs_cond)
++#define au_debug_off() atomic_dec(&aufs_cond)
++#define au_is_debug() atomic_read(&aufs_cond)
++#else
++#define DEBUG_ON(a) /* */
++#define au_debug_on() /* */
++#define au_debug_off() /* */
++#define au_is_debug() 0
++#endif
++
++#define MtxMustLock(mtx) DEBUG_ON(!mutex_is_locked(mtx))
++
++/* ---------------------------------------------------------------------- */
++
++/* debug print */
++#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
++#include <linux/lktr.h>
++#ifdef CONFIG_AUFS_DEBUG
++#undef LktrCond
++#define LktrCond unlikely((lktr_cond && lktr_cond()) || au_is_debug())
++#endif
++#else
++#define LktrCond au_is_debug()
++#define LKTRDumpVma(pre, vma, suf) /* */
++#define LKTRDumpStack() /* */
++#define LKTRTrace(fmt, args...) do { \
++ if (LktrCond) \
++ Dbg(fmt, ##args); \
++} while (0)
++#define LKTRLabel(label) LKTRTrace("%s\n", #label)
++#endif /* CONFIG_LKTR */
++
++#define TraceErr(e) do { \
++ if (unlikely((e) < 0)) \
++ LKTRTrace("err %d\n", (int)(e)); \
++} while (0)
++#define TraceErrPtr(p) do { \
++ if (IS_ERR(p)) \
++ LKTRTrace("err %ld\n", PTR_ERR(p)); \
++} while (0)
++#define TraceEnter() LKTRLabel(enter)
++
++/* dirty macros for debug print, use with "%.*s" and caution */
++#define LNPair(qstr) (qstr)->len,(qstr)->name
++#define DLNPair(d) LNPair(&(d)->d_name)
++
++/* ---------------------------------------------------------------------- */
++
++#define Dpri(lvl, fmt, arg...) \
++ printk(lvl AUFS_NAME " %s:%d:%s[%d]: " fmt, \
++ __func__, __LINE__, current->comm, current->pid, ##arg)
++#define Dbg(fmt, arg...) Dpri(KERN_DEBUG, fmt, ##arg)
++#define Warn(fmt, arg...) Dpri(KERN_WARNING, fmt, ##arg)
++#define Warn1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) Warn(fmt, ##arg); \
++ } while (0)
++#define Err(fmt, arg...) Dpri(KERN_ERR, fmt, ##arg)
++#define Err1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) Err(fmt, ##arg); \
++ } while (0)
++#define IOErr(fmt, arg...) Err("I/O Error, " fmt, ##arg)
++#define IOErr1(fmt, arg...) do { \
++ static unsigned char c; \
++ if (!c++) IOErr(fmt, ##arg); \
++ } while (0)
++#define IOErrWhck(fmt, arg...) Err("I/O Error, try whck. " fmt, ##arg)
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DEBUG
++struct aufs_nhash;
++void au_dpri_whlist(struct aufs_nhash *whlist);
++struct aufs_vdir;
++void au_dpri_vdir(struct aufs_vdir *vdir);
++void au_dpri_inode(struct inode *inode);
++void au_dpri_dentry(struct dentry *dentry);
++void au_dpri_file(struct file *filp);
++void au_dpri_sb(struct super_block *sb);
++#define DbgWhlist(w) do{LKTRTrace(#w "\n"); au_dpri_whlist(w);}while(0)
++#define DbgVdir(v) do{LKTRTrace(#v "\n"); au_dpri_vdir(v);}while(0)
++#define DbgInode(i) do{LKTRTrace(#i "\n"); au_dpri_inode(i);}while(0)
++#define DbgDentry(d) do{LKTRTrace(#d "\n"); au_dpri_dentry(d);}while(0)
++#define DbgFile(f) do{LKTRTrace(#f "\n"); au_dpri_file(f);}while(0)
++#define DbgSb(sb) do{LKTRTrace(#sb "\n"); au_dpri_sb(sb);}while(0)
++void DbgSleep(int sec);
++#else
++#define DbgWhlist(w) /* */
++#define DbgVdir(v) /* */
++#define DbgInode(i) /* */
++#define DbgDentry(d) /* */
++#define DbgFile(f) /* */
++#define DbgSb(sb) /* */
++#define DbgSleep(sec) /* */
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DEBUG_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dentry.c linux-2.6.22.1/fs/aufs/dentry.c
+--- linux-2.6.22.1.oorig/fs/aufs/dentry.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dentry.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,946 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dentry.c,v 1.41 2007/05/14 03:38:38 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++#ifdef CONFIG_AUFS_LHASH_PATCH
++
++#ifdef CONFIG_AUFS_DLGT
++struct lookup_hash_args {
++ struct dentry **errp;
++ struct qstr *name;
++ struct dentry *base;
++ struct nameidata *nd;
++};
++
++static void call_lookup_hash(void *args)
++{
++ struct lookup_hash_args *a = args;
++ *a->errp = __lookup_hash(a->name, a->base, a->nd);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++static struct dentry *lkup_hash(const char *name, struct dentry *parent,
++ int len, struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++ char *p;
++ unsigned long hash;
++ struct qstr this;
++ unsigned int c;
++ struct nameidata tmp_nd;
++
++ dentry = ERR_PTR(-EACCES);
++ this.name = name;
++ this.len = len;
++ if (unlikely(!len))
++ goto out;
++
++ p = (void*)name;
++ hash = init_name_hash();
++ while (len--) {
++ c = *p++;
++ if (unlikely(c == '/' || c == '\0'))
++ goto out;
++ hash = partial_name_hash(c, hash);
++ }
++ this.hash = end_name_hash(hash);
++
++ memset(&tmp_nd, 0, sizeof(tmp_nd));
++ tmp_nd.dentry = dget(parent);
++ tmp_nd.mnt = mntget(lkup->nfsmnt);
++#ifndef CONFIG_AUFS_DLGT
++ dentry = __lookup_hash(&this, parent, &tmp_nd);
++#else
++ if (!lkup->dlgt)
++ dentry = __lookup_hash(&this, parent, &tmp_nd);
++ else {
++ struct lookup_hash_args args = {
++ .errp = &dentry,
++ .name = &this,
++ .base = parent,
++ .nd = &tmp_nd
++ };
++ au_wkq_wait(call_lookup_hash, &args, /*dlgt*/1);
++ }
++#endif
++ path_release(&tmp_nd);
++
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++#elif defined(CONFIG_AUFS_DLGT)
++static struct dentry *lkup_hash(const char *name, struct dentry *parent,
++ int len, struct lkup_args *lkup)
++{
++ return ERR_PTR(-ENOSYS);
++}
++#endif
++
++#ifdef CONFIG_AUFS_DLGT
++struct lookup_one_len_args {
++ struct dentry **errp;
++ const char *name;
++ struct dentry *parent;
++ int len;
++};
++
++static void call_lookup_one_len(void *args)
++{
++ struct lookup_one_len_args *a = args;
++ *a->errp = lookup_one_len(a->name, a->parent, a->len);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
++/* cf. lookup_one_len() in linux/fs/namei.c */
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++
++ LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n",
++ DLNPair(parent), len, name, lkup->nfsmnt, lkup->dlgt);
++
++ if (!lkup->nfsmnt) {
++#ifndef CONFIG_AUFS_DLGT
++ dentry = lookup_one_len(name, parent, len);
++#else
++ if (!lkup->dlgt)
++ dentry = lookup_one_len(name, parent, len);
++ else {
++ struct lookup_one_len_args args = {
++ .errp = &dentry,
++ .name = name,
++ .parent = parent,
++ .len = len
++ };
++ au_wkq_wait(call_lookup_one_len, &args, /*dlgt*/1);
++ }
++#endif
++ } else
++ dentry = lkup_hash(name, parent, len, lkup);
++
++ TraceErrPtr(dentry);
++ return dentry;
++}
++#endif
++
++struct lkup_one_args {
++ struct dentry **errp;
++ const char *name;
++ struct dentry *parent;
++ int len;
++ struct lkup_args *lkup;
++};
++
++static void call_lkup_one(void *args)
++{
++ struct lkup_one_args *a = args;
++ *a->errp = lkup_one(a->name, a->parent, a->len, a->lkup);
++}
++
++/*
++ * returns positive/negative dentry, NULL or an error.
++ * NULL means whiteout-ed or not-found.
++ */
++static struct dentry *do_lookup(struct dentry *hidden_parent,
++ struct dentry *dentry, aufs_bindex_t bindex,
++ struct qstr *wh_name, int allow_neg,
++ mode_t type, int dlgt)
++{
++ struct dentry *hidden_dentry;
++ int wh_found, wh_able, opq;
++ struct inode *hidden_dir, *hidden_inode;
++ struct qstr *name;
++ struct super_block *sb;
++ struct lkup_args lkup = {.dlgt = dlgt};
++
++ LKTRTrace("%.*s/%.*s, b%d, allow_neg %d, type 0%o, dlgt %d\n",
++ DLNPair(hidden_parent), DLNPair(dentry), bindex, allow_neg,
++ type, dlgt);
++ DEBUG_ON(IS_ROOT(dentry));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ wh_found = 0;
++ sb = dentry->d_sb;
++ wh_able = sbr_is_whable(sb, bindex);
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ name = &dentry->d_name;
++ if (unlikely(wh_able)) {
++#if 0 //def CONFIG_AUFS_ROBR
++ if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN))
++ wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0,
++ &lkup);
++ else
++ wh_found = -EPERM;
++#else
++ wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0, &lkup);
++#endif
++ }
++ //if (LktrCond) wh_found = -1;
++ hidden_dentry = ERR_PTR(wh_found);
++ if (!wh_found)
++ goto real_lookup;
++ if (unlikely(wh_found < 0))
++ goto out;
++
++ /* We found a whiteout */
++ //set_dbend(dentry, bindex);
++ set_dbwh(dentry, bindex);
++ if (!allow_neg)
++ return NULL; /* success */
++
++ real_lookup:
++ // do not superio.
++ hidden_dentry = lkup_one(name->name, hidden_parent, name->len, &lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ if (IS_ERR(hidden_dentry))
++ goto out;
++ DEBUG_ON(d_unhashed(hidden_dentry));
++ hidden_inode = hidden_dentry->d_inode;
++ if (!hidden_inode) {
++ if (!allow_neg)
++ goto out_neg;
++ } else if (wh_found
++ || (type && type != (hidden_inode->i_mode & S_IFMT)))
++ goto out_neg;
++
++ if (dbend(dentry) <= bindex)
++ set_dbend(dentry, bindex);
++ if (dbstart(dentry) == -1 || bindex < dbstart(dentry))
++ set_dbstart(dentry, bindex);
++ set_h_dptr(dentry, bindex, hidden_dentry);
++
++ if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode) || !wh_able)
++ return hidden_dentry; /* success */
++
++ hi_lock_child(hidden_inode);
++ opq = is_diropq(hidden_dentry, &lkup);
++ //if (LktrCond) opq = -1;
++ i_unlock(hidden_inode);
++ if (opq > 0)
++ set_dbdiropq(dentry, bindex);
++ else if (unlikely(opq < 0)) {
++ set_h_dptr(dentry, bindex, NULL);
++ hidden_dentry = ERR_PTR(opq);
++ }
++ goto out;
++
++ out_neg:
++ dput(hidden_dentry);
++ hidden_dentry = NULL;
++ out:
++ TraceErrPtr(hidden_dentry);
++ return hidden_dentry;
++}
++
++/*
++ * returns the number of hidden positive dentries,
++ * otherwise an error.
++ */
++int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type)
++{
++ int npositive, err, allow_neg, dlgt;
++ struct dentry *parent;
++ aufs_bindex_t bindex, btail;
++ const struct qstr *name = &dentry->d_name;
++ struct qstr whname;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, b%d, type 0%o\n", LNPair(name), bstart, type);
++ DEBUG_ON(bstart < 0 || IS_ROOT(dentry));
++ parent = dget_parent(dentry);
++
++#if 1 //ndef CONFIG_AUFS_ROBR
++ err = -EPERM;
++ if (unlikely(!strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
++ goto out;
++#endif
++
++ err = au_alloc_whname(name->name, name->len, &whname);
++ //if (LktrCond) {au_free_whname(&whname); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ sb = dentry->d_sb;
++ dlgt = need_dlgt(sb);
++ allow_neg = !type;
++ npositive = 0;
++ btail = dbtaildir(parent);
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ struct dentry *hidden_parent, *hidden_dentry;
++ struct inode *hidden_inode;
++ struct inode *hidden_dir;
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry) {
++ if (hidden_dentry->d_inode)
++ npositive++;
++ if (type != S_IFDIR)
++ break;
++ continue;
++ }
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ if (!hidden_parent)
++ continue;
++ hidden_dir = hidden_parent->d_inode;
++ if (!hidden_dir || !S_ISDIR(hidden_dir->i_mode))
++ continue;
++
++ hi_lock_parent(hidden_dir);
++ hidden_dentry = do_lookup(hidden_parent, dentry, bindex,
++ &whname, allow_neg, type, dlgt);
++ // do not dput for testing
++ //if (LktrCond) {hidden_dentry = ERR_PTR(-1);}
++ i_unlock(hidden_dir);
++ err = PTR_ERR(hidden_dentry);
++ if (IS_ERR(hidden_dentry))
++ goto out_wh;
++ allow_neg = 0;
++
++ if (dbwh(dentry) != -1)
++ break;
++ if (!hidden_dentry)
++ continue;
++ hidden_inode = hidden_dentry->d_inode;
++ if (!hidden_inode)
++ continue;
++ npositive++;
++ if (!type)
++ type = hidden_inode->i_mode & S_IFMT;
++ if (type != S_IFDIR)
++ break;
++ else if (dbdiropq(dentry) != -1)
++ break;
++ }
++
++ if (npositive) {
++ LKTRLabel(positive);
++ au_update_dbstart(dentry);
++ }
++ err = npositive;
++
++ out_wh:
++ au_free_whname(&whname);
++ out:
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ struct dentry *dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(parent), len, name);
++ IMustLock(parent->d_inode);
++
++ if (!au_test_perm(parent->d_inode, MAY_EXEC, lkup->dlgt))
++ dentry = lkup_one(name, parent, len, lkup);
++ else {
++ // ugly
++ int dlgt = lkup->dlgt;
++ struct lkup_one_args args = {
++ .errp = &dentry,
++ .name = name,
++ .parent = parent,
++ .len = len,
++ .lkup = lkup
++ };
++
++ lkup->dlgt = 0;
++ au_wkq_wait(call_lkup_one, &args, /*dlgt*/0);
++ lkup->dlgt = dlgt;
++ }
++
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/*
++ * lookup @dentry on @bindex which should be negative.
++ */
++int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ int err;
++ struct dentry *parent, *hidden_parent, *hidden_dentry;
++ struct inode *hidden_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++ parent = dget_parent(dentry);
++ DEBUG_ON(!parent || !parent->d_inode
++ || !S_ISDIR(parent->d_inode->i_mode));
++ hidden_parent = au_h_dptr_i(parent, bindex);
++ DEBUG_ON(!hidden_parent);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bindex);
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ hidden_dentry = sio_lkup_one(dentry->d_name.name, hidden_parent,
++ dentry->d_name.len, &lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(hidden_dentry);
++ if (IS_ERR(hidden_dentry))
++ goto out;
++ if (unlikely(hidden_dentry->d_inode)) {
++ err = -EIO;
++ IOErr("b%d %.*s should be negative.%s\n",
++ bindex, DLNPair(hidden_dentry),
++ au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY) ? "" :
++ " Try udba=inotify.");
++ dput(hidden_dentry);
++ goto out;
++ }
++
++ if (bindex < dbstart(dentry))
++ set_dbstart(dentry, bindex);
++ if (dbend(dentry) < bindex)
++ set_dbend(dentry, bindex);
++ set_h_dptr(dentry, bindex, hidden_dentry);
++ err = 0;
++
++ out:
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns the number of found hidden positive dentries,
++ * otherwise an error.
++ */
++int au_refresh_hdentry(struct dentry *dentry, mode_t type)
++{
++ int npositive, pgen, new_sz, sgen, dgen;
++ struct aufs_dinfo *dinfo;
++ struct super_block *sb;
++ struct dentry *parent;
++ aufs_bindex_t bindex, parent_bend, parent_bstart, bwh, bdiropq, bend;
++ struct aufs_hdentry *p;
++ //struct nameidata nd;
++
++ LKTRTrace("%.*s, type 0%o\n", DLNPair(dentry), type);
++ DiMustWriteLock(dentry);
++ sb = dentry->d_sb;
++ DEBUG_ON(IS_ROOT(dentry));
++ parent = dget_parent(dentry);
++ pgen = au_digen(parent);
++ sgen = au_sigen(sb);
++ dgen = au_digen(dentry);
++ DEBUG_ON(pgen != sgen);
++
++ npositive = -ENOMEM;
++ new_sz = sizeof(*dinfo->di_hdentry) * (sbend(sb) + 1);
++ dinfo = dtodi(dentry);
++ p = au_kzrealloc(dinfo->di_hdentry, sizeof(*p) * (dinfo->di_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++ dinfo->di_hdentry = p;
++
++ bend = dinfo->di_bend;
++ bwh = dinfo->di_bwh;
++ bdiropq = dinfo->di_bdiropq;
++ p += dinfo->di_bstart;
++ for (bindex = dinfo->di_bstart; bindex <= bend; bindex++, p++) {
++ struct dentry *hd, *hdp;
++ struct aufs_hdentry tmp, *q;
++ aufs_bindex_t new_bindex;
++
++ hd = p->hd_dentry;
++ if (!hd)
++ continue;
++ hdp = dget_parent(hd);
++ if (hdp == au_h_dptr_i(parent, bindex)) {
++ dput(hdp);
++ continue;
++ }
++
++ new_bindex = au_find_dbindex(parent, hdp);
++ dput(hdp);
++ DEBUG_ON(new_bindex == bindex);
++ if (dinfo->di_bwh == bindex)
++ bwh = new_bindex;
++ if (dinfo->di_bdiropq == bindex)
++ bdiropq = new_bindex;
++ if (new_bindex < 0) { // test here
++ hdput(p);
++ p->hd_dentry = NULL;
++ continue;
++ }
++ /* swap two hidden dentries, and loop again */
++ q = dinfo->di_hdentry + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hd_dentry) {
++ bindex--;
++ p--;
++ }
++ }
++
++ // test here
++ dinfo->di_bwh = -1;
++ if (unlikely(bwh != -1 && bwh <= sbend(sb) && sbr_is_whable(sb, bwh)))
++ dinfo->di_bwh = bwh;
++ dinfo->di_bdiropq = -1;
++ if (unlikely(bdiropq != -1 && bdiropq <= sbend(sb)
++ && sbr_is_whable(sb, bdiropq)))
++ dinfo->di_bdiropq = bdiropq;
++ parent_bend = dbend(parent);
++ p = dinfo->di_hdentry;
++ for (bindex = 0; bindex <= parent_bend; bindex++, p++)
++ if (p->hd_dentry) {
++ dinfo->di_bstart = bindex;
++ break;
++ }
++ p = dinfo->di_hdentry + parent_bend;
++ //for (bindex = parent_bend; bindex > dinfo->di_bstart; bindex--, p--)
++ for (bindex = parent_bend; bindex >= 0; bindex--, p--)
++ if (p->hd_dentry) {
++ dinfo->di_bend = bindex;
++ break;
++ }
++
++ npositive = 0;
++ parent_bstart = dbstart(parent);
++ if (type != S_IFDIR && dinfo->di_bstart == parent_bstart)
++ goto out_dgen; /* success */
++
++#if 0
++ nd.last_type = LAST_ROOT;
++ nd.flags = LOOKUP_FOLLOW;
++ nd.depth = 0;
++ nd.mnt = mntget(??);
++ nd.dentry = dget(parent);
++#endif
++ npositive = lkup_dentry(dentry, parent_bstart, type);
++ //if (LktrCond) npositive = -1;
++ if (npositive < 0)
++ goto out;
++
++ out_dgen:
++ au_update_digen(dentry);
++ out:
++ dput(parent);
++ TraceErr(npositive);
++ return npositive;
++}
++
++static int h_d_revalidate(struct dentry *dentry, struct nameidata *nd,
++ int do_udba)
++{
++ int err, plus, locked, unhashed, is_root, h_plus, is_nfs;
++ struct nameidata fake_nd, *p;
++ aufs_bindex_t bindex, btail, bstart, ibs, ibe;
++ struct super_block *sb;
++ struct inode *inode, *first, *h_inode, *h_cached_inode;
++ umode_t mode, h_mode;
++ struct dentry *h_dentry;
++ int (*reval)(struct dentry *, struct nameidata *);
++ struct qstr *name;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(inode && au_digen(dentry) != au_iigen(inode));
++ //DbgDentry(dentry);
++ //DbgInode(inode);
++
++ err = 0;
++ sb = dentry->d_sb;
++ plus = 0;
++ mode = 0;
++ first = NULL;
++ ibs = ibe = -1;
++ unhashed = d_unhashed(dentry);
++ is_root = IS_ROOT(dentry);
++ name = &dentry->d_name;
++
++ /*
++ * Theoretically, REVAL test should be unnecessary in case of INOTIFY.
++ * But inotify doesn't fire some necessary events,
++ * IN_ATTRIB for atime/nlink/pageio
++ * IN_DELETE for NFS dentry
++ * Let's do REVAL test too.
++ */
++ if (do_udba && inode) {
++ mode = (inode->i_mode & S_IFMT);
++ plus = (inode->i_nlink > 0);
++ first = au_h_iptr(inode);
++ ibs = ibstart(inode);
++ ibe = ibend(inode);
++ }
++
++ btail = bstart = dbstart(dentry);
++ if (inode && S_ISDIR(inode->i_mode))
++ btail = dbtaildir(dentry);
++ locked = 0;
++ if (nd) {
++ fake_nd = *nd;
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (dentry != nd->dentry) {
++ di_read_lock_parent(nd->dentry, 0);
++ locked = 1;
++ }
++#endif
++ }
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ h_dentry = au_h_dptr_i(dentry, bindex);
++ if (unlikely(!h_dentry))
++ continue;
++ if (unlikely(do_udba
++ && !is_root
++ && (unhashed != d_unhashed(h_dentry)
++#if 1
++ || name->len != h_dentry->d_name.len
++ || memcmp(name->name, h_dentry->d_name.name,
++ name->len)
++#endif
++ ))) {
++ LKTRTrace("unhash 0x%x 0x%x, %.*s %.*s\n",
++ unhashed, d_unhashed(h_dentry),
++ DLNPair(dentry), DLNPair(h_dentry));
++ goto err;
++ }
++
++ reval = NULL;
++ if (h_dentry->d_op)
++ reval = h_dentry->d_op->d_revalidate;
++ if (unlikely(reval)) {
++ //LKTRLabel(hidden reval);
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ DEBUG_ON(IS_ERR(p));
++ err = !reval(h_dentry, p);
++ fake_dm_release(p);
++ if (unlikely(err)) {
++ //Dbg("here\n");
++ goto err;
++ }
++ }
++
++ if (unlikely(!do_udba))
++ continue;
++
++ /* UDBA tests */
++ h_inode = h_dentry->d_inode;
++ if (unlikely(!!inode != !!h_inode)) {
++ //Dbg("here\n");
++ goto err;
++ }
++
++ h_plus = plus;
++ h_mode = mode;
++ h_cached_inode = h_inode;
++ is_nfs = 0;
++ if (h_inode) {
++ h_mode = (h_inode->i_mode & S_IFMT);
++ h_plus = (h_inode->i_nlink > 0);
++ }
++ if (inode && ibs <= bindex && bindex <= ibe) {
++ h_cached_inode = au_h_iptr_i(inode, bindex);
++ //is_nfs = au_is_nfs(h_cached_inode->i_sb);
++ }
++
++ LKTRTrace("{%d, 0%o, %p}, h{%d, 0%o, %p}\n",
++ plus, mode, h_cached_inode,
++ h_plus, h_mode, h_inode);
++ if (unlikely(plus != h_plus || mode != h_mode
++ || (h_cached_inode != h_inode /* && !is_nfs */))) {
++ //Dbg("here\n");
++ goto err;
++ }
++ continue;
++
++ err:
++ err = -EINVAL;
++ break;
++ }
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (unlikely(locked))
++ di_read_unlock(nd->dentry, 0);
++#endif
++
++#if 0
++ // some filesystem uses CURRENT_TIME_SEC instead of CURRENT_TIME.
++ // NFS may stop IN_DELETE because of DCACHE_NFSFS_RENAMED.
++#if 0
++ && (!timespec_equal(&inode->i_ctime, &first->i_ctime)
++ || !timespec_equal(&inode->i_atime, &first->i_atime))
++#endif
++ if (unlikely(!err && udba && first))
++ au_cpup_attr_all(inode);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++static int simple_reval_dpath(struct dentry *dentry, int sgen)
++{
++ int err;
++ mode_t type;
++ struct dentry *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
++ SiMustAnyLock(dentry->d_sb);
++ DiMustWriteLock(dentry);
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode);
++
++ if (au_digen(dentry) == sgen)
++ return 0;
++
++ parent = dget_parent(dentry);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ DEBUG_ON(au_digen(parent) != sgen);
++#ifdef CONFIG_AUFS_DEBUG
++ {
++ struct dentry *d = parent;
++ while (!IS_ROOT(d)) {
++ DEBUG_ON(au_digen(d) != sgen);
++ d = d->d_parent;
++ }
++ }
++#endif
++ type = (inode->i_mode & S_IFMT);
++ /* returns a number of positive dentries */
++ err = au_refresh_hdentry(dentry, type);
++ if (err >= 0)
++ err = au_refresh_hinode(inode, dentry);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ dput(parent);
++ TraceErr(err);
++ return err;
++}
++
++int au_reval_dpath(struct dentry *dentry, int sgen)
++{
++ int err;
++ struct dentry *d, *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
++ DEBUG_ON(!dentry->d_inode);
++ DiMustWriteLock(dentry);
++
++ if (!stosi(dentry->d_sb)->si_failed_refresh_dirs)
++ return simple_reval_dpath(dentry, sgen);
++
++ /* slow loop, keep it simple and stupid */
++ /* cf: cpup_dirs() */
++ err = 0;
++ while (au_digen(dentry) != sgen) {
++ d = dentry;
++ while (1) {
++ parent = d->d_parent; // dget_parent()
++ if (au_digen(parent) == sgen)
++ break;
++ d = parent;
++ }
++
++ inode = d->d_inode;
++ if (d != dentry) {
++ //i_lock(inode);
++ di_write_lock_child(d);
++ }
++
++ /* someone might update our dentry while we were sleeping */
++ if (au_digen(d) != sgen) {
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ /* returns a number of positive dentries */
++ err = au_refresh_hdentry(d, inode->i_mode & S_IFMT);
++ //err = -1;
++ if (err >= 0)
++ err = au_refresh_hinode(inode, d);
++ //err = -1;
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++
++ if (d != dentry) {
++ di_write_unlock(d);
++ //i_unlock(inode);
++ }
++ if (unlikely(err))
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * THIS IS A BOOLEAN FUNCTION: returns 1 if valid, 0 otherwise.
++ * nfsd passes NULL as nameidata.
++ */
++static int aufs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
++{
++ int valid, sgen, err, do_udba;
++ struct super_block *sb;
++ struct inode *inode;
++
++ LKTRTrace("dentry %.*s\n", DLNPair(dentry));
++ if (nd && nd->dentry)
++ LKTRTrace("nd %.*s\n", DLNPair(nd->dentry));
++ //dir case: DEBUG_ON(dentry->d_parent != nd->dentry);
++ //remove failure case: DEBUG_ON(!IS_ROOT(dentry) && d_unhashed(dentry));
++ DEBUG_ON(!dentry->d_fsdata);
++ //DbgDentry(dentry);
++
++ err = -EINVAL;
++ inode = dentry->d_inode;
++ //DbgInode(inode);
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ sgen = au_sigen(sb);
++ if (au_digen(dentry) == sgen)
++ di_read_lock_child(dentry, !AUFS_I_RLOCK);
++ else {
++ DEBUG_ON(IS_ROOT(dentry));
++#ifdef ForceInotify
++ Dbg("UDBA or digen, %.*s\n", DLNPair(dentry));
++#endif
++ //i_lock(inode);
++ di_write_lock_child(dentry);
++ if (inode)
++ err = au_reval_dpath(dentry, sgen);
++ //err = -1;
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ //i_unlock(inode);
++ if (unlikely(err))
++ goto out;
++ ii_read_unlock(inode);
++ DEBUG_ON(au_iigen(inode) != sgen);
++ }
++
++ if (inode) {
++ if (au_iigen(inode) == sgen)
++ ii_read_lock_child(inode);
++ else {
++ DEBUG_ON(IS_ROOT(dentry));
++#ifdef ForceInotify
++ Dbg("UDBA or survived, %.*s\n", DLNPair(dentry));
++#endif
++ ii_write_lock_child(inode);
++ err = au_refresh_hinode(inode, dentry);
++ ii_downgrade_lock(inode);
++ if (unlikely(err))
++ goto out;
++ DEBUG_ON(au_iigen(inode) != sgen);
++ }
++ }
++
++#if 0 // fix it
++ /* parent dir i_nlink is not updated in the case of setattr */
++ if (S_ISDIR(inode->i_mode)) {
++ i_lock(inode);
++ ii_write_lock(inode);
++ au_cpup_attr_nlink(inode);
++ ii_write_unlock(inode);
++ i_unlock(inode);
++ }
++#endif
++
++ err = -EINVAL;
++ do_udba = !au_flag_test(sb, AuFlag_UDBA_NONE);
++ if (do_udba && inode && ibstart(inode) >= 0
++ && au_test_higen(inode, au_h_iptr(inode)))
++ goto out;
++ err = h_d_revalidate(dentry, nd, do_udba);
++ //err = -1;
++
++ out:
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ TraceErr(err);
++ valid = !err;
++ //au_debug_on();
++ if (!valid)
++ LKTRTrace("%.*s invalid\n", DLNPair(dentry));
++ //au_debug_off();
++ return valid;
++}
++
++static void aufs_d_release(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!d_unhashed(dentry));
++
++ dinfo = dentry->d_fsdata;
++ if (unlikely(!dinfo))
++ return;
++
++ /* dentry may not be revalidated */
++ bindex = dinfo->di_bstart;
++ if (bindex >= 0) {
++ struct aufs_hdentry *p;
++ bend = dinfo->di_bend;
++ DEBUG_ON(bend < bindex);
++ p = dinfo->di_hdentry + bindex;
++ while (bindex++ <= bend) {
++ if (p->hd_dentry)
++ hdput(p);
++ p++;
++ }
++ }
++ kfree(dinfo->di_hdentry);
++ cache_free_dinfo(dinfo);
++}
++
++#if 0
++/* it may be called at remount time, too */
++static void aufs_d_iput(struct dentry *dentry, struct inode *inode)
++{
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, i%lu\n", DLNPair(dentry), inode->i_ino);
++
++ sb = dentry->d_sb;
++#if 0
++ si_read_lock(sb);
++ if (unlikely(au_flag_test(sb, AuFlag_PLINK)
++ && au_is_plinked(sb, inode))) {
++ ii_write_lock(inode);
++ au_update_brange(inode, 1);
++ ii_write_unlock(inode);
++ }
++ si_read_unlock(sb);
++#endif
++ iput(inode);
++}
++#endif
++
++struct dentry_operations aufs_dop = {
++ .d_revalidate = aufs_d_revalidate,
++ .d_release = aufs_d_release
++ //.d_iput = aufs_d_iput
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dentry.h linux-2.6.22.1/fs/aufs/dentry.h
+--- linux-2.6.22.1.oorig/fs/aufs/dentry.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dentry.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,183 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dentry.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DENTRY_H__
++#define __AUFS_DENTRY_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++
++struct aufs_hdentry {
++ struct dentry *hd_dentry;
++};
++
++struct aufs_dinfo {
++ atomic_t di_generation;
++
++ struct aufs_rwsem di_rwsem;
++ aufs_bindex_t di_bstart, di_bend, di_bwh, di_bdiropq;
++ struct aufs_hdentry *di_hdentry;
++};
++
++struct lkup_args {
++ struct vfsmount *nfsmnt;
++ int dlgt;
++ //struct super_block *sb;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* dentry.c */
++#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup);
++#else
++static inline
++struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup)
++{
++ return lookup_one_len(name, parent, len);
++}
++#endif
++
++extern struct dentry_operations aufs_dop;
++struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
++ struct lkup_args *lkup);
++int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type);
++int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex);
++int au_refresh_hdentry(struct dentry *dentry, mode_t type);
++int au_reval_dpath(struct dentry *dentry, int sgen);
++
++/* dinfo.c */
++int au_alloc_dinfo(struct dentry *dentry);
++struct aufs_dinfo *dtodi(struct dentry *dentry);
++
++void di_read_lock(struct dentry *d, int flags, unsigned int lsc);
++void di_read_unlock(struct dentry *d, int flags);
++void di_downgrade_lock(struct dentry *d, int flags);
++void di_write_lock(struct dentry *d, unsigned int lsc);
++void di_write_unlock(struct dentry *d);
++void di_write_lock2_child(struct dentry *d1, struct dentry *d2, int isdir);
++void di_write_lock2_parent(struct dentry *d1, struct dentry *d2, int isdir);
++void di_write_unlock2(struct dentry *d1, struct dentry *d2);
++
++aufs_bindex_t dbstart(struct dentry *dentry);
++aufs_bindex_t dbend(struct dentry *dentry);
++aufs_bindex_t dbwh(struct dentry *dentry);
++aufs_bindex_t dbdiropq(struct dentry *dentry);
++struct dentry *au_h_dptr_i(struct dentry *dentry, aufs_bindex_t bindex);
++struct dentry *au_h_dptr(struct dentry *dentry);
++
++aufs_bindex_t dbtail(struct dentry *dentry);
++aufs_bindex_t dbtaildir(struct dentry *dentry);
++aufs_bindex_t dbtail_generic(struct dentry *dentry);
++
++void set_dbstart(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbend(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbwh(struct dentry *dentry, aufs_bindex_t bindex);
++void set_dbdiropq(struct dentry *dentry, aufs_bindex_t bindex);
++void hdput(struct aufs_hdentry *hdentry);
++void set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_dentry);
++
++void au_update_digen(struct dentry *dentry);
++void au_update_dbstart(struct dentry *dentry);
++int au_find_dbindex(struct dentry *dentry, struct dentry *h_dentry);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int au_digen(struct dentry *d)
++{
++ return atomic_read(&dtodi(d)->di_generation);
++}
++
++#ifdef CONFIG_AUFS_HINOTIFY
++static inline void au_digen_dec(struct dentry *d)
++{
++ atomic_dec(&dtodi(d)->di_generation);
++}
++#endif /* CONFIG_AUFS_HINOTIFY */
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for dinfo */
++enum {
++ AuLsc_DI_CHILD, /* child first */
++ AuLsc_DI_CHILD2, /* rename(2), link(2), and cpup at hinotify */
++ AuLsc_DI_CHILD3, /* copyup dirs */
++ AuLsc_DI_PARENT,
++ AuLsc_DI_PARENT2,
++ AuLsc_DI_PARENT3
++};
++
++/*
++ * di_read_lock_child, di_write_lock_child,
++ * di_read_lock_child2, di_write_lock_child2,
++ * di_read_lock_child3, di_write_lock_child3,
++ * di_read_lock_parent, di_write_lock_parent,
++ * di_read_lock_parent2, di_write_lock_parent2,
++ * di_read_lock_parent3, di_write_lock_parent3,
++ */
++#define ReadLockFunc(name, lsc) \
++static inline void di_read_lock_##name(struct dentry *d, int flags) \
++{di_read_lock(d, flags, AuLsc_DI_##lsc);}
++
++#define WriteLockFunc(name, lsc) \
++static inline void di_write_lock_##name(struct dentry *d) \
++{di_write_lock(d, AuLsc_DI_##lsc);}
++
++#define RWLockFuncs(name, lsc) \
++ ReadLockFunc(name, lsc); \
++ WriteLockFunc(name, lsc)
++
++RWLockFuncs(child, CHILD);
++RWLockFuncs(child2, CHILD2);
++RWLockFuncs(child3, CHILD3);
++RWLockFuncs(parent, PARENT);
++RWLockFuncs(parent2, PARENT2);
++RWLockFuncs(parent3, PARENT3);
++
++#undef ReadLockFunc
++#undef WriteLockFunc
++#undef RWLockFunc
++
++/* to debug easier, do not make them inlined functions */
++#define DiMustReadLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustReadLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustWriteLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustWriteLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustAnyLock(d) do { \
++ SiMustAnyLock((d)->d_sb); \
++ RwMustAnyLock(&dtodi(d)->di_rwsem); \
++} while (0)
++
++#define DiMustNoWaiters(d) RwMustNoWaiters(&dtodi(d)->di_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DENTRY_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dinfo.c linux-2.6.22.1/fs/aufs/dinfo.c
+--- linux-2.6.22.1.oorig/fs/aufs/dinfo.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dinfo.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,419 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dinfo.c,v 1.23 2007/05/07 03:43:36 sfjro Exp $ */
++
++#include "aufs.h"
++
++int au_alloc_dinfo(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo;
++ struct super_block *sb;
++ int nbr;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(dentry->d_fsdata);
++
++ dinfo = cache_alloc_dinfo();
++ //if (LktrCond) {cache_free_dinfo(dinfo); dinfo = NULL;}
++ if (dinfo) {
++ sb = dentry->d_sb;
++ nbr = sbend(sb) + 1;
++ if (unlikely(!nbr))
++ nbr++;
++ dinfo->di_hdentry = kcalloc(nbr, sizeof(*dinfo->di_hdentry),
++ GFP_KERNEL);
++ //if (LktrCond)
++ //{kfree(dinfo->di_hdentry); dinfo->di_hdentry = NULL;}
++ if (dinfo->di_hdentry) {
++ rw_init_wlock_nested(&dinfo->di_rwsem, AuLsc_DI_PARENT);
++ dinfo->di_bstart = dinfo->di_bend = -1;
++ dinfo->di_bwh = dinfo->di_bdiropq = -1;
++ atomic_set(&dinfo->di_generation, au_sigen(sb));
++
++ dentry->d_fsdata = dinfo;
++ dentry->d_op = &aufs_dop;
++ return 0; /* success */
++ }
++ cache_free_dinfo(dinfo);
++ }
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
++
++struct aufs_dinfo *dtodi(struct dentry *dentry)
++{
++ struct aufs_dinfo *dinfo = dentry->d_fsdata;
++ DEBUG_ON(!dinfo
++ || !dinfo->di_hdentry
++ /* || stosi(dentry->d_sb)->si_bend < dinfo->di_bend */
++ || dinfo->di_bend < dinfo->di_bstart
++ /* dbwh can be outside of this range */
++ || (0 <= dinfo->di_bdiropq
++ && (dinfo->di_bdiropq < dinfo->di_bstart
++ /* || dinfo->di_bend < dinfo->di_bdiropq */))
++ );
++ return dinfo;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void do_ii_write_lock(struct inode *inode, unsigned int lsc)
++{
++ switch (lsc) {
++ case AuLsc_DI_CHILD:
++ ii_write_lock_child(inode);
++ break;
++ case AuLsc_DI_CHILD2:
++ ii_write_lock_child2(inode);
++ break;
++ case AuLsc_DI_CHILD3:
++ ii_write_lock_child3(inode);
++ break;
++ case AuLsc_DI_PARENT:
++ ii_write_lock_parent(inode);
++ break;
++ case AuLsc_DI_PARENT2:
++ ii_write_lock_parent2(inode);
++ break;
++ case AuLsc_DI_PARENT3:
++ ii_write_lock_parent3(inode);
++ break;
++ default:
++ BUG();
++ }
++}
++
++static void do_ii_read_lock(struct inode *inode, unsigned int lsc)
++{
++ switch (lsc) {
++ case AuLsc_DI_CHILD:
++ ii_read_lock_child(inode);
++ break;
++ case AuLsc_DI_CHILD2:
++ ii_read_lock_child2(inode);
++ break;
++ case AuLsc_DI_CHILD3:
++ ii_read_lock_child3(inode);
++ break;
++ case AuLsc_DI_PARENT:
++ ii_read_lock_parent(inode);
++ break;
++ case AuLsc_DI_PARENT2:
++ ii_read_lock_parent2(inode);
++ break;
++ case AuLsc_DI_PARENT3:
++ ii_read_lock_parent3(inode);
++ break;
++ default:
++ BUG();
++ }
++}
++
++void di_read_lock(struct dentry *d, int flags, unsigned int lsc)
++{
++ SiMustAnyLock(d->d_sb);
++ // todo: always nested?
++ rw_read_lock_nested(&dtodi(d)->di_rwsem, lsc);
++ if (d->d_inode) {
++ if (flags & AUFS_I_WLOCK)
++ do_ii_write_lock(d->d_inode, lsc);
++ else if (flags & AUFS_I_RLOCK)
++ do_ii_read_lock(d->d_inode, lsc);
++ }
++}
++
++void di_read_unlock(struct dentry *d, int flags)
++{
++ SiMustAnyLock(d->d_sb);
++ if (d->d_inode) {
++ if (flags & AUFS_I_WLOCK)
++ ii_write_unlock(d->d_inode);
++ else if (flags & AUFS_I_RLOCK)
++ ii_read_unlock(d->d_inode);
++ }
++ rw_read_unlock(&dtodi(d)->di_rwsem);
++}
++
++void di_downgrade_lock(struct dentry *d, int flags)
++{
++ SiMustAnyLock(d->d_sb);
++ rw_dgrade_lock(&dtodi(d)->di_rwsem);
++ if (d->d_inode && (flags & AUFS_I_RLOCK))
++ ii_downgrade_lock(d->d_inode);
++}
++
++void di_write_lock(struct dentry *d, unsigned int lsc)
++{
++ SiMustAnyLock(d->d_sb);
++ // todo: always nested?
++ rw_write_lock_nested(&dtodi(d)->di_rwsem, lsc);
++ if (d->d_inode)
++ do_ii_write_lock(d->d_inode, lsc);
++}
++
++void di_write_unlock(struct dentry *d)
++{
++ SiMustAnyLock(d->d_sb);
++ if (d->d_inode)
++ ii_write_unlock(d->d_inode);
++ rw_write_unlock(&dtodi(d)->di_rwsem);
++}
++
++void di_write_lock2_child(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ struct dentry *d;
++
++ TraceEnter();
++ DEBUG_ON(d1 == d2
++ || d1->d_inode == d2->d_inode
++ || d1->d_sb != d2->d_sb);
++
++ if (isdir)
++ for (d = d1; d->d_parent != d; d = d->d_parent) // dget_parent()
++ if (d->d_parent == d2) {
++ di_write_lock_child(d1);
++ di_write_lock_child2(d2);
++ return;
++ }
++
++ di_write_lock_child(d2);
++ di_write_lock_child2(d1);
++}
++
++void di_write_lock2_parent(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ struct dentry *d;
++
++ TraceEnter();
++ DEBUG_ON(d1 == d2
++ || d1->d_inode == d2->d_inode
++ || d1->d_sb != d2->d_sb);
++
++ if (isdir)
++ for (d = d1; d->d_parent != d; d = d->d_parent) // dget_parent()
++ if (d->d_parent == d2) {
++ di_write_lock_parent(d1);
++ di_write_lock_parent2(d2);
++ return;
++ }
++
++ di_write_lock_parent(d2);
++ di_write_lock_parent2(d1);
++}
++
++void di_write_unlock2(struct dentry *d1, struct dentry *d2)
++{
++ di_write_unlock(d1);
++ if (d1->d_inode == d2->d_inode)
++ rw_write_unlock(&dtodi(d2)->di_rwsem);
++ else
++ di_write_unlock(d2);
++}
++
++/* ---------------------------------------------------------------------- */
++
++aufs_bindex_t dbstart(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bstart;
++}
++
++aufs_bindex_t dbend(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bend;
++}
++
++aufs_bindex_t dbwh(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ return dtodi(dentry)->di_bwh;
++}
++
++aufs_bindex_t dbdiropq(struct dentry *dentry)
++{
++ DiMustAnyLock(dentry);
++ DEBUG_ON(dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode));
++ return dtodi(dentry)->di_bdiropq;
++}
++
++struct dentry *au_h_dptr_i(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ struct dentry *d;
++
++ DiMustAnyLock(dentry);
++ if (dbstart(dentry) < 0 || bindex < dbstart(dentry))
++ return NULL;
++ DEBUG_ON(bindex < 0
++ /* || bindex > sbend(dentry->d_sb) */);
++ d = dtodi(dentry)->di_hdentry[0 + bindex].hd_dentry;
++ DEBUG_ON(d && (atomic_read(&d->d_count) <= 0));
++ return d;
++}
++
++struct dentry *au_h_dptr(struct dentry *dentry)
++{
++ return au_h_dptr_i(dentry, dbstart(dentry));
++}
++
++aufs_bindex_t dbtail(struct dentry *dentry)
++{
++ aufs_bindex_t bend, bwh;
++
++ bend = dbend(dentry);
++ if (0 <= bend) {
++ bwh = dbwh(dentry);
++ //DEBUG_ON(bend < bwh);
++ if (!bwh)
++ return bwh;
++ if (0 < bwh && bwh < bend)
++ return bwh - 1;
++ }
++ return bend;
++}
++
++aufs_bindex_t dbtaildir(struct dentry *dentry)
++{
++ aufs_bindex_t bend, bopq;
++
++ DEBUG_ON(dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode));
++
++ bend = dbtail(dentry);
++ if (0 <= bend) {
++ bopq = dbdiropq(dentry);
++ DEBUG_ON(bend < bopq);
++ if (0 <= bopq && bopq < bend)
++ bend = bopq;
++ }
++ return bend;
++}
++
++aufs_bindex_t dbtail_generic(struct dentry *dentry)
++{
++ struct inode *inode;
++
++ inode = dentry->d_inode;
++ if (inode && S_ISDIR(inode->i_mode))
++ return dbtaildir(dentry);
++ else
++ return dbtail(dentry);
++}
++
++/* ---------------------------------------------------------------------- */
++
++// hard/soft set
++void set_dbstart(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ /* */
++ dtodi(dentry)->di_bstart = bindex;
++}
++
++void set_dbend(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex
++ || bindex < dbstart(dentry));
++ dtodi(dentry)->di_bend = bindex;
++}
++
++void set_dbwh(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ /* dbwh can be outside of bstart - bend range */
++ dtodi(dentry)->di_bwh = bindex;
++}
++
++void set_dbdiropq(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ DiMustWriteLock(dentry);
++ DEBUG_ON(sbend(dentry->d_sb) < bindex);
++ DEBUG_ON((bindex != -1
++ && (bindex < dbstart(dentry) || dbend(dentry) < bindex))
++ || (dentry->d_inode
++ && dentry->d_inode->i_mode
++ && !S_ISDIR(dentry->d_inode->i_mode)));
++ dtodi(dentry)->di_bdiropq = bindex;
++}
++
++void hdput(struct aufs_hdentry *hd)
++{
++ dput(hd->hd_dentry);
++}
++
++void set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_dentry)
++{
++ struct aufs_hdentry *hd = dtodi(dentry)->di_hdentry + bindex;
++ DiMustWriteLock(dentry);
++ DEBUG_ON(bindex < dtodi(dentry)->di_bstart
++ || bindex > dtodi(dentry)->di_bend
++ || (h_dentry && atomic_read(&h_dentry->d_count) <= 0)
++ || (h_dentry && hd->hd_dentry)
++ );
++ if (hd->hd_dentry)
++ hdput(hd);
++ hd->hd_dentry = h_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void au_update_digen(struct dentry *dentry)
++{
++ //DiMustWriteLock(dentry);
++ DEBUG_ON(!dentry->d_sb);
++ atomic_set(&dtodi(dentry)->di_generation, au_sigen(dentry->d_sb));
++}
++
++void au_update_dbstart(struct dentry *dentry)
++{
++ aufs_bindex_t bindex, bstart = dbstart(dentry), bend = dbend(dentry);
++ struct dentry *hidden_dentry;
++
++ DiMustWriteLock(dentry);
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ if (hidden_dentry->d_inode) {
++ set_dbstart(dentry, bindex);
++ return;
++ }
++ set_h_dptr(dentry, bindex, NULL);
++ }
++ //set_dbstart(dentry, -1);
++ //set_dbend(dentry, -1);
++}
++
++int au_find_dbindex(struct dentry *dentry, struct dentry *hidden_dentry)
++{
++ aufs_bindex_t bindex, bend;
++
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++)
++ if (au_h_dptr_i(dentry, bindex) == hidden_dentry)
++ return bindex;
++ return -1;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dir.c linux-2.6.22.1/fs/aufs/dir.c
+--- linux-2.6.22.1.oorig/fs/aufs/dir.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dir.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,564 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dir.c,v 1.36 2007/05/14 03:38:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static int reopen_dir(struct file *file)
++{
++ int err;
++ struct dentry *dentry, *hidden_dentry;
++ aufs_bindex_t bindex, btail, bstart;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!S_ISDIR(dentry->d_inode->i_mode));
++
++ /* open all hidden dirs */
++ bstart = dbstart(dentry);
++#if 1
++ for (bindex = fbstart(file); bindex < bstart; bindex++)
++ set_h_fptr(file, bindex, NULL);
++#endif
++ set_fbstart(file, bstart);
++ btail = dbtaildir(dentry);
++#if 1
++ for (bindex = fbend(file); btail < bindex; bindex--)
++ set_h_fptr(file, bindex, NULL);
++#endif
++ set_fbend(file, btail);
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (hidden_file) {
++ DEBUG_ON(hidden_file->f_dentry != hidden_dentry);
++ continue;
++ }
++
++ hidden_file = hidden_open(dentry, bindex, file->f_flags);
++ // unavailable
++ //if (LktrCond) {fput(hidden_file);
++ //br_put(stobr(dentry->d_sb, bindex));hidden_file=ERR_PTR(-1);}
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out; // close all?
++ //cpup_file_flags(hidden_file, file);
++ set_h_fptr(file, bindex, hidden_file);
++ }
++ err = 0;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int do_open_dir(struct file *file, int flags)
++{
++ int err;
++ aufs_bindex_t bindex, btail;
++ struct dentry *dentry, *hidden_dentry;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, 0x%x\n", DLNPair(dentry), flags);
++ DEBUG_ON(!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode));
++
++ err = 0;
++ set_fvdir_cache(file, NULL);
++ file->f_version = dentry->d_inode->i_version;
++ bindex = dbstart(dentry);
++ set_fbstart(file, bindex);
++ btail = dbtaildir(dentry);
++ set_fbend(file, btail);
++ for (; !err && bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++
++ hidden_file = hidden_open(dentry, bindex, flags);
++ //if (LktrCond) {fput(hidden_file);
++ //br_put(stobr(dentry->d_sb, bindex));hidden_file=ERR_PTR(-1);}
++ if (!IS_ERR(hidden_file)) {
++ set_h_fptr(file, bindex, hidden_file);
++ continue;
++ }
++ err = PTR_ERR(hidden_file);
++ }
++ if (!err)
++ return 0; /* success */
++
++ /* close all */
++ for (bindex = fbstart(file); !err && bindex <= btail; bindex++)
++ set_h_fptr(file, bindex, NULL);
++ set_fbstart(file, -1);
++ set_fbend(file, -1);
++ return err;
++}
++
++static int aufs_open_dir(struct inode *inode, struct file *file)
++{
++ return au_do_open(inode, file, do_open_dir);
++}
++
++static int aufs_release_dir(struct inode *inode, struct file *file)
++{
++ struct aufs_vdir *vdir_cache;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(file->f_dentry));
++
++ sb = file->f_dentry->d_sb;
++ si_read_lock(sb);
++ fi_write_lock(file);
++ vdir_cache = fvdir_cache(file);
++ if (vdir_cache)
++ free_vdir(vdir_cache);
++ fi_write_unlock(file);
++ au_fin_finfo(file);
++ si_read_unlock(sb);
++ return 0;
++}
++
++static int fsync_dir(struct dentry *dentry, int datasync)
++{
++ int err;
++ struct inode *inode;
++ struct super_block *sb;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ DiMustAnyLock(dentry);
++ sb = dentry->d_sb;
++ SiMustAnyLock(sb);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++ IiMustAnyLock(inode);
++
++ err = 0;
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); !err && bindex <= bend; bindex++) {
++ struct dentry *h_dentry;
++ struct inode *h_inode;
++ struct file_operations *fop;
++
++ if (test_ro(sb, bindex, inode))
++ continue;
++ h_dentry = au_h_dptr_i(dentry, bindex);
++ if (!h_dentry)
++ continue;
++ h_inode = h_dentry->d_inode;
++ if (!h_inode)
++ continue;
++
++ /* cf. fs/nsfd/vfs.c and fs/nfsd/nfs4recover.c */
++ //hdir_lock(h_inode, inode, bindex);
++ i_lock(h_inode);
++ fop = (void*)h_inode->i_fop;
++ err = filemap_fdatawrite(h_inode->i_mapping);
++ if (!err && fop && fop->fsync)
++ err = fop->fsync(NULL, h_dentry, datasync);
++ if (!err)
++ err = filemap_fdatawrite(h_inode->i_mapping);
++ //hdir_unlock(h_inode, inode, bindex);
++ i_unlock(h_inode);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * @file may be NULL
++ */
++static int aufs_fsync_dir(struct file *file, struct dentry *dentry,
++ int datasync)
++{
++ int err;
++ struct inode *inode;
++ struct file *hidden_file;
++ struct super_block *sb;
++ aufs_bindex_t bend, bindex;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ err = 0;
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ if (file) {
++ err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
++ /*locked*/1);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ } else
++ di_read_lock_child(dentry, !AUFS_I_WLOCK);
++
++ ii_write_lock_child(inode);
++ if (file) {
++ bend = fbend(file);
++ for (bindex = fbstart(file); !err && bindex <= bend; bindex++) {
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (!hidden_file || test_ro(sb, bindex, inode))
++ continue;
++
++ err = -EINVAL;
++ if (hidden_file->f_op && hidden_file->f_op->fsync) {
++ // todo: try do_fsync() in fs/sync.c
++#if 0
++ DEBUG_ON(hidden_file->f_dentry->d_inode
++ != au_h_iptr_i(inode, bindex));
++ hdir_lock(hidden_file->f_dentry->d_inode, inode,
++ bindex);
++#else
++ i_lock(hidden_file->f_dentry->d_inode);
++#endif
++ err = hidden_file->f_op->fsync
++ (hidden_file, hidden_file->f_dentry,
++ datasync);
++ //err = -1;
++#if 0
++ hdir_unlock(hidden_file->f_dentry->d_inode,
++ inode, bindex);
++#else
++ i_unlock(hidden_file->f_dentry->d_inode);
++#endif
++ }
++ }
++ } else
++ err = fsync_dir(dentry, datasync);
++ au_cpup_attr_timesizes(inode);
++ ii_write_unlock(inode);
++ if (file)
++ fi_write_unlock(file);
++ else
++ di_read_unlock(dentry, !AUFS_I_WLOCK);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_readdir(struct file *file, void *dirent, filldir_t filldir)
++{
++ int err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ au_nfsd_lockdep_off();
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
++ /*locked*/1);
++ if (unlikely(err))
++ goto out;
++
++ ii_write_lock_child(inode);
++ err = au_init_vdir(file);
++ if (unlikely(err)) {
++ ii_write_unlock(inode);
++ goto out_unlock;
++ }
++ //DbgVdir(fvdir_cache(file));// goto out_unlock;
++
++ /* nfsd filldir calls lookup_one_len(). */
++ ii_downgrade_lock(inode);
++ err = au_fill_de(file, dirent, filldir);
++ //DbgVdir(fvdir_cache(file));// goto out_unlock;
++
++ inode->i_atime = au_h_iptr(inode)->i_atime;
++ ii_read_unlock(inode);
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ au_nfsd_lockdep_on();
++#if 0 // debug
++ if (LktrCond)
++ igrab(inode);
++#endif
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct test_empty_arg {
++ struct aufs_nhash *whlist;
++ int whonly;
++ aufs_bindex_t bindex;
++ int err, called;
++};
++
++static int test_empty_cb(void *__arg, const char *__name, int namelen,
++ loff_t offset, filldir_ino_t ino, unsigned int d_type)
++{
++ struct test_empty_arg *arg = __arg;
++ char *name = (void*)__name;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ arg->err = 0;
++ arg->called++;
++ //smp_mb();
++ if (name[0] == '.'
++ && (namelen == 1 || (name[1] == '.' && namelen == 2)))
++ return 0; /* success */
++
++ if (namelen <= AUFS_WH_PFX_LEN
++ || memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) {
++ if (arg->whonly && !test_known_wh(arg->whlist, name, namelen))
++ arg->err = -ENOTEMPTY;
++ goto out;
++ }
++
++ name += AUFS_WH_PFX_LEN;
++ namelen -= AUFS_WH_PFX_LEN;
++ if (!test_known_wh(arg->whlist, name, namelen))
++ arg->err = append_wh(arg->whlist, name, namelen, arg->bindex);
++
++ out:
++ //smp_mb();
++ TraceErr(arg->err);
++ return arg->err;
++}
++
++static int do_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
++{
++ int err, dlgt;
++ struct file *hidden_file;
++
++ LKTRTrace("%.*s, {%p, %d, %d}\n",
++ DLNPair(dentry), arg->whlist, arg->whonly, arg->bindex);
++
++ hidden_file = hidden_open(dentry, arg->bindex,
++ O_RDONLY | O_NONBLOCK | O_DIRECTORY
++ | O_LARGEFILE);
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out;
++
++ dlgt = need_dlgt(dentry->d_sb);
++ //hidden_file->f_pos = 0;
++ do {
++ arg->err = 0;
++ arg->called = 0;
++ //smp_mb();
++ err = vfsub_readdir(hidden_file, test_empty_cb, arg, dlgt);
++ if (err >= 0)
++ err = arg->err;
++ } while (!err && arg->called);
++ fput(hidden_file);
++ sbr_put(dentry->d_sb, arg->bindex);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct do_test_empty_args {
++ int *errp;
++ struct dentry *dentry;
++ struct test_empty_arg *arg;
++};
++
++static void call_do_test_empty(void *args)
++{
++ struct do_test_empty_args *a = args;
++ *a->errp = do_test_empty(a->dentry, a->arg);
++}
++
++static int sio_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
++{
++ int err;
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ hidden_dentry = au_h_dptr_i(dentry, arg->bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode || !S_ISDIR(hidden_inode->i_mode));
++
++ hi_lock_child(hidden_inode);
++ err = au_test_perm(hidden_inode, MAY_EXEC | MAY_READ,
++ need_dlgt(dentry->d_sb));
++ i_unlock(hidden_inode);
++ if (!err)
++ err = do_test_empty(dentry, arg);
++ else {
++ struct do_test_empty_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .arg = arg
++ };
++ au_wkq_wait(call_do_test_empty, &args, /*dlgt*/0);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++int au_test_empty_lower(struct dentry *dentry)
++{
++ int err;
++ struct inode *inode;
++ struct test_empty_arg arg;
++ struct aufs_nhash *whlist;
++ aufs_bindex_t bindex, bstart, btail;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++
++ bstart = dbstart(dentry);
++ arg.whlist = whlist;
++ arg.whonly = 0;
++ arg.bindex = bstart;
++ err = do_test_empty(dentry, &arg);
++ if (unlikely(err))
++ goto out_whlist;
++
++ arg.whonly = 1;
++ btail = dbtaildir(dentry);
++ for (bindex = bstart + 1; !err && bindex <= btail; bindex++) {
++ struct dentry *hidden_dentry;
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry && hidden_dentry->d_inode) {
++ DEBUG_ON(!S_ISDIR(hidden_dentry->d_inode->i_mode));
++ arg.bindex = bindex;
++ err = do_test_empty(dentry, &arg);
++ }
++ }
++
++ out_whlist:
++ nhash_del(whlist);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int test_empty(struct dentry *dentry, struct aufs_nhash *whlist)
++{
++ int err;
++ struct inode *inode;
++ struct test_empty_arg arg;
++ aufs_bindex_t bindex, btail;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ err = 0;
++ arg.whlist = whlist;
++ arg.whonly = 1;
++ btail = dbtaildir(dentry);
++ for (bindex = dbstart(dentry); !err && bindex <= btail; bindex++) {
++ struct dentry *hidden_dentry;
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (hidden_dentry && hidden_dentry->d_inode) {
++ DEBUG_ON(!S_ISDIR(hidden_dentry->d_inode->i_mode));
++ arg.bindex = bindex;
++ err = sio_test_empty(dentry, &arg);
++ }
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void au_add_nlink(struct inode *dir, struct inode *h_dir)
++{
++ DEBUG_ON(!S_ISDIR(dir->i_mode) || !S_ISDIR(h_dir->i_mode));
++ dir->i_nlink += h_dir->i_nlink - 2;
++ if (unlikely(h_dir->i_nlink < 2))
++ dir->i_nlink += 2;
++}
++
++void au_sub_nlink(struct inode *dir, struct inode *h_dir)
++{
++ DEBUG_ON(!S_ISDIR(dir->i_mode) || !S_ISDIR(h_dir->i_mode));
++ dir->i_nlink -= h_dir->i_nlink - 2;
++ if (unlikely(h_dir->i_nlink < 2))
++ dir->i_nlink -= 2;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 // comment
++struct file_operations {
++ struct module *owner;
++ loff_t (*llseek) (struct file *, loff_t, int);
++ ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
++ ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
++ ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
++ ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
++ int (*readdir) (struct file *, void *, filldir_t);
++ unsigned int (*poll) (struct file *, struct poll_table_struct *);
++ int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
++ long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
++ long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
++ int (*mmap) (struct file *, struct vm_area_struct *);
++ int (*open) (struct inode *, struct file *);
++ int (*flush) (struct file *);
++ int (*release) (struct inode *, struct file *);
++ int (*fsync) (struct file *, struct dentry *, int datasync);
++ int (*aio_fsync) (struct kiocb *, int datasync);
++ int (*fasync) (int, struct file *, int);
++ int (*lock) (struct file *, int, struct file_lock *);
++ ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
++ ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
++ unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
++ int (*check_flags)(int);
++ int (*dir_notify)(struct file *file, unsigned long arg);
++ int (*flock) (struct file *, int, struct file_lock *);
++};
++#endif
++
++struct file_operations aufs_dir_fop = {
++ .read = generic_read_dir,
++ .readdir = aufs_readdir,
++ .open = aufs_open_dir,
++ .release = aufs_release_dir,
++ .flush = aufs_flush,
++ .fsync = aufs_fsync_dir,
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/dir.h linux-2.6.22.1/fs/aufs/dir.h
+--- linux-2.6.22.1.oorig/fs/aufs/dir.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/dir.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,125 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: dir.h,v 1.18 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_DIR_H__
++#define __AUFS_DIR_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
++#define filldir_ino_t u64
++#else
++#define filldir_ino_t ino_t
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* need to be faster and smaller */
++
++#define AUFS_DEBLK_SIZE 512 // todo: changable
++#define AUFS_NHASH_SIZE 32 // todo: changable
++#if AUFS_DEBLK_SIZE < NAME_MAX || PAGE_SIZE < AUFS_DEBLK_SIZE
++#error invalid size AUFS_DEBLK_SIZE
++#endif
++
++typedef char aufs_deblk_t[AUFS_DEBLK_SIZE];
++
++struct aufs_nhash {
++ struct hlist_head heads[AUFS_NHASH_SIZE];
++};
++
++struct aufs_destr {
++ unsigned char len;
++ char name[0];
++} __attribute__ ((packed));
++
++struct aufs_dehstr {
++ struct hlist_node hash;
++ struct aufs_destr *str;
++};
++
++struct aufs_de {
++ ino_t de_ino;
++ unsigned char de_type;
++ //caution: packed
++ struct aufs_destr de_str;
++} __attribute__ ((packed));
++
++struct aufs_wh {
++ struct hlist_node wh_hash;
++ aufs_bindex_t wh_bindex;
++ struct aufs_destr wh_str;
++} __attribute__ ((packed));
++
++union aufs_deblk_p {
++ unsigned char *p;
++ aufs_deblk_t *deblk;
++ struct aufs_de *de;
++};
++
++struct aufs_vdir {
++ aufs_deblk_t **vd_deblk;
++ int vd_nblk;
++ struct {
++ int i;
++ union aufs_deblk_p p;
++ } vd_last;
++
++ unsigned long vd_version;
++ unsigned long vd_jiffy;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* dir.c */
++extern struct file_operations aufs_dir_fop;
++int au_test_empty_lower(struct dentry *dentry);
++int test_empty(struct dentry *dentry, struct aufs_nhash *whlist);
++void au_add_nlink(struct inode *dir, struct inode *h_dir);
++void au_sub_nlink(struct inode *dir, struct inode *h_dir);
++
++/* vdir.c */
++struct aufs_nhash *nhash_new(gfp_t gfp);
++void nhash_del(struct aufs_nhash *nhash);
++void nhash_init(struct aufs_nhash *nhash);
++void nhash_move(struct aufs_nhash *dst, struct aufs_nhash *src);
++void nhash_fin(struct aufs_nhash *nhash);
++int is_longer_wh(struct aufs_nhash *whlist, aufs_bindex_t btgt, int limit);
++int test_known_wh(struct aufs_nhash *whlist, char *name, int namelen);
++int append_wh(struct aufs_nhash *whlist, char *name, int namelen,
++ aufs_bindex_t bindex);
++void free_vdir(struct aufs_vdir *vdir);
++int au_init_vdir(struct file *file);
++int au_fill_de(struct file *file, void *dirent, filldir_t filldir);
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++unsigned int au_name_hash(const unsigned char *name, unsigned int len)
++{
++ return (full_name_hash(name, len) % AUFS_NHASH_SIZE);
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DIR_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/export.c linux-2.6.22.1/fs/aufs/export.c
+--- linux-2.6.22.1.oorig/fs/aufs/export.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/export.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,585 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: export.c,v 1.7 2007/05/14 03:38:24 sfjro Exp $ */
++
++#include "aufs.h"
++
++extern struct export_operations export_op_default;
++#define CALL(ops, func) (((ops)->func) ? ((ops)->func) : export_op_default.func)
++#define is_anon(d) ((d)->d_flags & DCACHE_DISCONNECTED)
++
++union conv {
++#if BITS_PER_LONG == 32
++ __u32 a[1];
++#else
++ __u32 a[2];
++#endif
++ ino_t ino;
++};
++
++static ino_t decode_ino(__u32 *a)
++{
++ union conv u;
++ u.a[0] = a[0];
++#if BITS_PER_LONG == 64
++ u.a[1] = a[1];
++#endif
++ return u.ino;
++}
++
++static void encode_ino(__u32 *a, ino_t ino)
++{
++ union conv u;
++ u.ino = ino;
++ a[0] = u.a[0];
++#if BITS_PER_LONG == 64
++ a[1] = u.a[1];
++#endif
++}
++
++static void decode_br_id_sigen(__u32 a, aufs_bindex_t *br_id,
++ aufs_bindex_t *sigen)
++{
++ BUILD_BUG_ON((sizeof(*br_id) + sizeof(*sigen)) > sizeof(a));
++ *br_id = a >> 16;
++ DEBUG_ON(*br_id < 0);
++ *sigen = a;
++ DEBUG_ON(*sigen < 0);
++}
++
++static __u32 encode_br_id_sigen(aufs_bindex_t br_id, aufs_bindex_t sigen)
++{
++ DEBUG_ON(br_id < 0 || sigen < 0);
++ return (br_id << 16) | sigen;
++}
++
++/* NFS file handle */
++enum {
++ /* support 64bit inode number */
++ /* but untested */
++ Fh_br_id_sigen,
++ Fh_ino1,
++#if BITS_PER_LONG == 64
++ Fh_ino2,
++#endif
++ Fh_dir_ino1,
++#if BITS_PER_LONG == 64
++ Fh_dir_ino2,
++#endif
++ Fh_h_ino1,
++#if BITS_PER_LONG == 64
++ Fh_h_ino2,
++#endif
++ Fh_h_igen,
++ Fh_h_type,
++ Fh_tail,
++
++ Fh_ino = Fh_ino1,
++ Fh_dir_ino = Fh_dir_ino1,
++ Fh_h_ino = Fh_h_ino1,
++};
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry *decode_by_ino(struct super_block *sb, ino_t ino,
++ ino_t dir_ino)
++{
++ struct dentry *dentry;
++ struct inode *inode;
++
++ LKTRTrace("i%lu, diri%lu\n", ino, dir_ino);
++
++ dentry = NULL;
++ inode = ilookup(sb, ino);
++ if (unlikely(!inode))
++ goto out;
++
++ dentry = ERR_PTR(-ESTALE);
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ dentry = NULL;
++ if (!S_ISDIR(inode->i_mode)) {
++ struct dentry *d;
++ spin_lock(&dcache_lock);
++ list_for_each_entry(d, &inode->i_dentry, d_alias)
++ if (!is_anon(d)
++ && d->d_parent->d_inode->i_ino == dir_ino) {
++ dentry = dget_locked(d);
++ break;
++ }
++ spin_unlock(&dcache_lock);
++ } else {
++ dentry = d_find_alias(inode);
++ if (dentry
++ && !is_anon(dentry)
++ && dentry->d_parent->d_inode->i_ino == dir_ino)
++ goto out_iput; /* success */
++
++ dput(dentry);
++ dentry = NULL;
++ }
++
++ out_iput:
++ iput(inode);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct find_name_by_ino {
++ int called, found;
++ ino_t ino;
++ char *name;
++ int namelen;
++};
++
++static int
++find_name_by_ino(void *arg, const char *name, int namelen, loff_t offset,
++ filldir_ino_t ino, unsigned int d_type)
++{
++ struct find_name_by_ino *a = arg;
++
++ a->called++;
++ if (a->ino != ino)
++ return 0;
++
++ memcpy(a->name, name, namelen);
++ a->namelen = namelen;
++ a->found = 1;
++ return 1;
++}
++
++static struct dentry *decode_by_dir_ino(struct super_block *sb, ino_t ino,
++ ino_t dir_ino)
++{
++ struct dentry *dentry, *parent;
++ struct inode *dir;
++ struct find_name_by_ino arg;
++ struct file *file;
++ int err;
++
++ LKTRTrace("i%lu, diri%lu\n", ino, dir_ino);
++
++ dentry = NULL;
++ dir = ilookup(sb, dir_ino);
++ if (unlikely(!dir))
++ goto out;
++
++ dentry = ERR_PTR(-ESTALE);
++ if (unlikely(is_bad_inode(dir)))
++ goto out_iput;
++
++ dentry = NULL;
++ parent = d_find_alias(dir);
++ if (parent) {
++ if (unlikely(is_anon(parent))) {
++ dput(parent);
++ goto out_iput;
++ }
++ } else
++ goto out_iput;
++
++ file = dentry_open(parent, NULL, au_dir_roflags);
++ dentry = (void*)file;
++ if (IS_ERR(file))
++ goto out_iput;
++
++ dentry = ERR_PTR(-ENOMEM);
++ arg.name = __getname();
++ if (unlikely(!arg.name))
++ goto out_fput;
++ arg.ino = ino;
++ arg.found = 0;
++
++ do {
++ arg.called = 0;
++ //smp_mb();
++ err = vfsub_readdir(file, find_name_by_ino, &arg, /*dlgt*/0);
++ } while (!err && !arg.found && arg.called);
++ dentry = ERR_PTR(err);
++ if (arg.found) {
++ /* do not call lkup_one(), nor dlgt */
++ i_lock(dir);
++ dentry = lookup_one_len(arg.name, parent, arg.namelen);
++ i_unlock(dir);
++ TraceErrPtr(dentry);
++ }
++
++ //out_putname:
++ __putname(arg.name);
++ out_fput:
++ fput(file);
++ out_iput:
++ iput(dir);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct append_name {
++ int found, called, len;
++ char *h_path;
++ ino_t h_ino;
++};
++
++static int append_name(void *arg, const char *name, int len, loff_t pos,
++ filldir_ino_t ino, unsigned int d_type)
++{
++ struct append_name *a = arg;
++ char *p;
++
++ a->called++;
++ if (ino != a->h_ino)
++ return 0;
++
++ DEBUG_ON(len == 1 && *name == '.');
++ DEBUG_ON(len == 2 && name[0] == '.' && name[1] == '.');
++ a->len = strlen(a->h_path);
++ memmove(a->h_path - a->len - 1, a->h_path, a->len);
++ a->h_path -= a->len + 1;
++ p = a->h_path + a->len;
++ *p++ = '/';
++ memcpy(p, name, a->len);
++ a->len += 1 + len;
++ a->found++;
++ return 1;
++}
++
++static int h_acceptable(void *expv, struct dentry *dentry)
++{
++ return 1;
++}
++
++static struct dentry*
++decode_by_path(struct super_block *sb, aufs_bindex_t bindex, __u32 *fh,
++ int fh_len, void *context)
++{
++ struct dentry *dentry, *h_parent, *root, *h_root;
++ struct super_block *h_sb;
++ char *path, *p;
++ struct vfsmount *h_mnt;
++ struct append_name arg;
++ int len, err;
++ struct file *h_file;
++ struct nameidata nd;
++ struct aufs_branch *br;
++
++ LKTRTrace("b%d\n", bindex);
++ SiMustAnyLock(sb);
++
++ br = stobr(sb, bindex);
++ //br_get(br);
++ h_mnt = br->br_mnt;
++ h_sb = h_mnt->mnt_sb;
++ LKTRTrace("%s, h_decode_fh\n", au_sbtype(h_sb));
++ h_parent = CALL(h_sb->s_export_op, decode_fh)
++ (h_sb, fh + Fh_tail, fh_len - Fh_tail, fh[Fh_h_type],
++ h_acceptable, /*context*/NULL);
++ dentry = h_parent;
++ if (unlikely(!h_parent || IS_ERR(h_parent))) {
++ Warn1("%s decode_fh failed\n", au_sbtype(h_sb));
++ goto out;
++ }
++ dentry = NULL;
++ if (unlikely(is_anon(h_parent))) {
++ Warn1("%s decode_fh returned a disconnected dentry\n",
++ au_sbtype(h_sb));
++ dput(h_parent);
++ goto out;
++ }
++
++ dentry = ERR_PTR(-ENOMEM);
++ path = __getname();
++ if (unlikely(!path)) {
++ dput(h_parent);
++ goto out;
++ }
++
++ root = sb->s_root;
++ di_read_lock_parent(root, !AUFS_I_RLOCK);
++ h_root = au_h_dptr_i(root, bindex);
++ di_read_unlock(root, !AUFS_I_RLOCK);
++ arg.h_path = d_path(h_root, h_mnt, path, PATH_MAX);
++ dentry = (void*)arg.h_path;
++ if (unlikely(!arg.h_path || IS_ERR(arg.h_path)))
++ goto out_putname;
++ len = strlen(arg.h_path);
++ arg.h_path = d_path(h_parent, h_mnt, path, PATH_MAX);
++ dentry = (void*)arg.h_path;
++ if (unlikely(!arg.h_path || IS_ERR(arg.h_path)))
++ goto out_putname;
++ LKTRTrace("%s\n", arg.h_path);
++ if (len != 1)
++ arg.h_path += len;
++ LKTRTrace("%s\n", arg.h_path);
++
++ /* cf. fs/exportfs/expfs.c */
++ h_file = dentry_open(h_parent, NULL, au_dir_roflags);
++ dentry = (void*)h_file;
++ if (IS_ERR(h_file))
++ goto out_putname;
++
++ arg.found = 0;
++ arg.h_ino = decode_ino(fh + Fh_h_ino);
++ do {
++ arg.called = 0;
++ err = vfsub_readdir(h_file, append_name, &arg, /*dlgt*/0);
++ } while (!err && !arg.found && arg.called);
++ LKTRTrace("%s, %d\n", arg.h_path, arg.len);
++
++ p = d_path(root, stosi(sb)->si_mnt, path, PATH_MAX - arg.len - 2);
++ dentry = (void*)p;
++ if (unlikely(!p || IS_ERR(p)))
++ goto out_fput;
++ p[strlen(p)] = '/';
++ LKTRTrace("%s\n", p);
++
++ err = path_lookup(p, LOOKUP_FOLLOW, &nd);
++ dentry = ERR_PTR(err);
++ if (!err) {
++ dentry = dget(nd.dentry);
++ if (unlikely(is_anon(dentry))) {
++ dput(dentry);
++ dentry = ERR_PTR(-ESTALE);
++ }
++ path_release(&nd);
++ }
++
++ out_fput:
++ fput(h_file);
++ out_putname:
++ __putname(path);
++ out:
++ //br_put(br);
++ TraceErrPtr(dentry);
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry*
++aufs_decode_fh(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context)
++{
++ struct dentry *dentry;
++ ino_t ino, dir_ino;
++ aufs_bindex_t bindex, br_id, sigen_v;
++ struct inode *inode, *h_inode;
++
++ //au_debug_on();
++ LKTRTrace("%d, fh{i%u, br_id_sigen 0x%x, hi%u}\n",
++ fh_type, fh[Fh_ino], fh[Fh_br_id_sigen], fh[Fh_h_ino]);
++ DEBUG_ON(fh_len < Fh_tail);
++
++ si_read_lock(sb);
++ lockdep_off();
++
++ /* branch id may be wrapped around */
++ dentry = ERR_PTR(-ESTALE);
++ decode_br_id_sigen(fh[Fh_br_id_sigen], &br_id, &sigen_v);
++ bindex = find_brindex(sb, br_id);
++ if (unlikely(bindex < 0 || au_sigen(sb) < sigen_v))
++ goto out;
++
++ /* is this inode still cached? */
++ ino = decode_ino(fh + Fh_ino);
++ dir_ino = decode_ino(fh + Fh_dir_ino);
++ dentry = decode_by_ino(sb, ino, dir_ino);
++ if (IS_ERR(dentry))
++ goto out;
++ if (dentry)
++ goto accept;
++
++ /* is the parent dir cached? */
++ dentry = decode_by_dir_ino(sb, ino, dir_ino);
++ if (IS_ERR(dentry))
++ goto out;
++ if (dentry)
++ goto accept;
++
++ /* lookup path */
++ dentry = decode_by_path(sb, bindex, fh, fh_len, context);
++ if (IS_ERR(dentry))
++ goto out;
++ if (unlikely(!dentry))
++ goto out_stale;
++ if (unlikely(dentry->d_inode->i_ino != ino))
++ goto out_dput;
++
++ accept:
++ inode = dentry->d_inode;
++ h_inode = NULL;
++ ii_read_lock_child(inode);
++ if (ibstart(inode) <= bindex && bindex <= ibend(inode))
++ h_inode = au_h_iptr_i(inode, bindex);
++ ii_read_unlock(inode);
++ if (h_inode
++ && h_inode->i_generation == fh[Fh_h_igen]
++ && acceptable(context, dentry))
++ goto out; /* success */
++ out_dput:
++ dput(dentry);
++ out_stale:
++ dentry = ERR_PTR(-ESTALE);
++ out:
++ lockdep_on();
++ si_read_unlock(sb);
++ TraceErrPtr(dentry);
++ //au_debug_off();
++ return dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
++ int connectable)
++{
++ int err;
++ struct super_block *sb, *h_sb;
++ struct inode *inode, *h_inode, *dir;
++ aufs_bindex_t bindex;
++ union conv u;
++ struct dentry *parent, *h_parent;
++
++ //au_debug_on();
++ BUILD_BUG_ON(sizeof(u.ino) != sizeof(u.a));
++ LKTRTrace("%.*s, max %d, conn %d\n",
++ DLNPair(dentry), *max_len, connectable);
++ DEBUG_ON(is_anon(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode);
++ parent = dentry->d_parent;
++ DEBUG_ON(is_anon(parent));
++
++ err = -ENOSPC;
++ if (unlikely(*max_len <= Fh_tail)) {
++ Warn1("NFSv2 client (max_len %d)?\n", *max_len);
++ goto out;
++ }
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++#ifdef CONFIG_AUFS_DEBUG
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ Warn1("NFS-exporting requires xino\n");
++#if 0
++ if (unlikely(au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ Warn1("udba=inotify is not recommended when exporting\n");
++#endif
++#endif
++
++ err = -EPERM;
++ bindex = ibstart(inode);
++ h_sb = sbr_sb(sb, bindex);
++ if (unlikely(!h_sb->s_export_op)) {
++ Err1("%s branch is not exportable\n", au_sbtype(h_sb));
++ goto out_unlock;
++ }
++
++#if 0 //def CONFIG_AUFS_ROBR
++ if (unlikely(SB_AUFS(h_sb))) {
++ Err1("aufs branch is not supported\n");
++ goto out_unlock;
++ }
++#endif
++
++ /* doesn't support pseudo-link */
++ if (unlikely(bindex < dbstart(dentry)
++ || dbend(dentry) < bindex
++ || !au_h_dptr_i(dentry, bindex))) {
++ Err("%.*s/%.*s, b%d, pseudo-link?\n",
++ DLNPair(dentry->d_parent), DLNPair(dentry), bindex);
++ goto out_unlock;
++ }
++
++ fh[Fh_br_id_sigen] = encode_br_id_sigen(sbr_id(sb, bindex),
++ au_sigen(sb));
++ encode_ino(fh + Fh_ino, inode->i_ino);
++ dir = parent->d_inode;
++ encode_ino(fh + Fh_dir_ino, dir->i_ino);
++ h_inode = au_h_iptr(inode);
++ encode_ino(fh + Fh_h_ino, h_inode->i_ino);
++ fh[Fh_h_igen] = h_inode->i_generation;
++
++ /* it should be set at exporting time */
++ if (unlikely(!h_sb->s_export_op->find_exported_dentry)) {
++ Warn("set default find_exported_dentry for %s\n",
++ au_sbtype(h_sb));
++ h_sb->s_export_op->find_exported_dentry = find_exported_dentry;
++ }
++
++ *max_len -= Fh_tail;
++ //LKTRTrace("Fh_tail %d, max_len %d\n", Fh_tail, *max_len);
++ h_parent = au_h_dptr_i(parent, bindex);
++ DEBUG_ON(is_anon(h_parent));
++ err = fh[Fh_h_type] = CALL(h_sb->s_export_op, encode_fh)
++ (h_parent, fh + Fh_tail, max_len, connectable);
++ *max_len += Fh_tail;
++ if (err != 255)
++ err = 2; //??
++ else
++ Warn1("%s encode_fh failed\n", au_sbtype(h_sb));
++
++ out_unlock:
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ out:
++ TraceErr(err);
++ //au_debug_off();
++ if (unlikely(err < 0))
++ err = 255;
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0
++struct export_operations {
++ struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context);
++ int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
++ int connectable);
++
++ /* the following are only called from the filesystem itself */
++ int (*get_name)(struct dentry *parent, char *name,
++ struct dentry *child);
++ struct dentry * (*get_parent)(struct dentry *child);
++ struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
++
++ /* This is set by the exporting module to a standard helper */
++ struct dentry * (*find_exported_dentry)(
++ struct super_block *sb, void *obj, void *parent,
++ int (*acceptable)(void *context, struct dentry *de),
++ void *context);
++};
++#endif
++
++struct export_operations aufs_export_op = {
++ .decode_fh = aufs_decode_fh,
++ .encode_fh = aufs_encode_fh
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/f_op.c linux-2.6.22.1/fs/aufs/f_op.c
+--- linux-2.6.22.1.oorig/fs/aufs/f_op.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/f_op.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,684 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: f_op.c,v 1.27 2007/05/14 03:38:24 sfjro Exp $ */
++
++#include <linux/fsnotify.h>
++#include <linux/pagemap.h>
++#include <linux/poll.h>
++#include <linux/security.h>
++#include <linux/version.h>
++#include "aufs.h"
++
++/* common function to regular file and dir */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#define FlushArgs hidden_file, id
++int aufs_flush(struct file *file, fl_owner_t id)
++#else
++#define FlushArgs hidden_file
++int aufs_flush(struct file *file)
++#endif
++{
++ int err;
++ struct dentry *dentry;
++ aufs_bindex_t bindex, bend;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ // aufs_read_lock_file()
++ si_read_lock(dentry->d_sb);
++ fi_read_lock(file);
++ di_read_lock_child(dentry, !AUFS_I_RLOCK);
++
++ err = 0;
++ bend = fbend(file);
++ for (bindex = fbstart(file); !err && bindex <= bend; bindex++) {
++ struct file *hidden_file;
++ hidden_file = au_h_fptr_i(file, bindex);
++ if (hidden_file && hidden_file->f_op
++ && hidden_file->f_op->flush)
++ err = hidden_file->f_op->flush(FlushArgs);
++ }
++
++ di_read_unlock(dentry, !AUFS_I_RLOCK);
++ fi_read_unlock(file);
++ si_read_unlock(dentry->d_sb);
++ TraceErr(err);
++ return err;
++}
++#undef FlushArgs
++
++/* ---------------------------------------------------------------------- */
++
++static int do_open_nondir(struct file *file, int flags)
++{
++ int err;
++ aufs_bindex_t bindex;
++ struct super_block *sb;
++ struct file *hidden_file;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_finfo *finfo;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, flags 0%o\n", DLNPair(dentry), flags);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || S_ISDIR(inode->i_mode));
++
++ err = 0;
++ finfo = ftofi(file);
++ finfo->fi_h_vm_ops = NULL;
++ sb = dentry->d_sb;
++ bindex = dbstart(dentry);
++ DEBUG_ON(!au_h_dptr(dentry)->d_inode);
++ /* O_TRUNC is processed already */
++ BUG_ON(test_ro(sb, bindex, inode) && (flags & O_TRUNC));
++
++ hidden_file = hidden_open(dentry, bindex, flags);
++ //if (LktrCond) {fput(hidden_file); br_put(stobr(dentry->d_sb, bindex));
++ //hidden_file = ERR_PTR(-1);}
++ if (!IS_ERR(hidden_file)) {
++ set_fbstart(file, bindex);
++ set_fbend(file, bindex);
++ set_h_fptr(file, bindex, hidden_file);
++ return 0; /* success */
++ }
++ err = PTR_ERR(hidden_file);
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_open_nondir(struct inode *inode, struct file *file)
++{
++ return au_do_open(inode, file, do_open_nondir);
++}
++
++static int aufs_release_nondir(struct inode *inode, struct file *file)
++{
++ struct super_block *sb = file->f_dentry->d_sb;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(file->f_dentry));
++
++ si_read_lock(sb);
++ au_fin_finfo(file);
++ si_read_unlock(sb);
++ return 0;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t aufs_read(struct file *file, char __user *buf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ struct dentry *dentry;
++ struct file *hidden_file;
++ struct super_block *sb;
++ struct inode *h_inode;
++ int dlgt;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(dentry), (unsigned long)count, *ppos);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //if (LktrCond) {fi_read_unlock(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ /* support LSM and notify */
++ dlgt = need_dlgt(sb);
++ hidden_file = au_h_fptr(file);
++ h_inode = hidden_file->f_dentry->d_inode;
++ if (!au_flag_test(sb, AuFlag_UDBA_INOTIFY))
++ err = vfsub_read_u(hidden_file, buf, count, ppos, dlgt);
++ else {
++ struct inode *dir = dentry->d_parent->d_inode,
++ *h_dir = hidden_file->f_dentry->d_parent->d_inode;
++ aufs_bindex_t bstart = fbstart(file);
++ hdir_lock(h_dir, dir, bstart);
++ err = vfsub_read_u(hidden_file, buf, count, ppos, dlgt);
++ hdir_unlock(h_dir, dir, bstart);
++ }
++ memcpy(&file->f_ra, &hidden_file->f_ra, sizeof(file->f_ra)); //??
++ dentry->d_inode->i_atime = hidden_file->f_dentry->d_inode->i_atime;
++
++ fi_read_unlock(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++static ssize_t aufs_write(struct file *file, const char __user *__buf,
++ size_t count, loff_t *ppos)
++{
++ ssize_t err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct super_block *sb;
++ struct file *hidden_file;
++ char __user *buf = (char __user*)__buf;
++ struct inode *h_inode;
++ int dlgt;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(dentry), (unsigned long)count, *ppos);
++
++ inode = dentry->d_inode;
++ i_lock(inode);
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/1,
++ /*locked*/1);
++ //if (LktrCond) {fi_write_unlock(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++ err = au_ready_to_write(file, -1);
++ //if (LktrCond) err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++
++ /* support LSM and notify */
++ dlgt = need_dlgt(sb);
++ hidden_file = au_h_fptr(file);
++ h_inode = hidden_file->f_dentry->d_inode;
++ if (!au_flag_test(sb, AuFlag_UDBA_INOTIFY))
++ err = vfsub_write_u(hidden_file, buf, count, ppos, dlgt);
++ else {
++ struct inode *dir = dentry->d_parent->d_inode,
++ *h_dir = hidden_file->f_dentry->d_parent->d_inode;
++ aufs_bindex_t bstart = fbstart(file);
++ hdir_lock(h_dir, dir, bstart);
++ err = vfsub_write_u(hidden_file, buf, count, ppos, dlgt);
++ hdir_unlock(h_dir, dir, bstart);
++ }
++ ii_write_lock_child(inode);
++ au_cpup_attr_timesizes(inode);
++ ii_write_unlock(inode);
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ i_unlock(inode);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 //def CONFIG_AUFS_ROBR
++struct lvma {
++ struct list_head list;
++ struct vm_area_struct *vma;
++};
++
++static struct file *safe_file(struct vm_area_struct *vma)
++{
++ struct file *file = vma->vm_file;
++ struct super_block *sb = file->f_dentry->d_sb;
++ struct lvma *lvma, *entry;
++ struct aufs_sbinfo *sbinfo;
++ int found, warn;
++
++ TraceEnter();
++ DEBUG_ON(!SB_AUFS(sb));
++
++ warn = 0;
++ found = 0;
++ sbinfo = stosi(sb);
++ spin_lock(&sbinfo->si_lvma_lock);
++ list_for_each_entry(entry, &sbinfo->si_lvma, list) {
++ found = (entry->vma == vma);
++ if (unlikely(found))
++ break;
++ }
++ if (!found) {
++ lvma = kmalloc(sizeof(*lvma), GFP_ATOMIC);
++ if (lvma) {
++ lvma->vma = vma;
++ list_add(&lvma->list, &sbinfo->si_lvma);
++ } else {
++ warn = 1;
++ file = NULL;
++ }
++ } else
++ file = NULL;
++ spin_unlock(&sbinfo->si_lvma_lock);
++
++ if (unlikely(warn))
++ Warn1("no memory for lvma\n");
++ return file;
++}
++
++static void reset_file(struct vm_area_struct *vma, struct file *file)
++{
++ struct super_block *sb = file->f_dentry->d_sb;
++ struct lvma *entry, *found;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ DEBUG_ON(!SB_AUFS(sb));
++
++ vma->vm_file = file;
++
++ found = NULL;
++ sbinfo = stosi(sb);
++ spin_lock(&sbinfo->si_lvma_lock);
++ list_for_each_entry(entry, &sbinfo->si_lvma, list)
++ if (entry->vma == vma){
++ found = entry;
++ break;
++ }
++ DEBUG_ON(!found);
++ list_del(&found->list);
++ spin_unlock(&sbinfo->si_lvma_lock);
++ kfree(found);
++}
++
++#else
++
++static struct file *safe_file(struct vm_area_struct *vma)
++{
++ struct file *file;
++
++ file = vma->vm_file;
++ if (file->private_data && au_is_aufs(file->f_dentry->d_sb))
++ return file;
++ return NULL;
++}
++
++static void reset_file(struct vm_area_struct *vma, struct file *file)
++{
++ vma->vm_file = file;
++ smp_mb();
++}
++#endif /* CONFIG_AUFS_ROBR */
++
++static struct page *aufs_nopage(struct vm_area_struct *vma, unsigned long addr,
++ int *type)
++{
++ struct page *page;
++ struct dentry *dentry;
++ struct file *file, *hidden_file;
++ struct inode *inode;
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ struct aufs_finfo *finfo;
++
++ TraceEnter();
++ DEBUG_ON(!vma || !vma->vm_file);
++ wait_event(wq, (file = safe_file(vma)));
++ DEBUG_ON(!au_is_aufs(file->f_dentry->d_sb));
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, addr %lx\n", DLNPair(dentry), addr);
++ inode = dentry->d_inode;
++ DEBUG_ON(!S_ISREG(inode->i_mode));
++
++ // do not revalidate, nor lock
++ finfo = ftofi(file);
++ hidden_file = finfo->fi_hfile[0 + finfo->fi_bstart].hf_file;
++ DEBUG_ON(!hidden_file || !au_is_mmapped(file));
++ vma->vm_file = hidden_file;
++ //smp_mb();
++ page = finfo->fi_h_vm_ops->nopage(vma, addr, type);
++ reset_file(vma, file);
++#if 0 //def CONFIG_SMP
++ //wake_up_nr(&wq, online_cpu - 1);
++ wake_up_all(&wq);
++#else
++ wake_up(&wq);
++#endif
++ if (!IS_ERR(page)) {
++ //page->mapping = file->f_mapping;
++ //get_page(page);
++ //file->f_mapping = hidden_file->f_mapping;
++ //touch_atime(NULL, dentry);
++ //inode->i_atime = hidden_file->f_dentry->d_inode->i_atime;
++ }
++ TraceErrPtr(page);
++ return page;
++}
++
++static int aufs_populate(struct vm_area_struct *vma, unsigned long addr,
++ unsigned long len, pgprot_t prot, unsigned long pgoff,
++ int nonblock)
++{
++ Err("please report me this application\n");
++ BUG();
++ return ftofi(vma->vm_file)->fi_h_vm_ops->populate
++ (vma, addr, len, prot, pgoff, nonblock);
++}
++
++static struct vm_operations_struct aufs_vm_ops = {
++ //.open = aufs_vmaopen,
++ //.close = aufs_vmaclose,
++ .nopage = aufs_nopage,
++ .populate = aufs_populate,
++ //page_mkwrite(struct vm_area_struct *vma, struct page *page)
++};
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_mmap(struct file *file, struct vm_area_struct *vma)
++{
++ int err, wlock, mmapped;
++ struct dentry *dentry;
++ struct super_block *sb;
++ struct file *h_file;
++ struct vm_operations_struct *vm_ops;
++ unsigned long flags;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, %lx, len %lu\n",
++ DLNPair(dentry), vma->vm_start, vma->vm_end - vma->vm_start);
++ DEBUG_ON(!S_ISREG(dentry->d_inode->i_mode));
++ DEBUG_ON(down_write_trylock(&vma->vm_mm->mmap_sem));
++
++ mmapped = au_is_mmapped(file);
++ wlock = 0;
++ if (file->f_mode & FMODE_WRITE) {
++ flags = VM_SHARED | VM_WRITE;
++ wlock = ((flags & vma->vm_flags) == flags);
++ }
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir,
++ wlock | !mmapped, /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ if (wlock) {
++ err = au_ready_to_write(file, -1);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ }
++
++ h_file = au_h_fptr(file);
++ vm_ops = ftofi(file)->fi_h_vm_ops;
++ if (unlikely(!mmapped)) {
++ // nfs uses some locks
++ lockdep_off();
++ err = h_file->f_op->mmap(h_file, vma);
++ lockdep_on();
++ if (unlikely(err))
++ goto out_unlock;
++ vm_ops = vma->vm_ops;
++ DEBUG_ON(!vm_ops);
++ err = do_munmap(current->mm, vma->vm_start,
++ vma->vm_end - vma->vm_start);
++ if (unlikely(err)) {
++ IOErr("failed internal unmapping %.*s, %d\n",
++ DLNPair(h_file->f_dentry), err);
++ err = -EIO;
++ goto out_unlock;
++ }
++ }
++ DEBUG_ON(!vm_ops);
++
++ err = generic_file_mmap(file, vma);
++ if (!err) {
++ file_accessed(h_file);
++ dentry->d_inode->i_atime = h_file->f_dentry->d_inode->i_atime;
++ vma->vm_ops = &aufs_vm_ops;
++ if (unlikely(!mmapped))
++ ftofi(file)->fi_h_vm_ops = vm_ops;
++ }
++
++ out_unlock:
++ if (!wlock && mmapped)
++ fi_read_unlock(file);
++ else
++ fi_write_unlock(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++// todo: try do_sendfile() in fs/read_write.c
++static ssize_t aufs_sendfile(struct file *file, loff_t *ppos,
++ size_t count, read_actor_t actor, void *target)
++{
++ ssize_t err;
++ struct file *h_file;
++ const char c = current->comm[4];
++ /* true if a kernel thread named 'loop[0-9].*' accesses a file */
++ const int loopback = (current->mm == NULL
++ && '0' <= c && c <= '9'
++ && strncmp(current->comm, "loop", 4) == 0);
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld, cnt %lu, loopback %d\n",
++ DLNPair(dentry), *ppos, (unsigned long)count, loopback);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ if (unlikely(err))
++ goto out;
++
++ err = -EINVAL;
++ h_file = au_h_fptr(file);
++ if (h_file->f_op && h_file->f_op->sendfile) {
++ if (/* unlikely */(loopback)) {
++ file->f_mapping = h_file->f_mapping;
++ smp_mb(); //??
++ }
++ // nfs uses some locks
++ lockdep_off();
++ err = h_file->f_op->sendfile
++ (h_file, ppos, count, actor, target);
++ lockdep_on();
++ dentry->d_inode->i_atime = h_file->f_dentry->d_inode->i_atime;
++ }
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* copied from linux/fs/select.h, must match */
++#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
++
++static unsigned int aufs_poll(struct file *file, poll_table *wait)
++{
++ unsigned int mask;
++ struct file *hidden_file;
++ int err;
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, wait %p\n", DLNPair(dentry), wait);
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode));
++
++ /* We should pretend an error happend. */
++ mask = POLLERR /* | POLLIN | POLLOUT */;
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ /* it is not an error of hidden_file has no operation */
++ mask = DEFAULT_POLLMASK;
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->poll)
++ mask = hidden_file->f_op->poll(hidden_file, wait);
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr((int)mask);
++ return mask;
++}
++
++static int aufs_fsync_nondir(struct file *file, struct dentry *dentry,
++ int datasync)
++{
++ int err, my_lock;
++ struct inode *inode;
++ struct file *hidden_file;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), datasync);
++ inode = dentry->d_inode;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++ IMustLock(inode);
++ my_lock = 0;
++#else
++ /* before 2.6.17,
++ * msync(2) calls me without locking i_sem/i_mutex, but fsync(2).
++ */
++ my_lock = !i_trylock(inode);
++#endif
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = 0; //-EBADF; // posix?
++ if (unlikely(!(file->f_mode & FMODE_WRITE)))
++ goto out;
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/1,
++ /*locked*/1);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ err = au_ready_to_write(file, -1);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++
++ err = -EINVAL;
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->fsync) {
++ // todo: apparmor thread?
++ //file->f_mapping->host->i_mutex
++ ii_write_lock_child(inode);
++ hi_lock_child(hidden_file->f_dentry->d_inode);
++ err = hidden_file->f_op->fsync
++ (hidden_file, hidden_file->f_dentry, datasync);
++ //err = -1;
++ au_cpup_attr_timesizes(inode);
++ i_unlock(hidden_file->f_dentry->d_inode);
++ ii_write_unlock(inode);
++ }
++
++ out_unlock:
++ fi_write_unlock(file);
++ out:
++ if (unlikely(my_lock))
++ i_unlock(inode);
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_fasync(int fd, struct file *file, int flag)
++{
++ int err;
++ struct file *hidden_file;
++ struct dentry *dentry;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), flag);
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ err = au_reval_and_lock_finfo(file, au_reopen_nondir, /*wlock*/0,
++ /*locked*/0);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++
++ hidden_file = au_h_fptr(file);
++ if (hidden_file->f_op && hidden_file->f_op->fasync)
++ err = hidden_file->f_op->fasync(fd, hidden_file, flag);
++ fi_read_unlock(file);
++
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if 0 // comment
++struct file_operations {
++ struct module *owner;
++ loff_t (*llseek) (struct file *, loff_t, int);
++ ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
++ ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
++ ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
++ ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
++ int (*readdir) (struct file *, void *, filldir_t);
++ unsigned int (*poll) (struct file *, struct poll_table_struct *);
++ int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
++ long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
++ long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
++ int (*mmap) (struct file *, struct vm_area_struct *);
++ int (*open) (struct inode *, struct file *);
++ int (*flush) (struct file *);
++ int (*release) (struct inode *, struct file *);
++ int (*fsync) (struct file *, struct dentry *, int datasync);
++ int (*aio_fsync) (struct kiocb *, int datasync);
++ int (*fasync) (int, struct file *, int);
++ int (*lock) (struct file *, int, struct file_lock *);
++ ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
++ ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
++ ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
++ unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
++ int (*check_flags)(int);
++ int (*dir_notify)(struct file *file, unsigned long arg);
++ int (*flock) (struct file *, int, struct file_lock *);
++};
++#endif
++
++struct file_operations aufs_file_fop = {
++ .read = aufs_read,
++ .write = aufs_write,
++ .poll = aufs_poll,
++ .mmap = aufs_mmap,
++ .open = aufs_open_nondir,
++ .flush = aufs_flush,
++ .release = aufs_release_nondir,
++ .fsync = aufs_fsync_nondir,
++ .fasync = aufs_fasync,
++ .sendfile = aufs_sendfile,
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/file.c linux-2.6.22.1/fs/aufs/file.c
+--- linux-2.6.22.1.oorig/fs/aufs/file.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/file.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,832 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: file.c,v 1.42 2007/05/14 03:39:09 sfjro Exp $ */
++
++//#include <linux/fsnotify.h>
++#include <linux/pagemap.h>
++//#include <linux/poll.h>
++//#include <linux/security.h>
++#include "aufs.h"
++
++/* drop flags for writing */
++unsigned int au_file_roflags(unsigned int flags)
++{
++ flags &= ~(O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_TRUNC);
++ flags |= O_RDONLY | O_NOATIME;
++ return flags;
++}
++
++/* common functions to regular file and dir */
++struct file *hidden_open(struct dentry *dentry, aufs_bindex_t bindex, int flags)
++{
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++ struct super_block *sb;
++ struct vfsmount *hidden_mnt;
++ struct file *hidden_file;
++ struct aufs_branch *br;
++ loff_t old_size;
++ int udba;
++
++ LKTRTrace("%.*s, b%d, flags 0%o\n", DLNPair(dentry), bindex, flags);
++ DEBUG_ON(!dentry);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ sb = dentry->d_sb;
++ udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++ if (unlikely(udba)) {
++ // test here?
++ }
++
++ br = stobr(sb, bindex);
++ br_get(br);
++ /* drop flags for writing */
++ if (test_ro(sb, bindex, dentry->d_inode))
++ flags = au_file_roflags(flags);
++ flags &= ~O_CREAT;
++ spin_lock(&hidden_inode->i_lock);
++ old_size = i_size_read(hidden_inode);
++ spin_unlock(&hidden_inode->i_lock);
++
++ //DbgSleep(3);
++
++ dget(hidden_dentry);
++ hidden_mnt = mntget(br->br_mnt);
++ hidden_file = dentry_open(hidden_dentry, hidden_mnt, flags);
++ //if (LktrCond) {fput(hidden_file); hidden_file = ERR_PTR(-1);}
++
++ if (!IS_ERR(hidden_file)) {
++#if 0 // remove this
++ if (/* old_size && */ (flags & O_TRUNC)) {
++ au_direval_dec(dentry);
++ if (!IS_ROOT(dentry))
++ au_direval_dec(dentry->d_parent);
++ }
++#endif
++ return hidden_file;
++ }
++
++ br_put(br);
++ TraceErrPtr(hidden_file);
++ return hidden_file;
++}
++
++static int do_coo(struct dentry *dentry, aufs_bindex_t bstart)
++{
++ int err;
++ struct dentry *parent, *h_parent, *h_dentry;
++ aufs_bindex_t bcpup;
++ struct inode *h_dir, *h_inode, *dir;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(IS_ROOT(dentry));
++ DiMustWriteLock(dentry);
++
++ parent = dentry->d_parent; // dget_parent()
++ di_write_lock_parent(parent);
++ bcpup = err = find_rw_parent_br(dentry, bstart);
++ //bcpup = err = find_rw_br(sb, bstart);
++ if (unlikely(err < 0)) {
++ err = 0; // stop copyup, it is not an error
++ goto out;
++ }
++ err = 0;
++
++ h_parent = au_h_dptr_i(parent, bcpup);
++ if (!h_parent) {
++ err = cpup_dirs(dentry, bcpup, NULL);
++ if (unlikely(err))
++ goto out;
++ h_parent = au_h_dptr_i(parent, bcpup);
++ }
++
++ h_dir = h_parent->d_inode;
++ h_dentry = au_h_dptr_i(dentry, bstart);
++ h_inode = h_dentry->d_inode;
++ dir = parent->d_inode;
++ hdir_lock(h_dir, dir, bcpup);
++ hi_lock_child(h_inode);
++ DEBUG_ON(au_h_dptr_i(dentry, bcpup));
++ err = sio_cpup_simple(dentry, bcpup, -1,
++ au_flags_cpup(CPUP_DTIME, parent));
++ TraceErr(err);
++ i_unlock(h_inode);
++ hdir_unlock(h_dir, dir, bcpup);
++
++ out:
++ di_write_unlock(parent);
++ TraceErr(err);
++ return err;
++}
++
++int au_do_open(struct inode *inode, struct file *file,
++ int (*open)(struct file *file, int flags))
++{
++ int err, coo;
++ struct dentry *dentry;
++ struct super_block *sb;
++ aufs_bindex_t bstart;
++ struct inode *h_dir, *dir;
++
++ dentry = file->f_dentry;
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++
++ sb = dentry->d_sb;
++ si_read_lock(sb);
++ coo = 0;
++#if 0
++ switch (au_flag_test_coo(sb)) {
++ case AuFlag_COO_LEAF:
++ coo = !S_ISDIR(inode->i_mode);
++ break;
++ case AuFlag_COO_ALL:
++ coo = 1;
++ break;
++ }
++#endif
++ err = au_init_finfo(file);
++ //if (LktrCond) {fi_write_unlock(file); fin_finfo(file); err = -1;}
++ if (unlikely(err))
++ goto out;
++
++ if (!coo) {
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ bstart = dbstart(dentry);
++ } else {
++ di_write_lock_child(dentry);
++ bstart = dbstart(dentry);
++ if (test_ro(sb, bstart, dentry->d_inode)) {
++ err = do_coo(dentry, bstart);
++ if (err) {
++ di_write_unlock(dentry);
++ goto out_finfo;
++ }
++ bstart = dbstart(dentry);
++ }
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ }
++
++ // todo: remove this extra locks
++ dir = dentry->d_parent->d_inode;
++ if (!IS_ROOT(dentry))
++ ii_read_lock_parent(dir);
++ h_dir = au_h_iptr_i(dir, bstart);
++ hdir_lock(h_dir, dir, bstart);
++ err = open(file, file->f_flags);
++ //if (LktrCond) err = -1;
++ hdir_unlock(h_dir, dir, bstart);
++ if (!IS_ROOT(dentry))
++ ii_read_unlock(dir);
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++
++ out_finfo:
++ fi_write_unlock(file);
++ if (unlikely(err))
++ au_fin_finfo(file);
++ //DbgFile(file);
++ out:
++ si_read_unlock(sb);
++ TraceErr(err);
++ return err;
++}
++
++int au_reopen_nondir(struct file *file)
++{
++ int err;
++ struct dentry *dentry;
++ aufs_bindex_t bstart, bindex, bend;
++ struct file *hidden_file, *h_file_tmp;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode)
++ || !au_h_dptr(dentry)->d_inode);
++ bstart = dbstart(dentry);
++
++ h_file_tmp = NULL;
++ if (fbstart(file) == bstart) {
++ hidden_file = au_h_fptr(file);
++ if (file->f_mode == hidden_file->f_mode)
++ return 0; /* success */
++ h_file_tmp = hidden_file;
++ get_file(h_file_tmp);
++ set_h_fptr(file, bstart, NULL);
++ }
++ DEBUG_ON(fbstart(file) < bstart
++ || ftofi(file)->fi_hfile[0 + bstart].hf_file);
++
++ hidden_file = hidden_open(dentry, bstart, file->f_flags & ~O_TRUNC);
++ //if (LktrCond) {fput(hidden_file); br_put(stobr(dentry->d_sb, bstart));
++ //hidden_file = ERR_PTR(-1);}
++ err = PTR_ERR(hidden_file);
++ if (IS_ERR(hidden_file))
++ goto out; // close all?
++ err = 0;
++ //cpup_file_flags(hidden_file, file);
++ set_fbstart(file, bstart);
++ set_h_fptr(file, bstart, hidden_file);
++ memcpy(&hidden_file->f_ra, &file->f_ra, sizeof(file->f_ra)); //??
++
++ /* close lower files */
++ bend = fbend(file);
++ for (bindex = bstart + 1; bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++ set_fbend(file, bstart);
++
++ out:
++ if (h_file_tmp)
++ fput(h_file_tmp);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * copyup the deleted file for writing.
++ */
++static int cpup_wh_file(struct file *file, aufs_bindex_t bdst, loff_t len)
++{
++ int err;
++ struct dentry *dentry, *parent, *hidden_parent, *tmp_dentry;
++ struct dentry *hidden_dentry_bstart, *hidden_dentry_bdst;
++ struct inode *hidden_dir;
++ aufs_bindex_t bstart;
++ struct aufs_dinfo *dinfo;
++ struct dtime dt;
++ struct lkup_args lkup;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, bdst %d, len %Lu\n", DLNPair(dentry), bdst, len);
++ DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode)
++ || !(file->f_mode & FMODE_WRITE));
++ DiMustWriteLock(dentry);
++ parent = dentry->d_parent;
++ IiMustAnyLock(parent->d_inode);
++ hidden_parent = au_h_dptr_i(parent, bdst);
++ DEBUG_ON(!hidden_parent);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!hidden_dir);
++ IMustLock(hidden_dir);
++
++ sb = parent->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bdst);
++ lkup.dlgt = need_dlgt(sb);
++ tmp_dentry = lkup_whtmp(hidden_parent, &dentry->d_name, &lkup);
++ //if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(tmp_dentry);
++ if (IS_ERR(tmp_dentry))
++ goto out;
++
++ dtime_store(&dt, parent, hidden_parent);
++ dinfo = dtodi(dentry);
++ bstart = dinfo->di_bstart;
++ hidden_dentry_bdst = dinfo->di_hdentry[0 + bdst].hd_dentry;
++ hidden_dentry_bstart = dinfo->di_hdentry[0 + bstart].hd_dentry;
++ dinfo->di_bstart = bdst;
++ dinfo->di_hdentry[0 + bdst].hd_dentry = tmp_dentry;
++ dinfo->di_hdentry[0 + bstart].hd_dentry = au_h_fptr(file)->f_dentry;
++ err = cpup_single(dentry, bdst, bstart, len,
++ au_flags_cpup(!CPUP_DTIME, parent));
++ //if (LktrCond) err = -1;
++ if (!err)
++ err = au_reopen_nondir(file);
++ //err = -1;
++ dinfo->di_hdentry[0 + bstart].hd_dentry = hidden_dentry_bstart;
++ dinfo->di_hdentry[0 + bdst].hd_dentry = hidden_dentry_bdst;
++ dinfo->di_bstart = bstart;
++ if (unlikely(err))
++ goto out_tmp;
++
++ DEBUG_ON(!d_unhashed(dentry));
++ err = vfsub_unlink(hidden_dir, tmp_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1;
++ if (unlikely(err)) {
++ IOErr("failed remove copied-up tmp file %.*s(%d)\n",
++ DLNPair(tmp_dentry), err);
++ err = -EIO;
++ }
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++
++ out_tmp:
++ dput(tmp_dentry);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct cpup_wh_file_args {
++ int *errp;
++ struct file *file;
++ aufs_bindex_t bdst;
++ loff_t len;
++};
++
++static void call_cpup_wh_file(void *args)
++{
++ struct cpup_wh_file_args *a = args;
++ *a->errp = cpup_wh_file(a->file, a->bdst, a->len);
++}
++
++/*
++ * prepare the @file for writing.
++ */
++int au_ready_to_write(struct file *file, loff_t len)
++{
++ int err;
++ struct dentry *dentry, *parent, *hidden_dentry, *hidden_parent;
++ struct inode *hidden_inode, *hidden_dir, *inode, *dir;
++ struct super_block *sb;
++ aufs_bindex_t bstart, bcpup;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, len %Ld\n", DLNPair(dentry), len);
++ FiMustWriteLock(file);
++
++ sb = dentry->d_sb;
++ bstart = fbstart(file);
++ DEBUG_ON(ftobr(file, bstart) != stobr(sb, bstart));
++
++ inode = dentry->d_inode;
++ ii_read_lock_child(inode);
++ LKTRTrace("rdonly %d, bstart %d\n", test_ro(sb, bstart, inode), bstart);
++ err = test_ro(sb, bstart, inode);
++ ii_read_unlock(inode);
++ if (!err && (au_h_fptr(file)->f_mode & FMODE_WRITE))
++ return 0;
++
++ /* need to cpup */
++ parent = dentry->d_parent; // dget_parent()
++ di_write_lock_child(dentry);
++ di_write_lock_parent(parent);
++ bcpup = err = find_rw_parent_br(dentry, bstart);
++ //bcpup = err = find_rw_br(sb, bstart);
++ if (unlikely(err < 0))
++ goto out_unlock;
++ err = 0;
++
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ if (!hidden_parent) {
++ err = cpup_dirs(dentry, bcpup, NULL);
++ //if (LktrCond) err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ }
++
++ hidden_dir = hidden_parent->d_inode;
++ hidden_dentry = au_h_fptr(file)->f_dentry;
++ hidden_inode = hidden_dentry->d_inode;
++ dir = parent->d_inode;
++ hdir_lock(hidden_dir, dir, bcpup);
++ hi_lock_child(hidden_inode);
++ if (d_unhashed(dentry) || d_unhashed(hidden_dentry)
++ /* || !hidden_inode->i_nlink */) {
++ if (!au_test_perm(hidden_dir, MAY_EXEC | MAY_WRITE,
++ need_dlgt(sb)))
++ err = cpup_wh_file(file, bcpup, len);
++ else {
++ struct cpup_wh_file_args args = {
++ .errp = &err,
++ .file = file,
++ .bdst = bcpup,
++ .len = len
++ };
++ au_wkq_wait(call_cpup_wh_file, &args, /*dlgt*/0);
++ }
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ } else {
++ if (!au_h_dptr_i(dentry, bcpup))
++ err = sio_cpup_simple(dentry, bcpup, len,
++ au_flags_cpup(CPUP_DTIME,
++ parent));
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ if (!err)
++ err = au_reopen_nondir(file);
++ //if (LktrCond) err = -1;
++ TraceErr(err);
++ }
++ i_unlock(hidden_inode);
++ hdir_unlock(hidden_dir, dir, bcpup);
++
++ out_unlock:
++ di_write_unlock(parent);
++ di_write_unlock(dentry);
++// out:
++ TraceErr(err);
++ return err;
++
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * after branch manipulating, refresh the file.
++ */
++static int refresh_file(struct file *file, int (*reopen)(struct file *file))
++{
++ int err, new_sz;
++ struct dentry *dentry;
++ aufs_bindex_t bend, bindex, bstart, brid;
++ struct aufs_hfile *p;
++ struct aufs_finfo *finfo;
++ struct super_block *sb;
++ struct inode *inode;
++ struct file *hidden_file;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ FiMustWriteLock(file);
++ DiMustReadLock(dentry);
++ inode = dentry->d_inode;
++ IiMustReadLock(inode);
++ //au_debug_on();
++ //DbgDentry(dentry);
++ //DbgFile(file);
++ //au_debug_off();
++
++ err = -ENOMEM;
++ sb = dentry->d_sb;
++ finfo = ftofi(file);
++ bstart = finfo->fi_bstart;
++ bend = finfo->fi_bstart;
++ new_sz = sizeof(*finfo->fi_hfile) * (sbend(sb) + 1);
++ p = au_kzrealloc(finfo->fi_hfile, sizeof(*p) * (finfo->fi_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++ finfo->fi_hfile = p;
++ hidden_file = p[0 + bstart].hf_file;
++
++ p = finfo->fi_hfile + finfo->fi_bstart;
++ brid = p->hf_br->br_id;
++ bend = finfo->fi_bend;
++ for (bindex = finfo->fi_bstart; bindex <= bend; bindex++, p++) {
++ struct aufs_hfile tmp, *q;
++ aufs_bindex_t new_bindex;
++
++ if (!p->hf_file)
++ continue;
++ new_bindex = find_bindex(sb, p->hf_br);
++ if (new_bindex == bindex)
++ continue;
++ if (new_bindex < 0) { // test here
++ set_h_fptr(file, bindex, NULL);
++ continue;
++ }
++
++ /* swap two hidden inode, and loop again */
++ q = finfo->fi_hfile + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hf_file) {
++ bindex--;
++ p--;
++ }
++ }
++ {
++ aufs_bindex_t s = finfo->fi_bstart, e = finfo->fi_bend;
++ finfo->fi_bstart = 0;
++ finfo->fi_bend = sbend(sb);
++ //au_debug_on();
++ //DbgFile(file);
++ //au_debug_off();
++ finfo->fi_bstart = s;
++ finfo->fi_bend = e;
++ }
++
++ p = finfo->fi_hfile;
++ if (!au_is_mmapped(file) && !d_unhashed(dentry)) {
++ bend = sbend(sb);
++ for (finfo->fi_bstart = 0; finfo->fi_bstart <= bend;
++ finfo->fi_bstart++, p++)
++ if (p->hf_file) {
++ if (p->hf_file->f_dentry
++ && p->hf_file->f_dentry->d_inode)
++ break;
++ else
++ au_hfput(p);
++ }
++ } else {
++ bend = find_brindex(sb, brid);
++ //LKTRTrace("%d\n", bend);
++ for (finfo->fi_bstart = 0; finfo->fi_bstart < bend;
++ finfo->fi_bstart++, p++)
++ if (p->hf_file)
++ au_hfput(p);
++ //LKTRTrace("%d\n", finfo->fi_bstart);
++ bend = sbend(sb);
++ }
++
++ p = finfo->fi_hfile + bend;
++ for (finfo->fi_bend = bend; finfo->fi_bend >= finfo->fi_bstart;
++ finfo->fi_bend--, p--)
++ if (p->hf_file) {
++ if (p->hf_file->f_dentry
++ && p->hf_file->f_dentry->d_inode)
++ break;
++ else
++ au_hfput(p);
++ }
++ //Dbg("%d, %d\n", finfo->fi_bstart, finfo->fi_bend);
++ DEBUG_ON(finfo->fi_bend < finfo->fi_bstart);
++ //DbgFile(file);
++ //DbgDentry(file->f_dentry);
++
++ err = 0;
++#if 0 // todo:
++ if (!au_h_dptr(dentry)->d_inode) {
++ au_update_figen(file);
++ goto out; /* success */
++ }
++#endif
++
++ if (unlikely(au_is_mmapped(file) || d_unhashed(dentry)))
++ goto out_update; /* success */
++
++ again:
++ bstart = ibstart(inode);
++ if (bstart < finfo->fi_bstart
++ && au_flag_test(sb, AuFlag_PLINK)
++ && au_is_plinked(sb, inode)) {
++ struct dentry *parent = dentry->d_parent; // dget_parent()
++ struct inode *dir = parent->d_inode, *h_dir;
++
++ if (test_ro(sb, bstart, inode)) {
++ di_read_lock_parent(parent, !AUFS_I_RLOCK);
++ bstart = err = find_rw_parent_br(dentry, bstart);
++ //bstart = err = find_rw_br(sb, bstart);
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ //todo: err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ di_write_lock_child(dentry);
++ if (bstart != ibstart(inode)) { // todo
++ /* someone changed our inode while we were sleeping */
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ goto again;
++ }
++
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ err = test_and_cpup_dirs(dentry, bstart, NULL);
++
++ // always superio.
++#if 1
++ h_dir = au_h_dptr_i(parent, bstart)->d_inode;
++ hdir_lock(h_dir, dir, bstart);
++ err = sio_cpup_simple(dentry, bstart, -1,
++ au_flags_cpup(CPUP_DTIME, parent));
++ hdir_unlock(h_dir, dir, bstart);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++#else
++ if (!is_au_wkq(current)) {
++ struct cpup_pseudo_link_args args = {
++ .errp = &err,
++ .dentry = dentry,
++ .bdst = bstart,
++ .do_lock = 1
++ };
++ au_wkq_wait(call_cpup_pseudo_link, &args);
++ } else
++ err = cpup_pseudo_link(dentry, bstart, /*do_lock*/1);
++#endif
++ di_downgrade_lock(dentry, AUFS_I_RLOCK);
++ if (unlikely(err))
++ goto out;
++ }
++
++ err = reopen(file);
++ //err = -1;
++ out_update:
++ if (!err) {
++ au_update_figen(file);
++ //DbgFile(file);
++ return 0; /* success */
++ }
++
++ /* error, close all hidden files */
++ bend = fbend(file);
++ for (bindex = fbstart(file); bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* common function to regular file and dir */
++int au_reval_and_lock_finfo(struct file *file, int (*reopen)(struct file *file),
++ int wlock, int locked)
++{
++ int err, sgen, fgen, pseudo_link;
++ struct dentry *dentry;
++ struct super_block *sb;
++ aufs_bindex_t bstart;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, w %d, l %d\n", DLNPair(dentry), wlock, locked);
++ sb = dentry->d_sb;
++ SiMustAnyLock(sb);
++
++ err = 0;
++ sgen = au_sigen(sb);
++ fi_write_lock(file);
++ fgen = au_figen(file);
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ bstart = dbstart(dentry);
++ pseudo_link = (bstart != ibstart(dentry->d_inode));
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ if (sgen == fgen && !pseudo_link && fbstart(file) == bstart) {
++ if (!wlock)
++ fi_downgrade_lock(file);
++ return 0; /* success */
++ }
++
++ LKTRTrace("sgen %d, fgen %d\n", sgen, fgen);
++ if (sgen != au_digen(dentry)) {
++ /*
++ * d_path() and path_lookup() is a simple and good approach
++ * to revalidate. but si_rwsem in DEBUG_RWSEM will cause a
++ * deadlock. removed the code.
++ */
++ di_write_lock_child(dentry);
++ err = au_reval_dpath(dentry, sgen);
++ //if (LktrCond) err = -1;
++ di_write_unlock(dentry);
++ if (unlikely(err < 0))
++ goto out;
++ DEBUG_ON(au_digen(dentry) != sgen);
++ }
++
++ di_read_lock_child(dentry, AUFS_I_RLOCK);
++ err = refresh_file(file, reopen);
++ //if (LktrCond) err = -1;
++ di_read_unlock(dentry, AUFS_I_RLOCK);
++ if (!err) {
++ if (!wlock)
++ fi_downgrade_lock(file);
++ } else
++ fi_write_unlock(file);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++// cf. aufs_nopage()
++// for madvise(2)
++static int aufs_readpage(struct file *file, struct page *page)
++{
++ TraceEnter();
++ unlock_page(page);
++ return 0;
++}
++
++// they will never be called.
++#ifdef CONFIG_AUFS_DEBUG
++static int aufs_prepare_write(struct file *file, struct page *page,
++ unsigned from, unsigned to)
++{BUG();return 0;}
++static int aufs_commit_write(struct file *file, struct page *page,
++ unsigned from, unsigned to)
++{BUG();return 0;}
++static int aufs_writepage(struct page *page, struct writeback_control *wbc)
++{BUG();return 0;}
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++static void aufs_sync_page(struct page *page)
++{BUG();}
++#else
++static int aufs_sync_page(struct page *page)
++{BUG(); return 0;}
++#endif
++
++#if 0 // comment
++static int aufs_writepages(struct address_space *mapping,
++ struct writeback_control *wbc)
++{BUG();return 0;}
++static int aufs_readpages(struct file *filp, struct address_space *mapping,
++ struct list_head *pages, unsigned nr_pages)
++{BUG();return 0;}
++static sector_t aufs_bmap(struct address_space *mapping, sector_t block)
++{BUG();return 0;}
++#endif
++
++static int aufs_set_page_dirty(struct page *page)
++{BUG();return 0;}
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
++static void aufs_invalidatepage (struct page *page, unsigned long offset)
++{BUG();}
++#else
++static int aufs_invalidatepage (struct page *page, unsigned long offset)
++{BUG(); return 0;}
++#endif
++static int aufs_releasepage (struct page *page, gfp_t gfp)
++{BUG();return 0;}
++static ssize_t aufs_direct_IO(int rw, struct kiocb *iocb,
++ const struct iovec *iov, loff_t offset,
++ unsigned long nr_segs)
++{BUG();return 0;}
++static struct page* aufs_get_xip_page(struct address_space *mapping,
++ sector_t offset, int create)
++{BUG();return NULL;}
++//static int aufs_migratepage (struct page *newpage, struct page *page)
++//{BUG();return 0;}
++#endif
++
++#if 0 // comment
++struct address_space {
++ struct inode *host; /* owner: inode, block_device */
++ struct radix_tree_root page_tree; /* radix tree of all pages */
++ rwlock_t tree_lock; /* and rwlock protecting it */
++ unsigned int i_mmap_writable;/* count VM_SHARED mappings */
++ struct prio_tree_root i_mmap; /* tree of private and shared mappings */
++ struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
++ spinlock_t i_mmap_lock; /* protect tree, count, list */
++ unsigned int truncate_count; /* Cover race condition with truncate */
++ unsigned long nrpages; /* number of total pages */
++ pgoff_t writeback_index;/* writeback starts here */
++ struct address_space_operations *a_ops; /* methods */
++ unsigned long flags; /* error bits/gfp mask */
++ struct backing_dev_info *backing_dev_info; /* device readahead, etc */
++ spinlock_t private_lock; /* for use by the address_space */
++ struct list_head private_list; /* ditto */
++ struct address_space *assoc_mapping; /* ditto */
++} __attribute__((aligned(sizeof(long))));
++
++struct address_space_operations {
++ int (*writepage)(struct page *page, struct writeback_control *wbc);
++ int (*readpage)(struct file *, struct page *);
++ void (*sync_page)(struct page *);
++
++ /* Write back some dirty pages from this mapping. */
++ int (*writepages)(struct address_space *, struct writeback_control *);
++
++ /* Set a page dirty. Return true if this dirtied it */
++ int (*set_page_dirty)(struct page *page);
++
++ int (*readpages)(struct file *filp, struct address_space *mapping,
++ struct list_head *pages, unsigned nr_pages);
++
++ /*
++ * ext3 requires that a successful prepare_write() call be followed
++ * by a commit_write() call - they must be balanced
++ */
++ int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
++ int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
++ /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
++ sector_t (*bmap)(struct address_space *, sector_t);
++ void (*invalidatepage) (struct page *, unsigned long);
++ int (*releasepage) (struct page *, gfp_t);
++ ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
++ loff_t offset, unsigned long nr_segs);
++ struct page* (*get_xip_page)(struct address_space *, sector_t,
++ int);
++ /* migrate the contents of a page to the specified target */
++ int (*migratepage) (struct page *, struct page *);
++};
++#endif
++
++struct address_space_operations aufs_aop = {
++ .readpage = aufs_readpage,
++#ifdef CONFIG_AUFS_DEBUG
++ .writepage = aufs_writepage,
++ .sync_page = aufs_sync_page,
++ //.writepages = aufs_writepages,
++ .set_page_dirty = aufs_set_page_dirty,
++ //.readpages = aufs_readpages,
++ .prepare_write = aufs_prepare_write,
++ .commit_write = aufs_commit_write,
++ //.bmap = aufs_bmap,
++ .invalidatepage = aufs_invalidatepage,
++ .releasepage = aufs_releasepage,
++ .direct_IO = aufs_direct_IO,
++ .get_xip_page = aufs_get_xip_page,
++ //.migratepage = aufs_migratepage
++#endif
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/file.h linux-2.6.22.1/fs/aufs/file.h
+--- linux-2.6.22.1.oorig/fs/aufs/file.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/file.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,140 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: file.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_FILE_H__
++#define __AUFS_FILE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/file.h>
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++// SEEK_xxx are defined in linux/fs.h
++#else
++enum {SEEK_SET, SEEK_CUR, SEEK_END};
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_branch;
++struct aufs_hfile {
++ struct file *hf_file;
++ struct aufs_branch *hf_br;
++};
++
++struct aufs_vdir;
++struct aufs_finfo {
++ atomic_t fi_generation;
++
++ struct aufs_rwsem fi_rwsem;
++ struct aufs_hfile *fi_hfile;
++ aufs_bindex_t fi_bstart, fi_bend;
++
++ union {
++ struct vm_operations_struct *fi_h_vm_ops;
++ struct aufs_vdir *fi_vdir_cache;
++ };
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* file.c */
++extern struct address_space_operations aufs_aop;
++unsigned int au_file_roflags(unsigned int flags);
++struct file *hidden_open(struct dentry *dentry, aufs_bindex_t bindex,
++ int flags);
++int au_do_open(struct inode *inode, struct file *file,
++ int (*open)(struct file *file, int flags));
++int au_reopen_nondir(struct file *file);
++int au_ready_to_write(struct file *file, loff_t len);
++int au_reval_and_lock_finfo(struct file *file, int (*reopen)(struct file *file),
++ int wlock, int locked);
++
++/* f_op.c */
++extern struct file_operations aufs_file_fop;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++int aufs_flush(struct file *file, fl_owner_t id);
++#else
++int aufs_flush(struct file *file);
++#endif
++
++/* finfo.c */
++struct aufs_finfo *ftofi(struct file *file);
++aufs_bindex_t fbstart(struct file *file);
++aufs_bindex_t fbend(struct file *file);
++struct aufs_vdir *fvdir_cache(struct file *file);
++struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex);
++struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex);
++struct file *au_h_fptr(struct file *file);
++
++void set_fbstart(struct file *file, aufs_bindex_t bindex);
++void set_fbend(struct file *file, aufs_bindex_t bindex);
++void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache);
++void au_hfput(struct aufs_hfile *hf);
++void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *h_file);
++void au_update_figen(struct file *file);
++
++void au_fin_finfo(struct file *file);
++int au_init_finfo(struct file *file);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int au_figen(struct file *f)
++{
++ return atomic_read(&ftofi(f)->fi_generation);
++}
++
++static inline int au_is_mmapped(struct file *f)
++{
++ return !!(ftofi(f)->fi_h_vm_ops);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * fi_read_lock, fi_write_lock,
++ * fi_read_unlock, fi_write_unlock, fi_downgrade_lock
++ */
++SimpleRwsemFuncs(fi, struct file *f, ftofi(f)->fi_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define FiMustReadLock(f) do {\
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustReadLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustWriteLock(f) do { \
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustWriteLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustAnyLock(f) do { \
++ SiMustAnyLock((f)->f_dentry->d_sb); \
++ RwMustAnyLock(&ftofi(f)->fi_rwsem); \
++} while (0)
++
++#define FiMustNoWaiters(f) RwMustNoWaiters(&ftofi(f)->fi_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_FILE_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/finfo.c linux-2.6.22.1/fs/aufs/finfo.c
+--- linux-2.6.22.1.oorig/fs/aufs/finfo.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/finfo.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,211 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: finfo.c,v 1.23 2007/04/30 05:45:21 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct aufs_finfo *ftofi(struct file *file)
++{
++ struct aufs_finfo *finfo = file->private_data;
++ DEBUG_ON(!finfo
++ || !finfo->fi_hfile
++ || (0 < finfo->fi_bend
++ && (/* stosi(file->f_dentry->d_sb)->si_bend
++ < finfo->fi_bend
++ || */ finfo->fi_bend < finfo->fi_bstart)));
++ return finfo;
++}
++
++// hard/soft set
++aufs_bindex_t fbstart(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_bstart;
++}
++
++aufs_bindex_t fbend(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_bend;
++}
++
++struct aufs_vdir *fvdir_cache(struct file *file)
++{
++ FiMustAnyLock(file);
++ return ftofi(file)->fi_vdir_cache;
++}
++
++struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustAnyLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_br && br_count(hf->hf_br) <= 0);
++ return hf->hf_br;
++}
++
++struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustAnyLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_file
++ && file_count(hf->hf_file) <= 0
++ && br_count(hf->hf_br) <= 0);
++ return hf->hf_file;
++}
++
++struct file *au_h_fptr(struct file *file)
++{
++ return au_h_fptr_i(file, fbstart(file));
++}
++
++void set_fbstart(struct file *file, aufs_bindex_t bindex)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(sbend(file->f_dentry->d_sb) < bindex);
++ ftofi(file)->fi_bstart = bindex;
++}
++
++void set_fbend(struct file *file, aufs_bindex_t bindex)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(sbend(file->f_dentry->d_sb) < bindex
++ || bindex < fbstart(file));
++ ftofi(file)->fi_bend = bindex;
++}
++
++void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache)
++{
++ FiMustWriteLock(file);
++ DEBUG_ON(!S_ISDIR(file->f_dentry->d_inode->i_mode)
++ || (ftofi(file)->fi_vdir_cache && vdir_cache));
++ ftofi(file)->fi_vdir_cache = vdir_cache;
++}
++
++void au_hfput(struct aufs_hfile *hf)
++{
++ fput(hf->hf_file);
++ hf->hf_file = NULL;
++ DEBUG_ON(!hf->hf_br);
++ br_put(hf->hf_br);
++ hf->hf_br = NULL;
++}
++
++void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *val)
++{
++ struct aufs_finfo *finfo = ftofi(file);
++ struct aufs_hfile *hf;
++
++ FiMustWriteLock(file);
++ DEBUG_ON(!finfo
++ || finfo->fi_bstart < 0
++ || bindex < finfo->fi_bstart
++ || finfo->fi_bend < bindex);
++ DEBUG_ON(val && file_count(val) <= 0);
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(val && hf->hf_file);
++ if (hf->hf_file)
++ au_hfput(hf);
++ if (val) {
++ hf->hf_file = val;
++ hf->hf_br = stobr(file->f_dentry->d_sb, bindex);
++ }
++}
++
++void au_update_figen(struct file *file)
++{
++ atomic_set(&ftofi(file)->fi_generation, au_digen(file->f_dentry));
++}
++
++void au_fin_finfo(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ struct dentry *dentry;
++ aufs_bindex_t bindex, bend;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ SiMustAnyLock(dentry->d_sb);
++
++ fi_write_lock(file);
++ bend = fbend(file);
++ bindex = fbstart(file);
++ if (bindex >= 0)
++ for (; bindex <= bend; bindex++)
++ set_h_fptr(file, bindex, NULL);
++
++ finfo = ftofi(file);
++#ifdef CONFIG_AUFS_DEBUG
++ if (finfo->fi_bstart >= 0) {
++ bend = fbend(file);
++ for (bindex = finfo->fi_bstart; bindex <= bend; bindex++) {
++ struct aufs_hfile *hf;
++ hf = finfo->fi_hfile + bindex;
++ DEBUG_ON(hf->hf_file || hf->hf_br);
++ }
++ }
++#endif
++
++ kfree(finfo->fi_hfile);
++ fi_write_unlock(file);
++ cache_free_finfo(finfo);
++ //file->private_data = NULL;
++}
++
++int au_init_finfo(struct file *file)
++{
++ struct aufs_finfo *finfo;
++ struct dentry *dentry;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ DEBUG_ON(!dentry->d_inode);
++
++ finfo = cache_alloc_finfo();
++ if (finfo) {
++ finfo->fi_hfile = kcalloc(sbend(dentry->d_sb) + 1,
++ sizeof(*finfo->fi_hfile), GFP_KERNEL);
++ if (finfo->fi_hfile) {
++ rw_init_wlock(&finfo->fi_rwsem);
++ finfo->fi_bstart = -1;
++ finfo->fi_bend = -1;
++ atomic_set(&finfo->fi_generation, au_digen(dentry));
++
++ file->private_data = finfo;
++ return 0; /* success */
++ }
++ cache_free_finfo(finfo);
++ }
++
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/hinotify.c linux-2.6.22.1/fs/aufs/hinotify.c
+--- linux-2.6.22.1.oorig/fs/aufs/hinotify.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/hinotify.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,536 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: hinotify.c,v 1.19 2007/05/14 03:39:21 sfjro Exp $ */
++
++#include "aufs.h"
++
++static struct inotify_handle *in_handle;
++static const __u32 in_mask = (IN_MOVE | IN_DELETE | IN_CREATE /* | IN_ACCESS */
++ | IN_MODIFY | IN_ATTRIB
++ | IN_DELETE_SELF | IN_MOVE_SELF);
++
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *hidden_inode)
++{
++ int err;
++ struct aufs_hinotify *hin;
++ s32 wd;
++
++ LKTRTrace("i%lu, hi%lu\n", inode->i_ino, hidden_inode->i_ino);
++
++ err = -ENOMEM;
++ hin = cache_alloc_hinotify();
++ if (hin) {
++ DEBUG_ON(hinode->hi_notify);
++ hinode->hi_notify = hin;
++ hin->hin_aufs_inode = inode;
++ inotify_init_watch(&hin->hin_watch);
++ wd = inotify_add_watch(in_handle, &hin->hin_watch, hidden_inode,
++ in_mask);
++ if (wd >= 0)
++ return 0; /* success */
++
++ err = wd;
++ put_inotify_watch(&hin->hin_watch);
++ cache_free_hinotify(hin);
++ hinode->hi_notify = NULL;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++void do_free_hinotify(struct aufs_hinode *hinode)
++{
++ int err;
++ struct aufs_hinotify *hin;
++
++ TraceEnter();
++
++ hin = hinode->hi_notify;
++ if (hin) {
++ err = 0;
++ if (atomic_read(&hin->hin_watch.count))
++ err = inotify_rm_watch(in_handle, &hin->hin_watch);
++
++ if (!err) {
++ cache_free_hinotify(hin);
++ hinode->hi_notify = NULL;
++ } else
++ IOErr1("failed inotify_rm_watch() %d\n", err);
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void ctl_hinotify(struct aufs_hinode *hinode, const __u32 mask)
++{
++ struct inode *hi;
++ struct inotify_watch *watch;
++
++ hi = hinode->hi_inode;
++ LKTRTrace("hi%lu, sb %p, 0x%x\n", hi->i_ino, hi->i_sb, mask);
++ if (0 && !strcmp(current->comm, "link"))
++ dump_stack();
++ IMustLock(hi);
++ if (!hinode->hi_notify)
++ return;
++
++ watch = &hinode->hi_notify->hin_watch;
++#if 0
++ {
++ u32 wd;
++ wd = inotify_find_update_watch(in_handle, hi, mask);
++ TraceErr(wd);
++ // ignore an err;
++ }
++#else
++ watch->mask = mask;
++ smp_mb();
++#endif
++ LKTRTrace("watch %p, mask %u\n", watch, watch->mask);
++}
++
++#define suspend_hinotify(hi) ctl_hinotify(hi, 0)
++#define resume_hinotify(hi) ctl_hinotify(hi, in_mask)
++
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("i%lu, b%d, lsc %d\n", dir->i_ino, bindex, lsc);
++ DEBUG_ON(!S_ISDIR(dir->i_mode));
++ hinode = itoii(dir)->ii_hinode + bindex;
++ DEBUG_ON(h_dir != hinode->hi_inode);
++
++ hi_lock(h_dir, lsc);
++ if (1 /* unlikely(au_flag_test(dir->i_sb, AuFlag_UDBA_HINOTIFY) */)
++ suspend_hinotify(hinode);
++}
++
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("i%lu, b%d\n", dir->i_ino, bindex);
++ DEBUG_ON(!S_ISDIR(dir->i_mode));
++ hinode = itoii(dir)->ii_hinode + bindex;
++ DEBUG_ON(h_dir != hinode->hi_inode);
++
++ if (1 /* unlikely(au_flag_test(dir->i_sb, AuFlag_UDBA_HINOTIFY) */)
++ resume_hinotify(hinode);
++ i_unlock(h_dir);
++}
++
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("%.*s, %.*s\n", DLNPair(h_parents[0]), DLNPair(h_parents[1]));
++
++ vfsub_lock_rename(h_parents[0], h_parents[1]);
++ hinode = itoii(dirs[0])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[0]->d_inode != hinode->hi_inode);
++ suspend_hinotify(hinode);
++ if (issamedir)
++ return;
++ hinode = itoii(dirs[1])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[1]->d_inode != hinode->hi_inode);
++ suspend_hinotify(hinode);
++}
++
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ struct aufs_hinode *hinode;
++
++ LKTRTrace("%.*s, %.*s\n", DLNPair(h_parents[0]), DLNPair(h_parents[1]));
++
++ hinode = itoii(dirs[0])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[0]->d_inode != hinode->hi_inode);
++ resume_hinotify(hinode);
++ if (!issamedir) {
++ hinode = itoii(dirs[1])->ii_hinode + bindex;
++ DEBUG_ON(h_parents[1]->d_inode != hinode->hi_inode);
++ resume_hinotify(hinode);
++ }
++ vfsub_unlock_rename(h_parents[0], h_parents[1]);
++}
++
++void au_reset_hinotify(struct inode *inode, unsigned int flags)
++{
++ aufs_bindex_t bindex, bend;
++ struct inode *hi;
++
++ LKTRTrace("i%lu, 0x%x\n", inode->i_ino, flags);
++
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); bindex <= bend; bindex++) {
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi) {
++ //hi_lock(hi, AUFS_LSC_H_CHILD);
++ igrab(hi);
++ set_h_iptr(inode, bindex, NULL, 0);
++ set_h_iptr(inode, bindex, igrab(hi), flags);
++ iput(hi);
++ //i_unlock(hi);
++ }
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DEBUG
++static char *in_name(u32 mask)
++{
++#define test_ret(flag) if (mask & flag) return #flag;
++ test_ret(IN_ACCESS);
++ test_ret(IN_MODIFY);
++ test_ret(IN_ATTRIB);
++ test_ret(IN_CLOSE_WRITE);
++ test_ret(IN_CLOSE_NOWRITE);
++ test_ret(IN_OPEN);
++ test_ret(IN_MOVED_FROM);
++ test_ret(IN_MOVED_TO);
++ test_ret(IN_CREATE);
++ test_ret(IN_DELETE);
++ test_ret(IN_DELETE_SELF);
++ test_ret(IN_MOVE_SELF);
++ test_ret(IN_UNMOUNT);
++ test_ret(IN_Q_OVERFLOW);
++ test_ret(IN_IGNORED);
++ return "";
++#undef test_ret
++}
++#else
++#define in_name(m) "??"
++#endif
++
++static int dec_gen_by_name(struct inode *dir, const char *_name, u32 mask)
++{
++ int err;
++ struct dentry *parent, *child;
++ struct inode *inode;
++ struct qstr *dname;
++ char *name = (void*)_name;
++ unsigned int len;
++
++ LKTRTrace("i%lu, %s, 0x%x %s\n",
++ dir->i_ino, name, mask, in_name(mask));
++
++ err = -1;
++ parent = d_find_alias(dir);
++ if (unlikely(!parent))
++ goto out;
++
++#if 0
++ if (unlikely(!memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)))
++ name += AUFS_WH_PFX_LEN;
++#endif
++ len = strlen(name);
++ spin_lock(&dcache_lock);
++ list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) {
++ dname = &child->d_name;
++ if (len == dname->len && !memcmp(dname->name, name, len)) {
++ au_digen_dec(child);
++#if 1
++ //todo: why both are needed
++ if (mask & IN_MOVE) {
++ spin_lock(&child->d_lock);
++ __d_drop(child);
++ spin_unlock(&child->d_lock);
++ }
++#endif
++
++ inode = child->d_inode;
++ if (inode)
++ au_iigen_dec(inode);
++ err = !!inode;
++
++ // todo: the i_nlink of newly created name by link(2)
++ // should be updated
++ // todo: some nfs dentry doesn't notified at deleteing
++ break;
++ }
++ }
++ spin_unlock(&dcache_lock);
++ dput(parent);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct postproc_args {
++ struct inode *h_dir, *dir, *h_child_inode;
++ char *h_child_name;
++ u32 mask;
++};
++
++static void dec_gen_by_ino(struct postproc_args *a)
++{
++ struct super_block *sb;
++ aufs_bindex_t bindex, bend, bfound;
++ struct xino xino;
++ struct inode *cinode;
++
++ TraceEnter();
++
++ sb = a->dir->i_sb;
++ DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++
++ bfound = -1;
++ bend = ibend(a->dir);
++ for (bindex = ibstart(a->dir); bfound == -1 && bindex <= bend; bindex++)
++ if (au_h_iptr_i(a->dir, bindex) == a->h_dir)
++ bfound = bindex;
++ if (bfound < 0)
++ return;
++
++ bindex = find_brindex(sb, itoii(a->dir)->ii_hinode[bfound + 0].hi_id);
++ if (bindex < 0)
++ return;
++ if (unlikely(xino_read(sb, bindex, a->h_child_inode->i_ino, &xino)))
++ return;
++ cinode = NULL;
++ if (xino.ino)
++ cinode = ilookup(sb, xino.ino);
++ if (cinode) {
++#if 1
++ if (1 || a->mask & IN_MOVE) {
++ struct dentry *child;
++ spin_lock(&dcache_lock);
++ list_for_each_entry(child, &cinode->i_dentry, d_alias)
++ au_digen_dec(child);
++ spin_unlock(&dcache_lock);
++ }
++#endif
++ au_iigen_dec(cinode);
++ iput(cinode);
++ }
++}
++
++static void reset_ino(struct postproc_args *a)
++{
++ aufs_bindex_t bindex, bend;
++ struct super_block *sb;
++ struct inode *h_dir;
++
++ sb = a->dir->i_sb;
++ bend = ibend(a->dir);
++ for (bindex = ibstart(a->dir); bindex <= bend; bindex++) {
++ h_dir = au_h_iptr_i(a->dir, bindex);
++ if (h_dir && h_dir != a->h_dir)
++ xino_write0(sb, bindex, h_dir->i_ino);
++ /* ignore this error */
++ }
++}
++
++static void postproc(void *args)
++{
++ struct postproc_args *a = args;
++ struct super_block *sb;
++ struct aufs_vdir *vdir;
++
++ //au_debug_on();
++ LKTRTrace("mask 0x%x %s, i%lu, hi%lu, hci%lu\n",
++ a->mask, in_name(a->mask), a->dir->i_ino, a->h_dir->i_ino,
++ a->h_child_inode ? a->h_child_inode->i_ino : 0);
++ DEBUG_ON(!a->dir);
++#if 0//def ForceInotify
++ Dbg("mask 0x%x %s, i%lu, hi%lu, hci%lu\n",
++ a->mask, in_name(a->mask), a->dir->i_ino, a->h_dir->i_ino,
++ a->h_child_inode ? a->h_child_inode->i_ino : 0);
++#endif
++
++ i_lock(a->dir);
++ sb = a->dir->i_sb;
++ si_read_lock(sb); // consider write_lock
++ ii_write_lock_parent(a->dir);
++
++ /* make dir entries obsolete */
++ vdir = ivdir(a->dir);
++ if (vdir)
++ vdir->vd_jiffy = 0;
++ a->dir->i_version++;
++
++ /*
++ * special handling root directory,
++ * sine d_revalidate may not be called later.
++ * main purpose is maintaining i_nlink.
++ */
++ if (unlikely(a->dir->i_ino == AUFS_ROOT_INO))
++ au_cpup_attr_all(a->dir);
++
++ if (a->h_child_inode && au_flag_test(sb, AuFlag_XINO))
++ dec_gen_by_ino(a);
++ else if (a->mask & (IN_MOVE_SELF | IN_DELETE_SELF))
++ reset_ino(a);
++
++ ii_write_unlock(a->dir);
++ si_read_unlock(sb);
++ i_unlock(a->dir);
++
++ au_mntput(a->dir->i_sb);
++ iput(a->h_child_inode);
++ iput(a->h_dir);
++ iput(a->dir);
++#if 0
++ if (atomic_dec_and_test(&stosi(sb)->si_hinotify))
++ wake_up_all(&stosi(sb)->si_hinotify_wq);
++#endif
++ kfree(a);
++ //au_debug_off();
++}
++
++static void aufs_inotify(struct inotify_watch *watch, u32 wd, u32 mask,
++ u32 cookie, const char *h_child_name,
++ struct inode *h_child_inode)
++{
++ struct aufs_hinotify *hinotify;
++ struct postproc_args *args;
++ int len;
++ char *p;
++ struct inode *dir;
++ //static DECLARE_WAIT_QUEUE_HEAD(wq);
++
++ //au_debug_on();
++ LKTRTrace("i%lu, wd %d, mask 0x%x %s, cookie 0x%x, hcname %s, hi%lu\n",
++ watch->inode->i_ino, wd, mask, in_name(mask), cookie,
++ h_child_name ? h_child_name : "",
++ h_child_inode ? h_child_inode->i_ino : 0);
++ //au_debug_off();
++ //IMustLock(h_dir);
++#if 0 //defined(ForceInotify) || defined(DbgInotify)
++ Dbg("i%lu, wd %d, mask 0x%x %s, cookie 0x%x, hcname %s, hi%lu\n",
++ watch->inode->i_ino, wd, mask, in_name(mask), cookie,
++ h_child_name ? h_child_name : "",
++ h_child_inode ? h_child_inode->i_ino : 0);
++#endif
++ /* if IN_UNMOUNT happens, there must be another bug */
++ if (mask & (IN_IGNORED | IN_UNMOUNT)) {
++ put_inotify_watch(watch);
++ return;
++ }
++
++ switch (mask & IN_ALL_EVENTS) {
++ case IN_MODIFY:
++ case IN_ATTRIB:
++ if (h_child_name)
++ return;
++ break;
++
++ case IN_MOVED_FROM:
++ case IN_MOVED_TO:
++ case IN_CREATE:
++ DEBUG_ON(!h_child_name || !h_child_inode);
++ break;
++ case IN_DELETE:
++ /*
++ * aufs never be able to get this child inode.
++ * revalidation should be in d_revalide()
++ * by checking i_nlink, i_generation or d_unhashed().
++ */
++ DEBUG_ON(!h_child_name);
++ break;
++
++ case IN_DELETE_SELF:
++ case IN_MOVE_SELF:
++ DEBUG_ON(h_child_name || h_child_inode);
++ break;
++
++ case IN_ACCESS:
++ default:
++ DEBUG_ON(1);
++ }
++
++#ifdef DbgInotify
++ WARN_ON(1);
++#endif
++
++ /* iput() will be called in postproc() */
++ hinotify = container_of(watch, struct aufs_hinotify, hin_watch);
++ DEBUG_ON(!hinotify || !hinotify->hin_aufs_inode);
++ dir = hinotify->hin_aufs_inode;
++
++ /* force re-lookup in next d_revalidate() */
++ if (dir->i_ino != AUFS_ROOT_INO)
++ au_iigen_dec(dir);
++ len = 0;
++ if (h_child_name && dec_gen_by_name(dir, h_child_name, mask))
++ len = strlen(h_child_name);
++
++ //wait_event(wq, (args = kmalloc(sizeof(*args), GFP_KERNEL)));
++ args = kmalloc(sizeof(*args) + len + 1, GFP_KERNEL);
++ if (unlikely(!args)) {
++ Err("no memory\n");
++ return;
++ }
++ args->mask = mask;
++ args->dir = igrab(dir);
++ args->h_dir = igrab(watch->inode);
++ args->h_child_inode = NULL;
++ if (len) {
++ if (h_child_inode)
++ args->h_child_inode = igrab(h_child_inode);
++ p = (void*)args;
++ args->h_child_name = p + sizeof(*args);
++ memcpy(args->h_child_name, h_child_name, len + 1);
++ }
++ //atomic_inc(&stosi(args->dir->i_sb)->si_hinotify);
++ /* prohibit umount */
++ au_mntget(args->dir->i_sb);
++ au_wkq_nowait(postproc, args, /*dlgt*/0);
++}
++
++#if 0
++void hinotify_flush(struct super_block *sb)
++{
++ atomic_t *p = &stosi(sb)->si_hinotify;
++ wait_event(stosi(sb)->si_hinotify_wq, !atomic_read(p));
++}
++#endif
++
++static void aufs_inotify_destroy(struct inotify_watch *watch)
++{
++ return;
++}
++
++static struct inotify_operations aufs_inotify_ops = {
++ .handle_event = aufs_inotify,
++ .destroy_watch = aufs_inotify_destroy
++};
++
++/* ---------------------------------------------------------------------- */
++
++int __init au_inotify_init(void)
++{
++ in_handle = inotify_init(&aufs_inotify_ops);
++ if (!IS_ERR(in_handle))
++ return 0;
++ TraceErrPtr(in_handle);
++ return PTR_ERR(in_handle);
++}
++
++void au_inotify_fin(void)
++{
++ inotify_destroy(in_handle);
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/i_op.c linux-2.6.22.1/fs/aufs/i_op.c
+--- linux-2.6.22.1.oorig/fs/aufs/i_op.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/i_op.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,641 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op.c,v 1.30 2007/04/23 00:55:05 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include <linux/security.h>
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++#ifdef CONFIG_AUFS_DLGT
++struct security_inode_permission_args {
++ int *errp;
++ struct inode *h_inode;
++ int mask;
++ struct nameidata *fake_nd;
++};
++
++static void call_security_inode_permission(void *args)
++{
++ struct security_inode_permission_args *a = args;
++ LKTRTrace("fsuid %d\n", current->fsuid);
++ *a->errp = security_inode_permission(a->h_inode, a->mask, a->fake_nd);
++}
++#endif
++
++static int hidden_permission(struct inode *hidden_inode, int mask,
++ struct nameidata *fake_nd, int brperm, int dlgt)
++{
++ int err, submask;
++ const int write_mask = (mask & (MAY_WRITE | MAY_APPEND));
++
++ LKTRTrace("ino %lu, mask 0x%x, brperm 0x%x\n",
++ hidden_inode->i_ino, mask, brperm);
++
++ err = -EACCES;
++ if (unlikely(write_mask && IS_IMMUTABLE(hidden_inode)))
++ goto out;
++
++ /* skip hidden fs test in the case of write to ro branch */
++ submask = mask & ~MAY_APPEND;
++ if (unlikely((write_mask && !br_writable(brperm))
++ || !hidden_inode->i_op
++ || !hidden_inode->i_op->permission)) {
++ //LKTRLabel(generic_permission);
++ err = generic_permission(hidden_inode, submask, NULL);
++ } else {
++ //LKTRLabel(h_inode->permission);
++ err = hidden_inode->i_op->permission(hidden_inode, submask,
++ fake_nd);
++ TraceErr(err);
++ }
++
++#if 1
++ if (!err) {
++#ifndef CONFIG_AUFS_DLGT
++ err = security_inode_permission(hidden_inode, mask, fake_nd);
++#else
++ if (!dlgt)
++ err = security_inode_permission(hidden_inode, mask,
++ fake_nd);
++ else {
++ struct security_inode_permission_args args = {
++ .errp = &err,
++ .h_inode = hidden_inode,
++ .mask = mask,
++ .fake_nd = fake_nd
++ };
++ au_wkq_wait(call_security_inode_permission, &args,
++ /*dlgt*/1);
++ }
++#endif
++ }
++#endif
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int silly_lock(struct inode *inode, struct nameidata *nd)
++{
++ int locked = 0;
++ struct super_block *sb = inode->i_sb;
++
++ LKTRTrace("i%lu, nd %p\n", inode->i_ino, nd);
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++#else
++ if (!nd || !nd->dentry) {
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++ } else if (nd->dentry->d_inode != inode) {
++ locked = 1;
++ /* lock child first, then parent */
++ si_read_lock(sb);
++ ii_read_lock_child(inode);
++ di_read_lock_parent(nd->dentry, 0);
++ } else {
++ locked = 2;
++ aufs_read_lock(nd->dentry, AUFS_I_RLOCK);
++ }
++#endif
++ return locked;
++}
++
++static void silly_unlock(int locked, struct inode *inode, struct nameidata *nd)
++{
++ struct super_block *sb = inode->i_sb;
++
++ LKTRTrace("locked %d, i%lu, nd %p\n", locked, inode->i_ino, nd);
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++#else
++ switch (locked) {
++ case 0:
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++ break;
++ case 1:
++ di_read_unlock(nd->dentry, 0);
++ ii_read_unlock(inode);
++ si_read_unlock(sb);
++ break;
++ case 2:
++ aufs_read_unlock(nd->dentry, AUFS_I_RLOCK);
++ break;
++ default:
++ BUG();
++ }
++#endif
++}
++
++static int aufs_permission(struct inode *inode, int mask, struct nameidata *nd)
++{
++ int err, locked, dlgt;
++ aufs_bindex_t bindex, bend;
++ struct inode *hidden_inode;
++ struct super_block *sb;
++ struct nameidata fake_nd, *p;
++ const int write_mask = (mask & (MAY_WRITE | MAY_APPEND));
++ const int nondir = !S_ISDIR(inode->i_mode);
++
++ LKTRTrace("ino %lu, mask 0x%x, nondir %d, write_mask %d, "
++ "nd %p{%p, %p}\n",
++ inode->i_ino, mask, nondir, write_mask,
++ nd, nd ? nd->dentry : NULL, nd ? nd->mnt : NULL);
++
++ sb = inode->i_sb;
++ locked = silly_lock(inode, nd);
++ dlgt = need_dlgt(sb);
++
++ if (nd)
++ fake_nd = *nd;
++ if (/* unlikely */(nondir || write_mask)) {
++ hidden_inode = au_h_iptr(inode);
++ DEBUG_ON(!hidden_inode
++ || ((hidden_inode->i_mode & S_IFMT)
++ != (inode->i_mode & S_IFMT)));
++ err = 0;
++ bindex = ibstart(inode);
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ /* actual test will be delegated to LSM */
++ if (IS_ERR(p))
++ DEBUG_ON(PTR_ERR(p) != -ENOENT);
++ else {
++ err = hidden_permission(hidden_inode, mask, p,
++ sbr_perm(sb, bindex), dlgt);
++ fake_dm_release(p);
++ }
++ if (write_mask && !err) {
++ err = find_rw_br(sb, bindex);
++ if (err >= 0)
++ err = 0;
++ }
++ goto out;
++ }
++
++ /* non-write to dir */
++ err = 0;
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); !err && bindex <= bend; bindex++) {
++ hidden_inode = au_h_iptr_i(inode, bindex);
++ if (!hidden_inode)
++ continue;
++ DEBUG_ON(!S_ISDIR(hidden_inode->i_mode));
++
++ p = fake_dm(&fake_nd, nd, sb, bindex);
++ /* actual test will be delegated to LSM */
++ if (IS_ERR(p))
++ DEBUG_ON(PTR_ERR(p) != -ENOENT);
++ else {
++ err = hidden_permission(hidden_inode, mask, p,
++ sbr_perm(sb, bindex), dlgt);
++ fake_dm_release(p);
++ }
++ }
++
++ out:
++ silly_unlock(locked, inode, nd);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry *aufs_lookup(struct inode *dir, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ struct dentry *ret, *parent;
++ int err, npositive;
++ struct inode *inode;
++
++ LKTRTrace("dir %lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ DEBUG_ON(IS_ROOT(dentry));
++ IMustLock(dir);
++
++ parent = dentry->d_parent; // dget_parent()
++ aufs_read_lock(parent, !AUFS_I_RLOCK);
++ err = au_alloc_dinfo(dentry);
++ //if (LktrCond) err = -1;
++ ret = ERR_PTR(err);
++ if (unlikely(err))
++ goto out;
++
++ err = npositive = lkup_dentry(dentry, dbstart(parent), /*type*/0);
++ //err = -1;
++ ret = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out_unlock;
++ inode = NULL;
++ if (npositive) {
++ inode = au_new_inode(dentry);
++ ret = (void*)inode;
++ }
++ if (!IS_ERR(inode)) {
++#if 1
++ /* d_splice_alias() also supports d_add() */
++ ret = d_splice_alias(inode, dentry);
++ if (unlikely(IS_ERR(ret) && inode))
++ ii_write_unlock(inode);
++#else
++ d_add(dentry, inode);
++#endif
++ }
++
++ out_unlock:
++ di_write_unlock(dentry);
++ out:
++ aufs_read_unlock(parent, !AUFS_I_RLOCK);
++ TraceErrPtr(ret);
++ return ret;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * decide the branch and the parent dir where we will create a new entry.
++ * returns new bindex or an error.
++ * copyup the parent dir if needed.
++ */
++int wr_dir(struct dentry *dentry, int add_entry, struct dentry *src_dentry,
++ aufs_bindex_t force_btgt, int do_lock_srcdir)
++{
++ int err;
++ aufs_bindex_t bcpup, bstart, src_bstart;
++ struct dentry *hidden_parent;
++ struct super_block *sb;
++ struct dentry *parent, *src_parent = NULL;
++ struct inode *dir, *src_dir = NULL;
++
++ LKTRTrace("%.*s, add %d, src %p, force %d, lock_srcdir %d\n",
++ DLNPair(dentry), add_entry, src_dentry, force_btgt,
++ do_lock_srcdir);
++
++ sb = dentry->d_sb;
++ parent = dentry->d_parent; // dget_parent()
++ bcpup = bstart = dbstart(dentry);
++ if (force_btgt < 0) {
++ if (src_dentry) {
++ src_bstart = dbstart(src_dentry);
++ if (src_bstart < bstart)
++ bcpup = src_bstart;
++ }
++ if (test_ro(sb, bcpup, dentry->d_inode)) {
++ if (!add_entry)
++ di_read_lock_parent(parent, !AUFS_I_RLOCK);
++ bcpup = err = find_rw_parent_br(dentry, bcpup);
++ //bcpup = err = find_rw_br(sb, bcpup);
++ if (!add_entry)
++ di_read_unlock(parent, !AUFS_I_RLOCK);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ } else {
++ DEBUG_ON(bstart <= force_btgt
++ || test_ro(sb, force_btgt, dentry->d_inode));
++ bcpup = force_btgt;
++ }
++ LKTRTrace("bstart %d, bcpup %d\n", bstart, bcpup);
++
++ err = bcpup;
++ if (bcpup == bstart)
++ goto out; /* success */
++
++ /* copyup the new parent into the branch we process */
++ hidden_parent = au_h_dptr(dentry)->d_parent; // dget_parent()
++ if (src_dentry) {
++ src_parent = src_dentry->d_parent; // dget_parent()
++ src_dir = src_parent->d_inode;
++ if (do_lock_srcdir)
++ di_write_lock_parent2(src_parent);
++ }
++
++ dir = parent->d_inode;
++ if (add_entry) {
++ au_update_dbstart(dentry);
++ IMustLock(dir);
++ DiMustWriteLock(parent);
++ IiMustWriteLock(dir);
++ } else
++ di_write_lock_parent(parent);
++
++ err = 0;
++ if (!au_h_dptr_i(parent, bcpup))
++ err = cpup_dirs(dentry, bcpup, src_parent);
++ //err = -1;
++ if (!err && add_entry) {
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ DEBUG_ON(!hidden_parent || !hidden_parent->d_inode);
++ hi_lock_parent(hidden_parent->d_inode);
++ err = lkup_neg(dentry, bcpup);
++ //err = -1;
++ i_unlock(hidden_parent->d_inode);
++ }
++
++ if (!add_entry)
++ di_write_unlock(parent);
++ if (do_lock_srcdir)
++ di_write_unlock(src_parent);
++ if (!err)
++ err = bcpup; /* success */
++ //err = -EPERM;
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int aufs_setattr(struct dentry *dentry, struct iattr *ia)
++{
++ int err, isdir;
++ aufs_bindex_t bstart, bcpup;
++ struct inode *hidden_inode, *inode, *dir, *h_dir, *gh_dir, *gdir;
++ struct dentry *hidden_dentry, *parent;
++ unsigned int udba;
++
++ LKTRTrace("%.*s, ia_valid 0x%x\n", DLNPair(dentry), ia->ia_valid);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ bstart = dbstart(dentry);
++ bcpup = err = wr_dir(dentry, /*add*/0, /*src_dentry*/NULL,
++ /*force_btgt*/-1, /*do_lock_srcdir*/0);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++
++ /* crazy udba locks */
++ udba = au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY);
++ parent = NULL;
++ gdir = gh_dir = dir = h_dir = NULL;
++ if ((udba || bstart != bcpup) && !IS_ROOT(dentry)) {
++ parent = dentry->d_parent; // dget_parent()
++ dir = parent->d_inode;
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ h_dir = au_h_iptr_i(dir, bcpup);
++ }
++ if (parent) {
++ if (unlikely(udba && !IS_ROOT(parent))) {
++ gdir = parent->d_parent->d_inode; // dget_parent()
++ ii_read_lock_parent2(gdir);
++ gh_dir = au_h_iptr_i(gdir, bcpup);
++ hgdir_lock(gh_dir, gdir, bcpup);
++ }
++ hdir_lock(h_dir, dir, bcpup);
++ }
++
++ isdir = S_ISDIR(inode->i_mode);
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++#define HiLock(bindex) do {\
++ if (!isdir) \
++ hi_lock_child(hidden_inode); \
++ else \
++ hdir2_lock(hidden_inode, inode, bindex); \
++ } while (0)
++#define HiUnlock(bindex) do {\
++ if (!isdir) \
++ i_unlock(hidden_inode); \
++ else \
++ hdir_unlock(hidden_inode, inode, bindex); \
++ } while (0)
++
++ if (bstart != bcpup) {
++ loff_t size = -1;
++
++ if ((ia->ia_valid & ATTR_SIZE)
++ && ia->ia_size < i_size_read(inode)) {
++ size = ia->ia_size;
++ ia->ia_valid &= ~ATTR_SIZE;
++ }
++ HiLock(bstart);
++ err = sio_cpup_simple(dentry, bcpup, size,
++ au_flags_cpup(CPUP_DTIME, parent));
++ //err = -1;
++ HiUnlock(bstart);
++ if (unlikely(err || !ia->ia_valid))
++ goto out_unlock;
++
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++ }
++
++ HiLock(bcpup);
++ err = vfsub_notify_change(hidden_dentry, ia, need_dlgt(dentry->d_sb));
++ //err = -1;
++ if (!err)
++ au_cpup_attr_changable(inode);
++ HiUnlock(bcpup);
++#undef HiLock
++#undef HiUnlock
++
++ out_unlock:
++ if (parent) {
++ hdir_unlock(h_dir, dir, bcpup);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ }
++ if (unlikely(gdir)) {
++ hdir_unlock(gh_dir, gdir, bcpup);
++ ii_read_unlock(gdir);
++ }
++ out:
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int hidden_readlink(struct dentry *dentry, int bindex,
++ char __user * buf, int bufsiz)
++{
++ struct super_block *sb;
++ struct dentry *hidden_dentry;
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (unlikely(!hidden_dentry->d_inode->i_op
++ || !hidden_dentry->d_inode->i_op->readlink))
++ return -EINVAL;
++
++ sb = dentry->d_sb;
++ if (!test_ro(sb, bindex, dentry->d_inode)) {
++ touch_atime(sbr_mnt(sb, bindex), hidden_dentry);
++ dentry->d_inode->i_atime = hidden_dentry->d_inode->i_atime;
++ }
++ return hidden_dentry->d_inode->i_op->readlink
++ (hidden_dentry, buf, bufsiz);
++}
++
++static int aufs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
++{
++ int err;
++
++ LKTRTrace("%.*s, %d\n", DLNPair(dentry), bufsiz);
++
++ aufs_read_lock(dentry, AUFS_I_RLOCK);
++ err = hidden_readlink(dentry, dbstart(dentry), buf, bufsiz);
++ //err = -1;
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++ TraceErr(err);
++ return err;
++}
++
++static void *aufs_follow_link(struct dentry *dentry, struct nameidata *nd)
++{
++ int err;
++ char *buf;
++ mm_segment_t old_fs;
++
++ LKTRTrace("%.*s, nd %.*s\n", DLNPair(dentry), DLNPair(nd->dentry));
++
++ err = -ENOMEM;
++ buf = __getname();
++ //buf = NULL;
++ if (unlikely(!buf))
++ goto out;
++
++ aufs_read_lock(dentry, AUFS_I_RLOCK);
++ old_fs = get_fs();
++ set_fs(KERNEL_DS);
++ err = hidden_readlink(dentry, dbstart(dentry), (char __user *)buf,
++ PATH_MAX);
++ //err = -1;
++ set_fs(old_fs);
++ aufs_read_unlock(dentry, AUFS_I_RLOCK);
++
++ if (err >= 0) {
++ buf[err] = 0;
++ /* will be freed by put_link */
++ nd_set_link(nd, buf);
++ return NULL; /* success */
++ }
++ __putname(buf);
++
++ out:
++ path_release(nd);
++ TraceErr(err);
++ return ERR_PTR(err);
++}
++
++static void aufs_put_link(struct dentry *dentry, struct nameidata *nd,
++ void *cookie)
++{
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ __putname(nd_get_link(nd));
++}
++
++/* ---------------------------------------------------------------------- */
++#if 0 // comment
++struct inode_operations {
++ int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
++ struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
++ int (*link) (struct dentry *,struct inode *,struct dentry *);
++ int (*unlink) (struct inode *,struct dentry *);
++ int (*symlink) (struct inode *,struct dentry *,const char *);
++ int (*mkdir) (struct inode *,struct dentry *,int);
++ int (*rmdir) (struct inode *,struct dentry *);
++ int (*mknod) (struct inode *,struct dentry *,int,dev_t);
++ int (*rename) (struct inode *, struct dentry *,
++ struct inode *, struct dentry *);
++ int (*readlink) (struct dentry *, char __user *,int);
++ void * (*follow_link) (struct dentry *, struct nameidata *);
++ void (*put_link) (struct dentry *, struct nameidata *, void *);
++ void (*truncate) (struct inode *);
++ int (*permission) (struct inode *, int, struct nameidata *);
++ int (*setattr) (struct dentry *, struct iattr *);
++ int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
++ int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
++ ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
++ ssize_t (*listxattr) (struct dentry *, char *, size_t);
++ int (*removexattr) (struct dentry *, const char *);
++ void (*truncate_range)(struct inode *, loff_t, loff_t);
++};
++#endif
++
++struct inode_operations aufs_symlink_iop = {
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++ .readlink = aufs_readlink,
++ .follow_link = aufs_follow_link,
++ .put_link = aufs_put_link
++};
++
++//i_op_add.c
++int aufs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
++int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
++int aufs_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd);
++int aufs_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry);
++int aufs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
++
++//i_op_del.c
++int aufs_unlink(struct inode *dir, struct dentry *dentry);
++int aufs_rmdir(struct inode *dir, struct dentry *dentry);
++
++// i_op_ren.c
++int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry);
++
++struct inode_operations aufs_dir_iop = {
++ .create = aufs_create,
++ .lookup = aufs_lookup,
++ .link = aufs_link,
++ .unlink = aufs_unlink,
++ .symlink = aufs_symlink,
++ .mkdir = aufs_mkdir,
++ .rmdir = aufs_rmdir,
++ .mknod = aufs_mknod,
++ .rename = aufs_rename,
++
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++#if 0 // xattr
++ .setxattr = aufs_setxattr,
++ .getxattr = aufs_getxattr,
++ .listxattr = aufs_listxattr,
++ .removexattr = aufs_removexattr
++#endif
++};
++
++struct inode_operations aufs_iop = {
++ .permission = aufs_permission,
++ .setattr = aufs_setattr,
++
++#if 0 // xattr
++ .setxattr = aufs_setxattr,
++ .getxattr = aufs_getxattr,
++ .listxattr = aufs_listxattr,
++ .removexattr = aufs_removexattr
++#endif
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/i_op_add.c linux-2.6.22.1/fs/aufs/i_op_add.c
+--- linux-2.6.22.1.oorig/fs/aufs/i_op_add.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/i_op_add.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,621 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_add.c,v 1.37 2007/05/07 03:46:08 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++/*
++ * final procedure of adding a new entry, except link(2).
++ * remove whiteout, instantiate, copyup the parent dir's times and size
++ * and update version.
++ * if it failed, re-create the removed whiteout.
++ */
++static int epilog(struct dentry *wh_dentry, struct dentry *dentry)
++{
++ int err, rerr;
++ aufs_bindex_t bwh;
++ struct inode *inode, *dir;
++ struct dentry *wh;
++ struct lkup_args lkup;
++
++ LKTRTrace("wh %p, %.*s\n", wh_dentry, DLNPair(dentry));
++
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ bwh = -1;
++ if (wh_dentry) {
++ bwh = dbwh(dentry);
++ err = au_unlink_wh_dentry(wh_dentry->d_parent->d_inode,
++ wh_dentry, dentry, lkup.dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ }
++
++ inode = au_new_inode(dentry);
++ //inode = ERR_PTR(-1);
++ if (!IS_ERR(inode)) {
++ d_instantiate(dentry, inode);
++ dir = dentry->d_parent->d_inode;
++ /* or always cpup dir mtime? */
++ if (ibstart(dir) == dbstart(dentry))
++ au_cpup_attr_timesizes(dir);
++ dir->i_version++;
++ return 0; /* success */
++ }
++
++ err = PTR_ERR(inode);
++ if (!wh_dentry)
++ goto out;
++
++ /* revert */
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bwh);
++ wh = simple_create_wh(dentry, bwh, wh_dentry->d_parent, &lkup);
++ //wh = ERR_PTR(-1);
++ rerr = PTR_ERR(wh);
++ if (!IS_ERR(wh)) {
++ dput(wh);
++ goto out;
++ }
++ IOErr("%.*s reverting whiteout failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * initial procedure of adding a new entry.
++ * prepare writable branch and the parent dir, lock it,
++ * lookup whiteout for the new entry.
++ */
++static struct dentry *
++lock_hdir_lkup_wh(struct dentry *dentry, struct dtime *dt,
++ struct dentry *src_dentry, int do_lock_srcdir)
++{
++ struct dentry *wh_dentry, *parent, *hidden_parent;
++ int err;
++ aufs_bindex_t bstart, bcpup;
++ struct inode *dir, *h_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, src %p\n", DLNPair(dentry), src_dentry);
++
++ parent = dentry->d_parent;
++ bstart = dbstart(dentry);
++ bcpup = err = wr_dir(dentry, 1, src_dentry, -1, do_lock_srcdir);
++ //err = -1;
++ wh_dentry = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out;
++
++ dir = parent->d_inode;
++ hidden_parent = au_h_dptr_i(parent, bcpup);
++ h_dir = hidden_parent->d_inode;
++ hdir_lock(h_dir, dir, bcpup);
++ if (dt)
++ dtime_store(dt, parent, hidden_parent);
++ if (/* bcpup != bstart || */ bcpup != dbwh(dentry))
++ return NULL; /* success */
++
++ lkup.nfsmnt = au_nfsmnt(parent->d_sb, bcpup);
++ lkup.dlgt = need_dlgt(parent->d_sb);
++ wh_dentry = lkup_wh(hidden_parent, &dentry->d_name, &lkup);
++ //wh_dentry = ERR_PTR(-1);
++ if (IS_ERR(wh_dentry))
++ hdir_unlock(h_dir, dir, bcpup);
++
++ out:
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++enum {Mknod, Symlink, Creat};
++struct simple_arg {
++ int type;
++ union {
++ struct {
++ int mode;
++ struct nameidata *nd;
++ } c;
++ struct {
++ const char *symname;
++ } s;
++ struct {
++ int mode;
++ dev_t dev;
++ } m;
++ } u;
++};
++
++static int add_simple(struct inode *dir, struct dentry *dentry,
++ struct simple_arg *arg)
++{
++ int err, dlgt;
++ struct dentry *hidden_dentry, *hidden_parent, *wh_dentry, *parent;
++ struct inode *hidden_dir;
++ struct dtime dt;
++
++ LKTRTrace("type %d, %.*s\n", arg->type, DLNPair(dentry));
++ IMustLock(dir);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, /*src_dentry*/NULL,
++ /*do_lock_srcdir*/0);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ dlgt = need_dlgt(dir->i_sb);
++
++#if 1 // partial testing
++ switch (arg->type) {
++ case Creat:
++#if 0
++ if (arg->u.c.nd) {
++ struct nameidata fake_nd;
++ fake_nd = *arg->u.c.nd;
++ fake_nd.dentry = dget(hidden_parent);
++ fake_nd.mnt = sbr_mnt(dentry->d_sb, dbstart(dentry));
++ mntget(fake_nd.mnt);
++ err = vfsub_create(hidden_dir, hidden_dentry,
++ arg->u.c.mode, &fake_nd, dlgt);
++ path_release(&fake_nd);
++ } else
++#endif
++ err = vfsub_create(hidden_dir, hidden_dentry,
++ arg->u.c.mode, NULL, dlgt);
++ break;
++ case Symlink:
++ err = vfsub_symlink(hidden_dir, hidden_dentry,
++ arg->u.s.symname, S_IALLUGO, dlgt);
++ break;
++ case Mknod:
++ err = vfsub_mknod(hidden_dir, hidden_dentry,
++ arg->u.m.mode, arg->u.m.dev, dlgt);
++ break;
++ default:
++ BUG();
++ }
++#else
++ err = -1;
++#endif
++ if (!err)
++ err = epilog(wh_dentry, dentry);
++ //err = -1;
++
++ /* revert */
++ if (unlikely(err && hidden_dentry->d_inode)) {
++ int rerr;
++ rerr = vfsub_unlink(hidden_dir, hidden_dentry, dlgt);
++ //rerr = -1;
++ if (rerr) {
++ IOErr("%.*s revert failure(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++ d_drop(dentry);
++ }
++
++ hdir_unlock(hidden_dir, dir, dbstart(dentry));
++ dput(wh_dentry);
++
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
++{
++ struct simple_arg arg = {
++ .type = Mknod,
++ .u.m = {.mode = mode, .dev = dev}
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
++{
++ struct simple_arg arg = {
++ .type = Symlink,
++ .u.s.symname = symname
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++int aufs_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd)
++{
++ struct simple_arg arg = {
++ .type = Creat,
++ .u.c = {.mode = mode, .nd = nd}
++ };
++ return add_simple(dir, dentry, &arg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct link_arg {
++ aufs_bindex_t bdst, bsrc;
++ int issamedir, dlgt;
++ struct dentry *src_parent, *parent, *hidden_dentry;
++ struct inode *hidden_dir, *inode;
++};
++
++static int cpup_before_link(struct dentry *src_dentry, struct inode *dir,
++ struct link_arg *a)
++{
++ int err;
++ unsigned int flags;
++ struct inode *hi, *hdir = NULL, *src_dir;
++
++ TraceEnter();
++
++ err = 0;
++ flags = au_flags_cpup(CPUP_DTIME, a->parent);
++ src_dir = a->src_parent->d_inode;
++ if (!a->issamedir) {
++ // todo: dead lock?
++ di_read_lock_parent2(a->src_parent, AUFS_I_RLOCK);
++ // this temporary unlock/lock is safe
++ hdir_unlock(a->hidden_dir, dir, a->bdst);
++ err = test_and_cpup_dirs(src_dentry, a->bdst, a->parent);
++ //err = -1;
++ if (!err) {
++ hdir = au_h_iptr_i(src_dir, a->bdst);
++ hdir_lock(hdir, src_dir, a->bdst);
++ flags = au_flags_cpup(CPUP_DTIME, a->src_parent);
++ }
++ }
++
++ if (!err) {
++ hi = au_h_dptr(src_dentry)->d_inode;
++ hi_lock_child(hi);
++ err = sio_cpup_simple(src_dentry, a->bdst, -1, flags);
++ //err = -1;
++ i_unlock(hi);
++ }
++
++ if (!a->issamedir) {
++ if (hdir)
++ hdir_unlock(hdir, src_dir, a->bdst);
++ hdir_lock(a->hidden_dir, dir, a->bdst);
++ di_read_unlock(a->src_parent, AUFS_I_RLOCK);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int cpup_or_link(struct dentry *src_dentry, struct link_arg *a)
++{
++ int err;
++ struct inode *inode, *h_inode, *h_dst_inode;
++ struct dentry *h_dentry;
++ aufs_bindex_t bstart;
++ struct super_block *sb;
++
++ TraceEnter();
++
++ sb = src_dentry->d_sb;
++ inode = src_dentry->d_inode;
++ h_dentry = au_h_dptr(src_dentry);
++ h_inode = h_dentry->d_inode;
++ bstart = ibstart(inode);
++ h_dst_inode = NULL;
++ if (bstart <= a->bdst)
++ h_dst_inode = au_h_iptr_i(inode, a->bdst);
++
++ if (!h_dst_inode) {
++ /* copyup src_dentry as the name of dentry. */
++ set_dbstart(src_dentry, a->bdst);
++ set_h_dptr(src_dentry, a->bdst, dget(a->hidden_dentry));
++ hi_lock_child(h_inode);
++ err = sio_cpup_single(src_dentry, a->bdst, a->bsrc, -1,
++ au_flags_cpup(!CPUP_DTIME, a->parent));
++ //err = -1;
++ i_unlock(h_inode);
++ set_h_dptr(src_dentry, a->bdst, NULL);
++ set_dbstart(src_dentry, a->bsrc);
++ } else {
++ /* the inode of src_dentry already exists on a.bdst branch */
++ h_dentry = d_find_alias(h_dst_inode);
++ if (h_dentry) {
++ err = vfsub_link(h_dentry, a->hidden_dir,
++ a->hidden_dentry, a->dlgt);
++ dput(h_dentry);
++ } else {
++ IOErr("no dentry found for i%lu on b%d\n",
++ h_dst_inode->i_ino, a->bdst);
++ err = -EIO;
++ }
++ }
++
++ if (!err)
++ append_plink(sb, a->inode, a->hidden_dentry, a->bdst);
++
++ TraceErr(err);
++ return err;
++}
++
++int aufs_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry)
++{
++ int err, rerr;
++ struct dentry *hidden_parent, *wh_dentry, *hidden_src_dentry;
++ struct dtime dt;
++ struct link_arg a;
++ struct super_block *sb;
++
++ LKTRTrace("src %.*s, i%lu, dst %.*s\n",
++ DLNPair(src_dentry), dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ IMustLock(src_dentry->d_inode);
++
++ aufs_read_and_write_lock2(dentry, src_dentry, /*isdir*/0);
++ a.src_parent = src_dentry->d_parent;
++ a.parent = dentry->d_parent;
++ a.issamedir = (a.src_parent == a.parent);
++ di_write_lock_parent(a.parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, src_dentry, !a.issamedir);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ a.inode = src_dentry->d_inode;
++ a.hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = a.hidden_dentry->d_parent;
++ a.hidden_dir = hidden_parent->d_inode;
++ IMustLock(a.hidden_dir);
++
++ err = 0;
++ sb = dentry->d_sb;
++ a.dlgt = need_dlgt(sb);
++
++ //todo: minor optimize, their sb may be same while their bindex differs.
++ a.bsrc = dbstart(src_dentry);
++ a.bdst = dbstart(dentry);
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ if (unlikely(!au_flag_test(sb, AuFlag_PLINK))) {
++ /*
++ * copyup src_dentry to the branch we process,
++ * and then link(2) to it.
++ * gave up 'pseudo link by cpup' approach,
++ * since nlink may be one and some applications will not work.
++ */
++ if (a.bdst < a.bsrc
++ /* && hidden_src_dentry->d_sb != a.hidden_dentry->d_sb */)
++ err = cpup_before_link(src_dentry, dir, &a);
++ if (!err) {
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ err = vfsub_link(hidden_src_dentry, a.hidden_dir,
++ a.hidden_dentry, a.dlgt);
++ //err = -1;
++ }
++ } else {
++ if (a.bdst < a.bsrc
++ /* && hidden_src_dentry->d_sb != a.hidden_dentry->d_sb */)
++ err = cpup_or_link(src_dentry, &a);
++ else {
++ hidden_src_dentry = au_h_dptr(src_dentry);
++ err = vfsub_link(hidden_src_dentry, a.hidden_dir,
++ a.hidden_dentry, a.dlgt);
++ //err = -1;
++ }
++ }
++ if (unlikely(err))
++ goto out_unlock;
++ if (wh_dentry) {
++ err = au_unlink_wh_dentry(a.hidden_dir, wh_dentry, dentry,
++ a.dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_revert;
++ }
++
++ dir->i_version++;
++ if (ibstart(dir) == dbstart(dentry))
++ au_cpup_attr_timesizes(dir);
++ if (!d_unhashed(a.hidden_dentry)
++ /* || hidden_old_inode->i_nlink <= nlink */
++ /* || SB_NFS(hidden_src_dentry->d_sb) */) {
++ dentry->d_inode = igrab(a.inode);
++ d_instantiate(dentry, a.inode);
++ a.inode->i_nlink++;
++ a.inode->i_ctime = dir->i_ctime;
++ } else
++ /* nfs case (< 2.6.15) */
++ d_drop(dentry);
++#if 0
++ au_debug_on();
++ DbgInode(a.inode);
++ au_debug_off();
++ {
++ aufs_bindex_t i;
++ for (i = ibstart(a.inode); i <= ibend(a.inode); i++) {
++ struct xino xino;
++ struct inode *hi;
++ hi = au_h_iptr_i(a.inode, i);
++ if (hi) {
++ xino_read(sb, i, hi->i_ino, &xino);
++ Dbg("hi%lu, i%lu\n", hi->i_ino, xino.ino);
++ }
++ }
++ }
++#endif
++ goto out_unlock; /* success */
++
++ out_revert:
++#if 0 // remove
++ if (d_unhashed(a.hidden_dentry)) {
++ /* hardlink on nfs (< 2.6.15) */
++ struct dentry *d;
++ const struct qstr *name = &a.hidden_dentry->d_name;
++ DEBUG_ON(a.hidden_dentry->d_parent->d_inode != a.hidden_dir);
++ // do not superio.
++ d = lkup_one(name->name, a.hidden_dentry->d_parent, name->len,
++ au_nfsmnt(sb, a.bdst)??, need_dlgt(sb));
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d))
++ goto out_rerr;
++ dput(a.hidden_dentry);
++ a.hidden_dentry = d;
++ DEBUG_ON(!d->d_inode);
++ }
++#endif
++ rerr = vfsub_unlink(a.hidden_dir, a.hidden_dentry, a.dlgt);
++ //rerr = -1;
++ if (!rerr)
++ goto out_dt;
++// out_rerr:
++ IOErr("%.*s reverting failed(%d, %d)\n", DLNPair(dentry), err, rerr);
++ err = -EIO;
++ out_dt:
++ d_drop(dentry);
++ dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
++ out_unlock:
++ hdir_unlock(a.hidden_dir, dir, a.bdst);
++ dput(wh_dentry);
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(a.parent);
++ aufs_read_and_write_unlock2(dentry, src_dentry);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
++{
++ int err, rerr, diropq, dlgt;
++ struct dentry *hidden_dentry, *hidden_parent, *wh_dentry, *parent,
++ *opq_dentry;
++ struct inode *hidden_dir, *hidden_inode;
++ struct dtime dt;
++ aufs_bindex_t bindex;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s, mode 0%o\n", dir->i_ino, DLNPair(dentry), mode);
++ IMustLock(dir);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ wh_dentry = lock_hdir_lkup_wh(dentry, &dt, /*src_dentry*/NULL,
++ /*do_lock_srcdir*/0);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ sb = dentry->d_sb;
++ bindex = dbstart(dentry);
++ hidden_dentry = au_h_dptr(dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ dlgt = need_dlgt(sb);
++
++ err = vfsub_mkdir(hidden_dir, hidden_dentry, mode, dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_unlock;
++ hidden_inode = hidden_dentry->d_inode;
++
++ /* make the dir opaque */
++ diropq = 0;
++ if (unlikely(wh_dentry || au_flag_test(sb, AuFlag_ALWAYS_DIROPQ))) {
++ hi_lock_child(hidden_inode);
++ opq_dentry = create_diropq(dentry, bindex, dlgt);
++ //opq_dentry = ERR_PTR(-1);
++ i_unlock(hidden_inode);
++ err = PTR_ERR(opq_dentry);
++ if (IS_ERR(opq_dentry))
++ goto out_dir;
++ dput(opq_dentry);
++ diropq = 1;
++ }
++
++ err = epilog(wh_dentry, dentry);
++ //err = -1;
++ if (!err) {
++ dir->i_nlink++;
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ if (unlikely(diropq)) {
++ LKTRLabel(revert opq);
++ hi_lock_child(hidden_inode);
++ rerr = remove_diropq(dentry, bindex, dlgt);
++ //rerr = -1;
++ i_unlock(hidden_inode);
++ if (rerr) {
++ IOErr("%.*s reverting diropq failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ }
++
++ out_dir:
++ LKTRLabel(revert dir);
++ rerr = vfsub_rmdir(hidden_dir, hidden_dentry, dlgt);
++ //rerr = -1;
++ if (rerr) {
++ IOErr("%.*s reverting dir failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ err = -EIO;
++ }
++ d_drop(dentry);
++ dtime_revert(&dt, /*fake flag*/CPUP_LOCKED_GHDIR);
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ out:
++ if (unlikely(err)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/i_op_del.c linux-2.6.22.1/fs/aufs/i_op_del.c
+--- linux-2.6.22.1.oorig/fs/aufs/i_op_del.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/i_op_del.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,414 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_del.c,v 1.35 2007/05/14 03:41:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++/* returns,
++ * 0: wh is unnecessary
++ * plus: wh is necessary
++ * minus: error
++ */
++int wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dentry *locked)
++{
++ int need_wh, err;
++ aufs_bindex_t bstart;
++ struct dentry *hidden_dentry;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, isdir %d, *bcpup %d, locked %p\n",
++ DLNPair(dentry), isdir, *bcpup, locked);
++ sb = dentry->d_sb;
++
++ bstart = dbstart(dentry);
++ LKTRTrace("bcpup %d, bstart %d\n", *bcpup, bstart);
++ hidden_dentry = au_h_dptr(dentry);
++ if (*bcpup < 0) {
++ *bcpup = bstart;
++ if (test_ro(sb, bstart, dentry->d_inode)) {
++ *bcpup = err = find_rw_parent_br(dentry, bstart);
++ //*bcpup = err = find_rw_br(sb, bstart);
++ //err = -1;
++ if (unlikely(err < 0))
++ goto out;
++ }
++ } else {
++ /* braces are added to stop a warning */
++ DEBUG_ON(bstart < *bcpup
++ || test_ro(sb, *bcpup, dentry->d_inode));
++ }
++ LKTRTrace("bcpup %d, bstart %d\n", *bcpup, bstart);
++
++ if (*bcpup != bstart) {
++ err = cpup_dirs(dentry, *bcpup, locked);
++ //err = -1;
++ if (unlikely(err))
++ goto out;
++ need_wh = 1;
++ } else {
++ //struct nameidata nd;
++ aufs_bindex_t old_bend, new_bend, bdiropq = -1;
++ old_bend = dbend(dentry);
++ if (isdir) {
++ bdiropq = dbdiropq(dentry);
++ set_dbdiropq(dentry, -1);
++ }
++ err = need_wh = lkup_dentry(dentry, bstart + 1, /*type*/0);
++ //err = -1;
++ if (isdir)
++ set_dbdiropq(dentry, bdiropq);
++ if (unlikely(err < 0))
++ goto out;
++ new_bend = dbend(dentry);
++ if (!need_wh && old_bend != new_bend) {
++ set_h_dptr(dentry, new_bend, NULL);
++ set_dbend(dentry, old_bend);
++#if 0
++ } else if (!au_h_dptr_i(dentry, new_bend)->d_inode) {
++ LKTRTrace("negative\n");
++ set_h_dptr(dentry, new_bend, NULL);
++ set_dbend(dentry, old_bend);
++ need_wh = 0;
++#endif
++ }
++ }
++ LKTRTrace("need_wh %d\n", need_wh);
++ err = need_wh;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static struct dentry *
++lock_hdir_create_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dtime *dt)
++{
++ struct dentry *wh_dentry;
++ int err, need_wh;
++ struct dentry *hidden_parent, *parent;
++ struct inode *dir, *h_dir;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, isdir %d\n", DLNPair(dentry), isdir);
++
++ err = need_wh = wr_dir_need_wh(dentry, isdir, bcpup, NULL);
++ //err = -1;
++ wh_dentry = ERR_PTR(err);
++ if (unlikely(err < 0))
++ goto out;
++
++ parent = dentry->d_parent;
++ dir = parent->d_inode;
++ hidden_parent = au_h_dptr_i(parent, *bcpup);
++ h_dir = hidden_parent->d_inode;
++ hdir_lock(h_dir, dir, *bcpup);
++ dtime_store(dt, parent, hidden_parent);
++ if (!need_wh)
++ return NULL; /* success, no need to create whiteout */
++
++ lkup.nfsmnt = au_nfsmnt(dentry->d_sb, *bcpup);
++ lkup.dlgt = need_dlgt(dentry->d_sb);
++ wh_dentry = simple_create_wh(dentry, *bcpup, hidden_parent, &lkup);
++ //wh_dentry = ERR_PTR(-1);
++ if (!IS_ERR(wh_dentry))
++ goto out; /* success */
++ /* returns with the parent is locked and wh_dentry is DGETed */
++
++ hdir_unlock(h_dir, dir, *bcpup);
++
++ out:
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++static int renwh_and_rmdir(struct dentry *dentry, aufs_bindex_t bindex,
++ struct aufs_nhash *whlist, struct inode *dir)
++{
++ int rmdir_later, err;
++ struct dentry *hidden_dentry;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++
++ err = rename_whtmp(dentry, bindex);
++ //err = -1;
++#if 0
++ //todo: bug
++ if (unlikely(err)) {
++ au_direval_inc(dentry->d_parent);
++ return err;
++ }
++#endif
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!au_is_nfs(hidden_dentry->d_sb)) {
++ const int dirwh = stosi(dentry->d_sb)->si_dirwh;
++ rmdir_later = (dirwh <= 1);
++ if (!rmdir_later)
++ rmdir_later = is_longer_wh(whlist, bindex, dirwh);
++ if (rmdir_later)
++ return rmdir_later;
++ }
++
++ err = rmdir_whtmp(hidden_dentry, whlist, bindex, dir, dentry->d_inode);
++ //err = -1;
++ if (unlikely(err)) {
++ IOErr("rmdir %.*s, b%d failed, %d. ignored\n",
++ DLNPair(hidden_dentry), bindex, err);
++ err = 0;
++ }
++ TraceErr(err);
++ return err;
++}
++
++static void epilog(struct inode *dir, struct dentry *dentry,
++ aufs_bindex_t bindex)
++{
++ d_drop(dentry);
++ dentry->d_inode->i_ctime = dir->i_ctime;
++ if (atomic_read(&dentry->d_count) == 1) {
++ set_h_dptr(dentry, dbstart(dentry), NULL);
++ au_update_dbstart(dentry);
++ }
++ if (ibstart(dir) == bindex)
++ au_cpup_attr_timesizes(dir);
++ dir->i_version++;
++}
++
++static int do_revert(int err, struct dentry *wh_dentry, struct dentry *dentry,
++ aufs_bindex_t bwh, struct dtime *dt, int dlgt)
++{
++ int rerr;
++
++ rerr = au_unlink_wh_dentry(wh_dentry->d_parent->d_inode, wh_dentry,
++ dentry, dlgt);
++ //rerr = -1;
++ if (!rerr) {
++ set_dbwh(dentry, bwh);
++ dtime_revert(dt, !CPUP_LOCKED_GHDIR);
++ return 0;
++ }
++
++ IOErr("%.*s reverting whiteout failed(%d, %d)\n",
++ DLNPair(dentry), err, rerr);
++ return -EIO;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int aufs_unlink(struct inode *dir, struct dentry *dentry)
++{
++ int err, dlgt;
++ struct inode *inode, *hidden_dir;
++ struct dentry *parent, *wh_dentry, *hidden_dentry, *hidden_parent;
++ struct dtime dt;
++ aufs_bindex_t bwh, bindex, bstart;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ inode = dentry->d_inode;
++ if (unlikely(!inode))
++ return -ENOENT; // possible?
++ IMustLock(inode);
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++
++ bstart = dbstart(dentry);
++ bwh = dbwh(dentry);
++ bindex = -1;
++ wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/0, &bindex, &dt);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ sb = dir->i_sb;
++ dlgt = need_dlgt(sb);
++ hidden_dentry = au_h_dptr(dentry);
++ dget(hidden_dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++
++ if (bindex == bstart) {
++ err = vfsub_unlink(hidden_dir, hidden_dentry, dlgt);
++ //err = -1;
++ } else {
++ DEBUG_ON(!wh_dentry);
++ hidden_parent = wh_dentry->d_parent;
++ DEBUG_ON(hidden_parent != au_h_dptr_i(parent, bindex));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ err = 0;
++ }
++
++ if (!err) {
++ inode->i_nlink--;
++ epilog(dir, dentry, bindex);
++#if 0
++ xino_write0(sb, bstart, hidden_dentry->d_inode->i_ino);
++ /* ignore this error */
++#endif
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ if (wh_dentry) {
++ int rerr;
++ rerr = do_revert(err, wh_dentry, dentry, bwh, &dt, dlgt);
++ if (rerr)
++ err = rerr;
++ }
++
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ dput(hidden_dentry);
++ out:
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ TraceErr(err);
++ return err;
++}
++
++int aufs_rmdir(struct inode *dir, struct dentry *dentry)
++{
++ int err, rmdir_later;
++ struct inode *inode, *hidden_dir;
++ struct dentry *parent, *wh_dentry, *hidden_dentry, *hidden_parent;
++ struct dtime dt;
++ aufs_bindex_t bwh, bindex, bstart;
++ struct rmdir_whtmp_arg *arg;
++ struct aufs_nhash *whlist;
++ struct super_block *sb;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++ IMustLock(dir);
++ inode = dentry->d_inode;
++ if (unlikely(!inode))
++ return -ENOENT; // possible?
++ IMustLock(inode);
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++
++ err = -ENOMEM;
++ arg = kmalloc(sizeof(*arg), GFP_KERNEL);
++ //arg = NULL;
++ if (unlikely(!arg))
++ goto out_whlist;
++
++ aufs_read_lock(dentry, AUFS_D_WLOCK);
++ parent = dentry->d_parent;
++ di_write_lock_parent(parent);
++ err = test_empty(dentry, whlist);
++ //err = -1;
++ if (unlikely(err))
++ goto out_arg;
++
++ bstart = dbstart(dentry);
++ bwh = dbwh(dentry);
++ bindex = -1;
++ wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/ 1, &bindex, &dt);
++ //wh_dentry = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out_arg;
++
++ hidden_dentry = au_h_dptr(dentry);
++ dget(hidden_dentry);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++
++ rmdir_later = 0;
++ if (bindex == bstart) {
++ IMustLock(hidden_dir);
++ err = renwh_and_rmdir(dentry, bstart, whlist, dir);
++ //err = -1;
++ if (err > 0) {
++ rmdir_later = err;
++ err = 0;
++ }
++ } else {
++ DEBUG_ON(!wh_dentry);
++ hidden_parent = wh_dentry->d_parent;
++ DEBUG_ON(hidden_parent != au_h_dptr_i(parent, bindex));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ err = 0;
++ }
++
++ sb = dentry->d_sb;
++ if (!err) {
++ //aufs_bindex_t bi, bend;
++
++ au_reset_hinotify(inode, /*flags*/0);
++ inode->i_nlink = 0;
++ set_dbdiropq(dentry, -1);
++ epilog(dir, dentry, bindex);
++
++ if (rmdir_later) {
++ kick_rmdir_whtmp(hidden_dentry, whlist, bstart, dir,
++ inode, arg);
++ arg = NULL;
++ }
++
++#if 0
++ bend = dbend(dentry);
++ for (bi = bstart; bi <= bend; bi++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(dentry, bi);
++ if (hd && hd->d_inode)
++ xino_write0(sb, bi, hd->d_inode->i_ino);
++ /* ignore this error */
++ }
++#endif
++
++ goto out_unlock; /* success */
++ }
++
++ /* revert */
++ LKTRLabel(revert);
++ if (wh_dentry) {
++ int rerr;
++ rerr = do_revert(err, wh_dentry, dentry, bwh, &dt,
++ need_dlgt(sb));
++ if (rerr)
++ err = rerr;
++ }
++
++ out_unlock:
++ hdir_unlock(hidden_dir, dir, bindex);
++ dput(wh_dentry);
++ dput(hidden_dentry);
++ out_arg:
++ di_write_unlock(parent);
++ aufs_read_unlock(dentry, AUFS_D_WLOCK);
++ kfree(arg);
++ out_whlist:
++ nhash_del(whlist);
++ out:
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/i_op_ren.c linux-2.6.22.1/fs/aufs/i_op_ren.c
+--- linux-2.6.22.1.oorig/fs/aufs/i_op_ren.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/i_op_ren.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,637 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: i_op_ren.c,v 1.39 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++#include "aufs.h"
++
++enum {SRC, DST};
++struct rename_args {
++ struct dentry *hidden_dentry[2], *parent[2], *hidden_parent[2];
++ struct aufs_nhash whlist;
++ aufs_bindex_t btgt, bstart[2];
++ struct super_block *sb;
++
++ unsigned int isdir:1;
++ unsigned int issamedir:1;
++ unsigned int whsrc:1;
++ unsigned int whdst:1;
++ unsigned int dlgt:1;
++} __attribute__((aligned(sizeof(long))));
++
++static int do_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry,
++ struct rename_args *a)
++{
++ int err, need_diropq, bycpup, rerr;
++ struct rmdir_whtmp_arg *tharg;
++ struct dentry *wh_dentry[2], *hidden_dst, *hg_parent;
++ struct inode *hidden_dir[2];
++ aufs_bindex_t bindex, bend;
++ unsigned int flags;
++ struct lkup_args lkup = {.dlgt = a->dlgt};
++
++ LKTRTrace("%.*s/%.*s, %.*s/%.*s, "
++ "hd{%p, %p}, hp{%p, %p}, wh %p, btgt %d, bstart{%d, %d}, "
++ "flags{%d, %d, %d, %d}\n",
++ DLNPair(a->parent[SRC]), DLNPair(src_dentry),
++ DLNPair(a->parent[DST]), DLNPair(dentry),
++ a->hidden_dentry[SRC], a->hidden_dentry[DST],
++ a->hidden_parent[SRC], a->hidden_parent[DST],
++ &a->whlist, a->btgt,
++ a->bstart[SRC], a->bstart[DST],
++ a->isdir, a->issamedir, a->whsrc, a->whdst);
++ hidden_dir[SRC] = a->hidden_parent[SRC]->d_inode;
++ hidden_dir[DST] = a->hidden_parent[DST]->d_inode;
++ IMustLock(hidden_dir[SRC]);
++ IMustLock(hidden_dir[DST]);
++
++ /* prepare workqueue arg */
++ hidden_dst = NULL;
++ tharg = NULL;
++ if (a->isdir && a->hidden_dentry[DST]->d_inode) {
++ err = -ENOMEM;
++ tharg = kmalloc(sizeof(*tharg), GFP_KERNEL);
++ //tharg = NULL;
++ if (unlikely(!tharg))
++ goto out;
++ hidden_dst = dget(a->hidden_dentry[DST]);
++ }
++
++ wh_dentry[SRC] = wh_dentry[DST] = NULL;
++ lkup.nfsmnt = au_nfsmnt(a->sb, a->btgt);
++ /* create whiteout for src_dentry */
++ if (a->whsrc) {
++ wh_dentry[SRC] = simple_create_wh(src_dentry, a->btgt,
++ a->hidden_parent[SRC], &lkup);
++ //wh_dentry[SRC] = ERR_PTR(-1);
++ err = PTR_ERR(wh_dentry[SRC]);
++ if (IS_ERR(wh_dentry[SRC]))
++ goto out_tharg;
++ }
++
++ /* lookup whiteout for dentry */
++ if (a->whdst) {
++ struct dentry *d;
++ d = lkup_wh(a->hidden_parent[DST], &dentry->d_name, &lkup);
++ //d = ERR_PTR(-1);
++ err = PTR_ERR(d);
++ if (IS_ERR(d))
++ goto out_whsrc;
++ if (!d->d_inode)
++ dput(d);
++ else
++ wh_dentry[DST] = d;
++ }
++
++ /* rename dentry to tmpwh */
++ if (tharg) {
++ err = rename_whtmp(dentry, a->btgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_whdst;
++ set_h_dptr(dentry, a->btgt, NULL);
++ err = lkup_neg(dentry, a->btgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_whtmp;
++ a->hidden_dentry[DST] = au_h_dptr_i(dentry, a->btgt);
++ }
++
++ /* cpup src */
++ if (a->hidden_dentry[DST]->d_inode && a->bstart[SRC] != a->btgt) {
++ flags = au_flags_cpup(!CPUP_DTIME, a->parent[SRC]);
++ hg_parent = a->hidden_parent[SRC]->d_parent;
++ if (!(flags & CPUP_LOCKED_GHDIR)
++ && hg_parent == a->hidden_parent[DST])
++ flags |= CPUP_LOCKED_GHDIR;
++
++ hi_lock_child(a->hidden_dentry[SRC]->d_inode);
++ err = sio_cpup_simple(src_dentry, a->btgt, -1, flags);
++ //err = -1; // untested dir
++ i_unlock(a->hidden_dentry[SRC]->d_inode);
++ if (unlikely(err))
++ goto out_whtmp;
++ }
++
++#if 0
++ /* clear the target ino in xino */
++ LKTRTrace("dir %d, dst inode %p\n", a->isdir, a->hidden_dentry[DST]->d_inode);
++ if (a->isdir && a->hidden_dentry[DST]->d_inode) {
++ Dbg("here\n");
++ err = xino_write(a->sb, a->btgt,
++ a->hidden_dentry[DST]->d_inode->i_ino, 0);
++ if (unlikely(err))
++ goto out_whtmp;
++ }
++#endif
++
++ /* rename by vfs_rename or cpup */
++ need_diropq = a->isdir
++ && (wh_dentry[DST]
++ || dbdiropq(dentry) == a->btgt
++ || au_flag_test(a->sb, AuFlag_ALWAYS_DIROPQ));
++ bycpup = 0;
++ if (dbstart(src_dentry) == a->btgt) {
++ if (need_diropq && dbdiropq(src_dentry) == a->btgt)
++ need_diropq = 0;
++ err = vfsub_rename(hidden_dir[SRC], au_h_dptr(src_dentry),
++ hidden_dir[DST], a->hidden_dentry[DST],
++ a->dlgt);
++ //err = -1;
++ } else {
++ bycpup = 1;
++ flags = au_flags_cpup(!CPUP_DTIME, a->parent[DST]);
++ hg_parent = a->hidden_parent[DST]->d_parent;
++ if (!(flags & CPUP_LOCKED_GHDIR)
++ && hg_parent == a->hidden_parent[SRC])
++ flags |= CPUP_LOCKED_GHDIR;
++
++ hi_lock_child(a->hidden_dentry[SRC]->d_inode);
++ set_dbstart(src_dentry, a->btgt);
++ set_h_dptr(src_dentry, a->btgt, dget(a->hidden_dentry[DST]));
++ //DbgDentry(src_dentry);
++ //DbgInode(src_dentry->d_inode);
++ err = sio_cpup_single(src_dentry, a->btgt, a->bstart[SRC], -1,
++ flags);
++ //err = -1; // untested dir
++ if (unlikely(err)) {
++ set_h_dptr(src_dentry, a->btgt, NULL);
++ set_dbstart(src_dentry, a->bstart[SRC]);
++ }
++ i_unlock(a->hidden_dentry[SRC]->d_inode);
++ }
++ if (unlikely(err))
++ goto out_whtmp;
++
++ /* make dir opaque */
++ if (need_diropq) {
++ struct dentry *diropq;
++ struct inode *h_inode;
++
++ h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
++ hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
++ diropq = create_diropq(src_dentry, a->btgt, a->dlgt);
++ //diropq = ERR_PTR(-1);
++ hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
++ err = PTR_ERR(diropq);
++ if (IS_ERR(diropq))
++ goto out_rename;
++ dput(diropq);
++ }
++
++ /* remove whiteout for dentry */
++ if (wh_dentry[DST]) {
++ err = au_unlink_wh_dentry(hidden_dir[DST], wh_dentry[DST],
++ dentry, a->dlgt);
++ //err = -1;
++ if (unlikely(err))
++ goto out_diropq;
++ }
++
++ /* remove whtmp */
++ if (tharg) {
++ if (au_is_nfs(hidden_dst->d_sb)
++ || !is_longer_wh(&a->whlist, a->btgt,
++ stosi(a->sb)->si_dirwh)) {
++ err = rmdir_whtmp(hidden_dst, &a->whlist, a->btgt, dir,
++ dentry->d_inode);
++ if (unlikely(err))
++ Warn("failed removing whtmp dir %.*s (%d), "
++ "ignored.\n", DLNPair(hidden_dst), err);
++ } else {
++ kick_rmdir_whtmp(hidden_dst, &a->whlist, a->btgt, dir,
++ dentry->d_inode, tharg);
++ dput(hidden_dst);
++ tharg = NULL;
++ }
++ }
++ err = 0;
++ goto out_success;
++
++#define RevertFailure(fmt, args...) do { \
++ IOErrWhck("revert failure: " fmt " (%d, %d)\n", \
++ ##args, err, rerr); \
++ err = -EIO; \
++ } while(0)
++
++ out_diropq:
++ if (need_diropq) {
++ struct inode *h_inode;
++
++ h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
++ // i_lock simplly since inotify is not set to h_inode.
++ hi_lock_parent(h_inode);
++ //hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
++ rerr = remove_diropq(src_dentry, a->btgt, a->dlgt);
++ //rerr = -1;
++ //hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
++ i_unlock(h_inode);
++ if (rerr)
++ RevertFailure("remove diropq %.*s",
++ DLNPair(src_dentry));
++ }
++ out_rename:
++ if (!bycpup) {
++ struct dentry *d;
++ struct qstr *name = &src_dentry->d_name;
++ d = lkup_one(name->name, a->hidden_parent[SRC], name->len,
++ &lkup);
++ //d = ERR_PTR(-1);
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d)) {
++ RevertFailure("lkup_one %.*s", DLNPair(src_dentry));
++ goto out_whtmp;
++ }
++ DEBUG_ON(d->d_inode);
++ rerr = vfsub_rename
++ (hidden_dir[DST], au_h_dptr_i(src_dentry, a->btgt),
++ hidden_dir[SRC], d, a->dlgt);
++ //rerr = -1;
++ d_drop(d);
++ dput(d);
++ //set_h_dptr(src_dentry, a->btgt, NULL);
++ if (rerr)
++ RevertFailure("rename %.*s", DLNPair(src_dentry));
++ } else {
++ rerr = vfsub_unlink(hidden_dir[DST], a->hidden_dentry[DST],
++ a->dlgt);
++ //rerr = -1;
++ set_h_dptr(src_dentry, a->btgt, NULL);
++ set_dbstart(src_dentry, a->bstart[SRC]);
++ if (rerr)
++ RevertFailure("unlink %.*s",
++ DLNPair(a->hidden_dentry[DST]));
++ }
++ out_whtmp:
++ if (tharg) {
++ struct dentry *d;
++ struct qstr *name = &dentry->d_name;
++ LKTRLabel(here);
++ d = lkup_one(name->name, a->hidden_parent[DST], name->len,
++ &lkup);
++ //d = ERR_PTR(-1);
++ rerr = PTR_ERR(d);
++ if (IS_ERR(d)) {
++ RevertFailure("lookup %.*s", LNPair(name));
++ goto out_whdst;
++ }
++ if (d->d_inode) {
++ d_drop(d);
++ dput(d);
++ goto out_whdst;
++ }
++ DEBUG_ON(d->d_inode);
++ rerr = vfsub_rename(hidden_dir[DST], hidden_dst,
++ hidden_dir[DST], d, a->dlgt);
++ //rerr = -1;
++ d_drop(d);
++ dput(d);
++ if (rerr) {
++ RevertFailure("rename %.*s", DLNPair(hidden_dst));
++ goto out_whdst;
++ }
++ set_h_dptr(dentry, a->btgt, NULL);
++ set_h_dptr(dentry, a->btgt, dget(hidden_dst));
++ }
++ out_whdst:
++ dput(wh_dentry[DST]);
++ wh_dentry[DST] = NULL;
++ out_whsrc:
++ if (wh_dentry[SRC]) {
++ LKTRLabel(here);
++ rerr = au_unlink_wh_dentry(hidden_dir[SRC], wh_dentry[SRC],
++ src_dentry, a->dlgt);
++ //rerr = -1;
++ if (rerr)
++ RevertFailure("unlink %.*s", DLNPair(wh_dentry[SRC]));
++ }
++#undef RevertFailure
++ d_drop(src_dentry);
++ bend = dbend(src_dentry);
++ for (bindex = dbstart(src_dentry); bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(src_dentry, bindex);
++ if (hd)
++ d_drop(hd);
++ }
++ d_drop(dentry);
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(dentry, bindex);
++ if (hd)
++ d_drop(hd);
++ }
++ au_update_dbstart(dentry);
++ if (tharg)
++ d_drop(hidden_dst);
++ out_success:
++ dput(wh_dentry[SRC]);
++ dput(wh_dentry[DST]);
++ out_tharg:
++ if (tharg) {
++ dput(hidden_dst);
++ kfree(tharg);
++ }
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * test if @dentry dir can be rename destination or not.
++ * success means, it is a logically empty dir.
++ */
++static int may_rename_dstdir(struct dentry *dentry, aufs_bindex_t btgt,
++ struct aufs_nhash *whlist)
++{
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ return test_empty(dentry, whlist);
++}
++
++/*
++ * test if @dentry dir can be rename source or not.
++ * if it can, return 0 and @children is filled.
++ * success means,
++ * - or, it is a logically empty dir.
++ * - or, it exists on writable branch and has no children including whiteouts
++ * on the lower branch.
++ */
++static int may_rename_srcdir(struct dentry *dentry, aufs_bindex_t btgt)
++{
++ int err;
++ aufs_bindex_t bstart;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++
++ bstart = dbstart(dentry);
++ if (bstart != btgt) {
++ struct aufs_nhash *whlist;
++
++ whlist = nhash_new(GFP_KERNEL);
++ err = PTR_ERR(whlist);
++ if (IS_ERR(whlist))
++ goto out;
++ err = test_empty(dentry, whlist);
++ nhash_del(whlist);
++ goto out;
++ }
++
++ if (bstart == dbtaildir(dentry))
++ return 0; /* success */
++
++ err = au_test_empty_lower(dentry);
++
++ out:
++ if (/* unlikely */(err == -ENOTEMPTY))
++ err = -EXDEV;
++ TraceErr(err);
++ return err;
++}
++
++int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry)
++{
++ int err, do_dt_dstdir;
++ aufs_bindex_t bend, bindex;
++ struct inode *inode, *dirs[2];
++ enum {PARENT, CHILD};
++ /* reduce stack space */
++ struct {
++ struct rename_args a;
++ struct dtime dt[2][2];
++ } *p;
++
++ LKTRTrace("i%lu, %.*s, i%lu, %.*s\n",
++ src_dir->i_ino, DLNPair(src_dentry),
++ dir->i_ino, DLNPair(dentry));
++ IMustLock(src_dir);
++ IMustLock(dir);
++ /* braces are added to stop a warning */
++ if (dentry->d_inode) {
++ IMustLock(dentry->d_inode);
++ }
++
++ err = -ENOMEM;
++ BUILD_BUG_ON(sizeof(*p) > PAGE_SIZE);
++ p = kmalloc(sizeof(*p), GFP_KERNEL);
++ if (unlikely(!p))
++ goto out;
++
++ err = -ENOTDIR;
++ p->a.sb = src_dentry->d_sb;
++ inode = src_dentry->d_inode;
++ p->a.isdir = !!S_ISDIR(inode->i_mode);
++ if (unlikely(p->a.isdir && dentry->d_inode
++ && !S_ISDIR(dentry->d_inode->i_mode)))
++ goto out_free;
++
++ aufs_read_and_write_lock2(dentry, src_dentry, p->a.isdir);
++ p->a.dlgt = !!need_dlgt(p->a.sb);
++ p->a.parent[SRC] = p->a.parent[DST] = dentry->d_parent;
++ p->a.issamedir = (src_dir == dir);
++ if (p->a.issamedir)
++ di_write_lock_parent(p->a.parent[DST]);
++ else {
++ p->a.parent[SRC] = src_dentry->d_parent;
++ di_write_lock2_parent(p->a.parent[SRC], p->a.parent[DST],
++ /*isdir*/1);
++ }
++
++ /* which branch we process */
++ p->a.bstart[DST] = dbstart(dentry);
++ p->a.btgt = err = wr_dir(dentry, 1, src_dentry, /*force_btgt*/-1,
++ /*do_lock_srcdir*/0);
++ if (unlikely(err < 0))
++ goto out_unlock;
++
++ /* are they available to be renamed */
++ err = 0;
++ nhash_init(&p->a.whlist);
++ if (p->a.isdir && dentry->d_inode) {
++ set_dbstart(dentry, p->a.bstart[DST]);
++ err = may_rename_dstdir(dentry, p->a.btgt, &p->a.whlist);
++ set_dbstart(dentry, p->a.btgt);
++ }
++ p->a.hidden_dentry[DST] = au_h_dptr(dentry);
++ if (unlikely(err))
++ goto out_unlock;
++ //todo: minor optimize, their sb may be same while their bindex differs.
++ p->a.bstart[SRC] = dbstart(src_dentry);
++ p->a.hidden_dentry[SRC] = au_h_dptr(src_dentry);
++ if (p->a.isdir) {
++ err = may_rename_srcdir(src_dentry, p->a.btgt);
++ if (unlikely(err))
++ goto out_children;
++ }
++
++ /* prepare the writable parent dir on the same branch */
++ err = wr_dir_need_wh(src_dentry, p->a.isdir, &p->a.btgt,
++ p->a.issamedir ? NULL : p->a.parent[DST]);
++ if (unlikely(err < 0))
++ goto out_children;
++ p->a.whsrc = !!err;
++ p->a.whdst = (p->a.bstart[DST] == p->a.btgt);
++ if (!p->a.whdst) {
++ err = cpup_dirs(dentry, p->a.btgt,
++ p->a.issamedir ? NULL : p->a.parent[SRC]);
++ if (unlikely(err))
++ goto out_children;
++ }
++
++ p->a.hidden_parent[SRC] = au_h_dptr_i(p->a.parent[SRC], p->a.btgt);
++ p->a.hidden_parent[DST] = au_h_dptr_i(p->a.parent[DST], p->a.btgt);
++ dirs[0] = src_dir;
++ dirs[1] = dir;
++ hdir_lock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++
++ /* store timestamps to be revertible */
++ dtime_store(p->dt[PARENT] + SRC, p->a.parent[SRC],
++ p->a.hidden_parent[SRC]);
++ if (!p->a.issamedir)
++ dtime_store(p->dt[PARENT] + DST, p->a.parent[DST],
++ p->a.hidden_parent[DST]);
++ do_dt_dstdir = 0;
++ if (p->a.isdir) {
++ dtime_store(p->dt[CHILD] + SRC, src_dentry,
++ p->a.hidden_dentry[SRC]);
++ if (p->a.hidden_dentry[DST]->d_inode) {
++ do_dt_dstdir = 1;
++ dtime_store(p->dt[CHILD] + DST, dentry,
++ p->a.hidden_dentry[DST]);
++ }
++ }
++
++ err = do_rename(src_dir, src_dentry, dir, dentry, &p->a);
++ if (unlikely(err))
++ goto out_dt;
++ hdir_unlock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++
++ /* update dir attributes */
++ dir->i_version++;
++ if (p->a.isdir)
++ au_cpup_attr_nlink(dir);
++ if (ibstart(dir) == p->a.btgt)
++ au_cpup_attr_timesizes(dir);
++
++ if (!p->a.issamedir) {
++ src_dir->i_version++;
++ if (p->a.isdir)
++ au_cpup_attr_nlink(src_dir);
++ if (ibstart(src_dir) == p->a.btgt)
++ au_cpup_attr_timesizes(src_dir);
++ }
++
++ // is this updating defined in POSIX?
++ if (unlikely(p->a.isdir)) {
++ //i_lock(inode);
++ au_cpup_attr_timesizes(inode);
++ //i_unlock(inode);
++ }
++
++#if 0
++ d_drop(src_dentry);
++#else
++ /* dput/iput all lower dentries */
++ set_dbwh(src_dentry, -1);
++ bend = dbend(src_dentry);
++ for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
++ struct dentry *hd;
++ hd = au_h_dptr_i(src_dentry, bindex);
++ if (hd)
++ set_h_dptr(src_dentry, bindex, NULL);
++ }
++ set_dbend(src_dentry, p->a.btgt);
++
++ bend = ibend(inode);
++ for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
++ struct inode *hi;
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi)
++ set_h_iptr(inode, bindex, NULL, 0);
++ }
++ set_ibend(inode, p->a.btgt);
++#endif
++
++#if 0
++ //au_debug_on();
++ //DbgDentry(dentry);
++ //DbgInode(dentry->d_inode);
++ //au_debug_off();
++ inode = dentry->d_inode;
++ if (inode) {
++ aufs_bindex_t bindex, bend;
++ struct dentry *hd;
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ hd = au_h_dptr_i(dentry, bindex);
++ if (hd && hd->d_inode)
++ xino_write0(p->a.sb, bindex, hd->d_inode->i_ino);
++ /* ignore this error */
++ }
++ }
++#endif
++
++ goto out_children; /* success */
++
++ out_dt:
++ dtime_revert(p->dt[PARENT] + SRC,
++ p->a.hidden_parent[SRC]->d_parent
++ == p->a.hidden_parent[DST]);
++ if (!p->a.issamedir)
++ dtime_revert(p->dt[PARENT] + DST,
++ p->a.hidden_parent[DST]->d_parent
++ == p->a.hidden_parent[SRC]);
++ if (p->a.isdir && err != -EIO) {
++ struct dentry *hd;
++
++ hd = p->dt[CHILD][SRC].dt_h_dentry;
++ hi_lock_child(hd->d_inode);
++ dtime_revert(p->dt[CHILD] + SRC, 1);
++ i_unlock(hd->d_inode);
++ if (do_dt_dstdir) {
++ hd = p->dt[CHILD][DST].dt_h_dentry;
++ hi_lock_child(hd->d_inode);
++ dtime_revert(p->dt[CHILD] + DST, 1);
++ i_unlock(hd->d_inode);
++ }
++ }
++ hdir_unlock_rename(p->a.hidden_parent, dirs, p->a.btgt, p->a.issamedir);
++ out_children:
++ nhash_fin(&p->a.whlist);
++ out_unlock:
++ //if (unlikely(err /* && p->a.isdir */)) {
++ if (unlikely(err && p->a.isdir)) {
++ au_update_dbstart(dentry);
++ d_drop(dentry);
++ }
++ if (p->a.issamedir)
++ di_write_unlock(p->a.parent[DST]);
++ else
++ di_write_unlock2(p->a.parent[SRC], p->a.parent[DST]);
++ aufs_read_and_write_unlock2(dentry, src_dentry);
++ out_free:
++ kfree(p);
++ out:
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/iinfo.c linux-2.6.22.1/fs/aufs/iinfo.c
+--- linux-2.6.22.1.oorig/fs/aufs/iinfo.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/iinfo.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: iinfo.c,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/mm.h>
++#include "aufs.h"
++
++struct aufs_iinfo *itoii(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++
++ iinfo = &(container_of(inode, struct aufs_icntnr, vfs_inode)->iinfo);
++ /* bad_inode case */
++ if (unlikely(!iinfo->ii_hinode))
++ return NULL;
++ DEBUG_ON(!iinfo->ii_hinode
++ /* || stosi(inode->i_sb)->si_bend < iinfo->ii_bend */
++ || iinfo->ii_bend < iinfo->ii_bstart);
++ return iinfo;
++}
++
++aufs_bindex_t ibstart(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ return itoii(inode)->ii_bstart;
++}
++
++aufs_bindex_t ibend(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ return itoii(inode)->ii_bend;
++}
++
++struct aufs_vdir *ivdir(struct inode *inode)
++{
++ IiMustAnyLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++ return itoii(inode)->ii_vdir;
++}
++
++struct inode *au_h_iptr_i(struct inode *inode, aufs_bindex_t bindex)
++{
++ struct inode *hidden_inode;
++
++ IiMustAnyLock(inode);
++ DEBUG_ON(bindex < 0 || ibend(inode) < bindex);
++ hidden_inode = itoii(inode)->ii_hinode[0 + bindex].hi_inode;
++ DEBUG_ON(hidden_inode && atomic_read(&hidden_inode->i_count) <= 0);
++ return hidden_inode;
++}
++
++struct inode *au_h_iptr(struct inode *inode)
++{
++ return au_h_iptr_i(inode, ibstart(inode));
++}
++
++aufs_bindex_t itoid_index(struct inode *inode, aufs_bindex_t bindex)
++{
++ IiMustAnyLock(inode);
++ DEBUG_ON(bindex < 0
++ || ibend(inode) < bindex
++ || !itoii(inode)->ii_hinode[0 + bindex].hi_inode);
++ return itoii(inode)->ii_hinode[0 + bindex].hi_id;
++}
++
++// hard/soft set
++void set_ibstart(struct inode *inode, aufs_bindex_t bindex)
++{
++ struct aufs_iinfo *iinfo = itoii(inode);
++ struct inode *h_inode;
++
++ IiMustWriteLock(inode);
++ DEBUG_ON(sbend(inode->i_sb) < bindex);
++ iinfo->ii_bstart = bindex;
++ h_inode = iinfo->ii_hinode[bindex + 0].hi_inode;
++ if (h_inode)
++ au_cpup_igen(inode, h_inode);
++}
++
++void set_ibend(struct inode *inode, aufs_bindex_t bindex)
++{
++ IiMustWriteLock(inode);
++ DEBUG_ON(sbend(inode->i_sb) < bindex
++ || bindex < ibstart(inode));
++ itoii(inode)->ii_bend = bindex;
++}
++
++void set_ivdir(struct inode *inode, struct aufs_vdir *vdir)
++{
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode)
++ || (itoii(inode)->ii_vdir && vdir));
++ itoii(inode)->ii_vdir = vdir;
++}
++
++void aufs_hiput(struct aufs_hinode *hinode)
++{
++ if (unlikely(hinode->hi_notify))
++ do_free_hinotify(hinode);
++ if (hinode->hi_inode)
++ iput(hinode->hi_inode);
++}
++
++unsigned int au_hi_flags(struct inode *inode, int isdir)
++{
++ unsigned int flags;
++ struct super_block *sb = inode->i_sb;
++
++ flags = 0;
++ if (au_flag_test(sb, AuFlag_XINO))
++ flags = AUFS_HI_XINO;
++ if (unlikely(isdir && au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ flags |= AUFS_HI_NOTIFY;
++ return flags;
++}
++
++void set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode, unsigned int flags)
++{
++ struct aufs_hinode *hinode;
++ struct inode *hi;
++ struct aufs_iinfo *iinfo = itoii(inode);
++
++ LKTRTrace("i%lu, b%d, hi%lu, flags 0x%x\n",
++ inode->i_ino, bindex, h_inode ? h_inode->i_ino : 0, flags);
++ IiMustWriteLock(inode);
++ hinode = iinfo->ii_hinode + bindex;
++ hi = hinode->hi_inode;
++ DEBUG_ON(bindex < ibstart(inode) || ibend(inode) < bindex
++ || (h_inode && atomic_read(&h_inode->i_count) <= 0)
++ || (h_inode && hi));
++
++ if (hi)
++ aufs_hiput(hinode);
++ hinode->hi_inode = h_inode;
++ if (h_inode) {
++ int err;
++ struct super_block *sb = inode->i_sb;
++
++ if (bindex == iinfo->ii_bstart)
++ au_cpup_igen(inode, h_inode);
++ hinode->hi_id = sbr_id(sb, bindex);
++ if (flags & AUFS_HI_XINO) {
++ struct xino xino = {
++ .ino = inode->i_ino,
++ //.h_gen = h_inode->i_generation
++ };
++ //WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ err = xino_write(sb, bindex, h_inode->i_ino, &xino);
++ if (unlikely(err)) {
++ IOErr1("failed xino_write() %d, force noxino\n",
++ err);
++ au_flag_clr(sb, AuFlag_XINO);
++ }
++ }
++ if (flags & AUFS_HI_NOTIFY) {
++ err = alloc_hinotify(hinode, inode, h_inode);
++ if (unlikely(err))
++ IOErr1("alloc_hinotify() %d\n", err);
++ else {
++ /* braces are added to stop a warning */
++ DEBUG_ON(!hinode->hi_notify);
++ }
++ }
++ }
++}
++
++void au_update_iigen(struct inode *inode)
++{
++ //IiMustWriteLock(inode);
++ DEBUG_ON(!inode->i_sb);
++ atomic_set(&itoii(inode)->ii_generation, au_sigen(inode->i_sb));
++}
++
++/* it may be called at remount time, too */
++void au_update_brange(struct inode *inode, int do_put_zero)
++{
++ struct aufs_iinfo *iinfo;
++
++ LKTRTrace("i%lu, %d\n", inode->i_ino, do_put_zero);
++ IiMustWriteLock(inode);
++
++ iinfo = itoii(inode);
++ if (unlikely(!iinfo) || iinfo->ii_bstart < 0)
++ return;
++
++ if (do_put_zero) {
++ aufs_bindex_t bindex;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend;
++ bindex++) {
++ struct inode *h_i;
++ h_i = iinfo->ii_hinode[0 + bindex].hi_inode;
++ if (h_i && !h_i->i_nlink)
++ set_h_iptr(inode, bindex, NULL, 0);
++ }
++ }
++
++ iinfo->ii_bstart = -1;
++ while (++iinfo->ii_bstart <= iinfo->ii_bend)
++ if (iinfo->ii_hinode[0 + iinfo->ii_bstart].hi_inode)
++ break;
++ if (iinfo->ii_bstart > iinfo->ii_bend) {
++ iinfo->ii_bend = iinfo->ii_bstart = -1;
++ return;
++ }
++
++ iinfo->ii_bend++;
++ while (0 <= --iinfo->ii_bend)
++ if (iinfo->ii_hinode[0 + iinfo->ii_bend].hi_inode)
++ break;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_iinfo_init(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++ struct super_block *sb;
++ int nbr, i;
++
++ sb = inode->i_sb;
++ DEBUG_ON(!sb);
++ iinfo = &(container_of(inode, struct aufs_icntnr, vfs_inode)->iinfo);
++ DEBUG_ON(iinfo->ii_hinode);
++ nbr = sbend(sb) + 1;
++ if (unlikely(!nbr))
++ nbr++;
++ iinfo->ii_hinode = kcalloc(nbr, sizeof(*iinfo->ii_hinode), GFP_KERNEL);
++ //iinfo->ii_hinode = NULL;
++ if (iinfo->ii_hinode) {
++ for (i = 0; i < nbr; i++)
++ iinfo->ii_hinode[i].hi_id = -1;
++ atomic_set(&iinfo->ii_generation, au_sigen(sb));
++ rw_init_nolock(&iinfo->ii_rwsem);
++ iinfo->ii_bstart = -1;
++ iinfo->ii_bend = -1;
++ iinfo->ii_vdir = NULL;
++ return 0;
++ }
++ return -ENOMEM;
++}
++
++void au_iinfo_fin(struct inode *inode)
++{
++ struct aufs_iinfo *iinfo;
++
++ iinfo = itoii(inode);
++ /* bad_inode case */
++ if (unlikely(!iinfo))
++ return;
++
++ if (unlikely(iinfo->ii_vdir))
++ free_vdir(iinfo->ii_vdir);
++
++ if (iinfo->ii_bstart >= 0) {
++ aufs_bindex_t bend;
++ struct aufs_hinode *hi;
++ hi = iinfo->ii_hinode + iinfo->ii_bstart;
++ bend = iinfo->ii_bend;
++ while (iinfo->ii_bstart++ <= bend) {
++ if (hi->hi_inode)
++ aufs_hiput(hi);
++ hi++;
++ }
++ //iinfo->ii_bstart = iinfo->ii_bend = -1;
++ }
++
++ kfree(iinfo->ii_hinode);
++ //iinfo->ii_hinode = NULL;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/inode.c linux-2.6.22.1/fs/aufs/inode.c
+--- linux-2.6.22.1.oorig/fs/aufs/inode.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/inode.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,339 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: inode.c,v 1.22 2007/05/07 03:44:35 sfjro Exp $ */
++
++#include "aufs.h"
++
++int au_refresh_hinode(struct inode *inode, struct dentry *dentry)
++{
++ int err, new_sz, update, isdir;
++ struct inode *first;
++ struct aufs_hinode *p, *q, tmp;
++ struct super_block *sb;
++ struct aufs_iinfo *iinfo;
++ aufs_bindex_t bindex, bend, new_bindex;
++ unsigned int flags;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ IiMustWriteLock(inode);
++
++ err = -ENOMEM;
++ sb = dentry->d_sb;
++ bend = sbend(sb);
++ new_sz = sizeof(*iinfo->ii_hinode) * (bend + 1);
++ iinfo = itoii(inode);
++ p = au_kzrealloc(iinfo->ii_hinode, sizeof(*p) * (iinfo->ii_bend + 1),
++ new_sz, GFP_KERNEL);
++ //p = NULL;
++ if (unlikely(!p))
++ goto out;
++
++ iinfo->ii_hinode = p;
++ err = 0;
++ update = 0;
++ p = iinfo->ii_hinode + iinfo->ii_bstart;
++ first = p->hi_inode;
++ for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend;
++ bindex++, p++) {
++ if (unlikely(!p->hi_inode))
++ continue;
++
++ new_bindex = find_brindex(sb, p->hi_id);
++ if (new_bindex == bindex)
++ continue;
++ if (new_bindex < 0) {
++ update++;
++ aufs_hiput(p);
++ p->hi_inode = NULL;
++ continue;
++ }
++
++ if (new_bindex < iinfo->ii_bstart)
++ iinfo->ii_bstart = new_bindex;
++ if (iinfo->ii_bend < new_bindex)
++ iinfo->ii_bend = new_bindex;
++ /* swap two hidden inode, and loop again */
++ q = iinfo->ii_hinode + new_bindex;
++ tmp = *q;
++ *q = *p;
++ *p = tmp;
++ if (tmp.hi_inode) {
++ bindex--;
++ p--;
++ }
++ }
++
++ isdir = S_ISDIR(inode->i_mode);
++ flags = au_hi_flags(inode, isdir);
++ bend = dbend(dentry);
++ for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
++ struct inode *hi;
++ struct dentry *hd;
++
++ hd = au_h_dptr_i(dentry, bindex);
++ if (!hd || !hd->d_inode)
++ continue;
++
++ if (iinfo->ii_bstart <= bindex && bindex <= iinfo->ii_bend) {
++ hi = au_h_iptr_i(inode, bindex);
++ if (hi) {
++ if (hi == hd->d_inode)
++ continue;
++ //Dbg("here\n");
++ err = -ESTALE;
++ break;
++ }
++ }
++ if (bindex < iinfo->ii_bstart)
++ iinfo->ii_bstart = bindex;
++ if (iinfo->ii_bend < bindex)
++ iinfo->ii_bend = bindex;
++ set_h_iptr(inode, bindex, igrab(hd->d_inode), flags);
++ update++;
++ }
++
++ bend = iinfo->ii_bend;
++ p = iinfo->ii_hinode;
++ for (bindex = 0; bindex <= bend; bindex++, p++)
++ if (p->hi_inode) {
++ iinfo->ii_bstart = bindex;
++ break;
++ }
++ p = iinfo->ii_hinode + bend;
++ for (bindex = bend; bindex > iinfo->ii_bstart; bindex--, p--)
++ if (p->hi_inode) {
++ iinfo->ii_bend = bindex;
++ break;
++ }
++ DEBUG_ON(iinfo->ii_bstart > bend || iinfo->ii_bend < 0);
++
++ if (unlikely(err))
++ goto out;
++
++ if (1 || first != au_h_iptr(inode))
++ au_cpup_attr_all(inode);
++ if (update && isdir)
++ inode->i_version++;
++ au_update_iigen(inode);
++
++ out:
++ //au_debug_on();
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++static int set_inode(struct inode *inode, struct dentry *dentry)
++{
++ int err, isdir;
++ struct dentry *hidden_dentry;
++ struct inode *hidden_inode;
++ umode_t mode;
++ aufs_bindex_t bindex, bstart, btail;
++ struct aufs_iinfo *iinfo;
++ unsigned int flags;
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++ DEBUG_ON(!(inode->i_state & I_NEW));
++ IiMustWriteLock(inode);
++ hidden_dentry = au_h_dptr(dentry);
++ DEBUG_ON(!hidden_dentry);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_inode);
++
++ err = 0;
++ isdir = 0;
++ bstart = dbstart(dentry);
++ mode = hidden_inode->i_mode;
++ switch (mode & S_IFMT) {
++ case S_IFREG:
++ btail = dbtail(dentry);
++ break;
++ case S_IFDIR:
++ isdir = 1;
++ btail = dbtaildir(dentry);
++ inode->i_op = &aufs_dir_iop;
++ inode->i_fop = &aufs_dir_fop;
++ break;
++ case S_IFLNK:
++ btail = dbtail(dentry);
++ inode->i_op = &aufs_symlink_iop;
++ break;
++ case S_IFBLK:
++ case S_IFCHR:
++ case S_IFIFO:
++ case S_IFSOCK:
++ btail = dbtail(dentry);
++ init_special_inode(inode, mode, hidden_inode->i_rdev);
++ break;
++ default:
++ IOErr("Unknown file type 0%o\n", mode);
++ err = -EIO;
++ goto out;
++ }
++
++ flags = au_hi_flags(inode, isdir);
++ iinfo = itoii(inode);
++ iinfo->ii_bstart = bstart;
++ iinfo->ii_bend = btail;
++ for (bindex = bstart; bindex <= btail; bindex++) {
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!hidden_dentry)
++ continue;
++ DEBUG_ON(!hidden_dentry->d_inode);
++ set_h_iptr(inode, bindex, igrab(hidden_dentry->d_inode), flags);
++ }
++ au_cpup_attr_all(inode);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* successful returns with iinfo write_locked */
++//todo: return with unlocked?
++static int reval_inode(struct inode *inode, struct dentry *dentry, int *matched)
++{
++ int err;
++ struct inode *h_inode, *h_dinode;
++ aufs_bindex_t bindex, bend;
++ //const int udba = !au_flag_test(inode->i_sb, AuFlag_UDBA_NONE);
++
++ LKTRTrace("i%lu, %.*s\n", inode->i_ino, DLNPair(dentry));
++
++ *matched = 0;
++
++ /*
++ * before this function, if aufs got any iinfo lock, it must be only
++ * one, the parent dir.
++ * it can happen by UDBA and the obsoleted inode number.
++ */
++ err = -EIO;
++ if (unlikely(inode->i_ino == parent_ino(dentry)))
++ goto out;
++
++ h_dinode = au_h_dptr(dentry)->d_inode;
++ hi_lock_child(inode); // bad name, this is not a hidden inode.
++ ii_write_lock_new(inode);
++ bend = ibend(inode);
++ for (bindex = ibstart(inode); bindex <= bend; bindex++) {
++ h_inode = au_h_iptr_i(inode, bindex);
++ if (h_inode && h_inode == h_dinode) {
++ //&& (ibs != bstart || !au_test_higen(inode, h_inode)));
++ *matched = 1;
++ err = 0;
++ if (unlikely(au_iigen(inode) != au_digen(dentry)))
++ err = au_refresh_hinode(inode, dentry);
++ break;
++ }
++ }
++ i_unlock(inode);
++ if (unlikely(err))
++ ii_write_unlock(inode);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* successful returns with iinfo write_locked */
++//todo: return with unlocked?
++struct inode *au_new_inode(struct dentry *dentry)
++{
++ struct inode *inode, *h_inode;
++ struct dentry *h_dentry;
++ ino_t h_ino;
++ struct super_block *sb;
++ int err, match;
++ aufs_bindex_t bstart;
++ struct xino xino;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ sb = dentry->d_sb;
++ h_dentry = au_h_dptr(dentry);
++ DEBUG_ON(!h_dentry);
++ h_inode = h_dentry->d_inode;
++ DEBUG_ON(!h_inode);
++
++ bstart = dbstart(dentry);
++ h_ino = h_inode->i_ino;
++ err = xino_read(sb, bstart, h_ino, &xino);
++ //err = -1;
++ inode = ERR_PTR(err);
++ if (unlikely(err))
++ goto out;
++ new_ino:
++ if (!xino.ino) {
++ xino.ino = xino_new_ino(sb);
++ if (!xino.ino) {
++ inode = ERR_PTR(-EIO);
++ goto out;
++ }
++ }
++
++ LKTRTrace("i%lu\n", xino.ino);
++ err = -ENOMEM;
++ inode = iget_locked(sb, xino.ino);
++ if (unlikely(!inode))
++ goto out;
++ err = PTR_ERR(inode);
++ if (IS_ERR(inode))
++ goto out;
++ err = -ENOMEM;
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ LKTRTrace("%lx, new %d\n", inode->i_state, !!(inode->i_state & I_NEW));
++ if (inode->i_state & I_NEW) {
++ sb->s_op->read_inode(inode);
++ if (!is_bad_inode(inode)) {
++ ii_write_lock_new(inode);
++ err = set_inode(inode, dentry);
++ //err = -1;
++ }
++ unlock_new_inode(inode);
++ if (!err)
++ goto out; /* success */
++ ii_write_unlock(inode);
++ goto out_iput;
++ } else {
++ err = reval_inode(inode, dentry, &match);
++ if (!err)
++ goto out; /* success */
++ else if (match)
++ goto out_iput;
++ }
++
++ Warn1("broken ino, b%d, %.*s/%.*s, hi%lu, i%lu. Try udba=inotify.\n",
++ bstart, DLNPair(dentry->d_parent), DLNPair(dentry), h_ino,
++ xino.ino);
++ xino.ino = 0;
++ err = xino_write0(sb, bstart, h_ino);
++ if (!err) {
++ iput(inode);
++ goto new_ino;
++ }
++
++ out_iput:
++ iput(inode);
++ inode = ERR_PTR(err);
++ out:
++ TraceErrPtr(inode);
++ return inode;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/inode.h linux-2.6.22.1/fs/aufs/inode.h
+--- linux-2.6.22.1.oorig/fs/aufs/inode.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/inode.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,377 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: inode.h,v 1.32 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_INODE_H__
++#define __AUFS_INODE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/inotify.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "vfsub.h"
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#else
++struct inotify_watch {};
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_hinotify {
++ struct inotify_watch hin_watch;
++ struct inode *hin_aufs_inode; /* no get/put */
++};
++
++struct aufs_hinode {
++ struct inode *hi_inode;
++ aufs_bindex_t hi_id;
++ struct aufs_hinotify *hi_notify;
++};
++
++struct aufs_vdir;
++struct aufs_iinfo {
++ atomic_t ii_generation;
++ struct super_block *ii_hsb1; /* no get/put */
++
++ struct aufs_rwsem ii_rwsem;
++ aufs_bindex_t ii_bstart, ii_bend;
++ struct aufs_hinode *ii_hinode;
++ struct aufs_vdir *ii_vdir;
++};
++
++struct aufs_icntnr {
++ struct aufs_iinfo iinfo;
++ struct inode vfs_inode;
++};
++
++/* ---------------------------------------------------------------------- */
++
++/* inode.c */
++int au_refresh_hinode(struct inode *inode, struct dentry *dentry);
++struct inode *au_new_inode(struct dentry *dentry);
++
++/* i_op.c */
++extern struct inode_operations aufs_iop, aufs_symlink_iop, aufs_dir_iop;
++int wr_dir(struct dentry *dentry, int negative, struct dentry *src_dentry,
++ aufs_bindex_t force_btgt, int do_lock_srcdir);
++
++/* i_op_del.c */
++int wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
++ struct dentry *locked);
++
++/* iinfo.c */
++struct aufs_iinfo *itoii(struct inode *inode);
++aufs_bindex_t ibstart(struct inode *inode);
++aufs_bindex_t ibend(struct inode *inode);
++struct aufs_vdir *ivdir(struct inode *inode);
++struct inode *au_h_iptr_i(struct inode *inode, aufs_bindex_t bindex);
++struct inode *au_h_iptr(struct inode *inode);
++aufs_bindex_t itoid_index(struct inode *inode, aufs_bindex_t bindex);
++
++void set_ibstart(struct inode *inode, aufs_bindex_t bindex);
++void set_ibend(struct inode *inode, aufs_bindex_t bindex);
++void set_ivdir(struct inode *inode, struct aufs_vdir *vdir);
++void aufs_hiput(struct aufs_hinode *hinode);
++#define AUFS_HI_XINO 1
++#define AUFS_HI_NOTIFY 2
++unsigned int au_hi_flags(struct inode *inode, int isdir);
++void set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode, unsigned int flags);
++void au_update_iigen(struct inode *inode);
++void au_update_brange(struct inode *inode, int do_put_zero);
++
++int au_iinfo_init(struct inode *inode);
++void au_iinfo_fin(struct inode *inode);
++
++/* plink.c */
++#ifdef CONFIG_AUFS_DEBUG
++void au_list_plink(struct super_block *sb);
++#else
++static inline void au_list_plink(struct super_block *sb)
++{
++ /* nothing */
++}
++#endif
++int au_is_plinked(struct super_block *sb, struct inode *inode);
++struct dentry *lkup_plink(struct super_block *sb, aufs_bindex_t bindex,
++ struct inode *inode);
++void append_plink(struct super_block *sb, struct inode *inode,
++ struct dentry *h_dentry, aufs_bindex_t bindex);
++void au_put_plink(struct super_block *sb);
++void half_refresh_plink(struct super_block *sb, aufs_bindex_t br_id);
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for hidden inode */
++/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
++// todo: reduce it by dcsub.
++enum {
++ AuLsc_Begin = I_MUTEX_QUOTA,
++ AuLsc_HI_GPARENT, /* setattr with inotify */
++ AuLsc_HI_PARENT, /* hidden inode, parent first */
++ AuLsc_HI_CHILD,
++ AuLsc_HI_PARENT2, /* copyup dirs */
++ AuLsc_HI_CHILD2,
++ AuLsc_End
++};
++
++/* simple abstraction */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
++static inline void i_lock(struct inode *i)
++{
++ down(&i->i_sem);
++}
++
++static inline void i_unlock(struct inode *i)
++{
++ up(&i->i_sem);
++}
++
++static inline int i_trylock(struct inode *i)
++{
++ return down_trylock(&i->i_sem);
++}
++
++static inline void hi_lock(struct inode *i, unsigned int lsc)
++{
++ i_lock(i);
++}
++
++#define IMustLock(i) DEBUG_ON(!down_trylock(&(i)->i_sem))
++#else
++static inline void i_lock(struct inode *i)
++{
++ mutex_lock(&i->i_mutex);
++}
++
++static inline void i_unlock(struct inode *i)
++{
++ mutex_unlock(&i->i_mutex);
++}
++
++static inline int i_trylock(struct inode *i)
++{
++ return mutex_trylock(&i->i_mutex);
++}
++
++static inline void hi_lock(struct inode *i, unsigned int lsc)
++{
++ mutex_lock_nested(&i->i_mutex, lsc);
++}
++
++#define IMustLock(i) MtxMustLock(&(i)->i_mutex)
++#endif
++
++/*
++ * hi_lock_gparent, hi_lock_parent, hi_lock_parent2, hi_lock_child,
++ * hi_lock_child2, hi_lock_whplink
++ */
++#define LockFunc(name, lsc) \
++static inline void hi_lock_##name(struct inode *h_i) \
++{hi_lock(h_i, AuLsc_HI_##lsc);}
++
++LockFunc(gparent, GPARENT);
++LockFunc(parent, PARENT);
++LockFunc(parent2, PARENT2);
++LockFunc(child, CHILD);
++LockFunc(child2, CHILD2);
++LockFunc(whplink, CHILD2); /* sharing lock-subclass */
++
++#undef LockFunc
++
++/* ---------------------------------------------------------------------- */
++
++/* tiny test for inode number */
++/* tmpfs generation is too rough */
++static inline int au_test_higen(struct inode *inode, struct inode *h_inode)
++{
++ //IiMustAnyLock(inode);
++ return !(itoii(inode)->ii_hsb1 == h_inode->i_sb
++ && inode->i_generation == h_inode->i_generation);
++}
++
++static inline int au_iigen(struct inode *inode)
++{
++ return atomic_read(&itoii(inode)->ii_generation);
++}
++
++#ifdef CONFIG_AUFS_HINOTIFY
++static inline void au_iigen_dec(struct inode *inode)
++{
++ //Dbg("i%lu\n", inode->i_ino);
++ atomic_dec(&itoii(inode)->ii_generation);
++}
++
++/* hinotify.c */
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *h_inode);
++void do_free_hinotify(struct aufs_hinode *hinode);
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc);
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex);
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir);
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir);
++void au_reset_hinotify(struct inode *inode, unsigned int flags);
++int __init au_inotify_init(void);
++void au_inotify_fin(void);
++#else
++static inline
++int alloc_hinotify(struct aufs_hinode *hinode, struct inode *inode,
++ struct inode *h_inode)
++{
++ return -EOPNOTSUPP;
++}
++
++static inline void do_free_hinotify(struct aufs_hinode *hinode)
++{
++ /* nothing */
++}
++
++static inline
++void do_hdir_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex,
++ unsigned int lsc)
++{
++ hi_lock(h_dir, lsc);
++}
++
++static inline
++void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
++{
++ i_unlock(h_dir);
++}
++
++static inline
++void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ vfsub_lock_rename(h_parents[0], h_parents[1]);
++}
++
++static inline
++void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
++ aufs_bindex_t bindex, int issamedir)
++{
++ vfsub_unlock_rename(h_parents[0], h_parents[1]);
++}
++
++static inline void au_reset_hinotify(struct inode *inode, unsigned int flags)
++{
++ /* nothing */
++}
++
++#define au_inotify_init() 0
++#define au_inotify_fin() /* */
++#endif /* CONFIG_AUFS_HINOTIFY */
++
++static inline void free_hinotify(struct inode *inode, aufs_bindex_t bindex)
++{
++ do_free_hinotify(itoii(inode)->ii_hinode + bindex);
++}
++
++/*
++ * hgdir_lock, hdir_lock, hdir2_lock
++ */
++#define LockFunc(name, lsc) \
++static inline \
++void name##_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex) \
++{do_hdir_lock(h_dir, dir, bindex, AuLsc_HI_##lsc);}
++
++LockFunc(hgdir, GPARENT);
++LockFunc(hdir, PARENT);
++LockFunc(hdir2, PARENT2);
++
++#undef LockFunc
++
++/* ---------------------------------------------------------------------- */
++
++/* lock subclass for iinfo */
++enum {
++ AuLsc_II_CHILD, /* child first */
++ AuLsc_II_CHILD2, /* rename(2), link(2), and cpup at hinotify */
++ AuLsc_II_CHILD3, /* copyup dirs */
++ AuLsc_II_PARENT,
++ AuLsc_II_PARENT2,
++ AuLsc_II_PARENT3,
++ AuLsc_II_NEW /* new inode */
++};
++
++/*
++ * ii_read_lock_child, ii_write_lock_child,
++ * ii_read_lock_child2, ii_write_lock_child2,
++ * ii_read_lock_child3, ii_write_lock_child3,
++ * ii_read_lock_parent, ii_write_lock_parent,
++ * ii_read_lock_parent2, ii_write_lock_parent2,
++ * ii_read_lock_parent3, ii_write_lock_parent3,
++ * ii_read_lock_new, ii_write_lock_new
++ */
++#define ReadLockFunc(name, lsc) \
++static inline void ii_read_lock_##name(struct inode *i) \
++{rw_read_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc);}
++
++#define WriteLockFunc(name, lsc) \
++static inline void ii_write_lock_##name(struct inode *i) \
++{rw_write_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc);}
++
++#define RWLockFuncs(name, lsc) \
++ ReadLockFunc(name, lsc); \
++ WriteLockFunc(name, lsc)
++
++RWLockFuncs(child, CHILD);
++RWLockFuncs(child2, CHILD2);
++RWLockFuncs(child3, CHILD3);
++RWLockFuncs(parent, PARENT);
++RWLockFuncs(parent2, PARENT2);
++RWLockFuncs(parent3, PARENT3);
++RWLockFuncs(new, NEW);
++
++#undef ReadLockFunc
++#undef WriteLockFunc
++#undef RWLockFunc
++
++/*
++ * ii_read_unlock, ii_write_unlock, ii_downgrade_lock
++ */
++SimpleUnlockRwsemFuncs(ii, struct inode *i, itoii(i)->ii_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define IiMustReadLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustReadLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustWriteLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustWriteLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustAnyLock(i) do { \
++ SiMustAnyLock((i)->i_sb); \
++ RwMustAnyLock(&itoii(i)->ii_rwsem); \
++} while (0)
++
++#define IiMustNoWaiters(i) RwMustNoWaiters(&itoii(i)->ii_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_INODE_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/misc.c linux-2.6.22.1/fs/aufs/misc.c
+--- linux-2.6.22.1.oorig/fs/aufs/misc.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/misc.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,228 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: misc.c,v 1.31 2007/05/14 03:41:52 sfjro Exp $ */
++
++//#include <linux/fs.h>
++//#include <linux/namei.h>
++//#include <linux/mm.h>
++//#include <asm/uaccess.h>
++#include "aufs.h"
++
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp)
++{
++ void *q;
++
++ LKTRTrace("p %p, nused %d, sz %d, ksize %d\n",
++ p, nused, new_sz, ksize(p));
++ DEBUG_ON(new_sz <= 0);
++ if (new_sz <= nused)
++ return p;
++ if (new_sz <= ksize(p)) {
++ memset(p + nused, 0, new_sz - nused);
++ return p;
++ }
++
++ q = kmalloc(new_sz, gfp);
++ //q = NULL;
++ if (unlikely(!q))
++ return NULL;
++ memcpy(q, p, nused);
++ memset(q + nused, 0, new_sz - nused);
++ //smp_mb();
++ kfree(p);
++ return q;
++}
++
++/* ---------------------------------------------------------------------- */
++
++// todo: make it inline
++struct nameidata *fake_dm(struct nameidata *fake_nd, struct nameidata *nd,
++ struct super_block *sb, aufs_bindex_t bindex)
++{
++ LKTRTrace("nd %p, b%d\n", nd, bindex);
++
++ if (!nd)
++ return NULL;
++
++ fake_nd->dentry = NULL;
++ fake_nd->mnt = NULL;
++
++#ifndef CONFIG_AUFS_FAKE_DM
++ DiMustAnyLock(nd->dentry);
++
++ if (bindex <= dbend(nd->dentry))
++ fake_nd->dentry = au_h_dptr_i(nd->dentry, bindex);
++ if (fake_nd->dentry) {
++ dget(fake_nd->dentry);
++ fake_nd->mnt = sbr_mnt(sb, bindex);
++ DEBUG_ON(!fake_nd->mnt);
++ mntget(fake_nd->mnt);
++ } else
++ fake_nd = ERR_PTR(-ENOENT);
++#endif
++
++ TraceErrPtr(fake_nd);
++ return fake_nd;
++}
++
++void fake_dm_release(struct nameidata *fake_nd)
++{
++#ifndef CONFIG_AUFS_FAKE_DM
++ if (fake_nd) {
++ mntput(fake_nd->mnt);
++ dput(fake_nd->dentry);
++ }
++#endif
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_copy_file(struct file *dst, struct file *src, loff_t len,
++ struct super_block *sb, int *sparse)
++{
++ int err, all_zero, dlgt;
++ unsigned long blksize;
++ char *buf;
++ /* reduce stack space */
++ struct iattr *ia;
++
++ LKTRTrace("%.*s, %.*s\n",
++ DLNPair(dst->f_dentry), DLNPair(src->f_dentry));
++ DEBUG_ON(!(dst->f_mode & FMODE_WRITE));
++ IMustLock(dst->f_dentry->d_parent->d_inode);
++
++ err = -ENOMEM;
++ blksize = dst->f_dentry->d_sb->s_blocksize;
++ if (!blksize || PAGE_SIZE < blksize)
++ blksize = PAGE_SIZE;
++ LKTRTrace("blksize %lu\n", blksize);
++ buf = kmalloc(blksize, GFP_KERNEL);
++ //buf = NULL;
++ if (unlikely(!buf))
++ goto out;
++ ia = kmalloc(sizeof(*ia), GFP_KERNEL);
++ if (unlikely(!ia))
++ goto out_buf;
++
++ dlgt = need_dlgt(sb);
++ err = all_zero = 0;
++ dst->f_pos = src->f_pos = 0;
++ while (len) {
++ size_t sz, rbytes, wbytes, i;
++ char *p;
++
++ LKTRTrace("len %lld\n", len);
++ sz = blksize;
++ if (len < blksize)
++ sz = len;
++
++ /* support LSM and notify */
++ rbytes = 0;
++ while (!rbytes || err == -EAGAIN || err == -EINTR)
++ err = rbytes = vfsub_read_k(src, buf, sz, &src->f_pos,
++ dlgt);
++ if (unlikely(err < 0))
++ break;
++
++ all_zero = 0;
++ if (len >= rbytes && rbytes == blksize) {
++ all_zero = 1;
++ p = buf;
++ for (i = 0; all_zero && i < rbytes; i++)
++ all_zero = !*p++;
++ }
++ if (!all_zero) {
++ wbytes = rbytes;
++ p = buf;
++ while (wbytes) {
++ size_t b;
++ /* support LSM and notify */
++ err = b = vfsub_write_k(dst, p, wbytes,
++ &dst->f_pos, dlgt);
++ if (unlikely(err == -EAGAIN || err == -EINTR))
++ continue;
++ if (unlikely(err < 0))
++ break;
++ wbytes -= b;
++ p += b;
++ }
++ } else {
++ loff_t res;
++ LKTRLabel(hole);
++ *sparse = 1;
++ err = res = vfsub_llseek(dst, rbytes, SEEK_CUR);
++ if (unlikely(res < 0))
++ break;
++ }
++ len -= rbytes;
++ err = 0;
++ }
++
++ /* the last block may be a hole */
++ if (unlikely(!err && all_zero)) {
++ struct dentry *h_d = dst->f_dentry;
++ struct inode *h_i = h_d->d_inode;
++
++ LKTRLabel(last hole);
++ do {
++ err = vfsub_write_k(dst, "\0", 1, &dst->f_pos, dlgt);
++ } while (err == -EAGAIN || err == -EINTR);
++ if (err == 1) {
++ ia->ia_size = dst->f_pos;
++ ia->ia_valid = ATTR_SIZE | ATTR_FILE;
++ ia->ia_file = dst;
++ hi_lock_child2(h_i);
++ err = vfsub_notify_change(h_d, ia, dlgt);
++ i_unlock(h_i);
++ }
++ }
++
++ kfree(ia);
++ out_buf:
++ kfree(buf);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int test_ro(struct super_block *sb, aufs_bindex_t bindex, struct inode *inode)
++{
++ int err;
++
++ err = br_rdonly(stobr(sb, bindex));
++ if (!err && inode) {
++ struct inode *hi = au_h_iptr_i(inode, bindex);
++ if (hi)
++ err = IS_IMMUTABLE(hi) ? -EROFS : 0;
++ }
++ return err;
++}
++
++int au_test_perm(struct inode *hidden_inode, int mask, int dlgt)
++{
++ if (!current->fsuid)
++ return 0;
++ if (unlikely(au_is_nfs(hidden_inode->i_sb)
++ && (mask & MAY_WRITE)
++ && S_ISDIR(hidden_inode->i_mode)))
++ mask |= MAY_READ; /* force permission check */
++ return vfsub_permission(hidden_inode, mask, NULL, dlgt);
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/misc.h linux-2.6.22.1/fs/aufs/misc.h
+--- linux-2.6.22.1.oorig/fs/aufs/misc.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/misc.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,187 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: misc.h,v 1.25 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_MISC_H__
++#define __AUFS_MISC_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/sched.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#define I_MUTEX_QUOTA 0
++#define lockdep_off() /* */
++#define lockdep_on() /* */
++#define mutex_lock_nested(mtx, lsc) mutex_lock(mtx)
++#define down_write_nested(rw, lsc) down_write(rw)
++#define down_read_nested(rw, lsc) down_read(rw)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_rwsem {
++ struct rw_semaphore rwsem;
++#ifdef CONFIG_AUFS_DEBUG
++ atomic_t rcnt;
++#endif
++};
++
++#ifdef CONFIG_AUFS_DEBUG
++#define DbgRcntInit(rw) atomic_set(&(rw)->rcnt, 0)
++#define DbgRcntInc(rw) atomic_inc(&(rw)->rcnt)
++#define DbgRcntDec(rw) WARN_ON(atomic_dec_return(&(rw)->rcnt) < 0)
++#else
++#define DbgRcntInit(rw) /* */
++#define DbgRcntInc(rw) /* */
++#define DbgRcntDec(rw) /* */
++#endif
++
++static inline void rw_init_nolock(struct aufs_rwsem *rw)
++{
++ DbgRcntInit(rw);
++ init_rwsem(&rw->rwsem);
++}
++
++static inline void rw_init_wlock(struct aufs_rwsem *rw)
++{
++ rw_init_nolock(rw);
++ down_write(&rw->rwsem);
++}
++
++static inline void rw_init_wlock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ rw_init_nolock(rw);
++ down_write_nested(&rw->rwsem, lsc);
++}
++
++static inline void rw_read_lock(struct aufs_rwsem *rw)
++{
++ down_read(&rw->rwsem);
++ DbgRcntInc(rw);
++}
++
++static inline void rw_read_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ down_read_nested(&rw->rwsem, lsc);
++ DbgRcntInc(rw);
++}
++
++static inline void rw_read_unlock(struct aufs_rwsem *rw)
++{
++ DbgRcntDec(rw);
++ up_read(&rw->rwsem);
++}
++
++static inline void rw_dgrade_lock(struct aufs_rwsem *rw)
++{
++ DbgRcntInc(rw);
++ downgrade_write(&rw->rwsem);
++}
++
++static inline void rw_write_lock(struct aufs_rwsem *rw)
++{
++ down_write(&rw->rwsem);
++}
++
++static inline void rw_write_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
++{
++ down_write_nested(&rw->rwsem, lsc);
++}
++
++static inline void rw_write_unlock(struct aufs_rwsem *rw)
++{
++ up_write(&rw->rwsem);
++}
++
++#if 0 // why is not _nested version defined
++static inline int rw_read_trylock(struct aufs_rwsem *rw)
++{
++ int ret = down_read_trylock(&rw->rwsem);
++ if (ret)
++ DbgRcntInc(rw);
++ return ret;
++}
++
++static inline int rw_write_trylock(struct aufs_rwsem *rw)
++{
++ return down_write_trylock(&rw->rwsem);
++}
++#endif
++
++#undef DbgRcntInit
++#undef DbgRcntInc
++#undef DbgRcntDec
++
++/* to debug easier, do not make them inlined functions */
++#define RwMustNoWaiters(rw) DEBUG_ON(!list_empty(&(rw)->rwsem.wait_list))
++#define RwMustAnyLock(rw) DEBUG_ON(down_write_trylock(&(rw)->rwsem))
++#ifdef CONFIG_AUFS_DEBUG
++#define RwMustReadLock(rw) do { \
++ RwMustAnyLock(rw); \
++ DEBUG_ON(!atomic_read(&(rw)->rcnt)); \
++} while (0)
++#define RwMustWriteLock(rw) do { \
++ RwMustAnyLock(rw); \
++ DEBUG_ON(atomic_read(&(rw)->rcnt)); \
++} while (0)
++#else
++#define RwMustReadLock(rw) RwMustAnyLock(rw)
++#define RwMustWriteLock(rw) RwMustAnyLock(rw)
++#endif
++
++#define SimpleLockRwsemFuncs(prefix, param, rwsem) \
++static inline void prefix##_read_lock(param) {rw_read_lock(&(rwsem));} \
++static inline void prefix##_write_lock(param) {rw_write_lock(&(rwsem));}
++//static inline void prefix##_read_trylock(param) {rw_read_trylock(&(rwsem));}
++//static inline void prefix##_write_trylock(param) {rw_write_trylock(&(rwsem));}
++//static inline void prefix##_read_trylock_nested(param, lsc)
++//{rw_read_trylock_nested(&(rwsem, lsc));}
++//static inline void prefix##_write_trylock_nestd(param, lsc)
++//{rw_write_trylock_nested(&(rwsem), nested);}
++
++#define SimpleUnlockRwsemFuncs(prefix, param, rwsem) \
++static inline void prefix##_read_unlock(param) {rw_read_unlock(&(rwsem));} \
++static inline void prefix##_write_unlock(param) {rw_write_unlock(&(rwsem));} \
++static inline void prefix##_downgrade_lock(param) {rw_dgrade_lock(&(rwsem));}
++
++#define SimpleRwsemFuncs(prefix, param, rwsem) \
++ SimpleLockRwsemFuncs(prefix, param, rwsem); \
++ SimpleUnlockRwsemFuncs(prefix, param, rwsem)
++
++/* ---------------------------------------------------------------------- */
++
++typedef ssize_t (*readf_t)(struct file*, char __user*, size_t, loff_t*);
++typedef ssize_t (*writef_t)(struct file*, const char __user*, size_t, loff_t*);
++
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp);
++struct nameidata *fake_dm(struct nameidata *fake_nd, struct nameidata *nd,
++ struct super_block *sb, aufs_bindex_t bindex);
++void fake_dm_release(struct nameidata *fake_nd);
++int au_copy_file(struct file *dst, struct file *src, loff_t len,
++ struct super_block *sb, int *sparse);
++int test_ro(struct super_block *sb, aufs_bindex_t bindex, struct inode *inode);
++int au_test_perm(struct inode *h_inode, int mask, int dlgt);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_MISC_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/module.c linux-2.6.22.1/fs/aufs/module.c
+--- linux-2.6.22.1.oorig/fs/aufs/module.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/module.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,334 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: module.c,v 1.9 2007/04/30 05:46:32 sfjro Exp $ */
++
++//#include <linux/init.h>
++//#include <linux/kobject.h>
++#include <linux/module.h>
++//#include <linux/seq_file.h>
++//#include <linux/sysfs.h>
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * aufs caches
++ */
++struct kmem_cache *aufs_cachep[AuCache_Last];
++static int __init create_cache(void)
++{
++#define Cache(type) kmem_cache_create(#type, sizeof(struct type), 0, \
++ SLAB_RECLAIM_ACCOUNT, NULL, NULL)
++
++ if ((aufs_cachep[AuCache_DINFO] = Cache(aufs_dinfo))
++ && (aufs_cachep[AuCache_ICNTNR] = Cache(aufs_icntnr))
++ && (aufs_cachep[AuCache_FINFO] = Cache(aufs_finfo))
++ //&& (aufs_cachep[AuCache_FINFO] = NULL)
++ && (aufs_cachep[AuCache_VDIR] = Cache(aufs_vdir))
++ && (aufs_cachep[AuCache_DEHSTR] = Cache(aufs_dehstr))
++ && (aufs_cachep[AuCache_HINOTIFY] = Cache(aufs_hinotify)))
++ return 0;
++ return -ENOMEM;
++
++#undef Cache
++}
++
++static void destroy_cache(void)
++{
++ int i;
++ for (i = 0; i < AuCache_Last; i++)
++ if (aufs_cachep[i])
++ kmem_cache_destroy(aufs_cachep[i]);
++}
++
++/* ---------------------------------------------------------------------- */
++
++char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
++int au_dir_roflags;
++extern struct file_system_type aufs_fs_type;
++
++#ifdef DbgDlgt
++#include <linux/security.h>
++#include "dbg_dlgt.c"
++#else
++#define dbg_dlgt_init() 0
++#define dbg_dlgt_fin() /* */
++#endif
++
++/*
++ * functions for module interface.
++ */
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Junjiro Okajima");
++MODULE_DESCRIPTION(AUFS_NAME " -- Another unionfs");
++MODULE_VERSION(AUFS_VERSION);
++
++/* it should be 'byte', but param_set_byte() prints by "%c" */
++short aufs_nwkq = AUFS_NWKQ_DEF;
++MODULE_PARM_DESC(nwkq, "the number of workqueue thread, " AUFS_WKQ_NAME);
++module_param_named(nwkq, aufs_nwkq, short, 0444);
++
++int sysaufs_brs = 0;
++MODULE_PARM_DESC(brs, "use <sysfs>/fs/aufs/brs");
++module_param_named(brs, sysaufs_brs, int, 0444);
++
++static int __init aufs_init(void)
++{
++ int err, i;
++ char *p;
++
++ //sbinfo->si_xino is atomic_long_t
++ BUILD_BUG_ON(sizeof(ino_t) != sizeof(long));
++
++#ifdef CONFIG_AUFS_DEBUG
++ {
++ struct aufs_destr destr;
++ destr.len = -1;
++ DEBUG_ON(destr.len < NAME_MAX);
++ }
++
++#ifdef CONFIG_4KSTACKS
++ printk("CONFIG_4KSTACKS is defined.\n");
++#endif
++#if 0 // verbose debug
++ {
++ union {
++ struct aufs_branch *br;
++ struct aufs_dinfo *di;
++ struct aufs_finfo *fi;
++ struct aufs_iinfo *ii;
++ struct aufs_hinode *hi;
++ struct aufs_sbinfo *si;
++ struct aufs_destr *destr;
++ struct aufs_de *de;
++ struct aufs_wh *wh;
++ struct aufs_vdir *vd;
++ } u;
++
++ printk("br{"
++ "xino %d, readf %d, writef %d, "
++ "id %d, perm %d, mnt %d, count %d, "
++ "wh_sem %d, wh %d, run %d} %d\n",
++ offsetof(typeof(*u.br), br_xino),
++ offsetof(typeof(*u.br), br_xino_read),
++ offsetof(typeof(*u.br), br_xino_write),
++ offsetof(typeof(*u.br), br_id),
++ offsetof(typeof(*u.br), br_perm),
++ offsetof(typeof(*u.br), br_mnt),
++ offsetof(typeof(*u.br), br_count),
++ offsetof(typeof(*u.br), br_wh_rwsem),
++ offsetof(typeof(*u.br), br_wh),
++ offsetof(typeof(*u.br), br_wh_running),
++ sizeof(*u.br));
++ printk("di{gen %d, rwsem %d, bstart %d, bend %d, bwh %d, "
++ "bdiropq %d, hdentry %d, reval %d} %d\n",
++ offsetof(typeof(*u.di), di_generation),
++ offsetof(typeof(*u.di), di_rwsem),
++ offsetof(typeof(*u.di), di_bstart),
++ offsetof(typeof(*u.di), di_bend),
++ offsetof(typeof(*u.di), di_bwh),
++ offsetof(typeof(*u.di), di_bdiropq),
++ offsetof(typeof(*u.di), di_hdentry),
++ offsetof(typeof(*u.di), di_reval),
++ sizeof(*u.di));
++ printk("fi{gen %d, rwsem %d, hfile %d, bstart %d, bend %d, "
++ "h_vm_ops %d, vdir_cach %d} %d\n",
++ offsetof(typeof(*u.fi), fi_generation),
++ offsetof(typeof(*u.fi), fi_rwsem),
++ offsetof(typeof(*u.fi), fi_hfile),
++ offsetof(typeof(*u.fi), fi_bstart),
++ offsetof(typeof(*u.fi), fi_bend),
++ offsetof(typeof(*u.fi), fi_h_vm_ops),
++ offsetof(typeof(*u.fi), fi_vdir_cache),
++ sizeof(*u.fi));
++ printk("ii{rwsem %d, bstart %d, bend %d, hinode %d, vdir %d} "
++ "%d\n",
++ offsetof(typeof(*u.ii), ii_rwsem),
++ offsetof(typeof(*u.ii), ii_bstart),
++ offsetof(typeof(*u.ii), ii_bend),
++ offsetof(typeof(*u.ii), ii_hinode),
++ offsetof(typeof(*u.ii), ii_vdir),
++ sizeof(*u.ii));
++ printk("hi{inode %d, id %d, notify %d} %d\n",
++ offsetof(typeof(*u.hi), hi_inode),
++ offsetof(typeof(*u.hi), hi_id),
++ offsetof(typeof(*u.hi), hi_notify),
++ sizeof(*u.hi));
++ printk("si{rwsem %d, gen %d, "
++ "failed_refresh %d, "
++ "bend %d, last id %d, br %d, "
++ "flags %d, "
++ "xino %d, "
++ "rdcache %d, "
++ "dirwh %d, "
++ "pl_lock %d, pl %d, "
++ "kobj %d} %d\n",
++ offsetof(typeof(*u.si), si_rwsem),
++ offsetof(typeof(*u.si), si_generation),
++ -1,//offsetof(typeof(*u.si), si_failed_refresh_dirs),
++ offsetof(typeof(*u.si), si_bend),
++ offsetof(typeof(*u.si), si_last_br_id),
++ offsetof(typeof(*u.si), si_branch),
++ offsetof(typeof(*u.si), si_flags),
++ offsetof(typeof(*u.si), si_xino),
++ offsetof(typeof(*u.si), si_rdcache),
++ offsetof(typeof(*u.si), si_dirwh),
++ offsetof(typeof(*u.si), si_plink_lock),
++ offsetof(typeof(*u.si), si_plink),
++ offsetof(typeof(*u.si), si_kobj),
++ sizeof(*u.si));
++ printk("destr{len %d, name %d} %d\n",
++ offsetof(typeof(*u.destr), len),
++ offsetof(typeof(*u.destr), name),
++ sizeof(*u.destr));
++ printk("de{ino %d, type %d, str %d} %d\n",
++ offsetof(typeof(*u.de), de_ino),
++ offsetof(typeof(*u.de), de_type),
++ offsetof(typeof(*u.de), de_str),
++ sizeof(*u.de));
++ printk("wh{hash %d, bindex %d, str %d} %d\n",
++ offsetof(typeof(*u.wh), wh_hash),
++ offsetof(typeof(*u.wh), wh_bindex),
++ offsetof(typeof(*u.wh), wh_str),
++ sizeof(*u.wh));
++ printk("vd{deblk %d, nblk %d, last %d, ver %d, jiffy %d} %d\n",
++ offsetof(typeof(*u.vd), vd_deblk),
++ offsetof(typeof(*u.vd), vd_nblk),
++ offsetof(typeof(*u.vd), vd_last),
++ offsetof(typeof(*u.vd), vd_version),
++ offsetof(typeof(*u.vd), vd_jiffy),
++ sizeof(*u.vd));
++ }
++#endif
++#endif
++
++ p = au_esc_chars;
++ for (i = 1; i <= ' '; i++)
++ *p++ = i;
++ *p++ = '\\';
++ *p++ = '\x7f';
++ *p = 0;
++
++ au_dir_roflags = au_file_roflags(O_DIRECTORY | O_LARGEFILE);
++#ifndef CONFIG_AUFS_SYSAUFS
++ sysaufs_brs = 0;
++#endif
++
++ err = -EINVAL;
++ if (unlikely(aufs_nwkq <= 0))
++ goto out;
++ err = create_cache();
++ if (unlikely(err))
++ goto out;
++ err = sysaufs_init();
++ if (unlikely(err))
++ goto out_cache;
++ err = au_wkq_init();
++ if (unlikely(err))
++ goto out_kobj;
++ err = au_inotify_init();
++ if (unlikely(err))
++ goto out_wkq;
++ err = dbg_dlgt_init();
++ if (unlikely(err))
++ goto out_inotify;
++ err = register_filesystem(&aufs_fs_type);
++ if (unlikely(err))
++ goto out_dlgt;
++ printk(AUFS_NAME " " AUFS_VERSION "\n");
++ return 0; /* success */
++
++ out_dlgt:
++ dbg_dlgt_fin();
++ out_inotify:
++ au_inotify_fin();
++ out_wkq:
++ au_wkq_fin();
++ out_kobj:
++ sysaufs_fin();
++ out_cache:
++ destroy_cache();
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static void __exit aufs_exit(void)
++{
++ unregister_filesystem(&aufs_fs_type);
++ dbg_dlgt_fin();
++ au_inotify_fin();
++ au_wkq_fin();
++ sysaufs_fin();
++ destroy_cache();
++}
++
++module_init(aufs_init);
++module_exit(aufs_exit);
++
++/* ---------------------------------------------------------------------- */
++
++// fake Kconfig
++#if 1
++#ifdef CONFIG_AUFS_HINOTIFY
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_HINOTIFY is supported in linux-2.6.18 and later.
++#endif
++#ifndef CONFIG_INOTIFY
++#error enable CONFIG_INOTIFY to use CONFIG_AUFS_HINOTIFY.
++#endif
++#endif
++
++#if AUFS_BRANCH_MAX > 511 && BITS_PER_LONG == 64 && PAGE_SIZE == 4096
++#warning For 4k pagesize and 64bit environment, \
++ CONFIG_AUFS_BRANCH_MAX_511 or smaller is recommended.
++#endif
++
++#ifdef CONFIG_AUFS_SYSAUFS
++#ifndef CONFIG_SYSFS
++#error CONFIG_AUFS_SYSAUFS requires CONFIG_SYSFS.
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_SYSAUFS requires linux-2.6.18 and later.
++#endif
++#endif
++
++#ifdef CONFIG_AUFS_EXPORT
++#if !defined(CONFIG_EXPORTFS) && !defined(CONFIG_EXPORTFS_MODULE)
++#error CONFIG_AUFS_EXPORT requires CONFIG_EXPORTFS
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#error CONFIG_AUFS_EXPORT requires linux-2.6.18 and later.
++#endif
++#if defined(CONFIG_EXPORTFS_MODULE) && defined(CONFIG_AUFS)
++#error need CONFIG_EXPORTFS=y to link aufs statically with CONFIG_AUFS_EXPORT
++#endif
++#endif
++
++#ifdef CONFIG_DEBUG_PROVE_LOCKING
++#if MAX_LOCKDEP_SUBCLASSES < AuLsc_End
++#warning lockdep will not work since aufs uses deeper locks.
++#endif
++#endif
++
++#ifdef CONFIG_AUFS_COMPAT
++#warning CONFIG_AUFS_COMPAT will be removed in the near future.
++#endif
++
++#endif
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/module.h linux-2.6.22.1/fs/aufs/module.h
+--- linux-2.6.22.1.oorig/fs/aufs/module.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/module.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: module.h,v 1.8 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_MODULE_H__
++#define __AUFS_MODULE_H__
++
++#ifdef __KERNEL__
++
++#include <linux/slab.h>
++
++/* ---------------------------------------------------------------------- */
++
++/* module parameters */
++extern short aufs_nwkq;
++extern int sysaufs_brs;
++
++/* ---------------------------------------------------------------------- */
++
++extern char au_esc_chars[];
++extern int au_dir_roflags;
++
++/* kmem cache */
++enum {AuCache_DINFO, AuCache_ICNTNR, AuCache_FINFO, AuCache_VDIR,
++ AuCache_DEHSTR, AuCache_HINOTIFY, AuCache_Last};
++extern struct kmem_cache *aufs_cachep[];
++
++#define CacheFuncs(name, index) \
++static inline void *cache_alloc_##name(void) \
++{return kmem_cache_alloc(aufs_cachep[index], GFP_KERNEL);} \
++static inline void cache_free_##name(void *p) \
++{kmem_cache_free(aufs_cachep[index], p);}
++
++CacheFuncs(dinfo, AuCache_DINFO);
++CacheFuncs(icntnr, AuCache_ICNTNR);
++CacheFuncs(finfo, AuCache_FINFO);
++CacheFuncs(vdir, AuCache_VDIR);
++CacheFuncs(dehstr, AuCache_DEHSTR);
++CacheFuncs(hinotify, AuCache_HINOTIFY);
++
++#undef CacheFuncs
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_MODULE_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/opts.c linux-2.6.22.1/fs/aufs/opts.c
+--- linux-2.6.22.1.oorig/fs/aufs/opts.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/opts.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,1043 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: opts.c,v 1.34 2007/05/14 03:40:27 sfjro Exp $ */
++
++#include <asm/types.h> // a distribution requires
++#include <linux/parser.h>
++#include "aufs.h"
++
++enum {
++ Opt_br,
++ Opt_add, Opt_del, Opt_mod, Opt_append, Opt_prepend,
++ Opt_idel, Opt_imod,
++ Opt_dirwh, Opt_rdcache, Opt_deblk, Opt_nhash,
++ Opt_xino, Opt_zxino, Opt_noxino,
++ Opt_plink, Opt_noplink, Opt_list_plink, Opt_clean_plink,
++ Opt_udba,
++ Opt_diropq_a, Opt_diropq_w,
++ Opt_warn_perm, Opt_nowarn_perm,
++ Opt_findrw_dir, Opt_findrw_br,
++ Opt_coo,
++ Opt_dlgt, Opt_nodlgt,
++ Opt_tail, Opt_ignore, Opt_err
++};
++
++static match_table_t options = {
++ {Opt_br, "br=%s"},
++ {Opt_br, "br:%s"},
++
++ {Opt_add, "add=%d:%s"},
++ {Opt_add, "add:%d:%s"},
++ {Opt_add, "ins=%d:%s"},
++ {Opt_add, "ins:%d:%s"},
++ {Opt_append, "append=%s"},
++ {Opt_append, "append:%s"},
++ {Opt_prepend, "prepend=%s"},
++ {Opt_prepend, "prepend:%s"},
++
++ {Opt_del, "del=%s"},
++ {Opt_del, "del:%s"},
++ //{Opt_idel, "idel:%d"},
++ {Opt_mod, "mod=%s"},
++ {Opt_mod, "mod:%s"},
++ //{Opt_imod, "imod:%d:%s"},
++
++ {Opt_dirwh, "dirwh=%d"},
++ {Opt_dirwh, "dirwh:%d"},
++
++ {Opt_xino, "xino=%s"},
++ {Opt_xino, "xino:%s"},
++ {Opt_noxino, "noxino"},
++ //{Opt_zxino, "zxino=%s"},
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
++ {Opt_plink, "plink"},
++ {Opt_noplink, "noplink"},
++#ifdef CONFIG_AUFS_DEBUG
++ {Opt_list_plink, "list_plink"},
++#endif
++ {Opt_clean_plink, "clean_plink"},
++#endif
++
++ {Opt_udba, "udba=%s"},
++
++ {Opt_diropq_a, "diropq=always"},
++ {Opt_diropq_a, "diropq=a"},
++ {Opt_diropq_w, "diropq=whiteouted"},
++ {Opt_diropq_w, "diropq=w"},
++
++ {Opt_warn_perm, "warn_perm"},
++ {Opt_nowarn_perm, "nowarn_perm"},
++
++#ifdef CONFIG_AUFS_DLGT
++ {Opt_dlgt, "dlgt"},
++ {Opt_nodlgt, "nodlgt"},
++#endif
++
++ {Opt_rdcache, "rdcache=%d"},
++ {Opt_rdcache, "rdcache:%d"},
++#if 0
++ {Opt_findrw_dir, "findrw=dir"},
++ {Opt_findrw_br, "findrw=br"},
++
++ {Opt_coo, "coo=%s"},
++
++ {Opt_deblk, "deblk=%d"},
++ {Opt_deblk, "deblk:%d"},
++ {Opt_nhash, "nhash=%d"},
++ {Opt_nhash, "nhash:%d"},
++#endif
++
++ {Opt_br, "dirs=%s"},
++ {Opt_ignore, "debug=%d"},
++ {Opt_ignore, "delete=whiteout"},
++ {Opt_ignore, "delete=all"},
++ {Opt_ignore, "imap=%s"},
++
++ {Opt_err, NULL}
++};
++
++/* ---------------------------------------------------------------------- */
++
++#define RW "rw"
++#define RO "ro"
++#define WH "wh"
++#define RR "rr"
++#define NoLinkWH "nolwh"
++
++static match_table_t brperms = {
++ {AuBr_RR, RR},
++ {AuBr_RO, RO},
++ {AuBr_RW, RW},
++
++ {AuBr_RRWH, RR "+" WH},
++ {AuBr_ROWH, RO "+" WH},
++ {AuBr_RWNoLinkWH, RW "+" NoLinkWH},
++
++ {AuBr_ROWH, "nfsro"},
++ {AuBr_RO, NULL}
++};
++
++static int br_perm_val(char *perm)
++{
++ int val;
++ substring_t args[MAX_OPT_ARGS];
++
++ DEBUG_ON(!perm || !*perm);
++ LKTRTrace("perm %s\n", perm);
++ val = match_token(perm, brperms, args);
++ TraceErr(val);
++ return val;
++}
++
++int br_perm_str(char *p, unsigned int len, int brperm)
++{
++ struct match_token *bp = brperms;
++
++ LKTRTrace("len %d, 0x%x\n", len, brperm);
++
++ while (bp->pattern) {
++ if (bp->token == brperm) {
++ if (strlen(bp->pattern) < len) {
++ strcpy(p, bp->pattern);
++ return 0;
++ } else
++ return -E2BIG;
++ }
++ bp++;
++ }
++
++ return -EIO;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static match_table_t udbalevel = {
++ {AuFlag_UDBA_REVAL, "reval"},
++#ifdef CONFIG_AUFS_HINOTIFY
++ {AuFlag_UDBA_INOTIFY, "inotify"},
++#endif
++ {AuFlag_UDBA_NONE, "none"},
++ {-1, NULL}
++};
++
++static int udba_val(char *str)
++{
++ substring_t args[MAX_OPT_ARGS];
++ return match_token(str, udbalevel, args);
++}
++
++au_parser_pattern_t udba_str(int udba)
++{
++ struct match_token *p = udbalevel;
++ while (p->pattern) {
++ if (p->token == udba)
++ return p->pattern;
++ p++;
++ }
++ BUG();
++ return "??";
++}
++
++void udba_set(struct super_block *sb, unsigned int flg)
++{
++ au_flag_clr(sb, AuMask_UDBA);
++ au_flag_set(sb, flg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static match_table_t coolevel = {
++ {AuFlag_COO_LEAF, "leaf"},
++ {AuFlag_COO_ALL, "all"},
++ {AuFlag_COO_NONE, "none"},
++ {-1, NULL}
++};
++
++#if 0
++static int coo_val(char *str)
++{
++ substring_t args[MAX_OPT_ARGS];
++ return match_token(str, coolevel, args);
++}
++#endif
++
++au_parser_pattern_t coo_str(int coo)
++{
++ struct match_token *p = coolevel;
++ while (p->pattern) {
++ if (p->token == coo)
++ return p->pattern;
++ p++;
++ }
++ BUG();
++ return "??";
++}
++static void coo_set(struct super_block *sb, unsigned int flg)
++{
++ au_flag_clr(sb, AuMask_COO);
++ au_flag_set(sb, flg);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static const int lkup_dirflags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
++
++#ifdef CONFIG_AUFS_DEBUG
++static void dump_opts(struct opts *opts)
++{
++ /* reduce stack space */
++ union {
++ struct opt_add *add;
++ struct opt_del *del;
++ struct opt_mod *mod;
++ struct opt_xino *xino;
++ } u;
++ struct opt *opt;
++
++ TraceEnter();
++
++ opt = opts->opt;
++ while (/* opt < opts_tail && */ opt->type != Opt_tail) {
++ switch (opt->type) {
++ case Opt_add:
++ u.add = &opt->add;
++ LKTRTrace("add {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_del:
++ case Opt_idel:
++ u.del = &opt->del;
++ LKTRTrace("del {%s, %p}\n", u.del->path, u.del->h_root);
++ break;
++ case Opt_mod:
++ case Opt_imod:
++ u.mod = &opt->mod;
++ LKTRTrace("mod {%s, 0x%x, %p}\n",
++ u.mod->path, u.mod->perm, u.mod->h_root);
++ break;
++ case Opt_append:
++ u.add = &opt->add;
++ LKTRTrace("append {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_prepend:
++ u.add = &opt->add;
++ LKTRTrace("prepend {b%d, %s, 0x%x, %p}\n",
++ u.add->bindex, u.add->path, u.add->perm,
++ u.add->nd.dentry);
++ break;
++ case Opt_dirwh:
++ LKTRTrace("dirwh %d\n", opt->dirwh);
++ break;
++ case Opt_rdcache:
++ LKTRTrace("rdcache %d\n", opt->rdcache);
++ break;
++ case Opt_xino:
++ u.xino = &opt->xino;
++ LKTRTrace("xino {%s %.*s}\n",
++ u.xino->path, DLNPair(u.xino->file->f_dentry));
++ break;
++ case Opt_noxino:
++ LKTRLabel(noxino);
++ break;
++ case Opt_plink:
++ LKTRLabel(plink);
++ break;
++ case Opt_noplink:
++ LKTRLabel(noplink);
++ break;
++ case Opt_list_plink:
++ LKTRLabel(list_plink);
++ break;
++ case Opt_clean_plink:
++ LKTRLabel(clean_plink);
++ break;
++ case Opt_udba:
++ LKTRTrace("udba %d, %s\n",
++ opt->udba, udba_str(opt->udba));
++ break;
++ case Opt_diropq_a:
++ LKTRLabel(diropq_a);
++ break;
++ case Opt_diropq_w:
++ LKTRLabel(diropq_w);
++ break;
++ case Opt_warn_perm:
++ LKTRLabel(warn_perm);
++ break;
++ case Opt_nowarn_perm:
++ LKTRLabel(nowarn_perm);
++ break;
++ case Opt_dlgt:
++ LKTRLabel(dlgt);
++ break;
++ case Opt_nodlgt:
++ LKTRLabel(nodlgt);
++ break;
++ case Opt_coo:
++ LKTRTrace("coo %d, %s\n", opt->coo, coo_str(opt->coo));
++ break;
++ default:
++ BUG();
++ }
++ opt++;
++ }
++}
++#else
++#define dump_opts(opts) /* */
++#endif
++
++void au_free_opts(struct opts *opts)
++{
++ struct opt *opt;
++
++ TraceEnter();
++
++ opt = opts->opt;
++ while (opt->type != Opt_tail) {
++ switch (opt->type) {
++ case Opt_add:
++ case Opt_append:
++ case Opt_prepend:
++ path_release(&opt->add.nd);
++ break;
++ case Opt_del:
++ case Opt_idel:
++ dput(opt->del.h_root);
++ break;
++ case Opt_mod:
++ case Opt_imod:
++ dput(opt->mod.h_root);
++ break;
++ case Opt_xino:
++ fput(opt->xino.file);
++ break;
++ }
++ opt++;
++ }
++}
++
++static int opt_add(struct opt *opt, char *opt_str, struct super_block *sb,
++ aufs_bindex_t bindex)
++{
++ int err;
++ struct opt_add *add = &opt->add;
++ char *p;
++
++ LKTRTrace("%s, b%d\n", opt_str, bindex);
++
++ add->bindex = bindex;
++ add->perm = AuBr_RO;
++ if (!bindex && !(sb->s_flags & MS_RDONLY))
++ add->perm = AuBr_RW;
++#ifdef CONFIG_AUFS_COMPAT
++ add->perm = AuBr_RW;
++#endif
++ add->path = opt_str;
++ p = strchr(opt_str, '=');
++ if (unlikely(p)) {
++ *p++ = 0;
++ if (*p)
++ add->perm = br_perm_val(p);
++ }
++
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(add->path, lkup_dirflags, &add->nd);
++ //err = -1;
++ if (!err) {
++ opt->type = Opt_add;
++ goto out;
++ }
++ Err("lookup failed %s (%d)\n", add->path, err);
++ err = -EINVAL;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* called without aufs lock */
++int au_parse_opts(struct super_block *sb, char *str, struct opts *opts)
++{
++ int err, n;
++ struct dentry *root;
++ struct opt *opt, *opt_tail;
++ char *opt_str;
++ substring_t args[MAX_OPT_ARGS];
++ aufs_bindex_t bindex;
++ struct nameidata nd;
++ /* reduce stack space */
++ union {
++ struct opt_del *del;
++ struct opt_mod *mod;
++ struct opt_xino *xino;
++ } u;
++ struct file *file;
++
++ LKTRTrace("%s, nopts %d\n", str, opts->max_opt);
++
++ root = sb->s_root;
++ err = 0;
++ bindex = 0;
++ opt = opts->opt;
++ opt_tail = opt + opts->max_opt - 1;
++ opt->type = Opt_tail;
++ while (!err && (opt_str = strsep(&str, ",")) && *opt_str) {
++ int token, skipped;
++ char *p;
++ err = -EINVAL;
++ token = match_token(opt_str, options, args);
++ LKTRTrace("%s, token %d, args[0]{%p, %p}\n",
++ opt_str, token, args[0].from, args[0].to);
++
++ skipped = 0;
++ switch (token) {
++ case Opt_br:
++ err = 0;
++ while (!err && (opt_str = strsep(&args[0].from, ":"))
++ && *opt_str) {
++ err = opt_add(opt, opt_str, sb, bindex++);
++ //if (LktrCond) err = -1;
++ if (unlikely(!err && ++opt > opt_tail)) {
++ err = -E2BIG;
++ break;
++ }
++ opt->type = Opt_tail;
++ skipped = 1;
++ }
++ break;
++ case Opt_add:
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ err = opt_add(opt, args[1].from, sb, bindex);
++ break;
++ case Opt_append:
++ case Opt_prepend:
++ err = opt_add(opt, args[0].from, sb, /*dummy bindex*/1);
++ if (!err)
++ opt->type = token;
++ break;
++ case Opt_del:
++ u.del = &opt->del;
++ u.del->path = args[0].from;
++ LKTRTrace("del path %s\n", u.del->path);
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(u.del->path, lkup_dirflags, &nd);
++ if (unlikely(err)) {
++ Err("lookup failed %s (%d)\n", u.del->path, err);
++ break;
++ }
++ u.del->h_root = dget(nd.dentry);
++ path_release(&nd);
++ opt->type = token;
++ break;
++#if 0
++ case Opt_idel:
++ u.del = &opt->del;
++ u.del->path = "(indexed)";
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (bindex < 0 || sbend(sb) < bindex) {
++ Err("out of bounds, %d\n", bindex);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++ }
++ err = 0;
++ u.del->h_root = dget(au_h_dptr_i(root, bindex));
++ opt->type = token;
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++#endif
++
++ case Opt_mod:
++ u.mod = &opt->mod;
++ u.mod->path = args[0].from;
++ p = strchr(u.mod->path, '=');
++ if (unlikely(!p)) {
++ Err("no permssion %s\n", opt_str);
++ break;
++ }
++ *p++ = 0;
++ u.mod->perm = br_perm_val(p);
++ LKTRTrace("mod path %s, perm 0x%x, %s\n",
++ u.mod->path, u.mod->perm, p);
++ // LSM may detect it
++ // do not superio.
++ err = path_lookup(u.mod->path, lkup_dirflags, &nd);
++ if (unlikely(err)) {
++ Err("lookup failed %s (%d)\n", u.mod->path, err);
++ break;
++ }
++ u.mod->h_root = dget(nd.dentry);
++ path_release(&nd);
++ opt->type = token;
++ break;
++#if 0
++ case Opt_imod:
++ u.mod = &opt->mod;
++ u.mod->path = "(indexed)";
++ if (unlikely(match_int(&args[0], &n))) {
++ Err("bad integer in %s\n", opt_str);
++ break;
++ }
++ bindex = n;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (bindex < 0 || sbend(sb) < bindex) {
++ Err("out of bounds, %d\n", bindex);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++ }
++ u.mod->perm = br_perm_val(args[1].from);
++ LKTRTrace("mod path %s, perm 0x%x, %s\n",
++ u.mod->path, u.mod->perm, args[1].from);
++ err = 0;
++ u.mod->h_root = dget(au_h_dptr_i(root, bindex));
++ opt->type = token;
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ break;
++#endif
++ case Opt_xino:
++ u.xino = &opt->xino;
++ file = xino_create(sb, args[0].from, /*silent*/0,
++ /*parent*/NULL);
++ err = PTR_ERR(file);
++ if (IS_ERR(file))
++ break;
++ err = -EINVAL;
++ if (unlikely(file->f_dentry->d_sb == sb)) {
++ fput(file);
++ Err("%s must be outside\n", args[0].from);
++ break;
++ }
++ err = 0;
++ u.xino->file = file;
++ u.xino->path = args[0].from;
++ opt->type = token;
++ break;
++
++ case Opt_dirwh:
++ if (unlikely(match_int(&args[0], &opt->dirwh)))
++ break;
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_rdcache:
++ if (unlikely(match_int(&args[0], &opt->rdcache)))
++ break;
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_noxino:
++ case Opt_plink:
++ case Opt_noplink:
++ case Opt_list_plink:
++ case Opt_clean_plink:
++ case Opt_diropq_a:
++ case Opt_diropq_w:
++ case Opt_warn_perm:
++ case Opt_nowarn_perm:
++ case Opt_dlgt:
++ case Opt_nodlgt:
++ err = 0;
++ opt->type = token;
++ break;
++
++ case Opt_udba:
++ opt->udba = udba_val(args[0].from);
++ if (opt->udba >= 0) {
++ err = 0;
++ opt->type = token;
++ }
++ break;
++
++#if 0
++ case Opt_coo:
++ opt->coo = coo_val(args[0].from);
++ if (opt->coo >= 0) {
++ err = 0;
++ opt->type = token;
++ }
++ break;
++#endif
++
++ case Opt_ignore:
++#ifndef CONFIG_AUFS_COMPAT
++ Warn("ignored %s\n", opt_str);
++#endif
++ skipped = 1;
++ err = 0;
++ break;
++ case Opt_err:
++ Err("unknown option %s\n", opt_str);
++ break;
++ }
++
++ if (!err && !skipped) {
++ if (unlikely(++opt > opt_tail)) {
++ err = -E2BIG;
++ opt--;
++ opt->type = Opt_tail;
++ break;
++ }
++ opt->type = Opt_tail;
++ }
++ }
++
++ dump_opts(opts);
++ if (unlikely(err))
++ au_free_opts(opts);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns,
++ * plus: processed without an error
++ * zero: unprocessed
++ */
++static int au_do_opt_simple(struct super_block *sb, struct opt *opt,
++ int remount, unsigned int *given)
++{
++ int err;
++ struct aufs_sbinfo *sbinfo = stosi(sb);
++
++ TraceEnter();
++
++ err = 1; /* handled */
++ switch (opt->type) {
++ case Opt_udba:
++ udba_set(sb, opt->udba);
++ *given |= opt->udba;
++ break;
++
++ case Opt_plink:
++ au_flag_set(sb, AuFlag_PLINK);
++ *given |= AuFlag_PLINK;
++ break;
++ case Opt_noplink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_put_plink(sb);
++ au_flag_clr(sb, AuFlag_PLINK);
++ *given |= AuFlag_PLINK;
++ break;
++ case Opt_list_plink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_list_plink(sb);
++ break;
++ case Opt_clean_plink:
++ if (au_flag_test(sb, AuFlag_PLINK))
++ au_put_plink(sb);
++ break;
++
++ case Opt_diropq_a:
++ au_flag_set(sb, AuFlag_ALWAYS_DIROPQ);
++ *given |= AuFlag_ALWAYS_DIROPQ;
++ break;
++ case Opt_diropq_w:
++ au_flag_clr(sb, AuFlag_ALWAYS_DIROPQ);
++ *given |= AuFlag_ALWAYS_DIROPQ;
++ break;
++
++ case Opt_dlgt:
++ au_flag_set(sb, AuFlag_DLGT);
++ *given |= AuFlag_DLGT;
++ break;
++ case Opt_nodlgt:
++ au_flag_clr(sb, AuFlag_DLGT);
++ *given |= AuFlag_DLGT;
++ break;
++
++ case Opt_warn_perm:
++ au_flag_set(sb, AuFlag_WARN_PERM);
++ *given |= AuFlag_WARN_PERM;
++ break;
++ case Opt_nowarn_perm:
++ au_flag_clr(sb, AuFlag_WARN_PERM);
++ *given |= AuFlag_WARN_PERM;
++ break;
++
++ case Opt_coo:
++ coo_set(sb, opt->coo);
++ *given |= opt->coo;
++ break;
++
++ case Opt_dirwh:
++ sbinfo->si_dirwh = opt->dirwh;
++ break;
++
++ case Opt_rdcache:
++ sbinfo->si_rdcache = opt->rdcache * HZ;
++ break;
++
++ default:
++ err = 0;
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns tri-state.
++ * plus: processed without an error
++ * zero: unprocessed
++ * minus: error
++ */
++static int au_do_opt_br(struct super_block *sb, struct opt *opt, int remount,
++ int *do_refresh)
++{
++ int err;
++
++ TraceEnter();
++
++ err = 0;
++ switch (opt->type) {
++ case Opt_append:
++ opt->add.bindex = sbend(sb) + 1;
++ goto add;
++ case Opt_prepend:
++ opt->add.bindex = 0;
++ add:
++ case Opt_add:
++ err = br_add(sb, &opt->add, remount);
++ if (!err)
++ *do_refresh = err = 1;
++ break;
++
++ case Opt_del:
++ case Opt_idel:
++ err = br_del(sb, &opt->del, remount);
++ if (!err)
++ *do_refresh = err = 1;
++ break;
++
++ case Opt_mod:
++ case Opt_imod:
++ err = br_mod(sb, &opt->mod, remount, do_refresh);
++ if (!err)
++ err = 1;
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int au_do_opt_xino(struct super_block *sb, struct opt *opt, int remount,
++ struct opt_xino **opt_xino)
++{
++ int err;
++
++ TraceEnter();
++
++ err = 0;
++ switch (opt->type) {
++ case Opt_xino:
++ err = xino_set(sb, &opt->xino, remount);
++ if (!err)
++ *opt_xino = &opt->xino;
++ break;
++ case Opt_noxino:
++ err = xino_clr(sb);
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int verify_opts(struct super_block *sb, int remount)
++{
++ int err;
++ aufs_bindex_t bindex, bend;
++ struct aufs_branch *br;
++ struct dentry *root;
++ struct inode *dir;
++ unsigned int do_plink;
++
++ TraceEnter();
++
++ if (unlikely(!(sb->s_flags & MS_RDONLY)
++ && !br_writable(sbr_perm(sb, 0))))
++ Warn("first branch should be rw\n");
++
++ err = 0;
++ root = sb->s_root;
++ dir = sb->s_root->d_inode;
++ do_plink = au_flag_test(sb, AuFlag_PLINK);
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ struct inode *h_dir;
++ int skip;
++
++ skip = 0;
++ h_dir = au_h_iptr_i(dir, bindex);
++ br = stobr(sb, bindex);
++ br_wh_read_lock(br);
++ switch (br->br_perm) {
++ case AuBr_RR:
++ case AuBr_RO:
++ case AuBr_RRWH:
++ case AuBr_ROWH:
++ skip = (!br->br_wh && !br->br_plink);
++ break;
++
++ case AuBr_RWNoLinkWH:
++ skip = !br->br_wh;
++ if (skip) {
++ if (do_plink)
++ skip = !!br->br_plink;
++ else
++ skip = !br->br_plink;
++ }
++ break;
++
++ case AuBr_RW:
++ skip = !!br->br_wh;
++ if (skip) {
++ if (do_plink)
++ skip = !!br->br_plink;
++ else
++ skip = !br->br_plink;
++ }
++ break;
++
++ default:
++ BUG();
++ }
++ br_wh_read_unlock(br);
++
++ if (skip)
++ continue;
++
++ hdir_lock(h_dir, dir, bindex);
++ br_wh_write_lock(br);
++ err = init_wh(au_h_dptr_i(root, bindex), br,
++ au_nfsmnt(sb, bindex), sb);
++ br_wh_write_unlock(br);
++ hdir_unlock(h_dir, dir, bindex);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++int au_do_opts_mount(struct super_block *sb, struct opts *opts)
++{
++ int err, do_refresh;
++ struct inode *dir;
++ struct opt *opt;
++ unsigned int flags, given;
++ struct opt_xino *opt_xino;
++ aufs_bindex_t bend, bindex;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DiMustWriteLock(sb->s_root);
++ dir = sb->s_root->d_inode;
++ IiMustWriteLock(dir);
++
++ err = 0;
++ given = 0;
++ opt_xino = NULL;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail)
++ err = au_do_opt_simple(sb, opt++, /*remount*/0, &given);
++ if (err > 0)
++ err = 0;
++ else if (unlikely(err < 0))
++ goto out;
++
++ /* disable them temporary */
++ flags = au_flag_test(sb, AuFlag_XINO | AuMask_UDBA | AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_XINO | AuFlag_DLGT);
++ udba_set(sb, AuFlag_UDBA_REVAL);
++
++ do_refresh = 0;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail)
++ err = au_do_opt_br(sb, opt++, /*remount*/0, &do_refresh);
++ if (err > 0)
++ err = 0;
++ else if (unlikely(err < 0))
++ goto out;
++
++ bend = sbend(sb);
++ if (unlikely(bend < 0)) {
++ err = -EINVAL;
++ Err("no branches\n");
++ goto out;
++ }
++
++ if (flags & AuFlag_XINO)
++ au_flag_set(sb, AuFlag_XINO);
++ opt = opts->opt;
++ while (!err && opt->type != Opt_tail)
++ err = au_do_opt_xino(sb, opt++, /*remount*/0, &opt_xino);
++ if (unlikely(err))
++ goto out;
++
++ //todo: test this error case.
++ err = verify_opts(sb, /*remount*/0);
++ DEBUG_ON(err);
++ if (unlikely(err))
++ goto out;
++
++ /* enable xino */
++ if (au_flag_test(sb, AuFlag_XINO) && !opt_xino) {
++ struct file *xino_file = xino_def(sb);
++ err = PTR_ERR(xino_file);
++ if (IS_ERR(xino_file))
++ goto out;
++
++ err = 0;
++ for (bindex = 0; !err && bindex <= bend; bindex++)
++ err = xino_init(sb, bindex, xino_file,
++ /*do_test*/bindex);
++ fput(xino_file);
++ if (unlikely(err))
++ goto out;
++ }
++
++ /* restore hinotify */
++ udba_set(sb, flags & AuMask_UDBA);
++ if (flags & AuFlag_UDBA_INOTIFY)
++ au_reset_hinotify(dir, au_hi_flags(dir, 1) & ~AUFS_HI_XINO);
++
++ /* restore dlgt */
++ if (flags & AuFlag_DLGT)
++ au_flag_set(sb, AuFlag_DLGT);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++int au_do_opts_remount(struct super_block *sb, struct opts *opts,
++ int *do_refresh, unsigned int *given)
++{
++ int err, rerr;
++ struct inode *dir;
++ struct opt_xino *opt_xino;
++ struct opt *opt;
++ unsigned int dlgt;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DiMustWriteLock(sb->s_root);
++ dir = sb->s_root->d_inode;
++ IiMustWriteLock(dir);
++ //DEBUG_ON(au_flag_test(sb, AuFlag_UDBA_INOTIFY));
++
++ err = 0;
++ *do_refresh = 0;
++ *given = 0;
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ opt_xino = NULL;
++ opt = opts->opt;
++ while (err >= 0 && opt->type != Opt_tail) {
++ err = au_do_opt_simple(sb, opt, /*remount*/1, given);
++
++ /* disable it temporary */
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_DLGT);
++
++ if (!err)
++ err = au_do_opt_br(sb, opt, /*remount*/1, do_refresh);
++ if (!err)
++ err = au_do_opt_xino(sb, opt, /*remount*/1, &opt_xino);
++
++ /* restore it */
++ au_flag_set(sb, dlgt);
++ opt++;
++ }
++ if (err > 0)
++ err = 0;
++ TraceErr(err);
++
++ /* go on if err */
++
++ //todo: test this error case.
++ au_flag_clr(sb, AuFlag_DLGT);
++ rerr = verify_opts(sb, /*remount*/1);
++ au_flag_set(sb, dlgt);
++
++ /* they are handled by the caller */
++ if (!*do_refresh)
++ *do_refresh = !!((*given & AuMask_UDBA)
++ || au_flag_test(sb, AuFlag_XINO));
++
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/opts.h linux-2.6.22.1/fs/aufs/opts.h
+--- linux-2.6.22.1.oorig/fs/aufs/opts.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/opts.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,96 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: opts.h,v 1.13 2007/05/14 06:27:18 sfjro Exp $ */
++
++#ifndef __AUFS_OPTS_H__
++#define __AUFS_OPTS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
++typedef const char* au_parser_pattern_t;
++#else
++typedef char* au_parser_pattern_t;
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++struct opt_add {
++ aufs_bindex_t bindex;
++ char *path;
++ int perm;
++ struct nameidata nd;
++};
++
++struct opt_del {
++ char *path;
++ struct dentry *h_root;
++};
++
++struct opt_mod {
++ char *path;
++ int perm;
++ struct dentry *h_root;
++};
++
++struct opt_xino {
++ char *path;
++ struct file *file;
++};
++
++struct opt {
++ int type;
++ union {
++ struct opt_xino xino;
++ struct opt_add add;
++ struct opt_del del;
++ struct opt_mod mod;
++ int dirwh;
++ int rdcache;
++ int deblk;
++ int nhash;
++ int udba;
++ int coo;
++ };
++};
++
++struct opts {
++ struct opt *opt;
++ int max_opt;
++};
++
++/* ---------------------------------------------------------------------- */
++
++int br_perm_str(char *p, unsigned int len, int brperm);
++au_parser_pattern_t udba_str(int udba);
++void udba_set(struct super_block *sb, unsigned int flg);
++//au_parser_pattern_t coo_str(int coo);
++void au_free_opts(struct opts *opts);
++int au_parse_opts(struct super_block *sb, char *str, struct opts *opts);
++int au_do_opts_mount(struct super_block *sb, struct opts *opts);
++int au_do_opts_remount(struct super_block *sb, struct opts *opts,
++ int *do_refresh, unsigned int *given);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_OPTS_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/plink.c linux-2.6.22.1/fs/aufs/plink.c
+--- linux-2.6.22.1.oorig/fs/aufs/plink.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/plink.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,331 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: plink.c,v 1.4 2007/05/14 03:39:10 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct pseudo_link {
++ struct list_head list;
++ struct inode *inode;
++};
++
++#ifdef CONFIG_AUFS_DEBUG
++void au_list_plink(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++
++ TraceEnter();
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list)
++ Dbg("%lu\n", plink->inode->i_ino);
++ spin_unlock(&sbinfo->si_plink_lock);
++}
++#endif
++
++int au_is_plinked(struct super_block *sb, struct inode *inode)
++{
++ int found;
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ found = 0;
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list)
++ if (plink->inode == inode) {
++ found = 1;
++ break;
++ }
++ spin_unlock(&sbinfo->si_plink_lock);
++ return found;
++}
++
++// 20 is max digits length of ulong 64
++#define PLINK_NAME_LEN ((20 + 1) * 2)
++
++static int plink_name(char *name, int len, struct inode *inode,
++ aufs_bindex_t bindex)
++{
++ int rlen;
++ struct inode *h_inode;
++
++ LKTRTrace("i%lu, b%d\n", inode->i_ino, bindex);
++ DEBUG_ON(len != PLINK_NAME_LEN);
++ h_inode = au_h_iptr_i(inode, bindex);
++ DEBUG_ON(!h_inode);
++ rlen = snprintf(name, len, "%lu.%lu", inode->i_ino, h_inode->i_ino);
++ DEBUG_ON(rlen >= len);
++ return rlen;
++}
++
++struct dentry *lkup_plink(struct super_block *sb, aufs_bindex_t bindex,
++ struct inode *inode)
++{
++ struct dentry *h_dentry, *h_parent;
++ struct aufs_branch *br;
++ struct inode *h_dir;
++ char tgtname[PLINK_NAME_LEN];
++ int len;
++ struct lkup_args lkup;
++
++ LKTRTrace("b%d, i%lu\n", bindex, inode->i_ino);
++ br = stobr(sb, bindex);
++ h_parent = br->br_plink;
++ DEBUG_ON(!h_parent);
++ h_dir = h_parent->d_inode;
++ DEBUG_ON(!h_dir);
++
++ len = plink_name(tgtname, sizeof(tgtname), inode, bindex);
++
++ // always superio.
++ lkup.nfsmnt = au_do_nfsmnt(br->br_mnt);
++ lkup.dlgt = need_dlgt(sb);
++ hi_lock_whplink(h_dir);
++ h_dentry = sio_lkup_one(tgtname, h_parent, len, &lkup);
++ i_unlock(h_dir);
++ return h_dentry;
++}
++
++static int do_whplink(char *tgt, int len, struct dentry *h_parent,
++ struct dentry *h_dentry, struct vfsmount *nfsmnt,
++ struct super_block *sb)
++{
++ int err;
++ struct dentry *h_tgt;
++ struct inode *h_dir;
++ struct lkup_args lkup = {
++ .nfsmnt = nfsmnt,
++ .dlgt = need_dlgt(sb)
++ };
++
++ h_tgt = lkup_one(tgt, h_parent, len, &lkup);
++ err = PTR_ERR(h_tgt);
++ if (IS_ERR(h_tgt))
++ goto out;
++
++ err = 0;
++ h_dir = h_parent->d_inode;
++ if (unlikely(h_tgt->d_inode && h_tgt->d_inode != h_dentry->d_inode))
++ err = vfsub_unlink(h_dir, h_tgt, lkup.dlgt);
++ if (!err && !h_tgt->d_inode) {
++ err = vfsub_link(h_dentry, h_dir, h_tgt, lkup.dlgt);
++ //inode->i_nlink++;
++ }
++ dput(h_tgt);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct do_whplink_args {
++ int *errp;
++ char *tgt;
++ int len;
++ struct dentry *h_parent;
++ struct dentry *h_dentry;
++ struct vfsmount *nfsmnt;
++ struct super_block *sb;
++};
++
++static void call_do_whplink(void *args)
++{
++ struct do_whplink_args *a = args;
++ *a->errp = do_whplink(a->tgt, a->len, a->h_parent, a->h_dentry,
++ a->nfsmnt, a->sb);
++}
++
++static int whplink(struct dentry *h_dentry, struct inode *inode,
++ aufs_bindex_t bindex, struct super_block *sb)
++{
++ int err, len;
++ struct aufs_branch *br;
++ struct dentry *h_parent;
++ struct inode *h_dir;
++ char tgtname[PLINK_NAME_LEN];
++
++ LKTRTrace("%.*s\n", DLNPair(h_dentry));
++ br = stobr(inode->i_sb, bindex);
++ h_parent = br->br_plink;
++ DEBUG_ON(!h_parent);
++ h_dir = h_parent->d_inode;
++ DEBUG_ON(!h_dir);
++
++ len = plink_name(tgtname, sizeof(tgtname), inode, bindex);
++
++ // always superio.
++ hi_lock_whplink(h_dir);
++ if (!is_au_wkq(current)) {
++ struct do_whplink_args args = {
++ .errp = &err,
++ .tgt = tgtname,
++ .len = len,
++ .h_parent = h_parent,
++ .h_dentry = h_dentry,
++ .nfsmnt = au_do_nfsmnt(br->br_mnt),
++ .sb = sb
++ };
++ au_wkq_wait(call_do_whplink, &args, /*dlgt*/0);
++ } else
++ err = do_whplink(tgtname, len, h_parent, h_dentry,
++ au_do_nfsmnt(br->br_mnt), sb);
++ i_unlock(h_dir);
++
++ TraceErr(err);
++ return err;
++}
++
++void append_plink(struct super_block *sb, struct inode *inode,
++ struct dentry *h_dentry, aufs_bindex_t bindex)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink;
++ int found, err, cnt;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++ SiMustAnyLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ cnt = 0;
++ found = 0;
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry(plink, plink_list, list) {
++ cnt++;
++ if (plink->inode == inode) {
++ found = 1;
++ break;
++ }
++ }
++
++ err = 0;
++ if (!found) {
++ struct pseudo_link *plink;
++
++ plink = kmalloc(sizeof(*plink), GFP_ATOMIC);
++ if (plink) {
++ plink->inode = igrab(inode);
++ list_add(&plink->list, plink_list);
++ cnt++;
++ } else
++ err = -ENOMEM;
++ }
++ spin_unlock(&sbinfo->si_plink_lock);
++
++ if (!err)
++ err = whplink(h_dentry, inode, bindex, sb);
++
++ if (unlikely(cnt > 100))
++ Warn1("unexpectedly many pseudo links, %d\n", cnt);
++ if (unlikely(err))
++ Warn("err %d, damaged pseudo link. ignored.\n", err);
++}
++
++static void do_put_plink(struct pseudo_link *plink, int do_del)
++{
++ TraceEnter();
++
++ iput(plink->inode);
++ if (do_del)
++ list_del(&plink->list);
++ kfree(plink);
++}
++
++void au_put_plink(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink, *tmp;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ //spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry_safe(plink, tmp, plink_list, list)
++ do_put_plink(plink, 0);
++ INIT_LIST_HEAD(plink_list);
++ //spin_unlock(&sbinfo->si_plink_lock);
++}
++
++void half_refresh_plink(struct super_block *sb, aufs_bindex_t br_id)
++{
++ struct aufs_sbinfo *sbinfo;
++ struct list_head *plink_list;
++ struct pseudo_link *plink, *tmp;
++ struct inode *inode;
++ aufs_bindex_t bstart, bend, bindex;
++ int do_put;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_PLINK));
++
++ sbinfo = stosi(sb);
++ plink_list = &sbinfo->si_plink;
++ //spin_lock(&sbinfo->si_plink_lock);
++ list_for_each_entry_safe(plink, tmp, plink_list, list) {
++ do_put = 0;
++ inode = igrab(plink->inode);
++ ii_write_lock_child(inode);
++ bstart = ibstart(inode);
++ bend = ibend(inode);
++ if (bstart >= 0) {
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ if (!au_h_iptr_i(inode, bindex)
++ || itoid_index(inode, bindex) != br_id)
++ continue;
++ set_h_iptr(inode, bindex, NULL, 0);
++ do_put = 1;
++ break;
++ }
++ } else
++ do_put_plink(plink, 1);
++
++ if (do_put) {
++ for (bindex = bstart; bindex <= bend; bindex++)
++ if (au_h_iptr_i(inode, bindex)) {
++ do_put = 0;
++ break;
++ }
++ if (do_put)
++ do_put_plink(plink, 1);
++ }
++ ii_write_unlock(inode);
++ iput(inode);
++ }
++ //spin_unlock(&sbinfo->si_plink_lock);
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/sbinfo.c linux-2.6.22.1/fs/aufs/sbinfo.c
+--- linux-2.6.22.1.oorig/fs/aufs/sbinfo.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/sbinfo.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,173 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sbinfo.c,v 1.30 2007/05/14 03:39:31 sfjro Exp $ */
++
++#include "aufs.h"
++
++struct aufs_sbinfo *stosi(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++ sbinfo = sb->s_fs_info;
++ //DEBUG_ON(sbinfo->si_bend < 0);
++ return sbinfo;
++}
++
++aufs_bindex_t sbend(struct super_block *sb)
++{
++ SiMustAnyLock(sb);
++ return stosi(sb)->si_bend;
++}
++
++struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex)
++{
++ SiMustAnyLock(sb);
++ DEBUG_ON(bindex < 0 || sbend(sb) < bindex
++ || !stosi(sb)->si_branch[0 + bindex]);
++ return stosi(sb)->si_branch[0 + bindex];
++}
++
++int au_sigen(struct super_block *sb)
++{
++ SiMustAnyLock(sb);
++ return stosi(sb)->si_generation;
++}
++
++int au_sigen_inc(struct super_block *sb)
++{
++ int gen;
++
++ SiMustWriteLock(sb);
++ gen = ++stosi(sb)->si_generation;
++ au_update_digen(sb->s_root);
++ au_update_iigen(sb->s_root->d_inode);
++ sb->s_root->d_inode->i_version++;
++ return gen;
++}
++
++int find_bindex(struct super_block *sb, struct aufs_branch *br)
++{
++ aufs_bindex_t bindex, bend;
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (stobr(sb, bindex) == br)
++ return bindex;
++ return -1;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* dentry and super_block lock. call at entry point */
++void aufs_read_lock(struct dentry *dentry, int flags)
++{
++ si_read_lock(dentry->d_sb);
++ if (flags & AUFS_D_WLOCK)
++ di_write_lock_child(dentry);
++ else
++ di_read_lock_child(dentry, flags);
++}
++
++void aufs_read_unlock(struct dentry *dentry, int flags)
++{
++ if (flags & AUFS_D_WLOCK)
++ di_write_unlock(dentry);
++ else
++ di_read_unlock(dentry, flags);
++ si_read_unlock(dentry->d_sb);
++}
++
++void aufs_write_lock(struct dentry *dentry)
++{
++ //au_wkq_wait_nwtask();
++ si_write_lock(dentry->d_sb);
++ di_write_lock_child(dentry);
++}
++
++void aufs_write_unlock(struct dentry *dentry)
++{
++ di_write_unlock(dentry);
++ si_write_unlock(dentry->d_sb);
++ //au_wkq_wait_nwtask();
++}
++
++void aufs_read_and_write_lock2(struct dentry *d1, struct dentry *d2, int isdir)
++{
++ DEBUG_ON(d1 == d2 || d1->d_sb != d2->d_sb);
++ si_read_lock(d1->d_sb);
++ di_write_lock2_child(d1, d2, isdir);
++}
++
++void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2)
++{
++ DEBUG_ON(d1 == d2 || d1->d_sb != d2->d_sb);
++ di_write_unlock2(d1, d2);
++ si_read_unlock(d1->d_sb);
++}
++
++/* ---------------------------------------------------------------------- */
++
++aufs_bindex_t new_br_id(struct super_block *sb)
++{
++ aufs_bindex_t br_id;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++
++ while (1) {
++ br_id = ++stosi(sb)->si_last_br_id;
++ if (br_id && find_brindex(sb, br_id) < 0)
++ return br_id;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_SYSAUFS
++static int make_xino(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++ struct super_block *sb = args->sb;
++ aufs_bindex_t bindex, bend;
++ struct file *xf;
++ struct inode *xi;
++
++ TraceEnter();
++ DEBUG_ON(args->index != SysaufsSb_XINO);
++ SiMustReadLock(sb);
++
++ *do_size = 0;
++ err = seq_printf(seq, "%d %lu\n", sizeof(struct xino),
++ atomic_long_read(&stosi(sb)->si_xino));
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ xf = stobr(sb, bindex)->br_xino;
++ xi = xf->f_dentry->d_inode;
++ err = seq_printf(seq, "%d: %d, %Lux%d %Ld\n",
++ bindex, file_count(xf),
++ (u64)xi->i_blocks, 1 << xi->i_blkbits,
++ i_size_read(xi));
++ }
++ return err;
++}
++
++sysaufs_op au_si_ops[] = {
++ [SysaufsSb_XINO] = make_xino
++};
++#endif
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/super.c linux-2.6.22.1/fs/aufs/super.c
+--- linux-2.6.22.1.oorig/fs/aufs/super.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/super.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,716 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: super.c,v 1.50 2007/05/14 03:39:42 sfjro Exp $ */
++
++#include <linux/module.h>
++#include <linux/seq_file.h>
++#include <linux/statfs.h>
++#include "aufs.h"
++
++/*
++ * super_operations
++ */
++static struct inode *aufs_alloc_inode(struct super_block *sb)
++{
++ struct aufs_icntnr *c;
++
++ TraceEnter();
++
++ c = cache_alloc_icntnr();
++ //if (LktrCond) {cache_free_icntnr(c); c = NULL;}
++ if (c) {
++ inode_init_once(&c->vfs_inode);
++ c->vfs_inode.i_version = 1; //sigen(sb);
++ c->iinfo.ii_hinode = NULL;
++ return &c->vfs_inode;
++ }
++ return NULL;
++}
++
++static void aufs_destroy_inode(struct inode *inode)
++{
++ LKTRTrace("i%lu\n", inode->i_ino);
++ au_iinfo_fin(inode);
++ cache_free_icntnr(container_of(inode, struct aufs_icntnr, vfs_inode));
++}
++
++//todo: how about merge with alloc_inode()?
++static void aufs_read_inode(struct inode *inode)
++{
++ int err;
++
++ LKTRTrace("i%lu\n", inode->i_ino);
++
++ err = au_iinfo_init(inode);
++ //if (LktrCond) err = -1;
++ if (!err) {
++ inode->i_version++;
++ inode->i_op = &aufs_iop;
++ inode->i_fop = &aufs_file_fop;
++ inode->i_mapping->a_ops = &aufs_aop;
++ return; /* success */
++ }
++
++ LKTRTrace("intializing inode info failed(%d)\n", err);
++ make_bad_inode(inode);
++}
++
++int au_show_brs(struct seq_file *seq, struct super_block *sb)
++{
++ int err;
++ aufs_bindex_t bindex, bend;
++ char a[16];
++ struct dentry *root;
++
++ TraceEnter();
++ SiMustAnyLock(sb);
++ root = sb->s_root;
++ DiMustAnyLock(root);
++
++ err = 0;
++ bend = sbend(sb);
++ for (bindex = 0; !err && bindex <= bend; bindex++) {
++ err = br_perm_str(a, sizeof(a), sbr_perm(sb, bindex));
++ if (!err)
++ err = seq_path(seq, sbr_mnt(sb, bindex),
++ au_h_dptr_i(root, bindex), au_esc_chars);
++ if (err > 0)
++ err = seq_printf(seq, "=%s", a);
++ if (!err && bindex != bend)
++ err = seq_putc(seq, ':');
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int aufs_show_options(struct seq_file *m, struct vfsmount *mnt)
++{
++ int err, n;
++ struct super_block *sb;
++ struct aufs_sbinfo *sbinfo;
++ struct dentry *root;
++ struct file *xino;
++
++ TraceEnter();
++
++ sb = mnt->mnt_sb;
++ root = sb->s_root;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ if (au_flag_test(sb, AuFlag_XINO)) {
++ err = seq_puts(m, ",xino=");
++ if (unlikely(err))
++ goto out;
++ xino = stobr(sb, 0)->br_xino;
++ err = seq_path(m, xino->f_vfsmnt, xino->f_dentry, au_esc_chars);
++ if (unlikely(err <= 0))
++ goto out;
++ err = 0;
++
++#define Deleted "\\040(deleted)"
++ m->count -= sizeof(Deleted) - 1;
++ DEBUG_ON(memcmp(m->buf + m->count, Deleted,
++ sizeof(Deleted) - 1));
++#undef Deleted
++ } else
++ err = seq_puts(m, ",noxino");
++
++ n = au_flag_test(sb, AuFlag_PLINK);
++ if (unlikely(!err && (AuDefFlags & AuFlag_PLINK) != n))
++ err = seq_printf(m, ",%splink", n ? "" : "no");
++ n = au_flag_test_udba(sb);
++ if (unlikely(!err && (AuDefFlags & AuMask_UDBA) != n))
++ err = seq_printf(m, ",udba=%s", udba_str(n));
++ n = au_flag_test(sb, AuFlag_ALWAYS_DIROPQ);
++ if (unlikely(!err && (AuDefFlags & AuFlag_ALWAYS_DIROPQ) != n))
++ err = seq_printf(m, ",diropq=%c", n ? 'a' : 'w');
++ n = au_flag_test(sb, AuFlag_DLGT);
++ if (unlikely(!err && (AuDefFlags & AuFlag_DLGT) != n))
++ err = seq_printf(m, ",%sdlgt", n ? "" : "no");
++ n = au_flag_test(sb, AuFlag_WARN_PERM);
++ if (unlikely(!err && (AuDefFlags & AuFlag_WARN_PERM) != n))
++ err = seq_printf(m, ",%swarn_perm", n ? "" : "no");
++
++ sbinfo = stosi(sb);
++ n = sbinfo->si_dirwh;
++ if (unlikely(!err && n != AUFS_DIRWH_DEF))
++ err = seq_printf(m, ",dirwh=%d", n);
++ n = sbinfo->si_rdcache / HZ;
++ if (unlikely(!err && n != AUFS_RDCACHE_DEF))
++ err = seq_printf(m, ",rdcache=%d", n);
++#if 0
++ n = au_flag_test_coo(sb);
++ if (unlikely(!err && (AuDefFlags & AuMask_COO) != n))
++ err = seq_printf(m, ",coo=%s", coo_str(n));
++#endif
++
++ if (!err && !sysaufs_brs) {
++#ifdef CONFIG_AUFS_COMPAT
++ err = seq_puts(m, ",dirs=");
++#else
++ err = seq_puts(m, ",br:");
++#endif
++ if (!err)
++ err = au_show_brs(m, sb);
++ }
++
++ out:
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ TraceErr(err);
++ if (err)
++ err = -E2BIG;
++ TraceErr(err);
++ return err;
++}
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++#define StatfsLock(d) aufs_read_lock((d)->d_sb->s_root, 0)
++#define StatfsUnlock(d) aufs_read_unlock((d)->d_sb->s_root, 0)
++#define StatfsArg(d) au_h_dptr((d)->d_sb->s_root)
++#define StatfsHInode(d) (StatfsArg(d)->d_inode)
++#define StatfsSb(d) ((d)->d_sb)
++static int aufs_statfs(struct dentry *arg, struct kstatfs *buf)
++#else
++#define StatfsLock(s) si_read_lock(s)
++#define StatfsUnlock(s) si_read_unlock(s)
++#define StatfsArg(s) sbr_sb(s, 0)
++#define StatfsHInode(s) (StatfsArg(s)->s_root->d_inode)
++#define StatfsSb(s) (s)
++static int aufs_statfs(struct super_block *arg, struct kstatfs *buf)
++#endif
++{
++ int err;
++
++ TraceEnter();
++
++ StatfsLock(arg);
++ err = vfsub_statfs(StatfsArg(arg), buf, need_dlgt(StatfsSb(arg)));
++ //if (LktrCond) err = -1;
++ StatfsUnlock(arg);
++ if (!err) {
++ //buf->f_type = AUFS_SUPER_MAGIC;
++ buf->f_type = 0;
++ buf->f_namelen -= AUFS_WH_PFX_LEN;
++ memset(&buf->f_fsid, 0, sizeof(buf->f_fsid));
++ }
++ //buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1;
++
++ TraceErr(err);
++ return err;
++}
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) || defined(UbuntuEdgy17Umount18)
++#define UmountBeginSb(mnt) (mnt)->mnt_sb
++static void aufs_umount_begin(struct vfsmount *arg, int flags)
++#else
++#define UmountBeginSb(sb) sb
++static void aufs_umount_begin(struct super_block *arg)
++#endif
++{
++ struct super_block *sb = UmountBeginSb(arg);
++
++ if (unlikely(!stosi(sb)))
++ return;
++
++ //au_wkq_wait_nwtask();
++ si_write_lock(sb);
++ if (au_flag_test(sb, AuFlag_PLINK)) {
++ au_put_plink(sb);
++ //kobj_umount(stosi(sb));
++ }
++#if 0
++ if (unlikely(au_flag_test(sb, AuFlag_UDBA_INOTIFY)))
++ shrink_dcache_sb(sb);
++#endif
++ si_write_unlock(sb);
++}
++
++static void free_sbinfo(struct aufs_sbinfo *sbinfo)
++{
++ TraceEnter();
++ DEBUG_ON(!sbinfo
++ || !list_empty(&sbinfo->si_plink));
++
++ free_branches(sbinfo);
++ kfree(sbinfo->si_branch);
++ kfree(sbinfo);
++}
++
++/* final actions when unmounting a file system */
++static void aufs_put_super(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++
++ sbinfo = stosi(sb);
++ if (unlikely(!sbinfo))
++ return;
++
++ sysaufs_del(sbinfo);
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && !defined(UbuntuEdgy17Umount18)
++ // umount_begin() may not be called.
++ aufs_umount_begin(sb);
++#endif
++ free_sbinfo(sbinfo);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * refresh directories at remount time.
++ */
++static int do_refresh_dir(struct dentry *dentry, unsigned int flags)
++{
++ int err;
++ struct dentry *parent;
++ struct inode *inode;
++
++ LKTRTrace("%.*s\n", DLNPair(dentry));
++ inode = dentry->d_inode;
++ DEBUG_ON(!inode || !S_ISDIR(inode->i_mode));
++
++ di_write_lock_child(dentry);
++ parent = dget_parent(dentry);
++ di_read_lock_parent(parent, AUFS_I_RLOCK);
++ err = au_refresh_hdentry(dentry, S_IFDIR);
++ if (err >= 0) {
++ err = au_refresh_hinode(inode, dentry);
++ if (!err)
++ au_reset_hinotify(inode, flags);
++ }
++ if (unlikely(err))
++ Err("unrecoverable error %d\n", err);
++ di_read_unlock(parent, AUFS_I_RLOCK);
++ dput(parent);
++ di_write_unlock(dentry);
++
++ TraceErr(err);
++ return err;
++}
++
++static int test_dir(struct dentry *dentry, void *arg)
++{
++ return S_ISDIR(dentry->d_inode->i_mode);
++}
++
++static int refresh_dir(struct dentry *root, int sgen)
++{
++ int err, i, j, ndentry;
++ const unsigned int flags = au_hi_flags(root->d_inode, /*isdir*/1);
++ struct au_dcsub_pages dpages;
++ struct au_dpage *dpage;
++ struct dentry **dentries;
++
++ LKTRTrace("sgen %d\n", sgen);
++ SiMustWriteLock(root->d_sb);
++ DEBUG_ON(au_digen(root) != sgen);
++ DiMustWriteLock(root);
++
++ err = au_dpages_init(&dpages, GFP_KERNEL);
++ if (unlikely(err))
++ goto out;
++ err = au_dcsub_pages(&dpages, root, test_dir, NULL);
++ if (unlikely(err))
++ goto out_dpages;
++
++ DiMustNoWaiters(root);
++ IiMustNoWaiters(root->d_inode);
++ di_write_unlock(root);
++ for (i = 0; !err && i < dpages.ndpage; i++) {
++ dpage = dpages.dpages + i;
++ dentries = dpage->dentries;
++ ndentry = dpage->ndentry;
++ for (j = 0; !err && j < ndentry; j++) {
++ struct dentry *d;
++ d = dentries[j];
++ DEBUG_ON(!S_ISDIR(d->d_inode->i_mode)
++ || IS_ROOT(d)
++ || au_digen(d->d_parent) != sgen);
++ if (au_digen(d) != sgen)
++ err = do_refresh_dir(d, flags);
++ }
++ }
++ di_write_lock_child(root); /* aufs_write_lock() calls ..._child() */
++
++ out_dpages:
++ au_dpages_free(&dpages);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* stop extra interpretation of errno in mount(8), and strange error messages */
++static int cvt_err(int err)
++{
++ TraceErr(err);
++
++ switch (err) {
++ case -ENOENT:
++ case -ENOTDIR:
++ case -EEXIST:
++ case -EIO:
++ err = -EINVAL;
++ }
++ return err;
++}
++
++/* protected by s_umount */
++static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
++{
++ int err, do_refresh;
++ struct dentry *root;
++ struct inode *inode;
++ struct opts opts;
++ unsigned int given, dlgt;
++
++ //au_debug_on();
++ LKTRTrace("flags 0x%x, data %s, len %d\n",
++ *flags, data ? data : "NULL", data ? strlen(data) : 0);
++
++ err = 0;
++ if (unlikely(!data || !*data))
++ goto out; /* success */
++
++ err = -ENOMEM;
++ memset(&opts, 0, sizeof(opts));
++ opts.opt = (void*)__get_free_page(GFP_KERNEL);
++ //if (LktrCond) {free_page((unsigned long)opts.opt); opts.opt = NULL;}
++ if (unlikely(!opts.opt))
++ goto out;
++ opts.max_opt = PAGE_SIZE / sizeof(*opts.opt);
++
++ /* parse it before aufs lock */
++ err = au_parse_opts(sb, data, &opts);
++ //if (LktrCond) {au_free_opts(&opts); err = -1;}
++ if (unlikely(err))
++ goto out_opts;
++
++ root = sb->s_root;
++ inode = root->d_inode;
++ i_lock(inode);
++ aufs_write_lock(root);
++
++ //DbgSleep(3);
++
++ /* au_do_opts() may return an error */
++ do_refresh = 0;
++ given = 0;
++ err = au_do_opts_remount(sb, &opts, &do_refresh, &given);
++ //if (LktrCond) err = -1;
++ au_free_opts(&opts);
++
++ if (do_refresh) {
++ int rerr;
++ struct aufs_sbinfo *sbinfo;
++
++ dlgt = au_flag_test(sb, AuFlag_DLGT);
++ au_flag_clr(sb, AuFlag_DLGT);
++ au_sigen_inc(sb);
++ au_reset_hinotify(inode, au_hi_flags(inode, /*isdir*/1));
++ sbinfo = stosi(sb);
++ sbinfo->si_failed_refresh_dirs = 0;
++ rerr = refresh_dir(root, au_sigen(sb));
++ if (unlikely(rerr)) {
++ sbinfo->si_failed_refresh_dirs = 1;
++ Warn("Refreshing directories failed, ignores (%d)\n",
++ rerr);
++ }
++ au_cpup_attr_all(inode);
++ au_flag_set(sb, dlgt);
++ }
++
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ /* braces are added to stop a warning */
++ if (do_refresh) {
++ sysaufs_notify_remount();
++ }
++
++ out_opts:
++ free_page((unsigned long)opts.opt);
++ out:
++ err = cvt_err(err);
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++static struct super_operations aufs_sop = {
++ .alloc_inode = aufs_alloc_inode,
++ .destroy_inode = aufs_destroy_inode,
++ .read_inode = aufs_read_inode,
++ //.dirty_inode = aufs_dirty_inode,
++ //.write_inode = aufs_write_inode,
++ //void (*put_inode) (struct inode *);
++ .drop_inode = generic_delete_inode,
++ //.delete_inode = aufs_delete_inode,
++ //.clear_inode = aufs_clear_inode,
++
++ .show_options = aufs_show_options,
++ .statfs = aufs_statfs,
++
++ .put_super = aufs_put_super,
++ //void (*write_super) (struct super_block *);
++ //int (*sync_fs)(struct super_block *sb, int wait);
++ //void (*write_super_lockfs) (struct super_block *);
++ //void (*unlockfs) (struct super_block *);
++ .remount_fs = aufs_remount_fs,
++ // depends upon umount flags. also use put_super() (< 2.6.18)
++ .umount_begin = aufs_umount_begin
++};
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * at first mount time.
++ */
++
++static int alloc_sbinfo(struct super_block *sb)
++{
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++
++ sbinfo = kmalloc(sizeof(*sbinfo), GFP_KERNEL);
++ //if (LktrCond) {kfree(sbinfo); sbinfo = NULL;}
++ if (unlikely(!sbinfo))
++ goto out;
++ sbinfo->si_branch = kzalloc(sizeof(*sbinfo->si_branch), GFP_KERNEL);
++ //if (LktrCond) {kfree(sbinfo->si_branch); sbinfo->si_branch = NULL;}
++ if (unlikely(!sbinfo->si_branch)) {
++ kfree(sbinfo);
++ goto out;
++ }
++ rw_init_wlock(&sbinfo->si_rwsem);
++ sbinfo->si_bend = -1;
++ atomic_long_set(&sbinfo->si_xino, AUFS_FIRST_INO);
++ spin_lock_init(&sbinfo->si_plink_lock);
++ INIT_LIST_HEAD(&sbinfo->si_plink);
++ init_lvma(sbinfo);
++ sbinfo->si_generation = 0;
++ sbinfo->si_last_br_id = 0;
++ sbinfo->si_failed_refresh_dirs = 0;
++ sbinfo->si_flags = 0;
++ sbinfo->si_dirwh = AUFS_DIRWH_DEF;
++ sbinfo->si_rdcache = AUFS_RDCACHE_DEF * HZ;
++ //atomic_set(&sbinfo->si_hinotify, 0);
++ //init_waitqueue_head(&sbinfo->si_hinotify_wq);
++
++ sb->s_fs_info = sbinfo;
++ au_flag_set(sb, AuDefFlags);
++#ifdef ForceInotify
++ udba_set(sb, AuFlag_UDBA_INOTIFY);
++#endif
++#ifdef ForceDlgt
++ au_flag_set(sb, AuFlag_DLGT);
++#endif
++#ifdef ForceNoPlink
++ au_flag_clr(sb, AuFlag_PLINK);
++#endif
++ return 0; /* success */
++
++ out:
++ TraceErr(-ENOMEM);
++ return -ENOMEM;
++}
++
++static int alloc_root(struct super_block *sb)
++{
++ int err;
++ struct inode *inode;
++ struct dentry *root;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ inode = iget(sb, AUFS_ROOT_INO);
++ //if (LktrCond) {iput(inode); inode = NULL;}
++ if (unlikely(!inode))
++ goto out;
++ err = PTR_ERR(inode);
++ if (IS_ERR(inode))
++ goto out;
++ err = -ENOMEM;
++ if (unlikely(is_bad_inode(inode)))
++ goto out_iput;
++
++ root = d_alloc_root(inode);
++ //if (LktrCond) {igrab(inode); dput(root); root = NULL;}
++ if (unlikely(!root))
++ goto out_iput;
++ err = PTR_ERR(root);
++ if (IS_ERR(root))
++ goto out_iput;
++
++ err = au_alloc_dinfo(root);
++ //if (LktrCond){rw_write_unlock(&dtodi(root)->di_rwsem);err=-1;}
++ if (!err) {
++ sb->s_root = root;
++ return 0; /* success */
++ }
++ dput(root);
++ goto out; /* do not iput */
++
++ out_iput:
++ iput(inode);
++ out:
++ TraceErr(err);
++ return err;
++
++}
++
++static int aufs_fill_super(struct super_block *sb, void *raw_data, int silent)
++{
++ int err;
++ struct dentry *root;
++ struct inode *inode;
++ struct opts opts;
++ char *arg = raw_data;
++
++ //au_debug_on();
++ if (unlikely(!arg || !*arg)) {
++ err = -EINVAL;
++ Err("no arg\n");
++ goto out;
++ }
++ LKTRTrace("%s, silent %d\n", arg, silent);
++
++ err = -ENOMEM;
++ memset(&opts, 0, sizeof(opts));
++ opts.opt = (void*)__get_free_page(GFP_KERNEL);
++ //if (LktrCond) {free_page((unsigned long)opts.opt); opts.opt = NULL;}
++ if (unlikely(!opts.opt))
++ goto out;
++ opts.max_opt = PAGE_SIZE / sizeof(*opts.opt);
++
++ err = alloc_sbinfo(sb);
++ //if (LktrCond) {si_write_unlock(sb);free_sbinfo(stosi(sb));err=-1;}
++ if (unlikely(err))
++ goto out_opts;
++ SiMustWriteLock(sb);
++ /* all timestamps always follow the ones on the branch */
++ sb->s_flags |= MS_NOATIME | MS_NODIRATIME;
++ sb->s_op = &aufs_sop;
++ au_init_export_op(sb);
++ //err = kobj_mount(stosi(sb));
++ //if (err)
++ //goto out_info;
++
++ err = alloc_root(sb);
++ //if (LktrCond) {rw_write_unlock(&dtodi(sb->s_root)->di_rwsem);
++ //dput(sb->s_root);sb->s_root=NULL;err=-1;}
++ if (unlikely(err)) {
++ DEBUG_ON(sb->s_root);
++ si_write_unlock(sb);
++ goto out_info;
++ }
++ root = sb->s_root;
++ DiMustWriteLock(root);
++ inode = root->d_inode;
++ inode->i_nlink = 2;
++
++ /*
++ * actually we can parse options regardless aufs lock here.
++ * but at remount time, parsing must be done before aufs lock.
++ * so we follow the same rule.
++ */
++ ii_write_lock_parent(inode);
++ aufs_write_unlock(root);
++ err = au_parse_opts(sb, arg, &opts);
++ //if (LktrCond) {au_free_opts(&opts); err = -1;}
++ if (unlikely(err))
++ goto out_root;
++
++ /* lock vfs_inode first, then aufs. */
++ i_lock(inode);
++ inode->i_op = &aufs_dir_iop;
++ inode->i_fop = &aufs_dir_fop;
++ aufs_write_lock(root);
++
++ sb->s_maxbytes = 0;
++ err = au_do_opts_mount(sb, &opts);
++ //if (LktrCond) err = -1;
++ au_free_opts(&opts);
++ if (unlikely(err))
++ goto out_unlock;
++ DEBUG_ON(!sb->s_maxbytes);
++
++ //DbgDentry(root);
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ //DbgSb(sb);
++ goto out_opts; /* success */
++
++ out_unlock:
++ aufs_write_unlock(root);
++ i_unlock(inode);
++ out_root:
++ dput(root);
++ sb->s_root = NULL;
++ out_info:
++ free_sbinfo(stosi(sb));
++ sb->s_fs_info = NULL;
++ out_opts:
++ free_page((unsigned long)opts.opt);
++ out:
++ TraceErr(err);
++ err = cvt_err(err);
++ TraceErr(err);
++ //au_debug_off();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++static int aufs_get_sb(struct file_system_type *fs_type, int flags,
++ const char *dev_name, void *raw_data,
++ struct vfsmount *mnt)
++{
++ int err;
++
++ /* all timestamps always follow the ones on the branch */
++ //mnt->mnt_flags |= MNT_NOATIME | MNT_NODIRATIME;
++ err = get_sb_nodev(fs_type, flags, raw_data, aufs_fill_super, mnt);
++ if (!err) {
++ struct aufs_sbinfo *sbinfo = stosi(mnt->mnt_sb);
++ sbinfo->si_mnt = mnt;
++ sysaufs_add(sbinfo);
++ }
++ return err;
++}
++#else
++static struct super_block *aufs_get_sb(struct file_system_type *fs_type,
++ int flags, const char *dev_name,
++ void *raw_data)
++{
++ return get_sb_nodev(fs_type, flags, raw_data, aufs_fill_super);
++}
++#endif
++
++struct file_system_type aufs_fs_type = {
++ .name = AUFS_FSTYPE,
++ .fs_flags = FS_REVAL_DOT, // for UDBA and NFS branch
++ .get_sb = aufs_get_sb,
++ .kill_sb = generic_shutdown_super,
++ //no need to __module_get() and module_put().
++ .owner = THIS_MODULE,
++};
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/super.h linux-2.6.22.1/fs/aufs/super.h
+--- linux-2.6.22.1.oorig/fs/aufs/super.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/super.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,339 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: super.h,v 1.44 2007/05/14 03:39:54 sfjro Exp $ */
++
++#ifndef __AUFS_SUPER_H__
++#define __AUFS_SUPER_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/version.h>
++#include <linux/aufs_type.h>
++#include "misc.h"
++#include "sysaufs.h"
++
++#ifdef CONFIG_AUFS_SYSAUFS
++/* entries under sysfs per mount-point */
++enum {SysaufsSb_XINO, /* SysaufsSb_PLINK, */ SysaufsSb_Last};
++struct sysaufs_sbinfo {
++ au_subsys_t subsys;
++ struct sysaufs_entry array[SysaufsSb_Last];
++};
++extern sysaufs_op au_si_ops[];
++#else
++struct sysaufs_sbinfo {};
++#endif
++
++struct aufs_sbinfo {
++ struct aufs_rwsem si_rwsem;
++
++ /* branch management */
++ /* wrap around attack by superuser? No. */
++ int si_generation;
++
++ /*
++ * set true when refresh_dirs() at remount time failed.
++ * then try refreshing dirs at access time again.
++ * if it is false, refreshing dirs at access time is unnecesary
++ */
++ unsigned int si_failed_refresh_dirs:1;
++
++ aufs_bindex_t si_bend;
++ aufs_bindex_t si_last_br_id;
++ struct aufs_branch **si_branch;
++
++ /* mount flags */
++ unsigned int si_flags;
++
++ /* external inode number table */
++ atomic_long_t si_xino; // time bomb
++ //struct file *si_xino_bmap;
++
++ /* readdir cache time, max, in HZ */
++ unsigned long si_rdcache;
++
++ /*
++ * If the number of whiteouts are larger than si_dirwh, leave all of
++ * them after rename_whtmp to reduce the cost of rmdir(2).
++ * future fsck.aufs or kernel thread will remove them later.
++ * Otherwise, remove all whiteouts and the dir in rmdir(2).
++ */
++ unsigned int si_dirwh;
++
++ /* pseudo_link list */ // dirty
++ spinlock_t si_plink_lock;
++ struct list_head si_plink;
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++ /* super_blocks list is not exported */
++ struct list_head si_list;
++ struct vfsmount *si_mnt; /* no get/put */
++#endif
++
++ /* sysfs */
++ struct sysaufs_sbinfo si_sysaufs;
++
++#ifdef CONFIG_AUFS_HINOTIFY
++ /* hinotify */
++ //atomic_t si_hinotify;
++ //wait_queue_head_t si_hinotify_wq;
++#endif
++
++#ifdef CONFIG_AUFS_ROBR
++ /* locked vma list for mmap() */ // very dirty
++ spinlock_t si_lvma_lock;
++ struct list_head si_lvma;
++#endif
++};
++
++/* an entry in a xino file */
++struct xino {
++ ino_t ino;
++ //__u32 h_gen;
++} __attribute__ ((packed));
++
++//#define AuXino_INVALID_HGEN (-1)
++
++/* ---------------------------------------------------------------------- */
++
++/* Mount flags */
++#define AuFlag_XINO 1
++#define AuFlag_ZXINO (1 << 1)
++#define AuFlag_PLINK (1 << 2)
++#define AuFlag_UDBA_NONE (1 << 3)
++#define AuFlag_UDBA_REVAL (1 << 4)
++#define AuFlag_UDBA_INOTIFY (1 << 5)
++#define AuFlag_WARN_PERM (1 << 6)
++#define AuFlag_COO_NONE (1 << 7)
++#define AuFlag_COO_LEAF (1 << 8)
++#define AuFlag_COO_ALL (1 << 9)
++#define AuFlag_ALWAYS_DIROPQ (1 << 10)
++#define AuFlag_DLGT (1 << 11)
++
++#define AuMask_UDBA (AuFlag_UDBA_NONE | AuFlag_UDBA_REVAL \
++ | AuFlag_UDBA_INOTIFY)
++#define AuMask_COO (AuFlag_COO_NONE | AuFlag_COO_LEAF \
++ | AuFlag_COO_ALL)
++
++#ifdef CONFIG_AUFS_COMPAT
++#define AuDefFlag_DIROPQ AuFlag_ALWAYS_DIROPQ
++#else
++#define AuDefFlag_DIROPQ 0
++#endif
++
++#define AuDefFlags_COMM (AuFlag_XINO | AuFlag_UDBA_REVAL | AuFlag_WARN_PERM \
++ | AuFlag_COO_NONE | AuDefFlag_DIROPQ)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
++#define AuDefFlags (AuDefFlags_COMM | AuFlag_PLINK)
++#else
++#define AuDefFlags AuDefFlags_COMM
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* flags for aufs_read_lock()/di_read_lock() */
++#define AUFS_D_WLOCK 1
++#define AUFS_I_RLOCK 2
++#define AUFS_I_WLOCK 4
++
++/* ---------------------------------------------------------------------- */
++
++/* super.c */
++int au_show_brs(struct seq_file *seq, struct super_block *sb);
++
++/* xino.c */
++struct file *xino_create(struct super_block *sb, char *fname, int silent,
++ struct dentry *parent);
++ino_t xino_new_ino(struct super_block *sb);
++int xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino);
++int xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino);
++int xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino);
++int xino_init(struct super_block *sb, aufs_bindex_t bindex,
++ struct file *base_file, int do_test);
++struct opt_xino;
++int xino_set(struct super_block *sb, struct opt_xino *xino, int remount);
++int xino_clr(struct super_block *sb);
++struct file *xino_def(struct super_block *sb);
++
++/* sbinfo.c */
++struct aufs_sbinfo *stosi(struct super_block *sb);
++aufs_bindex_t sbend(struct super_block *sb);
++struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex);
++int au_sigen(struct super_block *sb);
++int au_sigen_inc(struct super_block *sb);
++int find_bindex(struct super_block *sb, struct aufs_branch *br);
++
++void aufs_read_lock(struct dentry *dentry, int flags);
++void aufs_read_unlock(struct dentry *dentry, int flags);
++void aufs_write_lock(struct dentry *dentry);
++void aufs_write_unlock(struct dentry *dentry);
++void aufs_read_and_write_lock2(struct dentry *d1, struct dentry *d2, int isdir);
++void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2);
++
++aufs_bindex_t new_br_id(struct super_block *sb);
++
++/* ---------------------------------------------------------------------- */
++
++static inline const char *au_sbtype(struct super_block *sb)
++{
++ return sb->s_type->name;
++}
++
++static inline int au_is_aufs(struct super_block *sb)
++{
++ return !strcmp(au_sbtype(sb), AUFS_FSTYPE);
++}
++
++static inline int au_is_nfs(struct super_block *sb)
++{
++#if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
++ return !strcmp(au_sbtype(sb), "nfs");
++#else
++ return 0;
++#endif
++}
++
++static inline int au_is_remote(struct super_block *sb)
++{
++ return au_is_nfs(sb);
++}
++
++#ifdef CONFIG_AUFS_EXPORT
++static inline void au_init_export_op(struct super_block *sb)
++{
++ extern struct export_operations aufs_export_op;
++ sb->s_export_op = &aufs_export_op;
++}
++
++static inline int au_is_nfsd(struct task_struct *tsk)
++{
++ return (!tsk->mm && !strcmp(tsk->comm, "nfsd"));
++}
++
++static inline void au_nfsd_lockdep_off(void)
++{
++ /* braces are added to stop a warning */
++ if (au_is_nfsd(current)) {
++ lockdep_off();
++ }
++}
++
++static inline void au_nfsd_lockdep_on(void)
++{
++ /* braces are added to stop a warning */
++ if (au_is_nfsd(current)) {
++ lockdep_on();
++ }
++}
++#else
++static inline int au_is_nfsd(struct task_struct *tsk)
++{
++ return 0;
++}
++static inline void au_init_export_op(struct super_block *sb)
++{
++ /* nothing */
++}
++#define au_nfsd_lockdep_off() /* */
++#define au_nfsd_lockdep_on() /* */
++#endif /* CONFIG_AUFS_EXPORT */
++
++static inline void init_lvma(struct aufs_sbinfo *sbinfo)
++{
++#ifdef CONFIG_AUFS_ROBR
++ spin_lock_init(&sbinfo->si_lvma_lock);
++ INIT_LIST_HEAD(&sbinfo->si_lvma);
++#else
++ /* nothing */
++#endif
++}
++
++/* limited support before 2.6.18 */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
++static inline void au_mntget(struct super_block *sb)
++{
++ mntget(stosi(sb)->si_mnt);
++}
++
++static inline void au_mntput(struct super_block *sb)
++{
++ mntput(stosi(sb)->si_mnt);
++}
++#else
++static inline void au_mntget(struct super_block *sb)
++{
++ /* empty */
++}
++
++static inline void au_mntput(struct super_block *sb)
++{
++ /* empty */
++}
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++static inline void au_flag_set(struct super_block *sb, unsigned int flag)
++{
++ //SiMustWriteLock(sb);
++ stosi(sb)->si_flags |= flag;
++}
++
++static inline void au_flag_clr(struct super_block *sb, unsigned int flag)
++{
++ //SiMustWriteLock(sb);
++ stosi(sb)->si_flags &= ~flag;
++}
++
++static inline
++unsigned int au_flag_test(struct super_block *sb, unsigned int flag)
++{
++ //SiMustAnyLock(sb);
++ return stosi(sb)->si_flags & flag;
++}
++
++static inline unsigned int au_flag_test_udba(struct super_block *sb)
++{
++ return au_flag_test(sb, AuMask_UDBA);
++}
++
++static inline unsigned int au_flag_test_coo(struct super_block *sb)
++{
++ return au_flag_test(sb, AuMask_COO);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* lock superblock. mainly for entry point functions */
++/*
++ * si_read_lock, si_write_lock,
++ * si_read_unlock, si_write_unlock, si_downgrade_lock
++ */
++SimpleRwsemFuncs(si, struct super_block *sb, stosi(sb)->si_rwsem);
++
++/* to debug easier, do not make them inlined functions */
++#define SiMustReadLock(sb) RwMustReadLock(&stosi(sb)->si_rwsem)
++#define SiMustWriteLock(sb) RwMustWriteLock(&stosi(sb)->si_rwsem)
++#define SiMustAnyLock(sb) RwMustAnyLock(&stosi(sb)->si_rwsem)
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_SUPER_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/sysaufs.c linux-2.6.22.1/fs/aufs/sysaufs.c
+--- linux-2.6.22.1.oorig/fs/aufs/sysaufs.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/sysaufs.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,620 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sysaufs.c,v 1.6 2007/05/14 03:40:10 sfjro Exp $ */
++
++#include <linux/module.h>
++#include <linux/seq_file.h>
++#include <linux/sysfs.h>
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++/* super_blocks list is not exported */
++static DEFINE_MUTEX(aufs_sbilist_mtx);
++static LIST_HEAD(aufs_sbilist);
++
++/* ---------------------------------------------------------------------- */
++
++typedef ssize_t (*rwfunc_t)(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args);
++static ssize_t sysaufs_read(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args);
++static ssize_t sysaufs_free_write(struct kobject *kobj, char *buf, loff_t
++ offset, size_t sz, struct sysaufs_args *args);
++
++#define GFunc(name, _index, func) \
++static ssize_t name(struct kobject *kobj, char *buf, loff_t offset, size_t sz) \
++{ \
++ struct sysaufs_args args = { \
++ .index = (_index), \
++ .mtx = &aufs_sbilist_mtx, \
++ .sb = NULL \
++ }; \
++ return func(kobj, buf, offset, sz, &args); \
++}
++
++#define GFuncs(name, _index) \
++ GFunc(read_##name, _index, sysaufs_read); \
++ GFunc(write_##name, _index, sysaufs_free_write);
++
++static struct super_block *find_sb_locked(struct kobject *kobj)
++{
++ struct super_block *sb;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ sb = NULL;
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ if (&au_subsys_to_kset(sbinfo->si_sysaufs.subsys).kobj != kobj)
++ continue;
++ sb = sbinfo->si_mnt->mnt_sb;
++ si_read_lock(sb);
++ break;
++ }
++ return sb;
++}
++
++static ssize_t sb_func(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args, rwfunc_t func)
++{
++ ssize_t err;
++
++ err = -ENOENT;
++ mutex_lock(&aufs_sbilist_mtx);
++ args->sb = find_sb_locked(kobj);
++ if (args->sb) {
++ err = func(kobj, buf, offset, sz, args);
++ si_read_unlock(args->sb);
++ }
++ mutex_unlock(&aufs_sbilist_mtx);
++ return err;
++}
++
++#define SbFunc(name, _index, func) \
++static ssize_t name(struct kobject *kobj, char *buf, loff_t offset, size_t sz) \
++{ \
++ struct sysaufs_args args = { \
++ .index = (_index), \
++ .mtx = NULL \
++ }; \
++ return sb_func(kobj, buf, offset, sz, &args, func); \
++}
++
++#define SbFuncs(name, index) \
++ SbFunc(read_##name, index, sysaufs_read); \
++ SbFunc(write_##name, index, sysaufs_free_write)
++
++static decl_subsys(aufs, NULL, NULL);
++enum {Brs, Stat, Config, _Last};
++static struct sysaufs_entry g_array[_Last];
++GFuncs(brs, Brs);
++GFuncs(stat, Stat);
++GFuncs(config, Config);
++
++SbFuncs(xino, SysaufsSb_XINO);
++
++#define SetEntry(e, _name, init_size, _ops) \
++ do { \
++ (e)->attr.attr.name = #_name; \
++ (e)->attr.attr.owner = THIS_MODULE; \
++ (e)->attr.attr.mode = S_IRUGO | S_IWUSR; \
++ (e)->attr.read = read_##_name; \
++ (e)->attr.write = write_##_name; \
++ (e)->allocated = init_size; \
++ (e)->err = -1; \
++ (e)->ops = _ops; \
++ } while (0)
++
++#define Priv(e) (e)->attr.private
++#define Allocated(e) (e)->allocated
++#define Len(e) (e)->attr.size
++#define Name(e) attr_name((e)->attr)
++
++/* ---------------------------------------------------------------------- */
++
++static void free_entry(struct sysaufs_entry *e)
++{
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(!Priv(e));
++
++ if (Allocated(e) > 0)
++ kfree(Priv(e));
++ else
++ free_pages((unsigned long)Priv(e), -Allocated(e));
++ Priv(e) = NULL;
++ Len(e) = 0;
++}
++
++static void free_entries(void)
++{
++ static int a[] = {Brs, -1};
++ int *p = a;
++
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ while (*p >= 0) {
++ if (Priv(g_array + *p))
++ free_entry(g_array + *p);
++ p++;
++ }
++}
++
++static int alloc_entry(struct sysaufs_entry *e)
++{
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(Priv(e));
++ //Dbg("%d\n", Allocated(e));
++
++ if (Allocated(e) > 0)
++ Priv(e) = kmalloc(Allocated(e), GFP_KERNEL);
++ else
++ Priv(e) = (void*)__get_free_pages(GFP_KERNEL, -Allocated(e));
++ if (Priv(e))
++ return 0;
++ return -ENOMEM;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void unreg(au_subsys_t *subsys, struct sysaufs_entry *a, int n,
++ au_subsys_t *parent)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < n; i++, a++)
++ if (!a->err) {
++ sysfs_remove_bin_file
++ (&au_subsys_to_kset(*subsys).kobj, &a->attr);
++ if (Priv(a))
++ free_entry(a);
++ }
++
++ subsystem_unregister(subsys);
++ subsys_put(parent);
++}
++
++static int reg(au_subsys_t *subsys, struct sysaufs_entry *a, int n,
++ au_subsys_t *parent)
++{
++ int err, i;
++
++ TraceEnter();
++
++ subsys_get(parent);
++ kobj_set_kset_s(&au_subsys_to_kset(*subsys), *parent);
++ err = subsystem_register(subsys);
++ if (unlikely(err))
++ goto out;
++
++ for (i = 0; !err && i < n; i++)
++ err = a[i].err = sysfs_create_bin_file
++ (&au_subsys_to_kset(*subsys).kobj, &a[i].attr);
++ if (unlikely(err))
++ unreg(subsys, a, n, parent);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#define SbSetEntry(index, name, init_size) \
++ SetEntry(sa->array + index, name, init_size, au_si_ops);
++
++void sysaufs_add(struct aufs_sbinfo *sbinfo)
++{
++ int err;
++ struct sysaufs_sbinfo *sa = &sbinfo->si_sysaufs;
++
++ TraceEnter();
++
++ mutex_lock(&aufs_sbilist_mtx);
++ list_add_tail(&sbinfo->si_list, &aufs_sbilist);
++ free_entries();
++
++ memset(sa, 0, sizeof(*sa));
++ SbSetEntry(SysaufsSb_XINO, xino, 128);
++ err = kobject_set_name(&au_subsys_to_kset(sa->subsys).kobj, "%p",
++ sbinfo->si_mnt->mnt_sb);
++ if (!err)
++ err = reg(&sa->subsys, sa->array, ARRAY_SIZE(sa->array),
++ &aufs_subsys);
++ if (unlikely(err))
++ Warn("failed adding sysfs (%d)\n", err);
++
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++void sysaufs_del(struct aufs_sbinfo *sbinfo)
++{
++ struct sysaufs_sbinfo *sa = &sbinfo->si_sysaufs;
++
++ TraceEnter();
++
++ mutex_lock(&aufs_sbilist_mtx);
++ unreg(&sa->subsys, sa->array, ARRAY_SIZE(sa->array), &aufs_subsys);
++ list_del(&sbinfo->si_list);
++ free_entries();
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++void sysaufs_notify_remount(void)
++{
++ mutex_lock(&aufs_sbilist_mtx);
++ free_entries();
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int make_brs(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++ struct aufs_sbinfo *sbinfo;
++
++ TraceEnter();
++ MtxMustLock(&aufs_sbilist_mtx);
++ DEBUG_ON(args->index != Brs);
++
++ err = 0;
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ struct super_block *sb;
++ struct dentry *root;
++ struct vfsmount *mnt;
++
++ sb = sbinfo->si_mnt->mnt_sb;
++ root = sb->s_root;
++ aufs_read_lock(root, !AUFS_I_RLOCK);
++ mnt = sbinfo->si_mnt;
++ err = seq_escape
++ (seq, mnt->mnt_devname ? mnt->mnt_devname : "none",
++ au_esc_chars);
++ if (!err)
++ err = seq_putc(seq, ' ');
++ if (!err)
++ err = seq_path(seq, mnt, root, au_esc_chars);
++ if (err > 0)
++ err = seq_printf(seq, " %p br:", sb);
++ if (!err)
++ err = au_show_brs(seq, sb);
++ aufs_read_unlock(root, !AUFS_I_RLOCK);
++ if (!err)
++ err = seq_putc(seq, '\n');
++ else
++ break;
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++static int make_config(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err;
++
++ TraceEnter();
++ DEBUG_ON(args->index != Config);
++
++#ifdef CONFIG_AUFS
++ err = seq_puts(seq, "CONFIG_AUFS=y\n");
++#else
++ err = seq_puts(seq, "CONFIG_AUFS=m\n");
++#endif
++
++#define puts(m, v) \
++ if (!err) err = seq_puts(seq, "CONFIG_AUFS_" #m "=" #v "\n")
++#define puts_bool(m) puts(m, y)
++#define puts_mod(m) puts(m, m)
++
++#ifdef CONFIG_AUFS_FAKE_DM
++ puts_bool(FAKE_DM);
++#endif
++#ifdef CONFIG_AUFS_BRANCH_MAX_127
++ puts_bool(BRANCH_MAX_127);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_511)
++ puts_bool(BRANCH_MAX_511);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
++ puts_bool(BRANCH_MAX_1023);
++#elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
++ puts_bool(BRANCH_MAX_32767);
++#endif
++ puts_bool(SYSAUFS);
++#ifdef CONFIG_AUFS_HINOTIFY
++ puts_bool(HINOTIFY);
++#endif
++#ifdef CONFIG_AUFS_EXPORT
++ puts_bool(EXPORT);
++#endif
++#ifdef CONFIG_AUFS_ROBR
++ puts_bool(ROBR);
++#endif
++#ifdef CONFIG_AUFS_DLGT
++ puts_bool(DLGT);
++#endif
++#ifdef CONFIG_AUFS_LHASH_PATCH
++ puts_bool(LHASH_PATCH);
++#endif
++#ifdef CONFIG_AUFS_KSIZE_PATCH
++ puts_bool(KSIZE_PATCH);
++#endif
++#ifdef CONFIG_AUFS_DEBUG
++ puts_bool(DEBUG);
++#endif
++#ifdef CONFIG_AUFS_COMPAT
++ puts_bool(COMPAT);
++#endif
++
++#undef puts_bool
++#undef puts
++
++ TraceErr(err);
++ return err;
++}
++
++static int make_stat(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size)
++{
++ int err, i;
++
++ TraceEnter();
++ DEBUG_ON(args->index != Stat);
++
++ *do_size = 0;
++ err = seq_puts(seq, "wkq max_busy:");
++ for (i = 0; !err && i < aufs_nwkq; i++)
++ err = seq_printf(seq, " %u", au_wkq[i].max_busy);
++ if (!err)
++ err = seq_printf(seq, ", %u(generic)\n",
++ au_wkq[aufs_nwkq].max_busy);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int make(struct sysaufs_entry *e, struct sysaufs_args *args,
++ int *do_size)
++
++{
++ int err;
++ struct seq_file *seq;
++
++ TraceEnter();
++ DEBUG_ON(Priv(e));
++ MtxMustLock(&aufs_sbilist_mtx);
++
++ err = -ENOMEM;
++ seq = kzalloc(sizeof(*seq), GFP_KERNEL);
++ if (unlikely(!seq))
++ goto out;
++
++ Len(e) = 0;
++ while (1) {
++ err = alloc_entry(e);
++ if (unlikely(err))
++ break;
++
++ //mutex_init(&seq.lock);
++ seq->buf = Priv(e);
++ seq->count = 0;
++ seq->size = Allocated(e);
++ if (unlikely(Allocated(e) <= 0))
++ seq->size = PAGE_SIZE << -Allocated(e);
++
++ err = e->ops[args->index](seq, args, do_size);
++ if (!err) {
++ Len(e) = seq->count;
++ break; /* success */
++ }
++
++ free_entry(e);
++ if (Allocated(e) > 0) {
++ Allocated(e) <<= 1;
++ if (unlikely(Allocated(e) >= (int)PAGE_SIZE))
++ Allocated(e) = 0;
++ } else
++ Allocated(e)--;
++ //Dbg("%d\n", Allocated(e));
++ }
++ kfree(seq);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* why does sysfs pass my parent kobject? */
++static struct dentry *find_me(struct dentry *parent, struct sysaufs_entry *e)
++{
++#if 1
++ struct dentry *dentry;
++ const char *name = Name(e);
++ const unsigned int len = strlen(name);
++
++ //Dbg("%.*s\n", DLNPair(parent));
++ spin_lock(&dcache_lock);
++ list_for_each_entry(dentry, &parent->d_subdirs, D_CHILD) {
++ //Dbg("%.*s\n", DLNPair(dentry));
++ if (len == dentry->d_name.len
++ && !strcmp(dentry->d_name.name, name)) {
++ spin_unlock(&dcache_lock);
++ return dentry;
++ }
++ }
++ spin_unlock(&dcache_lock);
++#endif
++ return NULL;
++}
++
++static ssize_t sysaufs_read(struct kobject *kobj, char *buf, loff_t offset,
++ size_t sz, struct sysaufs_args *args)
++{
++ ssize_t err;
++ loff_t len;
++ struct dentry *d;
++ struct sysaufs_entry *e;
++ int do_size;
++
++ LKTRTrace("{%d, %p}, offset %Ld, sz %lu\n",
++ args->index, args->sb, offset, (unsigned long)sz);
++
++ if (unlikely(!sz))
++ return 0;
++
++ err = 0;
++ d = NULL;
++ e = g_array + args->index;
++ if (args->sb)
++ e = stosi(args->sb)->si_sysaufs.array + args->index;
++
++ do_size = 1;
++ if (args->mtx)
++ mutex_lock(args->mtx);
++ if (unlikely(!Priv(e))) {
++ err = make(e, args, &do_size);
++ DEBUG_ON(Len(e) > INT_MAX);
++ if (do_size) {
++ d = find_me(kobj->dentry, e);
++ if (d)
++ i_size_write(d->d_inode, Len(e));
++ }
++ }
++
++ if (!err) {
++ err = len = Len(e) - offset;
++ LKTRTrace("%Ld\n", len);
++ if (len > 0) {
++ if (len > sz)
++ err = sz;
++ memcpy(buf, Priv(e) + offset, err);
++ }
++
++ if (!do_size)
++ free_entry(e);
++ }
++ if (args->mtx)
++ mutex_unlock(args->mtx);
++
++ TraceErr(err);
++ return err;
++}
++
++static ssize_t sysaufs_free_write(struct kobject *kobj, char *buf,
++ loff_t offset, size_t sz,
++ struct sysaufs_args *args)
++{
++ struct dentry *d;
++ int allocated, len;
++ struct sysaufs_entry *e;
++
++ LKTRTrace("{%d, %p}\n", args->index, args->sb);
++
++ e = g_array + args->index;
++ if (args->sb)
++ e = stosi(args->sb)->si_sysaufs.array + args->index;
++
++ if (args->mtx)
++ mutex_lock(args->mtx);
++ if (Priv(e)) {
++ allocated = Allocated(e);
++ if (unlikely(allocated <= 0))
++ allocated = PAGE_SIZE << -allocated;
++ allocated >>= 1;
++ len = Len(e);
++
++ free_entry(e);
++ if (unlikely(len <= allocated)) {
++ if (Allocated(e) >= 0)
++ Allocated(e) = allocated;
++ else
++ Allocated(e)++;
++ }
++
++ d = find_me(kobj->dentry, e);
++ if (d && i_size_read(d->d_inode))
++ i_size_write(d->d_inode, 0);
++ }
++ if (args->mtx)
++ mutex_unlock(args->mtx);
++
++ return sz;
++}
++
++static sysaufs_op g_ops[] = {
++ [Brs] = make_brs,
++ [Stat] = make_stat,
++ [Config] = make_config
++};
++
++/* ---------------------------------------------------------------------- */
++
++#define GSetEntry(index, name, init_size) \
++ SetEntry(g_array + index, name, init_size, g_ops)
++
++int __init sysaufs_init(void)
++{
++ int err;
++
++ GSetEntry(Brs, brs, 128);
++ GSetEntry(Stat, stat, 32);
++ GSetEntry(Config, config, 256);
++ err = reg(&aufs_subsys, g_array, ARRAY_SIZE(g_array), &fs_subsys);
++ TraceErr(err);
++ return err;
++}
++
++void __exit sysaufs_fin(void)
++{
++ mutex_lock(&aufs_sbilist_mtx);
++ unreg(&aufs_subsys, g_array, ARRAY_SIZE(g_array), &fs_subsys);
++ mutex_unlock(&aufs_sbilist_mtx);
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef DbgDlgt
++int is_branch(struct super_block *h_sb)
++{
++ int found = 0;
++ struct aufs_sbinfo *sbinfo;
++
++ //Dbg("here\n");
++ mutex_lock(&aufs_sbilist_mtx);
++ list_for_each_entry(sbinfo, &aufs_sbilist, si_list) {
++ aufs_bindex_t bindex, bend;
++ struct super_block *sb;
++
++ sb = sbinfo->si_mnt->mnt_sb;
++ si_read_lock(sb);
++ bend = sbend(sb);
++ for (bindex = 0; !found && bindex <= bend; bindex++)
++ found = (h_sb == sbr_sb(sb, bindex));
++ si_read_unlock(sb);
++ }
++ mutex_unlock(&aufs_sbilist_mtx);
++ return found;
++}
++#endif
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/sysaufs.h linux-2.6.22.1/fs/aufs/sysaufs.h
+--- linux-2.6.22.1.oorig/fs/aufs/sysaufs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/sysaufs.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,83 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: sysaufs.h,v 1.3 2007/05/14 06:27:18 sfjro Exp $ */
++
++#ifndef __SYSAUFS_H__
++#define __SYSAUFS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/seq_file.h>
++#include <linux/sysfs.h>
++#include <linux/version.h>
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
++typedef struct kset au_subsys_t;
++#define au_subsys_to_kset(subsys) (subsys)
++#else
++typedef struct subsystem au_subsys_t;
++#define au_subsys_to_kset(subsys) ((subsys).kset)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* arguments for an entry under sysfs */
++struct sysaufs_args {
++ int index;
++ struct mutex *mtx;
++ struct super_block *sb;
++};
++
++typedef int (*sysaufs_op)(struct seq_file *seq, struct sysaufs_args *args,
++ int *do_size);
++
++/* an entry under sysfs */
++struct sysaufs_entry {
++ struct bin_attribute attr;
++ int allocated; /* zero minus means pages */
++ int err;
++ sysaufs_op *ops;
++};
++
++/* ---------------------------------------------------------------------- */
++
++struct aufs_sbinfo;
++#ifdef CONFIG_AUFS_SYSAUFS
++void sysaufs_add(struct aufs_sbinfo *sbinfo);
++void sysaufs_del(struct aufs_sbinfo *sbinfo);
++int __init sysaufs_init(void);
++void sysaufs_fin(void);
++void sysaufs_notify_remount(void);
++#else
++static inline void sysaufs_add(struct aufs_sbinfo *sbinfo)
++{
++ /* nothing */
++}
++
++static inline void sysaufs_del(struct aufs_sbinfo *sbinfo)
++{
++ /* nothing */
++}
++#define sysaufs_init() 0
++#define sysaufs_fin() /* */
++#define sysaufs_notify_remount() /* */
++#endif /* CONFIG_AUFS_SYSAUFS */
++
++#endif /* __KERNEL__ */
++#endif /* __SYSAUFS_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/vdir.c linux-2.6.22.1/fs/aufs/vdir.c
+--- linux-2.6.22.1.oorig/fs/aufs/vdir.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/vdir.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,802 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vdir.c,v 1.22 2007/05/14 03:38:52 sfjro Exp $ */
++
++#include "aufs.h"
++
++static int calc_size(int namelen)
++{
++ int sz;
++
++ sz = sizeof(struct aufs_de) + namelen;
++ if (sizeof(ino_t) == sizeof(long)) {
++ const int mask = sizeof(ino_t) - 1;
++ if (sz & mask) {
++ sz += sizeof(ino_t);
++ sz &= ~mask;
++ }
++ } else {
++#if 0 // remove
++ BUG();
++ // this block will be discarded by optimizer.
++ int m;
++ m = sz % sizeof(ino_t);
++ if (m)
++ sz += sizeof(ino_t) - m;
++#endif
++ }
++
++ DEBUG_ON(sz % sizeof(ino_t));
++ return sz;
++}
++
++static int set_deblk_end(union aufs_deblk_p *p, union aufs_deblk_p *deblk_end)
++{
++ if (calc_size(0) <= deblk_end->p - p->p) {
++ p->de->de_str.len = 0;
++ //smp_mb();
++ return 0;
++ }
++ return -1; // error
++}
++
++/* returns true or false */
++static int is_deblk_end(union aufs_deblk_p *p, union aufs_deblk_p *deblk_end)
++{
++ if (calc_size(0) <= deblk_end->p - p->p)
++ return !p->de->de_str.len;
++ return 1;
++}
++
++static aufs_deblk_t *last_deblk(struct aufs_vdir *vdir)
++{
++ return vdir->vd_deblk[vdir->vd_nblk - 1];
++}
++
++void nhash_init(struct aufs_nhash *nhash)
++{
++ int i;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++)
++ INIT_HLIST_HEAD(nhash->heads + i);
++}
++
++struct aufs_nhash *nhash_new(gfp_t gfp)
++{
++ struct aufs_nhash *nhash;
++
++ nhash = kmalloc(sizeof(*nhash), gfp);
++ if (nhash) {
++ nhash_init(nhash);
++ return nhash;
++ }
++ return ERR_PTR(-ENOMEM);
++}
++
++void nhash_del(struct aufs_nhash *nhash)
++{
++ nhash_fin(nhash);
++ kfree(nhash);
++}
++
++void nhash_move(struct aufs_nhash *dst, struct aufs_nhash *src)
++{
++ int i;
++
++ TraceEnter();
++
++ //DbgWhlist(src);
++ *dst = *src;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ struct hlist_head *h;
++ h = dst->heads + i;
++ if (h->first)
++ h->first->pprev = &h->first;
++ INIT_HLIST_HEAD(src->heads + i);
++ }
++ //DbgWhlist(src);
++ //DbgWhlist(dst);
++ //smp_mb();
++}
++
++/* ---------------------------------------------------------------------- */
++
++void nhash_fin(struct aufs_nhash *whlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos, *n;
++
++ TraceEnter();
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry_safe(tpos, pos, n, head, wh_hash) {
++ //hlist_del(pos);
++ kfree(tpos);
++ }
++ }
++}
++
++int is_longer_wh(struct aufs_nhash *whlist, aufs_bindex_t btgt, int limit)
++{
++ int n, i;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++
++ LKTRTrace("limit %d\n", limit);
++ //return 1;
++
++ n = 0;
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash)
++ if (tpos->wh_bindex == btgt && ++n > limit)
++ return 1;
++ }
++ return 0;
++}
++
++/* returns found(true) or not */
++int test_known_wh(struct aufs_nhash *whlist, char *name, int namelen)
++{
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ head = whlist->heads + au_name_hash(name, namelen);
++ hlist_for_each_entry(tpos, pos, head, wh_hash) {
++ str = &tpos->wh_str;
++ LKTRTrace("%.*s\n", str->len, str->name);
++ if (str->len == namelen && !memcmp(str->name, name, namelen))
++ return 1;
++ }
++ return 0;
++}
++
++int append_wh(struct aufs_nhash *whlist, char *name, int namelen,
++ aufs_bindex_t bindex)
++{
++ int err;
++ struct aufs_destr *str;
++ struct aufs_wh *wh;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ err = -ENOMEM;
++ wh = kmalloc(sizeof(*wh) + namelen, GFP_KERNEL);
++ if (unlikely(!wh))
++ goto out;
++ err = 0;
++ wh->wh_bindex = bindex;
++ str = &wh->wh_str;
++ str->len = namelen;
++ memcpy(str->name, name, namelen);
++ hlist_add_head(&wh->wh_hash,
++ whlist->heads + au_name_hash(name, namelen));
++ //smp_mb();
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++void free_vdir(struct aufs_vdir *vdir)
++{
++ aufs_deblk_t **deblk;
++
++ TraceEnter();
++
++ deblk = vdir->vd_deblk;
++ while (vdir->vd_nblk--) {
++ kfree(*deblk);
++ deblk++;
++ }
++ kfree(vdir->vd_deblk);
++ cache_free_vdir(vdir);
++}
++
++static int append_deblk(struct aufs_vdir *vdir)
++{
++ int err, sz, i;
++ aufs_deblk_t **o;
++ union aufs_deblk_p p, deblk_end;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ sz = sizeof(*o) * vdir->vd_nblk;
++ o = au_kzrealloc(vdir->vd_deblk, sz, sz + sizeof(*o), GFP_KERNEL);
++ if (unlikely(!o))
++ goto out;
++ vdir->vd_deblk = o;
++ p.deblk = kmalloc(sizeof(*p.deblk), GFP_KERNEL);
++ if (p.deblk) {
++ i = vdir->vd_nblk++;
++ vdir->vd_deblk[i] = p.deblk;
++ vdir->vd_last.i = i;
++ vdir->vd_last.p.p = p.p;
++ deblk_end.deblk = p.deblk + 1;
++ err = set_deblk_end(&p, &deblk_end);
++ DEBUG_ON(err);
++ }
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static struct aufs_vdir *alloc_vdir(void)
++{
++ struct aufs_vdir *vdir;
++ int err;
++
++ TraceEnter();
++
++ err = -ENOMEM;
++ vdir = cache_alloc_vdir();
++ if (unlikely(!vdir))
++ goto out;
++ vdir->vd_deblk = kzalloc(sizeof(*vdir->vd_deblk), GFP_KERNEL);
++ if (unlikely(!vdir->vd_deblk))
++ goto out_free;
++
++ vdir->vd_nblk = 0;
++ vdir->vd_version = 0;
++ vdir->vd_jiffy = 0;
++ err = append_deblk(vdir);
++ if (!err)
++ return vdir; /* success */
++
++ kfree(vdir->vd_deblk);
++
++ out_free:
++ cache_free_vdir(vdir);
++ out:
++ vdir = ERR_PTR(err);
++ TraceErrPtr(vdir);
++ return vdir;
++}
++
++static int reinit_vdir(struct aufs_vdir *vdir)
++{
++ int err;
++ union aufs_deblk_p p, deblk_end;
++
++ TraceEnter();
++
++ while (vdir->vd_nblk > 1) {
++ kfree(vdir->vd_deblk[vdir->vd_nblk - 1]);
++ vdir->vd_deblk[vdir->vd_nblk - 1] = NULL;
++ vdir->vd_nblk--;
++ }
++ p.deblk = vdir->vd_deblk[0];
++ deblk_end.deblk = p.deblk + 1;
++ err = set_deblk_end(&p, &deblk_end);
++ DEBUG_ON(err);
++ vdir->vd_version = 0;
++ vdir->vd_jiffy = 0;
++ vdir->vd_last.i = 0;
++ vdir->vd_last.p.deblk = vdir->vd_deblk[0];
++ //smp_mb();
++ //DbgVdir(vdir);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void free_dehlist(struct aufs_nhash *dehlist)
++{
++ int i;
++ struct hlist_head *head;
++ struct aufs_dehstr *tpos;
++ struct hlist_node *pos, *n;
++
++ TraceEnter();
++
++ for (i = 0; i < AUFS_NHASH_SIZE; i++) {
++ head = dehlist->heads + i;
++ hlist_for_each_entry_safe(tpos, pos, n, head, hash) {
++ //hlist_del(pos);
++ cache_free_dehstr(tpos);
++ }
++ }
++}
++
++/* returns found(true) or not */
++static int test_known(struct aufs_nhash *delist, char *name, int namelen)
++{
++ struct hlist_head *head;
++ struct aufs_dehstr *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", namelen, name);
++
++ head = delist->heads + au_name_hash(name, namelen);
++ hlist_for_each_entry(tpos, pos, head, hash) {
++ str = tpos->str;
++ LKTRTrace("%.*s\n", str->len, str->name);
++ if (str->len == namelen && !memcmp(str->name, name, namelen))
++ return 1;
++ }
++ return 0;
++
++}
++
++static int append_de(struct aufs_vdir *vdir, char *name, int namelen, ino_t ino,
++ unsigned int d_type, struct aufs_nhash *delist)
++{
++ int err, sz;
++ union aufs_deblk_p p, *room, deblk_end;
++ struct aufs_dehstr *dehstr;
++
++ LKTRTrace("%.*s %d, i%lu, dt%u\n", namelen, name, namelen, ino, d_type);
++
++ p.deblk = last_deblk(vdir);
++ deblk_end.deblk = p.deblk + 1;
++ room = &vdir->vd_last.p;
++ DEBUG_ON(room->p < p.p || deblk_end.p <= room->p
++ || !is_deblk_end(room, &deblk_end));
++
++ sz = calc_size(namelen);
++ if (unlikely(sz > deblk_end.p - room->p)) {
++ err = append_deblk(vdir);
++ if (unlikely(err))
++ goto out;
++ p.deblk = last_deblk(vdir);
++ deblk_end.deblk = p.deblk + 1;
++ //smp_mb();
++ DEBUG_ON(room->p != p.p);
++ }
++
++ err = -ENOMEM;
++ dehstr = cache_alloc_dehstr();
++ if (unlikely(!dehstr))
++ goto out;
++ dehstr->str = &room->de->de_str;
++ hlist_add_head(&dehstr->hash,
++ delist->heads + au_name_hash(name, namelen));
++
++ room->de->de_ino = ino;
++ room->de->de_type = d_type;
++ room->de->de_str.len = namelen;
++ memcpy(room->de->de_str.name, name, namelen);
++
++ err = 0;
++ room->p += sz;
++ if (unlikely(set_deblk_end(room, &deblk_end)))
++ err = append_deblk(vdir);
++ //smp_mb();
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct fillvdir_arg {
++ struct file *file;
++ struct aufs_vdir *vdir;
++ struct aufs_nhash *delist;
++ struct aufs_nhash *whlist;
++ aufs_bindex_t bindex;
++ int err;
++ int called;
++};
++
++static int fillvdir(void *__arg, const char *__name, int namelen, loff_t offset,
++ filldir_ino_t h_ino, unsigned int d_type)
++{
++ struct fillvdir_arg *arg = __arg;
++ char *name = (void*)__name;
++ aufs_bindex_t bindex, bend;
++ struct xino xino;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, namelen %d, i%Lu, dt%u\n",
++ namelen, name, namelen, (u64)h_ino, d_type);
++
++ sb = arg->file->f_dentry->d_sb;
++ bend = arg->bindex;
++ arg->err = 0;
++ arg->called++;
++ //smp_mb();
++ if (namelen <= AUFS_WH_PFX_LEN
++ || memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) {
++ for (bindex = 0; bindex < bend; bindex++)
++ if (test_known(arg->delist + bindex, name, namelen)
++ || test_known_wh(arg->whlist + bindex, name,
++ namelen))
++ goto out; /* already exists or whiteouted */
++
++ arg->err = xino_read(sb, bend, h_ino, &xino);
++ if (!arg->err && !xino.ino) {
++ //struct inode *h_inode;
++ xino.ino = xino_new_ino(sb);
++ if (unlikely(!xino.ino))
++ arg->err = -EIO;
++#if 0
++ //xino.h_gen = AuXino_INVALID_HGEN;
++ h_inode = ilookup(sbr_sb(sb, bend), h_ino);
++ if (h_inode) {
++ if (!is_bad_inode(h_inode)) {
++ xino.h_gen = h_inode->i_generation;
++ WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ }
++ iput(h_inode);
++ }
++#endif
++ arg->err = xino_write(sb, bend, h_ino, &xino);
++ }
++ if (!arg->err)
++ arg->err = append_de(arg->vdir, name, namelen, xino.ino,
++ d_type, arg->delist + bend);
++ } else {
++ name += AUFS_WH_PFX_LEN;
++ namelen -= AUFS_WH_PFX_LEN;
++ for (bindex = 0; bindex < bend; bindex++)
++ if (test_known_wh(arg->whlist + bend, name, namelen))
++ goto out; /* already whiteouted */
++ arg->err = append_wh(arg->whlist + bend, name, namelen, bend);
++ }
++
++ out:
++ if (!arg->err)
++ arg->vdir->vd_jiffy = jiffies;
++ //smp_mb();
++ TraceErr(arg->err);
++ return arg->err;
++}
++
++static int read_vdir(struct file *file, int may_read)
++{
++ int err, do_read, dlgt;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_vdir *vdir, *allocated;
++ unsigned long expire;
++ struct fillvdir_arg arg;
++ aufs_bindex_t bindex, bend, bstart;
++ struct super_block *sb;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, may %d\n", DLNPair(dentry), may_read);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ IMustLock(inode);
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++
++ err = 0;
++ allocated = NULL;
++ do_read = 0;
++ sb = inode->i_sb;
++ expire = stosi(sb)->si_rdcache;
++ vdir = ivdir(inode);
++ if (!vdir) {
++ DEBUG_ON(fvdir_cache(file));
++ do_read = 1;
++ vdir = alloc_vdir();
++ err = PTR_ERR(vdir);
++ if (IS_ERR(vdir))
++ goto out;
++ err = 0;
++ allocated = vdir;
++ } else if (may_read
++ && (inode->i_version != vdir->vd_version
++ || time_after(jiffies, vdir->vd_jiffy + expire))) {
++ LKTRTrace("iver %lu, vdver %lu, exp %lu\n",
++ inode->i_version, vdir->vd_version,
++ vdir->vd_jiffy + expire);
++ do_read = 1;
++ err = reinit_vdir(vdir);
++ if (unlikely(err))
++ goto out;
++ }
++ //DbgVdir(vdir); goto out;
++
++ if (!do_read)
++ return 0; /* success */
++
++ err = -ENOMEM;
++ bend = fbend(file);
++ arg.delist = kmalloc(sizeof(*arg.delist) * (bend + 1), GFP_KERNEL);
++ if (unlikely(!arg.delist))
++ goto out_vdir;
++ arg.whlist = kmalloc(sizeof(*arg.whlist) * (bend + 1), GFP_KERNEL);
++ if (unlikely(!arg.whlist))
++ goto out_delist;
++ err = 0;
++ for (bindex = 0; bindex <= bend; bindex++) {
++ nhash_init(arg.delist + bindex);
++ nhash_init(arg.whlist + bindex);
++ }
++
++ dlgt = need_dlgt(sb);
++ arg.file = file;
++ arg.vdir = vdir;
++ bstart = fbstart(file);
++ for (bindex = bstart; !err && bindex <= bend; bindex++) {
++ struct file *hf;
++ struct inode *h_inode;
++
++ hf = au_h_fptr_i(file, bindex);
++ if (!hf)
++ continue;
++
++ h_inode = hf->f_dentry->d_inode;
++ //hf->f_pos = 0;
++ arg.bindex = bindex;
++ do {
++ arg.err = 0;
++ arg.called = 0;
++ //smp_mb();
++ err = vfsub_readdir(hf, fillvdir, &arg, dlgt);
++ if (err >= 0)
++ err = arg.err;
++ } while (!err && arg.called);
++ }
++
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ free_dehlist(arg.delist + bindex);
++ nhash_fin(arg.whlist + bindex);
++ }
++ kfree(arg.whlist);
++
++ out_delist:
++ kfree(arg.delist);
++ out_vdir:
++ if (!err) {
++ //file->f_pos = 0;
++ vdir->vd_version = inode->i_version;
++ vdir->vd_last.i = 0;
++ vdir->vd_last.p.deblk = vdir->vd_deblk[0];
++ if (allocated)
++ set_ivdir(inode, allocated);
++ } else if (allocated)
++ free_vdir(allocated);
++ //DbgVdir(vdir); goto out;
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static int copy_vdir(struct aufs_vdir *tgt, struct aufs_vdir *src)
++{
++ int err, i, rerr, n;
++
++ TraceEnter();
++ DEBUG_ON(tgt->vd_nblk != 1);
++ //DbgVdir(tgt);
++
++ err = -ENOMEM;
++ if (tgt->vd_nblk < src->vd_nblk) {
++ aufs_deblk_t **p;
++ p = au_kzrealloc(tgt->vd_deblk, sizeof(*p) * tgt->vd_nblk,
++ sizeof(*p) * src->vd_nblk, GFP_KERNEL);
++ if (unlikely(!p))
++ goto out;
++ tgt->vd_deblk = p;
++ }
++
++ n = tgt->vd_nblk = src->vd_nblk;
++ memcpy(tgt->vd_deblk[0], src->vd_deblk[0], AUFS_DEBLK_SIZE);
++ //tgt->vd_last.i = 0;
++ //tgt->vd_last.p.deblk = tgt->vd_deblk[0];
++ tgt->vd_version = src->vd_version;
++ tgt->vd_jiffy = src->vd_jiffy;
++
++ for (i = 1; i < n; i++) {
++ tgt->vd_deblk[i] = kmalloc(AUFS_DEBLK_SIZE, GFP_KERNEL);
++ if (tgt->vd_deblk[i])
++ memcpy(tgt->vd_deblk[i], src->vd_deblk[i],
++ AUFS_DEBLK_SIZE);
++ else
++ goto out;
++ }
++ //smp_mb();
++ //DbgVdir(tgt);
++ return 0; /* success */
++
++ out:
++ rerr = reinit_vdir(tgt);
++ BUG_ON(rerr);
++ TraceErr(err);
++ return err;
++}
++
++int au_init_vdir(struct file *file)
++{
++ int err;
++ struct dentry *dentry;
++ struct inode *inode;
++ struct aufs_vdir *vdir_cache, *allocated;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ FiMustWriteLock(file);
++ inode = dentry->d_inode;
++ IiMustWriteLock(inode);
++ DEBUG_ON(!S_ISDIR(inode->i_mode));
++
++ err = read_vdir(file, !file->f_pos);
++ if (unlikely(err))
++ goto out;
++ //DbgVdir(ivdir(inode)); goto out;
++
++ allocated = NULL;
++ vdir_cache = fvdir_cache(file);
++ if (!vdir_cache) {
++ vdir_cache = alloc_vdir();
++ err = PTR_ERR(vdir_cache);
++ if (IS_ERR(vdir_cache))
++ goto out;
++ allocated = vdir_cache;
++ } else if (!file->f_pos && vdir_cache->vd_version != file->f_version) {
++ err = reinit_vdir(vdir_cache);
++ if (unlikely(err))
++ goto out;
++ } else
++ return 0; /* success */
++ //err = 0; DbgVdir(vdir_cache); goto out;
++
++ err = copy_vdir(vdir_cache, ivdir(inode));
++ if (!err) {
++ file->f_version = inode->i_version;
++ if (allocated)
++ set_fvdir_cache(file, allocated);
++ } else if (allocated)
++ free_vdir(allocated);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++static loff_t calc_offset(struct aufs_vdir *vdir)
++{
++ loff_t offset;
++ union aufs_deblk_p p;
++
++ p.deblk = vdir->vd_deblk[vdir->vd_last.i];
++ offset = vdir->vd_last.p.p - p.p;
++ offset += sizeof(*p.deblk) * vdir->vd_last.i;
++ return offset;
++}
++
++/* returns true or false */
++static int seek_vdir(struct file *file)
++{
++ int valid, i, n;
++ struct dentry *dentry;
++ struct aufs_vdir *vdir_cache;
++ loff_t offset;
++ union aufs_deblk_p p, deblk_end;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ vdir_cache = fvdir_cache(file);
++ DEBUG_ON(!vdir_cache);
++ //DbgVdir(vdir_cache);
++
++ valid = 1;
++ offset = calc_offset(vdir_cache);
++ LKTRTrace("offset %Ld\n", offset);
++ if (file->f_pos == offset)
++ goto out;
++
++ vdir_cache->vd_last.i = 0;
++ vdir_cache->vd_last.p.deblk = vdir_cache->vd_deblk[0];
++ if (!file->f_pos)
++ goto out;
++
++ valid = 0;
++ i = file->f_pos / AUFS_DEBLK_SIZE;
++ LKTRTrace("i %d\n", i);
++ if (i >= vdir_cache->vd_nblk)
++ goto out;
++
++ n = vdir_cache->vd_nblk;
++ //DbgVdir(vdir_cache);
++ for (; i < n; i++) {
++ p.deblk = vdir_cache->vd_deblk[i];
++ deblk_end.deblk = p.deblk + 1;
++ offset = i * AUFS_DEBLK_SIZE;
++ while (!is_deblk_end(&p, &deblk_end) && offset < file->f_pos) {
++ int l;
++ l = calc_size(p.de->de_str.len);
++ offset += l;
++ p.p += l;
++ }
++ if (!is_deblk_end(&p, &deblk_end)) {
++ valid = 1;
++ vdir_cache->vd_last.i = i;
++ vdir_cache->vd_last.p = p;
++ break;
++ }
++ }
++
++ out:
++ //smp_mb();
++ //DbgVdir(vdir_cache);
++ TraceErr(!valid);
++ return valid;
++}
++
++int au_fill_de(struct file *file, void *dirent, filldir_t filldir)
++{
++ int err, l;
++ struct dentry *dentry;
++ struct aufs_vdir *vdir_cache;
++ struct aufs_de *de;
++ union aufs_deblk_p deblk_end;
++
++ dentry = file->f_dentry;
++ LKTRTrace("%.*s, pos %Ld\n", DLNPair(dentry), file->f_pos);
++ vdir_cache = fvdir_cache(file);
++ DEBUG_ON(!vdir_cache);
++ //DbgVdir(vdir_cache);
++
++ if (!seek_vdir(file))
++ return 0;
++
++ while (1) {
++ deblk_end.deblk
++ = vdir_cache->vd_deblk[vdir_cache->vd_last.i] + 1;
++ while (!is_deblk_end(&vdir_cache->vd_last.p, &deblk_end)) {
++ de = vdir_cache->vd_last.p.de;
++ LKTRTrace("%.*s, off%Ld, i%lu, dt%d\n",
++ de->de_str.len, de->de_str.name,
++ file->f_pos, de->de_ino, de->de_type);
++ err = filldir(dirent, de->de_str.name, de->de_str.len,
++ file->f_pos, de->de_ino, de->de_type);
++ if (unlikely(err)) {
++ TraceErr(err);
++ //return err;
++ //todo: ignore the error caused by udba.
++ return 0;
++ }
++
++ l = calc_size(de->de_str.len);
++ vdir_cache->vd_last.p.p += l;
++ file->f_pos += l;
++ }
++ if (vdir_cache->vd_last.i < vdir_cache->vd_nblk - 1) {
++ vdir_cache->vd_last.i++;
++ vdir_cache->vd_last.p.deblk
++ = vdir_cache->vd_deblk[vdir_cache->vd_last.i];
++ file->f_pos = sizeof(*vdir_cache->vd_last.p.deblk)
++ * vdir_cache->vd_last.i;
++ continue;
++ }
++ break;
++ }
++
++ //smp_mb();
++ return 0;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/vfsub.c linux-2.6.22.1/fs/aufs/vfsub.c
+--- linux-2.6.22.1.oorig/fs/aufs/vfsub.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/vfsub.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,665 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vfsub.c,v 1.5 2007/04/23 00:55:06 sfjro Exp $ */
++// I'm going to slightly mad
++
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++struct permission_args {
++ int *errp;
++ struct inode *inode;
++ int mask;
++ struct nameidata *nd;
++};
++
++static void call_permission(void *args)
++{
++ struct permission_args *a = args;
++ *a->errp = do_vfsub_permission(a->inode, a->mask, a->nd);
++}
++
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_permission(inode, mask, nd);
++ else {
++ int err;
++ struct permission_args args = {
++ .errp = &err,
++ .inode = inode,
++ .mask = mask,
++ .nd = nd
++ };
++ au_wkq_wait(call_permission, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct create_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++ struct nameidata *nd;
++};
++
++static void call_create(void *args)
++{
++ struct create_args *a = args;
++ *a->errp = do_vfsub_create(a->dir, a->dentry, a->mode, a->nd);
++}
++
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_create(dir, dentry, mode, nd);
++ else {
++ int err;
++ struct create_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode,
++ .nd = nd
++ };
++ au_wkq_wait(call_create, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct symlink_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ const char *symname;
++ int mode;
++};
++
++static void call_symlink(void *args)
++{
++ struct symlink_args *a = args;
++ *a->errp = do_vfsub_symlink(a->dir, a->dentry, a->symname, a->mode);
++}
++
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_symlink(dir, dentry, symname, mode);
++ else {
++ int err;
++ struct symlink_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .symname = symname,
++ .mode = mode
++ };
++ au_wkq_wait(call_symlink, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct mknod_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++ dev_t dev;
++};
++
++static void call_mknod(void *args)
++{
++ struct mknod_args *a = args;
++ *a->errp = do_vfsub_mknod(a->dir, a->dentry, a->mode, a->dev);
++}
++
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_mknod(dir, dentry, mode, dev);
++ else {
++ int err;
++ struct mknod_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode,
++ .dev = dev
++ };
++ au_wkq_wait(call_mknod, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct mkdir_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++ int mode;
++};
++
++static void call_mkdir(void *args)
++{
++ struct mkdir_args *a = args;
++ *a->errp = do_vfsub_mkdir(a->dir, a->dentry, a->mode);
++}
++
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_mkdir(dir, dentry, mode);
++ else {
++ int err;
++ struct mkdir_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry,
++ .mode = mode
++ };
++ au_wkq_wait(call_mkdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct link_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *src_dentry, *dentry;
++};
++
++static void call_link(void *args)
++{
++ struct link_args *a = args;
++ *a->errp = do_vfsub_link(a->src_dentry, a->dir, a->dentry);
++}
++
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_link(src_dentry, dir, dentry);
++ else {
++ int err;
++ struct link_args args = {
++ .errp = &err,
++ .src_dentry = src_dentry,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_link, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct rename_args {
++ int *errp;
++ struct inode *src_dir, *dir;
++ struct dentry *src_dentry, *dentry;
++};
++
++static void call_rename(void *args)
++{
++ struct rename_args *a = args;
++ *a->errp = do_vfsub_rename(a->src_dir, a->src_dentry, a->dir,
++ a->dentry);
++}
++
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_rename(src_dir, src_dentry, dir, dentry);
++ else {
++ int err;
++ struct rename_args args = {
++ .errp = &err,
++ .src_dir = src_dir,
++ .src_dentry = src_dentry,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_rename, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct rmdir_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++};
++
++static void call_rmdir(void *args)
++{
++ struct rmdir_args *a = args;
++ *a->errp = do_vfsub_rmdir(a->dir, a->dentry);
++}
++
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_rmdir(dir, dentry);
++ else {
++ int err;
++ struct rmdir_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry
++ };
++ au_wkq_wait(call_rmdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct read_args {
++ ssize_t *errp;
++ struct file *file;
++ union {
++ void *kbuf;
++ char __user *ubuf;
++ };
++ size_t count;
++ loff_t *ppos;
++};
++
++static void call_read_k(void *args)
++{
++ struct read_args *a = args;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(a->file->f_dentry), (unsigned long)a->count,
++ *a->ppos);
++ *a->errp = do_vfsub_read_k(a->file, a->kbuf, a->count, a->ppos);
++}
++
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_read_u(file, ubuf, count, ppos);
++ else {
++ ssize_t err, read;
++ struct read_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++
++ if (unlikely(!count))
++ return 0;
++
++ /*
++ * workaround an application bug.
++ * generally, read(2) or write(2) may return the value shorter
++ * than requested. But many applications don't support it,
++ * for example bash.
++ */
++ err = -ENOMEM;
++ if (args.count > PAGE_SIZE)
++ args.count = PAGE_SIZE;
++ args.kbuf = kmalloc(args.count, GFP_KERNEL);
++ if (unlikely(!args.kbuf))
++ goto out;
++
++ read = 0;
++ do {
++ au_wkq_wait(call_read_k, &args, /*dlgt*/1);
++ if (unlikely(err > 0
++ && copy_to_user(ubuf, args.kbuf, err))) {
++ err = -EFAULT;
++ goto out_free;
++ } else if (!err)
++ break;
++ else if (unlikely(err < 0))
++ goto out_free;
++ count -= err;
++ /* do not read too much because of file i/o pointer */
++ if (unlikely(count < args.count))
++ args.count = count;
++ ubuf += err;
++ read += err;
++ } while (count);
++ smp_mb();
++ err = read;
++
++ out_free:
++ kfree(args.kbuf);
++ out:
++ return err;
++ }
++}
++
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_read_k(file, kbuf, count, ppos);
++ else {
++ ssize_t err;
++ struct read_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++ args.kbuf = kbuf;
++ au_wkq_wait(call_read_k, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct write_args {
++ ssize_t *errp;
++ struct file *file;
++ union {
++ void *kbuf;
++ const char __user *ubuf;
++ };
++ void *buf;
++ size_t count;
++ loff_t *ppos;
++};
++
++static void call_write_k(void *args)
++{
++ struct write_args *a = args;
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(a->file->f_dentry), (unsigned long)a->count,
++ *a->ppos);
++ *a->errp = do_vfsub_write_k(a->file, a->kbuf, a->count, a->ppos);
++}
++
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_write_u(file, ubuf, count, ppos);
++ else {
++ ssize_t err, written;
++ struct write_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++
++ if (unlikely(!count))
++ return 0;
++
++ /*
++ * workaround an application bug.
++ * generally, read(2) or write(2) may return the value shorter
++ * than requested. But many applications don't support it,
++ * for example bash.
++ */
++ err = -ENOMEM;
++ if (args.count > PAGE_SIZE)
++ args.count = PAGE_SIZE;
++ args.kbuf = kmalloc(args.count, GFP_KERNEL);
++ if (unlikely(!args.kbuf))
++ goto out;
++
++ written = 0;
++ do {
++ if (unlikely(copy_from_user(args.kbuf, ubuf, args.count))) {
++ err = -EFAULT;
++ goto out_free;
++ }
++
++ au_wkq_wait(call_write_k, &args, /*dlgt*/1);
++ if (err > 0) {
++ count -= err;
++ if (count < args.count)
++ args.count = count;
++ ubuf += err;
++ written += err;
++ } else if (!err)
++ break;
++ else if (unlikely(err < 0))
++ goto out_free;
++ } while (count);
++ err = written;
++
++ out_free:
++ kfree(args.kbuf);
++ out:
++ return err;
++ }
++}
++
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_write_k(file, kbuf, count, ppos);
++ else {
++ ssize_t err;
++ struct write_args args = {
++ .errp = &err,
++ .file = file,
++ .count = count,
++ .ppos = ppos
++ };
++ args.kbuf = kbuf;
++ au_wkq_wait(call_write_k, &args, /*dlgt*/1);
++ return err;
++ }
++}
++
++struct readdir_args {
++ int *errp;
++ struct file *file;
++ filldir_t filldir;
++ void *arg;
++};
++
++static void call_readdir(void *args)
++{
++ struct readdir_args *a = args;
++ *a->errp = do_vfsub_readdir(a->file, a->filldir, a->arg);
++}
++
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
++{
++ if (!dlgt)
++ return do_vfsub_readdir(file, filldir, arg);
++ else {
++ int err;
++ struct readdir_args args = {
++ .errp = &err,
++ .file = file,
++ .filldir = filldir,
++ .arg = arg
++ };
++ au_wkq_wait(call_readdir, &args, /*dlgt*/1);
++ return err;
++ }
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++/* ---------------------------------------------------------------------- */
++
++struct notify_change_args {
++ int *errp;
++ struct dentry *h_dentry;
++ struct iattr *ia;
++};
++
++static void call_notify_change(void *args)
++{
++ struct notify_change_args *a = args;
++ struct inode *h_inode;
++
++ LKTRTrace("%.*s, ia_valid 0x%x\n",
++ DLNPair(a->h_dentry), a->ia->ia_valid);
++ h_inode = a->h_dentry->d_inode;
++ IMustLock(h_inode);
++
++ *a->errp = -EPERM;
++ if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
++ lockdep_off();
++ *a->errp = notify_change(a->h_dentry, a->ia);
++ lockdep_on();
++ }
++ TraceErr(*a->errp);
++}
++
++int vfsub_notify_change(struct dentry *dentry, struct iattr *ia, int dlgt)
++{
++ int err;
++ struct notify_change_args args = {
++ .errp = &err,
++ .h_dentry = dentry,
++ .ia = ia
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_notify_change(&args);
++#else
++ if (!dlgt)
++ call_notify_change(&args);
++ else
++ au_wkq_wait(call_notify_change, &args, /*dlgt*/1);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct unlink_args {
++ int *errp;
++ struct inode *dir;
++ struct dentry *dentry;
++};
++
++static void call_unlink(void *args)
++{
++ struct unlink_args *a = args;
++ struct inode *h_inode;
++ const int stop_sillyrename = (au_is_nfs(a->dentry->d_sb)
++ && atomic_read(&a->dentry->d_count) == 1);
++
++ LKTRTrace("%.*s, stop_silly %d, cnt %d\n",
++ DLNPair(a->dentry), stop_sillyrename,
++ atomic_read(&a->dentry->d_count));
++ IMustLock(a->dir);
++
++ if (!stop_sillyrename)
++ dget(a->dentry);
++ h_inode = a->dentry->d_inode;
++ if (h_inode)
++ atomic_inc(&h_inode->i_count);
++#if 0 // partial testing
++ {
++ struct qstr *name = &a->dentry->d_name;
++ if (name->len == sizeof(AUFS_XINO_FNAME) - 1
++ && !strncmp(name->name, AUFS_XINO_FNAME, name->len)) {
++ lockdep_off();
++ *a->errp = vfs_unlink(a->dir, a->dentry);
++ lockdep_on();
++ } else
++ err = -1;
++ }
++#else
++ // vfs_unlink() locks inode
++ lockdep_off();
++ *a->errp = vfs_unlink(a->dir, a->dentry);
++ lockdep_on();
++#endif
++
++ if (!stop_sillyrename)
++ dput(a->dentry);
++ if (h_inode)
++ iput(h_inode);
++
++ TraceErr(*a->errp);
++}
++
++/*
++ * @dir: must be locked.
++ * @dentry: target dentry.
++ */
++int vfsub_unlink(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ int err;
++ struct unlink_args args = {
++ .errp = &err,
++ .dir = dir,
++ .dentry = dentry
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_unlink(&args);
++#else
++ if (!dlgt)
++ call_unlink(&args);
++ else
++ au_wkq_wait(call_unlink, &args, /*dlgt*/1);
++#endif
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct statfs_args {
++ int *errp;
++ void *arg;
++ struct kstatfs *buf;
++};
++
++static void call_statfs(void *args)
++{
++ struct statfs_args *a = args;
++ *a->errp = vfs_statfs(a->arg, a->buf);
++}
++
++int vfsub_statfs(void *arg, struct kstatfs *buf, int dlgt)
++{
++ int err;
++ struct statfs_args args = {
++ .errp = &err,
++ .arg = arg,
++ .buf = buf
++ };
++
++#ifndef CONFIG_AUFS_DLGT
++ call_statfs(&args);
++#else
++ if (!dlgt)
++ call_statfs(&args);
++ else
++ au_wkq_wait(call_statfs, &args, /*dlgt*/1);
++#endif
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/vfsub.h linux-2.6.22.1/fs/aufs/vfsub.h
+--- linux-2.6.22.1.oorig/fs/aufs/vfsub.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/vfsub.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,427 @@
++/*
++ * Copyright (C) 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: vfsub.h,v 1.8 2007/05/14 03:39:10 sfjro Exp $ */
++
++#ifndef __AUFS_VFSUB_H__
++#define __AUFS_VFSUB_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <asm/uaccess.h>
++#include "wkq.h"
++
++/* ---------------------------------------------------------------------- */
++
++/* simple abstractions, for future use */
++static inline
++int do_vfsub_permission(struct inode *inode, int mask, struct nameidata *nd)
++{
++ LKTRTrace("i%lu, mask 0x%x, nd %p\n", inode->i_ino, mask, nd);
++#if 0
++#else
++ return permission(inode, mask, nd);
++#endif
++}
++
++static inline
++struct file *vfsub_filp_open(const char *path, int oflags, int mode)
++{
++ struct file *err;
++
++ LKTRTrace("%s\n", path);
++
++ lockdep_off();
++ err = filp_open(path, oflags, mode);
++ lockdep_on();
++ return err;
++}
++
++static inline
++int vfsub_path_lookup(const char *name, unsigned int flags,
++ struct nameidata *nd)
++{
++ int err;
++
++ LKTRTrace("%s\n", name);
++
++ //lockdep_off();
++ err = path_lookup(name, flags, nd);
++ //lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++int do_vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_create(dir, dentry, mode, nd);
++#endif
++}
++
++static inline
++int do_vfsub_symlink(struct inode *dir, struct dentry *dentry,
++ const char *symname, int mode)
++{
++ LKTRTrace("i%lu, %.*s, %s, 0x%x\n",
++ dir->i_ino, DLNPair(dentry), symname, mode);
++#if 0
++#else
++ return vfs_symlink(dir, dentry, symname, mode);
++#endif
++}
++
++static inline
++int do_vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode,
++ dev_t dev)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_mknod(dir, dentry, mode, dev);
++#endif
++}
++
++static inline
++int do_vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("%.*s, i%lu, %.*s\n",
++ DLNPair(src_dentry), dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_link(src_dentry, dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++int do_vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("i%lu, %.*s, i%lu, %.*s\n",
++ src_dir->i_ino, DLNPair(src_dentry),
++ dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_rename(src_dir, src_dentry, dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++int do_vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode)
++{
++ LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, DLNPair(dentry), mode);
++#if 0
++#else
++ return vfs_mkdir(dir, dentry, mode);
++#endif
++}
++
++static inline int do_vfsub_rmdir(struct inode *dir, struct dentry *dentry)
++{
++ int err;
++
++ LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_rmdir(dir, dentry);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++ssize_t do_vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)count, *ppos);
++
++ /* nfs uses some locks */
++ lockdep_off();
++#if 0
++#else
++ err = vfs_read(file, ubuf, count, ppos);
++#endif
++ lockdep_on();
++ return err;
++}
++
++// kernel_read() ??
++static inline
++ssize_t do_vfsub_read_k(struct file *file, void *kbuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ err = do_vfsub_read_u(file, (char __user*)kbuf, count, ppos);
++ set_fs(oldfs);
++ return err;
++}
++
++static inline
++ssize_t do_vfsub_write_u(struct file *file, const char __user *ubuf,
++ size_t count, loff_t *ppos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)count, *ppos);
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_write(file, ubuf, count, ppos);
++#endif
++ lockdep_on();
++ return err;
++}
++
++static inline
++ssize_t do_vfsub_write_k(struct file *file, void *kbuf, size_t count,
++ loff_t *ppos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ err = do_vfsub_write_u(file, (const char __user*)kbuf, count, ppos);
++ set_fs(oldfs);
++ return err;
++}
++
++static inline
++int do_vfsub_readdir(struct file *file, filldir_t filldir, void *arg)
++{
++ int err;
++
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_readdir(file, filldir, arg);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static inline loff_t vfsub_llseek(struct file *file, loff_t offset, int origin)
++{
++ loff_t err;
++
++ LKTRTrace("%.*s\n", DLNPair(file->f_dentry));
++
++ lockdep_off();
++#if 0
++#else
++ err = vfs_llseek(file, offset, origin);
++#endif
++ lockdep_on();
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++static inline int need_dlgt(struct super_block *sb)
++{
++ return (au_flag_test(sb, AuFlag_DLGT) && !is_au_wkq(current));
++}
++
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt);
++
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt);
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt);
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt);
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt);
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt);
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt);
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt);
++
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt);
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt);
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt);
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt);
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt);
++
++#else
++
++static inline int need_dlgt(struct super_block *sb)
++{
++ return 0;
++}
++
++static inline
++int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
++ int dlgt)
++{
++ return do_vfsub_permission(inode, mask, nd);
++}
++
++static inline
++int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
++ struct nameidata *nd, int dlgt)
++{
++ return do_vfsub_create(dir, dentry, mode, nd);
++}
++
++static inline
++int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
++ int mode, int dlgt)
++{
++ return do_vfsub_symlink(dir, dentry, symname, mode);
++}
++
++static inline
++int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
++ int dlgt)
++{
++ return do_vfsub_mknod(dir, dentry, mode, dev);
++}
++
++static inline
++int vfsub_link(struct dentry *src_dentry, struct inode *dir,
++ struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_link(src_dentry, dir, dentry);
++}
++
++static inline
++int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
++ struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_rename(src_dir, src_dentry, dir, dentry);
++}
++
++static inline
++int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode,
++ int dlgt)
++{
++ return do_vfsub_mkdir(dir, dentry, mode);
++}
++
++static inline
++int vfsub_rmdir(struct inode *dir, struct dentry *dentry, int dlgt)
++{
++ return do_vfsub_rmdir(dir, dentry);
++}
++
++static inline
++ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ return do_vfsub_read_u(file, ubuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ return do_vfsub_read_k(file, kbuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
++ loff_t *ppos, int dlgt)
++{
++ return do_vfsub_write_u(file, ubuf, count, ppos);
++}
++
++static inline
++ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
++ int dlgt)
++{
++ return do_vfsub_write_k(file, kbuf, count, ppos);
++}
++
++static inline
++int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
++{
++ return do_vfsub_readdir(file, filldir, arg);
++}
++#endif /* CONFIG_AUFS_DLGT */
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++struct dentry *vfsub_lock_rename(struct dentry *d1, struct dentry *d2)
++{
++ struct dentry *d;
++
++ lockdep_off();
++ d = lock_rename(d1, d2);
++ lockdep_on();
++ return d;
++}
++
++static inline void vfsub_unlock_rename(struct dentry *d1, struct dentry *d2)
++{
++ lockdep_off();
++ unlock_rename(d1, d2);
++ lockdep_on();
++}
++
++/* ---------------------------------------------------------------------- */
++
++int vfsub_notify_change(struct dentry *dentry, struct iattr *ia, int dlgt);
++int vfsub_unlink(struct inode *dir, struct dentry *dentry, int dlgt);
++int vfsub_statfs(void *arg, struct kstatfs *buf, int dlgt);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_VFSUB_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/whout.c linux-2.6.22.1/fs/aufs/whout.c
+--- linux-2.6.22.1.oorig/fs/aufs/whout.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/whout.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,933 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: whout.c,v 1.14 2007/05/14 03:40:40 sfjro Exp $ */
++
++#include <linux/fs.h>
++#include <linux/namei.h>
++#include <linux/random.h>
++#include <linux/security.h>
++#include "aufs.h"
++
++#define WH_MASK S_IRUGO
++
++/* If a directory contains this file, then it is opaque. We start with the
++ * .wh. flag so that it is blocked by lookup.
++ */
++static struct qstr diropq_name = {
++ .name = AUFS_WH_DIROPQ,
++ .len = sizeof(AUFS_WH_DIROPQ) - 1
++};
++
++/*
++ * generate whiteout name, which is NOT terminated by NULL.
++ * @name: original d_name.name
++ * @len: original d_name.len
++ * @wh: whiteout qstr
++ * returns zero when succeeds, otherwise error.
++ * succeeded value as wh->name should be freed by au_free_whname().
++ */
++int au_alloc_whname(const char *name, int len, struct qstr *wh)
++{
++ char *p;
++
++ DEBUG_ON(!name || !len || !wh);
++
++ if (unlikely(len > PATH_MAX - AUFS_WH_PFX_LEN))
++ return -ENAMETOOLONG;
++
++ wh->len = len + AUFS_WH_PFX_LEN;
++ wh->name = p = kmalloc(wh->len, GFP_KERNEL);
++ //if (LktrCond) {kfree(p); wh->name = p = NULL;}
++ if (p) {
++ memcpy(p, AUFS_WH_PFX, AUFS_WH_PFX_LEN);
++ memcpy(p + AUFS_WH_PFX_LEN, name, len);
++ //smp_mb();
++ return 0;
++ }
++ return -ENOMEM;
++}
++
++void au_free_whname(struct qstr *wh)
++{
++ DEBUG_ON(!wh || !wh->name);
++ kfree(wh->name);
++#ifdef CONFIG_AUFS_DEBUG
++ wh->name = NULL;
++#endif
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if the @wh_name exists under @hidden_parent.
++ * @try_sio specifies the necessary of super-io.
++ */
++int is_wh(struct dentry *hidden_parent, struct qstr *wh_name, int try_sio,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct dentry *wh_dentry;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n", DLNPair(hidden_parent),
++ wh_name->len, wh_name->name, lkup->nfsmnt, lkup->dlgt);
++ hidden_dir = hidden_parent->d_inode;
++ DEBUG_ON(!S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ if (!try_sio)
++ wh_dentry = lkup_one(wh_name->name, hidden_parent,
++ wh_name->len, lkup);
++ else
++ wh_dentry = sio_lkup_one(wh_name->name, hidden_parent,
++ wh_name->len, lkup);
++ //if (LktrCond) {dput(wh_dentry); wh_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(wh_dentry);
++ if (IS_ERR(wh_dentry))
++ goto out;
++
++ err = 0;
++ if (!wh_dentry->d_inode)
++ goto out_wh; /* success */
++
++ err = 1;
++ if (S_ISREG(wh_dentry->d_inode->i_mode))
++ goto out_wh; /* success */
++
++ err = -EIO;
++ IOErr("%.*s Invalid whiteout entry type 0%o.\n",
++ DLNPair(wh_dentry), wh_dentry->d_inode->i_mode);
++
++ out_wh:
++ dput(wh_dentry);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * test if the @hidden_dentry sets opaque or not.
++ */
++int is_diropq(struct dentry *hidden_dentry, struct lkup_args *lkup)
++{
++ int err;
++ struct inode *hidden_dir;
++
++ LKTRTrace("dentry %.*s\n", DLNPair(hidden_dentry));
++ hidden_dir = hidden_dentry->d_inode;
++ DEBUG_ON(!S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ err = is_wh(hidden_dentry, &diropq_name, /*try_sio*/1, lkup);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * returns a negative dentry whose name is unique and temporary.
++ */
++struct dentry *lkup_whtmp(struct dentry *hidden_parent, struct qstr *prefix,
++ struct lkup_args *lkup)
++{
++#define HEX_LEN 4
++ struct dentry *dentry;
++ int len, i;
++ char defname[AUFS_WH_PFX_LEN * 2 + DNAME_INLINE_LEN_MIN + 1
++ + HEX_LEN + 1], *name, *p;
++ static unsigned char cnt;
++
++ LKTRTrace("hp %.*s, prefix %.*s\n",
++ DLNPair(hidden_parent), prefix->len, prefix->name);
++ DEBUG_ON(!hidden_parent->d_inode);
++ IMustLock(hidden_parent->d_inode);
++
++ name = defname;
++ len = sizeof(defname) - DNAME_INLINE_LEN_MIN + prefix->len - 1;
++ if (unlikely(prefix->len > DNAME_INLINE_LEN_MIN)) {
++ dentry = ERR_PTR(-ENAMETOOLONG);
++ if (unlikely(len >= PATH_MAX))
++ goto out;
++ dentry = ERR_PTR(-ENOMEM);
++ name = kmalloc(len + 1, GFP_KERNEL);
++ //if (LktrCond) {kfree(name); name = NULL;}
++ if (unlikely(!name))
++ goto out;
++ }
++
++ // doubly whiteout-ed
++ memcpy(name, AUFS_WH_PFX AUFS_WH_PFX, AUFS_WH_PFX_LEN * 2);
++ p = name + AUFS_WH_PFX_LEN * 2;
++ memcpy(p, prefix->name, prefix->len);
++ p += prefix->len;
++ *p++ = '.';
++ DEBUG_ON(name + len + 1 - p <= HEX_LEN);
++
++ for (i = 0; i < 3; i++) {
++ sprintf(p, "%.*d", HEX_LEN, cnt++);
++ dentry = sio_lkup_one(name, hidden_parent, len, lkup);
++ //if (LktrCond) {dput(dentry); dentry = ERR_PTR(-1);}
++ if (unlikely(IS_ERR(dentry) || !dentry->d_inode))
++ goto out_name;
++ dput(dentry);
++ }
++ //Warn("could not get random name\n");
++ dentry = ERR_PTR(-EEXIST);
++ Dbg("%.*s\n", len, name);
++ BUG();
++
++ out_name:
++ if (unlikely(name != defname))
++ kfree(name);
++ out:
++ TraceErrPtr(dentry);
++ return dentry;
++#undef HEX_LEN
++}
++
++/*
++ * rename the @dentry of @bindex to the whiteouted temporary name.
++ */
++int rename_whtmp(struct dentry *dentry, aufs_bindex_t bindex)
++{
++ int err;
++ struct inode *hidden_dir;
++ struct dentry *hidden_dentry, *hidden_parent, *tmp_dentry;
++ struct super_block *sb;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry || !hidden_dentry->d_inode);
++ hidden_parent = hidden_dentry->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ sb = dentry->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = need_dlgt(sb);
++ tmp_dentry = lkup_whtmp(hidden_parent, &hidden_dentry->d_name, &lkup);
++ //if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
++ err = PTR_ERR(tmp_dentry);
++ if (!IS_ERR(tmp_dentry)) {
++ /* under the same dir, no need to lock_rename() */
++ err = vfsub_rename(hidden_dir, hidden_dentry,
++ hidden_dir, tmp_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1; //unavailable
++ TraceErr(err);
++ dput(tmp_dentry);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++int au_unlink_wh_dentry(struct inode *hidden_dir, struct dentry *wh_dentry,
++ struct dentry *dentry, int dlgt)
++{
++ int err;
++
++ LKTRTrace("hi%lu, wh %.*s, d %p\n", hidden_dir->i_ino,
++ DLNPair(wh_dentry), dentry);
++ DEBUG_ON((dentry && dbwh(dentry) == -1)
++ || !wh_dentry->d_inode
++ || !S_ISREG(wh_dentry->d_inode->i_mode));
++ IMustLock(hidden_dir);
++
++ err = vfsub_unlink(hidden_dir, wh_dentry, dlgt);
++ //if (LktrCond) err = -1; // unavailable
++ if (!err && dentry)
++ set_dbwh(dentry, -1);
++
++ TraceErr(err);
++ return err;
++}
++
++static int unlink_wh_name(struct dentry *hidden_parent, struct qstr *wh,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct inode *hidden_dir;
++ struct dentry *hidden_dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(hidden_parent), LNPair(wh));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ // au_test_perm() is already done
++ hidden_dentry = lkup_one(wh->name, hidden_parent, wh->len, lkup);
++ //if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
++ if (!IS_ERR(hidden_dentry)) {
++ err = 0;
++ if (hidden_dentry->d_inode)
++ err = vfsub_unlink(hidden_dir, hidden_dentry,
++ lkup->dlgt);
++ dput(hidden_dentry);
++ } else
++ err = PTR_ERR(hidden_dentry);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void clean_wh(struct inode *h_dir, struct dentry *wh)
++{
++ TraceEnter();
++ if (wh->d_inode) {
++ int err = vfsub_unlink(h_dir, wh, /*dlgt*/0);
++ if (unlikely(err))
++ Warn("failed unlink %.*s (%d), ignored.\n",
++ DLNPair(wh), err);
++ }
++}
++
++static void clean_plink(struct inode *h_dir, struct dentry *plink)
++{
++ TraceEnter();
++ if (plink->d_inode) {
++ int err = vfsub_rmdir(h_dir, plink, /*dlgt*/0);
++ if (unlikely(err))
++ Warn("failed rmdir %.*s (%d), ignored.\n",
++ DLNPair(plink), err);
++ }
++}
++
++static int test_linkable(struct inode *h_dir)
++{
++ if (h_dir->i_op && h_dir->i_op->link)
++ return 0;
++ return -ENOSYS;
++}
++
++static int plink_dir(struct inode *h_dir, struct dentry *plink)
++{
++ int err;
++
++ err = -EEXIST;
++ if (!plink->d_inode) {
++ int mode = S_IRWXU;
++ if (unlikely(au_is_nfs(plink->d_sb)))
++ mode |= S_IXUGO;
++ err = vfsub_mkdir(h_dir, plink, mode, /*dlgt*/0);
++ } else if (S_ISDIR(plink->d_inode->i_mode))
++ err = 0;
++ else
++ Err("unknown %.*s exists\n", DLNPair(plink));
++
++ return err;
++}
++
++/*
++ * initialize the whiteout base file/dir for @br.
++ */
++int init_wh(struct dentry *h_root, struct aufs_branch *br,
++ struct vfsmount *nfsmnt, struct super_block *sb)
++{
++ int err;
++ struct dentry *wh, *plink;
++ struct inode *h_dir;
++ static struct qstr base_name[] = {
++ {.name = AUFS_WH_BASENAME, .len = sizeof(AUFS_WH_BASENAME) - 1},
++ {.name = AUFS_WH_PLINKDIR, .len = sizeof(AUFS_WH_PLINKDIR) - 1}
++ };
++ struct lkup_args lkup = {
++ .nfsmnt = nfsmnt,
++ .dlgt = 0 // always no dlgt
++ };
++ const int do_plink = au_flag_test(sb, AuFlag_PLINK);
++
++ LKTRTrace("nfsmnt %p\n", nfsmnt);
++ BrWhMustWriteLock(br);
++ SiMustWriteLock(sb);
++ h_dir = h_root->d_inode;
++ IMustLock(h_dir);
++
++ // doubly whiteouted
++ wh = lkup_wh(h_root, base_name + 0, &lkup);
++ //if (LktrCond) {dput(wh); wh = ERR_PTR(-1);}
++ err = PTR_ERR(wh);
++ if (IS_ERR(wh))
++ goto out;
++ DEBUG_ON(br->br_wh && br->br_wh != wh);
++
++ plink = lkup_wh(h_root, base_name + 1, &lkup);
++ err = PTR_ERR(plink);
++ if (IS_ERR(plink))
++ goto out_dput_wh;
++ DEBUG_ON(br->br_plink && br->br_plink != plink);
++
++ dput(br->br_wh);
++ dput(br->br_plink);
++ br->br_wh = br->br_plink = NULL;
++
++ err = 0;
++ switch (br->br_perm) {
++ case AuBr_RR:
++ case AuBr_RO:
++ case AuBr_RRWH:
++ case AuBr_ROWH:
++ clean_wh(h_dir, wh);
++ clean_plink(h_dir, plink);
++ break;
++
++ case AuBr_RWNoLinkWH:
++ clean_wh(h_dir, wh);
++ if (do_plink) {
++ err = test_linkable(h_dir);
++ if (unlikely(err))
++ goto out_nolink;
++
++ err = plink_dir(h_dir, plink);
++ if (unlikely(err))
++ goto out_err;
++ br->br_plink = dget(plink);
++ } else
++ clean_plink(h_dir, plink);
++ break;
++
++ case AuBr_RW:
++ /*
++ * for the moment, aufs supports the branch filesystem
++ * which does not support link(2).
++ * testing on FAT which does not support i_op->setattr() fully either,
++ * copyup failed.
++ * finally, such filesystem will not be used as the writable branch.
++ */
++ err = test_linkable(h_dir);
++ if (unlikely(err))
++ goto out_nolink;
++
++ err = -EEXIST;
++ if (!wh->d_inode)
++ err = vfsub_create(h_dir, wh, WH_MASK, NULL, /*dlgt*/0);
++ else if (S_ISREG(wh->d_inode->i_mode))
++ err = 0;
++ else
++ Err("unknown %.*s/%.*s exists\n",
++ DLNPair(h_root), DLNPair(wh));
++ if (unlikely(err))
++ goto out_err;
++
++ if (do_plink) {
++ err = plink_dir(h_dir, plink);
++ if (unlikely(err))
++ goto out_err;
++ br->br_plink = dget(plink);
++ } else
++ clean_plink(h_dir, plink);
++ br->br_wh = dget(wh);
++ break;
++
++ default:
++ BUG();
++ }
++
++ out_dput:
++ dput(plink);
++ out_dput_wh:
++ dput(wh);
++ out:
++ TraceErr(err);
++ return err;
++ out_nolink:
++ Err("%.*s doesn't support link(2), use noplink and rw+nolwh\n",
++ DLNPair(h_root));
++ goto out_dput;
++ out_err:
++ Err("an error(%d) on the writable branch %.*s(%s)\n",
++ err, DLNPair(h_root), au_sbtype(h_root->d_sb));
++ goto out_dput;
++}
++
++struct reinit_br_wh {
++ struct super_block *sb;
++ struct aufs_branch *br;
++};
++
++static void reinit_br_wh(void *arg)
++{
++ int err;
++ struct reinit_br_wh *a = arg;
++ struct inode *hidden_dir, *dir;
++ struct dentry *hidden_root;
++ aufs_bindex_t bindex;
++
++ TraceEnter();
++ DEBUG_ON(!a->br->br_wh || !a->br->br_wh->d_inode || current->fsuid);
++
++ err = 0;
++ /* big lock */
++ si_write_lock(a->sb);
++ if (unlikely(!br_writable(a->br->br_perm)))
++ goto out;
++ bindex = find_brindex(a->sb, a->br->br_id);
++ if (unlikely(bindex < 0))
++ goto out;
++
++ dir = a->sb->s_root->d_inode;
++ hidden_root = a->br->br_wh->d_parent;
++ hidden_dir = hidden_root->d_inode;
++ DEBUG_ON(!hidden_dir->i_op || !hidden_dir->i_op->link);
++ hdir_lock(hidden_dir, dir, bindex);
++ br_wh_write_lock(a->br);
++ err = vfsub_unlink(hidden_dir, a->br->br_wh, /*dlgt*/0);
++ //if (LktrCond) err = -1;
++ dput(a->br->br_wh);
++ a->br->br_wh = NULL;
++ if (!err)
++ err = init_wh(hidden_root, a->br, au_do_nfsmnt(a->br->br_mnt),
++ a->sb);
++ br_wh_write_unlock(a->br);
++ hdir_unlock(hidden_dir, dir, bindex);
++
++ out:
++ atomic_dec(&a->br->br_wh_running);
++ br_put(a->br);
++ si_write_unlock(a->sb);
++ au_mntput(a->sb);
++ kfree(arg);
++ if (unlikely(err))
++ IOErr("err %d\n", err);
++}
++
++static void kick_reinit_br_wh(struct super_block *sb, struct aufs_branch *br)
++{
++ int do_dec;
++ struct reinit_br_wh *arg;
++
++ do_dec = 1;
++ if (atomic_inc_return(&br->br_wh_running) != 1)
++ goto out;
++
++ // ignore ENOMEM
++ arg = kmalloc(sizeof(*arg), GFP_KERNEL);
++ if (arg) {
++ // dec(wh_running), kfree(arg) and br_put() in reinit function
++ arg->sb = sb;
++ arg->br = br;
++ br_get(br);
++ /* prohibit umount */
++ au_mntget(sb);
++ au_wkq_nowait(reinit_br_wh, arg, /*dlgt*/0);
++ do_dec = 0;
++ }
++
++ out:
++ if (do_dec)
++ atomic_dec(&br->br_wh_running);
++}
++
++/*
++ * create the whiteoute @wh.
++ */
++static int link_or_create_wh(struct dentry *wh, struct super_block *sb,
++ aufs_bindex_t bindex)
++{
++ int err, dlgt;
++ struct aufs_branch *br;
++ struct dentry *hidden_parent;
++ struct inode *hidden_dir;
++
++ LKTRTrace("%.*s\n", DLNPair(wh));
++ SiMustReadLock(sb);
++ hidden_parent = wh->d_parent;
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ dlgt = need_dlgt(sb);
++ br = stobr(sb, bindex);
++ br_wh_read_lock(br);
++ if (br->br_wh) {
++ err = vfsub_link(br->br_wh, hidden_dir, wh, dlgt);
++ if (!err || err != -EMLINK)
++ goto out;
++
++ // link count full. re-initialize br_wh.
++ kick_reinit_br_wh(sb, br);
++ }
++
++ // return this error in this context
++ err = vfsub_create(hidden_dir, wh, WH_MASK, NULL, dlgt);
++
++ out:
++ br_wh_read_unlock(br);
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * create or remove the diropq.
++ */
++static struct dentry *do_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt)
++{
++ struct dentry *opq_dentry, *hidden_dentry;
++ struct inode *hidden_dir;
++ int err;
++ struct super_block *sb;
++ struct lkup_args lkup;
++
++ LKTRTrace("%.*s, bindex %d, do_create %d\n", DLNPair(dentry),
++ bindex, do_create);
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ DEBUG_ON(!hidden_dentry);
++ hidden_dir = hidden_dentry->d_inode;
++ DEBUG_ON(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
++ IMustLock(hidden_dir);
++
++ // already checked by au_test_perm().
++ sb = dentry->d_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = dlgt;
++ opq_dentry = lkup_one(diropq_name.name, hidden_dentry, diropq_name.len,
++ &lkup);
++ //if (LktrCond) {dput(opq_dentry); opq_dentry = ERR_PTR(-1);}
++ if (IS_ERR(opq_dentry))
++ goto out;
++
++ if (do_create) {
++ DEBUG_ON(opq_dentry->d_inode);
++ err = link_or_create_wh(opq_dentry, sb, bindex);
++ //if (LktrCond) {vfs_unlink(hidden_dir, opq_dentry); err = -1;}
++ if (!err) {
++ set_dbdiropq(dentry, bindex);
++ goto out; /* success */
++ }
++ } else {
++ DEBUG_ON(/* !S_ISDIR(dentry->d_inode->i_mode)
++ * || */!opq_dentry->d_inode);
++ err = vfsub_unlink(hidden_dir, opq_dentry, lkup.dlgt);
++ //if (LktrCond) err = -1;
++ if (!err)
++ set_dbdiropq(dentry, -1);
++ }
++ dput(opq_dentry);
++ opq_dentry = ERR_PTR(err);
++
++ out:
++ TraceErrPtr(opq_dentry);
++ return opq_dentry;
++}
++
++struct do_diropq_args {
++ struct dentry **errp;
++ struct dentry *dentry;
++ aufs_bindex_t bindex;
++ int do_create, dlgt;
++};
++
++static void call_do_diropq(void *args)
++{
++ struct do_diropq_args *a = args;
++ *a->errp = do_diropq(a->dentry, a->bindex, a->do_create, a->dlgt);
++}
++
++struct dentry *sio_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt)
++{
++ struct dentry *diropq, *hidden_dentry;
++
++ LKTRTrace("%.*s, bindex %d, do_create %d\n",
++ DLNPair(dentry), bindex, do_create);
++
++ hidden_dentry = au_h_dptr_i(dentry, bindex);
++ if (!au_test_perm(hidden_dentry->d_inode, MAY_EXEC | MAY_WRITE, dlgt))
++ diropq = do_diropq(dentry, bindex, do_create, dlgt);
++ else {
++ struct do_diropq_args args = {
++ .errp = &diropq,
++ .dentry = dentry,
++ .bindex = bindex,
++ .do_create = do_create,
++ .dlgt = dlgt
++ };
++ au_wkq_wait(call_do_diropq, &args, /*dlgt*/0);
++ }
++
++ TraceErrPtr(diropq);
++ return diropq;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * lookup whiteout dentry.
++ * @hidden_parent: hidden parent dentry which must exist and be locked
++ * @base_name: name of dentry which will be whiteouted
++ * returns dentry for whiteout.
++ */
++struct dentry *lkup_wh(struct dentry *hidden_parent, struct qstr *base_name,
++ struct lkup_args *lkup)
++{
++ int err;
++ struct qstr wh_name;
++ struct dentry *wh_dentry;
++
++ LKTRTrace("%.*s/%.*s\n", DLNPair(hidden_parent), LNPair(base_name));
++ IMustLock(hidden_parent->d_inode);
++
++ err = au_alloc_whname(base_name->name, base_name->len, &wh_name);
++ //if (LktrCond) {au_free_whname(&wh_name); err = -1;}
++ wh_dentry = ERR_PTR(err);
++ if (!err) {
++ // do not superio.
++ wh_dentry = lkup_one(wh_name.name, hidden_parent, wh_name.len,
++ lkup);
++ au_free_whname(&wh_name);
++ }
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/*
++ * link/create a whiteout for @dentry on @bindex.
++ */
++struct dentry *simple_create_wh(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *hidden_parent,
++ struct lkup_args *lkup)
++{
++ struct dentry *wh_dentry;
++ int err;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s/%.*s on b%d\n", DLNPair(hidden_parent),
++ DLNPair(dentry), bindex);
++
++ sb = dentry->d_sb;
++ wh_dentry = lkup_wh(hidden_parent, &dentry->d_name, lkup);
++ //au_nfsmnt(sb, bindex), need_dlgt(sb));
++ //if (LktrCond) {dput(wh_dentry); wh_dentry = ERR_PTR(-1);}
++ if (!IS_ERR(wh_dentry) && !wh_dentry->d_inode) {
++ IMustLock(hidden_parent->d_inode);
++ err = link_or_create_wh(wh_dentry, sb, bindex);
++ if (!err)
++ set_dbwh(dentry, bindex);
++ else {
++ dput(wh_dentry);
++ wh_dentry = ERR_PTR(err);
++ }
++ }
++
++ TraceErrPtr(wh_dentry);
++ return wh_dentry;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/* Delete all whiteouts in this directory in branch bindex. */
++static int del_wh_children(struct aufs_nhash *whlist,
++ struct dentry *hidden_parent, aufs_bindex_t bindex,
++ struct lkup_args *lkup)
++{
++ int err, i;
++ struct qstr wh_name;
++ char *p;
++ struct inode *hidden_dir;
++ struct hlist_head *head;
++ struct aufs_wh *tpos;
++ struct hlist_node *pos;
++ struct aufs_destr *str;
++
++ LKTRTrace("%.*s\n", DLNPair(hidden_parent));
++ hidden_dir = hidden_parent->d_inode;
++ IMustLock(hidden_dir);
++ DEBUG_ON(IS_RDONLY(hidden_dir));
++ //SiMustReadLock(??);
++
++ err = -ENOMEM;
++ wh_name.name = p = __getname();
++ //if (LktrCond) {__putname(p); wh_name.name = p = NULL;}
++ if (unlikely(!wh_name.name))
++ goto out;
++ memcpy(p, AUFS_WH_PFX, AUFS_WH_PFX_LEN);
++ p += AUFS_WH_PFX_LEN;
++
++ // already checked by au_test_perm().
++ err = 0;
++ for (i = 0; !err && i < AUFS_NHASH_SIZE; i++) {
++ head = whlist->heads + i;
++ hlist_for_each_entry(tpos, pos, head, wh_hash) {
++ if (tpos->wh_bindex != bindex)
++ continue;
++ str = &tpos->wh_str;
++ if (str->len + AUFS_WH_PFX_LEN <= PATH_MAX) {
++ memcpy(p, str->name, str->len);
++ wh_name.len = AUFS_WH_PFX_LEN + str->len;
++ err = unlink_wh_name(hidden_parent, &wh_name,
++ lkup);
++ //if (LktrCond) err = -1;
++ if (!err)
++ continue;
++ break;
++ }
++ IOErr("whiteout name too long %.*s\n",
++ str->len, str->name);
++ err = -EIO;
++ break;
++ }
++ }
++ __putname(wh_name.name);
++
++ out:
++ TraceErr(err);
++ return err;
++}
++
++struct del_wh_children_args {
++ int *errp;
++ struct aufs_nhash *whlist;
++ struct dentry *hidden_parent;
++ aufs_bindex_t bindex;
++ struct lkup_args *lkup;
++};
++
++static void call_del_wh_children(void *args)
++{
++ struct del_wh_children_args *a = args;
++ *a->errp = del_wh_children(a->whlist, a->hidden_parent, a->bindex,
++ a->lkup);
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * rmdir the whiteouted temporary named dir @hidden_dentry.
++ * @whlist: whiteouted children.
++ */
++int rmdir_whtmp(struct dentry *hidden_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir, struct inode *inode)
++{
++ int err;
++ struct inode *hidden_inode, *hidden_dir;
++ struct lkup_args lkup;
++ struct super_block *sb;
++
++ LKTRTrace("hd %.*s, b%d, i%lu\n",
++ DLNPair(hidden_dentry), bindex, dir->i_ino);
++ IMustLock(dir);
++ IiMustAnyLock(dir);
++ hidden_dir = hidden_dentry->d_parent->d_inode;
++ IMustLock(hidden_dir);
++
++ sb = inode->i_sb;
++ lkup.nfsmnt = au_nfsmnt(sb, bindex);
++ lkup.dlgt = need_dlgt(sb);
++ hidden_inode = hidden_dentry->d_inode;
++ DEBUG_ON(hidden_inode != au_h_iptr_i(inode, bindex));
++ hdir2_lock(hidden_inode, inode, bindex);
++ if (!au_test_perm(hidden_inode, MAY_EXEC | MAY_WRITE, lkup.dlgt))
++ err = del_wh_children(whlist, hidden_dentry, bindex, &lkup);
++ else {
++ // ugly
++ int dlgt = lkup.dlgt;
++ struct del_wh_children_args args = {
++ .errp = &err,
++ .whlist = whlist,
++ .hidden_parent = hidden_dentry,
++ .bindex = bindex,
++ .lkup = &lkup
++ };
++
++ lkup.dlgt = 0;
++ au_wkq_wait(call_del_wh_children, &args, /*dlgt*/0);
++ lkup.dlgt = dlgt;
++ }
++ hdir_unlock(hidden_inode, inode, bindex);
++
++ if (!err) {
++ err = vfsub_rmdir(hidden_dir, hidden_dentry, lkup.dlgt);
++ //d_drop(hidden_dentry);
++ //if (LktrCond) err = -1;
++ }
++
++ if (!err) {
++ if (ibstart(dir) == bindex) {
++ au_cpup_attr_timesizes(dir);
++ //au_cpup_attr_nlink(dir);
++ dir->i_nlink--;
++ }
++ return 0; /* success */
++ }
++
++ Warn("failed removing %.*s(%d), ignored\n",
++ DLNPair(hidden_dentry), err);
++ return err;
++}
++
++static void do_rmdir_whtmp(void *arg)
++{
++ int err;
++ struct rmdir_whtmp_arg *a = arg;
++ struct super_block *sb;
++
++ LKTRTrace("%.*s, b%d, dir i%lu\n",
++ DLNPair(a->h_dentry), a->bindex, a->dir->i_ino);
++
++ i_lock(a->dir);
++ sb = a->dir->i_sb;
++ si_read_lock(sb);
++ err = test_ro(sb, a->bindex, NULL);
++ if (!err) {
++ struct inode *hidden_dir = a->h_dentry->d_parent->d_inode;
++
++ ii_write_lock_child(a->inode);
++ ii_write_lock_parent(a->dir);
++ hdir_lock(hidden_dir, a->dir, a->bindex);
++ err = rmdir_whtmp(a->h_dentry, &a->whlist, a->bindex,
++ a->dir, a->inode);
++ hdir_unlock(hidden_dir, a->dir, a->bindex);
++ ii_write_unlock(a->dir);
++ ii_write_unlock(a->inode);
++ }
++ dput(a->h_dentry);
++ nhash_fin(&a->whlist);
++ iput(a->inode);
++ si_read_unlock(sb);
++ au_mntput(sb);
++ i_unlock(a->dir);
++ iput(a->dir);
++ kfree(arg);
++ if (unlikely(err))
++ IOErr("err %d\n", err);
++}
++
++void kick_rmdir_whtmp(struct dentry *hidden_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir,
++ struct inode *inode, struct rmdir_whtmp_arg *arg)
++{
++ LKTRTrace("%.*s\n", DLNPair(hidden_dentry));
++ IMustLock(dir);
++
++ // all post-process will be done in do_rmdir_whtmp().
++ arg->h_dentry = dget(hidden_dentry);
++ nhash_init(&arg->whlist);
++ nhash_move(&arg->whlist, whlist);
++ arg->bindex = bindex;
++ arg->dir = igrab(dir);
++ arg->inode = igrab(inode);
++ /* prohibit umount */
++ au_mntget(dir->i_sb);
++
++ au_wkq_nowait(do_rmdir_whtmp, arg, /*dlgt*/0);
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/whout.h linux-2.6.22.1/fs/aufs/whout.h
+--- linux-2.6.22.1.oorig/fs/aufs/whout.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/whout.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: whout.h,v 1.8 2007/05/14 03:41:52 sfjro Exp $ */
++
++#ifndef __AUFS_WHOUT_H__
++#define __AUFS_WHOUT_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++#include <linux/aufs_type.h>
++
++int au_alloc_whname(const char *name, int len, struct qstr *wh);
++void au_free_whname(struct qstr *wh);
++
++struct lkup_args;
++int is_wh(struct dentry *h_parent, struct qstr *wh_name, int try_sio,
++ struct lkup_args *lkup);
++int is_diropq(struct dentry *h_dentry, struct lkup_args *lkup);
++
++struct dentry *lkup_whtmp(struct dentry *h_parent, struct qstr *prefix,
++ struct lkup_args *lkup);
++int rename_whtmp(struct dentry *dentry, aufs_bindex_t bindex);
++int au_unlink_wh_dentry(struct inode *h_dir, struct dentry *wh_dentry,
++ struct dentry *dentry, int dlgt);
++
++struct aufs_branch;
++int init_wh(struct dentry *h_parent, struct aufs_branch *br,
++ struct vfsmount *nfsmnt, struct super_block *sb);
++
++struct dentry *sio_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int do_create, int dlgt);
++
++struct dentry *lkup_wh(struct dentry *h_parent, struct qstr *base_name,
++ struct lkup_args *lkup);
++struct dentry *simple_create_wh(struct dentry *dentry, aufs_bindex_t bindex,
++ struct dentry *h_parent,
++ struct lkup_args *lkup);
++
++/* real rmdir the whiteout-ed dir */
++struct rmdir_whtmp_arg {
++ struct dentry *h_dentry;
++ struct aufs_nhash whlist;
++ aufs_bindex_t bindex;
++ struct inode *dir, *inode;
++};
++
++struct aufs_nhash;
++int rmdir_whtmp(struct dentry *h_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir, struct inode *inode);
++void kick_rmdir_whtmp(struct dentry *h_dentry, struct aufs_nhash *whlist,
++ aufs_bindex_t bindex, struct inode *dir,
++ struct inode *inode, struct rmdir_whtmp_arg *arg);
++
++/* ---------------------------------------------------------------------- */
++
++static inline
++struct dentry *create_diropq(struct dentry *dentry, aufs_bindex_t bindex,
++ int dlgt)
++{
++ return sio_diropq(dentry, bindex, 1, dlgt);
++}
++
++static inline
++int remove_diropq(struct dentry *dentry, aufs_bindex_t bindex, int dlgt)
++{
++ return PTR_ERR(sio_diropq(dentry, bindex, 0, dlgt));
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_WHOUT_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/wkq.c linux-2.6.22.1/fs/aufs/wkq.c
+--- linux-2.6.22.1.oorig/fs/aufs/wkq.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/wkq.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,283 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: wkq.c,v 1.14 2007/05/14 03:39:10 sfjro Exp $ */
++
++#include <linux/module.h>
++#include "aufs.h"
++
++struct au_wkq *au_wkq;
++
++struct au_cred {
++#ifdef CONFIG_AUFS_DLGT
++ uid_t fsuid;
++ gid_t fsgid;
++ kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
++ //unsigned keep_capabilities:1;
++ //struct user_struct *user;
++ //struct fs_struct *fs;
++ //struct nsproxy *nsproxy;
++#endif
++};
++
++struct au_wkinfo {
++ struct work_struct wk;
++
++ unsigned int wait:1;
++ unsigned int dlgt:1;
++ struct au_cred cred;
++
++ au_wkq_func_t func;
++ void *args;
++
++ atomic_t *busyp;
++ struct completion *comp;
++};
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_DLGT
++static void cred_store(struct au_cred *cred)
++{
++ cred->fsuid = current->fsuid;
++ cred->fsgid = current->fsgid;
++ cred->cap_effective = current->cap_effective;
++ cred->cap_inheritable = current->cap_inheritable;
++ cred->cap_permitted = current->cap_permitted;
++}
++
++static void cred_revert(struct au_cred *cred)
++{
++ DEBUG_ON(!is_au_wkq(current));
++ current->fsuid = cred->fsuid;
++ current->fsgid = cred->fsgid;
++ current->cap_effective = cred->cap_effective;
++ current->cap_inheritable = cred->cap_inheritable;
++ current->cap_permitted = cred->cap_permitted;
++}
++
++static void cred_switch(struct au_cred *old, struct au_cred *new)
++{
++ cred_store(old);
++ cred_revert(new);
++}
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++static void update_busy(struct au_wkq *wkq, struct au_wkinfo *wkinfo)
++{
++#ifdef CONFIG_AUFS_SYSAUFS
++ unsigned int new, old;
++
++ do {
++ new = atomic_read(wkinfo->busyp);
++ old = wkq->max_busy;
++ if (new <= old)
++ break;
++ } while (cmpxchg(&wkq->max_busy, old, new) == old);
++#endif
++}
++
++static int enqueue(struct au_wkq *wkq, struct au_wkinfo *wkinfo)
++{
++ wkinfo->busyp = &wkq->busy;
++ update_busy(wkq, wkinfo);
++ if (wkinfo->wait)
++ return !queue_work(wkq->q, &wkinfo->wk);
++ else
++ return !schedule_work(&wkinfo->wk);
++}
++
++static void do_wkq(struct au_wkinfo *wkinfo)
++{
++ unsigned int idle, n;
++ int i, idle_idx;
++
++ TraceEnter();
++
++ while (1) {
++ if (wkinfo->wait) {
++ idle_idx = 0;
++ idle = UINT_MAX;
++ for (i = 0; i < aufs_nwkq; i++) {
++ n = atomic_inc_return(&au_wkq[i].busy);
++ if (n == 1 && !enqueue(au_wkq + i, wkinfo))
++ return; /* success */
++
++ if (n < idle) {
++ idle_idx = i;
++ idle = n;
++ }
++ atomic_dec(&au_wkq[i].busy);
++ }
++ } else
++ idle_idx = aufs_nwkq;
++
++ atomic_inc(&au_wkq[idle_idx].busy);
++ if (!enqueue(au_wkq + idle_idx, wkinfo))
++ return; /* success */
++
++ /* impossible? */
++ Warn1("failed to queue_work()\n");
++ yield();
++ }
++}
++
++static AuWkqFunc(wkq_func, wk)
++{
++ struct au_wkinfo *wkinfo = container_of(wk, struct au_wkinfo, wk);
++
++ LKTRTrace("wkinfo{%u, %u, %p, %p, %p}\n",
++ wkinfo->wait, wkinfo->dlgt, wkinfo->func, wkinfo->busyp,
++ wkinfo->comp);
++#ifdef CONFIG_AUFS_DLGT
++ if (!wkinfo->dlgt)
++ wkinfo->func(wkinfo->args);
++ else {
++ struct au_cred cred;
++ cred_switch(&cred, &wkinfo->cred);
++ wkinfo->func(wkinfo->args);
++ cred_revert(&cred);
++ }
++#else
++ wkinfo->func(wkinfo->args);
++#endif
++ atomic_dec(wkinfo->busyp);
++ if (wkinfo->wait)
++ complete(wkinfo->comp);
++ else {
++ kfree(wkinfo);
++ module_put(THIS_MODULE);
++ }
++}
++
++void au_wkq_run(au_wkq_func_t func, void *args, int dlgt, int do_wait)
++{
++ DECLARE_COMPLETION_ONSTACK(comp);
++ struct au_wkinfo _wkinfo = {
++ .wait = 1,
++ .dlgt = !!dlgt,
++ .func = func,
++ .args = args,
++ .comp = &comp
++ }, *wkinfo = &_wkinfo;
++
++ LKTRTrace("dlgt %d, do_wait %d\n", dlgt, do_wait);
++ DEBUG_ON(is_au_wkq(current));
++
++ if (unlikely(!do_wait)) {
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ /*
++ * never fail.
++ * wkq_func() must free this wkinfo.
++ * it highly depends upon the implementation of workqueue.
++ */
++ wait_event(wq, (wkinfo = kmalloc(sizeof(*wkinfo), GFP_KERNEL)));
++ wkinfo->wait = 0;
++ wkinfo->dlgt = !!dlgt;
++ wkinfo->func = func;
++ wkinfo->args = args;
++ wkinfo->comp = NULL;
++ __module_get(THIS_MODULE);
++ }
++
++ AuInitWkq(&wkinfo->wk, wkq_func);
++#ifdef CONFIG_AUFS_DLGT
++ if (dlgt)
++ cred_store(&wkinfo->cred);
++#endif
++ do_wkq(wkinfo);
++ if (do_wait)
++ wait_for_completion(wkinfo->comp);
++}
++
++#if 0
++void au_wkq_wait_nwtask(void)
++{
++ static DECLARE_WAIT_QUEUE_HEAD(wq);
++ wait_event(wq, !atomic_read(&au_wkq[aufs_nwkq].busy));
++}
++#endif
++
++void au_wkq_fin(void)
++{
++ int i;
++
++ TraceEnter();
++
++ for (i = 0; i < aufs_nwkq; i++)
++ if (au_wkq[i].q && !IS_ERR(au_wkq[i].q))
++ destroy_workqueue(au_wkq[i].q);
++ kfree(au_wkq);
++}
++
++int __init au_wkq_init(void)
++{
++ int err, i;
++ struct au_wkq *nowaitq;
++
++ LKTRTrace("%d\n", aufs_nwkq);
++
++ /* '+1' is for accounting of nowait queue */
++ err = -ENOMEM;
++ au_wkq = kcalloc(aufs_nwkq + 1, sizeof(*au_wkq), GFP_KERNEL);
++ if (unlikely(!au_wkq))
++ goto out;
++
++ err = 0;
++ for (i = 0; i < aufs_nwkq; i++) {
++ au_wkq[i].q = create_singlethread_workqueue(AUFS_WKQ_NAME);
++ if (au_wkq[i].q && !IS_ERR(au_wkq[i].q)) {
++ atomic_set(&au_wkq[i].busy, 0);
++ au_wkq[i].max_busy = 0;
++ continue;
++ }
++
++ err = PTR_ERR(au_wkq[i].q);
++ au_wkq_fin();
++ break;
++ }
++
++ /* nowait accounting */
++ nowaitq = au_wkq + aufs_nwkq;
++ atomic_set(&nowaitq->busy, 0);
++ nowaitq->max_busy = 0;
++ nowaitq->q = NULL;
++
++#if 0 // test accouting
++ if (!err) {
++ static void f(void *args) {
++ DbgSleep(1);
++ }
++ int i;
++ //au_debug_on();
++ LKTRTrace("f %p\n", f);
++ for (i = 0; i < 10; i++)
++ au_wkq_nowait(f, NULL, 0);
++ for (i = 0; i < aufs_nwkq; i++)
++ au_wkq_wait(f, NULL, 0);
++ DbgSleep(11);
++ //au_debug_off();
++ }
++#endif
++
++ out:
++ TraceErr(err);
++ return err;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/wkq.h linux-2.6.22.1/fs/aufs/wkq.h
+--- linux-2.6.22.1.oorig/fs/aufs/wkq.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/wkq.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,81 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: wkq.h,v 1.9 2007/05/14 03:39:10 sfjro Exp $ */
++
++#ifndef __AUFS_WKQ_H__
++#define __AUFS_WKQ_H__
++
++#ifdef __KERNEL__
++
++#include <linux/sched.h>
++#include <linux/version.h>
++#include <linux/workqueue.h>
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
++#define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++/* internal workqueue named AUFS_WKQ_NAME */
++struct au_wkq {
++ struct workqueue_struct *q;
++
++ /* accounting */
++ atomic_t busy;
++ unsigned int max_busy;
++} ;//__attribute__ ((aligned));
++
++typedef void (*au_wkq_func_t)(void *args);
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
++#define AuInitWkq(wk, func) INIT_WORK(wk, func)
++#define AuWkqFunc(name, arg) void name(struct work_struct *arg)
++#else
++typedef void (*work_func_t)(void *arg);
++#define AuInitWkq(wk, func) INIT_WORK(wk, func, wk)
++#define AuWkqFunc(name, arg) void name(void *arg)
++#endif
++
++extern struct au_wkq *au_wkq;
++
++void au_wkq_run(au_wkq_func_t func, void *args, int dlgt, int do_wait);
++//void au_wkq_wait_nwtask(void);
++int __init au_wkq_init(void);
++void au_wkq_fin(void);
++
++/* ---------------------------------------------------------------------- */
++
++static inline int is_au_wkq(struct task_struct *tsk)
++{
++ return (!tsk->mm && !strcmp(current->comm, AUFS_WKQ_NAME));
++}
++
++static inline void au_wkq_wait(au_wkq_func_t func, void *args, int dlgt)
++{
++ au_wkq_run(func, args, dlgt, /*do_wait*/1);
++}
++
++static inline void au_wkq_nowait(au_wkq_func_t func, void *args, int dlgt)
++{
++ au_wkq_run(func, args, dlgt, /*do_wait*/0);
++}
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_WKQ_H__ */
+diff -rduNp linux-2.6.22.1.oorig/fs/aufs/xino.c linux-2.6.22.1/fs/aufs/xino.c
+--- linux-2.6.22.1.oorig/fs/aufs/xino.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/aufs/xino.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,644 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: xino.c,v 1.27 2007/05/14 03:39:10 sfjro Exp $ */
++
++//#include <linux/fs.h>
++#include <linux/fsnotify.h>
++#include <asm/uaccess.h>
++#include "aufs.h"
++
++static readf_t find_readf(struct file *h_file)
++{
++ const struct file_operations *fop = h_file->f_op;
++
++ if (fop) {
++ if (fop->read)
++ return fop->read;
++ if (fop->aio_read)
++ return do_sync_read;
++ }
++ return ERR_PTR(-ENOSYS);
++}
++
++static writef_t find_writef(struct file *h_file)
++{
++ const struct file_operations *fop = h_file->f_op;
++
++ if (fop) {
++ if (fop->write)
++ return fop->write;
++ if (fop->aio_write)
++ return do_sync_write;
++ }
++ return ERR_PTR(-ENOSYS);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t xino_fread(readf_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ LKTRTrace("%.*s, sz %lu, *pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)size, *pos);
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ do {
++ err = func(file, (char __user*)buf, size, pos);
++ } while (err == -EAGAIN || err == -EINTR);
++ set_fs(oldfs);
++
++#if 0
++ if (err > 0)
++ fsnotify_access(file->f_dentry);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static ssize_t do_xino_fwrite(writef_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++ mm_segment_t oldfs;
++
++ lockdep_off();
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ do {
++ err = func(file, (const char __user*)buf, size, pos);
++ } while (err == -EAGAIN || err == -EINTR);
++ set_fs(oldfs);
++ lockdep_on();
++
++#if 0
++ if (err > 0)
++ fsnotify_modify(file->f_dentry);
++#endif
++
++ TraceErr(err);
++ return err;
++}
++
++struct do_xino_fwrite_args {
++ ssize_t *errp;
++ writef_t func;
++ struct file *file;
++ void *buf;
++ size_t size;
++ loff_t *pos;
++};
++
++static void call_do_xino_fwrite(void *args)
++{
++ struct do_xino_fwrite_args *a = args;
++ *a->errp = do_xino_fwrite(a->func, a->file, a->buf, a->size, a->pos);
++}
++
++static ssize_t xino_fwrite(writef_t func, struct file *file, void *buf,
++ size_t size, loff_t *pos)
++{
++ ssize_t err;
++
++ LKTRTrace("%.*s, sz %lu, *pos %Ld\n",
++ DLNPair(file->f_dentry), (unsigned long)size, *pos);
++
++ // signal block and no wkq?
++ /*
++ * it breaks RLIMIT_FSIZE and normal user's limit,
++ * users should care about quota and real 'filesystem full.'
++ */
++ if (!is_au_wkq(current)) {
++ struct do_xino_fwrite_args args = {
++ .errp = &err,
++ .func = func,
++ .file = file,
++ .buf = buf,
++ .size = size,
++ .pos = pos
++ };
++ au_wkq_wait(call_do_xino_fwrite, &args, /*dlgt*/0);
++ } else
++ err = do_xino_fwrite(func, file, buf, size, pos);
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * write @ino to the xinofile for the specified branch{@sb, @bindex}
++ * at the position of @_ino.
++ * when @ino is zero, it is written to the xinofile and means no entry.
++ */
++int xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino)
++{
++ struct aufs_branch *br;
++ loff_t pos;
++ ssize_t sz;
++
++ LKTRTrace("b%d, hi%lu, i%lu\n", bindex, h_ino, xino->ino);
++ //DEBUG_ON(!xino->ino /* || !xino->h_gen */);
++ //WARN_ON(bindex == 0 && h_ino == 31);
++
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ return 0;
++
++ br = stobr(sb, bindex);
++ DEBUG_ON(!br || !br->br_xino);
++ pos = h_ino * sizeof(*xino);
++ sz = xino_fwrite(br->br_xino_write, br->br_xino, xino, sizeof(*xino),
++ &pos);
++ //if (LktrCond) sz = 1;
++ if (sz == sizeof(*xino))
++ return 0; /* success */
++
++ IOErr("write failed (%ld)\n", (long)sz);
++ return -EIO;
++}
++
++int xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino)
++{
++ struct xino xino = {
++ .ino = 0
++ };
++ return xino_write(sb, bindex, h_ino, &xino);
++}
++
++// why is not atomic_long_inc_return defined?
++static DEFINE_SPINLOCK(alir_lock);
++static long atomic_long_inc_return(atomic_long_t *a)
++{
++ long l;
++
++ spin_lock(&alir_lock);
++ atomic_long_inc(a);
++ l = atomic_long_read(a);
++ spin_unlock(&alir_lock);
++ return l;
++}
++
++ino_t xino_new_ino(struct super_block *sb)
++{
++ ino_t ino;
++
++ TraceEnter();
++ ino = atomic_long_inc_return(&stosi(sb)->si_xino);
++ BUILD_BUG_ON(AUFS_FIRST_INO < AUFS_ROOT_INO);
++ if (ino >= AUFS_ROOT_INO)
++ return ino;
++ else {
++ atomic_long_dec(&stosi(sb)->si_xino);
++ IOErr1("inode number overflow\n");
++ return 0;
++ }
++}
++
++/*
++ * read @ino from xinofile for the specified branch{@sb, @bindex}
++ * at the position of @h_ino.
++ * if @ino does not exist and @do_new is true, get new one.
++ */
++int xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
++ struct xino *xino)
++{
++ int err;
++ struct aufs_branch *br;
++ struct file *file;
++ loff_t pos;
++ ssize_t sz;
++
++ LKTRTrace("b%d, hi%lu\n", bindex, h_ino);
++
++ err = 0;
++ xino->ino = 0;
++ if (unlikely(!au_flag_test(sb, AuFlag_XINO)))
++ return 0; /* no ino */
++
++ br = stobr(sb, bindex);
++ file = br->br_xino;
++ DEBUG_ON(!file);
++ pos = h_ino * sizeof(*xino);
++ if (i_size_read(file->f_dentry->d_inode) < pos + sizeof(*xino))
++ return 0; /* no ino */
++
++ sz = xino_fread(br->br_xino_read, file, xino, sizeof(*xino), &pos);
++ if (sz == sizeof(*xino))
++ return 0; /* success */
++
++ err = sz;
++ if (unlikely(sz >= 0)) {
++ err = -EIO;
++ IOErr("xino read error (%ld)\n", (long)sz);
++ }
++
++ TraceErr(err);
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++struct file *xino_create(struct super_block *sb, char *fname, int silent,
++ struct dentry *parent)
++{
++ struct file *file;
++ int err;
++ struct dentry *hidden_parent;
++ struct inode *hidden_dir;
++ //const int udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
++
++ LKTRTrace("%s\n", fname);
++ //DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++
++ // LSM may detect it
++ // use sio?
++ file = vfsub_filp_open(fname, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE,
++ S_IRUGO | S_IWUGO);
++ //file = ERR_PTR(-1);
++ if (IS_ERR(file)) {
++ if (!silent)
++ Err("open %s(%ld)\n", fname, PTR_ERR(file));
++ return file;
++ }
++#if 0
++ if (unlikely(udba && parent))
++ au_direval_dec(parent);
++#endif
++
++ /* keep file count */
++ hidden_parent = dget_parent(file->f_dentry);
++ hidden_dir = hidden_parent->d_inode;
++ hi_lock_parent(hidden_dir);
++ err = vfsub_unlink(hidden_dir, file->f_dentry, /*dlgt*/0);
++#if 0
++ if (unlikely(!err && udba && parent))
++ au_direval_dec(parent);
++#endif
++ i_unlock(hidden_dir);
++ dput(hidden_parent);
++ if (unlikely(err)) {
++ if (!silent)
++ Err("unlink %s(%d)\n", fname, err);
++ goto out;
++ }
++ if (sb != file->f_dentry->d_sb)
++ return file; /* success */
++
++ if (!silent)
++ Err("%s must be outside\n", fname);
++ err = -EINVAL;
++
++ out:
++ fput(file);
++ file = ERR_PTR(err);
++ return file;
++}
++
++/*
++ * find another branch who is on the same filesystem of the specified
++ * branch{@btgt}. search until @bend.
++ */
++static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt,
++ aufs_bindex_t bend)
++{
++ aufs_bindex_t bindex;
++ struct super_block *tgt_sb = sbr_sb(sb, btgt);
++
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(btgt != bindex && tgt_sb == sbr_sb(sb, bindex)))
++ return bindex;
++ return -1;
++}
++
++/*
++ * create a new xinofile at the same place/path as @base_file.
++ */
++static struct file *xino_create2(struct file *base_file)
++{
++ struct file *file;
++ int err;
++ struct dentry *base, *dentry, *parent;
++ struct inode *dir;
++ struct qstr *name;
++ struct lkup_args lkup = {
++ .nfsmnt = NULL,
++ .dlgt = 0
++ };
++
++ base = base_file->f_dentry;
++ LKTRTrace("%.*s\n", DLNPair(base));
++ parent = dget_parent(base);
++ dir = parent->d_inode;
++ IMustLock(dir);
++
++ file = ERR_PTR(-EINVAL);
++ if (unlikely(au_is_nfs(parent->d_sb)))
++ goto out;
++
++ // do not superio, nor NFS.
++ name = &base->d_name;
++ dentry = lkup_one(name->name, parent, name->len, &lkup);
++ //if (LktrCond) {dput(dentry); dentry = ERR_PTR(-1);}
++ if (IS_ERR(dentry)) {
++ file = (void*)dentry;
++ Err("%.*s lookup err %ld\n", LNPair(name), PTR_ERR(dentry));
++ goto out;
++ }
++ err = vfsub_create(dir, dentry, S_IRUGO | S_IWUGO, NULL, /*dlgt*/0);
++ //if (LktrCond) {vfs_unlink(dir, dentry); err = -1;}
++ if (unlikely(err)) {
++ file = ERR_PTR(err);
++ Err("%.*s create err %d\n", LNPair(name), err);
++ goto out_dput;
++ }
++ file = dentry_open(dget(dentry), mntget(base_file->f_vfsmnt),
++ O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ if (IS_ERR(file)) {
++ Err("%.*s open err %ld\n", LNPair(name), PTR_ERR(file));
++ goto out_dput;
++ }
++ err = vfsub_unlink(dir, dentry, /*dlgt*/0);
++ //if (LktrCond) err = -1;
++ if (!err)
++ goto out_dput; /* success */
++
++ Err("%.*s unlink err %d\n", LNPair(name), err);
++ fput(file);
++ file = ERR_PTR(err);
++
++ out_dput:
++ dput(dentry);
++ out:
++ dput(parent);
++ TraceErrPtr(file);
++ return file;
++}
++
++/*
++ * initialize the xinofile for the specified branch{@sb, @bindex}
++ * at the place/path where @base_file indicates.
++ * test whether another branch is on the same filesystem or not,
++ * if @do_test is true.
++ */
++int xino_init(struct super_block *sb, aufs_bindex_t bindex,
++ struct file *base_file, int do_test)
++{
++ int err;
++ struct aufs_branch *br;
++ aufs_bindex_t bshared, bend;
++ struct file *file;
++ struct inode *inode, *hidden_inode;
++ struct xino xino;
++
++ LKTRTrace("b%d, base_file %p, do_test %d\n",
++ bindex, base_file, do_test);
++ SiMustWriteLock(sb);
++ DEBUG_ON(!au_flag_test(sb, AuFlag_XINO));
++ br = stobr(sb, bindex);
++ DEBUG_ON(br->br_xino);
++
++ file = NULL;
++ bshared = -1;
++ bend = sbend(sb);
++ if (do_test)
++ bshared = is_sb_shared(sb, bindex, bend);
++ if (unlikely(bshared >= 0)) {
++ struct aufs_branch *shared_br = stobr(sb, bshared);
++ if (shared_br->br_xino) {
++ file = shared_br->br_xino;
++ get_file(file);
++ }
++ }
++
++ if (!file) {
++ struct dentry *parent = dget_parent(base_file->f_dentry);
++ struct inode *dir = parent->d_inode;
++
++ hi_lock_parent(dir);
++ file = xino_create2(base_file);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ i_unlock(dir);
++ dput(parent);
++ err = PTR_ERR(file);
++ if (IS_ERR(file))
++ goto out;
++ }
++ br->br_xino_read = find_readf(file);
++ err = PTR_ERR(br->br_xino_read);
++ if (IS_ERR(br->br_xino_read))
++ goto out_put;
++ br->br_xino_write = find_writef(file);
++ err = PTR_ERR(br->br_xino_write);
++ if (IS_ERR(br->br_xino_write))
++ goto out_put;
++ br->br_xino = file;
++
++ inode = sb->s_root->d_inode;
++ hidden_inode = au_h_iptr_i(inode, bindex);
++ xino.ino = inode->i_ino;
++ //xino.h_gen = hidden_inode->i_generation;
++ //WARN_ON(xino.h_gen == AuXino_INVALID_HGEN);
++ err = xino_write(sb, bindex, hidden_inode->i_ino, &xino);
++ //if (LktrCond) err = -1;
++ if (!err)
++ return 0; /* success */
++
++ br->br_xino = NULL;
++
++ out_put:
++ fput(file);
++ out:
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * set xino mount option.
++ */
++int xino_set(struct super_block *sb, struct opt_xino *xino, int remount)
++{
++ int err, sparse;
++ aufs_bindex_t bindex, bend;
++ struct aufs_branch *br;
++ struct dentry *parent;
++ struct qstr *name;
++ struct file *cur_xino;
++ struct inode *dir;
++
++ LKTRTrace("%s\n", xino->path);
++
++ err = 0;
++ name = &xino->file->f_dentry->d_name;
++ parent = dget_parent(xino->file->f_dentry);
++ dir = parent->d_inode;
++ cur_xino = stobr(sb, 0)->br_xino;
++ if (remount
++ && cur_xino
++ && cur_xino->f_dentry->d_parent == parent
++ && name->len == cur_xino->f_dentry->d_name.len
++ && !memcmp(name->name, cur_xino->f_dentry->d_name.name, name->len))
++ goto out;
++
++ au_flag_set(sb, AuFlag_XINO);
++ bend = sbend(sb);
++ for (bindex = bend; bindex >= 0; bindex--) {
++ br = stobr(sb, bindex);
++ if (unlikely(br->br_xino && file_count(br->br_xino) > 1)) {
++ fput(br->br_xino);
++ br->br_xino = NULL;
++ }
++ }
++
++ for (bindex = 0; bindex <= bend; bindex++) {
++ struct file *file;
++ struct inode *inode;
++
++ br = stobr(sb, bindex);
++ if (unlikely(!br->br_xino))
++ continue;
++
++ DEBUG_ON(file_count(br->br_xino) != 1);
++ hi_lock_parent(dir);
++ file = xino_create2(xino->file);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ err = PTR_ERR(file);
++ if (IS_ERR(file)) {
++ i_unlock(dir);
++ break;
++ }
++ inode = br->br_xino->f_dentry->d_inode;
++ err = au_copy_file(file, br->br_xino, i_size_read(inode), sb,
++ &sparse);
++ //if (LktrCond) err = -1;
++ i_unlock(dir);
++ if (unlikely(err)) {
++ fput(file);
++ break;
++ }
++ fput(br->br_xino);
++ br->br_xino = file;
++ br->br_xino_read = find_readf(file);
++ DEBUG_ON(IS_ERR(br->br_xino_read));
++ br->br_xino_write = find_writef(file);
++ DEBUG_ON(IS_ERR(br->br_xino_write));
++ }
++
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (unlikely(!stobr(sb, bindex)->br_xino)) {
++ err = xino_init(sb, bindex, xino->file, /*do_test*/1);
++ //if (LktrCond) {fput(stobr(sb, bindex)->br_xino);
++ //stobr(sb, bindex)->br_xino = NULL; err = -1;}
++ if (!err)
++ continue;
++ IOErr("creating xino for branch %d(%d), "
++ "forcing noxino\n", bindex, err);
++ err = -EIO;
++ break;
++ }
++ out:
++ dput(parent);
++ if (!err)
++ au_flag_set(sb, AuFlag_XINO);
++ else
++ au_flag_clr(sb, AuFlag_XINO);
++ TraceErr(err);
++ return err;
++}
++
++/*
++ * clear xino mount option
++ */
++int xino_clr(struct super_block *sb)
++{
++ aufs_bindex_t bindex, bend;
++
++ TraceEnter();
++ SiMustWriteLock(sb);
++
++ bend = sbend(sb);
++ for (bindex = 0; bindex <= bend; bindex++) {
++ struct aufs_branch *br;
++ br = stobr(sb, bindex);
++ if (br->br_xino) {
++ fput(br->br_xino);
++ br->br_xino = NULL;
++ }
++ }
++
++ //todo: need to make iunique() to return the larger inode number
++
++ au_flag_clr(sb, AuFlag_XINO);
++ return 0;
++}
++
++/*
++ * create a xinofile at the default place/path.
++ */
++struct file *xino_def(struct super_block *sb)
++{
++ struct file *file;
++ aufs_bindex_t bend, bindex, bwr;
++ char *page, *p;
++
++ bend = sbend(sb);
++ bwr = -1;
++ for (bindex = 0; bindex <= bend; bindex++)
++ if (br_writable(sbr_perm(sb, bindex))
++ && !au_is_nfs(au_h_dptr_i(sb->s_root, bindex)->d_sb)) {
++ bwr = bindex;
++ break;
++ }
++
++ if (bwr != -1) {
++ // todo: rewrite with lkup_one()
++ file = ERR_PTR(-ENOMEM);
++ page = __getname();
++ //if (LktrCond) {__putname(page); page = NULL;}
++ if (unlikely(!page))
++ goto out;
++ p = d_path(au_h_dptr_i(sb->s_root, bwr), sbr_mnt(sb, bwr), page,
++ PATH_MAX - sizeof(AUFS_XINO_FNAME));
++ //if (LktrCond) p = ERR_PTR(-1);
++ file = (void*)p;
++ if (p && !IS_ERR(p)) {
++ strcat(p, "/" AUFS_XINO_FNAME);
++ LKTRTrace("%s\n", p);
++ file = xino_create(sb, p, /*silent*/0, sb->s_root);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ }
++ __putname(page);
++ } else {
++ file = xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0,
++ /*parent*/NULL);
++ //if (LktrCond) {fput(file); file = ERR_PTR(-1);}
++ }
++
++ out:
++ TraceErrPtr(file);
++ return file;
++}
+diff -rduNp linux-2.6.22.1.oorig/fs/squashfs/Makefile linux-2.6.22.1/fs/squashfs/Makefile
+--- linux-2.6.22.1.oorig/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/squashfs/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,7 @@
++#
++# Makefile for the linux squashfs routines.
++#
++
++obj-$(CONFIG_SQUASHFS) += squashfs.o
++squashfs-y += inode.o
++squashfs-y += squashfs2_0.o
+diff -rduNp linux-2.6.22.1.oorig/fs/squashfs/inode.c linux-2.6.22.1/fs/squashfs/inode.c
+--- linux-2.6.22.1.oorig/fs/squashfs/inode.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/squashfs/inode.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,2329 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * inode.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++#include <linux/buffer_head.h>
++#include <linux/vfs.h>
++#include <linux/vmalloc.h>
++#include <linux/smp_lock.h>
++
++#include "squashfs.h"
++
++static void vfs_read_inode(struct inode *i);
++static struct dentry *squashfs_get_parent(struct dentry *child);
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode);
++static int squashfs_statfs(struct dentry *, struct kstatfs *);
++static int squashfs_symlink_readpage(struct file *file, struct page *page);
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize);
++static int squashfs_readpage(struct file *file, struct page *page);
++static int squashfs_readpage4K(struct file *file, struct page *page);
++static int squashfs_readdir(struct file *, void *, filldir_t);
++static struct dentry *squashfs_lookup(struct inode *, struct dentry *,
++ struct nameidata *);
++static int squashfs_remount(struct super_block *s, int *flags, char *data);
++static void squashfs_put_super(struct super_block *);
++static int squashfs_get_sb(struct file_system_type *,int, const char *, void *,
++ struct vfsmount *);
++static struct inode *squashfs_alloc_inode(struct super_block *sb);
++static void squashfs_destroy_inode(struct inode *inode);
++static int init_inodecache(void);
++static void destroy_inodecache(void);
++
++static struct file_system_type squashfs_fs_type = {
++ .owner = THIS_MODULE,
++ .name = "squashfs",
++ .get_sb = squashfs_get_sb,
++ .kill_sb = kill_block_super,
++ .fs_flags = FS_REQUIRES_DEV
++};
++
++static const unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static struct super_operations squashfs_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .remount_fs = squashfs_remount
++};
++
++static struct super_operations squashfs_export_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .read_inode = vfs_read_inode
++};
++
++static struct export_operations squashfs_export_ops = {
++ .get_parent = squashfs_get_parent
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_symlink_aops = {
++ .readpage = squashfs_symlink_readpage
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_aops = {
++ .readpage = squashfs_readpage
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_aops_4K = {
++ .readpage = squashfs_readpage4K
++};
++
++static const struct file_operations squashfs_dir_ops = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir
++};
++
++SQSH_EXTERN struct inode_operations squashfs_dir_inode_ops = {
++ .lookup = squashfs_lookup
++};
++
++
++static struct buffer_head *get_block_length(struct super_block *s,
++ int *cur_index, int *offset, int *c_byte)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned short temp;
++ struct buffer_head *bh;
++
++ if (!(bh = sb_bread(s, *cur_index)))
++ goto out;
++
++ if (msblk->devblksize - *offset == 1) {
++ if (msblk->swap)
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ else
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ if (msblk->swap)
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ bh->b_data);
++ else
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ bh->b_data);
++ *c_byte = temp;
++ *offset = 1;
++ } else {
++ if (msblk->swap) {
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ } else {
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ }
++ *c_byte = temp;
++ *offset += 2;
++ }
++
++ if (SQUASHFS_CHECK_DATA(msblk->sblk.flags)) {
++ if (*offset == msblk->devblksize) {
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ *offset = 0;
++ }
++ if (*((unsigned char *) (bh->b_data + *offset)) !=
++ SQUASHFS_MARKER_BYTE) {
++ ERROR("Metadata block marker corrupt @ %x\n",
++ *cur_index);
++ brelse(bh);
++ goto out;
++ }
++ (*offset)++;
++ }
++ return bh;
++
++out:
++ return NULL;
++}
++
++
++SQSH_EXTERN unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >>
++ msblk->devblksize_log2) + 2];
++ unsigned int offset = index & ((1 << msblk->devblksize_log2) - 1);
++ unsigned int cur_index = index >> msblk->devblksize_log2;
++ int bytes, avail_bytes, b = 0, k = 0;
++ unsigned int compressed;
++ unsigned int c_byte = length;
++
++ if (c_byte) {
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d, src size %d\n", index, compressed
++ ? "" : "un", (unsigned int) c_byte, srclength);
++
++ if (c_byte > srclength || index < 0 || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ if (!(bh[0] = sb_getblk(s, cur_index)))
++ goto block_release;
++
++ for (b = 1; bytes < c_byte; b++) {
++ if (!(bh[b] = sb_getblk(s, ++cur_index)))
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b, bh);
++ } else {
++ if (index < 0 || (index + 2) > sblk->bytes_used)
++ goto read_failure;
++
++ if (!(bh[0] = get_block_length(s, &cur_index, &offset,
++ &c_byte)))
++ goto read_failure;
++
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed
++ ? "" : "un", (unsigned int) c_byte);
++
++ if (c_byte > srclength || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ for (b = 1; bytes < c_byte; b++) {
++ if (!(bh[b] = sb_getblk(s, ++cur_index)))
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b - 1, bh + 1);
++ }
++
++ if (compressed) {
++ int zlib_err = 0;
++
++ /*
++ * uncompress block
++ */
++
++ mutex_lock(&msblk->read_data_mutex);
++
++ msblk->stream.next_out = buffer;
++ msblk->stream.avail_out = srclength;
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ?
++ msblk->devblksize - offset :
++ c_byte - bytes;
++ wait_on_buffer(bh[k]);
++ if (!buffer_uptodate(bh[k]))
++ goto release_mutex;
++
++ msblk->stream.next_in = bh[k]->b_data + offset;
++ msblk->stream.avail_in = avail_bytes;
++
++ if (k == 0) {
++ zlib_err = zlib_inflateInit(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateInit returned unexpected result 0x%x, srclength %d\n",
++ zlib_err, srclength);
++ goto release_mutex;
++ }
++
++ if (avail_bytes == 0) {
++ offset = 0;
++ brelse(bh[k]);
++ continue;
++ }
++ }
++
++ zlib_err = zlib_inflate(&msblk->stream, Z_NO_FLUSH);
++ if (zlib_err != Z_OK && zlib_err != Z_STREAM_END) {
++ ERROR("zlib_inflate returned unexpected result 0x%x, srclength %d, avail_in %d, avail_out %d\n",
++ zlib_err, srclength, msblk->stream.avail_in, msblk->stream.avail_out);
++ goto release_mutex;
++ }
++
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++
++ if (zlib_err != Z_STREAM_END)
++ goto release_mutex;
++
++ zlib_err = zlib_inflateEnd(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateEnd returned unexpected result 0x%x, srclength %d\n",
++ zlib_err, srclength);
++ goto release_mutex;
++ }
++ bytes = msblk->stream.total_out;
++ mutex_unlock(&msblk->read_data_mutex);
++ } else {
++ int i;
++
++ for(i = 0; i < b; i++) {
++ wait_on_buffer(bh[i]);
++ if(!buffer_uptodate(bh[i]))
++ goto block_release;
++ }
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ?
++ msblk->devblksize - offset :
++ c_byte - bytes;
++ memcpy(buffer + bytes, bh[k]->b_data + offset, avail_bytes);
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++ }
++
++ if (next_index)
++ *next_index = index + c_byte + (length ? 0 :
++ (SQUASHFS_CHECK_DATA(msblk->sblk.flags)
++ ? 3 : 2));
++ return bytes;
++
++release_mutex:
++ mutex_unlock(&msblk->read_data_mutex);
++
++block_release:
++ for (; k < b; k++)
++ brelse(bh[k]);
++
++read_failure:
++ ERROR("sb_bread failed reading block 0x%x\n", cur_index);
++ return 0;
++}
++
++
++SQSH_EXTERN int squashfs_get_cached_block(struct super_block *s, char *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ int n, i, bytes, return_length = length;
++ long long next_index;
++
++ TRACE("Entered squashfs_get_cached_block [%llx:%x]\n", block, offset);
++
++ while ( 1 ) {
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ if (msblk->block_cache[i].block == block)
++ break;
++
++ mutex_lock(&msblk->block_cache_mutex);
++
++ if (i == SQUASHFS_CACHED_BLKS) {
++ /* read inode header block */
++ for (i = msblk->next_cache, n = SQUASHFS_CACHED_BLKS;
++ n ; n --, i = (i + 1) %
++ SQUASHFS_CACHED_BLKS)
++ if (msblk->block_cache[i].block !=
++ SQUASHFS_USED_BLK)
++ break;
++
++ if (n == 0) {
++ wait_queue_t wait;
++
++ init_waitqueue_entry(&wait, current);
++ add_wait_queue(&msblk->waitq, &wait);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ mutex_unlock(&msblk->block_cache_mutex);
++ schedule();
++ set_current_state(TASK_RUNNING);
++ remove_wait_queue(&msblk->waitq, &wait);
++ continue;
++ }
++ msblk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
++
++ if (msblk->block_cache[i].block ==
++ SQUASHFS_INVALID_BLK) {
++ if (!(msblk->block_cache[i].data =
++ kmalloc(SQUASHFS_METADATA_SIZE,
++ GFP_KERNEL))) {
++ ERROR("Failed to allocate cache"
++ "block\n");
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++ }
++
++ msblk->block_cache[i].block = SQUASHFS_USED_BLK;
++ mutex_unlock(&msblk->block_cache_mutex);
++
++ msblk->block_cache[i].length = squashfs_read_data(s,
++ msblk->block_cache[i].data, block, 0, &next_index, SQUASHFS_METADATA_SIZE);
++ if (msblk->block_cache[i].length == 0) {
++ ERROR("Unable to read cache block [%llx:%x]\n",
++ block, offset);
++ mutex_lock(&msblk->block_cache_mutex);
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++ kfree(msblk->block_cache[i].data);
++ wake_up(&msblk->waitq);
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++
++ mutex_lock(&msblk->block_cache_mutex);
++ wake_up(&msblk->waitq);
++ msblk->block_cache[i].block = block;
++ msblk->block_cache[i].next_index = next_index;
++ TRACE("Read cache block [%llx:%x]\n", block, offset);
++ }
++
++ if (msblk->block_cache[i].block != block) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ continue;
++ }
++
++ bytes = msblk->block_cache[i].length - offset;
++
++ if (bytes < 1) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ } else if (bytes >= length) {
++ if (buffer)
++ memcpy(buffer, msblk->block_cache[i].data +
++ offset, length);
++ if (msblk->block_cache[i].length - offset == length) {
++ *next_block = msblk->block_cache[i].next_index;
++ *next_offset = 0;
++ } else {
++ *next_block = block;
++ *next_offset = offset + length;
++ }
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto finish;
++ } else {
++ if (buffer) {
++ memcpy(buffer, msblk->block_cache[i].data +
++ offset, bytes);
++ buffer += bytes;
++ }
++ block = msblk->block_cache[i].next_index;
++ mutex_unlock(&msblk->block_cache_mutex);
++ length -= bytes;
++ offset = 0;
++ }
++ }
++
++finish:
++ return return_length;
++out:
++ return 0;
++}
++
++
++static int get_fragment_location(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
++ struct squashfs_fragment_entry fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry,
++ start_block, offset,
++ sizeof(sfragment_entry), &start_block,
++ &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, (char *) &fragment_entry,
++ start_block, offset,
++ sizeof(fragment_entry), &start_block,
++ &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++SQSH_EXTERN void release_cached_fragment(struct squashfs_sb_info *msblk, struct
++ squashfs_fragment_cache *fragment)
++{
++ mutex_lock(&msblk->fragment_mutex);
++ fragment->locked --;
++ wake_up(&msblk->fragment_wait_queue);
++ mutex_unlock(&msblk->fragment_mutex);
++}
++
++
++SQSH_EXTERN struct squashfs_fragment_cache *get_cached_fragment(struct super_block
++ *s, long long start_block,
++ int length)
++{
++ int i, n;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ while ( 1 ) {
++ mutex_lock(&msblk->fragment_mutex);
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS &&
++ msblk->fragment[i].block != start_block; i++);
++
++ if (i == SQUASHFS_CACHED_FRAGMENTS) {
++ for (i = msblk->next_fragment, n =
++ SQUASHFS_CACHED_FRAGMENTS; n &&
++ msblk->fragment[i].locked; n--, i = (i + 1) %
++ SQUASHFS_CACHED_FRAGMENTS);
++
++ if (n == 0) {
++ wait_queue_t wait;
++
++ init_waitqueue_entry(&wait, current);
++ add_wait_queue(&msblk->fragment_wait_queue,
++ &wait);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ mutex_unlock(&msblk->fragment_mutex);
++ schedule();
++ set_current_state(TASK_RUNNING);
++ remove_wait_queue(&msblk->fragment_wait_queue,
++ &wait);
++ continue;
++ }
++ msblk->next_fragment = (msblk->next_fragment + 1) %
++ SQUASHFS_CACHED_FRAGMENTS;
++
++ if (msblk->fragment[i].data == NULL)
++ if (!(msblk->fragment[i].data = SQUASHFS_ALLOC
++ (SQUASHFS_FILE_MAX_SIZE))) {
++ ERROR("Failed to allocate fragment "
++ "cache block\n");
++ mutex_unlock(&msblk->fragment_mutex);
++ goto out;
++ }
++
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ msblk->fragment[i].locked = 1;
++ mutex_unlock(&msblk->fragment_mutex);
++
++ if (!(msblk->fragment[i].length = squashfs_read_data(s,
++ msblk->fragment[i].data,
++ start_block, length, NULL, sblk->block_size))) {
++ ERROR("Unable to read fragment cache block "
++ "[%llx]\n", start_block);
++ msblk->fragment[i].locked = 0;
++ smp_mb();
++ goto out;
++ }
++
++ mutex_lock(&msblk->fragment_mutex);
++ msblk->fragment[i].block = start_block;
++ TRACE("New fragment %d, start block %lld, locked %d\n",
++ i, msblk->fragment[i].block,
++ msblk->fragment[i].locked);
++ mutex_unlock(&msblk->fragment_mutex);
++ break;
++ }
++
++ msblk->fragment[i].locked++;
++ mutex_unlock(&msblk->fragment_mutex);
++ TRACE("Got fragment %d, start block %lld, locked %d\n", i,
++ msblk->fragment[i].block,
++ msblk->fragment[i].locked);
++ break;
++ }
++
++ return &msblk->fragment[i];
++
++out:
++ return NULL;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header *inodeb)
++{
++ i->i_ino = inodeb->inode_number;
++ i->i_mtime.tv_sec = inodeb->mtime;
++ i->i_atime.tv_sec = inodeb->mtime;
++ i->i_ctime.tv_sec = inodeb->mtime;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_size = 0;
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static squashfs_inode_t squashfs_inode_lookup(struct super_block *s, int ino)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start = msblk->inode_lookup_table[SQUASHFS_LOOKUP_BLOCK(ino - 1)];
++ int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino - 1);
++ squashfs_inode_t inode;
++
++ TRACE("Entered squashfs_inode_lookup, inode_number = %d\n", ino);
++
++ if (msblk->swap) {
++ squashfs_inode_t sinode;
++
++ if (!squashfs_get_cached_block(s, (char *) &sinode, start, offset,
++ sizeof(sinode), &start, &offset))
++ goto out;
++ SQUASHFS_SWAP_INODE_T((&inode), &sinode);
++ } else if (!squashfs_get_cached_block(s, (char *) &inode, start, offset,
++ sizeof(inode), &start, &offset))
++ goto out;
++
++ TRACE("squashfs_inode_lookup, inode = 0x%llx\n", inode);
++
++ return inode;
++
++out:
++ return SQUASHFS_INVALID_BLK;
++}
++
++
++static void vfs_read_inode(struct inode *i)
++{
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ squashfs_inode_t inode = squashfs_inode_lookup(i->i_sb, i->i_ino);
++
++ TRACE("Entered vfs_read_inode\n");
++
++ if(inode != SQUASHFS_INVALID_BLK)
++ (msblk->read_inode)(i, inode);
++}
++
++
++static struct dentry *squashfs_get_parent(struct dentry *child)
++{
++ struct inode *i = child->d_inode;
++ struct inode *parent = iget(i->i_sb, SQUASHFS_I(i)->u.s2.parent_inode);
++ struct dentry *rv;
++
++ TRACE("Entered squashfs_get_parent\n");
++
++ if(parent == NULL) {
++ rv = ERR_PTR(-EACCES);
++ goto out;
++ }
++
++ rv = d_alloc_anon(parent);
++ if(rv == NULL)
++ rv = ERR_PTR(-ENOMEM);
++
++out:
++ return rv;
++}
++
++
++SQSH_EXTERN struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode, unsigned int inode_number)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct inode *i = iget_locked(s, inode_number);
++
++ TRACE("Entered squashfs_iget\n");
++
++ if(i && (i->i_state & I_NEW)) {
++ (msblk->read_inode)(i, inode);
++ unlock_new_inode(i);
++ }
++
++ return i;
++}
++
++
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long block = SQUASHFS_INODE_BLK(inode) +
++ sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header id, sid;
++ struct squashfs_base_inode_header *inodeb = &id.base,
++ *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_read_inode\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *) sinodeb, block,
++ offset, sizeof(*sinodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER(inodeb, sinodeb,
++ sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, (char *) inodeb, block,
++ offset, sizeof(*inodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_reg_inode_header *inodep = &id.reg;
++ struct squashfs_reg_inode_header *sinodep = &sid.reg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_nlink = 1;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_LREG_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_lreg_inode_header *inodep = &id.lreg;
++ struct squashfs_lreg_inode_header *sinodep = &sid.lreg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LREG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header *inodep = &id.dir;
++ struct squashfs_dir_inode_header *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset =
++ next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count =
++ inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Long directory inode %x:%x, start_block %x, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header *inodep =
++ &id.symlink;
++ struct squashfs_symlink_inode_header *sinodep =
++ &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header *inodep = &id.dev;
++ struct squashfs_dev_inode_header *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type ==
++ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR :
++ S_IFBLK;
++ init_special_inode(i, i->i_mode,
++ old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++ struct squashfs_ipc_inode_header *inodep = &id.ipc;
++ struct squashfs_ipc_inode_header *sinodep = &sid.ipc;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_IPC_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%llx:%x]\n", block, offset);
++
++failed_read1:
++ make_bad_inode(i);
++ return 0;
++}
++
++
++static int read_inode_lookup_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(sblk->inodes);
++
++ TRACE("In read_inode_lookup_table, length %d\n", length);
++
++ /* Allocate inode lookup table */
++ if (!(msblk->inode_lookup_table = kmalloc(length, GFP_KERNEL))) {
++ ERROR("Failed to allocate inode lookup table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->inode_lookup_table,
++ sblk->lookup_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read inode lookup table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long block;
++
++ for (i = 0; i < SQUASHFS_LOOKUP_BLOCKS(sblk->inodes); i++) {
++ SQUASHFS_SWAP_LOOKUP_BLOCKS((&block),
++ &msblk->inode_lookup_table[i], 1);
++ msblk->inode_lookup_table[i] = block;
++ }
++ }
++
++ return 1;
++}
++
++
++static int read_fragment_index_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_FRAGMENT_INDEX_BYTES(sblk->fragments);
++
++ if(length == 0)
++ return 1;
++
++ /* Allocate fragment index table */
++ if (!(msblk->fragment_index = kmalloc(length, GFP_KERNEL))) {
++ ERROR("Failed to allocate fragment index table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->fragment_index,
++ sblk->fragment_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sblk->fragments); i++) {
++ SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment),
++ &msblk->fragment_index[i], 1);
++ msblk->fragment_index[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int supported_squashfs_filesystem(struct squashfs_sb_info *msblk, int silent)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode;
++ msblk->read_blocklist = read_blocklist;
++ msblk->read_fragment_index_table = read_fragment_index_table;
++
++ if (sblk->s_major == 1) {
++ if (!squashfs_1_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 1.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with "
++ "Squashfs 1.0 support enabled\n");
++ return 0;
++ }
++ } else if (sblk->s_major == 2) {
++ if (!squashfs_2_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 2.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with "
++ "Squashfs 2.0 support enabled\n");
++ return 0;
++ }
++ } else if(sblk->s_major != SQUASHFS_MAJOR || sblk->s_minor >
++ SQUASHFS_MINOR) {
++ SERROR("Major/Minor mismatch, trying to mount newer %d.%d "
++ "filesystem\n", sblk->s_major, sblk->s_minor);
++ SERROR("Please update your kernel\n");
++ return 0;
++ }
++
++ return 1;
++}
++
++
++static int squashfs_fill_super(struct super_block *s, void *data, int silent)
++{
++ struct squashfs_sb_info *msblk;
++ struct squashfs_super_block *sblk;
++ int i;
++ char b[BDEVNAME_SIZE];
++ struct inode *root;
++
++ TRACE("Entered squashfs_read_superblock\n");
++
++ if (!(s->s_fs_info = kmalloc(sizeof(struct squashfs_sb_info),
++ GFP_KERNEL))) {
++ ERROR("Failed to allocate superblock\n");
++ goto failure;
++ }
++ memset(s->s_fs_info, 0, sizeof(struct squashfs_sb_info));
++ msblk = s->s_fs_info;
++ if (!(msblk->stream.workspace = vmalloc(zlib_inflate_workspacesize()))) {
++ ERROR("Failed to allocate zlib workspace\n");
++ goto failure;
++ }
++ sblk = &msblk->sblk;
++
++ msblk->devblksize = sb_min_blocksize(s, BLOCK_SIZE);
++ msblk->devblksize_log2 = ffz(~msblk->devblksize);
++
++ mutex_init(&msblk->read_data_mutex);
++ mutex_init(&msblk->read_page_mutex);
++ mutex_init(&msblk->block_cache_mutex);
++ mutex_init(&msblk->fragment_mutex);
++ mutex_init(&msblk->meta_index_mutex);
++
++ init_waitqueue_head(&msblk->waitq);
++ init_waitqueue_head(&msblk->fragment_wait_queue);
++
++ sblk->bytes_used = sizeof(struct squashfs_super_block);
++ if (!squashfs_read_data(s, (char *) sblk, SQUASHFS_START,
++ sizeof(struct squashfs_super_block) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, sizeof(struct squashfs_super_block))) {
++ SERROR("unable to read superblock\n");
++ goto failed_mount;
++ }
++
++ /* Check it is a SQUASHFS superblock */
++ msblk->swap = 0;
++ if ((s->s_magic = sblk->s_magic) != SQUASHFS_MAGIC) {
++ if (sblk->s_magic == SQUASHFS_MAGIC_SWAP) {
++ struct squashfs_super_block ssblk;
++
++ WARNING("Mounting a different endian SQUASHFS "
++ "filesystem on %s\n", bdevname(s->s_bdev, b));
++
++ SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk);
++ memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block));
++ msblk->swap = 1;
++ } else {
++ SERROR("Can't find a SQUASHFS superblock on %s\n",
++ bdevname(s->s_bdev, b));
++ goto failed_mount;
++ }
++ }
++
++ /* Check the MAJOR & MINOR versions */
++ if(!supported_squashfs_filesystem(msblk, silent))
++ goto failed_mount;
++
++ /* Check the filesystem does not extend beyond the end of the
++ block device */
++ if(sblk->bytes_used < 0 || sblk->bytes_used > i_size_read(s->s_bdev->bd_inode))
++ goto failed_mount;
++
++ /* Check the root inode for sanity */
++ if (SQUASHFS_INODE_OFFSET(sblk->root_inode) > SQUASHFS_METADATA_SIZE)
++ goto failed_mount;
++
++ TRACE("Found valid superblock on %s\n", bdevname(s->s_bdev, b));
++ TRACE("Inodes are %scompressed\n",
++ SQUASHFS_UNCOMPRESSED_INODES
++ (sblk->flags) ? "un" : "");
++ TRACE("Data is %scompressed\n",
++ SQUASHFS_UNCOMPRESSED_DATA(sblk->flags)
++ ? "un" : "");
++ TRACE("Check data is %s present in the filesystem\n",
++ SQUASHFS_CHECK_DATA(sblk->flags) ?
++ "" : "not");
++ TRACE("Filesystem size %lld bytes\n", sblk->bytes_used);
++ TRACE("Block size %d\n", sblk->block_size);
++ TRACE("Number of inodes %d\n", sblk->inodes);
++ if (sblk->s_major > 1)
++ TRACE("Number of fragments %d\n", sblk->fragments);
++ TRACE("Number of uids %d\n", sblk->no_uids);
++ TRACE("Number of gids %d\n", sblk->no_guids);
++ TRACE("sblk->inode_table_start %llx\n", sblk->inode_table_start);
++ TRACE("sblk->directory_table_start %llx\n", sblk->directory_table_start);
++ if (sblk->s_major > 1)
++ TRACE("sblk->fragment_table_start %llx\n",
++ sblk->fragment_table_start);
++ TRACE("sblk->uid_start %llx\n", sblk->uid_start);
++
++ s->s_flags |= MS_RDONLY;
++ s->s_op = &squashfs_super_ops;
++
++ /* Init inode_table block pointer array */
++ if (!(msblk->block_cache = kmalloc(sizeof(struct squashfs_cache) *
++ SQUASHFS_CACHED_BLKS, GFP_KERNEL))) {
++ ERROR("Failed to allocate block cache\n");
++ goto failed_mount;
++ }
++
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++
++ msblk->next_cache = 0;
++
++ /* Allocate read_page block */
++ if (!(msblk->read_page = kmalloc(sblk->block_size, GFP_KERNEL))) {
++ ERROR("Failed to allocate read_page block\n");
++ goto failed_mount;
++ }
++
++ /* Allocate uid and gid tables */
++ if (!(msblk->uid = kmalloc((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int), GFP_KERNEL))) {
++ ERROR("Failed to allocate uid/gid table\n");
++ goto failed_mount;
++ }
++ msblk->guid = msblk->uid + sblk->no_uids;
++
++ if (msblk->swap) {
++ unsigned int suid[sblk->no_uids + sblk->no_guids];
++
++ if (!squashfs_read_data(s, (char *) &suid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++ SQUASHFS_SWAP_DATA(msblk->uid, suid, (sblk->no_uids +
++ sblk->no_guids), (sizeof(unsigned int) * 8));
++ } else
++ if (!squashfs_read_data(s, (char *) msblk->uid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++
++ if (sblk->s_major == 1 && squashfs_1_0_supported(msblk))
++ goto allocate_root;
++
++ if (!(msblk->fragment = kmalloc(sizeof(struct squashfs_fragment_cache) *
++ SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) {
++ ERROR("Failed to allocate fragment block cache\n");
++ goto failed_mount;
++ }
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) {
++ msblk->fragment[i].locked = 0;
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ msblk->fragment[i].data = NULL;
++ }
++
++ msblk->next_fragment = 0;
++
++ /* Allocate and read fragment index table */
++ if (msblk->read_fragment_index_table(s) == 0)
++ goto failed_mount;
++
++ if(sblk->s_major < 3 || sblk->lookup_table_start == SQUASHFS_INVALID_BLK)
++ goto allocate_root;
++
++ /* Allocate and read inode lookup table */
++ if (read_inode_lookup_table(s) == 0)
++ goto failed_mount;
++
++ s->s_op = &squashfs_export_super_ops;
++ s->s_export_op = &squashfs_export_ops;
++
++allocate_root:
++ root = new_inode(s);
++ if ((msblk->read_inode)(root, sblk->root_inode) == 0)
++ goto failed_mount;
++ insert_inode_hash(root);
++
++ if ((s->s_root = d_alloc_root(root)) == NULL) {
++ ERROR("Root inode create failed\n");
++ iput(root);
++ goto failed_mount;
++ }
++
++ TRACE("Leaving squashfs_read_super\n");
++ return 0;
++
++failed_mount:
++ kfree(msblk->inode_lookup_table);
++ kfree(msblk->fragment_index);
++ kfree(msblk->fragment);
++ kfree(msblk->uid);
++ kfree(msblk->read_page);
++ kfree(msblk->block_cache);
++ kfree(msblk->fragment_index_2);
++ vfree(msblk->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ return -EINVAL;
++
++failure:
++ return -ENOMEM;
++}
++
++
++static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
++{
++ struct squashfs_sb_info *msblk = dentry->d_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ TRACE("Entered squashfs_statfs\n");
++
++ buf->f_type = SQUASHFS_MAGIC;
++ buf->f_bsize = sblk->block_size;
++ buf->f_blocks = ((sblk->bytes_used - 1) >> sblk->block_log) + 1;
++ buf->f_bfree = buf->f_bavail = 0;
++ buf->f_files = sblk->inodes;
++ buf->f_ffree = 0;
++ buf->f_namelen = SQUASHFS_NAME_LEN;
++
++ return 0;
++}
++
++
++static int squashfs_symlink_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ int index = page->index << PAGE_CACHE_SHIFT, length, bytes;
++ long long block = SQUASHFS_I(inode)->start_block;
++ int offset = SQUASHFS_I(inode)->offset;
++ void *pageaddr = kmap(page);
++
++ TRACE("Entered squashfs_symlink_readpage, page index %ld, start block "
++ "%llx, offset %x\n", page->index,
++ SQUASHFS_I(inode)->start_block,
++ SQUASHFS_I(inode)->offset);
++
++ for (length = 0; length < index; length += bytes) {
++ if (!(bytes = squashfs_get_cached_block(inode->i_sb, NULL,
++ block, offset, PAGE_CACHE_SIZE, &block,
++ &offset))) {
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block,
++ offset);
++ goto skip_read;
++ }
++ }
++
++ if (length != index) {
++ ERROR("(squashfs_symlink_readpage) length != index\n");
++ bytes = 0;
++ goto skip_read;
++ }
++
++ bytes = (i_size_read(inode) - length) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE :
++ i_size_read(inode) - length;
++
++ if (!(bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block,
++ offset, bytes, &block, &offset)))
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block, offset);
++
++skip_read:
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap(page);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ return 0;
++}
++
++
++struct meta_index *locate_meta_index(struct inode *inode, int index, int offset)
++{
++ struct meta_index *meta = NULL;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("locate_meta_index: index %d, offset %d\n", index, offset);
++
++ if(msblk->meta_index == NULL)
++ goto not_allocated;
++
++ for (i = 0; i < SQUASHFS_META_NUMBER; i ++)
++ if (msblk->meta_index[i].inode_number == inode->i_ino &&
++ msblk->meta_index[i].offset >= offset &&
++ msblk->meta_index[i].offset <= index &&
++ msblk->meta_index[i].locked == 0) {
++ TRACE("locate_meta_index: entry %d, offset %d\n", i,
++ msblk->meta_index[i].offset);
++ meta = &msblk->meta_index[i];
++ offset = meta->offset;
++ }
++
++ if (meta)
++ meta->locked = 1;
++
++not_allocated:
++ mutex_unlock(&msblk->meta_index_mutex);
++
++ return meta;
++}
++
++
++struct meta_index *empty_meta_index(struct inode *inode, int offset, int skip)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct meta_index *meta = NULL;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("empty_meta_index: offset %d, skip %d\n", offset, skip);
++
++ if(msblk->meta_index == NULL) {
++ if (!(msblk->meta_index = kmalloc(sizeof(struct meta_index) *
++ SQUASHFS_META_NUMBER, GFP_KERNEL))) {
++ ERROR("Failed to allocate meta_index\n");
++ goto failed;
++ }
++ for(i = 0; i < SQUASHFS_META_NUMBER; i++) {
++ msblk->meta_index[i].inode_number = 0;
++ msblk->meta_index[i].locked = 0;
++ }
++ msblk->next_meta_index = 0;
++ }
++
++ for(i = SQUASHFS_META_NUMBER; i &&
++ msblk->meta_index[msblk->next_meta_index].locked; i --)
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ if(i == 0) {
++ TRACE("empty_meta_index: failed!\n");
++ goto failed;
++ }
++
++ TRACE("empty_meta_index: returned meta entry %d, %p\n",
++ msblk->next_meta_index,
++ &msblk->meta_index[msblk->next_meta_index]);
++
++ meta = &msblk->meta_index[msblk->next_meta_index];
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ meta->inode_number = inode->i_ino;
++ meta->offset = offset;
++ meta->skip = skip;
++ meta->entries = 0;
++ meta->locked = 1;
++
++failed:
++ mutex_unlock(&msblk->meta_index_mutex);
++ return meta;
++}
++
++
++void release_meta_index(struct inode *inode, struct meta_index *meta)
++{
++ meta->locked = 0;
++ smp_mb();
++}
++
++
++static int read_block_index(struct super_block *s, int blocks, char *block_list,
++ long long *start_block, int *offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned int *block_listp;
++ int block = 0;
++
++ if (msblk->swap) {
++ char sblock_list[blocks << 2];
++
++ if (!squashfs_get_cached_block(s, sblock_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Unable to read block list [%llx:%x]\n",
++ *start_block, *offset);
++ goto failure;
++ }
++ SQUASHFS_SWAP_INTS(((unsigned int *)block_list),
++ ((unsigned int *)sblock_list), blocks);
++ } else
++ if (!squashfs_get_cached_block(s, block_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Unable to read block list [%llx:%x]\n",
++ *start_block, *offset);
++ goto failure;
++ }
++
++ for (block_listp = (unsigned int *) block_list; blocks;
++ block_listp++, blocks --)
++ block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp);
++
++ return block;
++
++failure:
++ return -1;
++}
++
++
++#define SIZE 256
++
++static inline int calculate_skip(int blocks) {
++ int skip = (blocks - 1) / ((SQUASHFS_SLOTS * SQUASHFS_META_ENTRIES + 1) * SQUASHFS_META_INDEXES);
++ return skip >= 7 ? 7 : skip + 1;
++}
++
++
++static int get_meta_index(struct inode *inode, int index,
++ long long *index_block, int *index_offset,
++ long long *data_block, char *block_list)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int skip = calculate_skip(i_size_read(inode) >> sblk->block_log);
++ int offset = 0;
++ struct meta_index *meta;
++ struct meta_entry *meta_entry;
++ long long cur_index_block = SQUASHFS_I(inode)->u.s1.block_list_start;
++ int cur_offset = SQUASHFS_I(inode)->offset;
++ long long cur_data_block = SQUASHFS_I(inode)->start_block;
++ int i;
++
++ index /= SQUASHFS_META_INDEXES * skip;
++
++ while ( offset < index ) {
++ meta = locate_meta_index(inode, index, offset + 1);
++
++ if (meta == NULL) {
++ if ((meta = empty_meta_index(inode, offset + 1,
++ skip)) == NULL)
++ goto all_done;
++ } else {
++ if(meta->entries == 0)
++ goto failed;
++ offset = index < meta->offset + meta->entries ? index :
++ meta->offset + meta->entries - 1;
++ meta_entry = &meta->meta_entry[offset - meta->offset];
++ cur_index_block = meta_entry->index_block + sblk->inode_table_start;
++ cur_offset = meta_entry->offset;
++ cur_data_block = meta_entry->data_block;
++ TRACE("get_meta_index: offset %d, meta->offset %d, "
++ "meta->entries %d\n", offset, meta->offset,
++ meta->entries);
++ TRACE("get_meta_index: index_block 0x%llx, offset 0x%x"
++ " data_block 0x%llx\n", cur_index_block,
++ cur_offset, cur_data_block);
++ }
++
++ for (i = meta->offset + meta->entries; i <= index &&
++ i < meta->offset + SQUASHFS_META_ENTRIES; i++) {
++ int blocks = skip * SQUASHFS_META_INDEXES;
++
++ while (blocks) {
++ int block = blocks > (SIZE >> 2) ? (SIZE >> 2) :
++ blocks;
++ int res = read_block_index(inode->i_sb, block,
++ block_list, &cur_index_block,
++ &cur_offset);
++
++ if (res == -1)
++ goto failed;
++
++ cur_data_block += res;
++ blocks -= block;
++ }
++
++ meta_entry = &meta->meta_entry[i - meta->offset];
++ meta_entry->index_block = cur_index_block - sblk->inode_table_start;
++ meta_entry->offset = cur_offset;
++ meta_entry->data_block = cur_data_block;
++ meta->entries ++;
++ offset ++;
++ }
++
++ TRACE("get_meta_index: meta->offset %d, meta->entries %d\n",
++ meta->offset, meta->entries);
++
++ release_meta_index(inode, meta);
++ }
++
++all_done:
++ *index_block = cur_index_block;
++ *index_offset = cur_offset;
++ *data_block = cur_data_block;
++
++ return offset * SQUASHFS_META_INDEXES * skip;
++
++failed:
++ release_meta_index(inode, meta);
++ return -1;
++}
++
++
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize)
++{
++ long long block_ptr;
++ int offset;
++ long long block;
++ int res = get_meta_index(inode, index, &block_ptr, &offset, &block,
++ block_list);
++
++ TRACE("read_blocklist: res %d, index %d, block_ptr 0x%llx, offset"
++ " 0x%x, block 0x%llx\n", res, index, block_ptr, offset,
++ block);
++
++ if(res == -1)
++ goto failure;
++
++ index -= res;
++
++ while ( index ) {
++ int blocks = index > (SIZE >> 2) ? (SIZE >> 2) : index;
++ int res = read_block_index(inode->i_sb, blocks, block_list,
++ &block_ptr, &offset);
++ if (res == -1)
++ goto failure;
++ block += res;
++ index -= blocks;
++ }
++
++ if (read_block_index(inode->i_sb, 1, block_list,
++ &block_ptr, &offset) == -1)
++ goto failure;
++ *bsize = *((unsigned int *) block_list);
++
++ return block;
++
++failure:
++ return 0;
++}
++
++
++static int squashfs_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned char *block_list;
++ long long block;
++ unsigned int bsize, i = 0, bytes = 0, byte_offset = 0;
++ int index = page->index >> (sblk->block_log - PAGE_CACHE_SHIFT);
++ void *pageaddr;
++ struct squashfs_fragment_cache *fragment = NULL;
++ char *data_ptr = msblk->read_page;
++
++ int mask = (1 << (sblk->block_log - PAGE_CACHE_SHIFT)) - 1;
++ int start_index = page->index & ~mask;
++ int end_index = start_index | mask;
++
++ TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
++ page->index,
++ SQUASHFS_I(inode)->start_block);
++
++ if (!(block_list = kmalloc(SIZE, GFP_KERNEL))) {
++ ERROR("Failed to allocate block_list\n");
++ goto skip_read;
++ }
++
++ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
++ PAGE_CACHE_SHIFT))
++ goto skip_read;
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < (i_size_read(inode) >>
++ sblk->block_log)) {
++ if ((block = (msblk->read_blocklist)(inode, index, 1,
++ block_list, NULL, &bsize)) == 0)
++ goto skip_read;
++
++ mutex_lock(&msblk->read_page_mutex);
++
++ if (!(bytes = squashfs_read_data(inode->i_sb, msblk->read_page,
++ block, bsize, NULL, sblk->block_size))) {
++ ERROR("Unable to read page, block %llx, size %x\n", block,
++ bsize);
++ mutex_unlock(&msblk->read_page_mutex);
++ goto skip_read;
++ }
++ } else {
++ if ((fragment = get_cached_fragment(inode->i_sb,
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ SQUASHFS_I(inode)->u.s1.fragment_size))
++ == NULL) {
++ ERROR("Unable to read page, block %llx, size %x\n",
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ (int) SQUASHFS_I(inode)->
++ u.s1.fragment_size);
++ goto skip_read;
++ }
++ bytes = SQUASHFS_I(inode)->u.s1.fragment_offset +
++ (i_size_read(inode) & (sblk->block_size
++ - 1));
++ byte_offset = SQUASHFS_I(inode)->u.s1.fragment_offset;
++ data_ptr = fragment->data;
++ }
++
++ for (i = start_index; i <= end_index && byte_offset < bytes;
++ i++, byte_offset += PAGE_CACHE_SIZE) {
++ struct page *push_page;
++ int avail = (bytes - byte_offset) > PAGE_CACHE_SIZE ?
++ PAGE_CACHE_SIZE : bytes - byte_offset;
++
++ TRACE("bytes %d, i %d, byte_offset %d, available_bytes %d\n",
++ bytes, i, byte_offset, avail);
++
++ push_page = (i == page->index) ? page :
++ grab_cache_page_nowait(page->mapping, i);
++
++ if (!push_page)
++ continue;
++
++ if (PageUptodate(push_page))
++ goto skip_page;
++
++ pageaddr = kmap_atomic(push_page, KM_USER0);
++ memcpy(pageaddr, data_ptr + byte_offset, avail);
++ memset(pageaddr + avail, 0, PAGE_CACHE_SIZE - avail);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(push_page);
++ SetPageUptodate(push_page);
++skip_page:
++ unlock_page(push_page);
++ if(i != page->index)
++ page_cache_release(push_page);
++ }
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < (i_size_read(inode) >>
++ sblk->block_log))
++ mutex_unlock(&msblk->read_page_mutex);
++ else
++ release_cached_fragment(msblk, fragment);
++
++ kfree(block_list);
++ return 0;
++
++skip_read:
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ kfree(block_list);
++ return 0;
++}
++
++
++static int squashfs_readpage4K(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned char *block_list;
++ long long block;
++ unsigned int bsize, bytes = 0;
++ void *pageaddr;
++
++ TRACE("Entered squashfs_readpage4K, page index %lx, start block %llx\n",
++ page->index,
++ SQUASHFS_I(inode)->start_block);
++
++ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
++ PAGE_CACHE_SHIFT)) {
++ block_list = NULL;
++ goto skip_read;
++ }
++
++ if (!(block_list = kmalloc(SIZE, GFP_KERNEL))) {
++ ERROR("Failed to allocate block_list\n");
++ goto skip_read;
++ }
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || page->index < (i_size_read(inode) >>
++ sblk->block_log)) {
++ block = (msblk->read_blocklist)(inode, page->index, 1,
++ block_list, NULL, &bsize);
++ if(block == 0)
++ goto skip_read;
++
++ mutex_lock(&msblk->read_page_mutex);
++ bytes = squashfs_read_data(inode->i_sb, msblk->read_page, block,
++ bsize, NULL, sblk->block_size);
++ if (bytes) {
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memcpy(pageaddr, msblk->read_page, bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ } else
++ ERROR("Unable to read page, block %llx, size %x\n",
++ block, bsize);
++ mutex_unlock(&msblk->read_page_mutex);
++ } else {
++ struct squashfs_fragment_cache *fragment =
++ get_cached_fragment(inode->i_sb,
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block,
++ SQUASHFS_I(inode)-> u.s1.fragment_size);
++ if (fragment) {
++ bytes = i_size_read(inode) & (sblk->block_size - 1);
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memcpy(pageaddr, fragment->data + SQUASHFS_I(inode)->
++ u.s1.fragment_offset, bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ release_cached_fragment(msblk, fragment);
++ } else
++ ERROR("Unable to read page, block %llx, size %x\n",
++ SQUASHFS_I(inode)->
++ u.s1.fragment_start_block, (int)
++ SQUASHFS_I(inode)-> u.s1.fragment_size);
++ }
++
++skip_read:
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ kfree(block_list);
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ f_pos =- 3;
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) &index,
++ index_start, index_offset,
++ sizeof(index), &index_start,
++ &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start,
++ &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length + 3;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ if (!(str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) index,
++ index_start, index_offset,
++ sizeof(struct squashfs_dir_index),
++ &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start,
++ index_offset, index->size + 1,
++ &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++failure:
++ return length + 3;
++}
++
++
++static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_readdir [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ while(file->f_pos < 3) {
++ char *name;
++ int size, i_ino;
++
++ if(file->f_pos == 0) {
++ name = ".";
++ size = 1;
++ i_ino = i->i_ino;
++ } else {
++ name = "..";
++ size = 2;
++ i_ino = SQUASHFS_I(i)->u.s2.parent_inode;
++ }
++ TRACE("Calling filldir(%x, %s, %d, %d, %d, %d)\n",
++ (unsigned int) dirent, name, size, (int)
++ file->f_pos, i_ino,
++ squashfs_filetype_table[1]);
++
++ if (filldir(dirent, name, size,
++ file->f_pos, i_ino,
++ squashfs_filetype_table[1]) < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos += size;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count,
++ file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block, next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block, next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset,
++ dire->size + 1, &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d, %d)\n",
++ (unsigned int) dirent, dire->name,
++ dire->size + 1, (int) file->f_pos,
++ dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1,
++ file->f_pos,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type])
++ < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_lookup [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_lookup;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_lookup;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name,
++ len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block,next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block,next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset, dire->size + 1,
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (name[0] < dire->name[0])
++ goto exit_lookup;
++
++ if ((len == dire->size + 1) && !strncmp(name, dire->name, len)) {
++ squashfs_inode_t ino = SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory "
++ "entry %s, inode %x:%x, %d\n", name,
++ dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number);
++
++ inode = squashfs_iget(i->i_sb, ino, dirh.inode_number + dire->inode_number);
++
++ goto exit_lookup;
++ }
++ }
++ }
++
++exit_lookup:
++ kfree(dire);
++ if (inode)
++ return d_splice_alias(inode, dentry);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_lookup;
++}
++
++
++static int squashfs_remount(struct super_block *s, int *flags, char *data)
++{
++ *flags |= MS_RDONLY;
++ return 0;
++}
++
++
++static void squashfs_put_super(struct super_block *s)
++{
++ int i;
++
++ if (s->s_fs_info) {
++ struct squashfs_sb_info *sbi = s->s_fs_info;
++ if (sbi->block_cache)
++ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++)
++ if (sbi->block_cache[i].block !=
++ SQUASHFS_INVALID_BLK)
++ kfree(sbi->block_cache[i].data);
++ if (sbi->fragment)
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++)
++ SQUASHFS_FREE(sbi->fragment[i].data);
++ kfree(sbi->fragment);
++ kfree(sbi->block_cache);
++ kfree(sbi->read_page);
++ kfree(sbi->uid);
++ kfree(sbi->fragment_index);
++ kfree(sbi->fragment_index_2);
++ kfree(sbi->meta_index);
++ vfree(sbi->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ }
++}
++
++
++static int squashfs_get_sb(struct file_system_type *fs_type, int flags,
++ const char *dev_name, void *data,
++ struct vfsmount *mnt)
++{
++ return get_sb_bdev(fs_type, flags, dev_name, data, squashfs_fill_super,
++ mnt);
++}
++
++
++static int __init init_squashfs_fs(void)
++{
++ int err = init_inodecache();
++ if (err)
++ goto out;
++
++ printk(KERN_INFO "squashfs: version 3.2-r2 (2007/01/15) "
++ "Phillip Lougher\n");
++
++ if ((err = register_filesystem(&squashfs_fs_type)))
++ destroy_inodecache();
++
++out:
++ return err;
++}
++
++
++static void __exit exit_squashfs_fs(void)
++{
++ unregister_filesystem(&squashfs_fs_type);
++ destroy_inodecache();
++}
++
++
++static struct kmem_cache * squashfs_inode_cachep;
++
++
++static struct inode *squashfs_alloc_inode(struct super_block *sb)
++{
++ struct squashfs_inode_info *ei;
++ ei = kmem_cache_alloc(squashfs_inode_cachep, GFP_KERNEL);
++ if (!ei)
++ return NULL;
++ return &ei->vfs_inode;
++}
++
++
++static void squashfs_destroy_inode(struct inode *inode)
++{
++ kmem_cache_free(squashfs_inode_cachep, SQUASHFS_I(inode));
++}
++
++
++static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
++{
++ struct squashfs_inode_info *ei = foo;
++
++ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
++ SLAB_CTOR_CONSTRUCTOR)
++ inode_init_once(&ei->vfs_inode);
++}
++
++
++static int __init init_inodecache(void)
++{
++ squashfs_inode_cachep = kmem_cache_create("squashfs_inode_cache",
++ sizeof(struct squashfs_inode_info),
++ 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
++ init_once, NULL);
++ if (squashfs_inode_cachep == NULL)
++ return -ENOMEM;
++ return 0;
++}
++
++
++static void destroy_inodecache(void)
++{
++ kmem_cache_destroy(squashfs_inode_cachep);
++}
++
++
++module_init(init_squashfs_fs);
++module_exit(exit_squashfs_fs);
++MODULE_DESCRIPTION("squashfs 3.2-r2, a compressed read-only filesystem");
++MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>");
++MODULE_LICENSE("GPL");
+diff -rduNp linux-2.6.22.1.oorig/fs/squashfs/squashfs.h linux-2.6.22.1/fs/squashfs/squashfs.h
+--- linux-2.6.22.1.oorig/fs/squashfs/squashfs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/squashfs/squashfs.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,87 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs.h
++ */
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#undef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#endif
++
++#ifdef SQUASHFS_TRACE
++#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
++#else
++#define TRACE(s, args...) {}
++#endif
++
++#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args)
++
++#define SERROR(s, args...) do { \
++ if (!silent) \
++ printk(KERN_ERR "SQUASHFS error: "s, ## args);\
++ } while(0)
++
++#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args)
++
++static inline struct squashfs_inode_info *SQUASHFS_I(struct inode *inode)
++{
++ return list_entry(inode, struct squashfs_inode_info, vfs_inode);
++}
++
++#if defined(CONFIG_SQUASHFS_1_0_COMPATIBILITY ) || defined(CONFIG_SQUASHFS_2_0_COMPATIBILITY)
++#define SQSH_EXTERN
++extern unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength);
++extern int squashfs_get_cached_block(struct super_block *s, char *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset);
++extern void release_cached_fragment(struct squashfs_sb_info *msblk, struct
++ squashfs_fragment_cache *fragment);
++extern struct squashfs_fragment_cache *get_cached_fragment(struct super_block
++ *s, long long start_block,
++ int length);
++extern struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode, unsigned int inode_number);
++extern const struct address_space_operations squashfs_symlink_aops;
++extern const struct address_space_operations squashfs_aops;
++extern const struct address_space_operations squashfs_aops_4K;
++extern struct inode_operations squashfs_dir_inode_ops;
++#else
++#define SQSH_EXTERN static
++#endif
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++extern int squashfs_1_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_1_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++extern int squashfs_2_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
+diff -rduNp linux-2.6.22.1.oorig/fs/squashfs/squashfs2_0.c linux-2.6.22.1/fs/squashfs/squashfs2_0.c
+--- linux-2.6.22.1.oorig/fs/squashfs/squashfs2_0.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/fs/squashfs/squashfs2_0.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,742 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs2_0.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++
++#include "squashfs.h"
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir);
++static struct dentry *squashfs_lookup_2(struct inode *, struct dentry *,
++ struct nameidata *);
++
++static struct file_operations squashfs_dir_ops_2 = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir_2
++};
++
++static struct inode_operations squashfs_dir_inode_ops_2 = {
++ .lookup = squashfs_lookup_2
++};
++
++static unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static int read_fragment_index_table_2(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ if (!(msblk->fragment_index_2 = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments), GFP_KERNEL))) {
++ ERROR("Failed to allocate uid/gid table\n");
++ return 0;
++ }
++
++ if (SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments) &&
++ !squashfs_read_data(s, (char *)
++ msblk->fragment_index_2,
++ sblk->fragment_table_start,
++ SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments))) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ unsigned int fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES_2(sblk->fragments);
++ i++) {
++ SQUASHFS_SWAP_FRAGMENT_INDEXES_2((&fragment),
++ &msblk->fragment_index_2[i], 1);
++ msblk->fragment_index_2[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int get_fragment_location_2(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index_2[SQUASHFS_FRAGMENT_INDEX_2(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET_2(fragment);
++ struct squashfs_fragment_entry_2 fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry_2 sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry,
++ start_block, offset,
++ sizeof(sfragment_entry), &start_block,
++ &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY_2(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, (char *) &fragment_entry,
++ start_block, offset,
++ sizeof(fragment_entry), &start_block,
++ &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header_2 *inodeb, unsigned int ino)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ i->i_ino = ino;
++ i->i_mtime.tv_sec = sblk->mkfs_time;
++ i->i_atime.tv_sec = sblk->mkfs_time;
++ i->i_ctime.tv_sec = sblk->mkfs_time;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_nlink = 1;
++ i->i_size = 0;
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static int squashfs_read_inode_2(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int block = SQUASHFS_INODE_BLK(inode) +
++ sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ unsigned int ino = i->i_ino;
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header_2 id, sid;
++ struct squashfs_base_inode_header_2 *inodeb = &id.base,
++ *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_iget\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *) sinodeb, block,
++ offset, sizeof(*sinodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(inodeb, sinodeb,
++ sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, (char *) inodeb, block,
++ offset, sizeof(*inodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb, ino);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ struct squashfs_reg_inode_header_2 *inodep = &id.reg;
++ struct squashfs_reg_inode_header_2 *sinodep = &sid.reg;
++ long long frag_blk;
++ unsigned int frag_size = 0;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location_2(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ if (sblk->block_size > 4096)
++ i->i_data.a_ops = &squashfs_aops;
++ else
++ i->i_data.a_ops = &squashfs_aops_4K;
++
++ TRACE("File inode %x:%x, start_block %x, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header_2 *inodep = &id.dir;
++ struct squashfs_dir_inode_header_2 *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header_2 *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header_2 *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset =
++ next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count =
++ inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Long directory inode %x:%x, start_block %x, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header_2 *inodep =
++ &id.symlink;
++ struct squashfs_symlink_inode_header_2 *sinodep =
++ &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header_2 *inodep = &id.dev;
++ struct squashfs_dev_inode_header_2 *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_mode |= (inodeb->inode_type ==
++ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR :
++ S_IFBLK;
++ init_special_inode(i, i->i_mode,
++ old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%x:%x]\n", block, offset);
++
++failed_read1:
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) &index,
++ index_start, index_offset,
++ sizeof(index), &index_start,
++ &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start,
++ &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ if (!(str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index_2 *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) index,
++ index_start, index_offset,
++ sizeof(struct squashfs_dir_index_2),
++ &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start,
++ index_offset, index->size + 1,
++ &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++failure:
++ return length;
++}
++
++
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++
++ TRACE("Entered squashfs_readdir_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count,
++ file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block, next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block, next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset,
++ dire->size + 1, &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n",
++ (unsigned int) dirent, dire->name,
++ dire->size + 1, (int) file->f_pos,
++ dirh.start_block, dire->offset,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1,
++ file->f_pos, SQUASHFS_MK_VFS_INODE(
++ dirh.start_block, dire->offset),
++ squashfs_filetype_table[dire->type])
++ < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup_2(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++ int sorted = sblk->s_major == 2 && sblk->s_minor >= 1;
++
++ TRACE("Entered squashfs_lookup_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_loop;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_loop;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name,
++ len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block,next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block,next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset, dire->size + 1,
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (sorted && name[0] < dire->name[0])
++ goto exit_loop;
++
++ if ((len == dire->size + 1) && !strncmp(name,
++ dire->name, len)) {
++ squashfs_inode_t ino =
++ SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++ unsigned int inode_number = SQUASHFS_MK_VFS_INODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory "
++ "entry %s, inode %x:%x, %lld\n", name,
++ dirh.start_block, dire->offset, ino);
++
++ inode = squashfs_iget(i->i_sb, ino, inode_number);
++
++ goto exit_loop;
++ }
++ }
++ }
++
++exit_loop:
++ kfree(dire);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_loop;
++}
++
++
++int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode_2;
++ msblk->read_fragment_index_table = read_fragment_index_table_2;
++
++ sblk->bytes_used = sblk->bytes_used_2;
++ sblk->uid_start = sblk->uid_start_2;
++ sblk->guid_start = sblk->guid_start_2;
++ sblk->inode_table_start = sblk->inode_table_start_2;
++ sblk->directory_table_start = sblk->directory_table_start_2;
++ sblk->fragment_table_start = sblk->fragment_table_start_2;
++
++ return 1;
++}
+diff -rduNp linux-2.6.22.1.oorig/include/linux/aufs_type.h linux-2.6.22.1/include/linux/aufs_type.h
+--- linux-2.6.22.1.oorig/include/linux/aufs_type.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/include/linux/aufs_type.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,97 @@
++/*
++ * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/* $Id: aufs_type.h,v 1.55 2007/05/14 03:40:57 sfjro Exp $ */
++
++#include <linux/ioctl.h>
++
++#ifndef __AUFS_TYPE_H__
++#define __AUFS_TYPE_H__
++
++#define AUFS_VERSION "20070514"
++
++/* ---------------------------------------------------------------------- */
++
++#ifdef CONFIG_AUFS_BRANCH_MAX_127
++typedef char aufs_bindex_t;
++#define AUFS_BRANCH_MAX 127
++#else
++typedef short aufs_bindex_t;
++#ifdef CONFIG_AUFS_BRANCH_MAX_511
++#define AUFS_BRANCH_MAX 511
++#elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
++#define AUFS_BRANCH_MAX 1023
++#elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
++#define AUFS_BRANCH_MAX 32767
++#else
++#error unknown CONFIG_AUFS_BRANCH_MAX value
++#endif
++#endif
++
++#define AUFS_NAME "aufs"
++#define AUFS_FSTYPE AUFS_NAME
++
++#define AUFS_ROOT_INO 2
++#define AUFS_FIRST_INO 11
++
++#define AUFS_WH_PFX ".wh."
++#define AUFS_WH_PFX_LEN ((int)sizeof(AUFS_WH_PFX) - 1)
++#define AUFS_XINO_FNAME "." AUFS_NAME ".xino"
++#define AUFS_XINO_DEFPATH "/tmp/" AUFS_XINO_FNAME
++#define AUFS_DIRWH_DEF 3
++#define AUFS_RDCACHE_DEF 10 /* seconds */
++#define AUFS_WKQ_NAME AUFS_NAME "d"
++#define AUFS_NWKQ_DEF 4
++
++#ifdef CONFIG_AUFS_COMPAT
++#define AUFS_DIROPQ_NAME "__dir_opaque"
++#else
++#define AUFS_DIROPQ_NAME AUFS_WH_PFX ".opq" /* whiteouted doubly */
++#endif
++#define AUFS_WH_DIROPQ AUFS_WH_PFX AUFS_DIROPQ_NAME
++
++/* will be whiteouted doubly */
++#define AUFS_WH_BASENAME AUFS_WH_PFX AUFS_NAME
++#define AUFS_WH_PLINKDIR AUFS_WH_PFX "plink"
++
++/* ---------------------------------------------------------------------- */
++
++/* ioctl */
++enum {AuCtlErr, AuCtlErr_Last};
++enum {
++ AuCtl_REFRESH, //AuCtl_REFRESHV,
++ //AuCtl_FLUSH_PLINK,
++ //AuCtl_CPUP,
++ AuCtl_CPDOWN, AuCtl_MVDOWN
++};
++
++struct aufs_ctl_cp {
++ int bsrc, bdst;
++ int err;
++};
++
++#define Type 'A'
++#define AUFS_CTL_REFRESH _IO(Type, AuCtl_REFRESH)
++//#define AUFS_CTL_REFRESHV _IO(Type, AuCtl_REFRESHV)
++//#define AUFS_CTL_FLUSH_PLINK _IOR(Type, AuCtl_FLUSH_PLINK)
++//#define AUFS_CTL_CPUP _IOWR(Type, AuCtl_CPUP, struct aufs_ctl_cp)
++#define AUFS_CTL_CPDOWN _IOWR(Type, AuCtl_CPDOWN, struct aufs_ctl_cp)
++#define AUFS_CTL_MVDOWN _IOWR(Type, AuCtl_MVDOWN, struct aufs_ctl_cp)
++#undef Type
++
++#endif /* __AUFS_TYPE_H__ */
+diff -rduNp linux-2.6.22.1.oorig/include/linux/squashfs_fs.h linux-2.6.22.1/include/linux/squashfs_fs.h
+--- linux-2.6.22.1.oorig/include/linux/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/include/linux/squashfs_fs.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,934 @@
++#ifndef SQUASHFS_FS
++#define SQUASHFS_FS
++
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs.h
++ */
++
++#ifndef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#define CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#endif
++
++#ifdef CONFIG_SQUASHFS_VMALLOC
++#define SQUASHFS_ALLOC(a) vmalloc(a)
++#define SQUASHFS_FREE(a) vfree(a)
++#else
++#define SQUASHFS_ALLOC(a) kmalloc(a, GFP_KERNEL)
++#define SQUASHFS_FREE(a) kfree(a)
++#endif
++#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
++#define SQUASHFS_MAJOR 3
++#define SQUASHFS_MINOR 0
++#define SQUASHFS_MAGIC 0x73717368
++#define SQUASHFS_MAGIC_SWAP 0x68737173
++#define SQUASHFS_START 0
++
++/* size of metadata (inode and directory) blocks */
++#define SQUASHFS_METADATA_SIZE 8192
++#define SQUASHFS_METADATA_LOG 13
++
++/* default size of data blocks */
++#define SQUASHFS_FILE_SIZE 65536
++#define SQUASHFS_FILE_LOG 16
++
++#define SQUASHFS_FILE_MAX_SIZE 65536
++
++/* Max number of uids and gids */
++#define SQUASHFS_UIDS 256
++#define SQUASHFS_GUIDS 255
++
++/* Max length of filename (not 255) */
++#define SQUASHFS_NAME_LEN 256
++
++#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
++#define SQUASHFS_INVALID_FRAG ((unsigned int) 0xffffffff)
++#define SQUASHFS_INVALID_BLK ((long long) -1)
++#define SQUASHFS_USED_BLK ((long long) -2)
++
++/* Filesystem flags */
++#define SQUASHFS_NOI 0
++#define SQUASHFS_NOD 1
++#define SQUASHFS_CHECK 2
++#define SQUASHFS_NOF 3
++#define SQUASHFS_NO_FRAG 4
++#define SQUASHFS_ALWAYS_FRAG 5
++#define SQUASHFS_DUPLICATE 6
++#define SQUASHFS_EXPORT 7
++
++#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
++
++#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOI)
++
++#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOD)
++
++#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOF)
++
++#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NO_FRAG)
++
++#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_ALWAYS_FRAG)
++
++#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_DUPLICATE)
++
++#define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_EXPORT)
++
++#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_CHECK)
++
++#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, \
++ duplicate_checking, exortable) (noi | (nod << 1) | (check_data << 2) \
++ | (nof << 3) | (no_frag << 4) | (always_frag << 5) | \
++ (duplicate_checking << 6) | (exportable << 7))
++
++/* Max number of types and file types */
++#define SQUASHFS_DIR_TYPE 1
++#define SQUASHFS_FILE_TYPE 2
++#define SQUASHFS_SYMLINK_TYPE 3
++#define SQUASHFS_BLKDEV_TYPE 4
++#define SQUASHFS_CHRDEV_TYPE 5
++#define SQUASHFS_FIFO_TYPE 6
++#define SQUASHFS_SOCKET_TYPE 7
++#define SQUASHFS_LDIR_TYPE 8
++#define SQUASHFS_LREG_TYPE 9
++
++/* 1.0 filesystem type definitions */
++#define SQUASHFS_TYPES 5
++#define SQUASHFS_IPC_TYPE 0
++
++/* Flag whether block is compressed or uncompressed, bit is set if block is
++ * uncompressed */
++#define SQUASHFS_COMPRESSED_BIT (1 << 15)
++
++#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
++ (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
++
++#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
++
++#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
++
++#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & \
++ ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? (B) & \
++ ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
++
++#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
++
++/*
++ * Inode number ops. Inodes consist of a compressed block number, and an
++ * uncompressed offset within that block
++ */
++#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
++
++#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
++
++#define SQUASHFS_MKINODE(A, B) ((squashfs_inode_t)(((squashfs_inode_t) (A)\
++ << 16) + (B)))
++
++/* Compute 32 bit VFS inode number from squashfs inode number */
++#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + \
++ ((b) >> 2) + 1))
++/* XXX */
++
++/* Translate between VFS mode and squashfs mode */
++#define SQUASHFS_MODE(a) ((a) & 0xfff)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES(A) ((A) * sizeof(struct squashfs_fragment_entry))
++
++#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\
++ sizeof(long long))
++
++/* inode lookup table defines */
++#define SQUASHFS_LOOKUP_BYTES(A) ((A) * sizeof(squashfs_inode_t))
++
++#define SQUASHFS_LOOKUP_BLOCK(A) (SQUASHFS_LOOKUP_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_OFFSET(A) (SQUASHFS_LOOKUP_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCKS(A) ((SQUASHFS_LOOKUP_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_BYTES(A) (SQUASHFS_LOOKUP_BLOCKS(A) *\
++ sizeof(long long))
++
++/* cached data constants for filesystem */
++#define SQUASHFS_CACHED_BLKS 8
++
++#define SQUASHFS_MAX_FILE_SIZE_LOG 64
++
++#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << \
++ (SQUASHFS_MAX_FILE_SIZE_LOG - 2))
++
++#define SQUASHFS_MARKER_BYTE 0xff
++
++/* meta index cache */
++#define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int))
++#define SQUASHFS_META_ENTRIES 31
++#define SQUASHFS_META_NUMBER 8
++#define SQUASHFS_SLOTS 4
++
++struct meta_entry {
++ long long data_block;
++ unsigned int index_block;
++ unsigned short offset;
++ unsigned short pad;
++};
++
++struct meta_index {
++ unsigned int inode_number;
++ unsigned int offset;
++ unsigned short entries;
++ unsigned short skip;
++ unsigned short locked;
++ unsigned short pad;
++ struct meta_entry meta_entry[SQUASHFS_META_ENTRIES];
++};
++
++
++/*
++ * definitions for structures on disk
++ */
++
++typedef long long squashfs_block_t;
++typedef long long squashfs_inode_t;
++
++struct squashfs_super_block {
++ unsigned int s_magic;
++ unsigned int inodes;
++ unsigned int bytes_used_2;
++ unsigned int uid_start_2;
++ unsigned int guid_start_2;
++ unsigned int inode_table_start_2;
++ unsigned int directory_table_start_2;
++ unsigned int s_major:16;
++ unsigned int s_minor:16;
++ unsigned int block_size_1:16;
++ unsigned int block_log:16;
++ unsigned int flags:8;
++ unsigned int no_uids:8;
++ unsigned int no_guids:8;
++ unsigned int mkfs_time /* time of filesystem creation */;
++ squashfs_inode_t root_inode;
++ unsigned int block_size;
++ unsigned int fragments;
++ unsigned int fragment_table_start_2;
++ long long bytes_used;
++ long long uid_start;
++ long long guid_start;
++ long long inode_table_start;
++ long long directory_table_start;
++ long long fragment_table_start;
++ long long lookup_table_start;
++} __attribute__ ((packed));
++
++struct squashfs_dir_index {
++ unsigned int index;
++ unsigned int start_block;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++#define SQUASHFS_BASE_INODE_HEADER \
++ unsigned int inode_type:4; \
++ unsigned int mode:12; \
++ unsigned int uid:8; \
++ unsigned int guid:8; \
++ unsigned int mtime; \
++ unsigned int inode_number;
++
++struct squashfs_base_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_lreg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ long long file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int parent_inode;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int i_count:16;
++ unsigned int parent_inode;
++ struct squashfs_dir_index index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header {
++ struct squashfs_base_inode_header base;
++ struct squashfs_dev_inode_header dev;
++ struct squashfs_symlink_inode_header symlink;
++ struct squashfs_reg_inode_header reg;
++ struct squashfs_lreg_inode_header lreg;
++ struct squashfs_dir_inode_header dir;
++ struct squashfs_ldir_inode_header ldir;
++ struct squashfs_ipc_inode_header ipc;
++};
++
++struct squashfs_dir_entry {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ int inode_number:16;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_header {
++ unsigned int count:8;
++ unsigned int start_block;
++ unsigned int inode_number;
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry {
++ long long start_block;
++ unsigned int size;
++ unsigned int pending;
++} __attribute__ ((packed));
++
++extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
++extern int squashfs_uncompress_init(void);
++extern int squashfs_uncompress_exit(void);
++
++/*
++ * macros to convert each packed bitfield structure from little endian to big
++ * endian and vice versa. These are needed when creating or using a filesystem
++ * on a machine with different byte ordering to the target architecture.
++ *
++ */
++
++#define SQUASHFS_SWAP_START \
++ int bits;\
++ int b_pos;\
++ unsigned long long val;\
++ unsigned char *s;\
++ unsigned char *d;
++
++#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_super_block));\
++ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
++ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
++ SQUASHFS_SWAP((s)->bytes_used_2, d, 64, 32);\
++ SQUASHFS_SWAP((s)->uid_start_2, d, 96, 32);\
++ SQUASHFS_SWAP((s)->guid_start_2, d, 128, 32);\
++ SQUASHFS_SWAP((s)->inode_table_start_2, d, 160, 32);\
++ SQUASHFS_SWAP((s)->directory_table_start_2, d, 192, 32);\
++ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
++ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
++ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
++ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
++ SQUASHFS_SWAP((s)->flags, d, 288, 8);\
++ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
++ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
++ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
++ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
++ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
++ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
++ SQUASHFS_SWAP((s)->fragment_table_start_2, d, 472, 32);\
++ SQUASHFS_SWAP((s)->bytes_used, d, 504, 64);\
++ SQUASHFS_SWAP((s)->uid_start, d, 568, 64);\
++ SQUASHFS_SWAP((s)->guid_start, d, 632, 64);\
++ SQUASHFS_SWAP((s)->inode_table_start, d, 696, 64);\
++ SQUASHFS_SWAP((s)->directory_table_start, d, 760, 64);\
++ SQUASHFS_SWAP((s)->fragment_table_start, d, 824, 64);\
++ SQUASHFS_SWAP((s)->lookup_table_start, d, 888, 64);\
++}
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 64, 32);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ipc_inode_header))\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dev_inode_header)); \
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->rdev, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_symlink_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->symlink_size, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_reg_inode_header));\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 160, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 192, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 224, 32);\
++}
++
++#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_lreg_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 128, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 192, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 224, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 256, 64);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 147, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 160, 32);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 192, 32);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ldir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 155, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 168, 32);\
++ SQUASHFS_SWAP((s)->i_count, d, 200, 16);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 216, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index));\
++ SQUASHFS_SWAP((s)->index, d, 0, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 32, 32);\
++ SQUASHFS_SWAP((s)->size, d, 64, 8);\
++}
++
++#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 40, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++ SQUASHFS_SWAP((s)->inode_number, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 64);\
++ SQUASHFS_SWAP((s)->size, d, 64, 32);\
++}
++
++#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
++
++#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 2);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 16)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
++}
++
++#define SQUASHFS_SWAP_INTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 4);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 32)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
++}
++
++#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 64)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 64);\
++}
++
++#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * bits / 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ bits)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++
++struct squashfs_base_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int type:4;
++ unsigned int offset:4;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n) \
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 4);\
++ SQUASHFS_SWAP((s)->guid, d, 20, 4);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_ipc_inode_header_1));\
++ SQUASHFS_SWAP((s)->type, d, 24, 4);\
++ SQUASHFS_SWAP((s)->offset, d, 28, 4);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dev_inode_header_1));\
++ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_1));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_reg_inode_header_1));\
++ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 88, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dir_inode_header_1));\
++ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 43, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
++}
++
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++
++struct squashfs_dir_index_2 {
++ unsigned int index:27;
++ unsigned int start_block:29;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_base_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++ unsigned int i_count:16;
++ struct squashfs_dir_index_2 index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header_2 {
++ struct squashfs_base_inode_header_2 base;
++ struct squashfs_dev_inode_header_2 dev;
++ struct squashfs_symlink_inode_header_2 symlink;
++ struct squashfs_reg_inode_header_2 reg;
++ struct squashfs_dir_inode_header_2 dir;
++ struct squashfs_ldir_inode_header_2 ldir;
++ struct squashfs_ipc_inode_header_2 ipc;
++};
++
++struct squashfs_dir_header_2 {
++ unsigned int count:8;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_dir_entry_2 {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry_2 {
++ unsigned int start_block;
++ unsigned int size;
++} __attribute__ ((packed));
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_2(s, d) \
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, sizeof(struct squashfs_ipc_inode_header_2))
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dev_inode_header_2)); \
++ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_2));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_reg_inode_header_2));\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
++ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 128, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 160, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 51, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_ldir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 59, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
++ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index_2));\
++ SQUASHFS_SWAP((s)->index, d, 0, 27);\
++ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
++ SQUASHFS_SWAP((s)->size, d, 56, 8);\
++}
++#define SQUASHFS_SWAP_DIR_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header_2));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry_2));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry_2));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
++ SQUASHFS_SWAP((s)->size, d, 32, 32);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES_2(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES_2(A) (A * sizeof(struct squashfs_fragment_entry_2))
++
++#define SQUASHFS_FRAGMENT_INDEX_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES_2(A) ((SQUASHFS_FRAGMENT_BYTES_2(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES_2(A) (SQUASHFS_FRAGMENT_INDEXES_2(A) *\
++ sizeof(int))
++
++#endif
++
++#ifdef __KERNEL__
++
++/*
++ * macros used to swap each structure entry, taking into account
++ * bitfields and different bitfield placing conventions on differing
++ * architectures
++ */
++
++#include <asm/byteorder.h>
++
++#ifdef __BIG_ENDIAN
++ /* convert from little endian to big endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, b_pos)
++#else
++ /* convert from big endian to little endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, 64 - tbits - b_pos)
++#endif
++
++#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
++ b_pos = pos % 8;\
++ val = 0;\
++ s = (unsigned char *)p + (pos / 8);\
++ d = ((unsigned char *) &val) + 7;\
++ for(bits = 0; bits < (tbits + b_pos); bits += 8) \
++ *d-- = *s++;\
++ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
++}
++
++#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);
++
++#endif
++#endif
+diff -rduNp linux-2.6.22.1.oorig/include/linux/squashfs_fs_i.h linux-2.6.22.1/include/linux/squashfs_fs_i.h
+--- linux-2.6.22.1.oorig/include/linux/squashfs_fs_i.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/include/linux/squashfs_fs_i.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,45 @@
++#ifndef SQUASHFS_FS_I
++#define SQUASHFS_FS_I
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_i.h
++ */
++
++struct squashfs_inode_info {
++ long long start_block;
++ unsigned int offset;
++ union {
++ struct {
++ long long fragment_start_block;
++ unsigned int fragment_size;
++ unsigned int fragment_offset;
++ long long block_list_start;
++ } s1;
++ struct {
++ long long directory_index_start;
++ unsigned int directory_index_offset;
++ unsigned int directory_index_count;
++ unsigned int parent_inode;
++ } s2;
++ } u;
++ struct inode vfs_inode;
++};
++#endif
+diff -rduNp linux-2.6.22.1.oorig/include/linux/squashfs_fs_sb.h linux-2.6.22.1/include/linux/squashfs_fs_sb.h
+--- linux-2.6.22.1.oorig/include/linux/squashfs_fs_sb.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/include/linux/squashfs_fs_sb.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,74 @@
++#ifndef SQUASHFS_FS_SB
++#define SQUASHFS_FS_SB
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_sb.h
++ */
++
++#include <linux/squashfs_fs.h>
++
++struct squashfs_cache {
++ long long block;
++ int length;
++ long long next_index;
++ char *data;
++};
++
++struct squashfs_fragment_cache {
++ long long block;
++ int length;
++ unsigned int locked;
++ char *data;
++};
++
++struct squashfs_sb_info {
++ struct squashfs_super_block sblk;
++ int devblksize;
++ int devblksize_log2;
++ int swap;
++ struct squashfs_cache *block_cache;
++ struct squashfs_fragment_cache *fragment;
++ int next_cache;
++ int next_fragment;
++ int next_meta_index;
++ unsigned int *uid;
++ unsigned int *guid;
++ long long *fragment_index;
++ unsigned int *fragment_index_2;
++ char *read_page;
++ struct mutex read_data_mutex;
++ struct mutex read_page_mutex;
++ struct mutex block_cache_mutex;
++ struct mutex fragment_mutex;
++ struct mutex meta_index_mutex;
++ wait_queue_head_t waitq;
++ wait_queue_head_t fragment_wait_queue;
++ struct meta_index *meta_index;
++ z_stream stream;
++ long long *inode_lookup_table;
++ int (*read_inode)(struct inode *i, squashfs_inode_t \
++ inode);
++ long long (*read_blocklist)(struct inode *inode, int \
++ index, int readahead_blks, char *block_list, \
++ unsigned short **block_p, unsigned int *bsize);
++ int (*read_fragment_index_table)(struct super_block *s);
++};
++#endif
+diff -rduNp linux-2.6.22.1.oorig/init/Kconfig linux-2.6.22.1/init/Kconfig
+--- linux-2.6.22.1.oorig/init/Kconfig 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/init/Kconfig 2007-07-24 14:17:46.000000000 +0200
+@@ -246,23 +246,21 @@ config AUDITSYSCALL
+ ensure that INOTIFY is configured.
+
+ config IKCONFIG
+- tristate "Kernel .config support"
++ tristate "Kernel .miniconfig support"
+ ---help---
+- This option enables the complete Linux kernel ".config" file
++ This option enables the mini Linux kernel ".miniconfig" file
+ contents to be saved in the kernel. It provides documentation
+ of which kernel options are used in a running kernel or in an
+- on-disk kernel. This information can be extracted from the kernel
+- image file with the script scripts/extract-ikconfig and used as
+- input to rebuild the current kernel or to build another kernel.
+- It can also be extracted from a running kernel by reading
+- /proc/config.gz if enabled (below).
++ on-disk kernel.
++ It can be extracted from a running kernel by reading
++ /proc/miniconfig.gz if enabled (below).
+
+ config IKCONFIG_PROC
+- bool "Enable access to .config through /proc/config.gz"
++ bool "Enable access to .miniconfig through /proc/miniconfig.gz"
+ depends on IKCONFIG && PROC_FS
+ ---help---
+ This option enables access to the kernel configuration file
+- through /proc/config.gz.
++ through /proc/miniconfig.gz.
+
+ config LOG_BUF_SHIFT
+ int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
+diff -rduNp linux-2.6.22.1.oorig/init/LzmaDecode.c linux-2.6.22.1/init/LzmaDecode.c
+--- linux-2.6.22.1.oorig/init/LzmaDecode.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/init/LzmaDecode.c 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,588 @@
++/*
++ LzmaDecode.c
++ LZMA Decoder (optimized for Speed version)
++
++ LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this Code, expressly permits you to
++ statically or dynamically link your Code (or bind by name) to the
++ interfaces of this file without subjecting your linked Code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#include "LzmaDecode.h"
++
++#ifndef Byte
++#define Byte unsigned char
++#endif
++
++#define kNumTopBits 24
++#define kTopValue ((UInt32)1 << kNumTopBits)
++
++#define kNumBitModelTotalBits 11
++#define kBitModelTotal (1 << kNumBitModelTotalBits)
++#define kNumMoveBits 5
++
++#define RC_READ_BYTE (*Buffer++)
++
++#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
++ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
++
++#ifdef _LZMA_IN_CB
++
++#define RC_TEST { if (Buffer == BufferLim) \
++ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
++ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
++
++#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
++
++#else
++
++#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
++
++#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
++
++#endif
++
++#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
++
++#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
++#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
++#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
++
++#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
++ { UpdateBit0(p); mi <<= 1; A0; } else \
++ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
++
++#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
++
++#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
++ { int i = numLevels; res = 1; \
++ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
++ res -= (1 << numLevels); }
++
++
++#define kNumPosBitsMax 4
++#define kNumPosStatesMax (1 << kNumPosBitsMax)
++
++#define kLenNumLowBits 3
++#define kLenNumLowSymbols (1 << kLenNumLowBits)
++#define kLenNumMidBits 3
++#define kLenNumMidSymbols (1 << kLenNumMidBits)
++#define kLenNumHighBits 8
++#define kLenNumHighSymbols (1 << kLenNumHighBits)
++
++#define LenChoice 0
++#define LenChoice2 (LenChoice + 1)
++#define LenLow (LenChoice2 + 1)
++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
++#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
++
++
++#define kNumStates 12
++#define kNumLitStates 7
++
++#define kStartPosModelIndex 4
++#define kEndPosModelIndex 14
++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
++
++#define kNumPosSlotBits 6
++#define kNumLenToPosStates 4
++
++#define kNumAlignBits 4
++#define kAlignTableSize (1 << kNumAlignBits)
++
++#define kMatchMinLen 2
++
++#define IsMatch 0
++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
++#define IsRepG0 (IsRep + kNumStates)
++#define IsRepG1 (IsRepG0 + kNumStates)
++#define IsRepG2 (IsRepG1 + kNumStates)
++#define IsRep0Long (IsRepG2 + kNumStates)
++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
++#define LenCoder (Align + kAlignTableSize)
++#define RepLenCoder (LenCoder + kNumLenProbs)
++#define Literal (RepLenCoder + kNumLenProbs)
++
++#if Literal != LZMA_BASE_SIZE
++StopCompilingDueBUG
++#endif
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
++{
++ unsigned char prop0;
++ if (size < LZMA_PROPERTIES_SIZE)
++ return LZMA_RESULT_DATA_ERROR;
++ prop0 = propsData[0];
++ if (prop0 >= (9 * 5 * 5))
++ return LZMA_RESULT_DATA_ERROR;
++ {
++ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
++ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
++ propsRes->lc = prop0;
++ /*
++ unsigned char remainder = (unsigned char)(prop0 / 9);
++ propsRes->lc = prop0 % 9;
++ propsRes->pb = remainder / 5;
++ propsRes->lp = remainder % 5;
++ */
++ }
++
++ #ifdef _LZMA_OUT_READ
++ {
++ int i;
++ propsRes->DictionarySize = 0;
++ for (i = 0; i < 4; i++)
++ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
++ if (propsRes->DictionarySize == 0)
++ propsRes->DictionarySize = 1;
++ }
++ #endif
++ return LZMA_RESULT_OK;
++}
++
++#define kLzmaStreamWasFinishedId (-1)
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *InCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
++{
++ CProb *p = vs->Probs;
++ SizeT nowPos = 0;
++ Byte previousByte = 0;
++ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
++ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
++ int lc = vs->Properties.lc;
++
++ #ifdef _LZMA_OUT_READ
++
++ UInt32 Range = vs->Range;
++ UInt32 Code = vs->Code;
++ #ifdef _LZMA_IN_CB
++ const Byte *Buffer = vs->Buffer;
++ const Byte *BufferLim = vs->BufferLim;
++ #else
++ const Byte *Buffer = inStream;
++ const Byte *BufferLim = inStream + inSize;
++ #endif
++ int state = vs->State;
++ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
++ int len = vs->RemainLen;
++ UInt32 globalPos = vs->GlobalPos;
++ UInt32 distanceLimit = vs->DistanceLimit;
++
++ Byte *dictionary = vs->Dictionary;
++ UInt32 dictionarySize = vs->Properties.DictionarySize;
++ UInt32 dictionaryPos = vs->DictionaryPos;
++
++ Byte tempDictionary[4];
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++ if (len == kLzmaStreamWasFinishedId)
++ return LZMA_RESULT_OK;
++
++ if (dictionarySize == 0)
++ {
++ dictionary = tempDictionary;
++ dictionarySize = 1;
++ tempDictionary[0] = vs->TempDictionary[0];
++ }
++
++ if (len == kLzmaNeedInitId)
++ {
++ {
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ UInt32 i;
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ rep0 = rep1 = rep2 = rep3 = 1;
++ state = 0;
++ globalPos = 0;
++ distanceLimit = 0;
++ dictionaryPos = 0;
++ dictionary[dictionarySize - 1] = 0;
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++ }
++ len = 0;
++ }
++ while(len != 0 && nowPos < outSize)
++ {
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ len--;
++ }
++ if (dictionaryPos == 0)
++ previousByte = dictionary[dictionarySize - 1];
++ else
++ previousByte = dictionary[dictionaryPos - 1];
++
++ #else /* if !_LZMA_OUT_READ */
++
++ int state = 0;
++ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
++ int len = 0;
++ const Byte *Buffer;
++ const Byte *BufferLim;
++ UInt32 Range;
++ UInt32 Code;
++
++ #ifndef _LZMA_IN_CB
++ *inSizeProcessed = 0;
++ #endif
++ *outSizeProcessed = 0;
++
++ {
++ UInt32 i;
++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
++ for (i = 0; i < numProbs; i++)
++ p[i] = kBitModelTotal >> 1;
++ }
++
++ #ifdef _LZMA_IN_CB
++ RC_INIT;
++ #else
++ RC_INIT(inStream, inSize);
++ #endif
++
++ #endif /* _LZMA_OUT_READ */
++
++ while(nowPos < outSize)
++ {
++ CProb *prob;
++ UInt32 bound;
++ int posState = (int)(
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & posStateMask);
++
++ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ int symbol = 1;
++ UpdateBit0(prob)
++ prob = p + Literal + (LZMA_LIT_SIZE *
++ (((
++ (nowPos
++ #ifdef _LZMA_OUT_READ
++ + globalPos
++ #endif
++ )
++ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
++
++ if (state >= kNumLitStates)
++ {
++ int matchByte;
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ matchByte = dictionary[pos];
++ #else
++ matchByte = outStream[nowPos - rep0];
++ #endif
++ do
++ {
++ int bit;
++ CProb *probLit;
++ matchByte <<= 1;
++ bit = (matchByte & 0x100);
++ probLit = prob + 0x100 + bit + symbol;
++ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
++ }
++ while (symbol < 0x100);
++ }
++ while (symbol < 0x100)
++ {
++ CProb *probLit = prob + symbol;
++ RC_GET_BIT(probLit, symbol)
++ }
++ previousByte = (Byte)symbol;
++
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #endif
++ if (state < 4) state = 0;
++ else if (state < 10) state -= 3;
++ else state -= 6;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRep + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ rep3 = rep2;
++ rep2 = rep1;
++ rep1 = rep0;
++ state = state < kNumLitStates ? 0 : 3;
++ prob = p + LenCoder;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG0 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
++ IfBit0(prob)
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos;
++ #endif
++ UpdateBit0(prob);
++
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit == 0)
++ #else
++ if (nowPos == 0)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ state = state < kNumLitStates ? 9 : 11;
++ #ifdef _LZMA_OUT_READ
++ pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ outStream[nowPos++] = previousByte;
++ #ifdef _LZMA_OUT_READ
++ if (distanceLimit < dictionarySize)
++ distanceLimit++;
++ #endif
++
++ continue;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ }
++ }
++ else
++ {
++ UInt32 distance;
++ UpdateBit1(prob);
++ prob = p + IsRepG1 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep1;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ prob = p + IsRepG2 + state;
++ IfBit0(prob)
++ {
++ UpdateBit0(prob);
++ distance = rep2;
++ }
++ else
++ {
++ UpdateBit1(prob);
++ distance = rep3;
++ rep3 = rep2;
++ }
++ rep2 = rep1;
++ }
++ rep1 = rep0;
++ rep0 = distance;
++ }
++ state = state < kNumLitStates ? 8 : 11;
++ prob = p + RepLenCoder;
++ }
++ {
++ int numBits, offset;
++ CProb *probLen = prob + LenChoice;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenLow + (posState << kLenNumLowBits);
++ offset = 0;
++ numBits = kLenNumLowBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenChoice2;
++ IfBit0(probLen)
++ {
++ UpdateBit0(probLen);
++ probLen = prob + LenMid + (posState << kLenNumMidBits);
++ offset = kLenNumLowSymbols;
++ numBits = kLenNumMidBits;
++ }
++ else
++ {
++ UpdateBit1(probLen);
++ probLen = prob + LenHigh;
++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
++ numBits = kLenNumHighBits;
++ }
++ }
++ RangeDecoderBitTreeDecode(probLen, numBits, len);
++ len += offset;
++ }
++
++ if (state < 4)
++ {
++ int posSlot;
++ state += kNumLitStates;
++ prob = p + PosSlot +
++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
++ kNumPosSlotBits);
++ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
++ if (posSlot >= kStartPosModelIndex)
++ {
++ int numDirectBits = ((posSlot >> 1) - 1);
++ rep0 = (2 | ((UInt32)posSlot & 1));
++ if (posSlot < kEndPosModelIndex)
++ {
++ rep0 <<= numDirectBits;
++ prob = p + SpecPos + rep0 - posSlot - 1;
++ }
++ else
++ {
++ numDirectBits -= kNumAlignBits;
++ do
++ {
++ RC_NORMALIZE
++ Range >>= 1;
++ rep0 <<= 1;
++ if (Code >= Range)
++ {
++ Code -= Range;
++ rep0 |= 1;
++ }
++ }
++ while (--numDirectBits != 0);
++ prob = p + Align;
++ rep0 <<= kNumAlignBits;
++ numDirectBits = kNumAlignBits;
++ }
++ {
++ int i = 1;
++ int mi = 1;
++ do
++ {
++ CProb *prob3 = prob + mi;
++ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
++ i <<= 1;
++ }
++ while(--numDirectBits != 0);
++ }
++ }
++ else
++ rep0 = posSlot;
++ if (++rep0 == (UInt32)(0))
++ {
++ /* it's for stream version */
++ len = kLzmaStreamWasFinishedId;
++ break;
++ }
++ }
++
++ len += kMatchMinLen;
++ #ifdef _LZMA_OUT_READ
++ if (rep0 > distanceLimit)
++ #else
++ if (rep0 > nowPos)
++ #endif
++ return LZMA_RESULT_DATA_ERROR;
++
++ #ifdef _LZMA_OUT_READ
++ if (dictionarySize - distanceLimit > (UInt32)len)
++ distanceLimit += len;
++ else
++ distanceLimit = dictionarySize;
++ #endif
++
++ do
++ {
++ #ifdef _LZMA_OUT_READ
++ UInt32 pos = dictionaryPos - rep0;
++ if (pos >= dictionarySize)
++ pos += dictionarySize;
++ previousByte = dictionary[pos];
++ dictionary[dictionaryPos] = previousByte;
++ if (++dictionaryPos == dictionarySize)
++ dictionaryPos = 0;
++ #else
++ previousByte = outStream[nowPos - rep0];
++ #endif
++ len--;
++ outStream[nowPos++] = previousByte;
++ }
++ while(len != 0 && nowPos < outSize);
++ }
++ }
++ RC_NORMALIZE;
++
++ #ifdef _LZMA_OUT_READ
++ vs->Range = Range;
++ vs->Code = Code;
++ vs->DictionaryPos = dictionaryPos;
++ vs->GlobalPos = globalPos + (UInt32)nowPos;
++ vs->DistanceLimit = distanceLimit;
++ vs->Reps[0] = rep0;
++ vs->Reps[1] = rep1;
++ vs->Reps[2] = rep2;
++ vs->Reps[3] = rep3;
++ vs->State = state;
++ vs->RemainLen = len;
++ vs->TempDictionary[0] = tempDictionary[0];
++ #endif
++
++ #ifdef _LZMA_IN_CB
++ vs->Buffer = Buffer;
++ vs->BufferLim = BufferLim;
++ #else
++ *inSizeProcessed = (SizeT)(Buffer - inStream);
++ #endif
++ *outSizeProcessed = nowPos;
++ return LZMA_RESULT_OK;
++}
+diff -rduNp linux-2.6.22.1.oorig/init/LzmaDecode.h linux-2.6.22.1/init/LzmaDecode.h
+--- linux-2.6.22.1.oorig/init/LzmaDecode.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/init/LzmaDecode.h 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,131 @@
++/*
++ LzmaDecode.h
++ LZMA Decoder interface
++
++ LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
++ http://www.7-zip.org/
++
++ LZMA SDK is licensed under two licenses:
++ 1) GNU Lesser General Public License (GNU LGPL)
++ 2) Common Public License (CPL)
++ It means that you can select one of these two licenses and
++ follow rules of that license.
++
++ SPECIAL EXCEPTION:
++ Igor Pavlov, as the author of this code, expressly permits you to
++ statically or dynamically link your code (or bind by name) to the
++ interfaces of this file without subjecting your linked code to the
++ terms of the CPL or GNU LGPL. Any modifications or additions
++ to this file, however, are subject to the LGPL or CPL terms.
++*/
++
++#ifndef __LZMADECODE_H
++#define __LZMADECODE_H
++
++/* #define _LZMA_IN_CB */
++/* Use callback for input data */
++
++/* #define _LZMA_OUT_READ */
++/* Use read function for output data */
++
++/* #define _LZMA_PROB32 */
++/* It can increase speed on some 32-bit CPUs,
++ but memory usage will be doubled in that case */
++
++/* #define _LZMA_LOC_OPT */
++/* Enable local speed optimizations inside code */
++
++/* #define _LZMA_SYSTEM_SIZE_T */
++/* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
++
++#ifndef UInt32
++#ifdef _LZMA_UINT32_IS_ULONG
++#define UInt32 unsigned long
++#else
++#define UInt32 unsigned int
++#endif
++#endif
++
++#ifndef SizeT
++#ifdef _LZMA_SYSTEM_SIZE_T
++#include <stddef.h>
++#define SizeT size_t
++#else
++#define SizeT UInt32
++#endif
++#endif
++
++#ifdef _LZMA_PROB32
++#define CProb UInt32
++#else
++#define CProb unsigned short
++#endif
++
++#define LZMA_RESULT_OK 0
++#define LZMA_RESULT_DATA_ERROR 1
++
++#ifdef _LZMA_IN_CB
++typedef struct _ILzmaInCallback
++{
++ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
++} ILzmaInCallback;
++#endif
++
++#define LZMA_BASE_SIZE 1846
++#define LZMA_LIT_SIZE 768
++
++#define LZMA_PROPERTIES_SIZE 5
++
++typedef struct _CLzmaProperties
++{
++ int lc;
++ int lp;
++ int pb;
++ #ifdef _LZMA_OUT_READ
++ UInt32 DictionarySize;
++ #endif
++}CLzmaProperties;
++
++int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
++
++#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
++
++#define kLzmaNeedInitId (-2)
++
++typedef struct _CLzmaDecoderState
++{
++ CLzmaProperties Properties;
++ CProb *Probs;
++
++ #ifdef _LZMA_IN_CB
++ const unsigned char *Buffer;
++ const unsigned char *BufferLim;
++ #endif
++
++ #ifdef _LZMA_OUT_READ
++ unsigned char *Dictionary;
++ UInt32 Range;
++ UInt32 Code;
++ UInt32 DictionaryPos;
++ UInt32 GlobalPos;
++ UInt32 DistanceLimit;
++ UInt32 Reps[4];
++ int State;
++ int RemainLen;
++ unsigned char TempDictionary[4];
++ #endif
++} CLzmaDecoderState;
++
++#ifdef _LZMA_OUT_READ
++#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
++#endif
++
++int LzmaDecode(CLzmaDecoderState *vs,
++ #ifdef _LZMA_IN_CB
++ ILzmaInCallback *inCallback,
++ #else
++ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
++ #endif
++ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
++
++#endif
+diff -rduNp linux-2.6.22.1.oorig/init/do_mounts_rd.c linux-2.6.22.1/init/do_mounts_rd.c
+--- linux-2.6.22.1.oorig/init/do_mounts_rd.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/init/do_mounts_rd.c 2007-07-24 14:17:46.000000000 +0200
+@@ -5,7 +5,9 @@
+ #include <linux/ext2_fs.h>
+ #include <linux/romfs_fs.h>
+ #include <linux/cramfs_fs.h>
++#include <linux/squashfs_fs.h>
+ #include <linux/initrd.h>
++#include <linux/vmalloc.h>
+ #include <linux/string.h>
+
+ #include "do_mounts.h"
+@@ -31,6 +33,9 @@ static int __init ramdisk_start_setup(ch
+ __setup("ramdisk_start=", ramdisk_start_setup);
+
+ static int __init crd_load(int in_fd, int out_fd);
++#ifdef CONFIG_LZMA_INITRD
++static int __init lzma_rd_load(int in_fd, int out_fd);
++#endif
+
+ /*
+ * This routine tries to find a RAM disk image to load, and returns the
+@@ -39,6 +44,7 @@ static int __init crd_load(int in_fd, in
+ * numbers could not be found.
+ *
+ * We currently check for the following magic numbers:
++ * squashfs
+ * minix
+ * ext2
+ * romfs
+@@ -53,6 +59,7 @@ identify_ramdisk_image(int fd, int start
+ struct ext2_super_block *ext2sb;
+ struct romfs_super_block *romfsb;
+ struct cramfs_super *cramfsb;
++ struct squashfs_super_block *squashfsb;
+ int nblocks = -1;
+ unsigned char *buf;
+
+@@ -64,6 +71,7 @@ identify_ramdisk_image(int fd, int start
+ ext2sb = (struct ext2_super_block *) buf;
+ romfsb = (struct romfs_super_block *) buf;
+ cramfsb = (struct cramfs_super *) buf;
++ squashfsb = (struct squashfs_super_block *) buf;
+ memset(buf, 0xe5, size);
+
+ /*
+@@ -82,6 +90,17 @@ identify_ramdisk_image(int fd, int start
+ nblocks = 0;
+ goto done;
+ }
++ /*
++ * handle lzma compressed initrd, returns nblocks=1 as indication
++ */
++ if( buf[0] < 9 * 5 * 5 && buf[9] == 0 && buf[10] == 0 && buf[11] == 0
++ && buf[12] == 0 )
++ {
++ printk( KERN_NOTICE "RAMDISK: LZMA image found at block %d\n",
++ start_block);
++ nblocks = 1; // just a convenient return flag
++ goto done;
++ }
+
+ /* romfs is at block zero too */
+ if (romfsb->word0 == ROMSB_WORD0 &&
+@@ -101,6 +120,18 @@ identify_ramdisk_image(int fd, int start
+ goto done;
+ }
+
++ /* squashfs is at block zero too */
++ if (squashfsb->s_magic == SQUASHFS_MAGIC) {
++ printk(KERN_NOTICE
++ "RAMDISK: squashfs filesystem found at block %d\n",
++ start_block);
++ if (squashfsb->s_major < 3)
++ nblocks = (squashfsb->bytes_used_2+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ else
++ nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ goto done;
++ }
++
+ /*
+ * Read block 1 to test for minix and ext2 superblock
+ */
+@@ -172,7 +203,22 @@ int __init rd_load_image(char *from)
+ #endif
+ goto done;
+ }
+-
++#ifdef CONFIG_LZMA_INITRD
++ /*
++ * handle lzma compressed image
++ */
++ if ( nblocks == 1 )
++ {
++ nblocks = 0;
++ if ( lzma_rd_load(in_fd, out_fd) == 0 )
++ {
++ printk("\nLZMA initrd loaded successfully\n");
++ goto successful_load;
++ }
++ printk(KERN_NOTICE "LZMA initrd is not in the correct format\n");
++ goto done;
++ }
++#endif
+ /*
+ * NOTE NOTE: nblocks is not actually blocks but
+ * the number of kibibytes of data to load into a ramdisk.
+@@ -393,6 +439,134 @@ static void __init error(char *x)
+ unzip_error = 1;
+ }
+
++#ifdef CONFIG_LZMA_INITRD
++#define _LZMA_IN_CB
++#define _LZMA_OUT_READ
++#include "LzmaDecode.h"
++#include "LzmaDecode.c"
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize);
++
++/*
++ * Do the lzma decompression
++ */
++static int __init lzma_rd_load(int in_fd, int out_fd)
++{
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned char* outputbuffer;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++ unsigned int kBlockSize = 0x10000;
++ unsigned int nowPos = 0;
++ unsigned int outsizeProcessed = 0;
++ int res;
++ ILzmaInCallback callback;
++
++ insize = 0; /* valid bytes in inbuf */
++ inptr = 0; /* index of next byte to be processed in inbuf */
++ exit_code = 0;
++ crd_infd = in_fd;
++ inbuf = kmalloc(INBUFSIZ, GFP_KERNEL);
++ if (inbuf == 0)
++ {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma input buffer\n");
++ return -1;
++ }
++
++ callback.Read = read_byte;
++
++ /* lzma args */
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ /* read dictionary size */
++ p = (char*)&state.Properties.DictionarySize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ /* get uncompressedSize */
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ /* skip big file */
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ printk( KERN_NOTICE "RAMDISK: LZMA lc=%d,lp=%d,pb=%d,dictSize=%d,origSize=%d\n",
++ state.Properties.lc, state.Properties.lp, state.Properties.pb, state.Properties.DictionarySize, uncompressedSize);
++ outputbuffer = kmalloc(kBlockSize, GFP_KERNEL);
++ if (outputbuffer == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma output buffer\n");
++ return -1;
++ }
++
++ state.Probs = (CProb*)kmalloc( LzmaGetNumProbs(&state.Properties)*sizeof(CProb), GFP_KERNEL);
++ if ( state.Probs == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma workspace\n");
++ return -1;
++ }
++
++#ifdef CONFIG_LZMA_INITRD_KMALLOC_ONLY
++ state.Dictionary = kmalloc( state.Properties.DictionarySize, GFP_KERNEL);
++#else
++ state.Dictionary = vmalloc( state.Properties.DictionarySize);
++#endif
++ if ( state.Dictionary == 0) {
++ printk(KERN_ERR "RAMDISK: Couldn't allocate lzma dictionary\n");
++ return -1;
++ }
++
++ printk( KERN_NOTICE "LZMA initrd by Ming-Ching Tiew <mctiew@yahoo.com> " );
++
++ LzmaDecoderInit( &state );
++
++ for( nowPos =0; nowPos < uncompressedSize ; )
++ {
++ UInt32 blockSize = uncompressedSize - nowPos;
++ if( blockSize > kBlockSize)
++ blockSize = kBlockSize;
++ res = LzmaDecode( &state, &callback, outputbuffer, blockSize, &outsizeProcessed);
++ if( res != 0 ) {
++ printk( KERN_ERR "RAMDISK: Lzma decode failure\n");
++ return -1;
++ }
++ if( outsizeProcessed == 0 )
++ {
++ uncompressedSize = nowPos;
++ printk( KERN_NOTICE "RAMDISK nowPos=%d, uncompressedSize=%d\n",
++ nowPos, uncompressedSize );
++ break;
++ }
++ sys_write(out_fd, outputbuffer, outsizeProcessed );
++ nowPos += outsizeProcessed;
++ printk( ".");
++ }
++
++#ifdef CONFIG_LZMA_INITRD_KMALLOC_ONLY
++ kfree(state.Dictionary);
++#else
++ vfree(state.Dictionary);
++#endif
++ kfree(inbuf);
++ kfree(outputbuffer);
++ kfree(state.Probs);
++ return 0;
++}
++
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++#endif /*CONFIG_LZMA_INITRD*/
++
+ static int __init crd_load(int in_fd, int out_fd)
+ {
+ int result;
+diff -rduNp linux-2.6.22.1.oorig/init/initramfs.c linux-2.6.22.1/init/initramfs.c
+--- linux-2.6.22.1.oorig/init/initramfs.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/init/initramfs.c 2007-07-24 14:17:46.000000000 +0200
+@@ -6,6 +6,7 @@
+ #include <linux/delay.h>
+ #include <linux/string.h>
+ #include <linux/syscalls.h>
++#include <linux/vmalloc.h>
+
+ static __initdata char *message;
+ static void __init error(char *x)
+@@ -441,6 +442,118 @@ static void __init flush_window(void)
+ outcnt = 0;
+ }
+
++#ifdef CONFIG_LZMA_INITRAM_FS
++#define _LZMA_IN_CB
++#define _LZMA_OUT_READ
++#include "LzmaDecode.h"
++#ifndef CONFIG_LZMA_INITRD
++ #include "LzmaDecode.c"
++#endif
++static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
++{
++ static unsigned char val;
++ *bufferSize = 1;
++ val = get_byte();
++ *buffer = &val;
++ return LZMA_RESULT_OK;
++}
++
++static int __init lzma_unzip(void)
++{
++ unsigned int i;
++ CLzmaDecoderState state;
++ unsigned char* outputbuffer;
++ unsigned int uncompressedSize = 0;
++ unsigned char* p;
++ unsigned int kBlockSize = 0x10000;
++ unsigned int nowPos = 0;
++ unsigned int outsizeProcessed = 0;
++ int res;
++ ILzmaInCallback callback;
++
++ callback.Read = read_byte;
++
++ // lzma args
++ i = get_byte();
++ state.Properties.lc = i % 9, i = i / 9;
++ state.Properties.lp = i % 5, state.Properties.pb = i / 5;
++
++ // read dictionary size
++ p = (char*)&state.Properties.DictionarySize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // get uncompressedSize
++ p= (char*)&uncompressedSize;
++ for (i = 0; i < 4; i++)
++ *p++ = get_byte();
++
++ // skip big file
++ for (i = 0; i < 4; i++)
++ get_byte();
++
++ printk( KERN_NOTICE "initramfs: LZMA lc=%d,lp=%d,pb=%d,dictSize=%d,origSize=%d\n",
++ state.Properties.lc,state.Properties.lp,state.Properties.pb,state.Properties.DictionarySize, uncompressedSize);
++ outputbuffer = kmalloc(kBlockSize, GFP_KERNEL);
++ if (outputbuffer == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma output buffer\n");
++ return -1;
++ }
++
++ state.Probs = (CProb*) kmalloc( LzmaGetNumProbs(&state.Properties)*sizeof(CProb), GFP_KERNEL);
++ if ( state.Probs == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma workspace\n");
++ return -1;
++ }
++
++#ifdef CONFIG_LZMA_INITRAM_FS_KMALLOC_ONLY
++ state.Dictionary = kmalloc( state.Properties.DictionarySize, GFP_KERNEL);
++#else
++ state.Dictionary = vmalloc( state.Properties.DictionarySize);
++#endif
++ if ( state.Dictionary == 0) {
++ printk(KERN_ERR "initramfs: Couldn't allocate lzma dictionary\n");
++ return -1;
++ }
++
++ printk( KERN_NOTICE "LZMA initramfs by Ming-Ching Tiew <mctiew@yahoo.com> " );
++
++ LzmaDecoderInit( &state );
++
++ for( nowPos =0; nowPos < uncompressedSize ; )
++ {
++ UInt32 blockSize = uncompressedSize - nowPos;
++ if( blockSize > kBlockSize)
++ blockSize = kBlockSize;
++ res = LzmaDecode( &state, &callback, outputbuffer, blockSize, &outsizeProcessed);
++ if( res != 0 ) {
++ panic( KERN_ERR "initramfs: Lzma decode failure\n");
++ return -1;
++ }
++ if( outsizeProcessed == 0 )
++ {
++ uncompressedSize = nowPos;
++ printk( KERN_NOTICE "initramfs: nowPos=%d, uncompressedSize=%d\n",
++ nowPos, uncompressedSize );
++ break;
++ }
++ flush_buffer(outputbuffer, outsizeProcessed);
++ nowPos += outsizeProcessed;
++ printk( ".");
++ }
++
++#ifdef CONFIG_LZMA_INITRAM_FS_KMALLOC_ONLY
++ kfree(state.Dictionary);
++#else
++ vfree(state.Dictionary);
++#endif
++ kfree(outputbuffer);
++ kfree(state.Probs);
++ return 0;
++}
++
++#endif /*CONFIG LZMA_INITRAM_FS*/
++
+ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
+ {
+ int written;
+@@ -475,12 +588,31 @@ static char * __init unpack_to_rootfs(ch
+ inptr = 0;
+ outcnt = 0; /* bytes in output buffer */
+ bytes_out = 0;
+- crc = (ulg)0xffffffffL; /* shift register contents */
+- makecrc();
+- gunzip();
+- if (state != Reset)
++ if( inbuf[0] == 037 && ((inbuf[1] == 0213) || (inbuf[1] == 0236)))
++ {
++ printk( KERN_NOTICE "detected gzip initramfs\n");
++ crc = (ulg)0xffffffffL; /* shift register contents */
++ makecrc();
++ gunzip();
++ if (state != Reset)
+ error("junk in gzipped archive");
+- this_header = saved_offset + inptr;
++ }
++#ifdef CONFIG_LZMA_INITRAM_FS
++ else if( inbuf[0] < 9 * 5 * 5 && buf[9] == 0 && buf[10] == 0
++ && buf[11] == 0 && buf[12] == 0 )
++ {
++ printk( KERN_NOTICE "detected lzma initramfs\n");
++ lzma_unzip();
++ }
++#endif
++ else
++ {
++ // skip forward ?
++ crc = (ulg)0xffffffffL; /* shift register contents */
++ makecrc();
++ gunzip();
++ }
++ this_header = saved_offset + inptr;
+ buf += inptr;
+ len -= inptr;
+ }
+diff -rduNp linux-2.6.22.1.oorig/kernel/Makefile linux-2.6.22.1/kernel/Makefile
+--- linux-2.6.22.1.oorig/kernel/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/kernel/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -66,7 +66,7 @@ $(obj)/configs.o: $(obj)/config_data.h
+ # config_data.h contains the same information as ikconfig.h but gzipped.
+ # Info from config_data can be extracted from /proc/config*
+ targets += config_data.gz
+-$(obj)/config_data.gz: .config FORCE
++$(obj)/config_data.gz: .miniconfig FORCE
+ $(call if_changed,gzip)
+
+ quiet_cmd_ikconfiggz = IKCFG $@
+diff -rduNp linux-2.6.22.1.oorig/kernel/configs.c linux-2.6.22.1/kernel/configs.c
+--- linux-2.6.22.1.oorig/kernel/configs.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/kernel/configs.c 2007-07-24 14:17:46.000000000 +0200
+@@ -79,7 +79,7 @@ static int __init ikconfig_init(void)
+ struct proc_dir_entry *entry;
+
+ /* create the current config file */
+- entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO,
++ entry = create_proc_entry("miniconfig.gz", S_IFREG | S_IRUGO,
+ &proc_root);
+ if (!entry)
+ return -ENOMEM;
+@@ -95,7 +95,7 @@ static int __init ikconfig_init(void)
+
+ static void __exit ikconfig_cleanup(void)
+ {
+- remove_proc_entry("config.gz", &proc_root);
++ remove_proc_entry("miniconfig.gz", &proc_root);
+ }
+
+ module_init(ikconfig_init);
+diff -rduNp linux-2.6.22.1.oorig/kernel/time/clocksource.c linux-2.6.22.1/kernel/time/clocksource.c
+--- linux-2.6.22.1.oorig/kernel/time/clocksource.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/kernel/time/clocksource.c 2007-07-24 14:17:46.000000000 +0200
+@@ -87,8 +87,8 @@ static void clocksource_ratewd(struct cl
+ if (delta > -WATCHDOG_THRESHOLD && delta < WATCHDOG_THRESHOLD)
+ return;
+
+- printk(KERN_WARNING "Clocksource %s unstable (delta = %Ld ns)\n",
+- cs->name, delta);
++/* printk(KERN_WARNING "Clocksource %s unstable (delta = %Ld ns)\n",
++ cs->name, delta); */
+ cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
+ clocksource_change_rating(cs, 0);
+ cs->flags &= ~CLOCK_SOURCE_WATCHDOG;
+diff -rduNp linux-2.6.22.1.oorig/miniconfig.sh linux-2.6.22.1/miniconfig.sh
+--- linux-2.6.22.1.oorig/miniconfig.sh 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/miniconfig.sh 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,2 @@
++#!/bin/sh -f
++make allnoconfig KCONFIG_ALLCONFIG=.miniconfig
+diff -rduNp linux-2.6.22.1.oorig/scripts/Makefile.lib linux-2.6.22.1/scripts/Makefile.lib
+--- linux-2.6.22.1.oorig/scripts/Makefile.lib 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/scripts/Makefile.lib 2007-07-24 14:17:46.000000000 +0200
+@@ -162,4 +162,9 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS)
+ quiet_cmd_gzip = GZIP $@
+ cmd_gzip = gzip -f -9 < $< > $@
+
++# LZMA
++#
++quiet_cmd_lzma = LZMA $@
++cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++
+
+diff -rduNp linux-2.6.22.1.oorig/scripts/gen_lzma_initramfs_list.sh linux-2.6.22.1/scripts/gen_lzma_initramfs_list.sh
+--- linux-2.6.22.1.oorig/scripts/gen_lzma_initramfs_list.sh 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/scripts/gen_lzma_initramfs_list.sh 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,292 @@
++#!/bin/bash
++# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
++# Copyright (c) 2006 Sam Ravnborg <sam@ravnborg.org>
++#
++# Released under the terms of the GNU GPL
++#
++# Generate a cpio packed initramfs. It uses gen_init_cpio to generate
++# the cpio archive, and gzip to pack it.
++# The script may also be used to generate the inputfile used for gen_init_cpio
++# This script assumes that gen_init_cpio is located in usr/ directory
++
++# error out on errors
++set -e
++
++usage() {
++cat << EOF
++Usage:
++$0 [-o <file>] [-u <uid>] [-g <gid>] { -s | -d | <cpio_source>} ...
++ -o <file> Create lzma initramfs file named <file> using
++ gen_init_cpio and lzma
++ -u <uid> User ID to map to user ID 0 (root).
++ <uid> is only meaningful if <cpio_source>
++ is a directory.
++ -g <gid> Group ID to map to group ID 0 (root).
++ <gid> is only meaningful if <cpio_source>
++ is a directory.
++ <cpio_source> File list or directory for cpio archive.
++ If <cpio_source> is a .cpio file it will be used
++ as direct input to initramfs.
++ -s Create lzma file with small dictionary size
++ -d Output the default cpio list.
++
++All options except -o and -l may be repeated and are interpreted
++sequentially and immediately. -u and -g states are preserved across
++<cpio_source> options so an explicit "-u 0 -g 0" is required
++to reset the root/group mapping.
++EOF
++}
++
++list_default_initramfs() {
++ # echo usr/kinit/kinit
++ :
++}
++
++default_initramfs() {
++ cat <<-EOF >> ${output}
++ # This is a very simple, default initramfs
++
++ dir /dev 0755 0 0
++ nod /dev/console 0600 0 0 c 5 1
++ dir /root 0700 0 0
++ # file /kinit usr/kinit/kinit 0755 0 0
++ # slink /init kinit 0755 0 0
++ EOF
++}
++
++filetype() {
++ local argv1="$1"
++
++ # symlink test must come before file test
++ if [ -L "${argv1}" ]; then
++ echo "slink"
++ elif [ -f "${argv1}" ]; then
++ echo "file"
++ elif [ -d "${argv1}" ]; then
++ echo "dir"
++ elif [ -b "${argv1}" -o -c "${argv1}" ]; then
++ echo "nod"
++ elif [ -p "${argv1}" ]; then
++ echo "pipe"
++ elif [ -S "${argv1}" ]; then
++ echo "sock"
++ else
++ echo "invalid"
++ fi
++ return 0
++}
++
++list_print_mtime() {
++ :
++}
++
++print_mtime() {
++ local my_mtime="0"
++
++ if [ -e "$1" ]; then
++ my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1)
++ fi
++
++ echo "# Last modified: ${my_mtime}" >> ${output}
++ echo "" >> ${output}
++}
++
++list_parse() {
++ echo "$1 \\"
++}
++
++# for each file print a line in following format
++# <filetype> <name> <path to file> <octal mode> <uid> <gid>
++# for links, devices etc the format differs. See gen_init_cpio for details
++parse() {
++ local location="$1"
++ local name="${location/${srcdir}//}"
++ # change '//' into '/'
++ name="${name//\/\///}"
++ local mode="$2"
++ local uid="$3"
++ local gid="$4"
++ local ftype=$(filetype "${location}")
++ # remap uid/gid to 0 if necessary
++ [ "$uid" -eq "$root_uid" ] && uid=0
++ [ "$gid" -eq "$root_gid" ] && gid=0
++ local str="${mode} ${uid} ${gid}"
++
++ [ "${ftype}" == "invalid" ] && return 0
++ [ "${location}" == "${srcdir}" ] && return 0
++
++ case "${ftype}" in
++ "file")
++ str="${ftype} ${name} ${location} ${str}"
++ ;;
++ "nod")
++ local dev_type=
++ local maj=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{sub(/,/, "", $5); print $5}')
++ local min=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{print $6}')
++
++ if [ -b "${location}" ]; then
++ dev_type="b"
++ else
++ dev_type="c"
++ fi
++ str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
++ ;;
++ "slink")
++ local target=$(LC_ALL=C ls -l "${location}" | \
++ gawk '{print $11}')
++ str="${ftype} ${name} ${target} ${str}"
++ ;;
++ *)
++ str="${ftype} ${name} ${str}"
++ ;;
++ esac
++
++ echo "${str}" >> ${output}
++
++ return 0
++}
++
++unknown_option() {
++ printf "ERROR: unknown option \"$arg\"\n" >&2
++ printf "If the filename validly begins with '-', " >&2
++ printf "then it must be prefixed\n" >&2
++ printf "by './' so that it won't be interpreted as an option." >&2
++ printf "\n" >&2
++ usage >&2
++ exit 1
++}
++
++list_header() {
++ :
++}
++
++header() {
++ printf "\n#####################\n# $1\n" >> ${output}
++}
++
++# process one directory (incl sub-directories)
++dir_filelist() {
++ ${dep_list}header "$1"
++
++ srcdir=$(echo "$1" | sed -e 's://*:/:g')
++ dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
++
++ # If $dirlist is only one line, then the directory is empty
++ if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
++ ${dep_list}print_mtime "$1"
++
++ echo "${dirlist}" | \
++ while read x; do
++ ${dep_list}parse ${x}
++ done
++ fi
++}
++
++# if only one file is specified and it is .cpio file then use it direct as fs
++# if a directory is specified then add all files in given direcotry to fs
++# if a regular file is specified assume it is in gen_initramfs format
++input_file() {
++ source="$1"
++ if [ -f "$1" ]; then
++ ${dep_list}header "$1"
++ is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')"
++ if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
++ cpio_file=$1
++ [ ! -z ${dep_list} ] && echo "$1"
++ return 0
++ fi
++ if [ -z ${dep_list} ]; then
++ print_mtime "$1" >> ${output}
++ cat "$1" >> ${output}
++ else
++ cat "$1" | while read type dir file perm ; do
++ if [ "$type" == "file" ]; then
++ echo "$file \\";
++ fi
++ done
++ fi
++ elif [ -d "$1" ]; then
++ dir_filelist "$1"
++ else
++ echo " ${prog}: Cannot open '$1'" >&2
++ exit 1
++ fi
++}
++
++prog=$0
++root_uid=0
++root_gid=0
++dep_list=
++cpio_file=
++cpio_list=
++output="/dev/stdout"
++output_file=""
++opt=""
++
++arg="$1"
++case "$arg" in
++ "-l") # files included in initramfs - used by kbuild
++ dep_list="list_"
++ echo "deps_initramfs := \\"
++ shift
++ ;;
++ "-o") # generate lzma-ed cpio image named $1
++ shift
++ output_file="$1"
++ cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
++ output=${cpio_list}
++ shift
++ ;;
++esac
++while [ $# -gt 0 ]; do
++ arg="$1"
++ shift
++ case "$arg" in
++ "-u") # map $1 to uid=0 (root)
++ root_uid="$1"
++ shift
++ ;;
++ "-g") # map $1 to gid=0 (root)
++ root_gid="$1"
++ shift
++ ;;
++ "-s")
++ opt="-d16"
++ ;;
++ "-d") # display default initramfs list
++ default_list="$arg"
++ ${dep_list}default_initramfs
++ ;;
++ "-h")
++ usage
++ exit 0
++ ;;
++ *)
++ case "$arg" in
++ "-"*)
++ unknown_option
++ ;;
++ *) # input file/dir - process it
++ input_file "$arg" "$#"
++ ;;
++ esac
++ ;;
++ esac
++done
++
++# If output_file is set we will generate cpio archive and lzma it
++# we are carefull to delete tmp files
++if [ ! -z ${output_file} ]; then
++ if [ -z ${cpio_file} ]; then
++ cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)"
++ usr/gen_init_cpio ${cpio_list} > ${cpio_tfile}
++ else
++ cpio_tfile=${cpio_file}
++ fi
++ rm ${cpio_list}
++ lzma e ${cpio_tfile} ${output_file} ${opt}
++ [ -z ${cpio_file} ] && rm ${cpio_tfile}
++fi
++exit 0
+diff -rduNp linux-2.6.22.1.oorig/shrinkconfig.sh linux-2.6.22.1/shrinkconfig.sh
+--- linux-2.6.22.1.oorig/shrinkconfig.sh 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/shrinkconfig.sh 2007-07-24 14:17:46.000000000 +0200
+@@ -0,0 +1,79 @@
++#! /bin/bash
++
++# shrinkconfig copyright 2006 by Rob Landley <rob@landley.net>
++# Licensed under the GNU General Public License version 2.
++
++if [ $# -ne 1 ]
++then
++ echo "Turns current .config into a miniconfig file."
++ echo "Usage: shrinkconfig mini.config"
++ exit 1
++fi
++
++if [ ! -f .config ]
++then
++ echo "Need a .config file to shrink."
++ exit 1
++fi
++LENGTH=$(wc -l < .config)
++
++OUTPUT="$1"
++cp .config "$OUTPUT"
++if [ $? -ne 0 ]
++then
++ echo "Couldn't create $OUTPUT"
++ exit 1
++fi
++
++# If we get interrupted, clean up the mess
++
++KERNELOUTPUT=""
++
++function cleanup
++{
++ echo
++ echo "Interrupted."
++ [ ! -z "$KERNELOUTPUT" ] && rm -rf "$KERNELOUTPUT"
++ rm "$OUTPUT"
++ exit 1
++}
++
++trap cleanup HUP INT QUIT TERM
++
++# Since the "O=" argument to make doesn't work recursively, we need to jump
++# through a few hoops to avoid overwriting the .config that we're shrinking.
++
++# If we're building out of tree, we'll have absolute paths to source and build
++# directories in the Makefile.
++
++KERNELSRC=$(sed -n -e 's/KERNELSRC[^/]*:=[^/]*//p' Makefile)
++[ -z "$KERNELSRC" ] && KERNELSRC=$(pwd)
++KERNELOUTPUT=`pwd`/.config.minitemp
++
++mkdir -p "$KERNELOUTPUT" || exit 1
++
++echo "Shrinking .config to $OUTPUT..."
++
++for I in $(seq 1 $LENGTH)
++do
++ echo -n -e "\r"$I/$LENGTH lines $(wc -c < "$OUTPUT") bytes
++
++ sed -n "${I}!p" "$OUTPUT" > "$KERNELOUTPUT"/.config.test
++ # Do a config with this file
++ make -C "$KERNELSRC" O="$KERNELOUTPUT" allnoconfig KCONFIG_ALLCONFIG="$KERNELOUTPUT"/.config.test > /dev/null
++
++ # Compare. The date changes, so expect a small difference each time.
++ D=$(diff "$KERNELOUTPUT"/.config .config | wc -l)
++ if [ $D -eq 4 ]
++ then
++ mv "$KERNELOUTPUT"/.config.test "$OUTPUT"
++ LENGTH=$[$LENGTH-1]
++ else
++ I=$[$I + 1]
++ fi
++done
++
++rm -rf "$KERNELOUTPUT"
++
++# One extra echo to preserve status line.
++echo
+diff -rduNp linux-2.6.22.1.oorig/usr/Makefile linux-2.6.22.1/usr/Makefile
+--- linux-2.6.22.1.oorig/usr/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/usr/Makefile 2007-07-24 14:17:46.000000000 +0200
+@@ -19,6 +19,7 @@ $(obj)/initramfs_data.o: $(obj)/initramf
+
+ hostprogs-y := gen_init_cpio
+ initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
++lzma_initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_lzma_initramfs_list.sh
+ ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
+ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
+ ramfs-args := \
+@@ -36,6 +37,14 @@ endif
+ quiet_cmd_initfs = GEN $@
+ cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
+
++ifdef CONFIG_LZMA_INITRAM_FS_SMALLMEM
++quiet_cmd_lzma_initfs = LZRAMFS $@
++ cmd_lzma_initfs = $(lzma_initramfs) -o $@ $(ramfs-args) -s $(ramfs-input)
++else
++quiet_cmd_lzma_initfs = LZRAMFS $@
++ cmd_lzma_initfs = $(lzma_initramfs) -o $@ $(ramfs-args) $(ramfs-input)
++endif
++
+ targets := initramfs_data.cpio.gz
+ # do not try to update files included in initramfs
+ $(deps_initramfs): ;
+@@ -48,5 +57,9 @@ $(deps_initramfs): klibcdirs
+ # 4) arguments to gen_initramfs.sh changes
+ $(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
+ $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
++ifdef CONFIG_LZMA_INITRAM_FS
++ $(call if_changed,lzma_initfs)
++else
+ $(call if_changed,initfs)
++endif
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-002-lzma-vmlinuz.01.patch b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-002-lzma-vmlinuz.01.patch
new file mode 100644
index 0000000000..05361ff9d4
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-002-lzma-vmlinuz.01.patch
@@ -0,0 +1,54 @@
+diff -rdup linux-2.6.21.5.oorig/arch/i386/boot/compressed/Makefile linux-2.6.21.5/arch/i386/boot/compressed/Makefile
+--- linux-2.6.21.5.oorig/arch/i386/boot/compressed/Makefile 2007-07-24 13:08:51.000000000 +0200
++++ linux-2.6.21.5/arch/i386/boot/compressed/Makefile 2007-07-24 14:54:38.000000000 +0200
+@@ -4,7 +4,7 @@
+ # create a compressed vmlinux image from the original vmlinux
+ #
+
+-tragets := head.o lzma_misc.o piggy.o \
++targets := head.o lzma_misc.o piggy.o \
+ vmlinux.bin.all vmlinux.relocs \
+ vmlinux vmlinux.bin vmlinux.bin.gz
+ EXTRA_AFLAGS := -traditional
+diff -rdup linux-2.6.21.5.oorig/scripts/gen_lzma_initramfs_list.sh linux-2.6.21.5/scripts/gen_lzma_initramfs_list.sh
+--- linux-2.6.21.5.oorig/scripts/gen_lzma_initramfs_list.sh 2007-07-24 13:08:51.000000000 +0200
++++ linux-2.6.21.5/scripts/gen_lzma_initramfs_list.sh 2007-07-24 15:12:10.000000000 +0200
+@@ -253,7 +253,7 @@ while [ $# -gt 0 ]; do
+ shift
+ ;;
+ "-s")
+- opt="-d16"
++ #opt="-d16" ? what was that supposed to do?
+ ;;
+ "-d") # display default initramfs list
+ default_list="$arg"
+@@ -286,7 +286,7 @@ if [ ! -z ${output_file} ]; then
+ cpio_tfile=${cpio_file}
+ fi
+ rm ${cpio_list}
+- lzma e ${cpio_tfile} ${output_file} ${opt}
++ lzma -z ${cpio_tfile} ${opt} -c > ${output_file}
+ [ -z ${cpio_file} ] && rm ${cpio_tfile}
+ fi
+ exit 0
+--- linux-2.6.21.5.oorig/arch/i386/boot/compressed/lzma_misc.c 2007-07-24 15:24:44.000000000 +0200
++++ linux-2.6.21.5/arch/i386/boot/compressed/lzma_misc.c 2007-07-24 17:09:40.000000000 +0200
+@@ -241,7 +241,6 @@ static int lzma_unzip(uch* output)
+
+ static int read_byte(void *object, const unsigned char **buffer, SizeT *bufferSize)
+ {
+- static unsigned int i = 0;
+ static unsigned char val;
+ *bufferSize = 1;
+ val = get_byte();
+--- linux-2.6.21.5.oorig/scripts/Makefile.lib 2007-07-24 15:24:44.000000000 +0200
++++ linux-2.6.21.5/scripts/Makefile.lib 2007-07-24 18:03:57.000000000 +0200
+@@ -165,6 +165,7 @@ cmd_gzip = gzip -f -9 < $< > $@
+ # LZMA
+ #
+ quiet_cmd_lzma = LZMA $@
+-cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++#cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
++cmd_lzma = lzma -z $< -c > $@
+
+
diff --git a/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-003-lzma-vmlinuz.patch b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-003-lzma-vmlinuz.patch
new file mode 100644
index 0000000000..8fb7e882d1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/kernel-headers/lzma/linux-2.6.22.1-003-lzma-vmlinuz.patch
@@ -0,0 +1,44 @@
+diff -rdup linux-2.6.22.1.old/scripts/Makefile.lib linux-2.6.22.1/scripts/Makefile.lib
+--- linux-2.6.22.1.old/scripts/Makefile.lib 2007-08-21 16:32:19.000000000 +0200
++++ linux-2.6.22.1/scripts/Makefile.lib 2007-08-21 16:43:20.000000000 +0200
+@@ -166,6 +166,6 @@ cmd_gzip = gzip -f -9 < $< > $@
+ #
+ quiet_cmd_lzma = LZMA $@
+ #cmd_lzma = lzma e $< $@ -lc7 -lp0 -pb0 2>/dev/null
+-cmd_lzma = lzma -z $< -c > $@
++cmd_lzma = $(LZMA) -z $< -c > $@
+
+
+diff -rdup linux-2.6.22.1.old/scripts/gen_lzma_initramfs_list.sh linux-2.6.22.1/scripts/gen_lzma_initramfs_list.sh
+--- linux-2.6.22.1.old/scripts/gen_lzma_initramfs_list.sh 2007-08-21 16:32:19.000000000 +0200
++++ linux-2.6.22.1/scripts/gen_lzma_initramfs_list.sh 2007-08-21 16:42:56.000000000 +0200
+@@ -11,7 +11,7 @@
+
+ # error out on errors
+ set -e
+-
++test "x$LZMA" = "x" && LZMA=lzma
+ usage() {
+ cat << EOF
+ Usage:
+@@ -286,7 +286,7 @@ if [ ! -z ${output_file} ]; then
+ cpio_tfile=${cpio_file}
+ fi
+ rm ${cpio_list}
+- lzma -z ${cpio_tfile} ${opt} -c > ${output_file}
++ $LZMA -z ${cpio_tfile} ${opt} -c > ${output_file}
+ [ -z ${cpio_file} ] && rm ${cpio_tfile}
+ fi
+ exit 0
+diff -rdup linux-2.6.22.1.old/usr/Makefile linux-2.6.22.1/usr/Makefile
+--- linux-2.6.22.1.old/usr/Makefile 2007-08-21 16:32:19.000000000 +0200
++++ linux-2.6.22.1/usr/Makefile 2007-08-21 16:46:22.000000000 +0200
+@@ -19,7 +19,7 @@ $(obj)/initramfs_data.o: $(obj)/initramf
+
+ hostprogs-y := gen_init_cpio
+ initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
+-lzma_initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_lzma_initramfs_list.sh
++lzma_initramfs := LZMA=$(LZMA) $(CONFIG_SHELL) $(srctree)/scripts/gen_lzma_initramfs_list.sh
+ ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
+ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
+ ramfs-args := \
diff --git a/cleopatre/buildroot/toolchain/mklibs/Config.in b/cleopatre/buildroot/toolchain/mklibs/Config.in
new file mode 100644
index 0000000000..2298a3e515
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/mklibs/Config.in
@@ -0,0 +1,5 @@
+config BR2_MKLIBS
+ bool "Run mklibs on the built root filesystem"
+ help
+ Recompiles all the shared libraries to only include the
+ symbols actually needed to run the binaries on the target
diff --git a/cleopatre/buildroot/toolchain/mklibs/mklibs.mk b/cleopatre/buildroot/toolchain/mklibs/mklibs.mk
new file mode 100644
index 0000000000..38fa674170
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/mklibs/mklibs.mk
@@ -0,0 +1,49 @@
+######################################################################
+#
+# mklibs
+#
+######################################################################
+MKLIBS_PROGRAM:=$(STAGING_DIR)/bin/mklibs.py
+
+$(MKLIBS_PROGRAM): toolchain/mklibs/mklibs.py
+ cp -dpf toolchain/mklibs/mklibs.py $@
+
+mklibs-clean:
+ rm -f $(MKLIBS_PROGRAM)
+
+mklibs-dirclean:
+ true
+
+#############################################################
+#
+# Run mklibs
+#
+#############################################################
+MKLIBS_PYTHON:=$(shell which python)
+ifeq ($(MKLIBS_PYTHON),)
+ MKLIBS_PYTHON=/usr/bin/python
+endif
+
+$(STAGING_DIR)/mklibs-stamp: $(MKLIBS_PROGRAM) $(MKLIBS_PYTHON) $(STAGING_DIR)/lib/*
+ find $(TARGET_DIR) -type f -perm +100 -exec \
+ file -r -N -F '' {} + | \
+ awk ' /executable.*dynamically/ { print $$1 }' > $(STAGING_DIR)/mklibs-progs
+ cd $(TARGET_DIR); PATH=$(PATH):$(STAGING_DIR)/bin $(MKLIBS_PYTHON) $(MKLIBS_PROGRAM) \
+ --target $(REAL_GNU_TARGET_NAME) --root $(STAGING_DIR) -d ./ \
+ `cat $(STAGING_DIR)/mklibs-progs`
+ touch $@
+
+# this empty target allows a mklibs dependeny to be included in the
+# target targets, but it will be only invoked if BR2_MKLIBS is conf'ed
+.PHONY: mklibs
+mklibs:
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+
+ifeq ($(strip $(BR2_MKLIBS)),y)
+mklibs: $(STAGING_DIR)/mklibs-stamp
+endif
diff --git a/cleopatre/buildroot/toolchain/mklibs/mklibs.py b/cleopatre/buildroot/toolchain/mklibs/mklibs.py
new file mode 100644
index 0000000000..a84fd42fa2
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/mklibs/mklibs.py
@@ -0,0 +1,597 @@
+#! /usr/bin/python
+
+# mklibs.py: An automated way to create a minimal /lib/ directory.
+#
+# Copyright 2001 by Falk Hueffner <falk@debian.org>
+# & Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de>
+#
+# mklibs.sh by Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>
+# used as template
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# HOW IT WORKS
+#
+# - Gather all unresolved symbols and libraries needed by the programs
+# and reduced libraries
+# - Gather all symbols provided by the already reduced libraries
+# (none on the first pass)
+# - If all symbols are provided we are done
+# - go through all libraries and remember what symbols they provide
+# - go through all unresolved/needed symbols and mark them as used
+# - for each library:
+# - find pic file (if not present copy and strip the so)
+# - compile in only used symbols
+# - strip
+# - back to the top
+
+# TODO
+# * complete argument parsing as given as comment in main
+
+import commands
+import string
+import re
+import sys
+import os
+import glob
+import getopt
+from stat import *
+
+DEBUG_NORMAL = 1
+DEBUG_VERBOSE = 2
+DEBUG_SPAM = 3
+
+debuglevel = DEBUG_NORMAL
+
+def debug(level, *msg):
+ if debuglevel >= level:
+ print string.join(msg)
+
+# A simple set class. It should be replaced with the standard sets.Set
+# type as soon as Python 2.3 is out.
+class Set:
+ def __init__(self):
+ self.__dict = {}
+
+ def add(self, obj):
+ self.__dict[obj] = 1
+
+ def contains(self, obj):
+ return self.__dict.has_key(obj)
+
+ def merge(self, s):
+ for e in s.elems():
+ self.add(e)
+
+ def elems(self):
+ return self.__dict.keys()
+
+ def size(self):
+ return len(self.__dict)
+
+ def __eq__(self, other):
+ return self.__dict == other.__dict
+
+ def __str__(self):
+ return `self.__dict.keys()`
+
+ def __repr__(self):
+ return `self.__dict.keys()`
+
+# return a list of lines of output of the command
+def command(command, *args):
+ debug(DEBUG_SPAM, "calling", command, string.join(args))
+ (status, output) = commands.getstatusoutput(command + ' ' + string.join(args))
+ if os.WEXITSTATUS(status) != 0:
+ print "Command failed with status", os.WEXITSTATUS(status), ":", \
+ command, string.join(args)
+ print "With output:", output
+ sys.exit(1)
+ return string.split(output, '\n')
+
+# Filter a list according to a regexp containing a () group. Return
+# a Set.
+def regexpfilter(list, regexp, groupnr = 1):
+ pattern = re.compile(regexp)
+ result = Set()
+ for x in list:
+ match = pattern.match(x)
+ if match:
+ result.add(match.group(groupnr))
+
+ return result
+
+# Return a Set of rpath strings for the passed object
+def rpath(obj):
+ if not os.access(obj, os.F_OK):
+ raise "Cannot find lib: " + obj
+ output = command(target + "objdump", "--private-headers", obj)
+ return map(lambda x: root + "/" + x, regexpfilter(output, ".*RPATH\s*(\S+)$").elems())
+
+# Return a Set of libraries the passed objects depend on.
+def library_depends(obj):
+ if not os.access(obj, os.F_OK):
+ raise "Cannot find lib: " + obj
+ output = command(target + "objdump", "--private-headers", obj)
+ return regexpfilter(output, ".*NEEDED\s*(\S+)$")
+
+# Return a list of libraries the passed objects depend on. The
+# libraries are in "-lfoo" format suitable for passing to gcc.
+def library_depends_gcc_libnames(obj):
+ if not os.access(obj, os.F_OK):
+ raise "Cannot find lib: " + obj
+ output = command(target + "objdump", "--private-headers", obj)
+ output = regexpfilter(output, ".*NEEDED\s*lib(\S+)\.so.*$")
+ if not output.elems():
+ return ""
+ else:
+ return "-l" + string.join(output.elems(), " -l")
+
+# Scan readelf output. Example:
+# Num: Value Size Type Bind Vis Ndx Name
+# 1: 000000012002ab48 168 FUNC GLOBAL DEFAULT UND strchr@GLIBC_2.0 (2)
+symline_regexp = \
+ re.compile("\s*\d+: .+\s+\d+\s+\w+\s+(\w+)+\s+\w+\s+(\w+)\s+([^\s@]+)")
+
+# Return undefined symbols in an object as a Set of tuples (name, weakness)
+def undefined_symbols(obj):
+ if not os.access(obj, os.F_OK):
+ raise "Cannot find lib" + obj
+
+ result = Set()
+ output = command(target + "readelf", "-s", "-W", obj)
+ for line in output:
+ match = symline_regexp.match(line)
+ if match:
+ bind, ndx, name = match.groups()
+ if ndx == "UND":
+ result.add((name, bind == "WEAK"))
+ return result
+
+# Return a Set of symbols provided by a library
+def provided_symbols(obj):
+ if not os.access(obj, os.F_OK):
+ raise "Cannot find lib" + obj
+
+ result = Set()
+ debug(DEBUG_SPAM, "provided_symbols result = ", `result`)
+ output = command(target + "readelf", "-s", "-W", obj)
+ for line in output:
+ match = symline_regexp.match(line)
+ if match:
+ bind, ndx, name = match.groups()
+ if bind != "LOCAL" and not ndx in ("UND", "ABS"):
+ debug(DEBUG_SPAM, "provided_symbols adding ", `name`)
+ result.add(name)
+ return result
+
+# Return real target of a symlink
+def resolve_link(file):
+ debug(DEBUG_SPAM, "resolving", file)
+ while S_ISLNK(os.lstat(file)[ST_MODE]):
+ new_file = os.readlink(file)
+ if new_file[0] != "/":
+ file = os.path.join(os.path.dirname(file), new_file)
+ else:
+ file = new_file
+ debug(DEBUG_SPAM, "resolved to", file)
+ return file
+
+# Find complete path of a library, by searching in lib_path
+def find_lib(lib):
+ for path in lib_path:
+ if os.access(path + "/" + lib, os.F_OK):
+ return path + "/" + lib
+
+ return ""
+
+# Find a PIC archive for the library
+def find_pic(lib):
+ base_name = so_pattern.match(lib).group(1)
+ for path in lib_path:
+ for file in glob.glob(path + "/" + base_name + "_pic.a"):
+ if os.access(file, os.F_OK):
+ return resolve_link(file)
+ return ""
+
+# Find a PIC .map file for the library
+def find_pic_map(lib):
+ base_name = so_pattern.match(lib).group(1)
+ for path in lib_path:
+ for file in glob.glob(path + "/" + base_name + "_pic.map"):
+ if os.access(file, os.F_OK):
+ return resolve_link(file)
+ return ""
+
+def extract_soname(so_file):
+ soname_data = regexpfilter(command(target + "readelf", "--all", "-W", so_file),
+ ".*SONAME.*\[(.*)\].*")
+ if soname_data.elems():
+ return soname_data.elems()[0]
+
+ return ""
+def usage(was_err):
+ if was_err:
+ outfd = sys.stderr
+ else:
+ outfd = sys.stdout
+ print >> outfd, "Usage: mklibs [OPTION]... -d DEST FILE ..."
+ print >> outfd, "Make a set of minimal libraries for FILE(s) in DEST."
+ print >> outfd, ""
+ print >> outfd, " -d, --dest-dir DIRECTORY create libraries in DIRECTORY"
+ print >> outfd, " -D, --no-default-lib omit default libpath (", string.join(default_lib_path, " : "), ")"
+ print >> outfd, " -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s) to the library search path"
+ print >> outfd, " --ldlib LDLIB use LDLIB for the dynamic linker"
+ print >> outfd, " --libc-extras-dir DIRECTORY look for libc extra files in DIRECTORY"
+ # Ugh... Adding the trailing '-' breaks common practice.
+ #print >> outfd, " --target TARGET prepend TARGET- to the gcc and binutils calls"
+ print >> outfd, " --target TARGET prepend TARGET to the gcc and binutils calls"
+ print >> outfd, " --root ROOT search in ROOT for library rpaths"
+ print >> outfd, " -v, --verbose explain what is being done"
+ print >> outfd, " -h, --help display this help and exit"
+ sys.exit(was_err)
+
+def version(vers):
+ print "mklibs: version ",vers
+ print ""
+
+#################### main ####################
+## Usage: ./mklibs.py [OPTION]... -d DEST FILE ...
+## Make a set of minimal libraries for FILE ... in directory DEST.
+##
+## Options:
+## -L DIRECTORY Add DIRECTORY to library search path.
+## -D, --no-default-lib Do not use default lib directories of /lib:/usr/lib
+## -n, --dry-run Don't actually run any commands; just print them.
+## -v, --verbose Print additional progress information.
+## -V, --version Print the version number and exit.
+## -h, --help Print this help and exit.
+## --ldlib Name of dynamic linker (overwrites environment variable ldlib)
+## --libc-extras-dir Directory for libc extra files
+## --target Use as prefix for gcc or binutils calls
+##
+## -d, --dest-dir DIRECTORY Create libraries in DIRECTORY.
+##
+## Required arguments for long options are also mandatory for the short options.
+
+# Clean the environment
+vers="0.12 with uClibc fixes"
+os.environ['LC_ALL'] = "C"
+
+# Argument parsing
+opts = "L:DnvVhd:r:"
+longopts = ["no-default-lib", "dry-run", "verbose", "version", "help",
+ "dest-dir=", "ldlib=", "libc-extras-dir=", "target=", "root="]
+
+# some global variables
+lib_rpath = []
+lib_path = []
+dest_path = "DEST"
+ldlib = "LDLIB"
+include_default_lib_path = "yes"
+default_lib_path = ["/lib/", "/usr/lib/", "/usr/X11R6/lib/"]
+libc_extras_dir = "/usr/lib/libc_pic"
+target = ""
+root = ""
+so_pattern = re.compile("((lib|ld).*)\.so(\..+)*")
+script_pattern = re.compile("^#!\s*/")
+
+try:
+ optlist, proglist = getopt.getopt(sys.argv[1:], opts, longopts)
+except getopt.GetoptError, msg:
+ print >> sys.stderr, msg
+ usage(1)
+
+for opt, arg in optlist:
+ if opt in ("-v", "--verbose"):
+ if debuglevel < DEBUG_SPAM:
+ debuglevel = debuglevel + 1
+ elif opt == "-L":
+ lib_path.extend(string.split(arg, ":"))
+ elif opt in ("-d", "--dest-dir"):
+ dest_path = arg
+ elif opt in ("-D", "--no-default-lib"):
+ include_default_lib_path = "no"
+ elif opt == "--ldlib":
+ ldlib = arg
+ elif opt == "--libc-extras-dir":
+ libc_extras_dir = arg
+ elif opt == "--target":
+ #target = arg + "-"
+ target = arg
+ elif opt in ("-r", "--root"):
+ root = arg
+ elif opt in ("--help", "-h"):
+ usage(0)
+ sys.exit(0)
+ elif opt in ("--version", "-V"):
+ version(vers)
+ sys.exit(0)
+ else:
+ print "WARNING: unknown option: " + opt + "\targ: " + arg
+
+if include_default_lib_path == "yes":
+ lib_path.extend(default_lib_path)
+
+if ldlib == "LDLIB":
+ ldlib = os.getenv("ldlib")
+
+objects = {} # map from inode to filename
+for prog in proglist:
+ inode = os.stat(prog)[ST_INO]
+ if objects.has_key(inode):
+ debug(DEBUG_SPAM, prog, "is a hardlink to", objects[inode])
+ elif so_pattern.match(prog):
+ debug(DEBUG_SPAM, prog, "is a library")
+ elif script_pattern.match(open(prog).read(256)):
+ debug(DEBUG_SPAM, prog, "is a script")
+ else:
+ objects[inode] = prog
+
+if not ldlib:
+ pattern = re.compile(".*Requesting program interpreter:.*/([^\]/]+).*")
+ for obj in objects.values():
+ output = command(target + "readelf", "--program-headers", obj)
+ for x in output:
+ match = pattern.match(x)
+ if match:
+ ldlib = match.group(1)
+ break
+ if ldlib:
+ break
+
+if not ldlib:
+ sys.exit("E: Dynamic linker not found, aborting.")
+
+debug(DEBUG_NORMAL, "I: Using", ldlib, "as dynamic linker.")
+
+pattern = re.compile(".*ld-uClibc.*");
+if pattern.match(ldlib):
+ uclibc = 1
+else:
+ uclibc = 0
+
+# Check for rpaths
+for obj in objects.values():
+ rpath_val = rpath(obj)
+ if rpath_val:
+ if root:
+ if debuglevel >= DEBUG_VERBOSE:
+ print "Adding rpath " + string.join(rpath_val, ":") + " for " + obj
+ lib_rpath.extend(rpath_val)
+ else:
+ print "warning: " + obj + " may need rpath, but --root not specified"
+
+lib_path.extend(lib_rpath)
+
+passnr = 1
+previous_pass_unresolved = Set()
+while 1:
+ debug(DEBUG_NORMAL, "I: library reduction pass", `passnr`)
+ if debuglevel >= DEBUG_VERBOSE:
+ print "Objects:",
+ for obj in objects.values():
+ print obj[string.rfind(obj, '/') + 1:],
+ print
+
+ passnr = passnr + 1
+ # Gather all already reduced libraries and treat them as objects as well
+ small_libs = []
+ for lib in regexpfilter(os.listdir(dest_path), "(.*-so-stripped)$").elems():
+ obj = dest_path + "/" + lib
+ small_libs.append(obj)
+ inode = os.stat(obj)[ST_INO]
+ if objects.has_key(inode):
+ debug(DEBUG_SPAM, obj, "is hardlink to", objects[inode])
+ else:
+ objects[inode] = obj
+
+ # DEBUG
+ for obj in objects.values():
+ small_libs.append(obj)
+ debug(DEBUG_VERBOSE, "Object:", obj)
+
+ # calculate what symbols and libraries are needed
+ needed_symbols = Set() # Set of (name, weakness-flag)
+ libraries = Set()
+ for obj in objects.values():
+ needed_symbols.merge(undefined_symbols(obj))
+ libraries.merge(library_depends(obj))
+
+ # FIXME: on i386 this is undefined but not marked UND
+ # I don't know how to detect those symbols but this seems
+ # to be the only one and including it on alpha as well
+ # doesn't hurt. I guess all archs can live with this.
+ needed_symbols.add(("sys_siglist", 1))
+
+ # calculate what symbols are present in small_libs
+ present_symbols = Set()
+ for lib in small_libs:
+ present_symbols.merge(provided_symbols(lib))
+
+ # are we finished?
+ using_ctor_dtor = 0
+ num_unresolved = 0
+ present_symbols_elems = present_symbols.elems()
+ unresolved = Set()
+ for (symbol, is_weak) in needed_symbols.elems():
+ if not symbol in present_symbols_elems:
+ debug(DEBUG_SPAM, "Still need:", symbol, `is_weak`)
+ unresolved.add((symbol, is_weak))
+ num_unresolved = num_unresolved + 1
+
+ debug (DEBUG_NORMAL, `needed_symbols.size()`, "symbols,",
+ `num_unresolved`, "unresolved")
+
+ if num_unresolved == 0:
+ break
+
+ if unresolved == previous_pass_unresolved:
+ # No progress in last pass. Verify all remaining symbols are weak.
+ for (symbol, is_weak) in unresolved.elems():
+ if not is_weak:
+ raise "Unresolvable symbol " + symbol
+ break
+
+ previous_pass_unresolved = unresolved
+
+ library_symbols = {}
+ library_symbols_used = {}
+ symbol_provider = {}
+
+ # Calculate all symbols each library provides
+ for library in libraries.elems():
+ path = find_lib(library)
+ if not path:
+ sys.exit("Library not found: " + library + " in path: "
+ + string.join(lib_path, " : "))
+ symbols = provided_symbols(path)
+ library_symbols[library] = Set()
+ library_symbols_used[library] = Set()
+ for symbol in symbols.elems():
+ if symbol_provider.has_key(symbol):
+ # in doubt, prefer symbols from libc
+ if re.match("^libc[\.-]", library):
+ library_symbols[library].add(symbol)
+ symbol_provider[symbol] = library
+ else:
+ debug(DEBUG_SPAM, "duplicate symbol", symbol, "in",
+ symbol_provider[symbol], "and", library)
+ else:
+ library_symbols[library].add(symbol)
+ symbol_provider[symbol] = library
+
+ # Fixup support for constructors and destructors
+ if symbol_provider.has_key("_init"):
+ debug(DEBUG_VERBOSE, library, ": Library has a constructor!");
+ using_ctor_dtor = 1
+ library_symbols[library].add("_init")
+ symbol_provider["_init"] = library
+ library_symbols_used[library].add("_init")
+
+ if symbol_provider.has_key("_fini"):
+ debug(DEBUG_VERBOSE, library, ": Library has a destructor!");
+ using_ctor_dtor = 1
+ library_symbols[library].add("_fini")
+ symbol_provider["_fini"] = library
+ library_symbols_used[library].add("_fini")
+
+ # which symbols are actually used from each lib
+ for (symbol, is_weak) in needed_symbols.elems():
+ if not symbol_provider.has_key(symbol):
+ if not is_weak:
+ if not uclibc or (symbol != "main"):
+ raise "No library provides non-weak " + symbol
+ else:
+ lib = symbol_provider[symbol]
+ library_symbols_used[lib].add(symbol)
+
+ # reduce libraries
+ for library in libraries.elems():
+ debug(DEBUG_VERBOSE, "reducing", library)
+ debug(DEBUG_SPAM, "using: " + string.join(library_symbols_used[library].elems()))
+ so_file = find_lib(library)
+ if root and (re.compile("^" + root).search(so_file)):
+ debug(DEBUG_VERBOSE, "no action required for " + so_file)
+ continue
+ so_file_name = os.path.basename(so_file)
+ if not so_file:
+ sys.exit("File not found:" + library)
+ pic_file = find_pic(library)
+ if not pic_file:
+ # No pic file, so we have to use the .so file, no reduction
+ debug(DEBUG_VERBOSE, "No pic file found for", so_file, "; copying")
+ command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
+ so_file, dest_path + "/" + so_file_name + "-so-stripped")
+ else:
+ # we have a pic file, recompile
+ debug(DEBUG_SPAM, "extracting from:", pic_file, "so_file:", so_file)
+ soname = extract_soname(so_file)
+ if soname == "":
+ debug(DEBUG_VERBOSE, so_file, " has no soname, copying")
+ continue
+ debug(DEBUG_SPAM, "soname:", soname)
+ base_name = so_pattern.match(library).group(1)
+ # libc needs its soinit.o and sofini.o as well as the pic
+ if (base_name == "libc") and not uclibc:
+ # force dso_handle.os to be included, otherwise reduced libc
+ # may segfault in ptmalloc_init due to undefined weak reference
+ extra_flags = find_lib(ldlib) + " -u __dso_handle"
+ extra_pre_obj = libc_extras_dir + "/soinit.o"
+ extra_post_obj = libc_extras_dir + "/sofini.o"
+ else:
+ extra_flags = ""
+ extra_pre_obj = ""
+ extra_post_obj = ""
+ map_file = find_pic_map(library)
+ if map_file:
+ extra_flags = extra_flags + " -Wl,--version-script=" + map_file
+ if library_symbols_used[library].elems():
+ joined_symbols = "-u" + string.join(library_symbols_used[library].elems(), " -u")
+ else:
+ joined_symbols = ""
+ if using_ctor_dtor == 1:
+ extra_flags = extra_flags + " -shared"
+ # compile in only used symbols
+ command(target + "gcc",
+ "-nostdlib -nostartfiles -shared -Wl,-soname=" + soname,\
+ joined_symbols, \
+ "-o", dest_path + "/" + so_file_name + "-so", \
+ extra_pre_obj, \
+ pic_file, \
+ extra_post_obj, \
+ extra_flags, \
+ "-lgcc -L", dest_path, \
+ "-L" + string.join(lib_path, " -L"), \
+ library_depends_gcc_libnames(so_file))
+ # strip result
+ command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
+ dest_path + "/" + so_file_name + "-so",
+ dest_path + "/" + so_file_name + "-so-stripped")
+ ## DEBUG
+ debug(DEBUG_VERBOSE, so_file, "\t", `os.stat(so_file)[ST_SIZE]`)
+ debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so", "\t",
+ `os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE]`)
+ debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so-stripped",
+ "\t", `os.stat(dest_path + "/" + so_file_name + "-so-stripped")[ST_SIZE]`)
+
+# Finalising libs and cleaning up
+for lib in regexpfilter(os.listdir(dest_path), "(.*)-so-stripped$").elems():
+ os.rename(dest_path + "/" + lib + "-so-stripped", dest_path + "/" + lib)
+for lib in regexpfilter(os.listdir(dest_path), "(.*-so)$").elems():
+ os.remove(dest_path + "/" + lib)
+
+# Canonicalize library names.
+for lib in regexpfilter(os.listdir(dest_path), "(.*so[.\d]*)$").elems():
+ this_lib_path = dest_path + "/" + lib
+ if os.path.islink(this_lib_path):
+ debug(DEBUG_VERBOSE, "Unlinking %s." % lib)
+ os.remove(this_lib_path)
+ continue
+ soname = extract_soname(this_lib_path)
+ if soname:
+ debug(DEBUG_VERBOSE, "Moving %s to %s." % (lib, soname))
+ os.rename(dest_path + "/" + lib, dest_path + "/" + soname)
+
+# Make sure the dynamic linker is present and is executable
+ld_file = find_lib(ldlib)
+ld_file_name = os.path.basename(ld_file)
+
+if not os.access(dest_path + "/" + ld_file_name, os.F_OK):
+ debug(DEBUG_NORMAL, "I: stripping and copying dynamic linker.")
+ command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
+ ld_file, dest_path + "/" + ld_file_name)
+
+os.chmod(dest_path + "/" + ld_file_name, 0755)
diff --git a/cleopatre/buildroot/toolchain/patch-kernel.sh b/cleopatre/buildroot/toolchain/patch-kernel.sh
new file mode 100755
index 0000000000..e2e89486d3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/patch-kernel.sh
@@ -0,0 +1,55 @@
+#! /bin/bash
+# A little script I whipped up to make it easy to
+# patch source trees and have sane error handling
+# -Erik
+#
+# (c) 2002 Erik Andersen <andersen@codepoet.org>
+
+# Set directories from arguments, or use defaults.
+targetdir=${1-.}
+patchdir=${2-../kernel-patches}
+shift 2
+patchpattern=${@-*}
+
+if [ ! -d "${targetdir}" ] ; then
+ echo "Aborting. '${targetdir}' is not a directory."
+ exit 1
+fi
+if [ ! -d "${patchdir}" ] ; then
+ echo "Aborting. '${patchdir}' is not a directory."
+ exit 1
+fi
+
+for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
+ case "$i" in
+ *.gz)
+ type="gzip"; uncomp="gunzip -dc"; ;;
+ *.bz)
+ type="bzip"; uncomp="bunzip -dc"; ;;
+ *.bz2)
+ type="bzip2"; uncomp="bunzip2 -dc"; ;;
+ *.zip)
+ type="zip"; uncomp="unzip -d"; ;;
+ *.Z)
+ type="compress"; uncomp="uncompress -c"; ;;
+ *)
+ type="plaintext"; uncomp="cat"; ;;
+ esac
+ echo ""
+ echo "Applying ${i} using ${type}: "
+ echo ${i} | cat >> ${targetdir}/.applied_patches_list
+ ${uncomp} ${patchdir}/${i} | patch -p1 -E -d ${targetdir}
+ if [ $? != 0 ] ; then
+ echo "Patch failed! Please fix $i!"
+ exit 1
+ fi
+done
+
+# Check for rejects...
+if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+ echo "Aborting. Reject files found."
+ exit 1
+fi
+
+# Remove backup files
+find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
diff --git a/cleopatre/buildroot/toolchain/sstrip/Config.in b/cleopatre/buildroot/toolchain/sstrip/Config.in
new file mode 100644
index 0000000000..be4fa28a37
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/sstrip/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_SSTRIP_TARGET
+ bool "Install sstrip for the target system"
+ help
+ Maximal 'strip'ing utility.
+
+config BR2_PACKAGE_SSTRIP_HOST
+ bool "Install sstrip for the host/build system"
+ help
+ Maximal 'strip'ing utility.
diff --git a/cleopatre/buildroot/toolchain/sstrip/sstrip.c b/cleopatre/buildroot/toolchain/sstrip/sstrip.c
new file mode 100644
index 0000000000..1842f053c6
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/sstrip/sstrip.c
@@ -0,0 +1,468 @@
+/* http://www.muppetlabs.com/~breadbox/software/elfkickers.html */
+
+/* sstrip: Copyright (C) 1999-2001 by Brian Raiter, under the GNU
+ * General Public License. No warranty. See COPYING for details.
+ *
+ * Aug 23, 2004 Hacked by Manuel Novoa III <mjn3@codepoet.org> to
+ * handle targets of different endianness and/or elf class, making
+ * it more useful in a cross-devel environment.
+ */
+
+/* ============== original README ===================
+ *
+ * sstrip is a small utility that removes the contents at the end of an
+ * ELF file that are not part of the program's memory image.
+ *
+ * Most ELF executables are built with both a program header table and a
+ * section header table. However, only the former is required in order
+ * for the OS to load, link and execute a program. sstrip attempts to
+ * extract the ELF header, the program header table, and its contents,
+ * leaving everything else in the bit bucket. It can only remove parts of
+ * the file that occur at the end, after the parts to be saved. However,
+ * this almost always includes the section header table, and occasionally
+ * a few random sections that are not used when running a program.
+ *
+ * It should be noted that the GNU bfd library is (understandably)
+ * dependent on the section header table as an index to the file's
+ * contents. Thus, an executable file that has no section header table
+ * cannot be used with gdb, objdump, or any other program based upon the
+ * bfd library, at all. In fact, the program will not even recognize the
+ * file as a valid executable. (This limitation is noted in the source
+ * code comments for bfd, and is marked "FIXME", so this may change at
+ * some future date. However, I would imagine that it is a pretty
+ * low-priority item, as executables without a section header table are
+ * rare in the extreme.) This probably also explains why strip doesn't
+ * offer the option to do this.
+ *
+ * Shared library files may also have their section header table removed.
+ * Such a library will still function; however, it will no longer be
+ * possible for a compiler to link a new program against it.
+ *
+ * As an added bonus, sstrip also tries to removes trailing zero bytes
+ * from the end of the file. (This normally cannot be done with an
+ * executable that has a section header table.)
+ *
+ * sstrip is a very simplistic program. It depends upon the common
+ * practice of putting the parts of the file that contribute to the
+ * memory image at the front, and the remaining material at the end. This
+ * permits it to discard the latter material without affecting file
+ * offsets and memory addresses in what remains. Of course, the ELF
+ * standard permits files to be organized in almost any order, so if a
+ * pathological linker decided to put its section headers at the top,
+ * sstrip would be useless on such executables.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <elf.h>
+#include <endian.h>
+#include <byteswap.h>
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+/* The name of the program.
+ */
+static char const *progname;
+
+/* The name of the current file.
+ */
+static char const *filename;
+
+
+/* A simple error-handling function. FALSE is always returned for the
+ * convenience of the caller.
+ */
+static int err(char const *errmsg)
+{
+ fprintf(stderr, "%s: %s: %s\n", progname, filename, errmsg);
+ return FALSE;
+}
+
+/* A flag to signal the need for endian reversal.
+ */
+static int do_reverse_endian;
+
+/* Get a value from the elf header, compensating for endianness.
+ */
+#define EGET(X) \
+ (__extension__ ({ \
+ uint64_t __res; \
+ if (!do_reverse_endian) { \
+ __res = (X); \
+ } else if (sizeof(X) == 1) { \
+ __res = (X); \
+ } else if (sizeof(X) == 2) { \
+ __res = bswap_16((X)); \
+ } else if (sizeof(X) == 4) { \
+ __res = bswap_32((X)); \
+ } else if (sizeof(X) == 8) { \
+ __res = bswap_64((X)); \
+ } else { \
+ fprintf(stderr, "%s: %s: EGET failed for size %d\n", \
+ progname, filename, sizeof(X)); \
+ exit(EXIT_FAILURE); \
+ } \
+ __res; \
+ }))
+
+/* Set a value 'Y' in the elf header to 'X', compensating for endianness.
+ */
+#define ESET(Y,X) \
+ do if (!do_reverse_endian) { \
+ Y = (X); \
+ } else if (sizeof(Y) == 1) { \
+ Y = (X); \
+ } else if (sizeof(Y) == 2) { \
+ Y = bswap_16((uint16_t)(X)); \
+ } else if (sizeof(Y) == 4) { \
+ Y = bswap_32((uint32_t)(X)); \
+ } else if (sizeof(Y) == 8) { \
+ Y = bswap_64((uint64_t)(X)); \
+ } else { \
+ fprintf(stderr, "%s: %s: ESET failed for size %d\n", \
+ progname, filename, sizeof(Y)); \
+ exit(EXIT_FAILURE); \
+ } while (0)
+
+
+/* A macro for I/O errors: The given error message is used only when
+ * errno is not set.
+ */
+#define ferr(msg) (err(errno ? strerror(errno) : (msg)))
+
+
+
+#define HEADER_FUNCTIONS(CLASS) \
+ \
+/* readelfheader() reads the ELF header into our global variable, and \
+ * checks to make sure that this is in fact a file that we should be \
+ * munging. \
+ */ \
+static int readelfheader ## CLASS (int fd, Elf ## CLASS ## _Ehdr *ehdr) \
+{ \
+ if (read(fd, ((char *)ehdr)+EI_NIDENT, sizeof(*ehdr) - EI_NIDENT) \
+ != sizeof(*ehdr) - EI_NIDENT) \
+ return ferr("missing or incomplete ELF header."); \
+ \
+ /* Verify the sizes of the ELF header and the program segment \
+ * header table entries. \
+ */ \
+ if (EGET(ehdr->e_ehsize) != sizeof(Elf ## CLASS ## _Ehdr)) \
+ return err("unrecognized ELF header size."); \
+ if (EGET(ehdr->e_phentsize) != sizeof(Elf ## CLASS ## _Phdr)) \
+ return err("unrecognized program segment header size."); \
+ \
+ /* Finally, check the file type. \
+ */ \
+ if (EGET(ehdr->e_type) != ET_EXEC && EGET(ehdr->e_type) != ET_DYN) \
+ return err("not an executable or shared-object library."); \
+ \
+ return TRUE; \
+} \
+ \
+/* readphdrtable() loads the program segment header table into memory. \
+ */ \
+static int readphdrtable ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
+ Elf ## CLASS ## _Phdr **phdrs) \
+{ \
+ size_t size; \
+ \
+ if (!EGET(ehdr->e_phoff) || !EGET(ehdr->e_phnum) \
+) return err("ELF file has no program header table."); \
+ \
+ size = EGET(ehdr->e_phnum) * sizeof **phdrs; \
+ if (!(*phdrs = malloc(size))) \
+ return err("Out of memory!"); \
+ \
+ errno = 0; \
+ if (read(fd, *phdrs, size) != (ssize_t)size) \
+ return ferr("missing or incomplete program segment header table."); \
+ \
+ return TRUE; \
+} \
+ \
+/* getmemorysize() determines the offset of the last byte of the file \
+ * that is referenced by an entry in the program segment header table. \
+ * (Anything in the file after that point is not used when the program \
+ * is executing, and thus can be safely discarded.) \
+ */ \
+static int getmemorysize ## CLASS (Elf ## CLASS ## _Ehdr const *ehdr, \
+ Elf ## CLASS ## _Phdr const *phdrs, \
+ unsigned long *newsize) \
+{ \
+ Elf ## CLASS ## _Phdr const *phdr; \
+ unsigned long size, n; \
+ int i; \
+ \
+ /* Start by setting the size to include the ELF header and the \
+ * complete program segment header table. \
+ */ \
+ size = EGET(ehdr->e_phoff) + EGET(ehdr->e_phnum) * sizeof *phdrs; \
+ if (size < sizeof *ehdr) \
+ size = sizeof *ehdr; \
+ \
+ /* Then keep extending the size to include whatever data the \
+ * program segment header table references. \
+ */ \
+ for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
+ if (EGET(phdr->p_type) != PT_NULL) { \
+ n = EGET(phdr->p_offset) + EGET(phdr->p_filesz); \
+ if (n > size) \
+ size = n; \
+ } \
+ } \
+ \
+ *newsize = size; \
+ return TRUE; \
+} \
+ \
+/* modifyheaders() removes references to the section header table if \
+ * it was stripped, and reduces program header table entries that \
+ * included truncated bytes at the end of the file. \
+ */ \
+static int modifyheaders ## CLASS (Elf ## CLASS ## _Ehdr *ehdr, \
+ Elf ## CLASS ## _Phdr *phdrs, \
+ unsigned long newsize) \
+{ \
+ Elf ## CLASS ## _Phdr *phdr; \
+ int i; \
+ \
+ /* If the section header table is gone, then remove all references \
+ * to it in the ELF header. \
+ */ \
+ if (EGET(ehdr->e_shoff) >= newsize) { \
+ ESET(ehdr->e_shoff,0); \
+ ESET(ehdr->e_shnum,0); \
+ ESET(ehdr->e_shentsize,0); \
+ ESET(ehdr->e_shstrndx,0); \
+ } \
+ \
+ /* The program adjusts the file size of any segment that was \
+ * truncated. The case of a segment being completely stripped out \
+ * is handled separately. \
+ */ \
+ for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
+ if (EGET(phdr->p_offset) >= newsize) { \
+ ESET(phdr->p_offset,newsize); \
+ ESET(phdr->p_filesz,0); \
+ } else if (EGET(phdr->p_offset) + EGET(phdr->p_filesz) > newsize) { \
+ newsize -= EGET(phdr->p_offset); \
+ ESET(phdr->p_filesz, newsize); \
+ } \
+ } \
+ \
+ return TRUE; \
+} \
+ \
+/* commitchanges() writes the new headers back to the original file \
+ * and sets the file to its new size. \
+ */ \
+static int commitchanges ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
+ Elf ## CLASS ## _Phdr *phdrs, \
+ unsigned long newsize) \
+{ \
+ size_t n; \
+ \
+ /* Save the changes to the ELF header, if any. \
+ */ \
+ if (lseek(fd, 0, SEEK_SET)) \
+ return ferr("could not rewind file"); \
+ errno = 0; \
+ if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr) \
+ return err("could not modify file"); \
+ \
+ /* Save the changes to the program segment header table, if any. \
+ */ \
+ if (lseek(fd, EGET(ehdr->e_phoff), SEEK_SET) == (off_t)-1) { \
+ err("could not seek in file."); \
+ goto warning; \
+ } \
+ n = EGET(ehdr->e_phnum) * sizeof *phdrs; \
+ if (write(fd, phdrs, n) != (ssize_t)n) { \
+ err("could not write to file"); \
+ goto warning; \
+ } \
+ \
+ /* Eleventh-hour sanity check: don't truncate before the end of \
+ * the program segment header table. \
+ */ \
+ if (newsize < EGET(ehdr->e_phoff) + n) \
+ newsize = EGET(ehdr->e_phoff) + n; \
+ \
+ /* Chop off the end of the file. \
+ */ \
+ if (ftruncate(fd, newsize)) { \
+ err("could not resize file"); \
+ goto warning; \
+ } \
+ \
+ return TRUE; \
+ \
+ warning: \
+ return err("ELF file may have been corrupted!"); \
+}
+
+
+/* First elements of Elf32_Ehdr and Elf64_Ehdr are common.
+ */
+static int readelfheaderident(int fd, Elf32_Ehdr *ehdr)
+{
+ errno = 0;
+ if (read(fd, ehdr, EI_NIDENT) != EI_NIDENT)
+ return ferr("missing or incomplete ELF header.");
+
+ /* Check the ELF signature.
+ */
+ if (!(ehdr->e_ident[EI_MAG0] == ELFMAG0 &&
+ ehdr->e_ident[EI_MAG1] == ELFMAG1 &&
+ ehdr->e_ident[EI_MAG2] == ELFMAG2 &&
+ ehdr->e_ident[EI_MAG3] == ELFMAG3))
+ {
+ err("missing ELF signature.");
+ return -1;
+ }
+
+ /* Compare the file's class and endianness with the program's.
+ */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
+ do_reverse_endian = 0;
+ } else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
+/* fprintf(stderr, "ELF file has different endianness.\n"); */
+ do_reverse_endian = 1;
+ }
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
+/* fprintf(stderr, "ELF file has different endianness.\n"); */
+ do_reverse_endian = 1;
+ } else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
+ do_reverse_endian = 0;
+ }
+#else
+#error unkown endianness
+#endif
+ else {
+ err("Unsupported endianness");
+ return -1;
+ }
+
+ /* Check the target architecture.
+ */
+/* if (EGET(ehdr->e_machine) != ELF_ARCH) { */
+/* /\* return err("ELF file created for different architecture."); *\/ */
+/* fprintf(stderr, "ELF file created for different architecture.\n"); */
+/* } */
+ return ehdr->e_ident[EI_CLASS];
+}
+
+
+HEADER_FUNCTIONS(32)
+
+HEADER_FUNCTIONS(64)
+
+/* truncatezeros() examines the bytes at the end of the file's
+ * size-to-be, and reduces the size to exclude any trailing zero
+ * bytes.
+ */
+static int truncatezeros(int fd, unsigned long *newsize)
+{
+ unsigned char contents[1024];
+ unsigned long size, n;
+
+ size = *newsize;
+ do {
+ n = sizeof contents;
+ if (n > size)
+ n = size;
+ if (lseek(fd, size - n, SEEK_SET) == (off_t)-1)
+ return ferr("cannot seek in file.");
+ if (read(fd, contents, n) != (ssize_t)n)
+ return ferr("cannot read file contents");
+ while (n && !contents[--n])
+ --size;
+ } while (size && !n);
+
+ /* Sanity check.
+ */
+ if (!size)
+ return err("ELF file is completely blank!");
+
+ *newsize = size;
+ return TRUE;
+}
+
+/* main() loops over the cmdline arguments, leaving all the real work
+ * to the other functions.
+ */
+int main(int argc, char *argv[])
+{
+ int fd;
+ union {
+ Elf32_Ehdr ehdr32;
+ Elf64_Ehdr ehdr64;
+ } e;
+ union {
+ Elf32_Phdr *phdrs32;
+ Elf64_Phdr *phdrs64;
+ } p;
+ unsigned long newsize;
+ char **arg;
+ int failures = 0;
+
+ if (argc < 2 || argv[1][0] == '-') {
+ printf("Usage: sstrip FILE...\n"
+ "sstrip discards all nonessential bytes from an executable.\n\n"
+ "Version 2.0-X Copyright (C) 2000,2001 Brian Raiter.\n"
+ "Cross-devel hacks Copyright (C) 2004 Manuel Novoa III.\n"
+ "This program is free software, licensed under the GNU\n"
+ "General Public License. There is absolutely no warranty.\n");
+ return EXIT_SUCCESS;
+ }
+
+ progname = argv[0];
+
+ for (arg = argv + 1 ; *arg != NULL ; ++arg) {
+ filename = *arg;
+
+ fd = open(*arg, O_RDWR);
+ if (fd < 0) {
+ ferr("can't open");
+ ++failures;
+ continue;
+ }
+
+ switch (readelfheaderident(fd, &e.ehdr32)) {
+ case ELFCLASS32:
+ if (!(readelfheader32(fd, &e.ehdr32) &&
+ readphdrtable32(fd, &e.ehdr32, &p.phdrs32) &&
+ getmemorysize32(&e.ehdr32, p.phdrs32, &newsize) &&
+ truncatezeros(fd, &newsize) &&
+ modifyheaders32(&e.ehdr32, p.phdrs32, newsize) &&
+ commitchanges32(fd, &e.ehdr32, p.phdrs32, newsize)))
+ ++failures;
+ break;
+ case ELFCLASS64:
+ if (!(readelfheader64(fd, &e.ehdr64) &&
+ readphdrtable64(fd, &e.ehdr64, &p.phdrs64) &&
+ getmemorysize64(&e.ehdr64, p.phdrs64, &newsize) &&
+ truncatezeros(fd, &newsize) &&
+ modifyheaders64(&e.ehdr64, p.phdrs64, newsize) &&
+ commitchanges64(fd, &e.ehdr64, p.phdrs64, newsize)))
+ ++failures;
+ break;
+ default:
+ ++failures;
+ break;
+ }
+ close(fd);
+ }
+
+ return failures ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/cleopatre/buildroot/toolchain/sstrip/sstrip.mk b/cleopatre/buildroot/toolchain/sstrip/sstrip.mk
new file mode 100644
index 0000000000..cb95e3faa8
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/sstrip/sstrip.mk
@@ -0,0 +1,70 @@
+######################################################################
+#
+# sstrip
+#
+######################################################################
+
+SSTRIP_SOURCE_FILE:=$(TOPDIR)/toolchain/sstrip/sstrip.c
+
+######################################################################
+#
+# sstrip host
+#
+######################################################################
+
+SSTRIP_HOST:=$(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-sstrip
+
+$(SSTRIP_HOST): $(SSTRIP_SOURCE_FILE)
+ mkdir -p $(@D) $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin
+ $(HOSTCC) $(CFLAGS_FOR_BUILD) $(SSTRIP_SOURCE_FILE) -o $(SSTRIP_HOST)
+ ln -snf ../../bin/$(REAL_GNU_TARGET_NAME)-sstrip \
+ $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/sstrip
+ ln -snf $(REAL_GNU_TARGET_NAME)-sstrip \
+ $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
+
+sstrip_host: $(SSTRIP_HOST)
+
+sstrip_host-source: $(SSTRIP_SOURCE_FILE)
+
+sstrip_host-clean:
+ rm -f $(SSTRIP_HOST)
+ rm -f $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/sstrip
+ rm -f $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip
+
+sstrip_host-dirclean:
+ true
+
+######################################################################
+#
+# sstrip target
+#
+######################################################################
+
+SSTRIP_TARGET:=$(TARGET_DIR)/usr/bin/sstrip
+
+$(SSTRIP_TARGET): $(SSTRIP_SOURCE_FILE)
+ $(TARGET_CC) $(TARGET_CFLAGS) $(SSTRIP_SOURCE_FILE) -o $(SSTRIP_TARGET)
+
+sstrip_target: $(SSTRIP_TARGET)
+
+sstrip_target-source: $(SSTRIP_SOURCE_FILE)
+
+sstrip_target-clean:
+ rm -f $(SSTRIP_TARGET)
+
+sstrip_target-dirclean:
+ true
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+
+ifeq ($(strip $(BR2_PACKAGE_SSTRIP_HOST)),y)
+TARGETS+=sstrip_host
+endif
+
+ifeq ($(strip $(BR2_PACKAGE_SSTRIP_TARGET)),y)
+TARGETS+=sstrip_target
+endif
diff --git a/cleopatre/buildroot/toolchain/uClibc/Config.in b/cleopatre/buildroot/toolchain/uClibc/Config.in
new file mode 100644
index 0000000000..11790363eb
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/Config.in
@@ -0,0 +1,85 @@
+# Choose uClibc options
+#
+
+comment "uClibc Options"
+
+choice
+ prompt "uClibc C library Version"
+ default BR2_UCLIBC_VERSION_0_9_29
+ help
+ Select the version of uClibc you wish to use.
+
+ config BR2_UCLIBC_VERSION_0_9_28_3
+ depends on BR2_DEPRECATED
+ bool "uClibc 0.9.28.3"
+ depends on BR2_EXT_UCLIBC_VERSION_0_9_28_3
+
+ config BR2_UCLIBC_VERSION_0_9_29
+ bool "uClibc 0.9.29"
+ depends on BR2_EXT_UCLIBC_VERSION_0_9_29
+
+ config BR2_UCLIBC_VERSION_SNAPSHOT
+ bool "daily snapshot"
+
+endchoice
+
+
+config BR2_USE_UCLIBC_SNAPSHOT
+ string "Date (yyyymmdd) of snapshot or 'snapshot' for latest"
+ default "snapshot"
+ depends on BR2_UCLIBC_VERSION_SNAPSHOT
+ help
+ Use latest snapshot or one from a specific date?
+
+config BR2_UCLIBC_CONFIG
+ string "uClibc configuration file to use?"
+ default "toolchain/uClibc/uClibc-0.9.28.config" if BR2_UCLIBC_VERSION_0_9_28_3
+ default "toolchain/uClibc/uClibc-0.9.29.config" if BR2_UCLIBC_VERSION_0_9_29
+ default "toolchain/uClibc/uClibc-0.9.29.config" if BR2_UCLIBC_VERSION_0_9_30
+ default "toolchain/uClibc/uClibc-snapshot.config" if BR2_UCLIBC_VERSION_SNAPSHOT
+ help
+ Some people may wish to use their own modified uClibc configuration
+ file and will specify their config file location with this option.
+ See also docs/README in this package.
+ If unsure, use the default.
+
+config BR2_ENABLE_LOCALE
+ bool "Enable locale/gettext/i18n support?"
+ help
+ Enable locale/gettext/i18n support?
+
+choice
+ prompt "Thread library implementation"
+ default BR2_PTHREADS_OLD
+ help
+ Select the version of libpthreads you want to use.
+ Not all thread variants work with all versions of uClibc,
+ the "linuxthreads (stable/old)" may be a working fallback
+ if you need threading at all.
+
+ config BR2_PTHREADS_NONE
+ bool "none"
+
+ config BR2_PTHREADS
+ bool "linuxthreads"
+
+ config BR2_PTHREADS_OLD
+ bool "linuxthreads (stable/old)"
+
+ config BR2_PTHREADS_NATIVE
+ bool "Native POSIX Threading (NPTL)"
+endchoice
+
+config BR2_PTHREAD_DEBUG
+ bool "Thread library debugging"
+ depends on BR2_PTHREADS || BR2_PTHREADS_OLD || BR2_PTHREADS_NATIVE
+ help
+ Build the thread library with debugging enabled.
+
+config BR2_UCLIBC_PROGRAM_INVOCATION
+ bool "Enable 'program invocation name'"
+ help
+ Support for the GNU-specific program_invocation_name and
+ program_invocation_short_name strings. Some GNU packages
+ (like tar and coreutils) utilize these for extra useful
+ output, but in general are not required.
diff --git a/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-001-libext.patch b/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-001-libext.patch
new file mode 100644
index 0000000000..e1740a7acf
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-001-libext.patch
@@ -0,0 +1,13 @@
+diff -urN uClibc-0.9.28.3-0rig/Makefile uClibc-0.9.28.3/Makefile
+--- uClibc-0.9.28.3-0rig/Makefile 2007-07-29 08:20:33.000000000 +0200
++++ uClibc-0.9.28.3/Makefile 2007-08-20 07:02:53.000000000 +0200
+@@ -157,7 +157,8 @@
+ install_dev:
+ $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
+ $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
+- -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
++ -$(INSTALL) -m 644 lib/*.a $(PREFIX)$(DEVEL_PREFIX)lib/
++ -$(INSTALL) -m 644 lib/*.so* $(PREFIX)$(DEVEL_PREFIX)lib/
+ if [ "$(KERNEL_SOURCE)" = "$(DEVEL_PREFIX)" ] ; then \
+ extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
+ else \
diff --git a/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-002-rm-whitespace.patch b/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-002-rm-whitespace.patch
new file mode 100644
index 0000000000..2ae0265880
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/ext_source/Atmel/avr32/0.9.28.3-avr32-2.0/uClibc-0.9.28.3-avr32-2.0-002-rm-whitespace.patch
@@ -0,0 +1,77 @@
+diff -urN uClibc-0.9.29-0rig/include/assert.h uClibc-0.9.29/include/assert.h
+--- uClibc-0.9.29-0rig/include/assert.h 2005-11-03 23:42:46.000000000 +0100
++++ uClibc-0.9.29/include/assert.h 2007-08-13 19:10:57.000000000 +0200
+@@ -31,7 +31,7 @@
+ #define _ASSERT_H 1
+ #include <features.h>
+
+-#if defined __cplusplus && __GNUC_PREREQ (2,95)
++#if defined __cplusplus && __GNUC_PREREQ(2,95)
+ # define __ASSERT_VOID_CAST static_cast<void>
+ #else
+ # define __ASSERT_VOID_CAST (void)
+@@ -59,13 +59,17 @@
+ (__ASSERT_VOID_CAST ((expr) ? 0 : \
+ (__assert (__STRING(expr), __FILE__, __LINE__, \
+ __ASSERT_FUNCTION), 0)))
+-
++
++/* Define some temporaries to workaround tinyx makedepend bug */
++#define __GNUC_PREREQ_2_6 __GNUC_PREREQ(2, 6)
++#define __GNUC_PREREQ_2_4 __GNUC_PREREQ(2, 4)
+ /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
+ which contains the name of the function currently being defined.
+ This is broken in G++ before version 2.6.
+ C9x has a similar variable called __func__, but prefer the GCC one since
+ it demangles C++ function names. */
+-# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
++
++# if defined __cplusplus ? __GNUC_PREREQ_2_6 : __GNUC_PREREQ_2_4
+ # define __ASSERT_FUNCTION __PRETTY_FUNCTION__
+ # else
+ # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+diff -urN uClibc-0.9.29-0rig/include/complex.h uClibc-0.9.29/include/complex.h
+--- uClibc-0.9.29-0rig/include/complex.h 2002-05-09 10:15:21.000000000 +0200
++++ uClibc-0.9.29/include/complex.h 2007-08-13 17:55:29.000000000 +0200
+@@ -33,7 +33,7 @@
+ /* We might need to add support for more compilers here. But since ISO
+ C99 is out hopefully all maintained compilers will soon provide the data
+ types `float complex' and `double complex'. */
+-#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
++#if __GNUC_PREREQ(2, 7) && !__GNUC_PREREQ(2, 97)
+ # define _Complex __complex__
+ #endif
+
+diff -urN uClibc-0.9.29-0rig/include/features.h uClibc-0.9.29/include/features.h
+--- uClibc-0.9.29-0rig/include/features.h 2006-11-29 22:10:04.000000000 +0100
++++ uClibc-0.9.29/include/features.h 2007-08-13 17:55:51.000000000 +0200
+@@ -143,7 +143,7 @@
+
+ /* Convenience macros to test the versions of glibc and gcc.
+ Use them like this:
+- #if __GNUC_PREREQ (2,8)
++ #if __GNUC_PREREQ(2,8)
+ ... code requiring gcc 2.8 or later ...
+ #endif
+ Note - they won't work for gcc1 or glibc1, since the _MINOR macros
+@@ -366,7 +366,7 @@
+ #endif /* !ASSEMBLER */
+
+ /* Decide whether we can define 'extern inline' functions in headers. */
+-#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
++#if __GNUC_PREREQ(2, 7) && defined __OPTIMIZE__ \
+ && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
+ # define __USE_EXTERN_INLINES 1
+ #endif
+diff -urN uClibc-0.9.29-0rig/include/tgmath.h uClibc-0.9.29/include/tgmath.h
+--- uClibc-0.9.29-0rig/include/tgmath.h 2002-05-09 10:15:21.000000000 +0200
++++ uClibc-0.9.29/include/tgmath.h 2007-08-13 17:56:17.000000000 +0200
+@@ -34,7 +34,7 @@
+ do not try this for now and instead concentrate only on GNU CC. Once
+ we have more information support for other compilers might follow. */
+
+-#if __GNUC_PREREQ (2, 7)
++#if __GNUC_PREREQ(2, 7)
+
+ # ifdef __NO_LONG_DOUBLE_MATH
+ # define __tgml(fct) fct
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-arch.patch.avr32 b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-arch.patch.avr32
new file mode 100644
index 0000000000..2e0f541a8e
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-arch.patch.avr32
@@ -0,0 +1,7650 @@
+diff -Nrup a/extra/Configs/Config.avr32 b/extra/Configs/Config.avr32
+--- a/extra/Configs/Config.avr32 1969-12-31 19:00:00.000000000 -0500
++++ b/extra/Configs/Config.avr32 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,42 @@
++#
++# For a description of the syntax of this configuration file,
++# see extra/config/Kconfig-language.txt
++#
++
++config HAVE_ELF
++ bool
++ default y
++
++config TARGET_ARCH
++ default "avr32"
++
++config ARCH_CFLAGS
++ string
++
++config ARCH_LDFLAGS
++ string
++
++config LIBGCC_CFLAGS
++ string
++
++config ARCH_SUPPORTS_BIG_ENDIAN
++ bool
++ default y
++
++config UCLIBC_COMPLETELY_PIC
++ select FORCE_SHAREABLE_TEXT_SEGMENTS
++ bool
++ default y
++
++choice
++ prompt "Target CPU Type"
++ default CONFIG_AP7000
++
++config CONFIG_AP7000
++ bool "AP7000"
++
++endchoice
++
++config LINKRELAX
++ bool "Enable linker optimizations"
++ default n
+diff -Nrup a/extra/Configs/Config.in b/extra/Configs/Config.in
+--- a/extra/Configs/Config.in 2007-01-25 19:01:55.000000000 -0500
++++ b/extra/Configs/Config.in 2008-02-28 19:02:10.000000000 -0500
+@@ -16,6 +16,9 @@ config TARGET_alpha
+ config TARGET_arm
+ bool "arm"
+
++config TARGET_avr32
++ bool "avr32"
++
+ config TARGET_bfin
+ bool "bfin"
+
+@@ -83,6 +86,10 @@ if TARGET_arm
+ source "extra/Configs/Config.arm"
+ endif
+
++if TARGET_avr32
++source "extra/Configs/Config.avr32"
++endif
++
+ if TARGET_bfin
+ source "extra/Configs/Config.bfin"
+ endif
+diff -Nrup a/include/elf.h b/include/elf.h
+--- a/include/elf.h 2007-01-25 19:22:03.000000000 -0500
++++ b/include/elf.h 2008-02-28 19:02:10.000000000 -0500
+@@ -305,6 +305,8 @@ typedef struct
+ /* D30V backend magic number. Written in the absence of an ABI. */
+ #define EM_CYGNUS_D30V 0x7676
+
++#define EM_AVR32 0x18ad
++
+ /* V850 backend magic number. Written in the absense of an ABI. */
+ #define EM_CYGNUS_V850 0x9080
+
+@@ -2751,6 +2753,55 @@ typedef Elf32_Addr Elf32_Conflict;
+ /* Keep this the last entry. */
+ #define R_960_NUM 8
+
++/* Atmel AVR32 relocations. */
++#define R_AVR32_NONE 0
++#define R_AVR32_32 1
++#define R_AVR32_16 2
++#define R_AVR32_8 3
++#define R_AVR32_32_PCREL 4
++#define R_AVR32_16_PCREL 5
++#define R_AVR32_8_PCREL 6
++#define R_AVR32_DIFF32 7
++#define R_AVR32_DIFF16 8
++#define R_AVR32_DIFF8 9
++#define R_AVR32_GOT32 10
++#define R_AVR32_GOT16 11
++#define R_AVR32_GOT8 12
++#define R_AVR32_21S 13
++#define R_AVR32_16U 14
++#define R_AVR32_16S 15
++#define R_AVR32_8S 16
++#define R_AVR32_8S_EXT 17
++#define R_AVR32_22H_PCREL 18
++#define R_AVR32_18W_PCREL 19
++#define R_AVR32_16B_PCREL 20
++#define R_AVR32_16N_PCREL 21
++#define R_AVR32_14UW_PCREL 22
++#define R_AVR32_11H_PCREL 23
++#define R_AVR32_10UW_PCREL 24
++#define R_AVR32_9H_PCREL 25
++#define R_AVR32_9UW_PCREL 26
++#define R_AVR32_HI16 27
++#define R_AVR32_LO16 28
++#define R_AVR32_GOTPC 29
++#define R_AVR32_GOTCALL 30
++#define R_AVR32_LDA_GOT 31
++#define R_AVR32_GOT21S 32
++#define R_AVR32_GOT18SW 33
++#define R_AVR32_GOT16S 34
++#define R_AVR32_GOT7UW 35
++#define R_AVR32_32_CPENT 36
++#define R_AVR32_CPCALL 37
++#define R_AVR32_16_CP 38
++#define R_AVR32_9W_CP 39
++#define R_AVR32_RELATIVE 40
++#define R_AVR32_GLOB_DAT 41
++#define R_AVR32_JMP_SLOT 42
++#define R_AVR32_ALIGN 43
++#define R_AVR32_NUM 44
++
++/* AVR32 dynamic tags */
++#define DT_AVR32_GOTSZ 0x70000001 /* Total size of GOT in bytes */
+
+ /* v850 relocations. */
+ #define R_V850_NONE 0
+diff -Nrup a/include/elf.h.orig b/include/elf.h.orig
+--- a/include/elf.h.orig 1969-12-31 19:00:00.000000000 -0500
++++ b/include/elf.h.orig 2007-01-25 19:22:03.000000000 -0500
+@@ -0,0 +1,2886 @@
++/* This file defines standard ELF types, structures, and macros.
++ Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _ELF_H
++#define _ELF_H 1
++
++#include <features.h>
++
++__BEGIN_DECLS
++
++/* Standard ELF types. */
++
++#include <stdint.h>
++
++/* Type for a 16-bit quantity. */
++typedef uint16_t Elf32_Half;
++typedef uint16_t Elf64_Half;
++
++/* Types for signed and unsigned 32-bit quantities. */
++typedef uint32_t Elf32_Word;
++typedef int32_t Elf32_Sword;
++typedef uint32_t Elf64_Word;
++typedef int32_t Elf64_Sword;
++
++/* Types for signed and unsigned 64-bit quantities. */
++typedef uint64_t Elf32_Xword;
++typedef int64_t Elf32_Sxword;
++typedef uint64_t Elf64_Xword;
++typedef int64_t Elf64_Sxword;
++
++/* Type of addresses. */
++typedef uint32_t Elf32_Addr;
++typedef uint64_t Elf64_Addr;
++
++/* Type of file offsets. */
++typedef uint32_t Elf32_Off;
++typedef uint64_t Elf64_Off;
++
++/* Type for section indices, which are 16-bit quantities. */
++typedef uint16_t Elf32_Section;
++typedef uint16_t Elf64_Section;
++
++/* Type for version symbol information. */
++typedef Elf32_Half Elf32_Versym;
++typedef Elf64_Half Elf64_Versym;
++
++
++/* The ELF file header. This appears at the start of every ELF file. */
++
++#define EI_NIDENT (16)
++
++typedef struct
++{
++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
++ Elf32_Half e_type; /* Object file type */
++ Elf32_Half e_machine; /* Architecture */
++ Elf32_Word e_version; /* Object file version */
++ Elf32_Addr e_entry; /* Entry point virtual address */
++ Elf32_Off e_phoff; /* Program header table file offset */
++ Elf32_Off e_shoff; /* Section header table file offset */
++ Elf32_Word e_flags; /* Processor-specific flags */
++ Elf32_Half e_ehsize; /* ELF header size in bytes */
++ Elf32_Half e_phentsize; /* Program header table entry size */
++ Elf32_Half e_phnum; /* Program header table entry count */
++ Elf32_Half e_shentsize; /* Section header table entry size */
++ Elf32_Half e_shnum; /* Section header table entry count */
++ Elf32_Half e_shstrndx; /* Section header string table index */
++} Elf32_Ehdr;
++
++typedef struct
++{
++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
++ Elf64_Half e_type; /* Object file type */
++ Elf64_Half e_machine; /* Architecture */
++ Elf64_Word e_version; /* Object file version */
++ Elf64_Addr e_entry; /* Entry point virtual address */
++ Elf64_Off e_phoff; /* Program header table file offset */
++ Elf64_Off e_shoff; /* Section header table file offset */
++ Elf64_Word e_flags; /* Processor-specific flags */
++ Elf64_Half e_ehsize; /* ELF header size in bytes */
++ Elf64_Half e_phentsize; /* Program header table entry size */
++ Elf64_Half e_phnum; /* Program header table entry count */
++ Elf64_Half e_shentsize; /* Section header table entry size */
++ Elf64_Half e_shnum; /* Section header table entry count */
++ Elf64_Half e_shstrndx; /* Section header string table index */
++} Elf64_Ehdr;
++
++/* Fields in the e_ident array. The EI_* macros are indices into the
++ array. The macros under each EI_* macro are the values the byte
++ may have. */
++
++#define EI_MAG0 0 /* File identification byte 0 index */
++#define ELFMAG0 0x7f /* Magic number byte 0 */
++
++#define EI_MAG1 1 /* File identification byte 1 index */
++#define ELFMAG1 'E' /* Magic number byte 1 */
++
++#define EI_MAG2 2 /* File identification byte 2 index */
++#define ELFMAG2 'L' /* Magic number byte 2 */
++
++#define EI_MAG3 3 /* File identification byte 3 index */
++#define ELFMAG3 'F' /* Magic number byte 3 */
++
++/* Conglomeration of the identification bytes, for easy testing as a word. */
++#define ELFMAG "\177ELF"
++#define SELFMAG 4
++
++#define EI_CLASS 4 /* File class byte index */
++#define ELFCLASSNONE 0 /* Invalid class */
++#define ELFCLASS32 1 /* 32-bit objects */
++#define ELFCLASS64 2 /* 64-bit objects */
++#define ELFCLASSNUM 3
++
++#define EI_DATA 5 /* Data encoding byte index */
++#define ELFDATANONE 0 /* Invalid data encoding */
++#define ELFDATA2LSB 1 /* 2's complement, little endian */
++#define ELFDATA2MSB 2 /* 2's complement, big endian */
++#define ELFDATANUM 3
++
++#define EI_VERSION 6 /* File version byte index */
++ /* Value must be EV_CURRENT */
++
++#define EI_OSABI 7 /* OS ABI identification */
++#define ELFOSABI_NONE 0 /* UNIX System V ABI */
++#define ELFOSABI_SYSV 0 /* Alias. */
++#define ELFOSABI_HPUX 1 /* HP-UX */
++#define ELFOSABI_NETBSD 2 /* NetBSD. */
++#define ELFOSABI_LINUX 3 /* Linux. */
++#define ELFOSABI_HURD 4 /* GNU/Hurd */
++#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
++#define ELFOSABI_AIX 7 /* IBM AIX. */
++#define ELFOSABI_IRIX 8 /* SGI Irix. */
++#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
++#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
++#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
++#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
++#define ELFOSABI_OPENVMS 13 /* OpenVMS */
++#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
++#define ELFOSABI_AROS 15 /* Amiga Research OS */
++#define ELFOSABI_ARM 97 /* ARM */
++#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
++
++#define EI_ABIVERSION 8 /* ABI version */
++
++#define EI_PAD 9 /* Byte index of padding bytes */
++
++/* Legal values for e_type (object file type). */
++
++#define ET_NONE 0 /* No file type */
++#define ET_REL 1 /* Relocatable file */
++#define ET_EXEC 2 /* Executable file */
++#define ET_DYN 3 /* Shared object file */
++#define ET_CORE 4 /* Core file */
++#define ET_NUM 5 /* Number of defined types */
++#define ET_LOOS 0xfe00 /* OS-specific range start */
++#define ET_HIOS 0xfeff /* OS-specific range end */
++#define ET_LOPROC 0xff00 /* Processor-specific range start */
++#define ET_HIPROC 0xffff /* Processor-specific range end */
++
++/* Legal values for e_machine (architecture). */
++
++#define EM_NONE 0 /* No machine */
++#define EM_M32 1 /* AT&T WE 32100 */
++#define EM_SPARC 2 /* SUN SPARC */
++#define EM_386 3 /* Intel 80386 */
++#define EM_68K 4 /* Motorola m68k family */
++#define EM_88K 5 /* Motorola m88k family */
++#define EM_486 6 /* Intel 80486 *//* Reserved for future use */
++#define EM_860 7 /* Intel 80860 */
++#define EM_MIPS 8 /* MIPS R3000 big-endian */
++#define EM_S370 9 /* IBM System/370 */
++#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
++
++#define EM_PARISC 15 /* HPPA */
++#define EM_VPP500 17 /* Fujitsu VPP500 */
++#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
++#define EM_960 19 /* Intel 80960 */
++#define EM_PPC 20 /* PowerPC */
++#define EM_PPC64 21 /* PowerPC 64-bit */
++#define EM_S390 22 /* IBM S390 */
++
++#define EM_V800 36 /* NEC V800 series */
++#define EM_FR20 37 /* Fujitsu FR20 */
++#define EM_RH32 38 /* TRW RH-32 */
++#define EM_MCORE 39 /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
++#define EM_RCE 39 /* Old name for MCore */
++#define EM_ARM 40 /* ARM */
++#define EM_FAKE_ALPHA 41 /* Digital Alpha */
++#define EM_SH 42 /* Renesas SH */
++#define EM_SPARCV9 43 /* SPARC v9 64-bit */
++#define EM_TRICORE 44 /* Siemens Tricore */
++#define EM_ARC 45 /* Argonaut RISC Core */
++#define EM_H8_300 46 /* Renesas H8/300 */
++#define EM_H8_300H 47 /* Renesas H8/300H */
++#define EM_H8S 48 /* Renesas H8S */
++#define EM_H8_500 49 /* Renesas H8/500 */
++#define EM_IA_64 50 /* Intel Merced */
++#define EM_MIPS_X 51 /* Stanford MIPS-X */
++#define EM_COLDFIRE 52 /* Motorola Coldfire */
++#define EM_68HC12 53 /* Motorola M68HC12 */
++#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
++#define EM_PCP 55 /* Siemens PCP */
++#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
++#define EM_NDR1 57 /* Denso NDR1 microprocessor */
++#define EM_STARCORE 58 /* Motorola Start*Core processor */
++#define EM_ME16 59 /* Toyota ME16 processor */
++#define EM_ST100 60 /* STMicroelectronic ST100 processor */
++#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
++#define EM_X86_64 62 /* AMD x86-64 architecture */
++#define EM_PDSP 63 /* Sony DSP Processor */
++
++#define EM_FX66 66 /* Siemens FX66 microcontroller */
++#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
++#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
++#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
++#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
++#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
++#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
++#define EM_SVX 73 /* Silicon Graphics SVx */
++#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
++#define EM_VAX 75 /* Digital VAX */
++#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
++#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
++#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
++#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
++#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
++#define EM_HUANY 81 /* Harvard University machine-independent object files */
++#define EM_PRISM 82 /* SiTera Prism */
++#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
++#define EM_FR30 84 /* Fujitsu FR30 */
++#define EM_D10V 85 /* Mitsubishi D10V */
++#define EM_D30V 86 /* Mitsubishi D30V */
++#define EM_V850 87 /* NEC v850 */
++#define EM_M32R 88 /* Renesas M32R */
++#define EM_MN10300 89 /* Matsushita MN10300 */
++#define EM_MN10200 90 /* Matsushita MN10200 */
++#define EM_PJ 91 /* picoJava */
++#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
++#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
++#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
++#define EM_IP2K 101 /* Ubicom IP2022 micro controller */
++#define EM_CR 103 /* National Semiconductor CompactRISC */
++#define EM_MSP430 105 /* TI msp430 micro controller */
++#define EM_BLACKFIN 106 /* Analog Devices Blackfin */
++#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
++#define EM_CRX 114 /* National Semiconductor CRX */
++#define EM_NUM 95
++
++/* If it is necessary to assign new unofficial EM_* values, please pick large
++ random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
++ with official or non-GNU unofficial values.
++
++ NOTE: Do not just increment the most recent number by one.
++ Somebody else somewhere will do exactly the same thing, and you
++ will have a collision. Instead, pick a random number.
++
++ Normally, each entity or maintainer responsible for a machine with an
++ unofficial e_machine number should eventually ask registry@caldera.com for
++ an officially blessed number to be added to the list above. */
++
++/* picoJava */
++#define EM_PJ_OLD 99
++
++/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */
++#define EM_CYGNUS_POWERPC 0x9025
++
++/* Old version of Sparc v9, from before the ABI; this should be
++ removed shortly. */
++#define EM_OLD_SPARCV9 11
++
++/* Old version of PowerPC, this should be removed shortly. */
++#define EM_PPC_OLD 17
++
++/* (Deprecated) Temporary number for the OpenRISC processor. */
++#define EM_OR32 0x8472
++
++/* Renesas M32C and M16C. */
++#define EM_M32C 0xFEB0
++
++/* Cygnus M32R ELF backend. Written in the absence of an ABI. */
++#define EM_CYGNUS_M32R 0x9041
++
++/* old S/390 backend magic number. Written in the absence of an ABI. */
++#define EM_S390_OLD 0xa390
++
++/* D10V backend magic number. Written in the absence of an ABI. */
++#define EM_CYGNUS_D10V 0x7650
++
++/* D30V backend magic number. Written in the absence of an ABI. */
++#define EM_CYGNUS_D30V 0x7676
++
++/* V850 backend magic number. Written in the absense of an ABI. */
++#define EM_CYGNUS_V850 0x9080
++
++/* mn10200 and mn10300 backend magic numbers.
++ Written in the absense of an ABI. */
++#define EM_CYGNUS_MN10200 0xdead
++#define EM_CYGNUS_MN10300 0xbeef
++
++/* FR30 magic number - no EABI available. */
++#define EM_CYGNUS_FR30 0x3330
++
++/* AVR magic number
++ Written in the absense of an ABI. */
++#define EM_AVR_OLD 0x1057
++
++/* OpenRISC magic number
++ Written in the absense of an ABI. */
++#define EM_OPENRISC_OLD 0x3426
++
++/* DLX magic number
++ Written in the absense of an ABI. */
++#define EM_DLX 0x5aa5
++
++#define EM_XSTORMY16 0xad45
++
++/* FRV magic number - no EABI available??. */
++#define EM_CYGNUS_FRV 0x5441
++
++/* Ubicom IP2xxx; no ABI */
++#define EM_IP2K_OLD 0x8217
++
++#define EM_MT 0x2530 /* Morpho MT; no ABI */
++
++/* MSP430 magic number
++ Written in the absense everything. */
++#define EM_MSP430_OLD 0x1059
++
++/* Vitesse IQ2000. */
++#define EM_IQ2000 0xFEBA
++
++/* Old, unofficial value for Xtensa. */
++#define EM_XTENSA_OLD 0xabc7
++
++/* Alpha backend magic number. Written in the absence of an ABI. */
++#define EM_ALPHA 0x9026
++
++/* NIOS magic number - no EABI available. */
++#define EM_NIOS32 0xFEBB
++
++/* V850 backend magic number. Written in the absense of an ABI. */
++#define EM_CYGNUS_V850 0x9080
++
++/* Legal values for e_version (version). */
++
++#define EV_NONE 0 /* Invalid ELF version */
++#define EV_CURRENT 1 /* Current version */
++#define EV_NUM 2
++
++/* Section header. */
++
++typedef struct
++{
++ Elf32_Word sh_name; /* Section name (string tbl index) */
++ Elf32_Word sh_type; /* Section type */
++ Elf32_Word sh_flags; /* Section flags */
++ Elf32_Addr sh_addr; /* Section virtual addr at execution */
++ Elf32_Off sh_offset; /* Section file offset */
++ Elf32_Word sh_size; /* Section size in bytes */
++ Elf32_Word sh_link; /* Link to another section */
++ Elf32_Word sh_info; /* Additional section information */
++ Elf32_Word sh_addralign; /* Section alignment */
++ Elf32_Word sh_entsize; /* Entry size if section holds table */
++} Elf32_Shdr;
++
++typedef struct
++{
++ Elf64_Word sh_name; /* Section name (string tbl index) */
++ Elf64_Word sh_type; /* Section type */
++ Elf64_Xword sh_flags; /* Section flags */
++ Elf64_Addr sh_addr; /* Section virtual addr at execution */
++ Elf64_Off sh_offset; /* Section file offset */
++ Elf64_Xword sh_size; /* Section size in bytes */
++ Elf64_Word sh_link; /* Link to another section */
++ Elf64_Word sh_info; /* Additional section information */
++ Elf64_Xword sh_addralign; /* Section alignment */
++ Elf64_Xword sh_entsize; /* Entry size if section holds table */
++} Elf64_Shdr;
++
++/* Special section indices. */
++
++#define SHN_UNDEF 0 /* Undefined section */
++#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
++#define SHN_LOPROC 0xff00 /* Start of processor-specific */
++#define SHN_BEFORE 0xff00 /* Order section before all others
++ (Solaris). */
++#define SHN_AFTER 0xff01 /* Order section after all others
++ (Solaris). */
++#define SHN_HIPROC 0xff1f /* End of processor-specific */
++#define SHN_LOOS 0xff20 /* Start of OS-specific */
++#define SHN_HIOS 0xff3f /* End of OS-specific */
++#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
++#define SHN_COMMON 0xfff2 /* Associated symbol is common */
++#define SHN_XINDEX 0xffff /* Index is in extra table. */
++#define SHN_HIRESERVE 0xffff /* End of reserved indices */
++
++/* Legal values for sh_type (section type). */
++
++#define SHT_NULL 0 /* Section header table entry unused */
++#define SHT_PROGBITS 1 /* Program data */
++#define SHT_SYMTAB 2 /* Symbol table */
++#define SHT_STRTAB 3 /* String table */
++#define SHT_RELA 4 /* Relocation entries with addends */
++#define SHT_HASH 5 /* Symbol hash table */
++#define SHT_DYNAMIC 6 /* Dynamic linking information */
++#define SHT_NOTE 7 /* Notes */
++#define SHT_NOBITS 8 /* Program space with no data (bss) */
++#define SHT_REL 9 /* Relocation entries, no addends */
++#define SHT_SHLIB 10 /* Reserved */
++#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
++#define SHT_INIT_ARRAY 14 /* Array of constructors */
++#define SHT_FINI_ARRAY 15 /* Array of destructors */
++#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
++#define SHT_GROUP 17 /* Section group */
++#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
++#define SHT_NUM 19 /* Number of defined types. */
++#define SHT_LOOS 0x60000000 /* Start OS-specific */
++#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
++#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
++#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
++#define SHT_SUNW_move 0x6ffffffa
++#define SHT_SUNW_COMDAT 0x6ffffffb
++#define SHT_SUNW_syminfo 0x6ffffffc
++#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
++#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
++#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
++#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
++#define SHT_HIOS 0x6fffffff /* End OS-specific type */
++#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
++#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
++#define SHT_LOUSER 0x80000000 /* Start of application-specific */
++#define SHT_HIUSER 0x8fffffff /* End of application-specific */
++
++/* Legal values for sh_flags (section flags). */
++
++#define SHF_WRITE (1 << 0) /* Writable */
++#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
++#define SHF_EXECINSTR (1 << 2) /* Executable */
++#define SHF_MERGE (1 << 4) /* Might be merged */
++#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
++#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
++#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
++#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
++ required */
++#define SHF_GROUP (1 << 9) /* Section is member of a group. */
++#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
++#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
++#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
++#define SHF_ORDERED (1 << 30) /* Special ordering requirement
++ (Solaris). */
++#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless
++ referenced or allocated (Solaris).*/
++
++/* Section group handling. */
++#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
++
++/* Symbol table entry. */
++
++typedef struct
++{
++ Elf32_Word st_name; /* Symbol name (string tbl index) */
++ Elf32_Addr st_value; /* Symbol value */
++ Elf32_Word st_size; /* Symbol size */
++ unsigned char st_info; /* Symbol type and binding */
++ unsigned char st_other; /* Symbol visibility */
++ Elf32_Section st_shndx; /* Section index */
++} Elf32_Sym;
++
++typedef struct
++{
++ Elf64_Word st_name; /* Symbol name (string tbl index) */
++ unsigned char st_info; /* Symbol type and binding */
++ unsigned char st_other; /* Symbol visibility */
++ Elf64_Section st_shndx; /* Section index */
++ Elf64_Addr st_value; /* Symbol value */
++ Elf64_Xword st_size; /* Symbol size */
++} Elf64_Sym;
++
++/* The syminfo section if available contains additional information about
++ every dynamic symbol. */
++
++typedef struct
++{
++ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
++ Elf32_Half si_flags; /* Per symbol flags */
++} Elf32_Syminfo;
++
++typedef struct
++{
++ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
++ Elf64_Half si_flags; /* Per symbol flags */
++} Elf64_Syminfo;
++
++/* Possible values for si_boundto. */
++#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
++#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
++#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
++
++/* Possible bitmasks for si_flags. */
++#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
++#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
++#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
++#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
++ loaded */
++/* Syminfo version values. */
++#define SYMINFO_NONE 0
++#define SYMINFO_CURRENT 1
++#define SYMINFO_NUM 2
++
++
++/* How to extract and insert information held in the st_info field. */
++
++#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
++#define ELF32_ST_TYPE(val) ((val) & 0xf)
++#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
++
++/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
++#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
++#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
++#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
++
++/* Legal values for ST_BIND subfield of st_info (symbol binding). */
++
++#define STB_LOCAL 0 /* Local symbol */
++#define STB_GLOBAL 1 /* Global symbol */
++#define STB_WEAK 2 /* Weak symbol */
++#define STB_NUM 3 /* Number of defined types. */
++#define STB_LOOS 10 /* Start of OS-specific */
++#define STB_HIOS 12 /* End of OS-specific */
++#define STB_LOPROC 13 /* Start of processor-specific */
++#define STB_HIPROC 15 /* End of processor-specific */
++
++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
++
++#define STT_NOTYPE 0 /* Symbol type is unspecified */
++#define STT_OBJECT 1 /* Symbol is a data object */
++#define STT_FUNC 2 /* Symbol is a code object */
++#define STT_SECTION 3 /* Symbol associated with a section */
++#define STT_FILE 4 /* Symbol's name is file name */
++#define STT_COMMON 5 /* Symbol is a common data object */
++#define STT_TLS 6 /* Symbol is thread-local data object*/
++#define STT_NUM 7 /* Number of defined types. */
++#define STT_LOOS 10 /* Start of OS-specific */
++#define STT_HIOS 12 /* End of OS-specific */
++#define STT_LOPROC 13 /* Start of processor-specific */
++#define STT_HIPROC 15 /* End of processor-specific */
++
++
++/* Symbol table indices are found in the hash buckets and chain table
++ of a symbol hash table section. This special index value indicates
++ the end of a chain, meaning no further symbols are found in that bucket. */
++
++#define STN_UNDEF 0 /* End of a chain. */
++
++
++/* How to extract and insert information held in the st_other field. */
++
++#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
++
++/* For ELF64 the definitions are the same. */
++#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
++
++/* Symbol visibility specification encoded in the st_other field. */
++#define STV_DEFAULT 0 /* Default symbol visibility rules */
++#define STV_INTERNAL 1 /* Processor specific hidden class */
++#define STV_HIDDEN 2 /* Sym unavailable in other modules */
++#define STV_PROTECTED 3 /* Not preemptible, not exported */
++
++
++/* Relocation table entry without addend (in section of type SHT_REL). */
++
++typedef struct
++{
++ Elf32_Addr r_offset; /* Address */
++ Elf32_Word r_info; /* Relocation type and symbol index */
++} Elf32_Rel;
++
++/* I have seen two different definitions of the Elf64_Rel and
++ Elf64_Rela structures, so we'll leave them out until Novell (or
++ whoever) gets their act together. */
++/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
++
++typedef struct
++{
++ Elf64_Addr r_offset; /* Address */
++ Elf64_Xword r_info; /* Relocation type and symbol index */
++} Elf64_Rel;
++
++/* Relocation table entry with addend (in section of type SHT_RELA). */
++
++typedef struct
++{
++ Elf32_Addr r_offset; /* Address */
++ Elf32_Word r_info; /* Relocation type and symbol index */
++ Elf32_Sword r_addend; /* Addend */
++} Elf32_Rela;
++
++typedef struct
++{
++ Elf64_Addr r_offset; /* Address */
++ Elf64_Xword r_info; /* Relocation type and symbol index */
++ Elf64_Sxword r_addend; /* Addend */
++} Elf64_Rela;
++
++/* How to extract and insert information held in the r_info field. */
++
++#define ELF32_R_SYM(val) ((val) >> 8)
++#define ELF32_R_TYPE(val) ((val) & 0xff)
++#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
++
++#define ELF64_R_SYM(i) ((i) >> 32)
++#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
++#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
++
++/* Program segment header. */
++
++typedef struct
++{
++ Elf32_Word p_type; /* Segment type */
++ Elf32_Off p_offset; /* Segment file offset */
++ Elf32_Addr p_vaddr; /* Segment virtual address */
++ Elf32_Addr p_paddr; /* Segment physical address */
++ Elf32_Word p_filesz; /* Segment size in file */
++ Elf32_Word p_memsz; /* Segment size in memory */
++ Elf32_Word p_flags; /* Segment flags */
++ Elf32_Word p_align; /* Segment alignment */
++} Elf32_Phdr;
++
++typedef struct
++{
++ Elf64_Word p_type; /* Segment type */
++ Elf64_Word p_flags; /* Segment flags */
++ Elf64_Off p_offset; /* Segment file offset */
++ Elf64_Addr p_vaddr; /* Segment virtual address */
++ Elf64_Addr p_paddr; /* Segment physical address */
++ Elf64_Xword p_filesz; /* Segment size in file */
++ Elf64_Xword p_memsz; /* Segment size in memory */
++ Elf64_Xword p_align; /* Segment alignment */
++} Elf64_Phdr;
++
++/* Legal values for p_type (segment type). */
++
++#define PT_NULL 0 /* Program header table entry unused */
++#define PT_LOAD 1 /* Loadable program segment */
++#define PT_DYNAMIC 2 /* Dynamic linking information */
++#define PT_INTERP 3 /* Program interpreter */
++#define PT_NOTE 4 /* Auxiliary information */
++#define PT_SHLIB 5 /* Reserved */
++#define PT_PHDR 6 /* Entry for header table itself */
++#define PT_TLS 7 /* Thread-local storage segment */
++#define PT_NUM 8 /* Number of defined types */
++#define PT_LOOS 0x60000000 /* Start of OS-specific */
++#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
++#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
++#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
++#define PT_PAX_FLAGS 0x65041580 /* Indicates PaX flag markings */
++#define PT_LOSUNW 0x6ffffffa
++#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
++#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
++#define PT_HISUNW 0x6fffffff
++#define PT_HIOS 0x6fffffff /* End of OS-specific */
++#define PT_LOPROC 0x70000000 /* Start of processor-specific */
++#define PT_HIPROC 0x7fffffff /* End of processor-specific */
++
++/* Legal values for p_flags (segment flags). */
++
++#define PF_X (1 << 0) /* Segment is executable */
++#define PF_W (1 << 1) /* Segment is writable */
++#define PF_R (1 << 2) /* Segment is readable */
++#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
++#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
++#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
++#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
++#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
++#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
++#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
++#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
++#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
++#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
++#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
++#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
++#define PF_MASKOS 0x0ff00000 /* OS-specific */
++#define PF_MASKPROC 0xf0000000 /* Processor-specific */
++
++/* Legal values for note segment descriptor types for core files. */
++
++#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
++#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
++#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
++#define NT_PRXREG 4 /* Contains copy of prxregset struct */
++#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
++#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
++#define NT_AUXV 6 /* Contains copy of auxv array */
++#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
++#define NT_ASRS 8 /* Contains copy of asrset struct */
++#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
++#define NT_PSINFO 13 /* Contains copy of psinfo struct */
++#define NT_PRCRED 14 /* Contains copy of prcred struct */
++#define NT_UTSNAME 15 /* Contains copy of utsname struct */
++#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
++#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
++#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/
++
++/* Legal values for the note segment descriptor types for object files. */
++
++#define NT_VERSION 1 /* Contains a version string. */
++
++
++/* Dynamic section entry. */
++
++typedef struct
++{
++ Elf32_Sword d_tag; /* Dynamic entry type */
++ union
++ {
++ Elf32_Word d_val; /* Integer value */
++ Elf32_Addr d_ptr; /* Address value */
++ } d_un;
++} Elf32_Dyn;
++
++typedef struct
++{
++ Elf64_Sxword d_tag; /* Dynamic entry type */
++ union
++ {
++ Elf64_Xword d_val; /* Integer value */
++ Elf64_Addr d_ptr; /* Address value */
++ } d_un;
++} Elf64_Dyn;
++
++/* Legal values for d_tag (dynamic entry type). */
++
++#define DT_NULL 0 /* Marks end of dynamic section */
++#define DT_NEEDED 1 /* Name of needed library */
++#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
++#define DT_PLTGOT 3 /* Processor defined value */
++#define DT_HASH 4 /* Address of symbol hash table */
++#define DT_STRTAB 5 /* Address of string table */
++#define DT_SYMTAB 6 /* Address of symbol table */
++#define DT_RELA 7 /* Address of Rela relocs */
++#define DT_RELASZ 8 /* Total size of Rela relocs */
++#define DT_RELAENT 9 /* Size of one Rela reloc */
++#define DT_STRSZ 10 /* Size of string table */
++#define DT_SYMENT 11 /* Size of one symbol table entry */
++#define DT_INIT 12 /* Address of init function */
++#define DT_FINI 13 /* Address of termination function */
++#define DT_SONAME 14 /* Name of shared object */
++#define DT_RPATH 15 /* Library search path (deprecated) */
++#define DT_SYMBOLIC 16 /* Start symbol search here */
++#define DT_REL 17 /* Address of Rel relocs */
++#define DT_RELSZ 18 /* Total size of Rel relocs */
++#define DT_RELENT 19 /* Size of one Rel reloc */
++#define DT_PLTREL 20 /* Type of reloc in PLT */
++#define DT_DEBUG 21 /* For debugging; unspecified */
++#define DT_TEXTREL 22 /* Reloc might modify .text */
++#define DT_JMPREL 23 /* Address of PLT relocs */
++#define DT_BIND_NOW 24 /* Process relocations of object */
++#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
++#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
++#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
++#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
++#define DT_RUNPATH 29 /* Library search path */
++#define DT_FLAGS 30 /* Flags for the object being loaded */
++#define DT_ENCODING 32 /* Start of encoded range */
++#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
++#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
++#define DT_NUM 34 /* Number used */
++#define DT_LOOS 0x6000000d /* Start of OS-specific */
++#define DT_HIOS 0x6ffff000 /* End of OS-specific */
++#define DT_LOPROC 0x70000000 /* Start of processor-specific */
++#define DT_HIPROC 0x7fffffff /* End of processor-specific */
++#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
++
++/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
++ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
++ approach. */
++#define DT_VALRNGLO 0x6ffffd00
++#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
++#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
++#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
++#define DT_CHECKSUM 0x6ffffdf8
++#define DT_PLTPADSZ 0x6ffffdf9
++#define DT_MOVEENT 0x6ffffdfa
++#define DT_MOVESZ 0x6ffffdfb
++#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
++#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
++ the following DT_* entry. */
++#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
++#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
++#define DT_VALRNGHI 0x6ffffdff
++#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
++#define DT_VALNUM 12
++
++/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
++ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
++
++ If any adjustment is made to the ELF object after it has been
++ built these entries will need to be adjusted. */
++#define DT_ADDRRNGLO 0x6ffffe00
++#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
++#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
++#define DT_CONFIG 0x6ffffefa /* Configuration information. */
++#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
++#define DT_AUDIT 0x6ffffefc /* Object auditing. */
++#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
++#define DT_MOVETAB 0x6ffffefe /* Move table. */
++#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
++#define DT_ADDRRNGHI 0x6ffffeff
++#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
++#define DT_ADDRNUM 10
++
++/* The versioning entry types. The next are defined as part of the
++ GNU extension. */
++#define DT_VERSYM 0x6ffffff0
++
++#define DT_RELACOUNT 0x6ffffff9
++#define DT_RELCOUNT 0x6ffffffa
++
++/* These were chosen by Sun. */
++#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
++#define DT_VERDEF 0x6ffffffc /* Address of version definition
++ table */
++#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
++#define DT_VERNEED 0x6ffffffe /* Address of table with needed
++ versions */
++#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
++#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
++#define DT_VERSIONTAGNUM 16
++
++/* Sun added these machine-independent extensions in the "processor-specific"
++ range. Be compatible. */
++#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
++#define DT_FILTER 0x7fffffff /* Shared object to get values from */
++#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
++#define DT_EXTRANUM 3
++
++/* Values of `d_un.d_val' in the DT_FLAGS entry. */
++#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
++#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
++#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
++#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
++#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
++
++/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
++ entry in the dynamic section. */
++#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
++#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
++#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
++#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
++#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
++#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
++#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
++#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
++#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
++#define DF_1_TRANS 0x00000200
++#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
++#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
++#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
++#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
++#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
++#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
++#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
++
++/* Flags for the feature selection in DT_FEATURE_1. */
++#define DTF_1_PARINIT 0x00000001
++#define DTF_1_CONFEXP 0x00000002
++
++/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
++#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
++#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
++ generally available. */
++
++/* Version definition sections. */
++
++typedef struct
++{
++ Elf32_Half vd_version; /* Version revision */
++ Elf32_Half vd_flags; /* Version information */
++ Elf32_Half vd_ndx; /* Version Index */
++ Elf32_Half vd_cnt; /* Number of associated aux entries */
++ Elf32_Word vd_hash; /* Version name hash value */
++ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
++ Elf32_Word vd_next; /* Offset in bytes to next verdef
++ entry */
++} Elf32_Verdef;
++
++typedef struct
++{
++ Elf64_Half vd_version; /* Version revision */
++ Elf64_Half vd_flags; /* Version information */
++ Elf64_Half vd_ndx; /* Version Index */
++ Elf64_Half vd_cnt; /* Number of associated aux entries */
++ Elf64_Word vd_hash; /* Version name hash value */
++ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
++ Elf64_Word vd_next; /* Offset in bytes to next verdef
++ entry */
++} Elf64_Verdef;
++
++
++/* Legal values for vd_version (version revision). */
++#define VER_DEF_NONE 0 /* No version */
++#define VER_DEF_CURRENT 1 /* Current version */
++#define VER_DEF_NUM 2 /* Given version number */
++
++/* Legal values for vd_flags (version information flags). */
++#define VER_FLG_BASE 0x1 /* Version definition of file itself */
++#define VER_FLG_WEAK 0x2 /* Weak version identifier */
++
++/* Versym symbol index values. */
++#define VER_NDX_LOCAL 0 /* Symbol is local. */
++#define VER_NDX_GLOBAL 1 /* Symbol is global. */
++#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
++#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
++
++/* Auxialiary version information. */
++
++typedef struct
++{
++ Elf32_Word vda_name; /* Version or dependency names */
++ Elf32_Word vda_next; /* Offset in bytes to next verdaux
++ entry */
++} Elf32_Verdaux;
++
++typedef struct
++{
++ Elf64_Word vda_name; /* Version or dependency names */
++ Elf64_Word vda_next; /* Offset in bytes to next verdaux
++ entry */
++} Elf64_Verdaux;
++
++
++/* Version dependency section. */
++
++typedef struct
++{
++ Elf32_Half vn_version; /* Version of structure */
++ Elf32_Half vn_cnt; /* Number of associated aux entries */
++ Elf32_Word vn_file; /* Offset of filename for this
++ dependency */
++ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
++ Elf32_Word vn_next; /* Offset in bytes to next verneed
++ entry */
++} Elf32_Verneed;
++
++typedef struct
++{
++ Elf64_Half vn_version; /* Version of structure */
++ Elf64_Half vn_cnt; /* Number of associated aux entries */
++ Elf64_Word vn_file; /* Offset of filename for this
++ dependency */
++ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
++ Elf64_Word vn_next; /* Offset in bytes to next verneed
++ entry */
++} Elf64_Verneed;
++
++
++/* Legal values for vn_version (version revision). */
++#define VER_NEED_NONE 0 /* No version */
++#define VER_NEED_CURRENT 1 /* Current version */
++#define VER_NEED_NUM 2 /* Given version number */
++
++/* Auxiliary needed version information. */
++
++typedef struct
++{
++ Elf32_Word vna_hash; /* Hash value of dependency name */
++ Elf32_Half vna_flags; /* Dependency specific information */
++ Elf32_Half vna_other; /* Unused */
++ Elf32_Word vna_name; /* Dependency name string offset */
++ Elf32_Word vna_next; /* Offset in bytes to next vernaux
++ entry */
++} Elf32_Vernaux;
++
++typedef struct
++{
++ Elf64_Word vna_hash; /* Hash value of dependency name */
++ Elf64_Half vna_flags; /* Dependency specific information */
++ Elf64_Half vna_other; /* Unused */
++ Elf64_Word vna_name; /* Dependency name string offset */
++ Elf64_Word vna_next; /* Offset in bytes to next vernaux
++ entry */
++} Elf64_Vernaux;
++
++
++/* Legal values for vna_flags. */
++#define VER_FLG_WEAK 0x2 /* Weak version identifier */
++
++
++/* Auxiliary vector. */
++
++/* This vector is normally only used by the program interpreter. The
++ usual definition in an ABI supplement uses the name auxv_t. The
++ vector is not usually defined in a standard <elf.h> file, but it
++ can't hurt. We rename it to avoid conflicts. The sizes of these
++ types are an arrangement between the exec server and the program
++ interpreter, so we don't fully specify them here. */
++
++typedef struct
++{
++ uint32_t a_type; /* Entry type */
++ union
++ {
++ uint32_t a_val; /* Integer value */
++ /* We use to have pointer elements added here. We cannot do that,
++ though, since it does not work when using 32-bit definitions
++ on 64-bit platforms and vice versa. */
++ } a_un;
++} Elf32_auxv_t;
++
++typedef struct
++{
++ uint64_t a_type; /* Entry type */
++ union
++ {
++ uint64_t a_val; /* Integer value */
++ /* We use to have pointer elements added here. We cannot do that,
++ though, since it does not work when using 32-bit definitions
++ on 64-bit platforms and vice versa. */
++ } a_un;
++} Elf64_auxv_t;
++
++/* Legal values for a_type (entry type). */
++
++#define AT_NULL 0 /* End of vector */
++#define AT_IGNORE 1 /* Entry should be ignored */
++#define AT_EXECFD 2 /* File descriptor of program */
++#define AT_PHDR 3 /* Program headers for program */
++#define AT_PHENT 4 /* Size of program header entry */
++#define AT_PHNUM 5 /* Number of program headers */
++#define AT_PAGESZ 6 /* System page size */
++#define AT_BASE 7 /* Base address of interpreter */
++#define AT_FLAGS 8 /* Flags */
++#define AT_ENTRY 9 /* Entry point of program */
++#define AT_NOTELF 10 /* Program is not ELF */
++#define AT_UID 11 /* Real uid */
++#define AT_EUID 12 /* Effective uid */
++#define AT_GID 13 /* Real gid */
++#define AT_EGID 14 /* Effective gid */
++#define AT_CLKTCK 17 /* Frequency of times() */
++
++/* Some more special a_type values describing the hardware. */
++#define AT_PLATFORM 15 /* String identifying platform. */
++#define AT_HWCAP 16 /* Machine dependent hints about
++ processor capabilities. */
++
++/* This entry gives some information about the FPU initialization
++ performed by the kernel. */
++#define AT_FPUCW 18 /* Used FPU control word. */
++
++/* Cache block sizes. */
++#define AT_DCACHEBSIZE 19 /* Data cache block size. */
++#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
++#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
++
++/* A special ignored value for PPC, used by the kernel to control the
++ interpretation of the AUXV. Must be > 16. */
++#define AT_IGNOREPPC 22 /* Entry should be ignored. */
++
++#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
++
++/* Pointer to the global system page used for system calls and other
++ nice things. */
++#define AT_SYSINFO 32
++#define AT_SYSINFO_EHDR 33
++
++/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains
++ log2 of line size; mask those to get cache size. */
++#define AT_L1I_CACHESHAPE 34
++#define AT_L1D_CACHESHAPE 35
++#define AT_L2_CACHESHAPE 36
++#define AT_L3_CACHESHAPE 37
++
++/* Note section contents. Each entry in the note section begins with
++ a header of a fixed form. */
++
++typedef struct
++{
++ Elf32_Word n_namesz; /* Length of the note's name. */
++ Elf32_Word n_descsz; /* Length of the note's descriptor. */
++ Elf32_Word n_type; /* Type of the note. */
++} Elf32_Nhdr;
++
++typedef struct
++{
++ Elf64_Word n_namesz; /* Length of the note's name. */
++ Elf64_Word n_descsz; /* Length of the note's descriptor. */
++ Elf64_Word n_type; /* Type of the note. */
++} Elf64_Nhdr;
++
++/* Known names of notes. */
++
++/* Solaris entries in the note section have this name. */
++#define ELF_NOTE_SOLARIS "SUNW Solaris"
++
++/* Note entries for GNU systems have this name. */
++#define ELF_NOTE_GNU "GNU"
++
++
++/* Defined types of notes for Solaris. */
++
++/* Value of descriptor (one word) is desired pagesize for the binary. */
++#define ELF_NOTE_PAGESIZE_HINT 1
++
++
++/* Defined note types for GNU systems. */
++
++/* ABI information. The descriptor consists of words:
++ word 0: OS descriptor
++ word 1: major version of the ABI
++ word 2: minor version of the ABI
++ word 3: subminor version of the ABI
++*/
++#define ELF_NOTE_ABI 1
++
++/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI
++ note section entry. */
++#define ELF_NOTE_OS_LINUX 0
++#define ELF_NOTE_OS_GNU 1
++#define ELF_NOTE_OS_SOLARIS2 2
++#define ELF_NOTE_OS_FREEBSD 3
++
++
++/* Move records. */
++typedef struct
++{
++ Elf32_Xword m_value; /* Symbol value. */
++ Elf32_Word m_info; /* Size and index. */
++ Elf32_Word m_poffset; /* Symbol offset. */
++ Elf32_Half m_repeat; /* Repeat count. */
++ Elf32_Half m_stride; /* Stride info. */
++} Elf32_Move;
++
++typedef struct
++{
++ Elf64_Xword m_value; /* Symbol value. */
++ Elf64_Xword m_info; /* Size and index. */
++ Elf64_Xword m_poffset; /* Symbol offset. */
++ Elf64_Half m_repeat; /* Repeat count. */
++ Elf64_Half m_stride; /* Stride info. */
++} Elf64_Move;
++
++/* Macro to construct move records. */
++#define ELF32_M_SYM(info) ((info) >> 8)
++#define ELF32_M_SIZE(info) ((unsigned char) (info))
++#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
++
++#define ELF64_M_SYM(info) ELF32_M_SYM (info)
++#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
++#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
++
++
++/* Motorola 68k specific definitions. */
++
++/* Values for Elf32_Ehdr.e_flags. */
++#define EF_CPU32 0x00810000
++
++/* m68k relocs. */
++
++#define R_68K_NONE 0 /* No reloc */
++#define R_68K_32 1 /* Direct 32 bit */
++#define R_68K_16 2 /* Direct 16 bit */
++#define R_68K_8 3 /* Direct 8 bit */
++#define R_68K_PC32 4 /* PC relative 32 bit */
++#define R_68K_PC16 5 /* PC relative 16 bit */
++#define R_68K_PC8 6 /* PC relative 8 bit */
++#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
++#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
++#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
++#define R_68K_GOT32O 10 /* 32 bit GOT offset */
++#define R_68K_GOT16O 11 /* 16 bit GOT offset */
++#define R_68K_GOT8O 12 /* 8 bit GOT offset */
++#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
++#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
++#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
++#define R_68K_PLT32O 16 /* 32 bit PLT offset */
++#define R_68K_PLT16O 17 /* 16 bit PLT offset */
++#define R_68K_PLT8O 18 /* 8 bit PLT offset */
++#define R_68K_COPY 19 /* Copy symbol at runtime */
++#define R_68K_GLOB_DAT 20 /* Create GOT entry */
++#define R_68K_JMP_SLOT 21 /* Create PLT entry */
++#define R_68K_RELATIVE 22 /* Adjust by program base */
++/* Keep this the last entry. */
++#define R_68K_NUM 23
++
++/* Intel 80386 specific definitions. */
++
++/* i386 relocs. */
++
++#define R_386_NONE 0 /* No reloc */
++#define R_386_32 1 /* Direct 32 bit */
++#define R_386_PC32 2 /* PC relative 32 bit */
++#define R_386_GOT32 3 /* 32 bit GOT entry */
++#define R_386_PLT32 4 /* 32 bit PLT address */
++#define R_386_COPY 5 /* Copy symbol at runtime */
++#define R_386_GLOB_DAT 6 /* Create GOT entry */
++#define R_386_JMP_SLOT 7 /* Create PLT entry */
++#define R_386_RELATIVE 8 /* Adjust by program base */
++#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
++#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
++#define R_386_32PLT 11
++#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
++#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
++ block offset */
++#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
++ offset */
++#define R_386_TLS_LE 17 /* Offset relative to static TLS
++ block */
++#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
++ general dynamic thread local data */
++#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
++ local dynamic thread local data
++ in LE code */
++#define R_386_16 20
++#define R_386_PC16 21
++#define R_386_8 22
++#define R_386_PC8 23
++#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
++ thread local data */
++#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
++#define R_386_TLS_GD_CALL 26 /* Relocation for call to
++ __tls_get_addr() */
++#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
++#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
++ thread local data in LE code */
++#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
++#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
++ __tls_get_addr() in LDM code */
++#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
++#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
++#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
++ block offset */
++#define R_386_TLS_LE_32 34 /* Negated offset relative to static
++ TLS block */
++#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
++#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
++#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
++/* Keep this the last entry. */
++#define R_386_NUM 38
++
++/* FR-V specific definitions. */
++#define R_FRV_NONE 0 /* No reloc. */
++#define R_FRV_32 1 /* Direct 32 bit. */
++/* Canonical function descriptor address. */
++#define R_FRV_FUNCDESC 14
++/* Private function descriptor initialization. */
++#define R_FRV_FUNCDESC_VALUE 18
++
++ /* gpr support */
++#define EF_FRV_GPR_MASK 0x00000003 /* mask for # of gprs */
++#define EF_FRV_GPR_32 0x00000001 /* -mgpr-32 */
++#define EF_FRV_GPR_64 0x00000002 /* -mgpr-64 */
++
++ /* fpr support */
++#define EF_FRV_FPR_MASK 0x0000000c /* mask for # of fprs */
++#define EF_FRV_FPR_32 0x00000004 /* -mfpr-32 */
++#define EF_FRV_FPR_64 0x00000008 /* -mfpr-64 */
++#define EF_FRV_FPR_NONE 0x0000000c /* -msoft-float */
++
++#define EF_FRV_PIC 0x00000100
++#define EF_FRV_FDPIC 0x00008000
++
++/* SUN SPARC specific definitions. */
++
++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
++
++#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */
++
++/* Values for Elf64_Ehdr.e_flags. */
++
++#define EF_SPARCV9_MM 3
++#define EF_SPARCV9_TSO 0
++#define EF_SPARCV9_PSO 1
++#define EF_SPARCV9_RMO 2
++#define EF_SPARC_LEDATA 0x800000 /* little endian data */
++#define EF_SPARC_EXT_MASK 0xFFFF00
++#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
++#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
++#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
++#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
++
++/* SPARC relocs. */
++
++#define R_SPARC_NONE 0 /* No reloc */
++#define R_SPARC_8 1 /* Direct 8 bit */
++#define R_SPARC_16 2 /* Direct 16 bit */
++#define R_SPARC_32 3 /* Direct 32 bit */
++#define R_SPARC_DISP8 4 /* PC relative 8 bit */
++#define R_SPARC_DISP16 5 /* PC relative 16 bit */
++#define R_SPARC_DISP32 6 /* PC relative 32 bit */
++#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
++#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
++#define R_SPARC_HI22 9 /* High 22 bit */
++#define R_SPARC_22 10 /* Direct 22 bit */
++#define R_SPARC_13 11 /* Direct 13 bit */
++#define R_SPARC_LO10 12 /* Truncated 10 bit */
++#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
++#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
++#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
++#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
++#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
++#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
++#define R_SPARC_COPY 19 /* Copy symbol at runtime */
++#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
++#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
++#define R_SPARC_RELATIVE 22 /* Adjust by program base */
++#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
++
++/* Additional Sparc64 relocs. */
++
++#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
++#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
++#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
++#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
++#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
++#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
++#define R_SPARC_10 30 /* Direct 10 bit */
++#define R_SPARC_11 31 /* Direct 11 bit */
++#define R_SPARC_64 32 /* Direct 64 bit */
++#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
++#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
++#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
++#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
++#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
++#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
++#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
++#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
++#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
++#define R_SPARC_7 43 /* Direct 7 bit */
++#define R_SPARC_5 44 /* Direct 5 bit */
++#define R_SPARC_6 45 /* Direct 6 bit */
++#define R_SPARC_DISP64 46 /* PC relative 64 bit */
++#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
++#define R_SPARC_HIX22 48 /* High 22 bit complemented */
++#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
++#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
++#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
++#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
++#define R_SPARC_REGISTER 53 /* Global register usage */
++#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
++#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
++#define R_SPARC_TLS_GD_HI22 56
++#define R_SPARC_TLS_GD_LO10 57
++#define R_SPARC_TLS_GD_ADD 58
++#define R_SPARC_TLS_GD_CALL 59
++#define R_SPARC_TLS_LDM_HI22 60
++#define R_SPARC_TLS_LDM_LO10 61
++#define R_SPARC_TLS_LDM_ADD 62
++#define R_SPARC_TLS_LDM_CALL 63
++#define R_SPARC_TLS_LDO_HIX22 64
++#define R_SPARC_TLS_LDO_LOX10 65
++#define R_SPARC_TLS_LDO_ADD 66
++#define R_SPARC_TLS_IE_HI22 67
++#define R_SPARC_TLS_IE_LO10 68
++#define R_SPARC_TLS_IE_LD 69
++#define R_SPARC_TLS_IE_LDX 70
++#define R_SPARC_TLS_IE_ADD 71
++#define R_SPARC_TLS_LE_HIX22 72
++#define R_SPARC_TLS_LE_LOX10 73
++#define R_SPARC_TLS_DTPMOD32 74
++#define R_SPARC_TLS_DTPMOD64 75
++#define R_SPARC_TLS_DTPOFF32 76
++#define R_SPARC_TLS_DTPOFF64 77
++#define R_SPARC_TLS_TPOFF32 78
++#define R_SPARC_TLS_TPOFF64 79
++/* Keep this the last entry. */
++#define R_SPARC_NUM 80
++
++/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
++
++#define DT_SPARC_REGISTER 0x70000001
++#define DT_SPARC_NUM 2
++
++/* Bits present in AT_HWCAP, primarily for Sparc32. */
++
++#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */
++#define HWCAP_SPARC_STBAR 2
++#define HWCAP_SPARC_SWAP 4
++#define HWCAP_SPARC_MULDIV 8
++#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */
++#define HWCAP_SPARC_ULTRA3 32
++
++/* MIPS R3000 specific definitions. */
++
++/* Legal values for e_flags field of Elf32_Ehdr. */
++
++#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
++#define EF_MIPS_PIC 2 /* Contains PIC code */
++#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
++#define EF_MIPS_XGOT 8
++#define EF_MIPS_64BIT_WHIRL 16
++#define EF_MIPS_ABI2 32
++#define EF_MIPS_ABI_ON32 64
++#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
++
++/* Legal values for MIPS architecture level. */
++
++#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
++#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
++#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
++#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
++#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
++#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
++#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
++
++/* The following are non-official names and should not be used. */
++
++#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
++#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
++#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
++#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
++#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
++#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
++#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
++
++/* Special section indices. */
++
++#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
++#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
++#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
++#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
++#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
++
++/* Legal values for sh_type field of Elf32_Shdr. */
++
++#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
++#define SHT_MIPS_MSYM 0x70000001
++#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
++#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
++#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
++#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
++#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
++#define SHT_MIPS_PACKAGE 0x70000007
++#define SHT_MIPS_PACKSYM 0x70000008
++#define SHT_MIPS_RELD 0x70000009
++#define SHT_MIPS_IFACE 0x7000000b
++#define SHT_MIPS_CONTENT 0x7000000c
++#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
++#define SHT_MIPS_SHDR 0x70000010
++#define SHT_MIPS_FDESC 0x70000011
++#define SHT_MIPS_EXTSYM 0x70000012
++#define SHT_MIPS_DENSE 0x70000013
++#define SHT_MIPS_PDESC 0x70000014
++#define SHT_MIPS_LOCSYM 0x70000015
++#define SHT_MIPS_AUXSYM 0x70000016
++#define SHT_MIPS_OPTSYM 0x70000017
++#define SHT_MIPS_LOCSTR 0x70000018
++#define SHT_MIPS_LINE 0x70000019
++#define SHT_MIPS_RFDESC 0x7000001a
++#define SHT_MIPS_DELTASYM 0x7000001b
++#define SHT_MIPS_DELTAINST 0x7000001c
++#define SHT_MIPS_DELTACLASS 0x7000001d
++#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
++#define SHT_MIPS_DELTADECL 0x7000001f
++#define SHT_MIPS_SYMBOL_LIB 0x70000020
++#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
++#define SHT_MIPS_TRANSLATE 0x70000022
++#define SHT_MIPS_PIXIE 0x70000023
++#define SHT_MIPS_XLATE 0x70000024
++#define SHT_MIPS_XLATE_DEBUG 0x70000025
++#define SHT_MIPS_WHIRL 0x70000026
++#define SHT_MIPS_EH_REGION 0x70000027
++#define SHT_MIPS_XLATE_OLD 0x70000028
++#define SHT_MIPS_PDR_EXCEPTION 0x70000029
++
++/* Legal values for sh_flags field of Elf32_Shdr. */
++
++#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
++#define SHF_MIPS_MERGE 0x20000000
++#define SHF_MIPS_ADDR 0x40000000
++#define SHF_MIPS_STRINGS 0x80000000
++#define SHF_MIPS_NOSTRIP 0x08000000
++#define SHF_MIPS_LOCAL 0x04000000
++#define SHF_MIPS_NAMES 0x02000000
++#define SHF_MIPS_NODUPE 0x01000000
++
++
++/* Symbol tables. */
++
++/* MIPS specific values for `st_other'. */
++#define STO_MIPS_DEFAULT 0x0
++#define STO_MIPS_INTERNAL 0x1
++#define STO_MIPS_HIDDEN 0x2
++#define STO_MIPS_PROTECTED 0x3
++#define STO_MIPS_SC_ALIGN_UNUSED 0xff
++
++/* MIPS specific values for `st_info'. */
++#define STB_MIPS_SPLIT_COMMON 13
++
++/* Entries found in sections of type SHT_MIPS_GPTAB. */
++
++typedef union
++{
++ struct
++ {
++ Elf32_Word gt_current_g_value; /* -G value used for compilation */
++ Elf32_Word gt_unused; /* Not used */
++ } gt_header; /* First entry in section */
++ struct
++ {
++ Elf32_Word gt_g_value; /* If this value were used for -G */
++ Elf32_Word gt_bytes; /* This many bytes would be used */
++ } gt_entry; /* Subsequent entries in section */
++} Elf32_gptab;
++
++/* Entry found in sections of type SHT_MIPS_REGINFO. */
++
++typedef struct
++{
++ Elf32_Word ri_gprmask; /* General registers used */
++ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
++ Elf32_Sword ri_gp_value; /* $gp register value */
++} Elf32_RegInfo;
++
++/* Entries found in sections of type SHT_MIPS_OPTIONS. */
++
++typedef struct
++{
++ unsigned char kind; /* Determines interpretation of the
++ variable part of descriptor. */
++ unsigned char size; /* Size of descriptor, including header. */
++ Elf32_Section section; /* Section header index of section affected,
++ 0 for global options. */
++ Elf32_Word info; /* Kind-specific information. */
++} Elf_Options;
++
++/* Values for `kind' field in Elf_Options. */
++
++#define ODK_NULL 0 /* Undefined. */
++#define ODK_REGINFO 1 /* Register usage information. */
++#define ODK_EXCEPTIONS 2 /* Exception processing options. */
++#define ODK_PAD 3 /* Section padding options. */
++#define ODK_HWPATCH 4 /* Hardware workarounds performed */
++#define ODK_FILL 5 /* record the fill value used by the linker. */
++#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
++#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
++#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
++
++/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
++
++#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
++#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
++#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
++#define OEX_SMM 0x20000 /* Force sequential memory mode? */
++#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
++#define OEX_PRECISEFP OEX_FPDBUG
++#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
++
++#define OEX_FPU_INVAL 0x10
++#define OEX_FPU_DIV0 0x08
++#define OEX_FPU_OFLO 0x04
++#define OEX_FPU_UFLO 0x02
++#define OEX_FPU_INEX 0x01
++
++/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
++
++#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
++#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
++#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
++#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
++
++#define OPAD_PREFIX 0x1
++#define OPAD_POSTFIX 0x2
++#define OPAD_SYMBOL 0x4
++
++/* Entry found in `.options' section. */
++
++typedef struct
++{
++ Elf32_Word hwp_flags1; /* Extra flags. */
++ Elf32_Word hwp_flags2; /* Extra flags. */
++} Elf_Options_Hw;
++
++/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
++
++#define OHWA0_R4KEOP_CHECKED 0x00000001
++#define OHWA1_R4KEOP_CLEAN 0x00000002
++
++/* MIPS relocs. */
++
++#define R_MIPS_NONE 0 /* No reloc */
++#define R_MIPS_16 1 /* Direct 16 bit */
++#define R_MIPS_32 2 /* Direct 32 bit */
++#define R_MIPS_REL32 3 /* PC relative 32 bit */
++#define R_MIPS_26 4 /* Direct 26 bit shifted */
++#define R_MIPS_HI16 5 /* High 16 bit */
++#define R_MIPS_LO16 6 /* Low 16 bit */
++#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
++#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
++#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
++#define R_MIPS_PC16 10 /* PC relative 16 bit */
++#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
++#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
++
++#define R_MIPS_SHIFT5 16
++#define R_MIPS_SHIFT6 17
++#define R_MIPS_64 18
++#define R_MIPS_GOT_DISP 19
++#define R_MIPS_GOT_PAGE 20
++#define R_MIPS_GOT_OFST 21
++#define R_MIPS_GOT_HI16 22
++#define R_MIPS_GOT_LO16 23
++#define R_MIPS_SUB 24
++#define R_MIPS_INSERT_A 25
++#define R_MIPS_INSERT_B 26
++#define R_MIPS_DELETE 27
++#define R_MIPS_HIGHER 28
++#define R_MIPS_HIGHEST 29
++#define R_MIPS_CALL_HI16 30
++#define R_MIPS_CALL_LO16 31
++#define R_MIPS_SCN_DISP 32
++#define R_MIPS_REL16 33
++#define R_MIPS_ADD_IMMEDIATE 34
++#define R_MIPS_PJUMP 35
++#define R_MIPS_RELGOT 36
++#define R_MIPS_JALR 37
++#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
++#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
++#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
++#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
++#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
++#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
++#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
++#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
++#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
++#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
++#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
++#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
++#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
++/* Keep this the last entry. */
++#define R_MIPS_NUM 51
++
++/* Legal values for p_type field of Elf32_Phdr. */
++
++#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
++#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
++#define PT_MIPS_OPTIONS 0x70000002
++
++/* Special program header types. */
++
++#define PF_MIPS_LOCAL 0x10000000
++
++/* Legal values for d_tag field of Elf32_Dyn. */
++
++#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
++#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
++#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
++#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
++#define DT_MIPS_FLAGS 0x70000005 /* Flags */
++#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
++#define DT_MIPS_MSYM 0x70000007
++#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
++#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
++#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
++#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
++#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
++#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
++#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
++#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
++#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
++#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
++#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
++#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
++ DT_MIPS_DELTA_CLASS. */
++#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
++#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
++ DT_MIPS_DELTA_INSTANCE. */
++#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
++#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
++ DT_MIPS_DELTA_RELOC. */
++#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
++ relocations refer to. */
++#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
++ DT_MIPS_DELTA_SYM. */
++#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
++ class declaration. */
++#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
++ DT_MIPS_DELTA_CLASSSYM. */
++#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
++#define DT_MIPS_PIXIE_INIT 0x70000023
++#define DT_MIPS_SYMBOL_LIB 0x70000024
++#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
++#define DT_MIPS_LOCAL_GOTIDX 0x70000026
++#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
++#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
++#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
++#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
++#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
++#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
++#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
++ function stored in GOT. */
++#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
++ by rld on dlopen() calls. */
++#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
++#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
++#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
++#define DT_MIPS_NUM 0x32
++
++/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
++
++#define RHF_NONE 0 /* No flags */
++#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
++#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
++#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
++#define RHF_NO_MOVE (1 << 3)
++#define RHF_SGI_ONLY (1 << 4)
++#define RHF_GUARANTEE_INIT (1 << 5)
++#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
++#define RHF_GUARANTEE_START_INIT (1 << 7)
++#define RHF_PIXIE (1 << 8)
++#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
++#define RHF_REQUICKSTART (1 << 10)
++#define RHF_REQUICKSTARTED (1 << 11)
++#define RHF_CORD (1 << 12)
++#define RHF_NO_UNRES_UNDEF (1 << 13)
++#define RHF_RLD_ORDER_SAFE (1 << 14)
++
++/* Entries found in sections of type SHT_MIPS_LIBLIST. */
++
++typedef struct
++{
++ Elf32_Word l_name; /* Name (string table index) */
++ Elf32_Word l_time_stamp; /* Timestamp */
++ Elf32_Word l_checksum; /* Checksum */
++ Elf32_Word l_version; /* Interface version */
++ Elf32_Word l_flags; /* Flags */
++} Elf32_Lib;
++
++typedef struct
++{
++ Elf64_Word l_name; /* Name (string table index) */
++ Elf64_Word l_time_stamp; /* Timestamp */
++ Elf64_Word l_checksum; /* Checksum */
++ Elf64_Word l_version; /* Interface version */
++ Elf64_Word l_flags; /* Flags */
++} Elf64_Lib;
++
++
++/* Legal values for l_flags. */
++
++#define LL_NONE 0
++#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
++#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
++#define LL_REQUIRE_MINOR (1 << 2)
++#define LL_EXPORTS (1 << 3)
++#define LL_DELAY_LOAD (1 << 4)
++#define LL_DELTA (1 << 5)
++
++/* Entries found in sections of type SHT_MIPS_CONFLICT. */
++
++typedef Elf32_Addr Elf32_Conflict;
++
++
++/* HPPA specific definitions. */
++
++/* Legal values for e_flags field of Elf32_Ehdr. */
++
++#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
++#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
++#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
++#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
++#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
++ prediction. */
++#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
++#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
++
++/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
++
++#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
++#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
++#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
++
++/* Additional section indeces. */
++
++#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
++ symbols in ANSI C. */
++#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
++
++/* Legal values for sh_type field of Elf32_Shdr. */
++
++#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
++#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
++#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
++
++/* Legal values for sh_flags field of Elf32_Shdr. */
++
++#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
++#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
++#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
++
++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
++
++#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
++
++#define STT_HP_OPAQUE (STT_LOOS + 0x1)
++#define STT_HP_STUB (STT_LOOS + 0x2)
++
++/* HPPA relocs. */
++
++#define R_PARISC_NONE 0 /* No reloc. */
++#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
++#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
++#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
++#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
++#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
++#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
++#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
++#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
++#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
++#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
++#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
++#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
++#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
++#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
++#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
++#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
++#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
++#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
++#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
++#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
++#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
++#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
++#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
++#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
++#define R_PARISC_FPTR64 64 /* 64 bits function address. */
++#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
++#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
++#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
++#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
++#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
++#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
++#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
++#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
++#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
++#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
++#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
++#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
++#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
++#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
++#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
++#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
++#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
++#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
++#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
++#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
++#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
++#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
++#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
++#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
++#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
++#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
++#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
++#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
++#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
++#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
++#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
++#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
++#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
++#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
++#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
++#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
++#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
++#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
++#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
++#define R_PARISC_LORESERVE 128
++#define R_PARISC_COPY 128 /* Copy relocation. */
++#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
++#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
++#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
++#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
++#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
++#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
++#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
++#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
++#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
++#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
++#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
++#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
++#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
++#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
++#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
++#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
++#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
++#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
++#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
++#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
++#define R_PARISC_HIRESERVE 255
++
++/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
++
++#define PT_HP_TLS (PT_LOOS + 0x0)
++#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
++#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
++#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
++#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
++#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
++#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
++#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
++#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
++#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
++#define PT_HP_PARALLEL (PT_LOOS + 0x10)
++#define PT_HP_FASTBIND (PT_LOOS + 0x11)
++#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
++#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
++#define PT_HP_STACK (PT_LOOS + 0x14)
++
++#define PT_PARISC_ARCHEXT 0x70000000
++#define PT_PARISC_UNWIND 0x70000001
++
++/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
++
++#define PF_PARISC_SBP 0x08000000
++
++#define PF_HP_PAGE_SIZE 0x00100000
++#define PF_HP_FAR_SHARED 0x00200000
++#define PF_HP_NEAR_SHARED 0x00400000
++#define PF_HP_CODE 0x01000000
++#define PF_HP_MODIFY 0x02000000
++#define PF_HP_LAZYSWAP 0x04000000
++#define PF_HP_SBP 0x08000000
++
++
++/* Alpha specific definitions. */
++
++/* Legal values for e_flags field of Elf64_Ehdr. */
++
++#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
++#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
++
++/* Legal values for sh_type field of Elf64_Shdr. */
++
++/* These two are primerily concerned with ECOFF debugging info. */
++#define SHT_ALPHA_DEBUG 0x70000001
++#define SHT_ALPHA_REGINFO 0x70000002
++
++/* Legal values for sh_flags field of Elf64_Shdr. */
++
++#define SHF_ALPHA_GPREL 0x10000000
++
++/* Legal values for st_other field of Elf64_Sym. */
++#define STO_ALPHA_NOPV 0x80 /* No PV required. */
++#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
++
++/* Alpha relocs. */
++
++#define R_ALPHA_NONE 0 /* No reloc */
++#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
++#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
++#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
++#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
++#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
++#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
++#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
++#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
++#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
++#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
++#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
++#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
++#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
++#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
++#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
++#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
++#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
++#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
++#define R_ALPHA_TLS_GD_HI 28
++#define R_ALPHA_TLSGD 29
++#define R_ALPHA_TLS_LDM 30
++#define R_ALPHA_DTPMOD64 31
++#define R_ALPHA_GOTDTPREL 32
++#define R_ALPHA_DTPREL64 33
++#define R_ALPHA_DTPRELHI 34
++#define R_ALPHA_DTPRELLO 35
++#define R_ALPHA_DTPREL16 36
++#define R_ALPHA_GOTTPREL 37
++#define R_ALPHA_TPREL64 38
++#define R_ALPHA_TPRELHI 39
++#define R_ALPHA_TPRELLO 40
++#define R_ALPHA_TPREL16 41
++/* Keep this the last entry. */
++#define R_ALPHA_NUM 46
++
++/* Magic values of the LITUSE relocation addend. */
++#define LITUSE_ALPHA_ADDR 0
++#define LITUSE_ALPHA_BASE 1
++#define LITUSE_ALPHA_BYTOFF 2
++#define LITUSE_ALPHA_JSR 3
++#define LITUSE_ALPHA_TLS_GD 4
++#define LITUSE_ALPHA_TLS_LDM 5
++
++/* Legal values for d_tag of Elf64_Dyn. */
++#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
++#define DT_ALPHA_NUM 1
++
++/* PowerPC specific declarations */
++
++/* Values for Elf32/64_Ehdr.e_flags. */
++#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
++
++/* Cygnus local bits below */
++#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
++#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
++ flag */
++
++/* PowerPC relocations defined by the ABIs */
++#define R_PPC_NONE 0
++#define R_PPC_ADDR32 1 /* 32bit absolute address */
++#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
++#define R_PPC_ADDR16 3 /* 16bit absolute address */
++#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
++#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
++#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
++#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
++#define R_PPC_ADDR14_BRTAKEN 8
++#define R_PPC_ADDR14_BRNTAKEN 9
++#define R_PPC_REL24 10 /* PC relative 26 bit */
++#define R_PPC_REL14 11 /* PC relative 16 bit */
++#define R_PPC_REL14_BRTAKEN 12
++#define R_PPC_REL14_BRNTAKEN 13
++#define R_PPC_GOT16 14
++#define R_PPC_GOT16_LO 15
++#define R_PPC_GOT16_HI 16
++#define R_PPC_GOT16_HA 17
++#define R_PPC_PLTREL24 18
++#define R_PPC_COPY 19
++#define R_PPC_GLOB_DAT 20
++#define R_PPC_JMP_SLOT 21
++#define R_PPC_RELATIVE 22
++#define R_PPC_LOCAL24PC 23
++#define R_PPC_UADDR32 24
++#define R_PPC_UADDR16 25
++#define R_PPC_REL32 26
++#define R_PPC_PLT32 27
++#define R_PPC_PLTREL32 28
++#define R_PPC_PLT16_LO 29
++#define R_PPC_PLT16_HI 30
++#define R_PPC_PLT16_HA 31
++#define R_PPC_SDAREL16 32
++#define R_PPC_SECTOFF 33
++#define R_PPC_SECTOFF_LO 34
++#define R_PPC_SECTOFF_HI 35
++#define R_PPC_SECTOFF_HA 36
++
++/* PowerPC relocations defined for the TLS access ABI. */
++#define R_PPC_TLS 67 /* none (sym+add)@tls */
++#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
++#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
++#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
++#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
++#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
++#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
++#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
++#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
++#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
++#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
++#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
++#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
++#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
++#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
++#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
++#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
++#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
++#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
++#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
++#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
++#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
++#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
++#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
++#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
++#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
++#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
++#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
++
++/* Keep this the last entry. */
++#define R_PPC_NUM 95
++
++/* The remaining relocs are from the Embedded ELF ABI, and are not
++ in the SVR4 ELF ABI. */
++#define R_PPC_EMB_NADDR32 101
++#define R_PPC_EMB_NADDR16 102
++#define R_PPC_EMB_NADDR16_LO 103
++#define R_PPC_EMB_NADDR16_HI 104
++#define R_PPC_EMB_NADDR16_HA 105
++#define R_PPC_EMB_SDAI16 106
++#define R_PPC_EMB_SDA2I16 107
++#define R_PPC_EMB_SDA2REL 108
++#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
++#define R_PPC_EMB_MRKREF 110
++#define R_PPC_EMB_RELSEC16 111
++#define R_PPC_EMB_RELST_LO 112
++#define R_PPC_EMB_RELST_HI 113
++#define R_PPC_EMB_RELST_HA 114
++#define R_PPC_EMB_BIT_FLD 115
++#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
++
++/* Diab tool relocations. */
++#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
++#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
++#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
++#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
++#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
++#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
++
++/* GNU relocs used in PIC code sequences. */
++#define R_PPC_REL16 249 /* word32 (sym-.) */
++#define R_PPC_REL16_LO 250 /* half16 (sym-.)@l */
++#define R_PPC_REL16_HI 251 /* half16 (sym-.)@h */
++#define R_PPC_REL16_HA 252 /* half16 (sym-.)@ha */
++
++/* This is a phony reloc to handle any old fashioned TOC16 references
++ that may still be in object files. */
++#define R_PPC_TOC16 255
++
++/* PowerPC specific values for the Dyn d_tag field. */
++#define DT_PPC_GOT (DT_LOPROC + 0)
++#define DT_PPC_NUM 1
++
++/* PowerPC64 relocations defined by the ABIs */
++#define R_PPC64_NONE R_PPC_NONE
++#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
++#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
++#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
++#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
++#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
++#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
++#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
++#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
++#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
++#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
++#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
++#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
++#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
++#define R_PPC64_GOT16 R_PPC_GOT16
++#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
++#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
++#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
++
++#define R_PPC64_COPY R_PPC_COPY
++#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
++#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
++#define R_PPC64_RELATIVE R_PPC_RELATIVE
++
++#define R_PPC64_UADDR32 R_PPC_UADDR32
++#define R_PPC64_UADDR16 R_PPC_UADDR16
++#define R_PPC64_REL32 R_PPC_REL32
++#define R_PPC64_PLT32 R_PPC_PLT32
++#define R_PPC64_PLTREL32 R_PPC_PLTREL32
++#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
++#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
++#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
++
++#define R_PPC64_SECTOFF R_PPC_SECTOFF
++#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
++#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
++#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
++#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
++#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
++#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
++#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
++#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
++#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
++#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
++#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
++#define R_PPC64_PLT64 45 /* doubleword64 L + A */
++#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
++#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
++#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
++#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
++#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
++#define R_PPC64_TOC 51 /* doubleword64 .TOC */
++#define R_PPC64_PLTGOT16 52 /* half16* M + A */
++#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
++#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
++#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
++
++#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
++#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
++#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
++#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
++#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
++#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
++#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
++#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
++#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
++#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
++#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
++
++/* PowerPC64 relocations defined for the TLS access ABI. */
++#define R_PPC64_TLS 67 /* none (sym+add)@tls */
++#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
++#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
++#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
++#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
++#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
++#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
++#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
++#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
++#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
++#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
++#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
++#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
++#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
++#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
++#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
++#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
++#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
++#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
++#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
++#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
++#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
++#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
++#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
++#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
++#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
++#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
++#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
++#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
++#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
++#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
++#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
++#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
++#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
++#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
++#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
++#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
++#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
++#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
++#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
++
++/* Keep this the last entry. */
++#define R_PPC64_NUM 107
++
++/* PowerPC64 specific values for the Dyn d_tag field. */
++#define DT_PPC64_GLINK (DT_LOPROC + 0)
++#define DT_PPC64_OPD (DT_LOPROC + 1)
++#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
++#define DT_PPC64_NUM 3
++
++
++/* ARM specific declarations */
++
++/* Processor specific flags for the ELF header e_flags field. */
++#define EF_ARM_RELEXEC 0x01
++#define EF_ARM_HASENTRY 0x02
++#define EF_ARM_INTERWORK 0x04
++#define EF_ARM_APCS_26 0x08
++#define EF_ARM_APCS_FLOAT 0x10
++#define EF_ARM_PIC 0x20
++#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
++#define EF_ARM_NEW_ABI 0x80
++#define EF_ARM_OLD_ABI 0x100
++
++/* Other constants defined in the ARM ELF spec. version B-01. */
++/* NB. These conflict with values defined above. */
++#define EF_ARM_SYMSARESORTED 0x04
++#define EF_ARM_DYNSYMSUSESEGIDX 0x08
++#define EF_ARM_MAPSYMSFIRST 0x10
++#define EF_ARM_EABIMASK 0XFF000000
++
++#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
++#define EF_ARM_EABI_UNKNOWN 0x00000000
++#define EF_ARM_EABI_VER1 0x01000000
++#define EF_ARM_EABI_VER2 0x02000000
++
++/* Additional symbol types for Thumb */
++#define STT_ARM_TFUNC 0xd
++
++/* ARM-specific values for sh_flags */
++#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
++#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
++ in the input to a link step */
++
++/* ARM-specific program header flags */
++#define PF_ARM_SB 0x10000000 /* Segment contains the location
++ addressed by the static base */
++
++/* Processor specific values for the Phdr p_type field. */
++#define PT_ARM_EXIDX 0x70000001 /* .ARM.exidx segment */
++
++/* ARM relocs. */
++
++#define R_ARM_NONE 0 /* No reloc */
++#define R_ARM_PC24 1 /* PC relative 26 bit branch */
++#define R_ARM_ABS32 2 /* Direct 32 bit */
++#define R_ARM_REL32 3 /* PC relative 32 bit */
++#define R_ARM_PC13 4
++#define R_ARM_ABS16 5 /* Direct 16 bit */
++#define R_ARM_ABS12 6 /* Direct 12 bit */
++#define R_ARM_THM_ABS5 7
++#define R_ARM_ABS8 8 /* Direct 8 bit */
++#define R_ARM_SBREL32 9
++#define R_ARM_THM_PC22 10
++#define R_ARM_THM_PC8 11
++#define R_ARM_AMP_VCALL9 12
++#define R_ARM_SWI24 13
++#define R_ARM_THM_SWI8 14
++#define R_ARM_XPC25 15
++#define R_ARM_THM_XPC22 16
++#define R_ARM_COPY 20 /* Copy symbol at runtime */
++#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
++#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
++#define R_ARM_RELATIVE 23 /* Adjust by program base */
++#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
++#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
++#define R_ARM_GOT32 26 /* 32 bit GOT entry */
++#define R_ARM_PLT32 27 /* 32 bit PLT address */
++#define R_ARM_ALU_PCREL_7_0 32
++#define R_ARM_ALU_PCREL_15_8 33
++#define R_ARM_ALU_PCREL_23_15 34
++#define R_ARM_LDR_SBREL_11_0 35
++#define R_ARM_ALU_SBREL_19_12 36
++#define R_ARM_ALU_SBREL_27_20 37
++#define R_ARM_GNU_VTENTRY 100
++#define R_ARM_GNU_VTINHERIT 101
++#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
++#define R_ARM_THM_PC9 103 /* thumb conditional branch */
++#define R_ARM_RXPC25 249
++#define R_ARM_RSBREL32 250
++#define R_ARM_THM_RPC22 251
++#define R_ARM_RREL32 252
++#define R_ARM_RABS22 253
++#define R_ARM_RPC24 254
++#define R_ARM_RBASE 255
++/* Keep this the last entry. */
++#define R_ARM_NUM 256
++
++/* IA-64 specific declarations. */
++
++/* Processor specific flags for the Ehdr e_flags field. */
++#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
++#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
++#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
++
++/* Processor specific values for the Phdr p_type field. */
++#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
++#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
++#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
++#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
++#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
++
++/* Processor specific flags for the Phdr p_flags field. */
++#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
++
++/* Processor specific values for the Shdr sh_type field. */
++#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
++#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
++
++/* Processor specific flags for the Shdr sh_flags field. */
++#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
++#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
++
++/* Processor specific values for the Dyn d_tag field. */
++#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
++#define DT_IA_64_NUM 1
++
++/* IA-64 relocations. */
++#define R_IA64_NONE 0x00 /* none */
++#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
++#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
++#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
++#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
++#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
++#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
++#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
++#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
++#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
++#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
++#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
++#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
++#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
++#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
++#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
++#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
++#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
++#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
++#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
++#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
++#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
++#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
++#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
++#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
++#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
++#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
++#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
++#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
++#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
++#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
++#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
++#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
++#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
++#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
++#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
++#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
++#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
++#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
++#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
++#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
++#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
++#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
++#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
++#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
++#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
++#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
++#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
++#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
++#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
++#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
++#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
++#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
++#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
++#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
++#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
++#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
++#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
++#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
++#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
++#define R_IA64_COPY 0x84 /* copy relocation */
++#define R_IA64_SUB 0x85 /* Addend and symbol difference */
++#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
++#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
++#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
++#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
++#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
++#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
++#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
++#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
++#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
++#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
++#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
++#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
++#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
++#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
++#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
++#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
++#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
++#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
++#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
++
++/* SH specific declarations */
++
++/* SH specific values for `st_other'. */
++
++/* If set, this is a symbol pointing to SHmedia code, which will be branched
++ to, so need to add 1 to the symbol value. */
++#define STO_SH5_ISA32 (1 << 2)
++
++/* SH relocs. */
++#define R_SH_NONE 0
++#define R_SH_DIR32 1
++#define R_SH_REL32 2
++#define R_SH_DIR8WPN 3
++#define R_SH_IND12W 4
++#define R_SH_DIR8WPL 5
++#define R_SH_DIR8WPZ 6
++#define R_SH_DIR8BP 7
++#define R_SH_DIR8W 8
++#define R_SH_DIR8L 9
++#define R_SH_SWITCH16 25
++#define R_SH_SWITCH32 26
++#define R_SH_USES 27
++#define R_SH_COUNT 28
++#define R_SH_ALIGN 29
++#define R_SH_CODE 30
++#define R_SH_DATA 31
++#define R_SH_LABEL 32
++#define R_SH_SWITCH8 33
++#define R_SH_GNU_VTINHERIT 34
++#define R_SH_GNU_VTENTRY 35
++#define R_SH_TLS_GD_32 144
++#define R_SH_TLS_LD_32 145
++#define R_SH_TLS_LDO_32 146
++#define R_SH_TLS_IE_32 147
++#define R_SH_TLS_LE_32 148
++#define R_SH_TLS_DTPMOD32 149
++#define R_SH_TLS_DTPOFF32 150
++#define R_SH_TLS_TPOFF32 151
++#define R_SH_GOT32 160
++#define R_SH_PLT32 161
++#define R_SH_COPY 162
++#define R_SH_GLOB_DAT 163
++#define R_SH_JMP_SLOT 164
++#define R_SH_RELATIVE 165
++#define R_SH_GOTOFF 166
++#define R_SH_GOTPC 167
++#define R_SH_RELATIVE_LOW16 197
++#define R_SH_RELATIVE_MEDLOW16 198
++#define R_SH_IMM_LOW16 246
++#define R_SH_IMM_LOW16_PCREL 247
++#define R_SH_IMM_MEDLOW16 248
++#define R_SH_IMM_MEDLOW16_PCREL 249
++
++/* Keep this the last entry. */
++#define R_SH_NUM 256
++
++/* Additional s390 relocs */
++
++#define R_390_NONE 0 /* No reloc. */
++#define R_390_8 1 /* Direct 8 bit. */
++#define R_390_12 2 /* Direct 12 bit. */
++#define R_390_16 3 /* Direct 16 bit. */
++#define R_390_32 4 /* Direct 32 bit. */
++#define R_390_PC32 5 /* PC relative 32 bit. */
++#define R_390_GOT12 6 /* 12 bit GOT offset. */
++#define R_390_GOT32 7 /* 32 bit GOT offset. */
++#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
++#define R_390_COPY 9 /* Copy symbol at runtime. */
++#define R_390_GLOB_DAT 10 /* Create GOT entry. */
++#define R_390_JMP_SLOT 11 /* Create PLT entry. */
++#define R_390_RELATIVE 12 /* Adjust by program base. */
++#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
++#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
++#define R_390_GOT16 15 /* 16 bit GOT offset. */
++#define R_390_PC16 16 /* PC relative 16 bit. */
++#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
++#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
++#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
++#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
++#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
++#define R_390_64 22 /* Direct 64 bit. */
++#define R_390_PC64 23 /* PC relative 64 bit. */
++#define R_390_GOT64 24 /* 64 bit GOT offset. */
++#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
++#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
++#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
++#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
++#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
++#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
++#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
++#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
++#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
++#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
++#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
++#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
++#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
++#define R_390_TLS_GDCALL 38 /* Tag for function call in general
++ dynamic TLS code. */
++#define R_390_TLS_LDCALL 39 /* Tag for function call in local
++ dynamic TLS code. */
++#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
++ thread local data. */
++#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
++ thread local data. */
++#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
++ block offset. */
++#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
++ block offset. */
++#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
++ block offset. */
++#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
++ thread local data in LE code. */
++#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
++ thread local data in LE code. */
++#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
++ negated static TLS block offset. */
++#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
++ negated static TLS block offset. */
++#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
++ negated static TLS block offset. */
++#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
++ static TLS block. */
++#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
++ static TLS block. */
++#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
++ block. */
++#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
++ block. */
++#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
++#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
++#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
++ block. */
++#define R_390_20 57 /* Direct 20 bit. */
++#define R_390_GOT20 58 /* 20 bit GOT offset. */
++#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */
++#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS
++ block offset. */
++/* Keep this the last entry. */
++#define R_390_NUM 61
++
++
++/* CRIS flags. */
++#define EF_CRIS_VARIANT_MASK 0x0000000e
++#define EF_CRIS_VARIANT_ANY_V0_V10 0x00000000
++#define EF_CRIS_VARIANT_V32 0x00000002
++#define EF_CRIS_VARIANT_COMMON_V10_V32 0x00000004
++
++/* CRIS relocations. */
++#define R_CRIS_NONE 0
++#define R_CRIS_8 1
++#define R_CRIS_16 2
++#define R_CRIS_32 3
++#define R_CRIS_8_PCREL 4
++#define R_CRIS_16_PCREL 5
++#define R_CRIS_32_PCREL 6
++#define R_CRIS_GNU_VTINHERIT 7
++#define R_CRIS_GNU_VTENTRY 8
++#define R_CRIS_COPY 9
++#define R_CRIS_GLOB_DAT 10
++#define R_CRIS_JUMP_SLOT 11
++#define R_CRIS_RELATIVE 12
++#define R_CRIS_16_GOT 13
++#define R_CRIS_32_GOT 14
++#define R_CRIS_16_GOTPLT 15
++#define R_CRIS_32_GOTPLT 16
++#define R_CRIS_32_GOTREL 17
++#define R_CRIS_32_PLT_GOTREL 18
++#define R_CRIS_32_PLT_PCREL 19
++
++/* Keep this the last entry. */
++#define R_CRIS_NUM 20
++
++
++/* AMD x86-64 relocations. */
++#define R_X86_64_NONE 0 /* No reloc */
++#define R_X86_64_64 1 /* Direct 64 bit */
++#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
++#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
++#define R_X86_64_PLT32 4 /* 32 bit PLT address */
++#define R_X86_64_COPY 5 /* Copy symbol at runtime */
++#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
++#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
++#define R_X86_64_RELATIVE 8 /* Adjust by program base */
++#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
++ offset to GOT */
++#define R_X86_64_32 10 /* Direct 32 bit zero extended */
++#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
++#define R_X86_64_16 12 /* Direct 16 bit zero extended */
++#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
++#define R_X86_64_8 14 /* Direct 8 bit sign extended */
++#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
++#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
++#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
++#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
++#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
++ to two GOT entries for GD symbol */
++#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
++ to two GOT entries for LD symbol */
++#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
++#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
++ to GOT entry for IE symbol */
++#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
++
++#define R_X86_64_NUM 24
++
++
++/* AM33 relocations. */
++#define R_MN10300_NONE 0 /* No reloc. */
++#define R_MN10300_32 1 /* Direct 32 bit. */
++#define R_MN10300_16 2 /* Direct 16 bit. */
++#define R_MN10300_8 3 /* Direct 8 bit. */
++#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
++#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
++#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
++#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */
++#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */
++#define R_MN10300_24 9 /* Direct 24 bit. */
++#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */
++#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */
++#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */
++#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */
++#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */
++#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */
++#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */
++#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */
++#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */
++#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */
++#define R_MN10300_COPY 20 /* Copy symbol at runtime. */
++#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */
++#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */
++#define R_MN10300_RELATIVE 23 /* Adjust by program base. */
++
++#define R_MN10300_NUM 24
++
++
++/* M32R relocs. */
++#define R_M32R_NONE 0 /* No reloc. */
++#define R_M32R_16 1 /* Direct 16 bit. */
++#define R_M32R_32 2 /* Direct 32 bit. */
++#define R_M32R_24 3 /* Direct 24 bit. */
++#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */
++#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */
++#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */
++#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */
++#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */
++#define R_M32R_LO16 9 /* Low 16 bit. */
++#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */
++#define R_M32R_GNU_VTINHERIT 11
++#define R_M32R_GNU_VTENTRY 12
++/* M32R relocs use SHT_RELA. */
++#define R_M32R_16_RELA 33 /* Direct 16 bit. */
++#define R_M32R_32_RELA 34 /* Direct 32 bit. */
++#define R_M32R_24_RELA 35 /* Direct 24 bit. */
++#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */
++#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */
++#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */
++#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */
++#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */
++#define R_M32R_LO16_RELA 41 /* Low 16 bit */
++#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */
++#define R_M32R_RELA_GNU_VTINHERIT 43
++#define R_M32R_RELA_GNU_VTENTRY 44
++
++#define R_M32R_GOT24 48 /* 24 bit GOT entry */
++#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */
++#define R_M32R_COPY 50 /* Copy symbol at runtime */
++#define R_M32R_GLOB_DAT 51 /* Create GOT entry */
++#define R_M32R_JMP_SLOT 52 /* Create PLT entry */
++#define R_M32R_RELATIVE 53 /* Adjust by program base */
++#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */
++#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */
++#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned
++ low */
++#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed
++ low */
++#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */
++#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to
++ GOT with unsigned low */
++#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to
++ GOT with signed low */
++#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to
++ GOT */
++#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT
++ with unsigned low */
++#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT
++ with signed low */
++#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
++#define R_M32R_NUM 256 /* Keep this the last entry. */
++
++/* i960 Relocations */
++#define R_960_NONE 0
++#define R_960_12 1
++#define R_960_32 2
++#define R_960_IP24 3
++#define R_960_SUB 4
++#define R_960_OPTCALL 5
++#define R_960_OPTCALLX 6
++#define R_960_OPTCALLXA 7
++/* Keep this the last entry. */
++#define R_960_NUM 8
++
++
++/* v850 relocations. */
++#define R_V850_NONE 0
++#define R_V850_9_PCREL 1
++#define R_V850_22_PCREL 2
++#define R_V850_HI16_S 3
++#define R_V850_HI16 4
++#define R_V850_LO16 5
++#define R_V850_32 6
++#define R_V850_16 7
++#define R_V850_8 8
++#define R_V850_SDA_16_16_OFFSET 9 /* For ld.b, st.b, set1, clr1,
++ not1, tst1, movea, movhi */
++#define R_V850_SDA_15_16_OFFSET 10 /* For ld.w, ld.h, ld.hu, st.w, st.h */
++#define R_V850_ZDA_16_16_OFFSET 11 /* For ld.b, st.b, set1, clr1,
++ not1, tst1, movea, movhi */
++#define R_V850_ZDA_15_16_OFFSET 12 /* For ld.w, ld.h, ld.hu, st.w, st.h */
++#define R_V850_TDA_6_8_OFFSET 13 /* For sst.w, sld.w */
++#define R_V850_TDA_7_8_OFFSET 14 /* For sst.h, sld.h */
++#define R_V850_TDA_7_7_OFFSET 15 /* For sst.b, sld.b */
++#define R_V850_TDA_16_16_OFFSET 16 /* For set1, clr1, not1, tst1,
++ movea, movhi */
++/* CYGNUS LOCAL v850e */
++#define R_V850_TDA_4_5_OFFSET 17 /* For sld.hu */
++#define R_V850_TDA_4_4_OFFSET 18 /* For sld.bu */
++#define R_V850_SDA_16_16_SPLIT_OFFSET 19 /* For ld.bu */
++#define R_V850_ZDA_16_16_SPLIT_OFFSET 20 /* For ld.bu */
++#define R_V850_CALLT_6_7_OFFSET 21 /* For callt */
++#define R_V850_CALLT_16_16_OFFSET 22 /* For callt */
++/* END CYGNUS LOCAL */
++#define R_V850_GNU_VTINHERIT 23
++#define R_V850_GNU_VTENTRY 24
++/* Keep this the last entry. */
++#define R_V850_NUM 25
++
++
++/* Renesas H8/300 Relocations */
++#define R_H8_NONE 0
++#define R_H8_DIR32 1
++#define R_H8_DIR32_28 2
++#define R_H8_DIR32_24 3
++#define R_H8_DIR32_16 4
++#define R_H8_DIR32U 6
++#define R_H8_DIR32U_28 7
++#define R_H8_DIR32U_24 8
++#define R_H8_DIR32U_20 9
++#define R_H8_DIR32U_16 10
++#define R_H8_DIR24 11
++#define R_H8_DIR24_20 12
++#define R_H8_DIR24_16 13
++#define R_H8_DIR24U 14
++#define R_H8_DIR24U_20 15
++#define R_H8_DIR24U_16 16
++#define R_H8_DIR16 17
++#define R_H8_DIR16U 18
++#define R_H8_DIR16S_32 19
++#define R_H8_DIR16S_28 20
++#define R_H8_DIR16S_24 21
++#define R_H8_DIR16S_20 22
++#define R_H8_DIR16S 23
++#define R_H8_DIR8 24
++#define R_H8_DIR8U 25
++#define R_H8_DIR8Z_32 26
++#define R_H8_DIR8Z_28 27
++#define R_H8_DIR8Z_24 28
++#define R_H8_DIR8Z_20 29
++#define R_H8_DIR8Z_16 30
++#define R_H8_PCREL16 31
++#define R_H8_PCREL8 32
++#define R_H8_BPOS 33
++#define R_H8_PCREL32 34
++#define R_H8_GOT32O 35
++#define R_H8_GOT16O 36
++#define R_H8_DIR16A8 59
++#define R_H8_DIR16R8 60
++#define R_H8_DIR24A8 61
++#define R_H8_DIR24R8 62
++#define R_H8_DIR32A16 63
++#define R_H8_ABS32 65
++#define R_H8_ABS32A16 127
++#define R_H8_NUM 128
++
++/* NIOS relocations. */
++#define R_NIOS_NONE 0
++#define R_NIOS_32 1 /* A 32 bit absolute relocation.*/
++#define R_NIOS_LO16_LO5 2 /* A LO-16 5 bit absolute relocation. */
++#define R_NIOS_LO16_HI11 3 /* A LO-16 top 11 bit absolute relocation. */
++#define R_NIOS_HI16_LO5 4 /* A HI-16 5 bit absolute relocation. */
++#define R_NIOS_HI16_HI11 5 /* A HI-16 top 11 bit absolute relocation. */
++#define R_NIOS_PCREL6 6 /* A 6 bit relative relocation. */
++#define R_NIOS_PCREL8 7 /* An 8 bit relative relocation. */
++#define R_NIOS_PCREL11 8 /* An 11 bit relative relocation. */
++#define R_NIOS_16 9 /* A 16 bit absolute relocation. */
++#define R_NIOS_H_LO5 10 /* Low 5-bits of absolute relocation in halfwords. */
++#define R_NIOS_H_HI11 11 /* Top 11 bits of 16-bit absolute relocation in halfwords. */
++#define R_NIOS_H_XLO5 12 /* Low 5 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
++#define R_NIOS_H_XHI11 13 /* Top 11 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
++#define R_NIOS_H_16 14 /* Half-word @h value */
++#define R_NIOS_H_32 15 /* Word @h value */
++#define R_NIOS_GNU_VTINHERIT 200 /* GNU extension to record C++ vtable hierarchy */
++#define R_NIOS_GNU_VTENTRY 201 /* GNU extension to record C++ vtable member usage */
++/* Keep this the last entry. */
++#define R_NIOS_NUM 202
++
++/* NIOS II relocations */
++#define R_NIOS2_NONE 0
++#define R_NIOS2_S16 1
++#define R_NIOS2_U16 2
++#define R_NIOS2_PCREL16 3
++#define R_NIOS2_CALL26 4
++#define R_NIOS2_IMM5 5
++#define R_NIOS2_CACHE_OPX 6
++#define R_NIOS2_IMM6 7
++#define R_NIOS2_IMM8 8
++#define R_NIOS2_HI16 9
++#define R_NIOS2_LO16 10
++#define R_NIOS2_HIADJ16 11
++#define R_NIOS2_BFD_RELOC_32 12
++#define R_NIOS2_BFD_RELOC_16 13
++#define R_NIOS2_BFD_RELOC_8 14
++#define R_NIOS2_GPREL 15
++#define R_NIOS2_GNU_VTINHERIT 16
++#define R_NIOS2_GNU_VTENTRY 17
++#define R_NIOS2_UJMP 18
++#define R_NIOS2_CJMP 19
++#define R_NIOS2_CALLR 20
++#define R_NIOS2_ALIGN 21
++/* Keep this the last entry. */
++#define R_NIOS2_NUM 22
++
++__END_DECLS
++
++#endif /* elf.h */
+diff -Nrup a/ldso/include/dl-string.h b/ldso/include/dl-string.h
+--- a/ldso/include/dl-string.h 2007-01-25 19:22:03.000000000 -0500
++++ b/ldso/include/dl-string.h 2008-02-28 19:03:13.000000000 -0500
+@@ -285,7 +285,9 @@ static __always_inline char * _dl_simple
+ /* On some arches constant strings are referenced through the GOT.
+ * This requires that load_addr must already be defined... */
+ #if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
+- defined(__mips__) || defined(__sh__) || defined(__powerpc__)
++ defined(__mips__) || defined(__sh__) || defined(__powerpc__) || \
++ defined(__avr32__)
++
+ # define CONSTANT_STRING_GOT_FIXUP(X) \
+ if ((X) < (const char *) load_addr) (X) += load_addr
+ # define NO_EARLY_SEND_STDERR
+diff -Nrup a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
+--- a/ldso/include/dl-syscall.h 2007-01-28 00:51:31.000000000 -0500
++++ b/ldso/include/dl-syscall.h 2008-02-28 19:06:04.000000000 -0500
+@@ -54,69 +54,69 @@
+ dynamic linking at all, so we cannot return any error codes.
+ We just punt if there is an error. */
+ #define __NR__dl_exit __NR_exit
+-static inline _syscall1(void, _dl_exit, int, status);
++static __always_inline _syscall1(void, _dl_exit, int, status);
+
+ #define __NR__dl_close __NR_close
+-static inline _syscall1(int, _dl_close, int, fd);
++static __always_inline _syscall1(int, _dl_close, int, fd);
+
+ #define __NR__dl_open __NR_open
+-static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
++static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
+ __kernel_mode_t, mode);
+
+ #define __NR__dl_write __NR_write
+-static inline _syscall3(unsigned long, _dl_write, int, fd,
++static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
+ const void *, buf, unsigned long, count);
+
+ #define __NR__dl_read __NR_read
+-static inline _syscall3(unsigned long, _dl_read, int, fd,
++static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
+ const void *, buf, unsigned long, count);
+
+ #define __NR__dl_mprotect __NR_mprotect
+-static inline _syscall3(int, _dl_mprotect, const void *, addr,
++static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
+ unsigned long, len, int, prot);
+
+ #define __NR__dl_stat __NR_stat
+-static inline _syscall2(int, _dl_stat, const char *, file_name,
++static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
+ struct stat *, buf);
+
+ #define __NR__dl_fstat __NR_fstat
+-static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
++static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
+
+ #define __NR__dl_munmap __NR_munmap
+-static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
++static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
+
+ #ifdef __NR_getxuid
+ # define __NR_getuid __NR_getxuid
+ #endif
+ #define __NR__dl_getuid __NR_getuid
+-static inline _syscall0(uid_t, _dl_getuid);
++static __always_inline _syscall0(uid_t, _dl_getuid);
+
+ #ifndef __NR_geteuid
+ # define __NR_geteuid __NR_getuid
+ #endif
+ #define __NR__dl_geteuid __NR_geteuid
+-static inline _syscall0(uid_t, _dl_geteuid);
++static __always_inline _syscall0(uid_t, _dl_geteuid);
+
+ #ifdef __NR_getxgid
+ # define __NR_getgid __NR_getxgid
+ #endif
+ #define __NR__dl_getgid __NR_getgid
+-static inline _syscall0(gid_t, _dl_getgid);
++static __always_inline _syscall0(gid_t, _dl_getgid);
+
+ #ifndef __NR_getegid
+ # define __NR_getegid __NR_getgid
+ #endif
+ #define __NR__dl_getegid __NR_getegid
+-static inline _syscall0(gid_t, _dl_getegid);
++static __always_inline _syscall0(gid_t, _dl_getegid);
+
+ #ifdef __NR_getxpid
+ # define __NR_getpid __NR_getxpid
+ #endif
+ #define __NR__dl_getpid __NR_getpid
+-static inline _syscall0(gid_t, _dl_getpid);
++static __always_inline _syscall0(gid_t, _dl_getpid);
+
+ #define __NR__dl_readlink __NR_readlink
+-static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
++static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
+ size_t, bufsiz);
+
+
+@@ -134,14 +134,14 @@ static inline _syscall3(int, _dl_readlin
+ #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
+
+ # define __NR__dl_mmap __NR_mmap
+-static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
++static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
+ int, prot, int, flags, int, fd, off_t, offset);
+
+ /* then try mmap2() */
+ #elif defined(__NR_mmap2)
+
+ # define __NR___syscall_mmap2 __NR_mmap2
+-static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
++static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
+ int, prot, int, flags, int, fd, off_t, offset);
+
+ /* Some architectures always use 12 as page shift for mmap2() eventhough the
+@@ -152,7 +152,7 @@ static inline _syscall6(__ptr_t, __sysca
+ # define MMAP2_PAGE_SHIFT 12
+ #endif
+
+-static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
++static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+ int flags, int fd, unsigned long offset)
+ {
+ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
+@@ -165,8 +165,8 @@ static inline void * _dl_mmap(void * add
+ #elif defined(__NR_mmap)
+
+ # define __NR__dl_mmap_real __NR_mmap
+-static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
+-static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
++static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
++static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+ int flags, int fd, unsigned long offset)
+ {
+ unsigned long buffer[6];
+diff -Nrup a/ldso/ldso/avr32/dl-debug.h b/ldso/ldso/avr32/dl-debug.h
+--- a/ldso/ldso/avr32/dl-debug.h 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/dl-debug.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,45 @@
++/*
++ * AVR32 ELF shared libary loader support
++ *
++ * Copyright (C) 2005 Atmel Norway
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. The name of the above contributors may not be
++ * used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++static const char *_dl_reltypes_tab[] = {
++ "R_AVR32_NONE",
++ "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
++ "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
++ "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
++ "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
++ "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
++ "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
++ "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
++ "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
++ "R_AVR32_HI16", "R_AVR32_LO16",
++ "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
++ "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
++ "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
++ "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
++ "R_AVR32_ALIGN",
++};
+diff -Nrup a/ldso/ldso/avr32/dl-startup.h b/ldso/ldso/avr32/dl-startup.h
+--- a/ldso/ldso/avr32/dl-startup.h 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/dl-startup.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,110 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * Architecture specific code used by dl-startup.c
++ * Copyright (C) 2005 Atmel Norway
++ */
++
++/* This is the library loader's main entry point. Let _dl_boot2 do its
++ * initializations and jump to the application's entry point
++ * afterwards. */
++asm( " .text\n"
++ " .global _start\n"
++ " .type _start,@function\n"
++ "_start:\n"
++ /* All arguments are on the stack initially */
++ " mov r12, sp\n"
++ " rcall _dl_start\n"
++ /* Returns user entry point in r12. Save it. */
++ " mov r0, r12\n"
++ /* We're PIC, so get the Global Offset Table */
++ " lddpc r6, .L_GOT\n"
++ ".L_RGOT:\n"
++ " rsub r6, pc\n"
++ /* Adjust argc and argv according to _dl_skip_args */
++ " ld.w r1, r6[_dl_skip_args@got]\n"
++ " ld.w r1, r1[0]\n"
++ " ld.w r2, sp++\n"
++ " sub r2, r1\n"
++ " add sp, sp, r1 << 2\n"
++ " st.w --sp, r2\n"
++ /* Load the finalizer function */
++ " ld.w r12, r6[_dl_fini@got]\n"
++ /* Jump to the user's entry point */
++ " mov pc, r0\n\n"
++
++ " .align 2\n"
++ ".L_GOT:"
++ " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
++ " .size _start, . - _start\n"
++ " .previous\n");
++
++/* Get a pointer to the argv array. On many platforms this can be just
++ * the address if the first argument, on other platforms we need to
++ * do something a little more subtle here. */
++#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
++
++
++/* We can't call functions before the GOT has been initialized */
++#define NO_FUNCS_BEFORE_BOOTSTRAP
++
++/*
++ * Relocate the GOT during dynamic loader bootstrap. This will add
++ * the load address to all entries in the GOT, which is necessary
++ * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
++ * GOT.
++ */
++static __always_inline
++void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
++{
++ Elf32_Addr i, nr_got;
++ register Elf32_Addr *__r6 __asm__("r6");
++ Elf32_Addr *got = __r6;
++
++ nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
++ for (i = 2; i < nr_got; i++)
++ got[i] += tpnt->loadaddr;
++}
++
++#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
++
++/* Handle relocation of the symbols in the dynamic loader. */
++static __always_inline
++void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
++ unsigned long symbol_addr,
++ unsigned long load_addr, Elf32_Sym *symtab)
++{
++ switch(ELF32_R_TYPE(rpnt->r_info)) {
++ case R_AVR32_NONE:
++ break;
++ case R_AVR32_GLOB_DAT:
++ case R_AVR32_JMP_SLOT:
++ *reloc_addr = symbol_addr;
++ break;
++ case R_AVR32_RELATIVE:
++ SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
++ SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
++ SEND_STDERR_DEBUG(" + ");
++ SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
++ *reloc_addr = load_addr + rpnt->r_addend;
++ break;
++ default:
++ SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
++ SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
++ SEND_STDERR("REL, SYMBOL, LOAD: ");
++ SEND_ADDRESS_STDERR(reloc_addr, 0);
++ SEND_STDERR(", ");
++ SEND_ADDRESS_STDERR(symbol_addr, 0);
++ SEND_STDERR(", ");
++ SEND_ADDRESS_STDERR(load_addr, 1);
++ _dl_exit(1);
++ }
++}
++
++/* Transfer control to the user's application, once the dynamic loader
++ * is done. This routine has to exit the current function, then call
++ * the _dl_elf_main function.
++ *
++ * Since our _dl_boot will simply call whatever is returned by
++ * _dl_boot2, we can just return the address we're supposed to
++ * call. */
++#define START() return _dl_elf_main;
+diff -Nrup a/ldso/ldso/avr32/dl-syscalls.h b/ldso/ldso/avr32/dl-syscalls.h
+--- a/ldso/ldso/avr32/dl-syscalls.h 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/dl-syscalls.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,5 @@
++/* We can't use the real errno in ldso, since it has not yet
++ * been dynamicly linked in yet. */
++extern int _dl_errno;
++#define __set_errno(X) {(_dl_errno) = (X);}
++#include "sys/syscall.h"
+diff -Nrup a/ldso/ldso/avr32/dl-sysdep.h b/ldso/ldso/avr32/dl-sysdep.h
+--- a/ldso/ldso/avr32/dl-sysdep.h 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/dl-sysdep.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,103 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * Various assembly language/system dependent hacks that are required
++ * so that we can minimize the amount of platform specific code.
++ * Copyright (C) 2004-2005 Atmel Norway
++ */
++
++/* Define this if the system uses RELOCA. */
++#define ELF_USES_RELOCA
++
++#include <elf.h>
++
++#define ARCH_NUM 1
++#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM)
++
++#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
++ do { \
++ if (dpnt->d_tag == DT_AVR32_GOTSZ) \
++ dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
++ } while (0)
++
++/* Initialization sequence for the application/library GOT. */
++#define INIT_GOT(GOT_BASE,MODULE) \
++ do { \
++ unsigned long i, nr_got; \
++ \
++ GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
++ GOT_BASE[1] = (unsigned long) MODULE; \
++ \
++ /* Add load address displacement to all GOT entries */ \
++ nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
++ for (i = 2; i < nr_got; i++) \
++ GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
++ } while (0)
++
++#define do_rem(result, n, base) ((result) = (n) % (base))
++
++/* Here we define the magic numbers that this dynamic loader should accept */
++#define MAGIC1 EM_AVR32
++#undef MAGIC2
++
++/* Used for error messages */
++#define ELF_TARGET "AVR32"
++
++unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
++
++/* 4096 bytes alignment */
++#define PAGE_ALIGN 0xfffff000
++#define ADDR_ALIGN 0xfff
++#define OFFS_ALIGN 0x7ffff000
++
++#define elf_machine_type_class(type) \
++ ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
++
++/* AVR32 doesn't need any COPY relocs */
++#define DL_NO_COPY_RELOCS
++
++/* Return the link-time address of _DYNAMIC. Conveniently, this is the
++ first element of the GOT. This must be inlined in a function which
++ uses global data. */
++static inline Elf32_Addr
++elf_machine_dynamic (void)
++{
++ register Elf32_Addr *got asm ("r6");
++ return *got;
++}
++
++/* Return the run-time load address of the shared object. */
++static inline Elf32_Addr
++elf_machine_load_address (void)
++{
++ extern void __dl_start asm("_dl_start");
++ Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
++ Elf32_Addr pcrel_addr;
++
++ asm (" lddpc %0, 2f\n"
++ "1: add %0, pc\n"
++ " rjmp 3f\n"
++ " .align 2\n"
++ "2: .long _dl_start - 1b\n"
++ "3:\n"
++ : "=r"(pcrel_addr) : : "cc");
++
++ return pcrel_addr - got_addr;
++}
++
++/*
++ * Perform any RELATIVE relocations specified by DT_RELCOUNT.
++ * Currently, we don't use that tag, but we might in the future as
++ * this would reduce the startup time somewhat (although probably not by much).
++ */
++static inline void
++elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
++ Elf32_Word relative_count)
++{
++ Elf32_Rela *rpnt = (void *)rel_addr;
++
++ do {
++ Elf32_Addr *reloc_addr;
++ reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
++ *reloc_addr = load_off + rpnt->r_addend;
++ } while (--relative_count);
++}
+diff -Nrup a/ldso/ldso/avr32/elfinterp.c b/ldso/ldso/avr32/elfinterp.c
+--- a/ldso/ldso/avr32/elfinterp.c 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/elfinterp.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,191 @@
++/*
++ * AVR32 ELF shared library loader suppport
++ *
++ * Copyright (C) 2004-2006 Atmel Corporation
++ *
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. The name of the above contributors may not be
++ * used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
++{
++ struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
++ Elf32_Sym *sym;
++ unsigned long local_gotno;
++ unsigned long gotsym;
++ unsigned long new_addr;
++ char *strtab, *symname;
++ unsigned long *entry;
++ unsigned long sym_index = got_offset / 4;
++
++#if 0
++ local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
++ gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
++
++ sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
++ + sym_index;
++ strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
++ symname = strtab + sym->st_name;
++
++#if 0
++ new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
++ tpnt->symbol_scope, tpnt,
++ resolver);
++#endif
++
++ entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
++ *entry = new_addr;
++#endif
++
++ return new_addr;
++}
++
++static int
++_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ unsigned long rel_addr, unsigned long rel_size,
++ int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
++{
++ Elf32_Sym *symtab;
++ Elf32_Rela *rpnt;
++ char *strtab;
++ int i;
++
++ rpnt = (Elf32_Rela *)rel_addr;
++ rel_size /= sizeof(Elf32_Rela);
++ symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
++ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
++
++ for (i = 0; i < rel_size; i++, rpnt++) {
++ int symtab_index, res;
++
++ symtab_index = ELF32_R_SYM(rpnt->r_info);
++
++ debug_sym(symtab, strtab, symtab_index);
++ debug_reloc(symtab, strtab, rpnt);
++
++ res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
++
++ if (res == 0)
++ continue;
++
++ _dl_dprintf(2, "\n%s: ", _dl_progname);
++
++ if (symtab_index)
++ _dl_dprintf(2, "symbol '%s': ",
++ strtab + symtab[symtab_index].st_name);
++
++ if (res < 0) {
++ int reloc_type = ELF32_R_TYPE(rpnt->r_info);
++#if defined(__SUPPORT_LD_DEBUG__)
++ _dl_dprintf(2, "can't handle reloc type %s\n",
++ _dl_reltypes(reloc_type));
++#else
++ _dl_dprintf(2, "can't handle reloc type %x\n",
++ reloc_type);
++#endif
++ _dl_exit(-res);
++ } else {
++ _dl_dprintf(2, "can't resolve symbol\n");
++ return res;
++ }
++ }
++
++ return 0;
++}
++
++static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
++{
++ int reloc_type;
++ int symtab_index;
++ char *symname;
++ unsigned long *reloc_addr;
++ unsigned long symbol_addr;
++#if defined(__SUPPORT_LD_DEBUG__)
++ unsigned long old_val;
++#endif
++
++ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
++ reloc_type = ELF32_R_TYPE(rpnt->r_info);
++ symtab_index = ELF32_R_SYM(rpnt->r_info);
++ symbol_addr = 0;
++ symname = strtab + symtab[symtab_index].st_name;
++
++ if (symtab_index) {
++ symbol_addr = (unsigned long)
++ _dl_find_hash(strtab + symtab[symtab_index].st_name,
++ tpnt->symbol_scope, tpnt,
++ elf_machine_type_class(reloc_type));
++
++ /* Allow undefined references to weak symbols */
++ if (!symbol_addr &&
++ ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
++ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
++ _dl_progname, symname);
++ return 0;
++ }
++ }
++
++#if defined(__SUPPORT_LD_DEBUG__)
++ old_val = *reloc_addr;
++#endif
++ switch (reloc_type) {
++ case R_AVR32_NONE:
++ break;
++ case R_AVR32_GLOB_DAT:
++ case R_AVR32_JMP_SLOT:
++ *reloc_addr = symbol_addr + rpnt->r_addend;
++ break;
++ case R_AVR32_RELATIVE:
++ *reloc_addr = (unsigned long)tpnt->loadaddr
++ + rpnt->r_addend;
++ break;
++ default:
++ return -1;
++ }
++
++#if defined(__SUPPORT_LD_DEBUG__)
++ if (_dl_debug_reloc && _dl_debug_detail)
++ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
++ old_val, *reloc_addr);
++#endif
++
++ return 0;
++}
++
++void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
++ unsigned long rel_addr,
++ unsigned long rel_size)
++{
++ /* TODO: Might want to support this in order to get faster
++ * startup times... */
++}
++
++int _dl_parse_relocation_information(struct dyn_elf *rpnt,
++ unsigned long rel_addr,
++ unsigned long rel_size)
++{
++ return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
++ _dl_do_reloc);
++}
+diff -Nrup a/ldso/ldso/avr32/resolve.S b/ldso/ldso/avr32/resolve.S
+--- a/ldso/ldso/avr32/resolve.S 1969-12-31 19:00:00.000000000 -0500
++++ b/ldso/ldso/avr32/resolve.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,28 @@
++/*
++ * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
++ * indicated in register r12 and jumps to the resolved address.
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ *
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define ip r5
++
++ .text
++ .global _dl_linux_resolve
++ .type _dl_linux_resolve,@function
++_dl_linux_resolve:
++ /* The PLT code pushed r8 for us. It contains the address of this
++ function's GOT entry, that is entry 0. ip contains the address
++ of the GOT entry of the function we wanted to call. */
++ stm --sp, r9-r12, lr
++ mov r11, r8
++ sub r12, ip, r8
++ rcall _dl_linux_resolver
++ mov ip, r12
++ popm r8-r12,lr
++ mov pc, ip
++ .size _dl_linux_resolve, . - _dl_linux_resolve
+diff -Nrup a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
+--- a/ldso/ldso/dl-startup.c 2007-01-25 19:22:03.000000000 -0500
++++ b/ldso/ldso/dl-startup.c 2008-02-28 19:02:10.000000000 -0500
+@@ -217,7 +217,9 @@ static void * __attribute_used__ _dl_sta
+ /* some arches (like MIPS) we have to tweak the GOT before relocations */
+ PERFORM_BOOTSTRAP_GOT(tpnt);
+
+-#else
++#endif
++
++#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
+
+ /* OK, now do the relocations. We do not do a lazy binding here, so
+ that once we are done, we have considerably more flexibility. */
+@@ -259,7 +261,7 @@ static void * __attribute_used__ _dl_sta
+ rel_addr += relative_count * sizeof(ELF_RELOC);;
+ }
+
+- rpnt = (ELF_RELOC *) (rel_addr + load_addr);
++ rpnt = (ELF_RELOC *) (rel_addr /* + load_addr */);
+ for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
+ reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+diff -Nrup a/libc/Makefile b/libc/Makefile
+--- a/libc/Makefile 2007-02-28 16:23:09.000000000 -0500
++++ b/libc/Makefile 2008-02-28 19:02:10.000000000 -0500
+@@ -59,7 +59,7 @@ $(LIBNAME) shared_$(LIBNAME) ar-target:
+ $(AR) dN 2 $(LIBNAME) $$objs && \
+ $(AR) dN 2 $(LIBNAME) $$objs
+ @for objfile in obj.signal \
+- obj.string.generic obj.string.$(TARGET_ARCH) obj.string \
++ obj.string obj.string.generic obj.string.$(TARGET_ARCH) \
+ obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \
+ if [ -e $$objfile ] ; then \
+ if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \
+diff -Nrup a/libc/string/avr32/bcopy.S b/libc/string/avr32/bcopy.S
+--- a/libc/string/avr32/bcopy.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/bcopy.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,15 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++ .text
++ .global bcopy
++ .type bcopy, @function
++ .align 1
++bcopy:
++ /* Swap the first two arguments */
++ eor r11, r12
++ eor r12, r11
++ eor r11, r12
++ rjmp __memmove
++ .size bcopy, . - bcopy
+diff -Nrup a/libc/string/avr32/bzero.S b/libc/string/avr32/bzero.S
+--- a/libc/string/avr32/bzero.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/bzero.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,12 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++ .text
++ .global bzero
++ .type bzero, @function
++ .align 1
++bzero:
++ mov r10, r11
++ mov r11, 0
++ rjmp __memset
+diff -Nrup a/libc/string/avr32/Makefile b/libc/string/avr32/Makefile
+--- a/libc/string/avr32/Makefile 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/Makefile 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,40 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++#
++# You should have received a copy of the GNU Library General Public License
++# along with this program; if not, write to the Free Software Foundation, Inc.,
++# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++TOPDIR=../../../
++include $(TOPDIR)Rules.mak
++
++SSRC := bcopy.S bzero.S memcmp.S memcpy.S memmove.S
++SSRC += memset.S strcmp.S strlen.S
++# memchr.S, strcat.S, strcpy.S, strncpy.S is broken
++SOBJS := $(patsubst %.S,%.o, $(SSRC))
++OBJS := $(SOBJS)
++
++OBJ_LIST:= ../../obj.string.$(TARGET_ARCH)
++
++all: $(OBJ_LIST)
++
++$(OBJ_LIST): $(OBJS)
++ echo $(addprefix string/$(TARGET_ARCH)/, $(OBJS)) > $@
++
++$(SOBJS): %.o: %.S
++ $(CC) $(ASFLAGS) -c $< -o $@
++ $(STRIPTOOL) -x -R .note -R .comment $@
++
++clean:
++ $(RM) *.[oa] *~ core
+diff -Nrup a/libc/string/avr32/memchr.S b/libc/string/avr32/memchr.S
+--- a/libc/string/avr32/memchr.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/memchr.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,62 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define str r12
++#define chr r11
++#define len r10
++
++ .text
++ .global memchr
++ .type memchr, @function
++memchr:
++ or chr, chr, chr << 8
++ or chr, chr, chr << 16
++
++ mov r9, str
++ andl r9, 3, COH
++ brne .Lunaligned_str
++
++1: sub len, 4
++ brlt 2f
++ ld.w r8, str++
++ psub.b r9, r8, r11
++ tnbz r9
++ brne 1b
++
++ sub str, 4
++ bfextu r9, r8, 24, 8
++ cp.b r9, r11
++ reteq str
++ sub str, -1
++ bfextu r9, r8, 16, 8
++ cp.b r9, r11
++ reteq str
++ sub str, -1
++ bfextu r9, r8, 8, 8
++ cp.b r9, r11
++ reteq str
++ sub str, -1
++ retal str
++
++2: sub len, -4
++ reteq 0
++
++3: ld.ub r8, str++
++ cp.w r8, 0
++ reteq str
++ sub len, 1
++ brne 3b
++
++ retal 0
++
++.Lunaligned_str:
++1: sub len, 1
++ retlt 0
++ ld.ub r8, str++
++ cp.b r8, r11
++ reteq str
++ sub r9, 1
++ brge 1b
++
++ rjmp .Laligned_search
+diff -Nrup a/libc/string/avr32/memcmp.S b/libc/string/avr32/memcmp.S
+--- a/libc/string/avr32/memcmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/memcmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,50 @@
++/*
++ * Copyright (C) 2004 Atmel Norway.
++ */
++
++#define s1 r12
++#define s2 r11
++#define len r10
++
++ .text
++ .global memcmp
++ .type memcmp, @function
++ .align 1
++memcmp:
++ sub len, 4
++ brlt .Lless_than_4
++
++1: ld.w r8, s1++
++ ld.w r9, s2++
++ cp.w r8, r9
++ brne .Lfound_word
++ sub len, 4
++ brge 1b
++
++.Lless_than_4:
++ sub len, -4
++ reteq 0
++
++1: ld.ub r8, s1++
++ ld.ub r9, s2++
++ sub r8, r9
++ retne r8
++ sub len, 1
++ brgt 1b
++
++ retal 0
++
++.Lfound_word:
++ psub.b r9, r8, r9
++ bfextu r8, r9, 24, 8
++ retne r8
++ bfextu r8, r9, 16, 8
++ retne r8
++ bfextu r8, r9, 8, 8
++ retne r8
++ retal r9
++
++ .size memcmp, . - memcmp
++
++ .weak bcmp
++ bcmp = memcmp
+diff -Nrup a/libc/string/avr32/memcpy.S b/libc/string/avr32/memcpy.S
+--- a/libc/string/avr32/memcpy.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/memcpy.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,110 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++/* Don't use r12 as dst since we must return it unmodified */
++#define dst r9
++#define src r11
++#define len r10
++
++ .text
++ .global memcpy
++ .type memcpy, @function
++
++ .global __memcpy
++ .hidden __memcpy
++ .type __memcpy, @function
++memcpy:
++__memcpy:
++ pref src[0]
++ mov dst, r12
++
++ /* If we have less than 32 bytes, don't do anything fancy */
++ cp.w len, 32
++ brge .Lmore_than_31
++
++ sub len, 1
++ retlt r12
++1: ld.ub r8, src++
++ st.b dst++, r8
++ sub len, 1
++ brge 1b
++ retal r12
++
++.Lmore_than_31:
++ pushm r0-r7, lr
++
++ /* Check alignment */
++ mov r8, src
++ andl r8, 31, COH
++ brne .Lunaligned_src
++ mov r8, dst
++ andl r8, 3, COH
++ brne .Lunaligned_dst
++
++.Laligned_copy:
++ sub len, 32
++ brlt .Lless_than_32
++
++1: /* Copy 32 bytes at a time */
++ ldm src, r0-r7
++ sub src, -32
++ stm dst, r0-r7
++ sub dst, -32
++ sub len, 32
++ brge 1b
++
++.Lless_than_32:
++ /* Copy 16 more bytes if possible */
++ sub len, -16
++ brlt .Lless_than_16
++ ldm src, r0-r3
++ sub src, -16
++ sub len, 16
++ stm dst, r0-r3
++ sub dst, -16
++
++.Lless_than_16:
++ /* Do the remaining as byte copies */
++ neg len
++ add pc, pc, len << 2
++ .rept 15
++ ld.ub r0, src++
++ st.b dst++, r0
++ .endr
++
++ popm r0-r7, pc
++
++.Lunaligned_src:
++ /* Make src cacheline-aligned. r8 = (src & 31) */
++ rsub r8, r8, 32
++ sub len, r8
++1: ld.ub r0, src++
++ st.b dst++, r0
++ sub r8, 1
++ brne 1b
++
++ /* If dst is word-aligned, we're ready to go */
++ pref src[0]
++ mov r8, 3
++ tst dst, r8
++ breq .Laligned_copy
++
++.Lunaligned_dst:
++ /* src is aligned, but dst is not. Expect bad performance */
++ sub len, 4
++ brlt 2f
++1: ld.w r0, src++
++ st.w dst++, r0
++ sub len, 4
++ brge 1b
++
++2: neg len
++ add pc, pc, len << 2
++ .rept 3
++ ld.ub r0, src++
++ st.b dst++, r0
++ .endr
++
++ popm r0-r7, pc
++ .size memcpy, . - memcpy
+diff -Nrup a/libc/string/avr32/memmove.S b/libc/string/avr32/memmove.S
+--- a/libc/string/avr32/memmove.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/memmove.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,114 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define dst r12
++#define src r11
++#define len r10
++
++ .text
++ .global memmove
++ .type memmove, @function
++
++ .global __memmove
++ .hidden __memmove
++ .type __memmove, @function
++memmove:
++__memmove:
++ cp.w src, dst
++ brge __memcpy
++
++ add dst, len
++ add src, len
++ pref src[-1]
++
++ /*
++ * The rest is basically the same as in memcpy.S except that
++ * the direction is reversed.
++ */
++ cp.w len, 32
++ brge .Lmore_than_31
++
++ sub len, 1
++ retlt r12
++1: ld.ub r8, --src
++ st.b --dst, r8
++ sub len, 1
++ brge 1b
++ retal r12
++
++.Lmore_than_31:
++ pushm r0-r7, lr
++
++ /* Check alignment */
++ mov r8, src
++ andl r8, 31, COH
++ brne .Lunaligned_src
++ mov r8, r12
++ andl r8, 3, COH
++ brne .Lunaligned_dst
++
++.Laligned_copy:
++ sub len, 32
++ brlt .Lless_than_32
++
++1: /* Copy 32 bytes at a time */
++ sub src, 32
++ ldm src, r0-r7
++ sub dst, 32
++ sub len, 32
++ stm dst, r0-r7
++ brge 1b
++
++.Lless_than_32:
++ /* Copy 16 more bytes if possible */
++ sub len, -16
++ brlt .Lless_than_16
++ sub src, 16
++ ldm src, r0-r3
++ sub dst, 16
++ sub len, 16
++ stm dst, r0-r3
++
++.Lless_than_16:
++ /* Do the remaining as byte copies */
++ sub len, -16
++ breq 2f
++1: ld.ub r0, --src
++ st.b --dst, r0
++ sub len, 1
++ brne 1b
++
++2: popm r0-r7, pc
++
++.Lunaligned_src:
++ /* Make src cacheline-aligned. r8 = (src & 31) */
++ sub len, r8
++1: ld.ub r0, --src
++ st.b --dst, r0
++ sub r8, 1
++ brne 1b
++
++ /* If dst is word-aligned, we're ready to go */
++ pref src[-4]
++ mov r8, 3
++ tst dst, r8
++ breq .Laligned_copy
++
++.Lunaligned_dst:
++ /* src is aligned, but dst is not. Expect bad performance */
++ sub len, 4
++ brlt 2f
++1: ld.w r0, --src
++ st.w --dst, r0
++ sub len, 4
++ brge 1b
++
++2: neg len
++ add pc, pc, len << 2
++ .rept 3
++ ld.ub r0, --src
++ st.b --dst, r0
++ .endr
++
++ popm r0-r7, pc
+diff -Nrup a/libc/string/avr32/memset.S b/libc/string/avr32/memset.S
+--- a/libc/string/avr32/memset.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/memset.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2004 Atmel Norway.
++ */
++
++#define s r12
++#define c r11
++#define n r10
++
++ .text
++ .global memset
++ .type memset, @function
++
++ .global __memset
++ .hidden __memset
++ .type __memset, @function
++
++ .align 1
++memset:
++__memset:
++ cp.w n, 32
++ mov r9, s
++ brge .Llarge_memset
++
++ sub n, 1
++ retlt s
++1: st.b s++, c
++ sub n, 1
++ brge 1b
++
++ retal r9
++
++.Llarge_memset:
++ mov r8, r11
++ mov r11, 3
++ bfins r8, r8, 8, 8
++ bfins r8, r8, 16, 16
++ tst s, r11
++ breq 2f
++
++1: st.b s++, r8
++ sub n, 1
++ tst s, r11
++ brne 1b
++
++2: mov r11, r9
++ mov r9, r8
++ sub n, 8
++
++3: st.d s++, r8
++ sub n, 8
++ brge 3b
++
++ /* If we are done, n == -8 and we'll skip all st.b insns below */
++ neg n
++ lsl n, 1
++ add pc, n
++ .rept 7
++ st.b s++, r8
++ .endr
++ retal r11
+diff -Nrup a/libc/string/avr32/strcat.S b/libc/string/avr32/strcat.S
+--- a/libc/string/avr32/strcat.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/strcat.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,95 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define s1 r9
++#define s2 r11
++
++ .text
++ .global strcat
++ .type strcat, @function
++ .align 1
++strcat:
++ mov s1, r12
++
++ /* Make sure s1 is word-aligned */
++ mov r10, s1
++ andl r10, 3, COH
++ breq 2f
++
++ add pc, pc, r10 << 3
++ sub r0, r0, 0 /* 4-byte nop */
++ ld.ub r8, s1++
++ sub r8, r8, 0
++ breq 2f
++ ld.ub r8, s1++
++ sub r8, r8, 0
++ breq 3f
++ ld.ub r8, s1++
++ sub r8, r8, 0
++ breq 4f
++
++ /* Find the end of the first string */
++5: ld.w r8, s1++
++ tnbz r8
++ brne 5b
++
++ sub s1, 4
++
++ bfextu r10, r8, 24, 8
++ cp.w r10, 0
++ breq 1f
++ sub s1, -1
++ bfextu r10, r8, 16, 8
++ cp.w r10, 0
++ breq 2f
++ sub s1, -1
++ bfextu r10, r8, 8, 8
++ cp.w r10, 0
++ breq 3f
++ sub s1, -1
++ rjmp 4f
++
++ /* Now, append s2 */
++1: ld.ub r8, s2++
++ st.b s1++, r8
++ cp.w r8, 0
++ reteq r12
++2: ld.ub r8, s2++
++ st.b s1++, r8
++ cp.w r8, 0
++ reteq r12
++3: ld.ub r8, s2++
++ st.b s1++, r8
++ cp.w r8, 0
++ reteq r12
++4: ld.ub r8, s2++
++ st.b s1++, r8
++ cp.w r8, 0
++ reteq r12
++
++ /* Copy one word at a time */
++ ld.w r8, s2++
++ tnbz r8
++ breq 2f
++1: st.w r8, s2++
++ ld.w r8, s2++
++ tnbz r8
++ brne 1b
++
++ /* Copy the remaining bytes */
++ bfextu r10, r8, 24, 8
++ st.b s1++, r10
++ cp.w r10, 0
++ reteq r12
++ bfextu r10, r8, 16, 8
++ st.b s1++, r10
++ cp.w r10, 0
++ reteq r12
++ bfextu r10, r8, 8, 8
++ st.b s1++, r10
++ cp.w r10, 0
++ reteq r12
++ st.b s1++, r8
++ retal r12
++ .size strcat, . - strcat
+diff -Nrup a/libc/string/avr32/strcmp.S b/libc/string/avr32/strcmp.S
+--- a/libc/string/avr32/strcmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/strcmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,80 @@
++/*
++ * Copyright (C) 2004 Atmel Norway.
++ */
++
++#define s1 r12
++#define s2 r11
++#define len r10
++
++ .text
++ .global strcmp
++ .type strcmp, @function
++ .align 1
++strcmp:
++ mov r8, 3
++ tst s1, r8
++ brne .Lunaligned_s1
++ tst s2, r8
++ brne .Lunaligned_s2
++
++1: ld.w r8, s1++
++ ld.w r9, s2++
++ cp.w r8, r9
++ brne 2f
++ tnbz r8
++ brne 1b
++ retal 0
++
++2: bfextu r12, r8, 24, 8
++ bfextu r11, r9, 24, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 16, 8
++ bfextu r11, r9, 16, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 8, 8
++ bfextu r11, r9, 8, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 0, 8
++ bfextu r11, r9, 0, 8
++ sub r12, r11
++ retal r12
++
++.Lunaligned_s1:
++3: tst s1, r8
++ breq 4f
++ ld.ub r10, s1++
++ ld.ub r9, s2++
++ sub r10, r9
++ retne r10
++ cp.w r9, 0
++ brne 3b
++ retal r10
++
++4: tst s2, r8
++ breq 1b
++
++.Lunaligned_s2:
++ /*
++ * s1 and s2 can't both be aligned, and unaligned word loads
++ * can trigger spurious exceptions if we cross a page boundary.
++ * Do it the slow way...
++ */
++1: ld.ub r8, s1++
++ ld.ub r9, s2++
++ sub r8, r9
++ retne r8
++ cp.w r9, 0
++ brne 1b
++ retal 0
++
++ .weak strcoll
++ strcoll = strcmp
+diff -Nrup a/libc/string/avr32/strcpy.S b/libc/string/avr32/strcpy.S
+--- a/libc/string/avr32/strcpy.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/strcpy.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,63 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ *
++ * To reduce the size, this one might simply call strncpy with len = -1.
++ */
++
++#define dst r9
++#define src r11
++
++ .text
++ .global strcpy
++ .type strcpy, @function
++strcpy:
++ mov dst, r12
++
++ pref src[0]
++
++ /*
++ * Check alignment. If src is aligned but dst isn't, we can't
++ * do much about it...
++ */
++ mov r8, src
++ andl r8, 3 COH
++ brne .Lunaligned_src
++
++.Laligned_copy:
++1: ld.w r8, src++
++ tnbz r8
++ breq 2f
++ st.w dst++, r8
++ rjmp 1b
++
++2: /*
++ * Ok, r8 now contains the terminating '\0'. Copy the
++ * remaining bytes individually.
++ */
++ bfextu r10, r8, 24, 8
++ st.b dst++, r10
++ cp.w r10, 0
++ reteq r12
++ bfextu r10, r8, 16, 8
++ st.b dst++, r10
++ cp.w r10, 0
++ reteq r12
++ bfextu r10, r8, 8, 8
++ st.b dst++, r10
++ cp.w r10, 0
++ reteq r12
++ st.b dst++, r8
++ retal r12
++
++.Lunaligned_src:
++ /* Copy bytes until we're aligned */
++ rsub r8, r8, 4
++ add pc, pc, r8 << 3
++ nop
++ nop
++ ld.ub r10, src++
++ st.b dst++, r10
++ cp.w r10, 0
++ reteq r12
++
++ rjmp .Laligned_copy
+diff -Nrup a/libc/string/avr32/stringtest.c b/libc/string/avr32/stringtest.c
+--- a/libc/string/avr32/stringtest.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/stringtest.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,144 @@
++
++#include <stdio.h>
++#include <string.h>
++#include <time.h>
++#include <sys/mman.h>
++
++#define BUF_SIZE (8 * 1024)
++
++static char *buf1;
++static char *buf1_ref;
++static char *buf2;
++
++extern void *optimized_memcpy(void *dest, void *src, size_t len);
++extern void *optimized_memmove(void *dest, void *src, size_t len);
++extern char *optimized_strcpy(char *dest, char *src);
++extern char *optimized_strncpy(char *dest, char *src, size_t len);
++
++void dump_mismatch(char *buf, char *ref, size_t len)
++{
++ int i, j;
++
++ for (i = 0; i < len; i += 16) {
++ if (memcmp(buf + i, ref + i, 16) == 0)
++ continue;
++
++ printf("%4x buf:", i);
++ for (j = i; j < (i + 16); j++)
++ printf(" %02x", buf[j]);
++ printf("\n ref:");
++ for (j = i; j < (i + 16); j++)
++ printf(" %02x", ref[j]);
++ printf("\n");
++ }
++}
++
++static void test_memcpy(int src_offset, int dst_offset, int len)
++{
++ clock_t start, old, new;
++ int i;
++
++ memset(buf1, 0x55, BUF_SIZE);
++ memset(buf1_ref, 0x55, BUF_SIZE);
++ memset(buf2, 0xaa, BUF_SIZE);
++
++ printf("Testing memcpy with offsets %d => %d and len %d...",
++ src_offset, dst_offset, len);
++
++ start = clock();
++ for (i = 0; i < 8192; i++)
++ optimized_memcpy(buf1 + dst_offset, buf2 + src_offset, len);
++ new = clock() - start;
++ start = clock();
++ for ( i = 0; i < 8192; i++)
++ memcpy(buf1_ref + dst_offset, buf2 + src_offset, len);
++ old = clock() - start;
++
++ if (memcmp(buf1, buf1_ref, BUF_SIZE) == 0)
++ printf("OK\n");
++ else {
++ printf("FAILED\n");
++ dump_mismatch(buf1, buf1_ref, BUF_SIZE);
++ }
++ printf("CPU time used: %d vs. %d\n", new, old);
++}
++
++static void test_memmove(int src_offset, int dst_offset, int len)
++{
++ clock_t start, old, new;
++
++ memset(buf1, 0x55, BUF_SIZE);
++ memset(buf1_ref, 0x55, BUF_SIZE);
++ memset(buf2, 0xaa, BUF_SIZE);
++
++ printf("Testing memmove with offsets %d => %d and len %d...",
++ src_offset, dst_offset, len);
++
++ start = clock();
++ optimized_memmove(buf1 + dst_offset, buf2 + src_offset, len);
++ new = clock() - start;
++ start = clock();
++ memmove(buf1_ref + dst_offset, buf2 + src_offset, len);
++ old = clock() - start;
++
++ if (memcmp(buf1, buf1_ref, BUF_SIZE) == 0)
++ printf("OK\n");
++ else {
++ printf("FAILED\n");
++ dump_mismatch(buf1, buf1_ref, BUF_SIZE);
++ }
++ printf("CPU time used: %d vs. %d\n", new, old);
++}
++
++int main(int argc, char *argv[])
++{
++ buf2 = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
++ if (buf2 == MAP_FAILED) {
++ perror("Failed to allocate memory for buf2");
++ return 1;
++ }
++ buf1 = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
++ if (buf1 == MAP_FAILED) {
++ perror("Failed to allocate memory for buf1");
++ return 1;
++ }
++ buf1_ref = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
++ if (buf1_ref == MAP_FAILED) {
++ perror("Failed to allocate memory for buf1_ref");
++ return 1;
++ }
++ printf("\n === MEMCPY ===\n\n");
++
++ test_memcpy(0, 0, BUF_SIZE - 32);
++ test_memcpy(0, 0, 1);
++ test_memcpy(0, 0, 31);
++ test_memcpy(0, 0, 32);
++ test_memcpy(0, 0, 127);
++ test_memcpy(0, 0, 128);
++ test_memcpy(4, 4, BUF_SIZE - 32 - 4);
++ test_memcpy(1, 1, BUF_SIZE - 32 - 1);
++ test_memcpy(1, 1, 126);
++ test_memcpy(0, 3, 128);
++ test_memcpy(1, 4, 128);
++ test_memcpy(0, 0, 0);
++
++ printf("\n === MEMMOVE ===\n\n");
++
++ test_memmove(0, 0, BUF_SIZE - 32);
++ test_memmove(0, 0, 1);
++ test_memmove(0, 0, 31);
++ test_memmove(0, 0, 32);
++ test_memmove(0, 0, BUF_SIZE - 33);
++ test_memmove(0, 0, 128);
++ test_memmove(4, 4, BUF_SIZE - 32 - 4);
++ test_memmove(1, 1, BUF_SIZE - 32 - 1);
++ test_memmove(1, 1, BUF_SIZE - 130);
++ test_memmove(0, 3, BUF_SIZE - 128);
++ test_memmove(1, 4, BUF_SIZE - 128);
++ test_memmove(0, 0, 0);
++
++ return 0;
++}
+diff -Nrup a/libc/string/avr32/strlen.S b/libc/string/avr32/strlen.S
+--- a/libc/string/avr32/strlen.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/strlen.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,52 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define str r12
++
++ .text
++ .global strlen
++ .type strlen, @function
++strlen:
++ mov r11, r12
++
++ mov r9, str
++ andl r9, 3, COH
++ brne .Lunaligned_str
++
++1: ld.w r8, str++
++ tnbz r8
++ brne 1b
++
++ sub r12, r11
++ bfextu r9, r8, 24, 8
++ cp.w r9, 0
++ subeq r12, 4
++ reteq r12
++ bfextu r9, r8, 16, 8
++ cp.w r9, 0
++ subeq r12, 3
++ reteq r12
++ bfextu r9, r8, 8, 8
++ cp.w r9, 0
++ subeq r12, 2
++ reteq r12
++ sub r12, 1
++ retal r12
++
++.Lunaligned_str:
++ add pc, pc, r9 << 3
++ sub r0, r0, 0 /* 4-byte nop */
++ ld.ub r8, str++
++ sub r8, r8, 0
++ breq 1f
++ ld.ub r8, str++
++ sub r8, r8, 0
++ breq 1f
++ ld.ub r8, str++
++ sub r8, r8, 0
++ brne 1b
++
++1: sub r12, 1
++ sub r12, r11
++ retal r12
+diff -Nrup a/libc/string/avr32/strncpy.S b/libc/string/avr32/strncpy.S
+--- a/libc/string/avr32/strncpy.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/strncpy.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,77 @@
++/*
++ * Copyright (C) 2004 Atmel Norway
++ */
++
++#define dst r9
++#define src r11
++
++ .text
++ .global strcpy
++ .type strncpy, @function
++strncpy:
++ mov dst, r12
++
++ pref src[0]
++ mov dst, r12
++
++ /*
++ * Check alignment. If src is aligned but dst isn't, we can't
++ * do much about it...
++ */
++ mov r8, src
++ andl r8, 3 COH
++ brne .Lunaligned_src
++
++.Laligned_copy:
++ sub r10, 4
++ brlt 3f
++1: ld.w r8, src++
++ tnbz r8
++ breq 2f
++ st.w dst++, r8
++ sub r10, 4
++ brne 1b
++
++3: sub r10, -4
++ reteq r12
++
++ /* This is safe as long as src is word-aligned and r10 > 0 */
++ ld.w r8, src++
++
++2: /*
++ * Ok, r8 now contains the terminating '\0'. Copy the
++ * remaining bytes individually.
++ */
++ bfextu r11, r8, 24, 8
++ st.b dst++, r11
++ cp.w r11, 0
++ reteq r12
++ sub r10, 1
++ reteq r12
++ bfextu r11, r8, 16, 8
++ st.b dst++, r11
++ cp.w r11, 0
++ reteq r12
++ sub r10, 1
++ reteq r12
++ bfextu r11, r8, 8, 8
++ st.b dst++, r11
++ cp.w r11, 0
++ reteq r12
++ sub r10, 1
++ reteq r12
++ st.b dst++, r8
++ retal r12
++
++.Lunaligned_src:
++ /* Copy bytes until we're aligned */
++ min r8, r8, r10
++ sub r10, r8
++ sub r8, 1
++ retlt r12
++1: ld.ub r10, src++
++ st.b dst++, r10
++ sub r8, 1
++ brge 1b
++
++ rjmp .Laligned_copy
+diff -Nrup a/libc/string/avr32/test_memcpy.c b/libc/string/avr32/test_memcpy.c
+--- a/libc/string/avr32/test_memcpy.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/string/avr32/test_memcpy.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,66 @@
++
++#include <stdio.h>
++#include <string.h>
++
++#define BUF_SIZE 32768
++
++static char buf1[BUF_SIZE] __attribute__((aligned(32)));
++static char buf1_ref[BUF_SIZE] __attribute__((aligned(32)));
++static char buf2[BUF_SIZE] __attribute__((aligned(32)));
++
++extern void *new_memcpy(void *dest, void *src, size_t len);
++
++void dump_mismatch(char *buf, char *ref, size_t len)
++{
++ int i, j;
++
++ for (i = 0; i < len; i += 16) {
++ if (memcmp(buf + i, ref + i, 16) == 0)
++ continue;
++
++ printf("% 4x buf:", i);
++ for (j = i; j < (i + 16); j++)
++ printf(" %02x", buf[j]);
++ printf("\n ref:");
++ for (j = i; j < (i + 16); j++)
++ printf(" %02x", ref[j]);
++ printf("\n");
++ }
++}
++
++void test(int src_offset, int dst_offset, int len)
++{
++ memset(buf1, 0x55, sizeof(buf1));
++ memset(buf1_ref, 0x55, sizeof(buf1_ref));
++ memset(buf2, 0xaa, sizeof(buf2));
++
++ printf("Testing with offsets %d => %d and len %d...",
++ src_offset, dst_offset, len);
++
++ new_memcpy(buf1 + dst_offset, buf2 + src_offset, len);
++ memcpy(buf1_ref + dst_offset, buf2 + src_offset, len);
++
++ if (memcmp(buf1, buf1_ref, sizeof(buf1)) == 0)
++ printf("OK\n");
++ else {
++ printf("FAILED\n");
++ dump_mismatch(buf1, buf1_ref, sizeof(buf1));
++ }
++}
++
++int main(int argc, char *argv[])
++{
++ test(0, 0, BUF_SIZE);
++ test(0, 0, 1);
++ test(0, 0, 31);
++ test(0, 0, 32);
++ test(0, 0, 127);
++ test(0, 0, 128);
++ test(4, 4, BUF_SIZE - 4);
++ test(1, 1, BUF_SIZE - 1);
++ test(1, 1, 126);
++ test(0, 3, 128);
++ test(1, 4, 128);
++
++ return 0;
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/atomicity.h b/libc/sysdeps/linux/avr32/bits/atomicity.h
+--- a/libc/sysdeps/linux/avr32/bits/atomicity.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/atomicity.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,86 @@
++/* Low-level functions for atomic operations. AVR32 version.
++ Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _ATOMICITY_H
++#define _ATOMICITY_H 1
++
++#include <inttypes.h>
++
++static inline int
++__attribute__((unused))
++exchange_and_add (volatile uint32_t *mem, int val)
++{
++ int tmp, result;
++
++ __asm__ __volatile__(
++ "/* Inline exchange and add */\n"
++ "1: ssrf 5\n"
++ " ld.w %0, %3\n"
++ " add %1, %0, %4\n"
++ " stcond %2, %1\n"
++ " brne 1b"
++ : "=&r"(result), "=&r"(tmp), "=m"(*mem)
++ : "m"(*mem), "r"(val)
++ : "cc", "memory");
++
++ return result;
++}
++
++static inline void
++__attribute__((unused))
++atomic_add (volatile uin32_t *mem, int val)
++{
++ int result;
++
++ __asm__ __volatile__(
++ "/* Inline atomic add */\n"
++ "1: ssrf 5\n"
++ " ld.w %0, %2\n"
++ " add %0, %3\n"
++ " stcond %2, %0\n"
++ " brne 1b"
++ : "=&r"(result), "=m"(*mem)
++ : "m"(*mem), "r"(val)
++ : "cc", "memory");
++}
++
++static inline int
++__attribute__((unused))
++compare_and_swap(volatile long int *p, long int oldval, long int newval)
++{
++ long int result, tmp;
++
++ __asm__ __volatile__(
++ "/* Inline compare and swap */\n"
++ "1: ssrf 5\n"
++ " ld.w %1, %3\n"
++ " cp.w %1, %5\n"
++ " sreq %0\n"
++ " brne 2f\n"
++ " stcond %2, %4\n"
++ " brne 1b\n"
++ "2:"
++ : "=&r"(result), "=&r"(tmp), "=m"(*p)
++ : "m"(*p), "r"(newval), "r"(oldval)
++ : "cc", "memory");
++
++ return result;
++}
++
++#endif /* atomicity.h */
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/byteswap.h b/libc/sysdeps/linux/avr32/bits/byteswap.h
+--- a/libc/sysdeps/linux/avr32/bits/byteswap.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/byteswap.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,80 @@
++/* Macros to swap the order of bytes in integer values.
++ Copyright (C) 2005 Atmel Norway.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
++# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
++#endif
++
++#ifndef _BITS_BYTESWAP_H
++#define _BITS_BYTESWAP_H 1
++
++/* Swap bytes in 16 bit value. */
++#if defined __GNUC__
++# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
++#else
++/* This is better than nothing. */
++static __inline unsigned short int
++__bswap_16 (unsigned short int __bsx)
++{
++ return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
++}
++#endif
++
++/* Swap bytes in 32 bit value. */
++#if defined __GNUC__
++# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
++#else
++static __inline unsigned int
++__bswap_32 (unsigned int __bsx)
++{
++ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
++ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
++}
++#endif
++
++#if defined __GNUC__
++/* Swap bytes in 64 bit value. */
++# define __bswap_constant_64(x) \
++ ((((x) & 0xff00000000000000ull) >> 56) \
++ | (((x) & 0x00ff000000000000ull) >> 40) \
++ | (((x) & 0x0000ff0000000000ull) >> 24) \
++ | (((x) & 0x000000ff00000000ull) >> 8) \
++ | (((x) & 0x00000000ff000000ull) << 8) \
++ | (((x) & 0x0000000000ff0000ull) << 24) \
++ | (((x) & 0x000000000000ff00ull) << 40) \
++ | (((x) & 0x00000000000000ffull) << 56))
++
++# define __bswap_64(x) \
++ (__extension__ \
++ ({ \
++ union { \
++ __extension__ unsigned long long int __ll; \
++ unsigned int __l[2]; \
++ } __w, __r; \
++ if (__builtin_constant_p(x)) \
++ __r.__ll = __bswap_constant_64(x); \
++ else { \
++ __w.__ll = (x); \
++ __r.__l[0] = __bswap_32(__w.__l[1]); \
++ __r.__l[1] = __bswap_32(__w.__l[0]); \
++ } \
++ __r.__ll; \
++ }))
++#endif
++
++#endif /* _BITS_BYTESWAP_H */
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/endian.h b/libc/sysdeps/linux/avr32/bits/endian.h
+--- a/libc/sysdeps/linux/avr32/bits/endian.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/endian.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,7 @@
++/* AVR32 is big-endian */
++
++#ifndef _ENDIAN_H
++# error "Never use <bits/endian.h> directly; include <endian.h> instead."
++#endif
++
++#define __BYTE_ORDER __BIG_ENDIAN
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
+--- a/libc/sysdeps/linux/avr32/bits/fcntl.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/fcntl.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,168 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ *
++ * This file is part of the Linux kernel
++ */
++#ifndef _FCNTL_H
++# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
++#endif
++
++#include <sys/types.h>
++
++/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
++ located on an ext2 file system */
++#define O_ACCMODE 00000003
++#define O_RDONLY 00000000
++#define O_WRONLY 00000001
++#define O_RDWR 00000002
++#define O_CREAT 00000100 /* not fcntl */
++#define O_EXCL 00000200 /* not fcntl */
++#define O_NOCTTY 00000400 /* not fcntl */
++#define O_TRUNC 00001000 /* not fcntl */
++#define O_APPEND 00002000
++#define O_NONBLOCK 00004000
++#define O_NDELAY O_NONBLOCK
++#define O_SYNC 00010000
++#define O_ASYNC 00020000
++
++#ifdef __USE_GNU
++# define O_DIRECT 00040000 /* must be a directory */
++# define O_DIRECTORY 00200000 /* direct disk access */
++# define O_NOFOLLOW 00400000 /* don't follow links */
++# define O_NOATIME 01000000 /* don't set atime */
++#endif
++
++#ifdef __USE_LARGEFILE64
++# define O_LARGEFILE 00100000
++#endif
++
++/* For now Linux has synchronisity options for data and read operations.
++ We define the symbols here but let them do the same as O_SYNC since
++ this is a superset. */
++#if defined __USE_POSIX199309 || defined __USE_UNIX98
++# define O_DSYNC O_SYNC /* Synchronize data. */
++# define O_RSYNC O_SYNC /* Synchronize read operations. */
++#endif
++
++#define F_DUPFD 0 /* dup */
++#define F_GETFD 1 /* get close_on_exec */
++#define F_SETFD 2 /* set/clear close_on_exec */
++#define F_GETFL 3 /* get file->f_flags */
++#define F_SETFL 4 /* set file->f_flags */
++
++#ifndef __USE_FILE_OFFSET64
++# define F_GETLK 5
++# define F_SETLK 6
++# define F_SETLKW 7
++#else
++# define F_GETLK F_GETLK64
++# define F_SETLK F_SETLK64
++# define F_SETLKW F_SETLKW64
++#endif
++#define F_GETLK64 12 /* using 'struct flock64' */
++#define F_SETLK64 13
++#define F_SETLKW64 14
++
++#if defined __USE_BSD || defined __USE_XOPEN2K
++# define F_SETOWN 8 /* for sockets. */
++# define F_GETOWN 9 /* for sockets. */
++#endif
++
++#ifdef __USE_GNU
++# define F_SETSIG 10 /* for sockets. */
++# define F_GETSIG 11 /* for sockets. */
++#endif
++
++#ifdef __USE_GNU
++# define F_SETLEASE 1024 /* Set a lease. */
++# define F_GETLEASE 1025 /* Enquire what lease is active. */
++# define F_NOTIFY 1026 /* Request notfications on a directory. */
++#endif
++
++/* for F_[GET|SET]FL */
++#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
++
++/* for posix fcntl() and lockf() */
++#define F_RDLCK 0
++#define F_WRLCK 1
++#define F_UNLCK 2
++
++/* for old implementation of bsd flock () */
++#define F_EXLCK 4 /* or 3 */
++#define F_SHLCK 8 /* or 4 */
++
++/* for leases */
++#define F_INPROGRESS 16
++
++#ifdef __USE_BSD
++/* operations for bsd flock(), also used by the kernel implementation */
++# define LOCK_SH 1 /* shared lock */
++# define LOCK_EX 2 /* exclusive lock */
++# define LOCK_NB 4 /* or'd with one of the above to prevent
++ blocking */
++# define LOCK_UN 8 /* remove lock */
++#endif
++
++#ifdef __USE_GNU
++# define LOCK_MAND 32 /* This is a mandatory flock */
++# define LOCK_READ 64 /* ... Which allows concurrent
++ read operations */
++# define LOCK_WRITE 128 /* ... Which allows concurrent
++ write operations */
++# define LOCK_RW 192 /* ... Which allows concurrent
++ read & write ops */
++#endif
++
++#ifdef __USE_GNU
++/* Types of directory notifications that may be requested with F_NOTIFY. */
++# define DN_ACCESS 0x00000001 /* File accessed. */
++# define DN_MODIFY 0x00000002 /* File modified. */
++# define DN_CREATE 0x00000004 /* File created. */
++# define DN_DELETE 0x00000008 /* File removed. */
++# define DN_RENAME 0x00000010 /* File renamed. */
++# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
++# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
++#endif
++
++struct flock {
++ short l_type;
++ short l_whence;
++#ifndef __USE_FILE_OFFSET64
++ __off_t l_start;
++ __off_t l_len;
++#else
++ __off64_t l_start;
++ __off64_t l_len;
++#endif
++ __pid_t l_pid;
++};
++
++#ifdef __USE_LARGEFILE64
++struct flock64 {
++ short l_type;
++ short l_whence;
++ __off64_t l_start;
++ __off64_t l_len;
++ __pid_t l_pid;
++};
++#endif
++
++/* Define some more compatibility macros to be backward compatible with
++ * BSD systems which did not managed to hide these kernel macros. */
++#ifdef __USE_BSD
++# define FAPPEND O_APPEND
++# define FFSYNC O_FSYNC
++# define FASYNC O_ASYNC
++# define FNONBLOCK O_NONBLOCK
++# define FNDELAY O_NDELAY
++#endif /* Use BSD. */
++
++/* Advise to `posix_fadvise'. */
++#ifdef __USE_XOPEN2K
++# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
++# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
++# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
++# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
++# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
++#endif
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/kernel_stat.h b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
+--- a/libc/sysdeps/linux/avr32/bits/kernel_stat.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,63 @@
++#ifndef _BITS_STAT_STRUCT_H
++#define _BITS_STAT_STRUCT_H
++
++/*
++ * This file provides struct stat, taken from kernel 2.6.4
++ * (include/asm-avr32/stat.h revision 1.1).
++ */
++
++struct kernel_stat {
++ unsigned long st_dev;
++ unsigned long st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned long st_rdev;
++ unsigned long st_size;
++ unsigned long st_blksize;
++ unsigned long st_blocks;
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++#define STAT_HAVE_NSEC 1
++
++struct kernel_stat64 {
++ unsigned long long st_dev;
++
++ unsigned long long st_ino;
++ unsigned int st_mode;
++ unsigned int st_nlink;
++
++ unsigned long st_uid;
++ unsigned long st_gid;
++
++ unsigned long long st_rdev;
++
++ long long st_size;
++ unsigned long __pad1;
++ unsigned long st_blksize;
++
++ unsigned long long st_blocks;
++
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++
++ unsigned long __unused1;
++ unsigned long __unused2;
++};
++
++#endif /* _BITS_STAT_STRUCT_H */
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/kernel_types.h b/libc/sysdeps/linux/avr32/bits/kernel_types.h
+--- a/libc/sysdeps/linux/avr32/bits/kernel_types.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,56 @@
++/* Note that we use the exact same include guard #define names
++ * as asm/posix_types.h. This will avoid gratuitous conflicts
++ * with the posix_types.h kernel header, and will ensure that
++ * our private content, and not the kernel header, will win.
++ * -Erik
++ */
++#ifndef __ASM_AVR32_POSIX_TYPES_H
++#define __ASM_AVR32_POSIX_TYPES_H
++
++/*
++ * This file is generally used by user-level software, so you need to
++ * be a little careful about namespace pollution etc. Also, we cannot
++ * assume GCC is being used.
++ */
++
++typedef unsigned long __kernel_dev_t;
++typedef unsigned long __kernel_ino_t;
++typedef unsigned short __kernel_mode_t;
++typedef unsigned short __kernel_nlink_t;
++typedef long __kernel_off_t;
++typedef int __kernel_pid_t;
++typedef unsigned short __kernel_ipc_pid_t;
++typedef unsigned int __kernel_uid_t;
++typedef unsigned int __kernel_gid_t;
++typedef unsigned long __kernel_size_t;
++typedef int __kernel_ssize_t;
++typedef int __kernel_ptrdiff_t;
++typedef long __kernel_time_t;
++typedef long __kernel_suseconds_t;
++typedef long __kernel_clock_t;
++typedef int __kernel_timer_t;
++typedef int __kernel_clockid_t;
++typedef int __kernel_daddr_t;
++typedef char * __kernel_caddr_t;
++typedef unsigned short __kernel_uid16_t;
++typedef unsigned short __kernel_gid16_t;
++typedef unsigned int __kernel_uid32_t;
++typedef unsigned int __kernel_gid32_t;
++
++typedef unsigned short __kernel_old_uid_t;
++typedef unsigned short __kernel_old_gid_t;
++typedef unsigned short __kernel_old_dev_t;
++
++#ifdef __GNUC__
++typedef long long __kernel_loff_t;
++#endif
++
++typedef struct {
++#if defined(__USE_ALL)
++ int val[2];
++#else
++ int __val[2];
++#endif
++} __kernel_fsid_t;
++
++#endif /* __ASM_AVR32_POSIX_TYPES_H */
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/machine-gmon.h b/libc/sysdeps/linux/avr32/bits/machine-gmon.h
+--- a/libc/sysdeps/linux/avr32/bits/machine-gmon.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/machine-gmon.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,69 @@
++/* Machine-dependent definitions for profiling support. AVR32 version.
++ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#define mcount_internal __mcount_internal
++
++#define _MCOUNT_DECL(frompc, selfpc) \
++static void __attribute((used)) mcount_internal(unsigned long frompc, unsigned long selfpc)
++
++/*
++ * This mcount implementation expects to get called after the prologue
++ * has been run. It also expects that r7 contains a valid frame
++ * pointer.
++ *
++ * When profiling, the compiler should generate something like this at
++ * each function entry:
++ *
++ * pushm r0-r7,lr // lr mandatory, others optional
++ * mov r7, sp
++ * // rest of prologue goes here
++ * mcall pc[.LC1 - .]
++ * // rest of function goes here
++ * .LC1:
++ * .long mcount
++ *
++ * or for PIC:
++ *
++ * pushm r0-r7,lr
++ * mov r7, sp
++ * // rest of prologue goes here
++ * lddpc r0, .LC1
++ * .L1: rsub r0, pc
++ * mcall r0[mcount@GOT]
++ * // rest of function goes here
++ * .LC1:
++ * .long .L1 - _GLOBAL_OFFSET_TABLE_
++ *
++ * This way, when mcount() is called, r7 points to the calling
++ * function's return address. It is guaranteed that calling mcount
++ * will clobber no registers except LR, which is unavoidable.
++ */
++#define MCOUNT asm( \
++ " .align 4\n" \
++ " .global _mcount\n" \
++ " .type _mcount,@function\n" \
++ "_mcount:\n" \
++ " pushm r8-r12,lr\n" \
++ " mov r11, lr\n" \
++ " ld.w r12, r7[0]\n" \
++ " rcall __mcount_internal\n" \
++ " popm r8-r12,pc\n" \
++ " .size _mcount, . - _mcount\n" \
++ " .weak mcount\n" \
++ " mcount = _mcount");
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/mman.h b/libc/sysdeps/linux/avr32/bits/mman.h
+--- a/libc/sysdeps/linux/avr32/bits/mman.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/mman.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,95 @@
++/* Definitions for POSIX memory map interface. Linux/AVR32 version.
++ Copyright (C) 1997, 2000 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_MMAN_H
++# error "Never include this file directly. Use <sys/mman.h> instead"
++#endif
++
++/* The following definitions basically come from the kernel headers.
++ But the kernel header is not namespace clean. */
++
++
++/* Protections are chosen from these bits, OR'd together. The
++ implementation does not necessarily support PROT_EXEC or PROT_WRITE
++ without PROT_READ. The only guarantees are that no writing will be
++ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
++
++#define PROT_READ 0x1 /* Page can be read. */
++#define PROT_WRITE 0x2 /* Page can be written. */
++#define PROT_EXEC 0x4 /* Page can be executed. */
++#define PROT_NONE 0x0 /* Page can not be accessed. */
++
++/* Sharing types (must choose one and only one of these). */
++#define MAP_SHARED 0x01 /* Share changes. */
++#define MAP_PRIVATE 0x02 /* Changes are private. */
++#ifdef __USE_MISC
++# define MAP_TYPE 0x0f /* Mask for type of mapping. */
++#endif
++
++/* Other flags. */
++#define MAP_FIXED 0x10 /* Interpret addr exactly. */
++#ifdef __USE_MISC
++# define MAP_FILE 0
++# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
++# define MAP_ANON MAP_ANONYMOUS
++#endif
++
++/* These are Linux-specific. */
++#ifdef __USE_MISC
++# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
++# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
++# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
++# define MAP_LOCKED 0x2000 /* Lock the mapping. */
++# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
++# define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
++# define MAP_NONBLOCK 0x10000 /* do not block on IO */
++#endif
++
++/* Flags to `msync'. */
++#define MS_ASYNC 1 /* Sync memory asynchronously. */
++#define MS_SYNC 4 /* Synchronous memory sync. */
++#define MS_INVALIDATE 2 /* Invalidate the caches. */
++
++/* Flags for `mlockall'. */
++#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
++#define MCL_FUTURE 2 /* Lock all additions to address
++ space. */
++
++/* Flags for `mremap'. */
++#ifdef __USE_GNU
++# define MREMAP_MAYMOVE 1
++#endif
++
++/* Advise to `madvise'. */
++#ifdef __USE_BSD
++# define MADV_NORMAL 0 /* No further special treatment. */
++# define MADV_RANDOM 1 /* Expect random page references. */
++# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define MADV_WILLNEED 3 /* Will need these pages. */
++# define MADV_DONTNEED 4 /* Don't need these pages. */
++#endif
++
++/* The POSIX people had to invent similar names for the same things. */
++#ifdef __USE_XOPEN2K
++# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
++# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
++# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
++# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
++#endif
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/profil-counter.h b/libc/sysdeps/linux/avr32/bits/profil-counter.h
+--- a/libc/sysdeps/linux/avr32/bits/profil-counter.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/profil-counter.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,26 @@
++/* Low-level statistical profiling support function. Linux/AVR32 version.
++ Copyright (C) 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#include <signal.h>
++
++void
++profil_counter(int signo, siginfo_t *si, struct sigcontext *sc)
++{
++ profil_count((void *)sc->pc);
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/setjmp.h b/libc/sysdeps/linux/avr32/bits/setjmp.h
+--- a/libc/sysdeps/linux/avr32/bits/setjmp.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/setjmp.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,21 @@
++/*
++ * Copyright (C) 2004-2005 Atmel Norway
++ */
++#ifndef _SETJMP_H
++# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
++#endif
++
++#ifndef _ASM
++/*
++ * The jump buffer contains r0-r7, sr, sp and lr. Other registers are
++ * not saved.
++ */
++typedef int __jmp_buf[11];
++#endif
++
++#define __JMP_BUF_SP 4
++
++/* Test if longjmp to JMPBUF would unwind the frame containing a local
++ variable at ADDRESS. */
++#define _JMPBUF_UNWINDS(jmpbuf, address) \
++ ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/syscalls.h b/libc/sysdeps/linux/avr32/bits/syscalls.h
+--- a/libc/sysdeps/linux/avr32/bits/syscalls.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/syscalls.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,143 @@
++#ifndef _SYSCALL_H
++# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
++#endif
++
++/*
++ * This includes the `__NR_<name>' syscall numbers taken from the
++ * Linux kernel header files. It also defines the traditional
++ * `SYS_<name>' macros for older programs.
++ */
++#include <bits/sysnum.h>
++
++#ifndef __set_errno
++# define __set_errno(val) (*__errno_location()) = (val)
++#endif
++#ifndef SYS_ify
++# define SYS_ify(syscall_name) (__NR_##syscall_name)
++#endif
++
++#ifndef __ASSEMBLER__
++
++#undef _syscall0
++#define _syscall0(type,name) \
++ type name(void) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 0)); \
++ }
++
++#undef _syscall1
++#define _syscall1(type,name,type1,arg1) \
++ type name(type1 arg1) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 1, arg1)); \
++ }
++
++#undef _syscall2
++#define _syscall2(type,name,type1,arg1,type2,arg2) \
++ type name(type1 arg1, type2 arg2) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 2, arg1, arg2)); \
++ }
++
++#undef _syscall3
++#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
++ type name(type1 arg1, type2 arg2, type3 arg3) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 3, arg1, \
++ arg2, arg3)); \
++ }
++
++#undef _syscall4
++#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 4, arg1, arg2, \
++ arg3, arg4)); \
++ }
++
++#undef _syscall5
++#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4,type5,arg5) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
++ type5 arg5) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 5, arg1, arg2, \
++ arg3, arg4, arg5)); \
++ }
++
++#undef _syscall6
++#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4,type5,arg5,type6,arg6) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
++ type5 arg5, type6 arg6) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
++ arg4, arg5, arg6)); \
++ }
++
++#undef unlikely
++#define unlikely(x) __builtin_expect((x), 0)
++
++#undef INLINE_SYSCALL
++#define INLINE_SYSCALL(name, nr, args...) \
++ ({ \
++ unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
++ __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
++ _sys_result = (unsigned int) -1; \
++ } \
++ (int) _sys_result; \
++ })
++
++#undef INTERNAL_SYSCALL_DECL
++#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
++
++#undef INTERNAL_SYSCALL
++#define INTERNAL_SYSCALL(name, err, nr, args...) \
++ ({ \
++ register int _a1 asm ("r12"); \
++ register int _scno asm("r8") = SYS_ify(name); \
++ LOAD_ARGS_##nr (args); \
++ asm volatile ("scall /* syscall " #name " */" \
++ : "=r" (_a1) \
++ : "r"(_scno) ASM_ARGS_##nr \
++ : "lr", "cc", "memory"); \
++ _a1; \
++ })
++
++#undef INTERNAL_SYSCALL_ERROR_P
++#define INTERNAL_SYSCALL_ERROR_P(val, err) \
++ ((unsigned int)(val) >= 0xfffff001U)
++
++#undef INTERNAL_SYSCALL_ERRNO
++#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
++
++#define LOAD_ARGS_0() do { } while(0)
++#define ASM_ARGS_0
++#define LOAD_ARGS_1(a1) \
++ _a1 = (int) (a1); \
++ LOAD_ARGS_0()
++#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
++#define LOAD_ARGS_2(a1, a2) \
++ register int _a2 asm("r11") = (int)(a2); \
++ LOAD_ARGS_1(a1)
++#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
++#define LOAD_ARGS_3(a1, a2, a3) \
++ register int _a3 asm("r10") = (int)(a3); \
++ LOAD_ARGS_2(a1, a2)
++#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
++#define LOAD_ARGS_4(a1, a2, a3, a4) \
++ register int _a4 asm("r9") = (int)(a4); \
++ LOAD_ARGS_3(a1, a2, a3)
++#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
++#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
++ register int _a5 asm("r5") = (int)(a5); \
++ LOAD_ARGS_4(a1, a2, a3, a4)
++#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
++#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
++ register int _a6 asm("r3") = (int)(a6); \
++ LOAD_ARGS_5(a1, a2, a3, a4, a5)
++#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
++
++#endif /* __ASSEMBLER__ */
+diff -Nrup a/libc/sysdeps/linux/avr32/bits/wordsize.h b/libc/sysdeps/linux/avr32/bits/wordsize.h
+--- a/libc/sysdeps/linux/avr32/bits/wordsize.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bits/wordsize.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1 @@
++#define __WORDSIZE 32
+diff -Nrup a/libc/sysdeps/linux/avr32/brk.c b/libc/sysdeps/linux/avr32/brk.c
+--- a/libc/sysdeps/linux/avr32/brk.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/brk.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,23 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++#include <errno.h>
++#include <sys/syscall.h>
++
++void *__curbrk = 0;
++
++int brk (void *addr)
++{
++ void *newbrk;
++
++ newbrk = INLINE_SYSCALL(brk, 1, addr);
++
++ __curbrk = newbrk;
++
++ if (newbrk < addr) {
++ __set_errno (ENOMEM);
++ return -1;
++ }
++
++ return 0;
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/bsd-_setjmp.S b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
+--- a/libc/sysdeps/linux/avr32/bsd-_setjmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bsd-_setjmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,12 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++
++ /* This just does a tail-call to __sigsetjmp(env, 0) */
++ .global _setjmp
++ .type _setjmp,"function"
++ .align 1
++_setjmp:
++ mov r11, 0
++ bral __sigsetjmp_internal
++ .size _setjmp, . - _setjmp
+diff -Nrup a/libc/sysdeps/linux/avr32/bsd-setjmp.S b/libc/sysdeps/linux/avr32/bsd-setjmp.S
+--- a/libc/sysdeps/linux/avr32/bsd-setjmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/bsd-setjmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,12 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++
++ /* This just does a tail-call to __sigsetjmp(env, 1) */
++ .global setjmp
++ .type setjmp,"function"
++ .align 1
++setjmp:
++ mov r11, 1
++ bral __sigsetjmp_internal
++ .size setjmp, . - setjmp
+diff -Nrup a/libc/sysdeps/linux/avr32/clone.c b/libc/sysdeps/linux/avr32/clone.c
+--- a/libc/sysdeps/linux/avr32/clone.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/clone.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,37 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++#include <errno.h>
++#include <sys/syscall.h>
++#include <unistd.h>
++
++/*
++ * I don't know if we can be absolutely certain that the fn and arg
++ * parameters are preserved when returning as the child. If the
++ * compiler stores them in registers (r0-r7), they should be.
++ */
++int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
++{
++ register int (*_fn)(void *arg) = fn;
++ register void *_arg = arg;
++ int err;
++
++ /* Sanity check the arguments */
++ err = -EINVAL;
++ if (!fn)
++ goto syscall_error;
++ if (!child_stack)
++ goto syscall_error;
++
++ err = INLINE_SYSCALL(clone, 2, flags, child_stack);
++ if (err < 0)
++ goto syscall_error;
++ else if (err != 0)
++ return err;
++
++ _exit(_fn(_arg));
++
++syscall_error:
++ __set_errno (-err);
++ return -1;
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/crt1.S b/libc/sysdeps/linux/avr32/crt1.S
+--- a/libc/sysdeps/linux/avr32/crt1.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/crt1.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,93 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ *
++ * When we enter _start, the stack looks like this:
++ * argc argument counter
++ * argv[0] pointer to program name
++ * argv[1..argc-1] pointers to program args
++ * NULL
++ * env[0..N] pointers to environment variables
++ * NULL
++ *
++ * r12 contains a function pointer to be registered with `atexit'.
++ * This is how the dynamic linker arranges to have DT_FINI functions
++ * called for shared libraries that have been loaded before this
++ * code runs.
++ *
++ * We're going to call the following function:
++ * __uClibc_main(int (*main)(int, char **, char **), int argc,
++ * char **argv, void (*app_init)(void), void (*app_fini)(void),
++ * void (*rtld_fini)(void), void *stack_end)
++ *
++ * So we need to set up things as follows:
++ * r12 = address of main
++ * r11 = argc
++ * r10 = &argv[0]
++ * r9 = address of _init
++ * r8 = address of _fini
++ * sp[0] = whatever we got passed in r12
++ */
++
++#include <features.h>
++
++ .text
++ .global _start
++ .type _start, @function
++_start:
++ /* Clear the frame pointer and link register since this is the outermost frame. */
++ mov r7, 0
++ mov lr, 0
++
++ ld.w r11, sp++ /* argc */
++ mov r10, sp /* &argv[0] */
++
++ st.w --sp, r10 /* stack_end */
++ st.w --sp, r12 /* rtld_fini */
++
++#ifdef __PIC__
++ lddpc r6, .L_GOT
++.L_RGOT:
++ rsub r6, pc
++ lda.w r9, _init
++ lda.w r8, _fini
++ lda.w r12, main
++
++ /* Ok, now run uClibc's main() -- should not return */
++ call __uClibc_main
++
++ .align 2
++.L_GOT:
++ .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
++#else
++ lddpc r9, __init_addr /* app_init */
++ lddpc r8, __fini_addr /* app_fini */
++ lddpc r12, __main_addr /* main */
++
++ /* Ok, now run uClibc's main() -- should not return */
++ lddpc pc, ___uClibc_main_addr
++
++ .align 2
++__init_addr:
++ .long _init
++__fini_addr:
++ .long _fini
++__main_addr:
++ .long main
++___uClibc_main_addr:
++ .long __uClibc_main
++#endif
++ .size _start, . - _start
++
++ /*
++ * The LSB says we need this.
++ */
++ .section ".note.ABI-tag", "a"
++ .align 4
++ .long 2f - 1f /* namesz */
++ .long 4f - 3f /* descsz */
++ .long 1 /* type */
++1: .asciz "GNU" /* name */
++2: .align 4
++3: .long 0 /* Linux executable */
++ .long 2,6,0 /* Earliest compatible kernel */
++4: .align 4
+diff -Nrup a/libc/sysdeps/linux/avr32/crti.S b/libc/sysdeps/linux/avr32/crti.S
+--- a/libc/sysdeps/linux/avr32/crti.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/crti.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,17 @@
++
++ .section .init
++ .align 2
++ .global _init
++ .type _init, @function
++_init:
++ /* Use a four-byte instruction to avoid NOPs */
++ stm --sp, r0-r7,lr
++ .align 2
++
++ .section .fini
++ .align 2
++ .global _fini
++ .type _fini, @function
++_fini:
++ stm --sp, r0-r7,lr
++ .align 2
+diff -Nrup a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S
+--- a/libc/sysdeps/linux/avr32/crtn.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/crtn.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,14 @@
++
++ .section .init
++ .align 2
++ .global _init
++ .type _init, @function
++ ldm sp++, r0-r7,pc
++ .size _init, . - _init
++
++ .section .fini
++ .align 2
++ .global _fini
++ .type _fini, @function
++ ldm sp++, r0-r7,pc
++ .size _fini, . - _fini
+diff -Nrup a/libc/sysdeps/linux/avr32/__longjmp.S b/libc/sysdeps/linux/avr32/__longjmp.S
+--- a/libc/sysdeps/linux/avr32/__longjmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/__longjmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,17 @@
++/* longjmp for AVR32
++ *
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++
++ .global __longjmp
++ .type __longjmp,"function"
++ .align 1
++__longjmp:
++ ldm r12++, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
++ mov r12, r11 /* get the return value right */
++ mustr r8 /* restore status register (lower half) */
++ cp r12, 0 /* can't return zero */
++ frs
++ moveq r12, 1
++ mov pc,lr
++ .size __longjmp, . - __longjmp
+diff -Nrup a/libc/sysdeps/linux/avr32/Makefile b/libc/sysdeps/linux/avr32/Makefile
+--- a/libc/sysdeps/linux/avr32/Makefile 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/Makefile 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,93 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++#
++# You should have received a copy of the GNU Library General Public License
++# along with this program; if not, write to the Free Software Foundation, Inc.,
++# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++TOPDIR=../../../../
++include $(TOPDIR)Rules.mak
++ASFLAGS=$(CFLAGS)
++
++CRT_SRC = crt1.S
++CRT_OBJ = crt1.o
++SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ))
++CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
++
++SSRC=__longjmp.S setjmp.S bsd-setjmp.S vfork.S \
++ bsd-_setjmp.S sigrestorer.S syscall.S
++SOBJS=$(patsubst %.S,%.o, $(SSRC))
++
++CSRC=clone.c brk.c sigaction.c mmap.c
++COBJS=$(patsubst %.c,%.o, $(CSRC))
++
++OBJS=$(SOBJS) $(COBJS)
++
++OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH)
++
++all: $(OBJ_LIST)
++
++$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS)
++ echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST)
++ $(INSTALL) -d $(TOPDIR)lib/
++ cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/
++
++$(CRT_OBJ): $(CRT_SRC)
++ $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
++ $(STRIPTOOL) -x -R .note -R .comment $*.o
++
++$(SCRT_OBJ): $(CRT_SRC)
++ $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o
++ $(STRIPTOOL) -x -R .note -R .comment $*.o
++
++$(SOBJS): %.o : %.S
++ $(CC) $(ASFLAGS) -c $< -o $@
++ $(STRIPTOOL) -x -R .note -R .comment $*.o
++
++$(COBJS): %.o : %.c
++ $(CC) $(CFLAGS) -c $< -o $@
++ $(STRIPTOOL) -x -R .note -R .comment $*.o
++
++ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
++crti.o: crti.S
++ $(CC) $(ASFLAGS) -c crti.S -o crti.o
++
++$(TOPDIR)lib/crti.o: crti.o
++ $(INSTALL) -d $(TOPDIR)lib/
++ cp crti.o $(TOPDIR)lib/
++
++crtn.o: crtn.S
++ $(CC) $(ASFLAGS) -c crtn.S -o crtn.o
++
++$(TOPDIR)lib/crtn.o: crtn.o
++ $(INSTALL) -d $(TOPDIR)lib/
++ cp crtn.o $(TOPDIR)lib/
++else
++$(TOPDIR)lib/crti.o:
++ $(INSTALL) -d $(TOPDIR)lib/
++ $(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
++$(TOPDIR)lib/crtn.o:
++ $(INSTALL) -d $(TOPDIR)lib/
++ $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
++endif
++
++
++headers:
++# $(LN) -fs ../libc/sysdeps/linux/avr32/fpu_control.h $(TOPDIR)/include/
++
++clean:
++ $(RM) *.[oa] *~ core
++ $(RM) bits/sysnum.h
++ $(RM) gmon-start.S
++
+diff -Nrup a/libc/sysdeps/linux/avr32/_mmap.c b/libc/sysdeps/linux/avr32/_mmap.c
+--- a/libc/sysdeps/linux/avr32/_mmap.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/_mmap.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,33 @@
++/* Copyright (C) 2005 Atmel Norway
++
++ This program is free software; you can redistribute it and/or modify it under
++ the terms of the GNU Library General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at your option) any
++ later version.
++
++ This program is distributed in the hope that it will be useful, but WITHOUT
++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++ FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++ details.
++
++ You should have received a copy of the GNU Library General Public License
++ along with this program; if not, write to the Free Software Foundation, Inc.,
++ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++ Derived in part from the Linux-8086 C library, the GNU C Library, and several
++ other sundry sources. Files within this library are copyright by their
++ respective copyright holders.
++ */
++
++#include <errno.h>
++#include <sys/mman.h>
++#include <sys/syscall.h>
++
++#define __NR_mmap2 __NR_mmap
++
++static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, pgoff);
++
++__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
++{
++ return mmap2(addr, len, prot, flags, fd, offset >> 12);
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/mmap.c b/libc/sysdeps/linux/avr32/mmap.c
+--- a/libc/sysdeps/linux/avr32/mmap.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/mmap.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2005 Atmel Norway
++
++ This program is free software; you can redistribute it and/or modify it under
++ the terms of the GNU Library General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at your option) any
++ later version.
++
++ This program is distributed in the hope that it will be useful, but WITHOUT
++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++ FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++ details.
++
++ You should have received a copy of the GNU Library General Public License
++ along with this program; if not, write to the Free Software Foundation, Inc.,
++ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++ Derived in part from the Linux-8086 C library, the GNU C Library, and several
++ other sundry sources. Files within this library are copyright by their
++ respective copyright holders.
++ */
++
++#include <errno.h>
++#include <sys/mman.h>
++#include <sys/syscall.h>
++
++static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, pgoff);
++
++__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
++{
++ return mmap2(addr, len, prot, flags, fd, offset >> 12);
++}
+diff -Nrup a/libc/sysdeps/linux/avr32/setjmp.S b/libc/sysdeps/linux/avr32/setjmp.S
+--- a/libc/sysdeps/linux/avr32/setjmp.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/setjmp.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++#define _SETJMP_H
++#define _ASM
++#include <bits/setjmp.h>
++
++ .text
++
++ .global __sigsetjmp
++ .type __sigsetjmp,"function"
++
++ /* Create a global, hidden symbol for use by setjmp() and _setjmp().
++ If it's not hidden, the linker will complain about a relative
++ jump to a dynamic symbol when building a shared library.
++
++ Also, if a user overrides the __sigsetjmp function, he might not
++ expect the setjmp() and _setjmp() function to effectively be
++ overridden as well. */
++ .global __sigsetjmp_internal
++ .hidden __sigsetjmp_internal
++ .type __sigsetjmp_internal,"function"
++ .align 1
++__sigsetjmp:
++__sigsetjmp_internal:
++ mustr r8
++ stm r12, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
++
++ /* Make a tail call to __sigjmp_save; it takes the same args. */
++#ifdef __PIC__
++ mov r9, r6
++ lddpc r6, .LG
++.L1: rsub r6, pc
++ ld.w r8, r6[__sigjmp_save@got]
++ mov r6, r9
++ mov pc, r8
++
++ .align 2
++.LG: .long .L1 - _GLOBAL_OFFSET_TABLE_
++#else
++ rjmp __sigjmp_save
++#endif
++ .size __sigsetjmp, . - __sigsetjmp
+diff -Nrup a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c
+--- a/libc/sysdeps/linux/avr32/sigaction.c 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sigaction.c 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,49 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++#include <errno.h>
++#include <signal.h>
++#include <string.h>
++#include <sys/syscall.h>
++#include <bits/kernel_sigaction.h>
++
++#define SA_RESTORER 0x04000000
++extern void __default_rt_sa_restorer(void);
++
++/*
++ * If act is not NULL, change the action for sig to *act.
++ * If oact is not NULL, put the old action for sig in *oact.
++ */
++int __libc_sigaction(int signum, const struct sigaction *act,
++ struct sigaction *oldact)
++{
++ struct kernel_sigaction kact, koact;
++ int result;
++
++ if (act) {
++ kact.k_sa_handler = act->sa_handler;
++ memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
++ kact.sa_flags = act->sa_flags;
++ if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
++ kact.sa_restorer = act->sa_restorer;
++ else
++ kact.sa_restorer = __default_rt_sa_restorer;
++ kact.sa_flags |= SA_RESTORER;
++ }
++
++ result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
++ oldact ? __ptrvalue(&koact) : NULL,
++ _NSIG / 8);
++
++ if (oldact && result >= 0) {
++ oldact->sa_handler = koact.k_sa_handler;
++ memcpy(&oldact->sa_mask, &koact.sa_mask,
++ sizeof(oldact->sa_mask));
++ oldact->sa_flags = koact.sa_flags;
++ oldact->sa_restorer = koact.sa_restorer;
++ }
++
++ return result;
++}
++
++weak_alias(__libc_sigaction, sigaction)
+diff -Nrup a/libc/sysdeps/linux/avr32/sigrestorer.S b/libc/sysdeps/linux/avr32/sigrestorer.S
+--- a/libc/sysdeps/linux/avr32/sigrestorer.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sigrestorer.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,11 @@
++/*
++ * Copyright (C) 2004 Atmel Norway AS
++ */
++#include <sys/syscall.h>
++
++ .global __default_rt_sa_restorer
++ .type __default_rt_sa_restorer,"function"
++ .align 1
++__default_rt_sa_restorer:
++ mov r8, __NR_rt_sigreturn
++ scall
+diff -Nrup a/libc/sysdeps/linux/avr32/sys/elf.h b/libc/sysdeps/linux/avr32/sys/elf.h
+--- a/libc/sysdeps/linux/avr32/sys/elf.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sys/elf.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,26 @@
++/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_ELF_H
++#define _SYS_ELF_H 1
++
++#warning "This header is obsolete; use <sys/procfs.h> instead."
++
++#include <sys/procfs.h>
++
++#endif /* sys/elf.h */
+diff -Nrup a/libc/sysdeps/linux/avr32/sys/io.h b/libc/sysdeps/linux/avr32/sys/io.h
+--- a/libc/sysdeps/linux/avr32/sys/io.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sys/io.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,48 @@
++/* Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_IO_H
++
++#define _SYS_IO_H 1
++#include <features.h>
++
++__BEGIN_DECLS
++
++/* If TURN_ON is TRUE, request for permission to do direct i/o on the
++ port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
++ permission off for that range. This call requires root privileges. */
++extern int ioperm (unsigned long int __from, unsigned long int __num,
++ int __turn_on) __THROW;
++
++/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero,
++ permission to access any I/O port is granted. This call requires
++ root privileges. */
++extern int iopl (int __level) __THROW;
++
++/* The functions that actually perform reads and writes. */
++extern unsigned char inb (unsigned long int port) __THROW;
++extern unsigned short int inw (unsigned long int port) __THROW;
++extern unsigned long int inl (unsigned long int port) __THROW;
++
++extern void outb (unsigned char value, unsigned long int port) __THROW;
++extern void outw (unsigned short value, unsigned long int port) __THROW;
++extern void outl (unsigned long value, unsigned long int port) __THROW;
++
++__END_DECLS
++
++#endif /* _SYS_IO_H */
+diff -Nrup a/libc/sysdeps/linux/avr32/sys/procfs.h b/libc/sysdeps/linux/avr32/sys/procfs.h
+--- a/libc/sysdeps/linux/avr32/sys/procfs.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sys/procfs.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,123 @@
++/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_PROCFS_H
++#define _SYS_PROCFS_H 1
++
++/* This is somewhat modelled after the file of the same name on SVR4
++ systems. It provides a definition of the core file format for ELF
++ used on Linux. It doesn't have anything to do with the /proc file
++ system, even though Linux has one.
++
++ Anyway, the whole purpose of this file is for GDB and GDB only.
++ Don't read too much into it. Don't use it for anything other than
++ GDB unless you know what you are doing. */
++
++#include <features.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/user.h>
++
++__BEGIN_DECLS
++
++/* Type for a general-purpose register. */
++typedef unsigned long elf_greg_t;
++
++/* And the whole bunch of them. We could have used `struct
++ user_regs' directly in the typedef, but tradition says that
++ the register set is an array, which does have some peculiar
++ semantics, so leave it that way. */
++#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
++typedef elf_greg_t elf_gregset_t[ELF_NGREG];
++
++/* Register set for the floating-point registers. */
++typedef struct user_fpregs elf_fpregset_t;
++
++/* Signal info. */
++struct elf_siginfo
++ {
++ int si_signo; /* Signal number. */
++ int si_code; /* Extra code. */
++ int si_errno; /* Errno. */
++ };
++
++/* Definitions to generate Intel SVR4-like core files. These mostly
++ have the same names as the SVR4 types with "elf_" tacked on the
++ front to prevent clashes with Linux definitions, and the typedef
++ forms have been avoided. This is mostly like the SVR4 structure,
++ but more Linuxy, with things that Linux does not support and which
++ GDB doesn't really use excluded. */
++
++struct elf_prstatus
++ {
++ struct elf_siginfo pr_info; /* Info associated with signal. */
++ short int pr_cursig; /* Current signal. */
++ unsigned long int pr_sigpend; /* Set of pending signals. */
++ unsigned long int pr_sighold; /* Set of held signals. */
++ __pid_t pr_pid;
++ __pid_t pr_ppid;
++ __pid_t pr_pgrp;
++ __pid_t pr_sid;
++ struct timeval pr_utime; /* User time. */
++ struct timeval pr_stime; /* System time. */
++ struct timeval pr_cutime; /* Cumulative user time. */
++ struct timeval pr_cstime; /* Cumulative system time. */
++ elf_gregset_t pr_reg; /* GP registers. */
++ int pr_fpvalid; /* True if math copro being used. */
++ };
++
++
++#define ELF_PRARGSZ (80) /* Number of chars for args. */
++
++struct elf_prpsinfo
++ {
++ char pr_state; /* Numeric process state. */
++ char pr_sname; /* Char for pr_state. */
++ char pr_zomb; /* Zombie. */
++ char pr_nice; /* Nice val. */
++ unsigned long int pr_flag; /* Flags. */
++ unsigned short int pr_uid;
++ unsigned short int pr_gid;
++ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
++ /* Lots missing */
++ char pr_fname[16]; /* Filename of executable. */
++ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
++ };
++
++/* The rest of this file provides the types for emulation of the
++ Solaris <proc_service.h> interfaces that should be implemented by
++ users of libthread_db. */
++
++/* Addresses. */
++typedef void *psaddr_t;
++
++/* Register sets. Linux has different names. */
++typedef elf_gregset_t prgregset_t;
++typedef elf_fpregset_t prfpregset_t;
++
++/* We don't have any differences between processes and threads,
++ therefore have only one PID type. */
++typedef __pid_t lwpid_t;
++
++/* Process status and info. In the end we do provide typedefs for them. */
++typedef struct elf_prstatus prstatus_t;
++typedef struct elf_prpsinfo prpsinfo_t;
++
++__END_DECLS
++
++#endif /* sys/procfs.h */
+diff -Nrup a/libc/sysdeps/linux/avr32/sys/ucontext.h b/libc/sysdeps/linux/avr32/sys/ucontext.h
+--- a/libc/sysdeps/linux/avr32/sys/ucontext.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sys/ucontext.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,94 @@
++/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++/* Linux/AVR32 ABI compliant context switching support. */
++
++#ifndef _SYS_UCONTEXT_H
++#define _SYS_UCONTEXT_H 1
++
++#include <features.h>
++#include <signal.h>
++#include <sys/procfs.h>
++#include <bits/sigcontext.h>
++
++typedef int greg_t;
++
++/* Number of general registers. */
++#define NGREG 16
++
++/* Container for all general registers. */
++typedef elf_gregset_t gregset_t;
++
++/* Number of each register is the `gregset_t' array. */
++enum
++{
++ R0 = 0,
++#define R0 R0
++ R1 = 1,
++#define R1 R1
++ R2 = 2,
++#define R2 R2
++ R3 = 3,
++#define R3 R3
++ R4 = 4,
++#define R4 R4
++ R5 = 5,
++#define R5 R5
++ R6 = 6,
++#define R6 R6
++ R7 = 7,
++#define R7 R7
++ R8 = 8,
++#define R8 R8
++ R9 = 9,
++#define R9 R9
++ R10 = 10,
++#define R10 R10
++ R11 = 11,
++#define R11 R11
++ R12 = 12,
++#define R12 R12
++ R13 = 13,
++#define R13 R13
++ R14 = 14,
++#define R14 R14
++ R15 = 15
++#define R15 R15
++};
++
++/* Structure to describe FPU registers. */
++typedef elf_fpregset_t fpregset_t;
++
++/* Context to describe whole processor state. */
++typedef struct
++ {
++ gregset_t gregs;
++ fpregset_t fpregs;
++ } mcontext_t;
++
++/* Userlevel context. */
++typedef struct ucontext
++{
++ unsigned long uc_flags;
++ struct ucontext *uc_link;
++ stack_t uc_stack;
++ struct sigcontext uc_mcontext;
++ sigset_t uc_sigmask; /* mask last for extensibility */
++} ucontext_t;
++
++#endif /* sys/ucontext.h */
+diff -Nrup a/libc/sysdeps/linux/avr32/sys/user.h b/libc/sysdeps/linux/avr32/sys/user.h
+--- a/libc/sysdeps/linux/avr32/sys/user.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/sys/user.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,46 @@
++#ifndef _SYS_USER_H
++#define _SYS_USER_H
++
++struct user_fpregs
++{
++
++};
++
++struct user_regs
++{
++ unsigned long sr;
++ unsigned long pc;
++ unsigned long lr;
++ unsigned long sp;
++ unsigned long r12;
++ unsigned long r11;
++ unsigned long r10;
++ unsigned long r9;
++ unsigned long r8;
++ unsigned long r7;
++ unsigned long r6;
++ unsigned long r5;
++ unsigned long r4;
++ unsigned long r3;
++ unsigned long r2;
++ unsigned long r1;
++ unsigned long r0;
++ unsigned long r12_orig;
++};
++
++struct user
++{
++ struct user_regs regs; /* general registers */
++ size_t u_tsize; /* text size (pages) */
++ size_t u_dsize; /* data size (pages) */
++ size_t u_ssize; /* stack size (pages) */
++ unsigned long start_code; /* text starting address */
++ unsigned long start_data; /* data starting address */
++ unsigned long start_stack; /* stack starting address */
++ long int signal; /* signal causing core dump */
++ struct user_regs * u_ar0; /* help gdb find registers */
++ unsigned long magic; /* identifies a core file */
++ char u_comm[32]; /* user command name */
++};
++
++#endif /* _SYS_USER_H */
+diff -Nrup a/libc/sysdeps/linux/avr32/syscall.S b/libc/sysdeps/linux/avr32/syscall.S
+--- a/libc/sysdeps/linux/avr32/syscall.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/syscall.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,81 @@
++/*
++ * syscall for AVR32/uClibc
++ *
++ * Copyright (C) 2004 Atmel Norway
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU Library General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or (at your
++ * option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
++ * for more details.
++ *
++ * You should have received a copy of the GNU Library General Public License
++ * along with this program; if not, write to the Free Software Foundation,
++ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++#include <features.h>
++
++ .text
++
++ /*
++ * long int syscall(long int sysno, ...)
++ */
++ .global syscall
++ .type syscall, @function
++ .align 2
++syscall:
++ stm --sp, r3,r5,lr
++ sub lr, sp, -12
++ mov r8, r12
++ ldm lr, r3,r5,r9-r12
++ scall
++ cp.w r12, -4095
++ brlo .Ldone
++
++#ifdef __PIC__
++ lddpc r5, .Lgot
++.Lgotcalc:
++ rsub r5, pc
++# ifdef __UCLIBC_HAS_THREADS__
++ mov r3, r12
++ mcall r5[__errno_location@got]
++ st.w r12[0], r3
++# else
++ ld.w r3, r5[errno@got]
++ st.w r3[0], r12
++# endif
++#else
++# ifdef __UCLIBC_HAS_THREADS__
++ mov r3, r12
++ mcall .Lerrno_location
++ st.w r12[0], r3
++# else
++ lddpc r3, .Lerrno
++ st.w r3[0], r12
++# endif
++#endif
++ mov r12, -1
++
++.Ldone:
++ ldm sp++, r3,r5,pc
++
++ .align 2
++#ifdef __PIC__
++.Lgot:
++ .long .Lgotcalc - _GLOBAL_OFFSET_TABLE_
++#else
++# ifdef __UCLIBC_HAS_THREADS__
++.Lerrno_location:
++ .long __errno_location
++# else
++.Lerrno:
++ .long errno
++# endif
++#endif
++
++
++ .size syscall, . - syscall
+diff -Nrup a/libc/sysdeps/linux/avr32/vfork.S b/libc/sysdeps/linux/avr32/vfork.S
+--- a/libc/sysdeps/linux/avr32/vfork.S 1969-12-31 19:00:00.000000000 -0500
++++ b/libc/sysdeps/linux/avr32/vfork.S 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,55 @@
++ /*
++ * vfork for uClibc
++ *
++ * Copyright (C) 2005 Atmel Norway
++ */
++
++ /*
++ * Clone the process without copying the address space. The
++ * calling process is suspended until the child either exits
++ * or calls execve.
++ *
++ * This all means that we cannot rely on the stack to store
++ * away registers, since they will be overwritten by the child
++ * as soon as it makes another function call (e.g. execve()).
++ * Fortunately, the Linux kernel preserves LR across system calls.
++ */
++#include <features.h>
++#include <sys/syscall.h>
++
++ .global __vfork
++ .type __vfork,@function
++ .align 1
++__vfork:
++ mov r8, __NR_vfork
++ scall
++ cp.w r12, -4096
++ retls r12
++
++ /* vfork failed, so we may use the stack freely */
++ pushm r4-r7,lr
++#ifdef __PIC__
++ lddpc r6, .L_GOT
++ rsub r4, r12, 0
++.L_RGOT:
++ rsub r6, pc
++ mcall r6[__errno_location@got]
++#else
++ rsub r4, r12, 0
++ mcall .L__errno_location
++#endif
++ st.w r12[0], r4
++ popm r4-r7,pc,r12=-1
++
++ .align 2
++#ifdef __PIC__
++.L_GOT:
++ .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
++#else
++.L__errno_location:
++ .long __errno_location
++#endif
++ .size __vfork, . - __vfork
++
++ .weak vfork
++ vfork = __vfork
+diff -Nrup a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
+--- a/libc/sysdeps/linux/common/create_module.c 2004-03-11 19:21:20.000000000 -0500
++++ b/libc/sysdeps/linux/common/create_module.c 2008-02-28 19:02:10.000000000 -0500
+@@ -61,7 +61,8 @@ unsigned long create_module(const char *
+ {
+ return __create_module(name, size, 0, 0);
+ }
+-#else
++/* create_module is obsolete in Linux 2.6, so AVR32 doesn't have it */
++#elif !defined(__avr32__)
+ /* Sparc, MIPS, etc don't mistake return values for errors. */
+ _syscall2(unsigned long, create_module, const char *, name, size_t, size);
+ #endif
+diff -Nrup a/libc/sysdeps/linux/common/getrusage.c b/libc/sysdeps/linux/common/getrusage.c
+--- a/libc/sysdeps/linux/common/getrusage.c 2005-01-05 18:11:28.000000000 -0500
++++ b/libc/sysdeps/linux/common/getrusage.c 2008-02-28 19:02:10.000000000 -0500
+@@ -10,4 +10,4 @@
+ #include "syscalls.h"
+ #include <unistd.h>
+ #include <wait.h>
+-_syscall2(int, getrusage, int, who, struct rusage *, usage);
++_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);
+diff -Nrup a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c
+--- a/libc/sysdeps/linux/common/open64.c 2002-10-31 13:20:21.000000000 -0500
++++ b/libc/sysdeps/linux/common/open64.c 2008-02-28 19:02:10.000000000 -0500
+@@ -26,7 +26,7 @@
+ #endif
+
+ #ifdef __UCLIBC_HAS_LFS__
+-extern int __libc_open (__const char *file, int oflag, mode_t mode);
++extern int __libc_open (__const char *file, int oflag, ...);
+
+ /* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
+ a third argument is the file protection. */
+diff -Nrup a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
+--- a/libc/sysdeps/linux/common/__syscall_fcntl.c 2005-07-30 10:02:24.000000000 -0400
++++ b/libc/sysdeps/linux/common/__syscall_fcntl.c 2008-02-28 19:02:10.000000000 -0500
+@@ -12,7 +12,7 @@
+ #include <fcntl.h>
+
+ #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
+-extern int __libc_fcntl64(int fd, int cmd, long arg);
++extern int __libc_fcntl64(int fd, int cmd, ...);
+ #endif
+
+ #define __NR___syscall_fcntl __NR_fcntl
+diff -Nrup a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
+--- a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h 1969-12-31 19:00:00.000000000 -0500
++++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,92 @@
++/* Machine-dependent pthreads configuration and inline functions.
++
++ Copyright (C) 2005 Atmel Norway
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public License as
++ published by the Free Software Foundation; either version 2.1 of the
++ License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; see the file COPYING.LIB. If not,
++ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#ifndef _PT_MACHINE_H
++#define _PT_MACHINE_H 1
++
++#include <features.h>
++
++static inline int
++_test_and_set (int *p, int v) __THROW
++{
++ int result;
++
++ __asm__ __volatile__(
++ "/* Inline test and set */\n"
++ "1: ssrf 5\n"
++ " ld.w %0, %2\n"
++ " tst %0, %3\n"
++ " breq 2f\n"
++ " stcond %1, %3\n"
++ " brne 1b\n"
++ "2:"
++ : "=&r"(result), "=m"(*p)
++ : "m"(*p), "r"(v)
++ : "memory", "cc");
++
++ return result;
++}
++
++#ifndef PT_EI
++# define PT_EI extern inline
++#endif
++
++extern long int testandset (int *spinlock);
++extern int __compare_and_swap (long int *p, long int oldval, long int newval);
++
++/* Spinlock implementation; required. */
++PT_EI long int
++testandset (int *spinlock)
++{
++ return _test_and_set(spinlock, 1);
++}
++
++
++/* Get some notion of the current stack. Need not be exactly the top
++ of the stack, just something somewhere in the current frame. */
++#define CURRENT_STACK_FRAME stack_pointer
++register char * stack_pointer __asm__ ("sp");
++
++/* Compare-and-swap for semaphores. */
++
++#define HAS_COMPARE_AND_SWAP
++PT_EI int
++__compare_and_swap(long int *p, long int oldval, long int newval)
++{
++ long int result, tmp;
++
++ __asm__ __volatile__(
++ "/* Inline compare and swap */\n"
++ "1: ssrf 5\n"
++ " ld.w %1, %3\n"
++ " cp.w %1, %5\n"
++ " sreq %0\n"
++ " brne 2f\n"
++ " stcond %2, %4\n"
++ " brne 1b\n"
++ "2:"
++ : "=&r"(result), "=&r"(tmp), "=m"(*p)
++ : "m"(*p), "r"(newval), "r"(oldval)
++ : "cc", "memory");
++
++ return result;
++}
++
++#endif /* pt-machine.h */
+diff -Nrup a/Makefile b/Makefile
+--- a/Makefile 2007-02-01 21:24:29.000000000 -0500
++++ b/Makefile 2008-02-28 19:02:10.000000000 -0500
+@@ -163,7 +163,7 @@ install_dev:
+ else \
+ extra_exclude="" ; \
+ fi ; \
+- tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
++ tar -chf - --exclude .svn --exclude CVS $$extra_exclude include \
+ | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
+ echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
+ $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
+diff -Nrup a/Makefile.orig b/Makefile.orig
+--- a/Makefile.orig 1969-12-31 19:00:00.000000000 -0500
++++ b/Makefile.orig 2007-02-01 21:24:29.000000000 -0500
+@@ -0,0 +1,383 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or
++# modify it under the terms of the GNU Library General Public
++# License as published by the Free Software Foundation; either
++# version 2 of the License, or (at your option) any later
++# version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU Library General Public License for more details.
++#
++# You should have received a copy of the GNU Library General
++# Public License along with this program; if not, write to the
++# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
++# Boston, MA 02111-1307 USA
++
++
++#--------------------------------------------------------------
++# You shouldn't need to mess with anything beyond this point...
++#--------------------------------------------------------------
++noconfig_targets := menuconfig config oldconfig randconfig \
++ defconfig allyesconfig allnoconfig clean distclean \
++ release tags TAGS
++TOPDIR=./
++include Rules.mak
++
++DIRS = ldso libc libcrypt libresolv libnsl libutil libm libpthread librt
++ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
++ DIRS += libintl
++endif
++
++ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
++
++all: headers pregen subdirs shared finished
++
++# In this section, we need .config
++-include .config.cmd
++
++shared: subdirs
++ifeq ($(strip $(HAVE_SHARED)),y)
++ $(SECHO)
++ $(SECHO) Building shared libraries ...
++ $(SECHO)
++ @$(MAKE) -C libc shared
++ @$(MAKE) -C ldso shared
++ @$(MAKE) -C libcrypt shared
++ @$(MAKE) -C libresolv shared
++ @$(MAKE) -C libnsl shared
++ @$(MAKE) -C libutil shared
++ @$(MAKE) -C libm shared
++ @$(MAKE) -C libpthread shared
++ @$(MAKE) -C librt shared
++ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
++ @$(MAKE) -C libintl shared
++endif
++else
++ $(SECHO)
++ $(SECHO) Not building shared libraries ...
++ $(SECHO)
++endif
++
++finished: shared
++ $(SECHO)
++ $(SECHO) Finally finished compiling ...
++ $(SECHO)
++
++include/bits/uClibc_config.h: .config
++ @if [ ! -x ./extra/config/conf ] ; then \
++ $(MAKE) -C extra/config conf; \
++ fi;
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -o extra/Configs/Config.in
++
++# For the moment, we have to keep re-running this target
++# because the fix includes scripts rely on pre-processers
++# in order to generate the headers correctly :(. That
++# means we can't use the $(HOSTCC) in order to get the
++# correct output.
++ifeq ($(strip $(ARCH_HAS_MMU)),y)
++export header_extra_args =
++else
++export header_extra_args = -n
++endif
++headers: include/bits/uClibc_config.h
++ @$(SHELL_SET_X); \
++ ./extra/scripts/fix_includes.sh \
++ -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
++ $(header_extra_args)
++ @cd include/bits; \
++ set -e; \
++ for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
++ $(LN) -fs $$i .; \
++ done; \
++ if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
++ for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
++ $(LN) -fs $$i .; \
++ done; \
++ fi
++ @cd include/sys; \
++ set -e; \
++ for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
++ $(LN) -fs $$i .; \
++ done; \
++ if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
++ for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
++ $(LN) -fs $$i .; \
++ done; \
++ fi
++ @cd $(TOPDIR); \
++ set -e; \
++ $(SHELL_SET_X); \
++ TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
++ if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
++ $(RM) include/bits/sysnum.h.new; \
++ else \
++ mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
++ fi
++ $(MAKE) -C libc/sysdeps/linux/common headers
++ $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
++
++# Command used to download source code
++WGET:=wget --passive-ftp
++
++LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
++
++pregen: headers
++ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
++ (cd extra/locale; \
++ if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
++ $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
++ fi );
++endif
++ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
++ (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
++ $(MAKE) -C extra/locale pregen
++endif
++
++
++subdirs: $(patsubst %, _dir_%, $(DIRS))
++$(patsubst %, _dir_%, $(DIRS)): headers
++ $(MAKE) -C $(patsubst _dir_%, %, $@)
++
++tags:
++ ctags -R
++
++install: install_runtime install_dev finished2
++
++
++RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
++
++# Installs header files and development library links.
++install_dev:
++ $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
++ $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
++ -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
++ if [ "$(KERNEL_SOURCE)" = "$(DEVEL_PREFIX)" ] ; then \
++ extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
++ else \
++ extra_exclude="" ; \
++ fi ; \
++ tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
++ | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
++ echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
++ $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
++ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
++ # Remove floating point related headers since float support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
++ # Remove wide char headers since wide char support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
++ # Remove iconv header since locale support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
++ # Remove printf header since custom print specifier support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
++ # Remove xlocale header since extended locale support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
++ # Remove libintl header since gettext support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
++ # Remove regex headers since regex support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
++ # Remove wordexp header since wordexp support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
++ # Remove ftw header since ftw support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
++ # Remove glob header since glob support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
++endif
++ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
++ # Remove getopt header since gnu getopt support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
++endif
++ifneq ($(strip $(HAS_SHADOW)),y)
++ # Remove getopt header since shadow password support is disabled.
++ $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
++endif
++ -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
++ chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
++ done;
++ -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
++ -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
++ifeq ($(strip $(HAVE_SHARED)),y)
++ for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
++ sed -e 's/lib\///'` ; do \
++ $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
++ $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
++ done;
++ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
++ $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
++ $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
++endif
++# # If we build shared libraries then the static libs are PIC...
++# # Make _pic.a symlinks to make mklibs.py and similar tools happy.
++ for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
++ $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
++ | sed -e 's/\.a$$/_pic.a/'`; \
++ done;
++ # Ugh!!! Remember that libdl.a and libdl_pic.a are different. Since
++ # libdl is pretty small, and not likely to benefit from mklibs.py and
++ # similar, lets just remove libdl_pic.a and avoid the issue
++ rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
++endif
++
++
++# Installs run-time libraries
++install_runtime:
++ifeq ($(strip $(HAVE_SHARED)),y)
++ $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
++ $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
++ $(PREFIX)$(RUNTIME_PREFIX)lib
++ cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
++ @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
++ set -e; \
++ $(SHELL_SET_X); \
++ $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
++ $(PREFIX)$(RUNTIME_PREFIX)lib; \
++ fi;
++endif
++
++.PHONY: utils
++ifeq ($(strip $(HAVE_SHARED)),y)
++utils:
++ $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
++else
++utils: dummy
++endif
++
++# Installs helper applications, such as 'ldd' and 'ldconfig'
++install_utils: utils
++ $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
++#ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
++# @$(MAKE) -C libc/misc/wchar iconv.target
++# $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
++# $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
++#endif
++
++finished2:
++ $(SECHO)
++ $(SECHO) Finished installing ...
++ $(SECHO)
++
++else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
++
++all: menuconfig
++
++# configuration
++# ---------------------------------------------------------------------------
++extra/config/conf:
++ $(MAKE) -C extra/config conf
++
++extra/config/mconf:
++ $(MAKE) -C extra/config ncurses mconf
++
++menuconfig: extra/config/mconf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/mconf extra/Configs/Config.in
++
++config: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf extra/Configs/Config.in
++
++oldconfig: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -o extra/Configs/Config.in
++
++randconfig: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -r extra/Configs/Config.in
++
++allyesconfig: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -y extra/Configs/Config.in
++ sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
++ sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
++ sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
++ sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
++ sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
++ @./extra/config/conf -o extra/Configs/Config.in
++
++allnoconfig: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -n extra/Configs/Config.in
++
++defconfig: extra/config/conf
++ $(RM) -r include/bits
++ $(INSTALL) -d include/bits
++ @./extra/config/conf -d extra/Configs/Config.in
++
++clean:
++ - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
++ @$(RM) -r tmp lib include/bits libc/tmp _install
++ $(RM) libc/obj.* headers
++ $(MAKE) -C test clean
++ $(MAKE) -C ldso clean
++ $(MAKE) -C libc/misc/internals clean
++ $(MAKE) -C libc/misc/wchar clean
++ $(MAKE) -C libc/unistd clean
++ $(MAKE) -C libc/sysdeps/linux/common clean
++ $(MAKE) -C extra/locale clean
++ $(MAKE) -C utils clean
++ @set -e; \
++ for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
++ $(RM) include/sys/$$i; \
++ done; \
++ if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
++ for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
++ $(RM) include/sys/$$i; \
++ done; \
++ fi;
++ @$(RM) include/linux include/asm*
++ @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
++ $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
++ fi;
++
++distclean: clean
++ $(RM) .config .config.old .config.cmd
++ $(MAKE) -C extra clean
++
++dist release:
++ $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
++ svn -q export . ../uClibc-$(VERSION)
++ tar cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
++ du -b ../uClibc-$(VERSION).tar.bz2
++
++endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
++
++check:
++ $(MAKE) -C test
++
++.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig
+diff -Nrup a/Rules.mak b/Rules.mak
+--- a/Rules.mak 2007-02-28 16:12:06.000000000 -0500
++++ b/Rules.mak 2008-02-28 19:02:10.000000000 -0500
+@@ -234,6 +234,12 @@ ifeq ($(strip $(TARGET_ARCH)),frv)
+ UCLIBC_LDSO=ld.so.1
+ endif
+
++ifeq ($(strip $(TARGET_ARCH)),avr32)
++ CPU_CFLAGS-$(CONFIG_AP7000) += -mcpu=ap7000
++ CPU_CFLAGS-$(LINKRELAX) += -masm-addr-pseudos -Wa,--pic,--linkrelax
++ CPU_LDFLAGS-$(LINKRELAX) += --relax
++endif
++
+ # Keep the check_gcc from being needlessly executed
+ ifndef PIEFLAG
+ ifneq ($(UCLIBC_BUILD_PIE),y)
+diff -Nrup a/Rules.mak.orig b/Rules.mak.orig
+--- a/Rules.mak.orig 1969-12-31 19:00:00.000000000 -0500
++++ b/Rules.mak.orig 2008-02-28 19:02:10.000000000 -0500
+@@ -0,0 +1,361 @@
++# Rules.make for uClibc
++#
++# Copyright (C) 2000 by Lineo, inc.
++# Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++#
++# You should have received a copy of the GNU Library General Public License
++# along with this program; if not, write to the Free Software Foundation, Inc.,
++# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++
++#-----------------------------------------------------------
++# This file contains rules which are shared between multiple
++# Makefiles. All normal configuration options live in the
++# file named ".config". Don't mess with this file unless
++# you know what you are doing.
++
++
++#-----------------------------------------------------------
++# If you are running a cross compiler, you will want to set
++# 'CROSS' to something more interesting ... Target
++# architecture is determined by asking the CC compiler what
++# arch it compiles things for, so unless your compiler is
++# broken, you should not need to specify TARGET_ARCH.
++#
++# Most people will set this stuff on the command line, i.e.
++# make CROSS=arm-linux-
++# will build uClibc for 'arm'.
++
++ifndef CROSS
++CROSS=
++endif
++CC = $(CROSS)gcc
++AR = $(CROSS)ar
++LD = $(CROSS)ld
++NM = $(CROSS)nm
++RANLIB = $(CROSS)ranlib
++STRIPTOOL = $(CROSS)strip
++
++INSTALL = install
++LN = ln
++RM = rm -f
++
++# Select the compiler needed to build binaries for your development system
++HOSTCC = gcc
++HOSTCFLAGS = -O2 -Wall
++
++
++#---------------------------------------------------------
++# Nothing beyond this point should ever be touched by mere
++# mortals. Unless you hang out with the gods, you should
++# probably leave all this stuff alone.
++MAJOR_VERSION := 0
++MINOR_VERSION := 9
++SUBLEVEL := 28
++EXTRAVERSION := 3
++VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).$(EXTRAVERSION)
++# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
++LC_ALL := C
++export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
++
++SHARED_FULLNAME:=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
++SHARED_MAJORNAME:=libc.so.$(MAJOR_VERSION)
++UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
++LIBNAME:=libc.a
++LIBC:=$(TOPDIR)libc/$(LIBNAME)
++
++# Make sure DESTDIR and PREFIX can be used to install
++# PREFIX is a uClibcism while DESTDIR is a common GNUism
++ifndef PREFIX
++PREFIX = $(DESTDIR)
++endif
++
++# Pull in the user's uClibc configuration
++ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
++-include $(TOPDIR).config
++endif
++
++ifndef CROSS
++CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
++endif
++
++# A nifty macro to make testing gcc features easier
++check_gcc=$(shell \
++ if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
++ then echo "$(1)"; else echo "$(2)"; fi)
++check_as=$(shell \
++ if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
++ then echo "-Wa,$(1)"; fi)
++
++# Setup some shortcuts so that silent mode is silent like it should be
++ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
++export MAKE_IS_SILENT=n
++SECHO=@echo
++SHELL_SET_X=set -x
++else
++export MAKE_IS_SILENT=y
++SECHO=-@false
++SHELL_SET_X=set +x
++endif
++
++# Make certain these contain a final "/", but no "//"s.
++TARGET_ARCH:=$(shell grep -s ^TARGET_ARCH $(TOPDIR)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g')
++RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
++DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
++export RUNTIME_PREFIX DEVEL_PREFIX
++
++ARFLAGS:=cr
++
++OPTIMIZATION:=
++PICFLAG:=-fPIC
++PIEFLAG_NAME:=-fPIE
++
++# Some nice CPU specific optimizations
++ifeq ($(strip $(TARGET_ARCH)),i386)
++ OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
++ OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
++ CPU_CFLAGS-$(CONFIG_386)+=-march=i386
++ CPU_CFLAGS-$(CONFIG_486)+=-march=i486
++ CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
++ CPU_CFLAGS-$(CONFIG_586)+=-march=i586
++ CPU_CFLAGS-$(CONFIG_586MMX)+=$(call check_gcc,-march=pentium-mmx,-march=i586)
++ CPU_CFLAGS-$(CONFIG_686)+=-march=i686
++ CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
++ CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686)
++ CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686)
++ CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586)
++ CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-malign-functions=4 -march=i686)
++ CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686 -malign-functions=0 -malign-jumps=0 -malign-loops=0
++ CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586)
++ CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586)
++ CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) -malign-functions=0 -malign-jumps=0 -malign-loops=0
++ CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),arm)
++ OPTIMIZATION+=-fstrict-aliasing
++ CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL
++ CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB
++ CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
++ CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
++ CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+=
++ CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3
++ CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3
++ CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4
++ CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4
++ CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4
++ CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5
++ CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
++ CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
++ CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
++ CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
++ CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv4 -Wa,-mcpu=xscale
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),mips)
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
++ CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),sh)
++ OPTIMIZATION+=-fstrict-aliasing
++ OPTIMIZATION+= $(call check_gcc,-mprefergot,)
++ CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL
++ CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB
++ CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml
++ CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb
++ CPU_CFLAGS-$(CONFIG_SH2)+=-m2
++ CPU_CFLAGS-$(CONFIG_SH3)+=-m3
++ifeq ($(strip $(UCLIBC_HAS_FLOATS)),y)
++ CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
++ CPU_CFLAGS-$(CONFIG_SH4)+=-m4
++else
++ CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
++ CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
++endif
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),sh64)
++ OPTIMIZATION+=-fstrict-aliasing
++ CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN):=-EL
++ CPU_LDFLAGS-$(ARCH_BIG_ENDIAN):=-EB
++ CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml
++ CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb
++ CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),h8300)
++ CPU_LDFLAGS-$(CONFIG_H8300H)+= -ms8300h
++ CPU_LDFLAGS-$(CONFIG_H8S) += -ms8300s
++ CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32 -fsigned-char
++ CPU_CFLAGS-$(CONFIG_H8S) += -ms -mint32 -fsigned-char
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),cris)
++ CPU_LDFLAGS-$(CONFIG_CRIS)+=-mcrislinux
++ CPU_CFLAGS-$(CONFIG_CRIS)+=-mlinux
++ PICFLAG:=-fpic
++ PIEFLAG_NAME:=-fpie
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),powerpc)
++# PowerPC can hold 8192 entries in its GOT with -fpic which is more than
++# enough. Therefore use -fpic which will reduce code size and generates
++# faster code.
++ PICFLAG:=-fpic
++ PIEFLAG_NAME:=-fpie
++ PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
++ CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),frv)
++ CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd
++ CPU_CFLAGS-$(CONFIG_FRV)+=-mfdpic
++ # Using -pie causes the program to have an interpreter, which is
++ # forbidden, so we must make do with -shared. Unfortunately,
++ # -shared by itself would get us global function descriptors
++ # and calls through PLTs, dynamic resolution of symbols, etc,
++ # which would break as well, but -Bsymbolic comes to the rescue.
++ export LDPIEFLAG:=-shared -Bsymbolic
++ UCLIBC_LDSO=ld.so.1
++endif
++
++ifeq ($(strip $(TARGET_ARCH)),avr32)
++ CPU_CFLAGS-$(CONFIG_AP7000) += -mcpu=ap7000
++endif
++
++# Keep the check_gcc from being needlessly executed
++ifndef PIEFLAG
++ifneq ($(UCLIBC_BUILD_PIE),y)
++export PIEFLAG:=
++else
++export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
++endif
++endif
++# We need to keep track of both the CC PIE flag (above) as
++# well as the LD PIE flag (below) because we can't rely on
++# gcc passing -pie if we used -fPIE
++ifndef LDPIEFLAG
++ifneq ($(UCLIBC_BUILD_PIE),y)
++export LDPIEFLAG:=
++else
++export LDPIEFLAG:=$(shell $(LD) --help | grep -q pie && echo "-Wl,-pie")
++endif
++endif
++
++# Use '-Os' optimization if available, else use -O2, allow Config to override
++OPTIMIZATION+=$(call check_gcc,-Os,-O2)
++# Use the gcc 3.4 -funit-at-a-time optimization when available
++OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
++
++# Add a bunch of extra pedantic annoyingly strict checks
++XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
++XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
++CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
++
++LDADD_LIBFLOAT=
++ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
++# Add -msoft-float to the CPU_FLAGS since ldso and libdl ignore CFLAGS.
++# If -msoft-float isn't supported, we want an error anyway.
++# Hmm... might need to revisit this for arm since it has 2 different
++# soft float encodings.
++ CPU_CFLAGS += -msoft-float
++ifeq ($(strip $(TARGET_ARCH)),arm)
++# No longer needed with current toolchains, but leave it here for now.
++# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
++# LDADD_LIBFLOAT=-lfloat
++endif
++endif
++
++SSP_DISABLE_FLAGS:=$(call check_gcc,-fno-stack-protector,)
++ifeq ($(UCLIBC_BUILD_SSP),y)
++SSP_CFLAGS:=$(call check_gcc,-fno-stack-protector-all,)
++SSP_CFLAGS+=$(call check_gcc,-fstack-protector,)
++SSP_ALL_CFLAGS:=$(call check_gcc,-fstack-protector-all,)
++else
++SSP_CFLAGS:=$(SSP_DISABLE_FLAGS)
++endif
++
++# Some nice CFLAGS to work with
++CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
++ -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)include -I.
++LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc -z defs
++
++ifeq ($(DODEBUG),y)
++ #CFLAGS += -g3
++ CFLAGS += -O0 -g3
++ LDFLAGS := $(LDFLAGS_NOSTRIP)
++ STRIPTOOL:= true -Since_we_are_debugging
++else
++ CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
++ LDFLAGS := $(LDFLAGS_NOSTRIP) -s
++endif
++
++ifeq ($(UCLIBC_BUILD_RELRO),y)
++LDFLAGS+=-z relro
++endif
++
++ifeq ($(UCLIBC_BUILD_NOW),y)
++LDFLAGS+=-z now
++endif
++
++# Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
++#CFLAGS+=-iwithprefix include
++CFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
++
++ifneq ($(DOASSERTS),y)
++ CFLAGS += -DNDEBUG
++endif
++
++CFLAGS_NOPIC:=$(CFLAGS)
++ifeq ($(DOPIC),y)
++ CFLAGS += $(PICFLAG)
++endif
++
++ifeq ($(DL_FINI_CRT_COMPAT),y)
++CFLAGS += -D_DL_FINI_CRT_COMPAT
++endif
++
++# Keep the check_as from being needlessly executed
++ASFLAGS = $(CFLAGS)
++ifndef ASFLAGS_NOEXEC
++ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
++export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
++else
++export ASFLAGS_NOEXEC :=
++endif
++endif
++ASFLAGS += $(ASFLAGS_NOEXEC)
++
++LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
++LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
++LIBGCC_DIR:=$(dir $(LIBGCC))
++
++########################################
++#
++# uClinux shared lib support
++#
++
++ifeq ($(CONFIG_BINFMT_SHARED_FLAT),y)
++ # For the shared version of this, we specify no stack and its library ID
++ FLTFLAGS += -s 0
++ LIBID=1
++ export LIBID FLTFLAGS
++ SHARED_TARGET = lib/libc
++endif
++
++TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
+diff -Nrup a/utils/ldd.c b/utils/ldd.c
+--- a/utils/ldd.c 2004-10-06 03:34:17.000000000 -0400
++++ b/utils/ldd.c 2008-02-28 19:02:10.000000000 -0500
+@@ -56,6 +56,11 @@
+ #define ELFCLASSM ELFCLASS32
+ #endif
+
++#if defined(__avr32__)
++#define MATCH_MACHINE(x) (x == EM_AVR32)
++#define ELFCLASSM ELFCLASS32
++#endif
++
+ #if defined(__s390__)
+ #define MATCH_MACHINE(x) (x == EM_S390)
+ #define ELFCLASSM ELFCLASS32
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-string-ops.patch.powerpc b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-string-ops.patch.powerpc
new file mode 100644
index 0000000000..0311e3ba03
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.3-string-ops.patch.powerpc
@@ -0,0 +1,56 @@
+diff -urpN uClibc-0.9.28.3/libc/string/powerpc/string.c uClibc-0.9.28.3-patched/libc/string/powerpc/string.c
+--- uClibc-0.9.28.3/libc/string/powerpc/string.c 2005-06-21 16:03:15.000000000 +0200
++++ uClibc-0.9.28.3-patched/libc/string/powerpc/string.c 2008-03-27 00:22:16.000000000 +0100
+@@ -32,7 +32,7 @@
+ #include <locale.h> /* for __LOCALE_C_ONLY */
+
+ #ifdef L_memcpy
+-void attribute_hidden *__memcpy(void *to, const void *from, size_t n)
++void *memcpy(void *to, const void *from, size_t n)
+ /* PPC can do pre increment and load/store, but not post increment and load/store.
+ Therefore use *++ptr instead of *ptr++. */
+ {
+@@ -87,11 +87,10 @@ void attribute_hidden *__memcpy(void *to
+ goto copy_chunks;
+ goto lessthan8;
+ }
+-strong_alias(__memcpy, memcpy);
+ #endif
+
+ #ifdef L_memmove
+-void attribute_hidden *__memmove(void *to, const void *from, size_t n)
++void *memmove(void *to, const void *from, size_t n)
+ {
+ unsigned long rem, chunks, tmp1, tmp2;
+ unsigned char *tmp_to;
+@@ -142,7 +141,6 @@ void attribute_hidden *__memmove(void *t
+ goto copy_chunks;
+ goto lessthan8;
+ }
+-strong_alias(__memmove, memmove);
+ #endif
+
+ #ifdef L_memset
+@@ -156,7 +154,7 @@ static inline int expand_byte_word(int c
+ : "=r" (c) : "0" (c));
+ return c;
+ }
+-void attribute_hidden *__memset(void *to, int c, size_t n)
++void *memset(void *to, int c, size_t n)
+ {
+ unsigned long rem, chunks;
+ unsigned char *tmp_to;
+@@ -202,12 +200,10 @@ void attribute_hidden *__memset(void *to
+ goto copy_chunks;
+ goto lessthan8;
+ }
+-strong_alias(__memset, memset);
+ #endif
+
+ #ifdef L_bzero
+-weak_alias(__bzero,bzero);
+-void __bzero(void *s, size_t n)
++void bzero(void *s, size_t n)
+ {
+ (void)memset(s, 0, n);
+ }
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.config b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.config
new file mode 100644
index 0000000000..07dc7e282d
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.28.config
@@ -0,0 +1,179 @@
+#
+# Automatically generated make config: don't edit
+#
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_x86_64 is not set
+
+#
+# Target Architecture Features and Options
+#
+HAVE_ELF=y
+TARGET_ARCH="none"
+# ARCH_LITTLE_ENDIAN is not set
+# ARCH_BIG_ENDIAN is not set
+# ARCH_SUPPORTS_LITTLE_ENDIAN is not set
+# ARCH_SUPPORTS_BIG_ENDIAN is not set
+# ARCH_HAS_NO_MMU is not set
+ARCH_HAS_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+HAS_FPU=y
+DO_C99_MATH=y
+WARNINGS="-Wall"
+KERNEL_SOURCE="/usr/src/linux"
+HAVE_DOT_CONFIG=y
+# CONFIG_ARM_EABI is not set
+# CONFIG_GENERIC_ARM is not set
+# CONFIG_ARM610 is not set
+# CONFIG_ARM710 is not set
+# CONFIG_ARM7TDMI is not set
+# CONFIG_ARM720T is not set
+# CONFIG_ARM920T is not set
+# CONFIG_ARM922T is not set
+# CONFIG_ARM926T is not set
+# CONFIG_ARM1136JF_S is not set
+# CONFIG_ARM_SA110 is not set
+# CONFIG_ARM_SA1100 is not set
+# CONFIG_ARM_XSCALE is not set
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+
+#
+# General Library Settings
+#
+# HAVE_NO_PIC is not set
+DOPIC=y
+# HAVE_NO_SHARED is not set
+HAVE_SHARED=y
+# ARCH_HAS_NO_LDSO is not set
+BUILD_UCLIBC_LDSO=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# LDSO_RUNPATH is not set
+# DL_FINI_CRT_COMPAT is not set
+UCLIBC_CTOR_DTOR=y
+# HAS_NO_THREADS is not set
+UCLIBC_HAS_THREADS=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_LFS=y
+# UCLIBC_STATIC_LDCONFIG is not set
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_DYNAMIC_ATEXIT=y
+HAS_SHADOW=y
+# UNIX98PTY_ONLY is not set
+ASSUME_DEVPTS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+
+#
+# Networking Support
+#
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_WCHAR=y
+# UCLIBC_HAS_LOCALE is not set
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+# USE_OLD_VFPRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+# UCLIBC_HAS_WORDEXP is not set
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GLOB=y
+
+#
+# Library Installation Options
+#
+SHARED_LIB_LOADER_PREFIX="/lib"
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr/"
+
+#
+# uClibc security related options
+#
+# UCLIBC_SECURITY is not set
+
+#
+# uClibc development/debugging options
+#
+CROSS_COMPILER_PREFIX=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+WARNINGS="-Wall"
+# UCLIBC_MJN3_ONLY is not set
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-001-fix-mmap.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-001-fix-mmap.patch
new file mode 100644
index 0000000000..4775e8c332
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-001-fix-mmap.patch
@@ -0,0 +1,91 @@
+--- uClibc-0.9.29.oorig/test/mmap/mmap2.c (revision 0)
++++ uClibc-0.9.29/test/mmap/mmap2.c (revision 18616)
+@@ -0,0 +1,41 @@
++/* When trying to map /dev/mem with offset 0xFFFFF000 on the ARM platform, mmap
++ * returns -EOVERFLOW.
++ *
++ * Since off_t is defined as a long int and the sign bit is set in the address,
++ * the shift operation shifts in ones instead of zeroes
++ * from the left. This results the offset sent to the kernel function becomes
++ * 0xFFFFFFFF instead of 0x000FFFFF with MMAP2_PAGE_SHIFT set to 12.
++ */
++
++#include <unistd.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <sys/mman.h>
++
++#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
++ __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
++
++#define MAP_SIZE 4096UL
++#define MAP_MASK (MAP_SIZE - 1)
++
++int main(int argc, char **argv) {
++ void* map_base = 0;
++ int fd;
++ off_t target = 0xfffff000;
++ if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
++ printf("/dev/mem opened.\n");
++ fflush(stdout);
++
++ /* Map one page */
++ map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
++ fd, target & ~MAP_MASK);
++ if(map_base == (void *) -1) FATAL;
++ printf("Memory mapped at address %p.\n", map_base);
++ fflush(stdout);
++ if(munmap(map_base, MAP_SIZE) == -1) FATAL;
++ close(fd);
++ return 0;
++}
+--- uClibc-0.9.29.oorig/libc/sysdeps/linux/arm/mmap.c (revision 18615)
++++ uClibc-0.9.29/libc/sysdeps/linux/arm/mmap.c (revision 18616)
+@@ -27,7 +27,6 @@ __ptr_t mmap(__ptr_t addr, size_t len, i
+
+ #elif defined (__NR_mmap2)
+ #define __NR__mmap __NR_mmap2
+-
+ #ifndef MMAP2_PAGE_SHIFT
+ # define MMAP2_PAGE_SHIFT 12
+ #endif
+@@ -39,9 +38,17 @@ __ptr_t mmap(__ptr_t addr, size_t len, i
+ {
+ /* check if offset is page aligned */
+ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
++ {
++ __set_errno(EINVAL);
+ return MAP_FAILED;
++ }
++#ifdef __USE_FILE_OFFSET64
++ return (__ptr_t) _mmap (addr, len, prot, flags,
++ fd,((__u_quad_t) offset >> MMAP2_PAGE_SHIFT));
++#else
+ return (__ptr_t) _mmap (addr, len, prot, flags,
+- fd,(off_t) (offset >> MMAP2_PAGE_SHIFT));
++ fd,((__u_long) offset >> MMAP2_PAGE_SHIFT));
++#endif
+ }
+ #elif defined (__NR_mmap)
+ # define __NR__mmap __NR_mmap
+--- uClibc-0.9.29.oorig/libc/sysdeps/linux/common/mmap64.c (revision 18615)
++++ uClibc-0.9.29/libc/sysdeps/linux/common/mmap64.c (revision 18616)
+@@ -58,8 +58,13 @@ __ptr_t mmap64(__ptr_t addr, size_t len,
+ __set_errno(EINVAL);
+ return MAP_FAILED;
+ }
+-
+- return __syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
++#ifdef __USE_FILE_OFFSET64
++ return __syscall_mmap2(addr, len, prot, flags,
++ fd,((__u_quad_t)offset >> MMAP2_PAGE_SHIFT));
++#else
++ return __syscall_mmap2(addr, len, prot, flags,
++ fd,((__u_long)offset >> MMAP2_PAGE_SHIFT));
++#endif
+ }
+
+ # endif
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-arch.patch.avr32 b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-arch.patch.avr32
new file mode 100644
index 0000000000..d275ac2302
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-arch.patch.avr32
@@ -0,0 +1,3546 @@
+diff --git a/Rules.mak b/Rules.mak
+index d054bbb..55381cf 100644
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -313,6 +313,12 @@ ifeq ($(TARGET_ARCH),frv)
+ UCLIBC_LDSO=ld.so.1
+ endif
+
++ifeq ($(strip $(TARGET_ARCH)),avr32)
++ CPU_CFLAGS-$(CONFIG_AVR32_AP7) += -march=ap
++ CPU_CFLAGS-$(CONFIG_LINKRELAX) += -mrelax
++ CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
++endif
++
+ # Keep the check_gcc from being needlessly executed
+ ifndef PIEFLAG
+ ifneq ($(UCLIBC_BUILD_PIE),y)
+diff --git a/extra/Configs/Config.avr32 b/extra/Configs/Config.avr32
+new file mode 100644
+index 0000000..8d70e6e
+--- /dev/null
++++ b/extra/Configs/Config.avr32
+@@ -0,0 +1,31 @@
++#
++# For a description of the syntax of this configuration file,
++# see extra/config/Kconfig-language.txt
++#
++
++config TARGET_ARCH
++ string
++ default "avr32"
++
++config FORCE_OPTIONS_FOR_ARCH
++ bool
++ default y
++ select ARCH_BIG_ENDIAN
++ select FORCE_SHAREABLE_TEXT_SEGMENTS
++
++config ARCH_CFLAGS
++ string
++
++choice
++ prompt "Target CPU Type"
++ default CONFIG_AVR32_AP7
++
++config CONFIG_AVR32_AP7
++ bool "AVR32 AP7"
++ select ARCH_HAS_MMU
++
++endchoice
++
++config LINKRELAX
++ bool "Enable linker optimizations"
++ default y
+diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
+index 8eab394..10c9f7b 100644
+--- a/extra/Configs/Config.in
++++ b/extra/Configs/Config.in
+@@ -16,6 +16,9 @@ config TARGET_alpha
+ config TARGET_arm
+ bool "arm"
+
++config TARGET_avr32
++ bool "avr32"
++
+ config TARGET_bfin
+ bool "bfin"
+
+@@ -92,6 +95,10 @@ if TARGET_arm
+ source "extra/Configs/Config.arm"
+ endif
+
++if TARGET_avr32
++source "extra/Configs/Config.avr32"
++endif
++
+ if TARGET_bfin
+ source "extra/Configs/Config.bfin"
+ endif
+diff --git a/extra/Configs/defconfigs/avr32 b/extra/Configs/defconfigs/avr32
+new file mode 100644
+index 0000000..0b890a2
+--- /dev/null
++++ b/extra/Configs/defconfigs/avr32
+@@ -0,0 +1 @@
++TARGET_avr32=y
+diff --git a/include/elf.h b/include/elf.h
+index 19805d7..ab90160 100644
+--- a/include/elf.h
++++ b/include/elf.h
+@@ -354,6 +354,8 @@ typedef struct
+ /* NIOS magic number - no EABI available. */
+ #define EM_NIOS32 0xFEBB
+
++#define EM_AVR32 0x18ad
++
+ /* V850 backend magic number. Written in the absense of an ABI. */
+ #define EM_CYGNUS_V850 0x9080
+
+@@ -2828,6 +2830,55 @@ typedef Elf32_Addr Elf32_Conflict;
+ /* Keep this the last entry. */
+ #define R_V850_NUM 25
+
++/* Atmel AVR32 relocations. */
++#define R_AVR32_NONE 0
++#define R_AVR32_32 1
++#define R_AVR32_16 2
++#define R_AVR32_8 3
++#define R_AVR32_32_PCREL 4
++#define R_AVR32_16_PCREL 5
++#define R_AVR32_8_PCREL 6
++#define R_AVR32_DIFF32 7
++#define R_AVR32_DIFF16 8
++#define R_AVR32_DIFF8 9
++#define R_AVR32_GOT32 10
++#define R_AVR32_GOT16 11
++#define R_AVR32_GOT8 12
++#define R_AVR32_21S 13
++#define R_AVR32_16U 14
++#define R_AVR32_16S 15
++#define R_AVR32_8S 16
++#define R_AVR32_8S_EXT 17
++#define R_AVR32_22H_PCREL 18
++#define R_AVR32_18W_PCREL 19
++#define R_AVR32_16B_PCREL 20
++#define R_AVR32_16N_PCREL 21
++#define R_AVR32_14UW_PCREL 22
++#define R_AVR32_11H_PCREL 23
++#define R_AVR32_10UW_PCREL 24
++#define R_AVR32_9H_PCREL 25
++#define R_AVR32_9UW_PCREL 26
++#define R_AVR32_HI16 27
++#define R_AVR32_LO16 28
++#define R_AVR32_GOTPC 29
++#define R_AVR32_GOTCALL 30
++#define R_AVR32_LDA_GOT 31
++#define R_AVR32_GOT21S 32
++#define R_AVR32_GOT18SW 33
++#define R_AVR32_GOT16S 34
++#define R_AVR32_GOT7UW 35
++#define R_AVR32_32_CPENT 36
++#define R_AVR32_CPCALL 37
++#define R_AVR32_16_CP 38
++#define R_AVR32_9W_CP 39
++#define R_AVR32_RELATIVE 40
++#define R_AVR32_GLOB_DAT 41
++#define R_AVR32_JMP_SLOT 42
++#define R_AVR32_ALIGN 43
++#define R_AVR32_NUM 44
++
++/* AVR32 dynamic tags */
++#define DT_AVR32_GOTSZ 0x70000001 /* Total size of GOT in bytes */
+
+ /* Renesas H8/300 Relocations */
+ #define R_H8_NONE 0
+diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
+index 32c5bf8..eb43bd9 100644
+--- a/ldso/include/dl-string.h
++++ b/ldso/include/dl-string.h
+@@ -285,7 +285,8 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
+ /* On some arches constant strings are referenced through the GOT.
+ * This requires that load_addr must already be defined... */
+ #if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
+- defined(__mips__) || defined(__sh__) || defined(__powerpc__)
++ defined(__mips__) || defined(__sh__) || defined(__powerpc__) || \
++ defined(__avr32__)
+ # define CONSTANT_STRING_GOT_FIXUP(X) \
+ if ((X) < (const char *) load_addr) (X) += load_addr
+ # define NO_EARLY_SEND_STDERR
+diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
+index b42416a..4404219 100644
+--- a/ldso/include/dl-syscall.h
++++ b/ldso/include/dl-syscall.h
+@@ -55,69 +55,69 @@
+ dynamic linking at all, so we cannot return any error codes.
+ We just punt if there is an error. */
+ #define __NR__dl_exit __NR_exit
+-static inline _syscall1(void, _dl_exit, int, status);
++static __always_inline _syscall1(void, _dl_exit, int, status);
+
+ #define __NR__dl_close __NR_close
+-static inline _syscall1(int, _dl_close, int, fd);
++static __always_inline _syscall1(int, _dl_close, int, fd);
+
+ #define __NR__dl_open __NR_open
+-static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
++static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
+ __kernel_mode_t, mode);
+
+ #define __NR__dl_write __NR_write
+-static inline _syscall3(unsigned long, _dl_write, int, fd,
++static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
+ const void *, buf, unsigned long, count);
+
+ #define __NR__dl_read __NR_read
+-static inline _syscall3(unsigned long, _dl_read, int, fd,
++static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
+ const void *, buf, unsigned long, count);
+
+ #define __NR__dl_mprotect __NR_mprotect
+-static inline _syscall3(int, _dl_mprotect, const void *, addr,
++static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
+ unsigned long, len, int, prot);
+
+ #define __NR__dl_stat __NR_stat
+-static inline _syscall2(int, _dl_stat, const char *, file_name,
++static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
+ struct stat *, buf);
+
+ #define __NR__dl_fstat __NR_fstat
+-static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
++static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
+
+ #define __NR__dl_munmap __NR_munmap
+-static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
++static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
+
+ #ifdef __NR_getxuid
+ # define __NR_getuid __NR_getxuid
+ #endif
+ #define __NR__dl_getuid __NR_getuid
+-static inline _syscall0(uid_t, _dl_getuid);
++static __always_inline _syscall0(uid_t, _dl_getuid);
+
+ #ifndef __NR_geteuid
+ # define __NR_geteuid __NR_getuid
+ #endif
+ #define __NR__dl_geteuid __NR_geteuid
+-static inline _syscall0(uid_t, _dl_geteuid);
++static __always_inline _syscall0(uid_t, _dl_geteuid);
+
+ #ifdef __NR_getxgid
+ # define __NR_getgid __NR_getxgid
+ #endif
+ #define __NR__dl_getgid __NR_getgid
+-static inline _syscall0(gid_t, _dl_getgid);
++static __always_inline _syscall0(gid_t, _dl_getgid);
+
+ #ifndef __NR_getegid
+ # define __NR_getegid __NR_getgid
+ #endif
+ #define __NR__dl_getegid __NR_getegid
+-static inline _syscall0(gid_t, _dl_getegid);
++static __always_inline _syscall0(gid_t, _dl_getegid);
+
+ #ifdef __NR_getxpid
+ # define __NR_getpid __NR_getxpid
+ #endif
+ #define __NR__dl_getpid __NR_getpid
+-static inline _syscall0(gid_t, _dl_getpid);
++static __always_inline _syscall0(gid_t, _dl_getpid);
+
+ #define __NR__dl_readlink __NR_readlink
+-static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
++static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
+ size_t, bufsiz);
+
+ #ifdef __UCLIBC_HAS_SSP__
+@@ -146,14 +146,14 @@ static inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv,
+ #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
+
+ # define __NR__dl_mmap __NR_mmap
+-static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
++static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
+ int, prot, int, flags, int, fd, off_t, offset);
+
+ /* then try mmap2() */
+ #elif defined(__NR_mmap2)
+
+ # define __NR___syscall_mmap2 __NR_mmap2
+-static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
++static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
+ int, prot, int, flags, int, fd, off_t, offset);
+
+ /* Some architectures always use 12 as page shift for mmap2() eventhough the
+@@ -164,7 +164,7 @@ static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
+ # define MMAP2_PAGE_SHIFT 12
+ #endif
+
+-static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
++static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+ int flags, int fd, unsigned long offset)
+ {
+ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
+@@ -177,8 +177,8 @@ static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+ #elif defined(__NR_mmap)
+
+ # define __NR__dl_mmap_real __NR_mmap
+-static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
+-static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
++static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
++static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+ int flags, int fd, unsigned long offset)
+ {
+ unsigned long buffer[6];
+diff --git a/ldso/ldso/avr32/dl-debug.h b/ldso/ldso/avr32/dl-debug.h
+new file mode 100644
+index 0000000..fe35539
+--- /dev/null
++++ b/ldso/ldso/avr32/dl-debug.h
+@@ -0,0 +1,45 @@
++/*
++ * AVR32 ELF shared libary loader support
++ *
++ * Copyright (C) 2005-2007 Atmel Corporation
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. The name of the above contributors may not be
++ * used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++static const char *_dl_reltypes_tab[] = {
++ "R_AVR32_NONE",
++ "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
++ "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
++ "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
++ "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
++ "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
++ "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
++ "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
++ "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
++ "R_AVR32_HI16", "R_AVR32_LO16",
++ "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
++ "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
++ "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
++ "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
++ "R_AVR32_ALIGN",
++};
+diff --git a/ldso/ldso/avr32/dl-startup.h b/ldso/ldso/avr32/dl-startup.h
+new file mode 100644
+index 0000000..3b9a641
+--- /dev/null
++++ b/ldso/ldso/avr32/dl-startup.h
+@@ -0,0 +1,112 @@
++/*
++ * Architecture specific code used by dl-startup.c
++ *
++ * Copyright (C) 2005-2007 Atmel Corporation
++ *
++ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
++ */
++
++/* This is the library loader's main entry point. Let _dl_boot2 do its
++ * initializations and jump to the application's entry point
++ * afterwards. */
++asm( " .text\n"
++ " .global _start\n"
++ " .type _start,@function\n"
++ "_start:\n"
++ /* All arguments are on the stack initially */
++ " mov r12, sp\n"
++ " rcall _dl_start\n"
++ /* Returns user entry point in r12. Save it. */
++ " mov r0, r12\n"
++ /* We're PIC, so get the Global Offset Table */
++ " lddpc r6, .L_GOT\n"
++ ".L_RGOT:\n"
++ " rsub r6, pc\n"
++ /* Adjust argc and argv according to _dl_skip_args */
++ " ld.w r1, r6[_dl_skip_args@got]\n"
++ " ld.w r1, r1[0]\n"
++ " ld.w r2, sp++\n"
++ " sub r2, r1\n"
++ " add sp, sp, r1 << 2\n"
++ " st.w --sp, r2\n"
++ /* Load the finalizer function */
++ " ld.w r12, r6[_dl_fini@got]\n"
++ /* Jump to the user's entry point */
++ " mov pc, r0\n\n"
++
++ " .align 2\n"
++ ".L_GOT:"
++ " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
++ " .size _start, . - _start\n"
++ " .previous\n");
++
++/* Get a pointer to the argv array. On many platforms this can be just
++ * the address if the first argument, on other platforms we need to
++ * do something a little more subtle here. */
++#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
++
++
++/* We can't call functions before the GOT has been initialized */
++#define NO_FUNCS_BEFORE_BOOTSTRAP
++
++/*
++ * Relocate the GOT during dynamic loader bootstrap. This will add
++ * the load address to all entries in the GOT, which is necessary
++ * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
++ * GOT.
++ */
++static __always_inline
++void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
++{
++ Elf32_Addr i, nr_got;
++ register Elf32_Addr *__r6 __asm__("r6");
++ Elf32_Addr *got = __r6;
++
++ nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
++ for (i = 2; i < nr_got; i++)
++ got[i] += tpnt->loadaddr;
++}
++
++#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
++
++/* Handle relocation of the symbols in the dynamic loader. */
++static __always_inline
++void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
++ unsigned long symbol_addr,
++ unsigned long load_addr, Elf32_Sym *symtab)
++{
++ switch(ELF32_R_TYPE(rpnt->r_info)) {
++ case R_AVR32_NONE:
++ break;
++ case R_AVR32_GLOB_DAT:
++ case R_AVR32_JMP_SLOT:
++ *reloc_addr = symbol_addr;
++ break;
++ case R_AVR32_RELATIVE:
++ SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
++ SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
++ SEND_STDERR_DEBUG(" + ");
++ SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
++ *reloc_addr = load_addr + rpnt->r_addend;
++ break;
++ default:
++ SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
++ SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
++ SEND_STDERR("REL, SYMBOL, LOAD: ");
++ SEND_ADDRESS_STDERR(reloc_addr, 0);
++ SEND_STDERR(", ");
++ SEND_ADDRESS_STDERR(symbol_addr, 0);
++ SEND_STDERR(", ");
++ SEND_ADDRESS_STDERR(load_addr, 1);
++ _dl_exit(1);
++ }
++}
++
++/* Transfer control to the user's application, once the dynamic loader
++ * is done. This routine has to exit the current function, then call
++ * the _dl_elf_main function.
++ *
++ * Since our _dl_boot will simply call whatever is returned by
++ * _dl_boot2, we can just return the address we're supposed to
++ * call. */
++#define START() return _dl_elf_main;
+diff --git a/ldso/ldso/avr32/dl-syscalls.h b/ldso/ldso/avr32/dl-syscalls.h
+new file mode 100644
+index 0000000..996bb87
+--- /dev/null
++++ b/ldso/ldso/avr32/dl-syscalls.h
+@@ -0,0 +1,6 @@
++/* We can't use the real errno in ldso, since it has not yet
++ * been dynamicly linked in yet. */
++#include "sys/syscall.h"
++extern int _dl_errno;
++#undef __set_errno
++#define __set_errno(X) {(_dl_errno) = (X);}
+diff --git a/ldso/ldso/avr32/dl-sysdep.h b/ldso/ldso/avr32/dl-sysdep.h
+new file mode 100644
+index 0000000..1a30172
+--- /dev/null
++++ b/ldso/ldso/avr32/dl-sysdep.h
+@@ -0,0 +1,105 @@
++/*
++ * Various assembly language/system dependent hacks that are required
++ * so that we can minimize the amount of platform specific code.
++ *
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
++ */
++
++/* Define this if the system uses RELOCA. */
++#define ELF_USES_RELOCA
++
++#include <elf.h>
++
++#define ARCH_NUM 1
++#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM)
++
++#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
++ do { \
++ if (dpnt->d_tag == DT_AVR32_GOTSZ) \
++ dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
++ } while (0)
++
++/* Initialization sequence for the application/library GOT. */
++#define INIT_GOT(GOT_BASE,MODULE) \
++ do { \
++ unsigned long i, nr_got; \
++ \
++ GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
++ GOT_BASE[1] = (unsigned long) MODULE; \
++ \
++ /* Add load address displacement to all GOT entries */ \
++ nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
++ for (i = 2; i < nr_got; i++) \
++ GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
++ } while (0)
++
++#define do_rem(result, n, base) ((result) = (n) % (base))
++
++/* Here we define the magic numbers that this dynamic loader should accept */
++#define MAGIC1 EM_AVR32
++#undef MAGIC2
++
++/* Used for error messages */
++#define ELF_TARGET "AVR32"
++
++unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
++
++/* 4096 bytes alignment */
++#define PAGE_ALIGN 0xfffff000
++#define ADDR_ALIGN 0xfff
++#define OFFS_ALIGN 0x7ffff000
++
++#define elf_machine_type_class(type) \
++ ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
++
++/* AVR32 doesn't need any COPY relocs */
++#define DL_NO_COPY_RELOCS
++
++/* Return the link-time address of _DYNAMIC. Conveniently, this is the
++ first element of the GOT. This must be inlined in a function which
++ uses global data. */
++static inline Elf32_Addr
++elf_machine_dynamic (void)
++{
++ register Elf32_Addr *got asm ("r6");
++ return *got;
++}
++
++/* Return the run-time load address of the shared object. */
++static inline Elf32_Addr
++elf_machine_load_address (void)
++{
++ extern void __dl_start asm("_dl_start");
++ Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
++ Elf32_Addr pcrel_addr;
++
++ asm (" lddpc %0, 2f\n"
++ "1: add %0, pc\n"
++ " rjmp 3f\n"
++ " .align 2\n"
++ "2: .long _dl_start - 1b\n"
++ "3:\n"
++ : "=r"(pcrel_addr) : : "cc");
++
++ return pcrel_addr - got_addr;
++}
++
++/*
++ * Perform any RELATIVE relocations specified by DT_RELCOUNT.
++ * Currently, we don't use that tag, but we might in the future as
++ * this would reduce the startup time somewhat (although probably not by much).
++ */
++static inline void
++elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
++ Elf32_Word relative_count)
++{
++ Elf32_Rela *rpnt = (void *)rel_addr;
++
++ do {
++ Elf32_Addr *reloc_addr;
++ reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
++ *reloc_addr = load_off + rpnt->r_addend;
++ } while (--relative_count);
++}
+diff --git a/ldso/ldso/avr32/elfinterp.c b/ldso/ldso/avr32/elfinterp.c
+new file mode 100644
+index 0000000..196292b
+--- /dev/null
++++ b/ldso/ldso/avr32/elfinterp.c
+@@ -0,0 +1,191 @@
++/*
++ * AVR32 ELF shared library loader suppport
++ *
++ * Copyright (C) 2004-2006 Atmel Corporation
++ *
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. The name of the above contributors may not be
++ * used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
++{
++ struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
++ Elf32_Sym *sym;
++ unsigned long local_gotno;
++ unsigned long gotsym;
++ unsigned long new_addr;
++ char *strtab, *symname;
++ unsigned long *entry;
++ unsigned long sym_index = got_offset / 4;
++
++#if 0
++ local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
++ gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
++
++ sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
++ + sym_index;
++ strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
++ symname = strtab + sym->st_name;
++
++#if 0
++ new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
++ tpnt->symbol_scope, tpnt,
++ resolver);
++#endif
++
++ entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
++ *entry = new_addr;
++#endif
++
++ return new_addr;
++}
++
++static int
++_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ unsigned long rel_addr, unsigned long rel_size,
++ int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
++{
++ Elf32_Sym *symtab;
++ Elf32_Rela *rpnt;
++ char *strtab;
++ int i;
++
++ rpnt = (Elf32_Rela *)rel_addr;
++ rel_size /= sizeof(Elf32_Rela);
++ symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
++ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
++
++ for (i = 0; i < rel_size; i++, rpnt++) {
++ int symtab_index, res;
++
++ symtab_index = ELF32_R_SYM(rpnt->r_info);
++
++ debug_sym(symtab, strtab, symtab_index);
++ debug_reloc(symtab, strtab, rpnt);
++
++ res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
++
++ if (res == 0)
++ continue;
++
++ _dl_dprintf(2, "\n%s: ", _dl_progname);
++
++ if (symtab_index)
++ _dl_dprintf(2, "symbol '%s': ",
++ strtab + symtab[symtab_index].st_name);
++
++ if (res < 0) {
++ int reloc_type = ELF32_R_TYPE(rpnt->r_info);
++#if defined(__SUPPORT_LD_DEBUG__)
++ _dl_dprintf(2, "can't handle reloc type %s\n",
++ _dl_reltypes(reloc_type));
++#else
++ _dl_dprintf(2, "can't handle reloc type %x\n",
++ reloc_type);
++#endif
++ _dl_exit(-res);
++ } else {
++ _dl_dprintf(2, "can't resolve symbol\n");
++ return res;
++ }
++ }
++
++ return 0;
++}
++
++static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
++ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
++{
++ int reloc_type;
++ int symtab_index;
++ char *symname;
++ unsigned long *reloc_addr;
++ unsigned long symbol_addr;
++#if defined(__SUPPORT_LD_DEBUG__)
++ unsigned long old_val;
++#endif
++
++ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
++ reloc_type = ELF32_R_TYPE(rpnt->r_info);
++ symtab_index = ELF32_R_SYM(rpnt->r_info);
++ symbol_addr = 0;
++ symname = strtab + symtab[symtab_index].st_name;
++
++ if (symtab_index) {
++ symbol_addr = (unsigned long)
++ _dl_find_hash(strtab + symtab[symtab_index].st_name,
++ tpnt->symbol_scope, tpnt,
++ elf_machine_type_class(reloc_type));
++
++ /* Allow undefined references to weak symbols */
++ if (!symbol_addr &&
++ ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
++ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
++ _dl_progname, symname);
++ return 0;
++ }
++ }
++
++#if defined(__SUPPORT_LD_DEBUG__)
++ old_val = *reloc_addr;
++#endif
++ switch (reloc_type) {
++ case R_AVR32_NONE:
++ break;
++ case R_AVR32_GLOB_DAT:
++ case R_AVR32_JMP_SLOT:
++ *reloc_addr = symbol_addr + rpnt->r_addend;
++ break;
++ case R_AVR32_RELATIVE:
++ *reloc_addr = (unsigned long)tpnt->loadaddr
++ + rpnt->r_addend;
++ break;
++ default:
++ return -1;
++ }
++
++#if defined(__SUPPORT_LD_DEBUG__)
++ if (_dl_debug_reloc && _dl_debug_detail)
++ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
++ old_val, *reloc_addr);
++#endif
++
++ return 0;
++}
++
++void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
++ unsigned long rel_addr,
++ unsigned long rel_size)
++{
++ /* TODO: Might want to support this in order to get faster
++ * startup times... */
++}
++
++int _dl_parse_relocation_information(struct dyn_elf *rpnt,
++ unsigned long rel_addr,
++ unsigned long rel_size)
++{
++ return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
++ _dl_do_reloc);
++}
+diff --git a/ldso/ldso/avr32/resolve.S b/ldso/ldso/avr32/resolve.S
+new file mode 100644
+index 0000000..e3cb7f4
+--- /dev/null
++++ b/ldso/ldso/avr32/resolve.S
+@@ -0,0 +1,28 @@
++/*
++ * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
++ * indicated in register r12 and jumps to the resolved address.
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ *
++ * Copyright (C) 2004-2007 Atmel Corporation
++ */
++
++#define ip r5
++
++ .text
++ .global _dl_linux_resolve
++ .type _dl_linux_resolve,@function
++_dl_linux_resolve:
++ /* The PLT code pushed r8 for us. It contains the address of this
++ function's GOT entry, that is entry 0. ip contains the address
++ of the GOT entry of the function we wanted to call. */
++ stm --sp, r9-r12, lr
++ mov r11, r8
++ sub r12, ip, r8
++ rcall _dl_linux_resolver
++ mov ip, r12
++ popm r8-r12,lr
++ mov pc, ip
++ .size _dl_linux_resolve, . - _dl_linux_resolve
+diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
+index 5cf1d04..d4294ec 100644
+--- a/ldso/ldso/dl-startup.c
++++ b/ldso/ldso/dl-startup.c
+@@ -217,7 +217,9 @@ DL_START(unsigned long args)
+ /* some arches (like MIPS) we have to tweak the GOT before relocations */
+ PERFORM_BOOTSTRAP_GOT(tpnt);
+
+-#else
++#endif
++
++#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
+
+ /* OK, now do the relocations. We do not do a lazy binding here, so
+ that once we are done, we have considerably more flexibility. */
+diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
+index f4e6cac..9cdc3fe 100644
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -1643,7 +1643,7 @@ int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type,
+ *result=result_buf;
+ ret=NETDB_SUCCESS;
+ #ifdef __UCLIBC_HAS_IPV6__
+- } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
++ } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
+ DPRINTF("Found INET6\n");
+ addr_list6[0] = in6;
+ addr_list6[1] = 0;
+@@ -1658,8 +1658,8 @@ int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type,
+ } else {
+ DPRINTF("Error\n");
+ ret=TRY_AGAIN;
+- break; /* bad ip address */
+- }
++ continue; /* bad ip address, keep searching */
++ }
+
+ if (action!=GETHOSTENT) {
+ fclose(fp);
+diff --git a/libc/string/avr32/Makefile b/libc/string/avr32/Makefile
+new file mode 100644
+index 0000000..e19e9d9
+--- /dev/null
++++ b/libc/string/avr32/Makefile
+@@ -0,0 +1,26 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++#
++# You should have received a copy of the GNU Library General Public License
++# along with this program; if not, write to the Free Software Foundation, Inc.,
++# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++top_srcdir := ../../../
++top_builddir := ../../../
++
++all: objs
++
++include $(top_builddir)Rules.mak
++include ../Makefile.in
++include $(top_srcdir)Makerules
+diff --git a/libc/string/avr32/bcopy.S b/libc/string/avr32/bcopy.S
+new file mode 100644
+index 0000000..87c1e04
+--- /dev/null
++++ b/libc/string/avr32/bcopy.S
+@@ -0,0 +1,26 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <features.h>
++
++#ifdef __UCLIBC_SUSV3_LEGACY__
++
++ .text
++ .global bcopy
++ .type bcopy, @function
++ .align 1
++bcopy:
++ /* Swap the first two arguments */
++ eor r11, r12
++ eor r12, r11
++ eor r11, r12
++ rjmp __GI_memmove
++
++ .size bcopy, . - bcopy
++
++#endif /* __UCLIBC_SUSV3_LEGACY__ */
+diff --git a/libc/string/avr32/bzero.S b/libc/string/avr32/bzero.S
+new file mode 100644
+index 0000000..c999e65
+--- /dev/null
++++ b/libc/string/avr32/bzero.S
+@@ -0,0 +1,22 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#ifdef __UCLIBC_SUSV3_LEGACY__
++
++ .text
++ .global bzero
++ .type bzero, @function
++ .align 1
++bzero:
++ mov r10, r11
++ mov r11, 0
++ rjmp __memset
++
++ .size bzero, . - bzero
++
++#endif /* __UCLIBC_SUSV3_LEGACY__ */
+diff --git a/libc/string/avr32/memcmp.S b/libc/string/avr32/memcmp.S
+new file mode 100644
+index 0000000..ae6cc91
+--- /dev/null
++++ b/libc/string/avr32/memcmp.S
+@@ -0,0 +1,61 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <features.h>
++
++#define s1 r12
++#define s2 r11
++#define len r10
++
++ .text
++ .global memcmp
++ .type memcmp, @function
++ .align 1
++memcmp:
++ sub len, 4
++ brlt .Lless_than_4
++
++1: ld.w r8, s1++
++ ld.w r9, s2++
++ cp.w r8, r9
++ brne .Lfound_word
++ sub len, 4
++ brge 1b
++
++.Lless_than_4:
++ sub len, -4
++ reteq 0
++
++1: ld.ub r8, s1++
++ ld.ub r9, s2++
++ sub r8, r9
++ retne r8
++ sub len, 1
++ brgt 1b
++
++ retal 0
++
++.Lfound_word:
++ mov len, 4
++
++2: bfextu r11, r9, 24, 8
++ bfextu r12, r8, 24, 8
++ sub r12, r11
++ retne r12
++ lsl r8, 8
++ lsl r9, 8
++ sub len, 1
++ brne 2b
++ retal r12
++
++ .size memcmp, . - memcmp
++
++libc_hidden_def(memcmp)
++#ifdef __UCLIBC_SUSV3_LEGACY__
++strong_alias(memcmp,bcmp)
++#endif
+diff --git a/libc/string/avr32/memcpy.S b/libc/string/avr32/memcpy.S
+new file mode 100644
+index 0000000..bf091ab
+--- /dev/null
++++ b/libc/string/avr32/memcpy.S
+@@ -0,0 +1,111 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++/* Don't use r12 as dst since we must return it unmodified */
++#define dst r9
++#define src r11
++#define len r10
++
++ .text
++ .global memcpy
++ .type memcpy, @function
++memcpy:
++ pref src[0]
++ mov dst, r12
++
++ /* If we have less than 32 bytes, don't do anything fancy */
++ cp.w len, 32
++ brge .Lmore_than_31
++
++ sub len, 1
++ retlt r12
++1: ld.ub r8, src++
++ st.b dst++, r8
++ sub len, 1
++ brge 1b
++ retal r12
++
++.Lmore_than_31:
++ pushm r0-r7, lr
++
++ /* Check alignment */
++ mov r8, src
++ andl r8, 31, COH
++ brne .Lunaligned_src
++ mov r8, dst
++ andl r8, 3, COH
++ brne .Lunaligned_dst
++
++.Laligned_copy:
++ sub len, 32
++ brlt .Lless_than_32
++
++1: /* Copy 32 bytes at a time */
++ ldm src, r0-r7
++ sub src, -32
++ stm dst, r0-r7
++ sub dst, -32
++ sub len, 32
++ brge 1b
++
++.Lless_than_32:
++ /* Copy 16 more bytes if possible */
++ sub len, -16
++ brlt .Lless_than_16
++ ldm src, r0-r3
++ sub src, -16
++ sub len, 16
++ stm dst, r0-r3
++ sub dst, -16
++
++.Lless_than_16:
++ /* Do the remaining as byte copies */
++ neg len
++ add pc, pc, len << 2
++ .rept 15
++ ld.ub r0, src++
++ st.b dst++, r0
++ .endr
++
++ popm r0-r7, pc
++
++.Lunaligned_src:
++ /* Make src cacheline-aligned. r8 = (src & 31) */
++ rsub r8, r8, 32
++ sub len, r8
++1: ld.ub r0, src++
++ st.b dst++, r0
++ sub r8, 1
++ brne 1b
++
++ /* If dst is word-aligned, we're ready to go */
++ pref src[0]
++ mov r8, 3
++ tst dst, r8
++ breq .Laligned_copy
++
++.Lunaligned_dst:
++ /* src is aligned, but dst is not. Expect bad performance */
++ sub len, 4
++ brlt 2f
++1: ld.w r0, src++
++ st.w dst++, r0
++ sub len, 4
++ brge 1b
++
++2: neg len
++ add pc, pc, len << 2
++ .rept 3
++ ld.ub r0, src++
++ st.b dst++, r0
++ .endr
++
++ popm r0-r7, pc
++ .size memcpy, . - memcpy
++
++libc_hidden_def(memcpy)
+diff --git a/libc/string/avr32/memmove.S b/libc/string/avr32/memmove.S
+new file mode 100644
+index 0000000..98287c5
+--- /dev/null
++++ b/libc/string/avr32/memmove.S
+@@ -0,0 +1,116 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#define dst r12
++#define src r11
++#define len r10
++
++ .text
++ .global memmove
++ .type memmove, @function
++memmove:
++ cp.w src, dst
++ brge __GI_memcpy
++
++ add dst, len
++ add src, len
++ pref src[-1]
++
++ /*
++ * The rest is basically the same as in memcpy.S except that
++ * the direction is reversed.
++ */
++ cp.w len, 32
++ brge .Lmore_than_31
++
++ sub len, 1
++ retlt r12
++1: ld.ub r8, --src
++ st.b --dst, r8
++ sub len, 1
++ brge 1b
++ retal r12
++
++.Lmore_than_31:
++ pushm r0-r7, lr
++
++ /* Check alignment */
++ mov r8, src
++ andl r8, 31, COH
++ brne .Lunaligned_src
++ mov r8, r12
++ andl r8, 3, COH
++ brne .Lunaligned_dst
++
++.Laligned_copy:
++ sub len, 32
++ brlt .Lless_than_32
++
++1: /* Copy 32 bytes at a time */
++ sub src, 32
++ ldm src, r0-r7
++ sub dst, 32
++ sub len, 32
++ stm dst, r0-r7
++ brge 1b
++
++.Lless_than_32:
++ /* Copy 16 more bytes if possible */
++ sub len, -16
++ brlt .Lless_than_16
++ sub src, 16
++ ldm src, r0-r3
++ sub dst, 16
++ sub len, 16
++ stm dst, r0-r3
++
++.Lless_than_16:
++ /* Do the remaining as byte copies */
++ sub len, -16
++ breq 2f
++1: ld.ub r0, --src
++ st.b --dst, r0
++ sub len, 1
++ brne 1b
++
++2: popm r0-r7, pc
++
++.Lunaligned_src:
++ /* Make src cacheline-aligned. r8 = (src & 31) */
++ sub len, r8
++1: ld.ub r0, --src
++ st.b --dst, r0
++ sub r8, 1
++ brne 1b
++
++ /* If dst is word-aligned, we're ready to go */
++ pref src[-4]
++ mov r8, 3
++ tst dst, r8
++ breq .Laligned_copy
++
++.Lunaligned_dst:
++ /* src is aligned, but dst is not. Expect bad performance */
++ sub len, 4
++ brlt 2f
++1: ld.w r0, --src
++ st.w --dst, r0
++ sub len, 4
++ brge 1b
++
++2: neg len
++ add pc, pc, len << 2
++ .rept 3
++ ld.ub r0, --src
++ st.b --dst, r0
++ .endr
++
++ popm r0-r7, pc
++ .size memmove, . - memmove
++
++libc_hidden_def(memmove)
+diff --git a/libc/string/avr32/memset.S b/libc/string/avr32/memset.S
+new file mode 100644
+index 0000000..33cfaed
+--- /dev/null
++++ b/libc/string/avr32/memset.S
+@@ -0,0 +1,70 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <features.h>
++
++#define s r12
++#define c r11
++#define n r10
++
++ .text
++ .global memset
++ .type memset, @function
++
++ .global __memset
++ .hidden __memset
++ .type __memset, @function
++
++ .align 1
++memset:
++__memset:
++ cp.w n, 32
++ mov r9, s
++ brge .Llarge_memset
++
++ sub n, 1
++ retlt s
++1: st.b s++, c
++ sub n, 1
++ brge 1b
++
++ retal r9
++
++.Llarge_memset:
++ mov r8, r11
++ mov r11, 3
++ bfins r8, r8, 8, 8
++ bfins r8, r8, 16, 16
++ tst s, r11
++ breq 2f
++
++1: st.b s++, r8
++ sub n, 1
++ tst s, r11
++ brne 1b
++
++2: mov r11, r9
++ mov r9, r8
++ sub n, 8
++
++3: st.d s++, r8
++ sub n, 8
++ brge 3b
++
++ /* If we are done, n == -8 and we'll skip all st.b insns below */
++ neg n
++ lsl n, 1
++ add pc, n
++ .rept 7
++ st.b s++, r8
++ .endr
++ retal r11
++
++ .size memset, . - memset
++
++libc_hidden_def(memset)
+diff --git a/libc/string/avr32/strcmp.S b/libc/string/avr32/strcmp.S
+new file mode 100644
+index 0000000..f73bd43
+--- /dev/null
++++ b/libc/string/avr32/strcmp.S
+@@ -0,0 +1,91 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <features.h>
++
++#define s1 r12
++#define s2 r11
++#define len r10
++
++ .text
++ .global strcmp
++ .type strcmp, @function
++ .align 1
++strcmp:
++ mov r8, 3
++ tst s1, r8
++ brne .Lunaligned_s1
++ tst s2, r8
++ brne .Lunaligned_s2
++
++1: ld.w r8, s1++
++ ld.w r9, s2++
++ cp.w r8, r9
++ brne 2f
++ tnbz r8
++ brne 1b
++ retal 0
++
++2: bfextu r12, r8, 24, 8
++ bfextu r11, r9, 24, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 16, 8
++ bfextu r11, r9, 16, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 8, 8
++ bfextu r11, r9, 8, 8
++ sub r12, r11
++ retne r12
++ cp.w r11, 0
++ reteq 0
++ bfextu r12, r8, 0, 8
++ bfextu r11, r9, 0, 8
++ sub r12, r11
++ retal r12
++
++.Lunaligned_s1:
++3: tst s1, r8
++ breq 4f
++ ld.ub r10, s1++
++ ld.ub r9, s2++
++ sub r10, r9
++ retne r10
++ cp.w r9, 0
++ brne 3b
++ retal r10
++
++4: tst s2, r8
++ breq 1b
++
++.Lunaligned_s2:
++ /*
++ * s1 and s2 can't both be aligned, and unaligned word loads
++ * can trigger spurious exceptions if we cross a page boundary.
++ * Do it the slow way...
++ */
++1: ld.ub r8, s1++
++ ld.ub r9, s2++
++ sub r8, r9
++ retne r8
++ cp.w r9, 0
++ brne 1b
++ retal 0
++
++ .size strcmp, . - strcmp
++
++libc_hidden_def(strcmp)
++#ifndef __UCLIBC_HAS_LOCALE__
++strong_alias(strcmp, strcoll)
++libc_hidden_def(strcoll)
++#endif
+diff --git a/libc/string/avr32/strlen.S b/libc/string/avr32/strlen.S
+new file mode 100644
+index 0000000..5223e53
+--- /dev/null
++++ b/libc/string/avr32/strlen.S
+@@ -0,0 +1,62 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <features.h>
++
++#define str r12
++
++ .text
++ .global strlen
++ .type strlen, @function
++strlen:
++ mov r11, r12
++
++ mov r9, str
++ andl r9, 3, COH
++ brne .Lunaligned_str
++
++1: ld.w r8, str++
++ tnbz r8
++ brne 1b
++
++ sub r12, r11
++ bfextu r9, r8, 24, 8
++ cp.w r9, 0
++ subeq r12, 4
++ reteq r12
++ bfextu r9, r8, 16, 8
++ cp.w r9, 0
++ subeq r12, 3
++ reteq r12
++ bfextu r9, r8, 8, 8
++ cp.w r9, 0
++ subeq r12, 2
++ reteq r12
++ sub r12, 1
++ retal r12
++
++.Lunaligned_str:
++ add pc, pc, r9 << 3
++ sub r0, r0, 0 /* 4-byte nop */
++ ld.ub r8, str++
++ sub r8, r8, 0
++ breq 1f
++ ld.ub r8, str++
++ sub r8, r8, 0
++ breq 1f
++ ld.ub r8, str++
++ sub r8, r8, 0
++ brne 1b
++
++1: sub r12, 1
++ sub r12, r11
++ retal r12
++
++ .size strlen, . - strlen
++
++libc_hidden_def(strlen)
+diff --git a/libc/sysdeps/linux/avr32/Makefile b/libc/sysdeps/linux/avr32/Makefile
+new file mode 100644
+index 0000000..338abc0
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/Makefile
+@@ -0,0 +1,25 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
++#
++# This program is free software; you can redistribute it and/or modify it under
++# the terms of the GNU Library General Public License as published by the Free
++# Software Foundation; either version 2 of the License, or (at your option) any
++# later version.
++#
++# This program is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
++# details.
++#
++# You should have received a copy of the GNU Library General Public License
++# along with this program; if not, write to the Free Software Foundation, Inc.,
++# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++
++top_srcdir=../../../../
++top_builddir=../../../../
++all: objs
++
++include $(top_builddir)Rules.mak
++include Makefile.arch
++include $(top_srcdir)Makerules
+diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
+new file mode 100644
+index 0000000..44fc01e
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/Makefile.arch
+@@ -0,0 +1,13 @@
++# Makefile for uClibc
++#
++# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
++#
++# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
++#
++
++CSRC := brk.c clone.c mmap.c sigaction.c
++
++SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
++ sigrestorer.S syscall.S vfork.S
++
++include $(top_srcdir)/libc/sysdeps/linux/Makefile.commonarch
+diff --git a/libc/sysdeps/linux/avr32/__longjmp.S b/libc/sysdeps/linux/avr32/__longjmp.S
+new file mode 100644
+index 0000000..6154bb2
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/__longjmp.S
+@@ -0,0 +1,21 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++ .global __longjmp
++ .type __longjmp,"function"
++ .align 1
++__longjmp:
++ ldm r12++, r0-r8,sp,lr
++ mustr r8 /* restore status register (lower half) */
++ cp r11, 0 /* can't return zero */
++ frs
++ moveq r11, 1
++ retal r11
++ .size __longjmp, . - __longjmp
++
++libc_hidden_def(__longjmp)
+diff --git a/libc/sysdeps/linux/avr32/bits/atomic.h b/libc/sysdeps/linux/avr32/bits/atomic.h
+new file mode 100644
+index 0000000..e6be41f
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/atomic.h
+@@ -0,0 +1,120 @@
++/*
++ * Copyright (C) 2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#ifndef _AVR32_BITS_ATOMIC_H
++#define _AVR32_BITS_ATOMIC_H 1
++
++#include <inttypes.h>
++
++typedef int32_t atomic32_t;
++typedef uint32_t uatomic32_t;
++typedef int_fast32_t atomic_fast32_t;
++typedef uint_fast32_t uatomic_fast32_t;
++
++typedef intptr_t atomicptr_t;
++typedef uintptr_t uatomicptr_t;
++typedef intmax_t atomic_max_t;
++typedef uintmax_t uatomic_max_t;
++
++#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
++ (abort(), 0)
++
++#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
++ (abort(), 0)
++
++#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
++ ({ \
++ __typeof__(*(mem)) __prev; \
++ __asm__ __volatile__( \
++ "/* __arch_compare_and_exchange_val_32_acq */\n" \
++ "1: ssrf 5\n" \
++ " ld.w %[result], %[m]\n" \
++ " cp.w %[result], %[old]\n" \
++ " brne 2f\n" \
++ " stcond %[m], %[new]\n" \
++ " brne 1b\n" \
++ "2:" \
++ : [result] "=&r"(__result), [m] "=m"(*(mem)) \
++ : "m"(*(mem)), [old] "ir"(oldval), \
++ [new] "r"(newval) \
++ : "memory", "cc"); \
++ __prev; \
++ })
++
++#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
++ (abort(), 0)
++
++#define __arch_exchange_32_acq(mem, newval) \
++ ({ \
++ __typeof__(*(mem)) __oldval; \
++ __asm__ __volatile__( \
++ "/*__arch_exchange_32_acq */\n" \
++ " xchg %[old], %[m], %[new]" \
++ : [old] "=&r"(__oldval) \
++ : [m] "r"(mem), [new] "r"(newval) \
++ : "memory"); \
++ __oldval; \
++ })
++
++#define __arch_atomic_exchange_and_add_32(mem, value) \
++ ({ \
++ __typeof__(*(mem)) __oldval, __tmp; \
++ __asm__ __volatile__( \
++ "/* __arch_atomic_exchange_and_add_32 */\n" \
++ "1: ssrf 5\n" \
++ " ld.w %[old], %[m]\n" \
++ " add %[tmp], %[old], %[val]\n" \
++ " stcond %[m], %[tmp]\n" \
++ " brne 1b" \
++ : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
++ [m] "=m"(*(mem)) \
++ : "m"(*(mem)), [val] "r"(value) \
++ : "memory", "cc"); \
++ __oldval; \
++ })
++
++#define __arch_atomic_decrement_if_positive_32(mem) \
++ ({ \
++ __typeof__(*(mem)) __oldval, __tmp; \
++ __asm__ __volatile__( \
++ "/* __arch_atomic_decrement_if_positive_32 */\n" \
++ "1: ssrf 5\n" \
++ " ld.w %[old], %[m]\n" \
++ " sub %[tmp], %[old], 1\n" \
++ " brlt 2f\n" \
++ " stcond %[m], %[tmp]\n" \
++ " brne 1b" \
++ "2:" \
++ : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
++ [m] "=m"(*(mem)) \
++ : "m"(*(mem)) \
++ : "memory", "cc"); \
++ __oldval; \
++ })
++
++#define atomic_exchange_acq(mem, newval) \
++ ({ \
++ if (sizeof(*(mem)) != 4) \
++ abort(); \
++ __arch_exchange_32_acq(mem, newval); \
++ })
++
++#define atomic_exchange_and_add(mem, newval) \
++ ({ \
++ if (sizeof(*(mem)) != 4) \
++ abort(); \
++ __arch_atomic_exchange_and_add_32(mem, newval); \
++ })
++
++#define atomic_decrement_if_positive(mem) \
++ ({ \
++ if (sizeof(*(mem)) != 4) \
++ abort(); \
++ __arch_atomic_decrement_if_positive_32(mem); \
++ })
++
++#endif /* _AVR32_BITS_ATOMIC_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/byteswap.h b/libc/sysdeps/linux/avr32/bits/byteswap.h
+new file mode 100644
+index 0000000..1c030b9
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/byteswap.h
+@@ -0,0 +1,70 @@
++/*
++ * Copyright (C) 2005 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
++# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
++#endif
++
++#ifndef _BITS_BYTESWAP_H
++#define _BITS_BYTESWAP_H 1
++
++/* Swap bytes in 16 bit value. */
++#if defined __GNUC__
++# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
++#else
++/* This is better than nothing. */
++static __inline unsigned short int
++__bswap_16 (unsigned short int __bsx)
++{
++ return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
++}
++#endif
++
++/* Swap bytes in 32 bit value. */
++#if defined __GNUC__
++# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
++#else
++static __inline unsigned int
++__bswap_32 (unsigned int __bsx)
++{
++ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
++ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
++}
++#endif
++
++#if defined __GNUC__
++/* Swap bytes in 64 bit value. */
++# define __bswap_constant_64(x) \
++ ((((x) & 0xff00000000000000ull) >> 56) \
++ | (((x) & 0x00ff000000000000ull) >> 40) \
++ | (((x) & 0x0000ff0000000000ull) >> 24) \
++ | (((x) & 0x000000ff00000000ull) >> 8) \
++ | (((x) & 0x00000000ff000000ull) << 8) \
++ | (((x) & 0x0000000000ff0000ull) << 24) \
++ | (((x) & 0x000000000000ff00ull) << 40) \
++ | (((x) & 0x00000000000000ffull) << 56))
++
++# define __bswap_64(x) \
++ (__extension__ \
++ ({ \
++ union { \
++ __extension__ unsigned long long int __ll; \
++ unsigned int __l[2]; \
++ } __w, __r; \
++ if (__builtin_constant_p(x)) \
++ __r.__ll = __bswap_constant_64(x); \
++ else { \
++ __w.__ll = (x); \
++ __r.__l[0] = __bswap_32(__w.__l[1]); \
++ __r.__l[1] = __bswap_32(__w.__l[0]); \
++ } \
++ __r.__ll; \
++ }))
++#endif
++
++#endif /* _BITS_BYTESWAP_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/endian.h b/libc/sysdeps/linux/avr32/bits/endian.h
+new file mode 100644
+index 0000000..7bb6358
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/endian.h
+@@ -0,0 +1,7 @@
++/* AVR32 is big-endian */
++
++#ifndef _ENDIAN_H
++# error "Never use <bits/endian.h> directly; include <endian.h> instead."
++#endif
++
++#define __BYTE_ORDER __BIG_ENDIAN
+diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
+new file mode 100644
+index 0000000..1abff17
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
+@@ -0,0 +1,165 @@
++#ifndef _FCNTL_H
++# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
++#endif
++
++#include <sys/types.h>
++
++/*
++ * open/fcntl - O_SYNC is only implemented on blocks devices and on files
++ * located on an ext2 file system
++ */
++#define O_ACCMODE 00000003
++#define O_RDONLY 00000000
++#define O_WRONLY 00000001
++#define O_RDWR 00000002
++#define O_CREAT 00000100 /* not fcntl */
++#define O_EXCL 00000200 /* not fcntl */
++#define O_NOCTTY 00000400 /* not fcntl */
++#define O_TRUNC 00001000 /* not fcntl */
++#define O_APPEND 00002000
++#define O_NONBLOCK 00004000
++#define O_NDELAY O_NONBLOCK
++#define O_SYNC 00010000
++#define O_ASYNC 00020000
++
++#ifdef __USE_GNU
++# define O_DIRECT 00040000 /* must be a directory */
++# define O_DIRECTORY 00200000 /* direct disk access */
++# define O_NOFOLLOW 00400000 /* don't follow links */
++# define O_NOATIME 01000000 /* don't set atime */
++#endif
++
++#ifdef __USE_LARGEFILE64
++# define O_LARGEFILE 00100000
++#endif
++
++/* For now Linux has synchronisity options for data and read operations.
++ We define the symbols here but let them do the same as O_SYNC since
++ this is a superset. */
++#if defined __USE_POSIX199309 || defined __USE_UNIX98
++# define O_DSYNC O_SYNC /* Synchronize data. */
++# define O_RSYNC O_SYNC /* Synchronize read operations. */
++#endif
++
++#define F_DUPFD 0 /* dup */
++#define F_GETFD 1 /* get close_on_exec */
++#define F_SETFD 2 /* set/clear close_on_exec */
++#define F_GETFL 3 /* get file->f_flags */
++#define F_SETFL 4 /* set file->f_flags */
++
++#ifndef __USE_FILE_OFFSET64
++# define F_GETLK 5
++# define F_SETLK 6
++# define F_SETLKW 7
++#else
++# define F_GETLK F_GETLK64
++# define F_SETLK F_SETLK64
++# define F_SETLKW F_SETLKW64
++#endif
++#define F_GETLK64 12 /* using 'struct flock64' */
++#define F_SETLK64 13
++#define F_SETLKW64 14
++
++#if defined __USE_BSD || defined __USE_XOPEN2K
++# define F_SETOWN 8 /* for sockets. */
++# define F_GETOWN 9 /* for sockets. */
++#endif
++
++#ifdef __USE_GNU
++# define F_SETSIG 10 /* for sockets. */
++# define F_GETSIG 11 /* for sockets. */
++#endif
++
++#ifdef __USE_GNU
++# define F_SETLEASE 1024 /* Set a lease. */
++# define F_GETLEASE 1025 /* Enquire what lease is active. */
++# define F_NOTIFY 1026 /* Request notfications on a directory. */
++#endif
++
++/* for F_[GET|SET]FL */
++#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
++
++/* for posix fcntl() and lockf() */
++#define F_RDLCK 0
++#define F_WRLCK 1
++#define F_UNLCK 2
++
++/* for old implementation of bsd flock () */
++#define F_EXLCK 4 /* or 3 */
++#define F_SHLCK 8 /* or 4 */
++
++/* for leases */
++#define F_INPROGRESS 16
++
++#ifdef __USE_BSD
++/* operations for bsd flock(), also used by the kernel implementation */
++# define LOCK_SH 1 /* shared lock */
++# define LOCK_EX 2 /* exclusive lock */
++# define LOCK_NB 4 /* or'd with one of the above to prevent
++ blocking */
++# define LOCK_UN 8 /* remove lock */
++#endif
++
++#ifdef __USE_GNU
++# define LOCK_MAND 32 /* This is a mandatory flock */
++# define LOCK_READ 64 /* ... Which allows concurrent
++ read operations */
++# define LOCK_WRITE 128 /* ... Which allows concurrent
++ write operations */
++# define LOCK_RW 192 /* ... Which allows concurrent
++ read & write ops */
++#endif
++
++#ifdef __USE_GNU
++/* Types of directory notifications that may be requested with F_NOTIFY. */
++# define DN_ACCESS 0x00000001 /* File accessed. */
++# define DN_MODIFY 0x00000002 /* File modified. */
++# define DN_CREATE 0x00000004 /* File created. */
++# define DN_DELETE 0x00000008 /* File removed. */
++# define DN_RENAME 0x00000010 /* File renamed. */
++# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
++# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
++#endif
++
++struct flock {
++ short l_type;
++ short l_whence;
++#ifndef __USE_FILE_OFFSET64
++ __off_t l_start;
++ __off_t l_len;
++#else
++ __off64_t l_start;
++ __off64_t l_len;
++#endif
++ __pid_t l_pid;
++};
++
++#ifdef __USE_LARGEFILE64
++struct flock64 {
++ short l_type;
++ short l_whence;
++ __off64_t l_start;
++ __off64_t l_len;
++ __pid_t l_pid;
++};
++#endif
++
++/* Define some more compatibility macros to be backward compatible with
++ * BSD systems which did not managed to hide these kernel macros. */
++#ifdef __USE_BSD
++# define FAPPEND O_APPEND
++# define FFSYNC O_FSYNC
++# define FASYNC O_ASYNC
++# define FNONBLOCK O_NONBLOCK
++# define FNDELAY O_NDELAY
++#endif /* Use BSD. */
++
++/* Advise to `posix_fadvise'. */
++#ifdef __USE_XOPEN2K
++# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
++# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
++# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
++# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
++# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
++#endif
+diff --git a/libc/sysdeps/linux/avr32/bits/kernel_stat.h b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
+new file mode 100644
+index 0000000..f97d23b
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
+@@ -0,0 +1,67 @@
++#ifndef _BITS_STAT_STRUCT_H
++#define _BITS_STAT_STRUCT_H
++
++#ifndef _LIBC
++#error bits/kernel_stat.h is for internal uClibc use only!
++#endif
++
++/*
++ * This file provides struct stat, taken from kernel 2.6.4. Verified
++ * to match kernel 2.6.22.
++ */
++
++struct kernel_stat {
++ unsigned long st_dev;
++ unsigned long st_ino;
++ unsigned short st_mode;
++ unsigned short st_nlink;
++ unsigned short st_uid;
++ unsigned short st_gid;
++ unsigned long st_rdev;
++ unsigned long st_size;
++ unsigned long st_blksize;
++ unsigned long st_blocks;
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++ unsigned long __unused4;
++ unsigned long __unused5;
++};
++
++#define STAT_HAVE_NSEC 1
++
++struct kernel_stat64 {
++ unsigned long long st_dev;
++
++ unsigned long long st_ino;
++ unsigned int st_mode;
++ unsigned int st_nlink;
++
++ unsigned long st_uid;
++ unsigned long st_gid;
++
++ unsigned long long st_rdev;
++
++ long long st_size;
++ unsigned long __pad1;
++ unsigned long st_blksize;
++
++ unsigned long long st_blocks;
++
++ unsigned long st_atime;
++ unsigned long st_atime_nsec;
++
++ unsigned long st_mtime;
++ unsigned long st_mtime_nsec;
++
++ unsigned long st_ctime;
++ unsigned long st_ctime_nsec;
++
++ unsigned long __unused1;
++ unsigned long __unused2;
++};
++
++#endif /* _BITS_STAT_STRUCT_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/kernel_types.h b/libc/sysdeps/linux/avr32/bits/kernel_types.h
+new file mode 100644
+index 0000000..f7d8b52
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h
+@@ -0,0 +1,55 @@
++/* Note that we use the exact same include guard #define names
++ * as asm/posix_types.h. This will avoid gratuitous conflicts
++ * with the posix_types.h kernel header, and will ensure that
++ * our private content, and not the kernel header, will win.
++ * -Erik
++ */
++#ifndef __ASM_AVR32_POSIX_TYPES_H
++#define __ASM_AVR32_POSIX_TYPES_H
++
++/*
++ * This file is generally used by user-level software, so you need to
++ * be a little careful about namespace pollution etc. Also, we cannot
++ * assume GCC is being used.
++ */
++
++typedef unsigned long __kernel_dev_t;
++typedef unsigned long __kernel_ino_t;
++typedef unsigned short __kernel_mode_t;
++typedef unsigned short __kernel_nlink_t;
++typedef long __kernel_off_t;
++typedef int __kernel_pid_t;
++typedef unsigned short __kernel_ipc_pid_t;
++typedef unsigned int __kernel_uid_t;
++typedef unsigned int __kernel_gid_t;
++typedef unsigned long __kernel_size_t;
++typedef long __kernel_ssize_t;
++typedef int __kernel_ptrdiff_t;
++typedef long __kernel_time_t;
++typedef long __kernel_suseconds_t;
++typedef long __kernel_clock_t;
++typedef int __kernel_timer_t;
++typedef int __kernel_clockid_t;
++typedef int __kernel_daddr_t;
++typedef char * __kernel_caddr_t;
++typedef unsigned short __kernel_uid16_t;
++typedef unsigned short __kernel_gid16_t;
++typedef unsigned int __kernel_uid32_t;
++typedef unsigned int __kernel_gid32_t;
++typedef unsigned short __kernel_old_uid_t;
++typedef unsigned short __kernel_old_gid_t;
++typedef unsigned short __kernel_old_dev_t;
++
++#ifdef __GNUC__
++typedef long long __kernel_loff_t;
++#endif
++
++typedef struct {
++#if defined(__USE_ALL)
++ int val[2];
++#else
++ int __val[2];
++#endif
++} __kernel_fsid_t;
++
++#endif /* __ASM_AVR32_POSIX_TYPES_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/mman.h b/libc/sysdeps/linux/avr32/bits/mman.h
+new file mode 100644
+index 0000000..5f6e3c3
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/mman.h
+@@ -0,0 +1,103 @@
++/* Definitions for POSIX memory map interface. Linux/AVR32 version.
++ Copyright (C) 1997, 2000 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_MMAN_H
++# error "Never include this file directly. Use <sys/mman.h> instead"
++#endif
++
++/* The following definitions basically come from the kernel headers.
++ But the kernel header is not namespace clean. */
++
++
++/* Protections are chosen from these bits, OR'd together. The
++ implementation does not necessarily support PROT_EXEC or PROT_WRITE
++ without PROT_READ. The only guarantees are that no writing will be
++ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
++
++#define PROT_READ 0x1 /* Page can be read. */
++#define PROT_WRITE 0x2 /* Page can be written. */
++#define PROT_EXEC 0x4 /* Page can be executed. */
++#define PROT_NONE 0x0 /* Page can not be accessed. */
++#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
++ growsdown vma (mprotect only). */
++#define PROT_GROWSUP 0x02000000 /* Extend change to start of
++ growsup vma (mprotect only). */
++
++/* Sharing types (must choose one and only one of these). */
++#define MAP_SHARED 0x01 /* Share changes. */
++#define MAP_PRIVATE 0x02 /* Changes are private. */
++#ifdef __USE_MISC
++# define MAP_TYPE 0x0f /* Mask for type of mapping. */
++#endif
++
++/* Other flags. */
++#define MAP_FIXED 0x10 /* Interpret addr exactly. */
++#ifdef __USE_MISC
++# define MAP_FILE 0
++# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
++# define MAP_ANON MAP_ANONYMOUS
++#endif
++
++/* These are Linux-specific. */
++#ifdef __USE_MISC
++# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
++# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
++# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
++# define MAP_LOCKED 0x2000 /* Lock the mapping. */
++# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
++# define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
++# define MAP_NONBLOCK 0x10000 /* do not block on IO */
++#endif
++
++/* Flags to `msync'. */
++#define MS_ASYNC 1 /* Sync memory asynchronously. */
++#define MS_SYNC 4 /* Synchronous memory sync. */
++#define MS_INVALIDATE 2 /* Invalidate the caches. */
++
++/* Flags for `mlockall'. */
++#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
++#define MCL_FUTURE 2 /* Lock all additions to address
++ space. */
++
++/* Flags for `mremap'. */
++#ifdef __USE_GNU
++# define MREMAP_MAYMOVE 1
++# define MREMAP_FIXED 2
++#endif
++
++/* Advise to `madvise'. */
++#ifdef __USE_BSD
++# define MADV_NORMAL 0 /* No further special treatment. */
++# define MADV_RANDOM 1 /* Expect random page references. */
++# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define MADV_WILLNEED 3 /* Will need these pages. */
++# define MADV_DONTNEED 4 /* Don't need these pages. */
++# define MADV_REMOVE 9 /* Remove these pages and resources. */
++# define MADV_DONTFORK 10 /* Do not inherit across fork. */
++# define MADV_DOFORK 11 /* Do inherit across fork. */
++#endif
++
++/* The POSIX people had to invent similar names for the same things. */
++#ifdef __USE_XOPEN2K
++# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
++# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
++# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
++# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
++# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
++#endif
+diff --git a/libc/sysdeps/linux/avr32/bits/setjmp.h b/libc/sysdeps/linux/avr32/bits/setjmp.h
+new file mode 100644
+index 0000000..78348a3
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/setjmp.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (C) 2004-2005 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#ifndef _BITS_SETJMP_H
++#define _BITS_SETJMP_H 1
++
++#if !defined _SETJMP_H && !defined _PTHREAD_H
++# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
++#endif
++
++#ifndef _ASM
++/*
++ * The jump buffer contains r0-r7, sr, sp and lr. Other registers are
++ * not saved.
++ */
++typedef int __jmp_buf[11];
++#endif
++
++#define __JMP_BUF_SP 4
++
++/* Test if longjmp to JMPBUF would unwind the frame containing a local
++ variable at ADDRESS. */
++#define _JMPBUF_UNWINDS(jmpbuf, address) \
++ ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
++
++#endif /* _BITS_SETJMP_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/stackinfo.h b/libc/sysdeps/linux/avr32/bits/stackinfo.h
+new file mode 100644
+index 0000000..29b8452
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/stackinfo.h
+@@ -0,0 +1,28 @@
++/* Copyright (C) 1999 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++/* This file contains a bit of information about the stack allocation
++ of the processor. */
++
++#ifndef _STACKINFO_H
++#define _STACKINFO_H 1
++
++/* On AVR32 the stack grows down. */
++#define _STACK_GROWS_DOWN 1
++
++#endif /* stackinfo.h */
+diff --git a/libc/sysdeps/linux/avr32/bits/syscalls.h b/libc/sysdeps/linux/avr32/bits/syscalls.h
+new file mode 100644
+index 0000000..22ac059
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/syscalls.h
+@@ -0,0 +1,143 @@
++#ifndef _BITS_SYSCALLS_H
++#define _BITS_SYSCALLS_H
++#ifndef _SYSCALL_H
++# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
++#endif
++
++/*
++ * This includes the `__NR_<name>' syscall numbers taken from the
++ * Linux kernel header files. It also defines the traditional
++ * `SYS_<name>' macros for older programs.
++ */
++#include <bits/sysnum.h>
++
++#ifndef __ASSEMBLER__
++
++#include <errno.h>
++
++#define SYS_ify(syscall_name) (__NR_##syscall_name)
++
++#undef _syscall0
++#define _syscall0(type,name) \
++ type name(void) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 0)); \
++ }
++
++#undef _syscall1
++#define _syscall1(type,name,type1,arg1) \
++ type name(type1 arg1) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 1, arg1)); \
++ }
++
++#undef _syscall2
++#define _syscall2(type,name,type1,arg1,type2,arg2) \
++ type name(type1 arg1, type2 arg2) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 2, arg1, arg2)); \
++ }
++
++#undef _syscall3
++#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
++ type name(type1 arg1, type2 arg2, type3 arg3) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 3, arg1, \
++ arg2, arg3)); \
++ }
++
++#undef _syscall4
++#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 4, arg1, arg2, \
++ arg3, arg4)); \
++ }
++
++#undef _syscall5
++#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4,type5,arg5) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
++ type5 arg5) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 5, arg1, arg2, \
++ arg3, arg4, arg5)); \
++ }
++
++#undef _syscall6
++#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3, \
++ type4,arg4,type5,arg5,type6,arg6) \
++ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
++ type5 arg5, type6 arg6) \
++ { \
++ return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
++ arg4, arg5, arg6)); \
++ }
++
++#undef unlikely
++#define unlikely(x) __builtin_expect((x), 0)
++
++#undef INLINE_SYSCALL
++#define INLINE_SYSCALL(name, nr, args...) \
++ ({ \
++ unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
++ __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
++ _sys_result = (unsigned int) -1; \
++ } \
++ (int) _sys_result; \
++ })
++
++#undef INTERNAL_SYSCALL_DECL
++#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
++
++#undef INTERNAL_SYSCALL
++#define INTERNAL_SYSCALL(name, err, nr, args...) \
++ ({ \
++ register int _a1 asm ("r12"); \
++ register int _scno asm("r8") = SYS_ify(name); \
++ LOAD_ARGS_##nr (args); \
++ asm volatile ("scall /* syscall " #name " */" \
++ : "=r" (_a1) \
++ : "r"(_scno) ASM_ARGS_##nr \
++ : "cc", "memory"); \
++ _a1; \
++ })
++
++#undef INTERNAL_SYSCALL_ERROR_P
++#define INTERNAL_SYSCALL_ERROR_P(val, err) \
++ ((unsigned int)(val) >= 0xfffff001U)
++
++#undef INTERNAL_SYSCALL_ERRNO
++#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
++
++#define LOAD_ARGS_0() do { } while(0)
++#define ASM_ARGS_0
++#define LOAD_ARGS_1(a1) \
++ _a1 = (int) (a1); \
++ LOAD_ARGS_0()
++#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
++#define LOAD_ARGS_2(a1, a2) \
++ register int _a2 asm("r11") = (int)(a2); \
++ LOAD_ARGS_1(a1)
++#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
++#define LOAD_ARGS_3(a1, a2, a3) \
++ register int _a3 asm("r10") = (int)(a3); \
++ LOAD_ARGS_2(a1, a2)
++#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
++#define LOAD_ARGS_4(a1, a2, a3, a4) \
++ register int _a4 asm("r9") = (int)(a4); \
++ LOAD_ARGS_3(a1, a2, a3)
++#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
++#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
++ register int _a5 asm("r5") = (int)(a5); \
++ LOAD_ARGS_4(a1, a2, a3, a4)
++#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
++#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
++ register int _a6 asm("r3") = (int)(a6); \
++ LOAD_ARGS_5(a1, a2, a3, a4, a5)
++#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
++
++#endif /* __ASSEMBLER__ */
++#endif /* _BITS_SYSCALLS_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
+new file mode 100644
+index 0000000..e95e8a5
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
+@@ -0,0 +1,45 @@
++/*
++ * Track misc arch-specific features that aren't config options
++ */
++
++#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
++#define _BITS_UCLIBC_ARCH_FEATURES_H
++
++/* instruction used when calling abort() to kill yourself */
++/* trigger illegal instruction exception, same as BUG in Linux */
++#define __UCLIBC_ABORT_INSTRUCTION__ ".short 0x5df0"
++
++/* can your target use syscall6() for mmap ? */
++#define __UCLIBC_MMAP_HAS_6_ARGS__
++
++/* does your target use syscall4() for truncate64 ? (32bit arches only) */
++#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
++
++/* does your target have a broken create_module() ? */
++#undef __UCLIBC_BROKEN_CREATE_MODULE__
++
++/* does your target have to worry about older [gs]etrlimit() ? */
++#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
++
++/* does your target prefix all symbols with an _ ? */
++#define __UCLIBC_NO_UNDERSCORES__
++
++/* does your target have an asm .set ? */
++#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
++
++/* define if target doesn't like .global */
++#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
++
++/* define if target supports .weak */
++#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
++
++/* define if target supports .weakext */
++#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
++
++/* needed probably only for ppc64 */
++#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
++
++/* define if target supports IEEE signed zero floats */
++#define __UCLIBC_HAVE_SIGNED_ZERO__
++
++#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
+diff --git a/libc/sysdeps/linux/avr32/bits/wordsize.h b/libc/sysdeps/linux/avr32/bits/wordsize.h
+new file mode 100644
+index 0000000..1b5842a
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bits/wordsize.h
+@@ -0,0 +1 @@
++#define __WORDSIZE 32
+diff --git a/libc/sysdeps/linux/avr32/brk.c b/libc/sysdeps/linux/avr32/brk.c
+new file mode 100644
+index 0000000..a54b49a
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/brk.c
+@@ -0,0 +1,31 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#include <errno.h>
++#include <unistd.h>
++#include <sys/syscall.h>
++
++libc_hidden_proto(brk)
++
++void *__curbrk attribute_hidden = 0;
++
++int brk (void *addr)
++{
++ void *newbrk;
++
++ newbrk = (void *)INLINE_SYSCALL(brk, 1, addr);
++
++ __curbrk = newbrk;
++
++ if (newbrk < addr) {
++ __set_errno (ENOMEM);
++ return -1;
++ }
++
++ return 0;
++}
++libc_hidden_def(brk)
+diff --git a/libc/sysdeps/linux/avr32/bsd-_setjmp.S b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
+new file mode 100644
+index 0000000..be66a10
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
+@@ -0,0 +1,16 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++ /* This just does a tail-call to __sigsetjmp(env, 0) */
++ .global _setjmp
++ .type _setjmp,"function"
++ .align 1
++_setjmp:
++ mov r11, 0
++ bral __GI___sigsetjmp
++ .size _setjmp, . - _setjmp
+diff --git a/libc/sysdeps/linux/avr32/bsd-setjmp.S b/libc/sysdeps/linux/avr32/bsd-setjmp.S
+new file mode 100644
+index 0000000..4635eeb
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/bsd-setjmp.S
+@@ -0,0 +1,16 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++ /* This just does a tail-call to __sigsetjmp(env, 1) */
++ .global setjmp
++ .type setjmp,"function"
++ .align 1
++setjmp:
++ mov r11, 1
++ bral __GI___sigsetjmp
++ .size setjmp, . - setjmp
+diff --git a/libc/sysdeps/linux/avr32/clone.c b/libc/sysdeps/linux/avr32/clone.c
+new file mode 100644
+index 0000000..e43b0f3
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/clone.c
+@@ -0,0 +1,41 @@
++/*
++ * Copyright (C) 2004 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#include <errno.h>
++#include <sys/syscall.h>
++#include <unistd.h>
++
++/*
++ * I don't know if we can be absolutely certain that the fn and arg
++ * parameters are preserved when returning as the child. If the
++ * compiler stores them in registers (r0-r7), they should be.
++ */
++int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
++{
++ register int (*_fn)(void *arg) = fn;
++ register void *_arg = arg;
++ int err;
++
++ /* Sanity check the arguments */
++ err = -EINVAL;
++ if (!fn)
++ goto syscall_error;
++ if (!child_stack)
++ goto syscall_error;
++
++ err = INLINE_SYSCALL(clone, 2, flags, child_stack);
++ if (err < 0)
++ goto syscall_error;
++ else if (err != 0)
++ return err;
++
++ _exit(_fn(_arg));
++
++syscall_error:
++ __set_errno (-err);
++ return -1;
++}
+diff --git a/libc/sysdeps/linux/avr32/crt1.S b/libc/sysdeps/linux/avr32/crt1.S
+new file mode 100644
+index 0000000..ca1fa7a
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/crt1.S
+@@ -0,0 +1,97 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ *
++ * When we enter _start, the stack looks like this:
++ * argc argument counter
++ * argv[0] pointer to program name
++ * argv[1..argc-1] pointers to program args
++ * NULL
++ * env[0..N] pointers to environment variables
++ * NULL
++ *
++ * r12 contains a function pointer to be registered with `atexit'.
++ * This is how the dynamic linker arranges to have DT_FINI functions
++ * called for shared libraries that have been loaded before this
++ * code runs.
++ *
++ * We're going to call the following function:
++ * __uClibc_main(int (*main)(int, char **, char **), int argc,
++ * char **argv, void (*app_init)(void), void (*app_fini)(void),
++ * void (*rtld_fini)(void), void *stack_end)
++ *
++ * So we need to set up things as follows:
++ * r12 = address of main
++ * r11 = argc
++ * r10 = &argv[0]
++ * r9 = address of _init
++ * r8 = address of _fini
++ * sp[0] = whatever we got passed in r12
++ */
++
++#include <features.h>
++
++ .text
++ .global _start
++ .type _start, @function
++_start:
++ /* Clear the frame pointer and link register since this is the outermost frame. */
++ mov r7, 0
++ mov lr, 0
++
++ ld.w r11, sp++ /* argc */
++ mov r10, sp /* &argv[0] */
++
++ st.w --sp, r10 /* stack_end */
++ st.w --sp, r12 /* rtld_fini */
++
++#ifdef __PIC__
++ lddpc r6, .L_GOT
++.L_RGOT:
++ rsub r6, pc
++ lda.w r9, _init
++ lda.w r8, _fini
++ lda.w r12, main
++
++ /* Ok, now run uClibc's main() -- should not return */
++ call __uClibc_main
++
++ .align 2
++.L_GOT:
++ .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
++#else
++ lddpc r9, __init_addr /* app_init */
++ lddpc r8, __fini_addr /* app_fini */
++ lddpc r12, __main_addr /* main */
++
++ /* Ok, now run uClibc's main() -- should not return */
++ lddpc pc, ___uClibc_main_addr
++
++ .align 2
++__init_addr:
++ .long _init
++__fini_addr:
++ .long _fini
++__main_addr:
++ .long main
++___uClibc_main_addr:
++ .long __uClibc_main
++#endif
++ .size _start, . - _start
++
++ /*
++ * The LSB says we need this.
++ */
++ .section ".note.ABI-tag", "a"
++ .align 4
++ .long 2f - 1f /* namesz */
++ .long 4f - 3f /* descsz */
++ .long 1 /* type */
++1: .asciz "GNU" /* name */
++2: .align 4
++3: .long 0 /* Linux executable */
++ .long 2,6,0 /* Earliest compatible kernel */
++4: .align 4
+diff --git a/libc/sysdeps/linux/avr32/crti.S b/libc/sysdeps/linux/avr32/crti.S
+new file mode 100644
+index 0000000..660f47c
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/crti.S
+@@ -0,0 +1,26 @@
++
++ .section .init
++ .align 2
++ .global _init
++ .type _init, @function
++_init:
++ stm --sp, r6, lr
++ lddpc r6, 2f
++1: rsub r6, pc
++ rjmp 3f
++ .align 2
++2: .long 1b - _GLOBAL_OFFSET_TABLE_
++3:
++
++ .section .fini
++ .align 2
++ .global _fini
++ .type _fini, @function
++_fini:
++ stm --sp, r6, lr
++ lddpc r6, 2f
++1: rsub r6, pc
++ rjmp 3f
++ .align 2
++2: .long 1b - _GLOBAL_OFFSET_TABLE_
++3:
+diff --git a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S
+new file mode 100644
+index 0000000..f7d1040
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/crtn.S
+@@ -0,0 +1,14 @@
++
++ .section .init
++ .align 2
++ .global _init
++ .type _init, @function
++ ldm sp++, r6, pc
++ .size _init, . - _init
++
++ .section .fini
++ .align 2
++ .global _fini
++ .type _fini, @function
++ ldm sp++, r6, pc
++ .size _fini, . - _fini
+diff --git a/libc/sysdeps/linux/avr32/mmap.c b/libc/sysdeps/linux/avr32/mmap.c
+new file mode 100644
+index 0000000..2ee025a
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/mmap.c
+@@ -0,0 +1,33 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++#include <errno.h>
++#include <unistd.h>
++#include <sys/mman.h>
++#include <sys/syscall.h>
++
++libc_hidden_proto(mmap)
++
++static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot,
++ int, flags, int, fd, __off_t, pgoff);
++
++__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
++{
++ unsigned long page_size = sysconf(_SC_PAGESIZE);
++ unsigned long pgoff;
++
++ if (offset & (page_size - 1)) {
++ __set_errno(EINVAL);
++ return MAP_FAILED;
++ }
++
++ pgoff = (unsigned long)offset >> (31 - __builtin_clz(page_size));
++
++ return mmap2(addr, len, prot, flags, fd, pgoff);
++}
++libc_hidden_def(mmap)
+diff --git a/libc/sysdeps/linux/avr32/setjmp.S b/libc/sysdeps/linux/avr32/setjmp.S
+new file mode 100644
+index 0000000..7d0354b
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/setjmp.S
+@@ -0,0 +1,29 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#define _SETJMP_H
++#define _ASM
++#include <bits/setjmp.h>
++
++ .text
++
++ .global __sigsetjmp
++ .type __sigsetjmp,"function"
++
++ .align 1
++__sigsetjmp:
++ mustr r8
++ stm r12, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
++
++ /*
++ * Make a tail call to __sigjmp_save; it takes the same args
++ * and is hidden so we don't need to mess around with the GOT.
++ */
++ rjmp __sigjmp_save
++ .size __sigsetjmp, . - __sigsetjmp
++
++libc_hidden_def(__sigsetjmp)
+diff --git a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c
+new file mode 100644
+index 0000000..a97ff3d
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sigaction.c
+@@ -0,0 +1,59 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#include <errno.h>
++#include <signal.h>
++#include <string.h>
++#include <sys/syscall.h>
++#include <bits/kernel_sigaction.h>
++
++#define SA_RESTORER 0x04000000
++extern void __default_rt_sa_restorer(void);
++
++libc_hidden_proto(memcpy)
++
++/*
++ * If act is not NULL, change the action for sig to *act.
++ * If oact is not NULL, put the old action for sig in *oact.
++ */
++int __libc_sigaction(int signum, const struct sigaction *act,
++ struct sigaction *oldact)
++{
++ struct kernel_sigaction kact, koact;
++ int result;
++
++ if (act) {
++ kact.k_sa_handler = act->sa_handler;
++ memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
++ kact.sa_flags = act->sa_flags;
++ if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
++ kact.sa_restorer = act->sa_restorer;
++ else
++ kact.sa_restorer = __default_rt_sa_restorer;
++ kact.sa_flags |= SA_RESTORER;
++ }
++
++ result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
++ oldact ? __ptrvalue(&koact) : NULL,
++ _NSIG / 8);
++
++ if (oldact && result >= 0) {
++ oldact->sa_handler = koact.k_sa_handler;
++ memcpy(&oldact->sa_mask, &koact.sa_mask,
++ sizeof(oldact->sa_mask));
++ oldact->sa_flags = koact.sa_flags;
++ oldact->sa_restorer = koact.sa_restorer;
++ }
++
++ return result;
++}
++
++#ifndef LIBC_SIGACTION
++libc_hidden_proto(sigaction)
++weak_alias(__libc_sigaction, sigaction)
++libc_hidden_weak(sigaction)
++#endif
+diff --git a/libc/sysdeps/linux/avr32/sigrestorer.S b/libc/sysdeps/linux/avr32/sigrestorer.S
+new file mode 100644
+index 0000000..df6a1ba
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sigrestorer.S
+@@ -0,0 +1,15 @@
++/*
++ * Copyright (C) 2004 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#include <sys/syscall.h>
++
++ .global __default_rt_sa_restorer
++ .type __default_rt_sa_restorer,"function"
++ .align 1
++__default_rt_sa_restorer:
++ mov r8, __NR_rt_sigreturn
++ scall
+diff --git a/libc/sysdeps/linux/avr32/sys/elf.h b/libc/sysdeps/linux/avr32/sys/elf.h
+new file mode 100644
+index 0000000..faa7310
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sys/elf.h
+@@ -0,0 +1,26 @@
++/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_ELF_H
++#define _SYS_ELF_H 1
++
++#warning "This header is obsolete; use <sys/procfs.h> instead."
++
++#include <sys/procfs.h>
++
++#endif /* sys/elf.h */
+diff --git a/libc/sysdeps/linux/avr32/sys/procfs.h b/libc/sysdeps/linux/avr32/sys/procfs.h
+new file mode 100644
+index 0000000..3b37363
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sys/procfs.h
+@@ -0,0 +1,123 @@
++/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _SYS_PROCFS_H
++#define _SYS_PROCFS_H 1
++
++/* This is somewhat modelled after the file of the same name on SVR4
++ systems. It provides a definition of the core file format for ELF
++ used on Linux. It doesn't have anything to do with the /proc file
++ system, even though Linux has one.
++
++ Anyway, the whole purpose of this file is for GDB and GDB only.
++ Don't read too much into it. Don't use it for anything other than
++ GDB unless you know what you are doing. */
++
++#include <features.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/user.h>
++
++__BEGIN_DECLS
++
++/* Type for a general-purpose register. */
++typedef unsigned long elf_greg_t;
++
++/* And the whole bunch of them. We could have used `struct
++ user_regs' directly in the typedef, but tradition says that
++ the register set is an array, which does have some peculiar
++ semantics, so leave it that way. */
++#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
++typedef elf_greg_t elf_gregset_t[ELF_NGREG];
++
++/* Register set for the floating-point registers. */
++typedef struct user_fpregs elf_fpregset_t;
++
++/* Signal info. */
++struct elf_siginfo
++ {
++ int si_signo; /* Signal number. */
++ int si_code; /* Extra code. */
++ int si_errno; /* Errno. */
++ };
++
++/* Definitions to generate Intel SVR4-like core files. These mostly
++ have the same names as the SVR4 types with "elf_" tacked on the
++ front to prevent clashes with Linux definitions, and the typedef
++ forms have been avoided. This is mostly like the SVR4 structure,
++ but more Linuxy, with things that Linux does not support and which
++ GDB doesn't really use excluded. */
++
++struct elf_prstatus
++ {
++ struct elf_siginfo pr_info; /* Info associated with signal. */
++ short int pr_cursig; /* Current signal. */
++ unsigned long int pr_sigpend; /* Set of pending signals. */
++ unsigned long int pr_sighold; /* Set of held signals. */
++ __pid_t pr_pid;
++ __pid_t pr_ppid;
++ __pid_t pr_pgrp;
++ __pid_t pr_sid;
++ struct timeval pr_utime; /* User time. */
++ struct timeval pr_stime; /* System time. */
++ struct timeval pr_cutime; /* Cumulative user time. */
++ struct timeval pr_cstime; /* Cumulative system time. */
++ elf_gregset_t pr_reg; /* GP registers. */
++ int pr_fpvalid; /* True if math copro being used. */
++ };
++
++
++#define ELF_PRARGSZ (80) /* Number of chars for args. */
++
++struct elf_prpsinfo
++ {
++ char pr_state; /* Numeric process state. */
++ char pr_sname; /* Char for pr_state. */
++ char pr_zomb; /* Zombie. */
++ char pr_nice; /* Nice val. */
++ unsigned long int pr_flag; /* Flags. */
++ unsigned short int pr_uid;
++ unsigned short int pr_gid;
++ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
++ /* Lots missing */
++ char pr_fname[16]; /* Filename of executable. */
++ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
++ };
++
++/* The rest of this file provides the types for emulation of the
++ Solaris <proc_service.h> interfaces that should be implemented by
++ users of libthread_db. */
++
++/* Addresses. */
++typedef void *psaddr_t;
++
++/* Register sets. Linux has different names. */
++typedef elf_gregset_t prgregset_t;
++typedef elf_fpregset_t prfpregset_t;
++
++/* We don't have any differences between processes and threads,
++ therefore have only one PID type. */
++typedef __pid_t lwpid_t;
++
++/* Process status and info. In the end we do provide typedefs for them. */
++typedef struct elf_prstatus prstatus_t;
++typedef struct elf_prpsinfo prpsinfo_t;
++
++__END_DECLS
++
++#endif /* sys/procfs.h */
+diff --git a/libc/sysdeps/linux/avr32/sys/ucontext.h b/libc/sysdeps/linux/avr32/sys/ucontext.h
+new file mode 100644
+index 0000000..82c7fe2
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sys/ucontext.h
+@@ -0,0 +1,90 @@
++/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++/* Linux/AVR32 ABI compliant context switching support. */
++
++#ifndef _SYS_UCONTEXT_H
++#define _SYS_UCONTEXT_H 1
++
++#include <features.h>
++#include <signal.h>
++#include <sys/procfs.h>
++#include <bits/sigcontext.h>
++
++typedef int greg_t;
++
++/* Number of general registers. */
++#define NGREG 16
++
++/* Container for all general registers. */
++typedef elf_gregset_t gregset_t;
++
++/* Number of each register is the `gregset_t' array. */
++enum
++{
++ R0 = 0,
++#define R0 R0
++ R1 = 1,
++#define R1 R1
++ R2 = 2,
++#define R2 R2
++ R3 = 3,
++#define R3 R3
++ R4 = 4,
++#define R4 R4
++ R5 = 5,
++#define R5 R5
++ R6 = 6,
++#define R6 R6
++ R7 = 7,
++#define R7 R7
++ R8 = 8,
++#define R8 R8
++ R9 = 9,
++#define R9 R9
++ R10 = 10,
++#define R10 R10
++ R11 = 11,
++#define R11 R11
++ R12 = 12,
++#define R12 R12
++ R13 = 13,
++#define R13 R13
++ R14 = 14,
++#define R14 R14
++ R15 = 15
++#define R15 R15
++};
++
++/* Structure to describe FPU registers. */
++typedef elf_fpregset_t fpregset_t;
++
++/* Context to describe whole processor state. */
++typedef struct sigcontext mcontext_t;
++
++/* Userlevel context. */
++typedef struct ucontext
++{
++ unsigned long uc_flags;
++ struct ucontext *uc_link;
++ stack_t uc_stack;
++ mcontext_t uc_mcontext;
++ sigset_t uc_sigmask; /* mask last for extensibility */
++} ucontext_t;
++
++#endif /* sys/ucontext.h */
+diff --git a/libc/sysdeps/linux/avr32/sys/user.h b/libc/sysdeps/linux/avr32/sys/user.h
+new file mode 100644
+index 0000000..c0b3d38
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/sys/user.h
+@@ -0,0 +1,46 @@
++#ifndef _SYS_USER_H
++#define _SYS_USER_H
++
++struct user_fpregs
++{
++
++};
++
++struct user_regs
++{
++ unsigned long sr;
++ unsigned long pc;
++ unsigned long lr;
++ unsigned long sp;
++ unsigned long r12;
++ unsigned long r11;
++ unsigned long r10;
++ unsigned long r9;
++ unsigned long r8;
++ unsigned long r7;
++ unsigned long r6;
++ unsigned long r5;
++ unsigned long r4;
++ unsigned long r3;
++ unsigned long r2;
++ unsigned long r1;
++ unsigned long r0;
++ unsigned long r12_orig;
++};
++
++struct user
++{
++ struct user_regs regs; /* general registers */
++ size_t u_tsize; /* text size (pages) */
++ size_t u_dsize; /* data size (pages) */
++ size_t u_ssize; /* stack size (pages) */
++ unsigned long start_code; /* text starting address */
++ unsigned long start_data; /* data starting address */
++ unsigned long start_stack; /* stack starting address */
++ long int signal; /* signal causing core dump */
++ struct user_regs * u_ar0; /* help gdb find registers */
++ unsigned long magic; /* identifies a core file */
++ char u_comm[32]; /* user command name */
++};
++
++#endif /* _SYS_USER_H */
+diff --git a/libc/sysdeps/linux/avr32/syscall.S b/libc/sysdeps/linux/avr32/syscall.S
+new file mode 100644
+index 0000000..55c1b1f
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/syscall.S
+@@ -0,0 +1,71 @@
++/*
++ * Copyright (C) 2004-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#include <features.h>
++
++ .text
++
++ /*
++ * long int syscall(long int sysno, ...)
++ */
++ .global syscall
++ .type syscall, @function
++ .align 2
++syscall:
++ stm --sp, r3,r5,r6,lr
++ sub lr, sp, -16
++ mov r8, r12
++ ldm lr, r3,r5,r9-r12
++ scall
++ cp.w r12, -4095
++ brlo .Ldone
++
++#ifdef __PIC__
++ lddpc r6, .Lgot
++.Lgotcalc:
++ rsub r6, pc
++# ifdef __UCLIBC_HAS_THREADS__
++ rsub r3, r12, 0
++ mcall r6[__errno_location@got]
++ st.w r12[0], r3
++# else
++ ld.w r3, r6[errno@got]
++ neg r12
++ st.w r3[0], r12
++# endif
++#else
++# ifdef __UCLIBC_HAS_THREADS__
++ rsub r3, r12, 0
++ mcall .Lerrno_location
++ st.w r12[0], r3
++# else
++ lddpc r3, .Lerrno
++ neg r12
++ st.w r3[0], r12
++# endif
++#endif
++ mov r12, -1
++
++.Ldone:
++ ldm sp++, r3,r5,r6,pc
++
++ .align 2
++#ifdef __PIC__
++.Lgot:
++ .long .Lgotcalc - _GLOBAL_OFFSET_TABLE_
++#else
++# ifdef __UCLIBC_HAS_THREADS__
++.Lerrno_location:
++ .long __errno_location
++# else
++.Lerrno:
++ .long errno
++# endif
++#endif
++
++
++ .size syscall, . - syscall
+diff --git a/libc/sysdeps/linux/avr32/vfork.S b/libc/sysdeps/linux/avr32/vfork.S
+new file mode 100644
+index 0000000..03ca99f
+--- /dev/null
++++ b/libc/sysdeps/linux/avr32/vfork.S
+@@ -0,0 +1,58 @@
++/*
++ * Copyright (C) 2005 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++
++/*
++ * Clone the process without copying the address space. The
++ * calling process is suspended until the child either exits
++ * or calls execve.
++ *
++ * This all means that we cannot rely on the stack to store
++ * away registers, since they will be overwritten by the child
++ * as soon as it makes another function call (e.g. execve()).
++ * Fortunately, the Linux kernel preserves LR across system calls.
++ */
++
++#include <features.h>
++#include <sys/syscall.h>
++
++ .global __vfork
++ .type __vfork,@function
++ .align 1
++__vfork:
++ mov r8, __NR_vfork
++ scall
++ cp.w r12, -4096
++ retls r12
++
++ /* vfork failed, so we may use the stack freely */
++ pushm r4-r7,lr
++#ifdef __PIC__
++ lddpc r6, .L_GOT
++ rsub r4, r12, 0
++.L_RGOT:
++ rsub r6, pc
++ mcall r6[__errno_location@got]
++#else
++ rsub r4, r12, 0
++ mcall .L__errno_location
++#endif
++ st.w r12[0], r4
++ popm r4-r7,pc,r12=-1
++
++ .align 2
++#ifdef __PIC__
++.L_GOT:
++ .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
++#else
++.L__errno_location:
++ .long __errno_location
++#endif
++ .size __vfork, . - __vfork
++
++weak_alias(__vfork,vfork)
++libc_hidden_weak(vfork)
+diff --git a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
+new file mode 100644
+index 0000000..eccf329
+--- /dev/null
++++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
+@@ -0,0 +1,73 @@
++/* Machine-dependent pthreads configuration and inline functions.
++ *
++ * Copyright (C) 2005-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#ifndef _PT_MACHINE_H
++#define _PT_MACHINE_H 1
++
++#include <features.h>
++
++static inline int
++_test_and_set (int *p, int v)
++{
++ int result;
++
++ __asm__ __volatile__(
++ "/* Inline test and set */\n"
++ " xchg %[old], %[mem], %[new]"
++ : [old] "=&r"(result)
++ : [mem] "r"(p), [new] "r"(v)
++ : "memory");
++
++ return result;
++}
++
++#ifndef PT_EI
++# define PT_EI extern inline
++#endif
++
++extern long int testandset (int *spinlock);
++extern int __compare_and_swap (long int *p, long int oldval, long int newval);
++
++/* Spinlock implementation; required. */
++PT_EI long int
++testandset (int *spinlock)
++{
++ return _test_and_set(spinlock, 1);
++}
++
++
++/* Get some notion of the current stack. Need not be exactly the top
++ of the stack, just something somewhere in the current frame. */
++#define CURRENT_STACK_FRAME stack_pointer
++register char * stack_pointer __asm__ ("sp");
++
++/* Compare-and-swap for semaphores. */
++
++#define HAS_COMPARE_AND_SWAP
++PT_EI int
++__compare_and_swap(long int *p, long int oldval, long int newval)
++{
++ long int result;
++
++ __asm__ __volatile__(
++ "/* Inline compare and swap */\n"
++ "1: ssrf 5\n"
++ " ld.w %[result], %[mem]\n"
++ " eor %[result], %[old]\n"
++ " brne 2f\n"
++ " stcond %[mem], %[new]\n"
++ " brne 1b\n"
++ "2:"
++ : [result] "=&r"(result), [mem] "=m"(*p)
++ : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
++ : "cc", "memory");
++
++ return result == 0;
++}
++
++#endif /* pt-machine.h */
+diff --git a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
+new file mode 100644
+index 0000000..fe12bf8
+--- /dev/null
++++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
+@@ -0,0 +1,73 @@
++/* Machine-dependent pthreads configuration and inline functions.
++ *
++ * Copyright (C) 2005-2007 Atmel Corporation
++ *
++ * This file is subject to the terms and conditions of the GNU Lesser General
++ * Public License. See the file "COPYING.LIB" in the main directory of this
++ * archive for more details.
++ */
++#ifndef _PT_MACHINE_H
++#define _PT_MACHINE_H 1
++
++#include <features.h>
++
++static inline int
++_test_and_set (int *p, int v) __THROW
++{
++ int result;
++
++ __asm__ __volatile__(
++ "/* Inline test and set */\n"
++ " xchg %[old], %[mem], %[new]"
++ : [old] "=&r"(result)
++ : [mem] "r"(p), [new] "r"(v)
++ : "memory");
++
++ return result;
++}
++
++#ifndef PT_EI
++# define PT_EI extern inline
++#endif
++
++extern long int testandset (int *spinlock);
++extern int __compare_and_swap (long int *p, long int oldval, long int newval);
++
++/* Spinlock implementation; required. */
++PT_EI long int
++testandset (int *spinlock)
++{
++ return _test_and_set(spinlock, 1);
++}
++
++
++/* Get some notion of the current stack. Need not be exactly the top
++ of the stack, just something somewhere in the current frame. */
++#define CURRENT_STACK_FRAME stack_pointer
++register char * stack_pointer __asm__ ("sp");
++
++/* Compare-and-swap for semaphores. */
++
++#define HAS_COMPARE_AND_SWAP
++PT_EI int
++__compare_and_swap(long int *p, long int oldval, long int newval)
++{
++ int result;
++
++ __asm__ __volatile__(
++ "/* Inline compare and swap */\n"
++ "1: ssrf 5\n"
++ " ld.w %[result], %[mem]\n"
++ " eor %[result], %[old]\n"
++ " brne 2f\n"
++ " stcond %[mem], %[new]\n"
++ " brne 1b\n"
++ "2:"
++ : [result] "=&r"(result), [mem] "=m"(*p)
++ : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
++ : "cc", "memory");
++
++ return result == 0;
++}
++
++#endif /* pt-machine.h */
+diff --git a/utils/ldd.c b/utils/ldd.c
+index 75ad628..e34acd9 100644
+--- a/utils/ldd.c
++++ b/utils/ldd.c
+@@ -44,6 +44,11 @@
+ #define ELFCLASSM ELFCLASS32
+ #endif
+
++#if defined(__avr32__)
++#define MATCH_MACHINE(x) (x == EM_AVR32)
++#define ELFCLASSM ELFCLASS32
++#endif
++
+ #if defined(__s390__)
+ #define MATCH_MACHINE(x) (x == EM_S390)
+ #define ELFCLASSM ELFCLASS32
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-conditional-sched_affinity.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-conditional-sched_affinity.patch
new file mode 100644
index 0000000000..509c42af52
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-conditional-sched_affinity.patch
@@ -0,0 +1,53 @@
+diff -ur uClibc-0.9.29/libc/sysdeps/linux/common/sched_getaffinity.c uClibc-0.9.29-patched/libc/sysdeps/linux/common/sched_getaffinity.c
+--- uClibc-0.9.29/libc/sysdeps/linux/common/sched_getaffinity.c 2007-02-12 16:52:32.000000000 -0600
++++ uClibc-0.9.29-patched/libc/sysdeps/linux/common/sched_getaffinity.c 2007-05-09 18:05:09.397411811 -0500
+@@ -29,6 +29,7 @@
+ #include <sys/param.h>
+ #include <sys/types.h>
+
++#ifdef __NR_sched_getaffinity
+ libc_hidden_proto(memset)
+
+ #define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
+@@ -48,5 +49,15 @@
+ }
+ return res;
+ }
++#else
++/*
++int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
++{
++ __set_errno(ENOSYS);
++ return -1;
++}
++*/
+ #endif
+ #endif
++
++#endif
+diff -ur uClibc-0.9.29/libc/sysdeps/linux/common/sched_setaffinity.c uClibc-0.9.29-patched/libc/sysdeps/linux/common/sched_setaffinity.c
+--- uClibc-0.9.29/libc/sysdeps/linux/common/sched_setaffinity.c 2007-02-12 16:52:32.000000000 -0600
++++ uClibc-0.9.29-patched/libc/sysdeps/linux/common/sched_setaffinity.c 2007-05-09 18:05:09.397411811 -0500
+@@ -31,6 +31,7 @@
+ #include <sys/types.h>
+ #include <alloca.h>
+
++#ifdef __NR_sched_setaffinity
+ libc_hidden_proto(getpid)
+
+ #define __NR___syscall_sched_setaffinity __NR_sched_setaffinity
+@@ -74,5 +75,14 @@
+
+ return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
+ }
++#else
++/*
++int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
++{
++ __set_errno(ENOSYS);
++ return -1;
++}
++*/
++#endif
+ #endif
+ #endif
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-filter-gnu99-from-assembly-flags.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-filter-gnu99-from-assembly-flags.patch
new file mode 100644
index 0000000000..d1a7e3ac41
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-filter-gnu99-from-assembly-flags.patch
@@ -0,0 +1,12 @@
+diff -ur uClibc-0.9.29/Makerules uClibc-0.9.29-patched/Makerules
+--- uClibc-0.9.29/Makerules 2006-12-10 18:25:23.000000000 -0600
++++ uClibc-0.9.29-patched/Makerules 2008-01-26 17:04:50.965699518 -0600
+@@ -96,7 +96,7 @@
+ disp_ld = $($(DISP)_disp_ld)
+
+ cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(^D)))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
+-cmd_compile.S = $(cmd_compile.c) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
++cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
+ cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
+ cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
+ cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-fget_putc.diff b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-fget_putc.diff
new file mode 100644
index 0000000000..15d61490b3
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-fget_putc.diff
@@ -0,0 +1,396 @@
+diff -ur uClibc-0.9.29/libc/inet/rpc/rcmd.c uClibc-0.9.29-patched/libc/inet/rpc/rcmd.c
+--- uClibc-0.9.29/libc/inet/rpc/rcmd.c 2007-01-10 11:46:19.000000000 -0600
++++ uClibc-0.9.29-patched/libc/inet/rpc/rcmd.c 2007-05-09 18:05:21.638421151 -0500
+@@ -126,7 +126,7 @@
+ libc_hidden_proto(listen)
+ libc_hidden_proto(sigsetmask)
+ libc_hidden_proto(getc_unlocked)
+-libc_hidden_proto(__fgetc_unlocked)
++//libc_hidden_proto(fgetc_unlocked)
+ libc_hidden_proto(fopen)
+ libc_hidden_proto(fclose)
+ libc_hidden_proto(fprintf)
+diff -ur uClibc-0.9.29/libc/inet/rpc/ruserpass.c uClibc-0.9.29-patched/libc/inet/rpc/ruserpass.c
+--- uClibc-0.9.29/libc/inet/rpc/ruserpass.c 2006-03-23 05:14:16.000000000 -0600
++++ uClibc-0.9.29-patched/libc/inet/rpc/ruserpass.c 2007-05-09 18:05:21.638421151 -0500
+@@ -63,7 +63,7 @@
+ libc_hidden_proto(fopen)
+ libc_hidden_proto(fclose)
+ libc_hidden_proto(getc_unlocked)
+-libc_hidden_proto(__fgetc_unlocked)
++//libc_hidden_proto(__fgetc_unlocked)
+
+ #define _(X) (X)
+ /* #include "ftp_var.h" */
+diff -ur uClibc-0.9.29/libc/misc/error/error.c uClibc-0.9.29-patched/libc/misc/error/error.c
+--- uClibc-0.9.29/libc/misc/error/error.c 2006-05-04 09:44:13.000000000 -0500
++++ uClibc-0.9.29-patched/libc/misc/error/error.c 2007-05-09 18:05:21.646421810 -0500
+@@ -30,11 +30,14 @@
+ libc_hidden_proto(strerror)
+ libc_hidden_proto(fprintf)
+ libc_hidden_proto(exit)
++//#undef putc
+ libc_hidden_proto(putc)
++libc_hidden_proto(fputc)
+ libc_hidden_proto(vfprintf)
+ libc_hidden_proto(fflush)
+-libc_hidden_proto(fputc)
+-libc_hidden_proto(__fputc_unlocked)
++//#ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__
++libc_hidden_proto(fputc_unlocked)
++//#endif
+
+ /* This variable is incremented each time `error' is called. */
+ unsigned int error_message_count = 0;
+diff -ur uClibc-0.9.29/libc/misc/ttyent/getttyent.c uClibc-0.9.29-patched/libc/misc/ttyent/getttyent.c
+--- uClibc-0.9.29/libc/misc/ttyent/getttyent.c 2006-12-07 17:24:02.000000000 -0600
++++ uClibc-0.9.29-patched/libc/misc/ttyent/getttyent.c 2007-05-09 18:05:21.646421810 -0500
+@@ -44,8 +44,10 @@
+ libc_hidden_proto(__fsetlocking)
+ libc_hidden_proto(rewind)
+ libc_hidden_proto(fgets_unlocked)
++//#undef getc_unlocked
+ libc_hidden_proto(getc_unlocked)
+-libc_hidden_proto(__fgetc_unlocked)
++//#undef fgetc_unlocked
++libc_hidden_proto(fgetc_unlocked)
+ libc_hidden_proto(fopen)
+ libc_hidden_proto(fclose)
+ libc_hidden_proto(abort)
+diff -ur uClibc-0.9.29/libc/pwd_grp/pwd_grp.c uClibc-0.9.29-patched/libc/pwd_grp/pwd_grp.c
+--- uClibc-0.9.29/libc/pwd_grp/pwd_grp.c 2007-04-13 03:32:18.000000000 -0500
++++ uClibc-0.9.29-patched/libc/pwd_grp/pwd_grp.c 2007-05-09 18:05:21.638421151 -0500
+@@ -43,11 +43,12 @@
+ libc_hidden_proto(strtoul)
+ libc_hidden_proto(rewind)
+ libc_hidden_proto(fgets_unlocked)
+-libc_hidden_proto(__fputc_unlocked)
+ libc_hidden_proto(sprintf)
+ libc_hidden_proto(fopen)
+ libc_hidden_proto(fclose)
+ libc_hidden_proto(fprintf)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+ #ifdef __UCLIBC_HAS_XLOCALE__
+ libc_hidden_proto(__ctype_b_loc)
+ #elif __UCLIBC_HAS_CTYPE_TABLES__
+@@ -801,7 +802,7 @@
+
+ do {
+ if (!*m) {
+- if (__fputc_unlocked('\n', f) >= 0) {
++ if (fputc_unlocked('\n', f) >= 0) {
+ rv = 0;
+ }
+ break;
+@@ -867,7 +868,7 @@
+ goto DO_UNLOCK;
+ }
+
+- if (__fputc_unlocked('\n', stream) > 0) {
++ if (fputc_unlocked('\n', stream) > 0) {
+ rv = 0;
+ }
+
+diff -ur uClibc-0.9.29/libc/stdio/_scanf.c uClibc-0.9.29-patched/libc/stdio/_scanf.c
+--- uClibc-0.9.29/libc/stdio/_scanf.c 2007-01-20 12:32:10.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/_scanf.c 2007-05-09 18:05:21.642421481 -0500
+@@ -86,7 +86,8 @@
+ libc_hidden_proto(vsscanf)
+ libc_hidden_proto(fclose)
+ libc_hidden_proto(getc_unlocked)
+-libc_hidden_proto(__fgetc_unlocked)
++//#undef fgetc_unlocked
++libc_hidden_proto(fgetc_unlocked)
+ #ifdef __UCLIBC_HAS_WCHAR__
+ libc_hidden_proto(wcslen)
+ libc_hidden_proto(vfwscanf)
+diff -ur uClibc-0.9.29/libc/stdio/fgetc.c uClibc-0.9.29-patched/libc/stdio/fgetc.c
+--- uClibc-0.9.29/libc/stdio/fgetc.c 2006-01-15 16:41:03.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/fgetc.c 2007-05-09 18:05:21.642421481 -0500
+@@ -13,13 +13,13 @@
+ #undef getc
+ #undef getc_unlocked
+
+-libc_hidden_proto(__fgetc_unlocked)
++libc_hidden_proto(fgetc_unlocked)
+
+ #ifdef __DO_UNLOCKED
+
+ libc_hidden_proto(fflush_unlocked)
+
+-int __fgetc_unlocked(FILE *stream)
++int fgetc_unlocked(FILE *stream)
+ {
+ __STDIO_STREAM_VALIDATE(stream);
+
+@@ -73,26 +73,22 @@
+
+ return EOF;
+ }
+-libc_hidden_def(__fgetc_unlocked)
+-
+-libc_hidden_proto(fgetc_unlocked)
+-strong_alias(__fgetc_unlocked,fgetc_unlocked)
+ libc_hidden_def(fgetc_unlocked)
+
+ //libc_hidden_proto(__getc_unlocked)
+-//strong_alias(__fgetc_unlocked,__getc_unlocked)
++//strong_alias(fgetc_unlocked,__getc_unlocked)
+ //libc_hidden_def(__getc_unlocked)
+
+ libc_hidden_proto(getc_unlocked)
+-strong_alias(__fgetc_unlocked,getc_unlocked)
++strong_alias(fgetc_unlocked,getc_unlocked)
+ libc_hidden_def(getc_unlocked)
+
+ #ifndef __UCLIBC_HAS_THREADS__
+ libc_hidden_proto(fgetc)
+-strong_alias(__fgetc_unlocked,fgetc)
++strong_alias(fgetc_unlocked,fgetc)
+ libc_hidden_def(fgetc)
+
+-strong_alias(__fgetc_unlocked,getc)
++strong_alias(fgetc_unlocked,getc)
+ #endif
+
+ #elif defined __UCLIBC_HAS_THREADS__
+diff -ur uClibc-0.9.29/libc/stdio/fgets.c uClibc-0.9.29-patched/libc/stdio/fgets.c
+--- uClibc-0.9.29/libc/stdio/fgets.c 2006-01-15 16:41:03.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/fgets.c 2007-05-09 18:05:21.638421151 -0500
+@@ -10,8 +10,7 @@
+ libc_hidden_proto(fgets_unlocked)
+
+ #ifdef __DO_UNLOCKED
+-
+-libc_hidden_proto(__fgetc_unlocked)
++libc_hidden_proto(fgetc_unlocked)
+
+ char *fgets_unlocked(char *__restrict s, int n,
+ register FILE * __restrict stream)
+@@ -38,7 +37,7 @@
+ break;
+ }
+ } else {
+- if ((c = __fgetc_unlocked(stream)) == EOF) {
++ if ((c = fgetc_unlocked(stream)) == EOF) {
+ if (__FERROR_UNLOCKED(stream)) {
+ goto ERROR;
+ }
+diff -ur uClibc-0.9.29/libc/stdio/fputc.c uClibc-0.9.29-patched/libc/stdio/fputc.c
+--- uClibc-0.9.29/libc/stdio/fputc.c 2007-04-14 12:03:18.000000000 -0500
++++ uClibc-0.9.29-patched/libc/stdio/fputc.c 2007-05-09 20:50:51.350629927 -0500
+@@ -16,7 +16,7 @@
+
+ #ifdef __DO_UNLOCKED
+
+-int __fputc_unlocked(int c, register FILE *stream)
++int fputc_unlocked(int c, register FILE *stream)
+ {
+ __STDIO_STREAM_VALIDATE(stream);
+
+@@ -70,22 +70,22 @@
+ BAD:
+ return EOF;
+ }
+-libc_hidden_def(__fputc_unlocked)
++libc_hidden_def(fputc_unlocked)
+
+ /* exposing these would be fundamentally *wrong*! fix you, instead! */
+ /* libc_hidden_proto(fputc_unlocked) */
+-strong_alias(__fputc_unlocked,fputc_unlocked)
++/* strong_alias(__fputc_unlocked,fputc_unlocked) */
+ /* exposing these would be fundamentally *wrong*! fix you, instead! */
+ /* libc_hidden_def(fputc_unlocked) */
+
+ libc_hidden_proto(putc_unlocked)
+-strong_alias(__fputc_unlocked,putc_unlocked)
++strong_alias(fputc_unlocked,putc_unlocked)
+ libc_hidden_def(putc_unlocked)
+ #ifndef __UCLIBC_HAS_THREADS__
+-strong_alias(__fputc_unlocked,fputc)
++strong_alias(fputc_unlocked,fputc)
+
+ libc_hidden_proto(putc)
+-strong_alias(__fputc_unlocked,putc)
++strong_alias(fputc_unlocked,putc)
+ libc_hidden_def(putc)
+ #endif
+
+diff -ur uClibc-0.9.29/libc/stdio/getchar.c uClibc-0.9.29-patched/libc/stdio/getchar.c
+--- uClibc-0.9.29/libc/stdio/getchar.c 2006-12-19 22:30:25.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/getchar.c 2007-05-09 18:05:21.642421481 -0500
+@@ -7,7 +7,8 @@
+
+ #include "_stdio.h"
+
+-libc_hidden_proto(__fgetc_unlocked)
++//#undef fgetc_unlocked
++libc_hidden_proto(fgetc_unlocked)
+
+ #undef getchar
+ #ifdef __DO_UNLOCKED
+diff -ur uClibc-0.9.29/libc/stdio/getdelim.c uClibc-0.9.29-patched/libc/stdio/getdelim.c
+--- uClibc-0.9.29/libc/stdio/getdelim.c 2006-02-13 02:52:46.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/getdelim.c 2007-05-09 18:05:21.642421481 -0500
+@@ -11,8 +11,8 @@
+ #include "_stdio.h"
+
+ libc_hidden_proto(getdelim)
+-
+-libc_hidden_proto(__fgetc_unlocked)
++//#undef fgetc_unlocked
++libc_hidden_proto(fgetc_unlocked)
+
+ /* Note: There is a defect in this function. (size_t vs ssize_t). */
+
+diff -ur uClibc-0.9.29/libc/stdio/old_vfprintf.c uClibc-0.9.29-patched/libc/stdio/old_vfprintf.c
+--- uClibc-0.9.29/libc/stdio/old_vfprintf.c 2006-01-22 13:35:08.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/old_vfprintf.c 2007-05-09 18:05:21.642421481 -0500
+@@ -149,7 +149,8 @@
+ libc_hidden_proto(strnlen)
+ libc_hidden_proto(memcpy)
+ libc_hidden_proto(putc_unlocked)
+-libc_hidden_proto(__fputc_unlocked)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+ libc_hidden_proto(__glibc_strerror_r)
+
+ /* #undef __UCLIBC_HAS_FLOATS__ */
+diff -ur uClibc-0.9.29/libc/stdio/putchar.c uClibc-0.9.29-patched/libc/stdio/putchar.c
+--- uClibc-0.9.29/libc/stdio/putchar.c 2006-01-13 18:58:03.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/putchar.c 2007-05-09 18:05:21.642421481 -0500
+@@ -7,7 +7,8 @@
+
+ #include "_stdio.h"
+
+-libc_hidden_proto(__fputc_unlocked)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+
+ #undef putchar
+ #ifdef __DO_UNLOCKED
+diff -ur uClibc-0.9.29/libc/stdio/puts.c uClibc-0.9.29-patched/libc/stdio/puts.c
+--- uClibc-0.9.29/libc/stdio/puts.c 2006-01-13 18:58:03.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/puts.c 2007-05-09 18:05:21.642421481 -0500
+@@ -7,7 +7,8 @@
+
+ #include "_stdio.h"
+
+-libc_hidden_proto(__fputc_unlocked)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+ libc_hidden_proto(fputs_unlocked)
+
+ int puts(register const char * __restrict s)
+@@ -25,7 +26,7 @@
+ /* Note: Nonportable as fputs need only return nonnegative on success. */
+ if ((n = fputs_unlocked(s, stream)) != EOF) {
+ ++n;
+- if (__fputc_unlocked('\n', stream) == EOF) {
++ if (fputc_unlocked('\n', stream) == EOF) {
+ n = EOF;
+ }
+ }
+diff -ur uClibc-0.9.29/libc/stdio/putwchar.c uClibc-0.9.29-patched/libc/stdio/putwchar.c
+--- uClibc-0.9.29/libc/stdio/putwchar.c 2006-01-14 14:16:19.000000000 -0600
++++ uClibc-0.9.29-patched/libc/stdio/putwchar.c 2007-05-09 18:05:21.642421481 -0500
+@@ -22,7 +22,8 @@
+
+ #elif defined __UCLIBC_HAS_THREADS__
+
+-libc_hidden_proto(__fputc_unlocked)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+ /* psm: should this be fputwc? */
+ libc_hidden_proto(fputc)
+
+diff -ur uClibc-0.9.29/libc/sysdeps/linux/common/bits/uClibc_stdio.h uClibc-0.9.29-patched/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+--- uClibc-0.9.29/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2007-01-28 07:16:58.000000000 -0600
++++ uClibc-0.9.29-patched/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2007-05-09 20:56:02.408110608 -0500
+@@ -381,33 +381,29 @@
+ # define __FEOF(__stream) __FEOF_UNLOCKED(__stream)
+ #endif
+
+-extern int __fgetc_unlocked(FILE *__stream);
+-extern int __fputc_unlocked(int __c, FILE *__stream);
+-
+ /* First define the default definitions.
+ They are overridden below as necessary. */
+-#define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
++#define __FGETC_UNLOCKED(__stream) (fgetc_unlocked)((__stream))
+ #define __FGETC(__stream) (fgetc)((__stream))
+-#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream))
+-#define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
++#define __GETC_UNLOCKED_MACRO(__stream) (fgetc_unlocked)((__stream))
++#define __GETC_UNLOCKED(__stream) (fgetc_unlocked)((__stream))
+ #define __GETC(__stream) (fgetc)((__stream))
+
+-#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
++#define __FPUTC_UNLOCKED(__c, __stream) (fputc_unlocked)((__c),(__stream))
+ #define __FPUTC(__c, __stream) (fputc)((__c),(__stream))
+-#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream))
+-#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
++#define __PUTC_UNLOCKED_MACRO(__c, __stream) (fputc_unlocked)((__c),(__stream))
++#define __PUTC_UNLOCKED(__c, __stream) (fputc_unlocked)((__c),(__stream))
+ #define __PUTC(__c, __stream) (fputc)((__c),(__stream))
+
+
+ #ifdef __STDIO_GETC_MACRO
+-
+ extern FILE *__stdin; /* For getchar() macro. */
+
+ # undef __GETC_UNLOCKED_MACRO
+ # define __GETC_UNLOCKED_MACRO(__stream) \
+ ( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \
+ ? (*(__stream)->__bufpos++) \
+- : __fgetc_unlocked(__stream) )
++ : fgetc_unlocked(__stream) )
+
+ # if 0
+ /* Classic macro approach. getc{_unlocked} can have side effects. */
+@@ -453,20 +449,17 @@
+ # endif
+ # endif
+
+-#else
+-
+ #endif /* __STDIO_GETC_MACRO */
+
+
+ #ifdef __STDIO_PUTC_MACRO
+-
+ extern FILE *__stdout; /* For putchar() macro. */
+
+ # undef __PUTC_UNLOCKED_MACRO
+ # define __PUTC_UNLOCKED_MACRO(__c, __stream) \
+ ( ((__stream)->__bufpos < (__stream)->__bufputc_u) \
+ ? (*(__stream)->__bufpos++) = (__c) \
+- : __fputc_unlocked((__c),(__stream)) )
++ : (fputc_unlocked((__c),(__stream)) )
+
+ # if 0
+ /* Classic macro approach. putc{_unlocked} can have side effects.*/
+@@ -489,7 +482,8 @@
+ }) )
+
+ # undef __PUTC_UNLOCKED
+-# define __PUTC_UNLOCKED(__c, __stream) __FPUTC_UNLOCKED((__c), (__stream))
++# define __PUTC_UNLOCKED(__c, __stream) \
++ __FPUTC_UNLOCKED((__c), (__stream))
+
+ # ifdef __UCLIBC_HAS_THREADS__
+ # undef __FPUTC
+diff -ur uClibc-0.9.29/libc/unistd/getpass.c uClibc-0.9.29-patched/libc/unistd/getpass.c
+--- uClibc-0.9.29/libc/unistd/getpass.c 2006-07-05 05:58:38.000000000 -0500
++++ uClibc-0.9.29-patched/libc/unistd/getpass.c 2007-05-09 18:05:21.642421481 -0500
+@@ -36,7 +36,8 @@
+ libc_hidden_proto(fputs)
+ libc_hidden_proto(fputc)
+ libc_hidden_proto(putc)
+-libc_hidden_proto(__fputc_unlocked)
++//#undef fputc_unlocked
++libc_hidden_proto(fputc_unlocked)
+
+ /* It is desirable to use this bit on systems that have it.
+ The only bit of terminal state we want to twiddle is echoing, which is
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-gethostent_r-failure-retval.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-gethostent_r-failure-retval.patch
new file mode 100644
index 0000000000..7b246c1ad7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-gethostent_r-failure-retval.patch
@@ -0,0 +1,12 @@
+diff -ur uClibc-0.9.29/libc/inet/resolv.c uClibc-0.9.29-patched/libc/inet/resolv.c
+--- uClibc-0.9.29/libc/inet/resolv.c 2007-04-23 12:01:05.000000000 -0500
++++ uClibc-0.9.29-patched/libc/inet/resolv.c 2007-05-09 18:05:33.563404419 -0500
+@@ -1700,7 +1700,7 @@
+ int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
+ struct hostent **result, int *h_errnop)
+ {
+- int ret;
++ int ret = HOST_NOT_FOUND;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (__gethostent_fp == NULL) {
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-internal_function-definition.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-internal_function-definition.patch
new file mode 100644
index 0000000000..9b88d826f1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-internal_function-definition.patch
@@ -0,0 +1,51 @@
+Index: uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
+===================================================================
+--- uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h (revision 18898)
++++ uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h (working copy)
+@@ -42,6 +42,8 @@
+ /* define if target supports IEEE signed zero floats */
+ #define __UCLIBC_HAVE_SIGNED_ZERO__
+
++#if defined _LIBC
+ #define internal_function __attribute__ ((regparm (3), stdcall))
++#endif
+
+ #endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
+Index: uClibc/include/libc-symbols.h
+===================================================================
+--- uClibc/include/libc-symbols.h (revision 18898)
++++ uClibc/include/libc-symbols.h (working copy)
+@@ -22,6 +22,16 @@
+ #ifndef _LIBC_SYMBOLS_H
+ #define _LIBC_SYMBOLS_H 1
+
++/* This is defined for the compilation of all C library code. features.h
++ tests this to avoid inclusion of stubs.h while compiling the library,
++ before stubs.h has been generated. Some library code that is shared
++ with other packages also tests this symbol to see if it is being
++ compiled as part of the C library. We must define this before including
++ config.h, because it makes some definitions conditional on whether libc
++ itself is being compiled, or just some generator program. */
++#define _LIBC 1
++
++
+ /* This file's macros are included implicitly in the compilation of every
+ file in the C library by -imacros.
+
+@@ -40,16 +50,6 @@
+
+ #include <bits/uClibc_arch_features.h>
+
+-
+-/* This is defined for the compilation of all C library code. features.h
+- tests this to avoid inclusion of stubs.h while compiling the library,
+- before stubs.h has been generated. Some library code that is shared
+- with other packages also tests this symbol to see if it is being
+- compiled as part of the C library. We must define this before including
+- config.h, because it makes some definitions conditional on whether libc
+- itself is being compiled, or just some generator program. */
+-#define _LIBC 1
+-
+ /* Enable declarations of GNU extensions, since we are compiling them. */
+ #define _GNU_SOURCE 1
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-sa_onstack.patch.avr32 b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-sa_onstack.patch.avr32
new file mode 100644
index 0000000000..722decdbd7
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-fix-sa_onstack.patch.avr32
@@ -0,0 +1,31 @@
+From 974a769cc135bcfb1ea751db34a84ed6b5ceb509 Mon Sep 17 00:00:00 2001
+From: Haavard Skinnemoen <hskinnemoen@atmel.com>
+Date: Fri, 7 Dec 2007 14:02:19 +0100
+Subject: [PATCH] AVR32: Fix sa_restorer when SA_ONSTACK is set
+
+I don't remember exactly why we decided to pick the caller's value of
+sa_restorer when SA_ONSTACK is set, but it seems to break LTP's
+sigaltstack testcase. Some users have reported problems with
+sigaltstack as well; hopefully this will fix it.
+
+Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
+---
+ libc/sysdeps/linux/avr32/sigaction.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c
+index a97ff3d..6dcca91 100644
+--- a/libc/sysdeps/linux/avr32/sigaction.c
++++ b/libc/sysdeps/linux/avr32/sigaction.c
+@@ -30,7 +30,7 @@ int __libc_sigaction(int signum, const struct sigaction *act,
+ kact.k_sa_handler = act->sa_handler;
+ memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
+ kact.sa_flags = act->sa_flags;
+- if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
++ if (kact.sa_flags & SA_RESTORER)
+ kact.sa_restorer = act->sa_restorer;
+ else
+ kact.sa_restorer = __default_rt_sa_restorer;
+--
+1.5.3.4
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-linuxthreads.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-linuxthreads.patch
new file mode 100644
index 0000000000..8ce2439b46
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-linuxthreads.patch
@@ -0,0 +1,145 @@
+--- a/libpthread/linuxthreads.old/attr.c 2006-01-24 12:41:01.000000000 -0500
++++ b/libpthread/linuxthreads.old/attr.c 2008-02-10 11:35:32.000000000 -0500
+@@ -25,6 +25,14 @@
+ #include "pthread.h"
+ #include "internals.h"
+
++#include <sys/resource.h>
++#include <inttypes.h>
++#include <stdio.h>
++#include <stdio_ext.h>
++#include <stdlib.h>
++#include <sys/resource.h>
++
++
+ /* NOTE: With uClibc I don't think we need this versioning stuff.
+ * Therefore, define the function pthread_attr_init() here using
+ * a strong symbol. */
+@@ -209,4 +217,94 @@ int __pthread_attr_getstacksize(const pt
+ *stacksize = attr->__stacksize;
+ return 0;
+ }
++
++
++extern int *__libc_stack_end;
++
+ weak_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
++void* pthread_getattr_np(pthread_t thread, pthread_attr_t *attr)
++{
++ static void *stackBase = 0;
++ static size_t stackSize = 0;
++ int ret = 0;
++ /* Stack size limit. */
++ struct rlimit rl;
++
++ /* The safest way to get the top of the stack is to read
++ /proc/self/maps and locate the line into which
++ __libc_stack_end falls. */
++ FILE *fp = fopen("/proc/self/maps", "rc");
++ if (fp == NULL)
++ ret = errno;
++ /* We need the limit of the stack in any case. */
++ else if (getrlimit (RLIMIT_STACK, &rl) != 0)
++ ret = errno;
++ else {
++ /* We need no locking. */
++ __fsetlocking (fp, FSETLOCKING_BYCALLER);
++
++ /* Until we found an entry (which should always be the case)
++ mark the result as a failure. */
++ ret = ENOENT;
++
++ char *line = NULL;
++ size_t linelen = 0;
++ uintptr_t last_to = 0;
++
++ while (! feof_unlocked (fp)) {
++ if (getdelim (&line, &linelen, '\n', fp) <= 0)
++ break;
++
++ uintptr_t from;
++ uintptr_t to;
++ if (sscanf (line, "%x-%x", &from, &to) != 2)
++ continue;
++ if (from <= (uintptr_t) __libc_stack_end
++ && (uintptr_t) __libc_stack_end < to) {
++ /* Found the entry. Now we have the info we need. */
++ attr->__stacksize = rl.rlim_cur;
++#ifdef _STACK_GROWS_UP
++ /* Don't check to enforce a limit on the __stacksize */
++ attr->__stackaddr = (void *) from;
++#else
++ attr->__stackaddr = (void *) to;
++
++ /* The limit might be too high. */
++ if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr - last_to)
++ attr->__stacksize = (size_t) attr->__stackaddr - last_to;
++#endif
++
++ /* We succeed and no need to look further. */
++ ret = 0;
++ break;
++ }
++ last_to = to;
++ }
++
++ fclose (fp);
++ free (line);
++ }
++#ifndef _STACK_GROWS_UP
++ stackBase = (char *) attr->__stackaddr - attr->__stacksize;
++#else
++ stackBase = attr->__stackaddr;
++#endif
++ stackSize = attr->__stacksize;
++ return (void*)(stackBase + stackSize);
++}
++
++int __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr,
++ size_t *stacksize)
++{
++ /* XXX This function has a stupid definition. The standard specifies
++ no error value but what is if no stack address was set? We simply
++ return the value we have in the member. */
++#ifndef _STACK_GROWS_UP
++ *stackaddr = (char *) attr->__stackaddr - attr->__stacksize;
++#else
++ *stackaddr = attr->__stackaddr;
++#endif
++ *stacksize = attr->__stacksize;
++ return 0;
++}
++weak_alias (__pthread_attr_getstack, pthread_attr_getstack)
+
+--- a/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h 2006-12-07 22:19:36.000000000 -0500
++++ b/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h 2008-02-10 11:42:35.000000000 -0500
+@@ -288,15 +288,11 @@ extern int pthread_attr_getstacksize (__
+ __attr, size_t *__restrict __stacksize)
+ __THROW;
+
+-#if 0
+-/* Not yet implemented in uClibc! */
+-
+ #ifdef __USE_GNU
+ /* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread TH. It shall be called on unitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+-extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
+-#endif
++extern void* pthread_getattr_np(pthread_t thread, pthread_attr_t *attr);
+ #endif
+
+ /* Functions for scheduling control. */
+@@ -599,6 +595,11 @@ extern int pthread_cancel (pthread_t __c
+ cancelled. */
+ extern void pthread_testcancel (void);
+
++/* Return the previously set address for the stack. */
++extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
++ void **__restrict __stackaddr,
++ size_t *__restrict __stacksize) __THROW;
++
+
+ /* Install a cleanup handler: ROUTINE will be called with arguments ARG
+ when the thread is cancelled or calls pthread_exit. ROUTINE will also
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-rm-whitespace.patch b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-rm-whitespace.patch
new file mode 100644
index 0000000000..6004f91e32
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-rm-whitespace.patch
@@ -0,0 +1,86 @@
+diff -urN uClibc-0.9.29-0rig/include/assert.h uClibc-0.9.29/include/assert.h
+--- uClibc-0.9.29-0rig/include/assert.h 2005-11-03 23:42:46.000000000 +0100
++++ uClibc-0.9.29/include/assert.h 2007-08-13 19:10:57.000000000 +0200
+@@ -31,7 +31,7 @@
+ #define _ASSERT_H 1
+ #include <features.h>
+
+-#if defined __cplusplus && __GNUC_PREREQ (2,95)
++#if defined __cplusplus && __GNUC_PREREQ(2,95)
+ # define __ASSERT_VOID_CAST static_cast<void>
+ #else
+ # define __ASSERT_VOID_CAST (void)
+@@ -59,13 +59,17 @@
+ (__ASSERT_VOID_CAST ((expr) ? 0 : \
+ (__assert (__STRING(expr), __FILE__, __LINE__, \
+ __ASSERT_FUNCTION), 0)))
+-
++
++/* Define some temporaries to workaround tinyx makedepend bug */
++#define __GNUC_PREREQ_2_6 __GNUC_PREREQ(2, 6)
++#define __GNUC_PREREQ_2_4 __GNUC_PREREQ(2, 4)
+ /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
+ which contains the name of the function currently being defined.
+ This is broken in G++ before version 2.6.
+ C9x has a similar variable called __func__, but prefer the GCC one since
+ it demangles C++ function names. */
+-# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
++
++# if defined __cplusplus ? __GNUC_PREREQ_2_6 : __GNUC_PREREQ_2_4
+ # define __ASSERT_FUNCTION __PRETTY_FUNCTION__
+ # else
+ # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+diff -urN uClibc-0.9.29-0rig/include/complex.h uClibc-0.9.29/include/complex.h
+--- uClibc-0.9.29-0rig/include/complex.h 2002-05-09 10:15:21.000000000 +0200
++++ uClibc-0.9.29/include/complex.h 2007-08-13 17:55:29.000000000 +0200
+@@ -33,7 +33,7 @@
+ /* We might need to add support for more compilers here. But since ISO
+ C99 is out hopefully all maintained compilers will soon provide the data
+ types `float complex' and `double complex'. */
+-#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
++#if __GNUC_PREREQ(2, 7) && !__GNUC_PREREQ(2, 97)
+ # define _Complex __complex__
+ #endif
+
+diff -urN uClibc-0.9.29-0rig/include/features.h uClibc-0.9.29/include/features.h
+--- uClibc-0.9.29-0rig/include/features.h 2006-11-29 22:10:04.000000000 +0100
++++ uClibc-0.9.29/include/features.h 2007-08-13 17:55:51.000000000 +0200
+@@ -143,7 +143,7 @@
+
+ /* Convenience macros to test the versions of glibc and gcc.
+ Use them like this:
+- #if __GNUC_PREREQ (2,8)
++ #if __GNUC_PREREQ(2,8)
+ ... code requiring gcc 2.8 or later ...
+ #endif
+ Note - they won't work for gcc1 or glibc1, since the _MINOR macros
+@@ -297,7 +297,7 @@
+ /* uClibc does not support _FORTIFY_SOURCE */
+ #undef _FORTIFY_SOURCE
+ #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
+- && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
++ && __GNUC_PREREQ(4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
+ # if _FORTIFY_SOURCE > 1
+ # define __USE_FORTIFY_LEVEL 2
+ # else
+@@ -366,7 +366,7 @@
+ #endif /* !ASSEMBLER */
+
+ /* Decide whether we can define 'extern inline' functions in headers. */
+-#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
++#if __GNUC_PREREQ(2, 7) && defined __OPTIMIZE__ \
+ && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
+ # define __USE_EXTERN_INLINES 1
+ #endif
+diff -urN uClibc-0.9.29-0rig/include/tgmath.h uClibc-0.9.29/include/tgmath.h
+--- uClibc-0.9.29-0rig/include/tgmath.h 2002-05-09 10:15:21.000000000 +0200
++++ uClibc-0.9.29/include/tgmath.h 2007-08-13 17:56:17.000000000 +0200
+@@ -34,7 +34,7 @@
+ do not try this for now and instead concentrate only on GNU CC. Once
+ we have more information support for other compilers might follow. */
+
+-#if __GNUC_PREREQ (2, 7)
++#if __GNUC_PREREQ(2, 7)
+
+ # ifdef __NO_LONG_DOUBLE_MATH
+ # define __tgml(fct) fct
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-wchar.config b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-wchar.config
new file mode 100644
index 0000000000..b15fc6fff1
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29-wchar.config
@@ -0,0 +1,215 @@
+#
+# Automatically generated make config: don't edit
+# Tue Jul 17 02:34:41 2007
+#
+# TARGET_alpha is not set
+TARGET_arm=y
+# TARGET_bfin is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_vax is not set
+# TARGET_x86_64 is not set
+
+#
+# Target Architecture Features and Options
+#
+TARGET_ARCH="arm"
+FORCE_OPTIONS_FOR_ARCH=y
+CONFIG_ARM_OABI=y
+# CONFIG_ARM_EABI is not set
+CONFIG_GENERIC_ARM=y
+# CONFIG_ARM610 is not set
+# CONFIG_ARM710 is not set
+# CONFIG_ARM7TDMI is not set
+# CONFIG_ARM720T is not set
+# CONFIG_ARM920T is not set
+# CONFIG_ARM922T is not set
+# CONFIG_ARM926T is not set
+# CONFIG_ARM10T is not set
+# CONFIG_ARM1136JF_S is not set
+# CONFIG_ARM1176JZ_S is not set
+# CONFIG_ARM1176JZF_S is not set
+# CONFIG_ARM_SA110 is not set
+# CONFIG_ARM_SA1100 is not set
+# CONFIG_ARM_XSCALE is not set
+# CONFIG_ARM_IWMMXT is not set
+TARGET_SUBARCH=""
+
+#
+# Using ELF file format
+#
+ARCH_ANY_ENDIAN=y
+ARCH_LITTLE_ENDIAN=y
+# ARCH_WANTS_BIG_ENDIAN is not set
+ARCH_WANTS_LITTLE_ENDIAN=y
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+KERNEL_HEADERS="/home/ulf/projects/Buildroot/20070712/buildroot/toolchain_build_arm/linux/include"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+# HAVE_NO_PIC is not set
+DOPIC=y
+# HAVE_NO_SHARED is not set
+# ARCH_HAS_NO_LDSO is not set
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# UCLIBC_STATIC_LDCONFIG is not set
+# LDSO_RUNPATH is not set
+UCLIBC_CTOR_DTOR=y
+# HAS_NO_THREADS is not set
+UCLIBC_HAS_THREADS=y
+# PTHREADS_DEBUG_SUPPORT is not set
+LINUXTHREADS_OLD=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_DYNAMIC_ATEXIT=y
+# COMPAT_ATEXIT is not set
+# UCLIBC_SUSV3_LEGACY is not set
+# UCLIBC_SUSV3_LEGACY_MACROS is not set
+UCLIBC_HAS_SHADOW=y
+# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set
+UCLIBC_HAS___PROGNAME=y
+# UNIX98PTY_ONLY is not set
+ASSUME_DEVPTS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Networking Support
+#
+# UCLIBC_HAS_IPV6 is not set
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+UCLIBC_USE_NETLINK=y
+# UCLIBC_HAS_BSD_RES_CLOSE is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_WCHAR=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_PREGENERATED_LOCALE_DATA=y
+UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=y
+# UCLIBC_HAS_XLOCALE is not set
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+# UCLIBC_HAS_GLIBC_DIGIT_GROUPING is not set
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_WORDEXP is not set
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_GLOB=y
+
+#
+# Library Installation Options
+#
+SHARED_LIB_LOADER_PREFIX="/lib"
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr/"
+
+#
+# Security options
+#
+# UCLIBC_BUILD_PIE is not set
+# UCLIBC_HAS_ARC4RANDOM is not set
+# HAVE_NO_SSP is not set
+# UCLIBC_HAS_SSP is not set
+UCLIBC_BUILD_RELRO=y
+UCLIBC_BUILD_NOW=y
+# UCLIBC_BUILD_NOEXECSTACK is not set
+
+#
+# uClibc development/debugging options
+#
+CROSS_COMPILER_PREFIX="/usr/local/arm/gcc-4.2.0-uclibc-20070714/usr/bin/arm-linux-uclibc-"
+UCLIBC_EXTRA_CFLAGS=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+DOSTRIP=y
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
+WARNINGS="-Wall"
+# EXTRA_WARNINGS is not set
+# DOMULTI is not set
+# UCLIBC_MJN3_ONLY is not set
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29.config b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29.config
new file mode 100644
index 0000000000..468233a765
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-0.9.29.config
@@ -0,0 +1,219 @@
+#
+# Automatically generated make config: don't edit
+#
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_vax is not set
+# TARGET_x86_64 is not set
+
+#
+# Target Architecture Features and Options
+#
+TARGET_ARCH="none"
+FORCE_OPTIONS_FOR_ARCH=y
+# ARCH_LITTLE_ENDIAN is not set
+# ARCH_BIG_ENDIAN is not set
+# ARCH_WANTS_LITTLE_ENDIAN is not set
+# ARCH_WANTS_BIG_ENDIAN is not set
+
+#
+# Using Little Endian
+#
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+KERNEL_SOURCE="/usr/src/linux"
+KERNEL_HEADERS="/usr/src/linux/include"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+# HAVE_NO_PIC is not set
+DOPIC=y
+# LINKRELAX is not set
+# HAVE_NO_SHARED is not set
+# ARCH_HAS_NO_LDSO is not set
+BUILD_UCLIBC_LDSO=y
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# UCLIBC_STATIC_LDCONFIG is not set
+# LDSO_RUNPATH is not set
+# DL_FINI_CRT_COMPAT is not set
+UCLIBC_CTOR_DTOR=y
+# HAS_NO_THREADS is not set
+UCLIBC_HAS_THREADS=y
+# PTHREADS_DEBUG_SUPPORT is not set
+LINUXTHREADS_OLD=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_DYNAMIC_ATEXIT=y
+# COMPAT_ATEXIT is not set
+HAS_SHADOW=y
+# UCLIBC_SUSV3_LEGACY is not set
+# UCLIBC_SUSV3_LEGACY_MACROS is not set
+UCLIBC_HAS_SHADOW=y
+# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set
+UCLIBC_HAS___PROGNAME=y
+# UNIX98PTY_ONLY is not set
+ASSUME_DEVPTS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Networking Support
+#
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+# UCLIBC_USE_NETLINK is not set
+# UCLIBC_HAS_BSD_RES_CLOSE is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+# UCLIBC_HAS_WCHAR is not set
+# UCLIBC_HAS_LOCALE is not set
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+# USE_OLD_VFPRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+# UCLIBC_HAS_GETTEXT_AWARENESS is not set
+UCLIBC_HAS_GNU_GETSUBOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_WORDEXP is not set
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_GLOB=y
+
+#
+# Library Installation Options
+#
+SHARED_LIB_LOADER_PREFIX="/lib"
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr/"
+
+#
+# uClibc security related options
+#
+# UCLIBC_SECURITY is not set
+# UCLIBC_BUILD_PIE is not set
+# UCLIBC_HAS_ARC4RANDOM is not set
+# HAVE_NO_SSP is not set
+# UCLIBC_HAS_SSP is not set
+UCLIBC_BUILD_RELRO=y
+UCLIBC_BUILD_NOW=y
+# UCLIBC_BUILD_NOEXECSTACK is not set
+
+#
+# uClibc development/debugging options
+#
+CROSS_COMPILER_PREFIX=""
+UCLIBC_EXTRA_CFLAGS=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+DOSTRIP=y
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
+WARNINGS="-Wall"
+# EXTRA_WARNINGS is not set
+# DOMULTI is not set
+# UCLIBC_MJN3_ONLY is not set
+
+# USE_BX is not set
+# CONFIG_GENERIC_ARM is not set
+# CONFIG_ARM610 is not set
+# CONFIG_ARM710 is not set
+# CONFIG_ARM7TDMI is not set
+# CONFIG_ARM720T is not set
+# CONFIG_ARM920T is not set
+# CONFIG_ARM922T is not set
+# CONFIG_ARM926T is not set
+# CONFIG_ARM10T is not set
+# CONFIG_ARM1136JF_S is not set
+# CONFIG_ARM1176JZ_S is not set
+# CONFIG_ARM1176JZF_S is not set
+# CONFIG_ARM_SA110 is not set
+# CONFIG_ARM_SA1100 is not set
+# CONFIG_ARM_XSCALE is not set
+# CONFIG_ARM_IWMMXT is not set
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uClibc-snapshot.config b/cleopatre/buildroot/toolchain/uClibc/uClibc-snapshot.config
new file mode 100644
index 0000000000..cf253f5433
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uClibc-snapshot.config
@@ -0,0 +1,201 @@
+#
+# Automatically generated make config: don't edit
+#
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_vax is not set
+# TARGET_x86_64 is not set
+# TARGET_xtensa is not set
+TARGET_SUBARCH=""
+
+#
+# Target Architecture Features and Options
+#
+TARGET_ARCH="none"
+FORCE_OPTIONS_FOR_ARCH=y
+
+#
+# Using ELF file format
+#
+# ARCH_LITTLE_ENDIAN is not set
+# ARCH_BIG_ENDIAN is not set
+# ARCH_WANTS_LITTLE_ENDIAN is not set
+# ARCH_WANTS_BIG_ENDIAN is not set
+
+#
+# Using Little Endian
+#
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+# UCLIBC_HAS_FENV is not set
+KERNEL_HEADERS="/usr/src/linux/include"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+# HAVE_NO_PIC is not set
+DOPIC=y
+# HAVE_NO_SHARED is not set
+# ARCH_HAS_NO_LDSO is not set
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# UCLIBC_STATIC_LDCONFIG is not set
+# LDSO_RUNPATH is not set
+UCLIBC_CTOR_DTOR=y
+# LDSO_GNU_HASH_SUPPORT is not set
+# HAS_NO_THREADS is not set
+UCLIBC_HAS_THREADS=y
+# PTHREADS_DEBUG_SUPPORT is not set
+LINUXTHREADS_OLD=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_DYNAMIC_ATEXIT=y
+# COMPAT_ATEXIT is not set
+# UCLIBC_SUSV3_LEGACY is not set
+# UCLIBC_SUSV3_LEGACY_MACROS is not set
+UCLIBC_HAS_SHADOW=y
+# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set
+# UNIX98PTY_ONLY is not set
+ASSUME_DEVPTS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Networking Support
+#
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+# UCLIBC_USE_NETLINK is not set
+# UCLIBC_HAS_BSD_RES_CLOSE is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+# UCLIBC_HAS_WCHAR is not set
+# UCLIBC_HAS_LOCALE is not set
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+# USE_OLD_VFPRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_WORDEXP is not set
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_GLOB=y
+
+#
+# Library Installation Options
+#
+SHARED_LIB_LOADER_PREFIX="/lib"
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr/"
+
+#
+# Security options
+#
+# UCLIBC_BUILD_PIE is not set
+# UCLIBC_HAS_ARC4RANDOM is not set
+# HAVE_NO_SSP is not set
+# UCLIBC_HAS_SSP is not set
+UCLIBC_BUILD_RELRO=y
+UCLIBC_BUILD_NOW=y
+# UCLIBC_BUILD_NOEXECSTACK is not set
+
+#
+# uClibc development/debugging options
+#
+CROSS_COMPILER_PREFIX=""
+UCLIBC_EXTRA_CFLAGS=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+DOSTRIP=y
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
+WARNINGS="-Wall"
+# EXTRA_WARNINGS is not set
+# DOMULTI is not set
+# UCLIBC_MJN3_ONLY is not set
+
diff --git a/cleopatre/buildroot/toolchain/uClibc/uclibc.mk b/cleopatre/buildroot/toolchain/uClibc/uclibc.mk
new file mode 100644
index 0000000000..4e8a7e3e60
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/uClibc/uclibc.mk
@@ -0,0 +1,625 @@
+#############################################################
+#
+# uClibc (the C library)
+#
+#############################################################
+
+ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
+
+# specifying UCLIBC_CONFIG_FILE on the command-line overrides the .config
+# setting.
+ifndef UCLIBC_CONFIG_FILE
+UCLIBC_CONFIG_FILE=$(subst ",, $(strip $(BR2_UCLIBC_CONFIG)))
+#")
+endif
+
+ifeq ($(BR2_UCLIBC_VERSION_SNAPSHOT),y)
+# Be aware that this changes daily....
+UCLIBC_VER:=0.9.29
+UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc
+UCLIBC_SOURCE:=uClibc-$(strip $(subst ",, $(BR2_USE_UCLIBC_SNAPSHOT))).tar.bz2
+#"))
+UCLIBC_SITE:=http://www.uclibc.org/downloads/snapshots
+UCLIBC_PATCH_DIR:=toolchain/uClibc/
+else
+# releases
+ifeq ($(BR2_UCLIBC_VERSION_0_9_29),y)
+UCLIBC_VER:=0.9.29
+endif
+ifeq ($(BR2_UCLIBC_VERSION_0_9_28_3),y)
+UCLIBC_VER:=0.9.28.3
+endif
+UCLIBC_SITE:=http://www.uclibc.org/downloads
+
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_SOURCE),y)
+UCLIBC_SITE:=$(VENDOR_SITE)
+endif
+
+UCLIBC_OFFICIAL_VERSION:=$(UCLIBC_VER)$(VENDOR_SUFFIX)$(VENDOR_UCLIBC_RELEASE)
+
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
+UCLIBC_PATCH_DIR:=toolchain/uClibc/
+else
+UCLIBC_PATCH_DIR:=toolchain/uClibc/ext_source/$(VENDOR_PATCH_DIR)/$(UCLIBC_OFFICIAL_VERSION)
+endif
+
+UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc-$(UCLIBC_OFFICIAL_VERSION)
+UCLIBC_SOURCE:=uClibc-$(UCLIBC_OFFICIAL_VERSION).tar.bz2
+endif
+
+UCLIBC_CAT:=$(BZCAT)
+
+UCLIBC_TARGET_ARCH:=$(shell $(SHELL) -c "echo $(ARCH) | sed \
+ -e 's/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh[234].*/sh/' \
+ -e 's/mips.*/mips/' \
+ -e 's/mipsel.*/mips/' \
+ -e 's/cris.*/cris/' \
+ -e 's/nios2.*/nios2/' \
+")
+# just handle the ones that can be big or little
+UCLIBC_TARGET_ENDIAN:=$(shell $(SHELL) -c "echo $(ARCH) | sed \
+ -e 's/armeb/BIG/' \
+ -e 's/arm/LITTLE/' \
+ -e 's/mipsel/LITTLE/' \
+ -e 's/mips/BIG/' \
+ -e 's/sh[234].*eb/BIG/' \
+ -e 's/sh[234]/LITTLE/' \
+ -e 's/sparc.*/BIG/' \
+")
+
+ifneq ($(UCLIBC_TARGET_ENDIAN),LITTLE)
+ifneq ($(UCLIBC_TARGET_ENDIAN),BIG)
+UCLIBC_TARGET_ENDIAN:=
+endif
+endif
+ifeq ($(UCLIBC_TARGET_ENDIAN),LITTLE)
+UCLIBC_NOT_TARGET_ENDIAN:=BIG
+else
+UCLIBC_NOT_TARGET_ENDIAN:=LITTLE
+endif
+
+UCLIBC_ARM_TYPE:=CONFIG_$(strip $(subst ",, $(BR2_ARM_TYPE)))
+#"))
+UCLIBC_SPARC_TYPE:=CONFIG_SPARC_$(strip $(subst ",, $(BR2_SPARC_TYPE)))
+#"))
+
+$(DL_DIR)/$(UCLIBC_SOURCE):
+ $(WGET) -P $(DL_DIR) $(UCLIBC_SITE)/$(UCLIBC_SOURCE)
+
+ifneq ($(BR2_ENABLE_LOCALE),)
+UCLIBC_SITE_LOCALE:=http://www.uclibc.org/downloads
+UCLIBC_SOURCE_LOCALE:=uClibc-locale-030818.tgz
+
+$(DL_DIR)/$(UCLIBC_SOURCE_LOCALE):
+ $(WGET) -P $(DL_DIR) $(UCLIBC_SITE_LOCALE)/$(UCLIBC_SOURCE_LOCALE)
+
+UCLIBC_LOCALE_DATA:=$(DL_DIR)/$(UCLIBC_SOURCE_LOCALE)
+else
+UCLIBC_LOCALE_DATA=
+endif
+
+uclibc-unpacked: $(UCLIBC_DIR)/.unpacked
+$(UCLIBC_DIR)/.unpacked: $(DL_DIR)/$(UCLIBC_SOURCE) $(UCLIBC_LOCALE_DATA)
+ mkdir -p $(TOOL_BUILD_DIR)
+ rm -rf $(UCLIBC_DIR)
+ $(UCLIBC_CAT) $(DL_DIR)/$(UCLIBC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
+ touch $@
+
+uclibc-patched: $(UCLIBC_DIR)/.patched
+$(UCLIBC_DIR)/.patched: $(UCLIBC_DIR)/.unpacked
+ifneq ($(BR2_UCLIBC_VERSION_SNAPSHOT),y)
+ toolchain/patch-kernel.sh $(UCLIBC_DIR) $(UCLIBC_PATCH_DIR) \
+ uClibc-$(UCLIBC_OFFICIAL_VERSION)-\*.patch \
+ uClibc-$(UCLIBC_OFFICIAL_VERSION)-\*.patch.$(ARCH)
+else
+ toolchain/patch-kernel.sh $(UCLIBC_DIR) $(UCLIBC_PATCH_DIR) \
+ uClibc.\*.patch uClibc.\*.patch.$(ARCH)
+endif
+ifneq ($(BR2_ENABLE_LOCALE),)
+ cp -dpf $(DL_DIR)/$(UCLIBC_SOURCE_LOCALE) $(UCLIBC_DIR)/extra/locale/
+endif
+ touch $@
+
+
+# Some targets may wish to provide their own UCLIBC_CONFIG_FILE...
+$(UCLIBC_DIR)/.oldconfig: $(UCLIBC_DIR)/.patched $(UCLIBC_CONFIG_FILE)
+ cp -f $(UCLIBC_CONFIG_FILE) $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's,^CROSS_COMPILER_PREFIX=.*,CROSS_COMPILER_PREFIX="$(TARGET_CROSS)",g' \
+ -e 's,# TARGET_$(UCLIBC_TARGET_ARCH) is not set,TARGET_$(UCLIBC_TARGET_ARCH)=y,g' \
+ -e 's,^TARGET_ARCH=".*",TARGET_ARCH=\"$(UCLIBC_TARGET_ARCH)\",g' \
+ -e 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(LINUX_HEADERS_DIR)\",g' \
+ -e 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(LINUX_HEADERS_DIR)/include\",g' \
+ -e 's,^RUNTIME_PREFIX=.*,RUNTIME_PREFIX=\"/\",g' \
+ -e 's,^DEVEL_PREFIX=.*,DEVEL_PREFIX=\"/usr/\",g' \
+ -e 's,^SHARED_LIB_LOADER_PREFIX=.*,SHARED_LIB_LOADER_PREFIX=\"/lib\",g' \
+ $(UCLIBC_DIR)/.oldconfig
+ifeq ($(UCLIBC_TARGET_ARCH),arm)
+ (/bin/echo "# CONFIG_GENERIC_ARM is not set"; \
+ /bin/echo "# CONFIG_ARM610 is not set"; \
+ /bin/echo "# CONFIG_ARM710 is not set"; \
+ /bin/echo "# CONFIG_ARM7TDMI is not set"; \
+ /bin/echo "# CONFIG_ARM720T is not set"; \
+ /bin/echo "# CONFIG_ARM920T is not set"; \
+ /bin/echo "# CONFIG_ARM922T is not set"; \
+ /bin/echo "# CONFIG_ARM926T is not set"; \
+ /bin/echo "# CONFIG_ARM10T is not set"; \
+ /bin/echo "# CONFIG_ARM1136JF_S is not set"; \
+ /bin/echo "# CONFIG_ARM1176JZ_S is not set"; \
+ /bin/echo "# CONFIG_ARM1176JZF_S is not set"; \
+ /bin/echo "# CONFIG_ARM_SA110 is not set"; \
+ /bin/echo "# CONFIG_ARM_SA1100 is not set"; \
+ /bin/echo "# CONFIG_ARM_XSCALE is not set"; \
+ /bin/echo "# CONFIG_ARM_IWMMXT is not set"; \
+ ) >> $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's/^\(CONFIG_[^_]*[_]*ARM[^=]*\)=.*/# \1 is not set/g' \
+ $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's/^.*$(UCLIBC_ARM_TYPE).*/$(UCLIBC_ARM_TYPE)=y/g' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/CONFIG_ARM_.ABI/d' $(UCLIBC_DIR)/.oldconfig
+ifeq ($(BR2_ARM_EABI),y)
+ /bin/echo "# CONFIG_ARM_OABI is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "CONFIG_ARM_EABI=y" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_ARM_OABI),y)
+ /bin/echo "CONFIG_ARM_OABI=y" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_ARM_EABI is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+endif
+ifeq ($(UCLIBC_TARGET_ARCH),mips)
+ $(SED) '/CONFIG_MIPS_[NO].._ABI/d' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/CONFIG_MIPS_ISA_.*/d' $(UCLIBC_DIR)/.oldconfig
+ (/bin/echo "# CONFIG_MIPS_O32_ABI is not set"; \
+ /bin/echo "# CONFIG_MIPS_N32_ABI is not set"; \
+ /bin/echo "# CONFIG_MIPS_N64_ABI is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_1 is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_2 is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_3 is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_4 is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_MIPS32 is not set"; \
+ /bin/echo "# CONFIG_MIPS_ISA_MIPS64 is not set"; \
+ ) >> $(UCLIBC_DIR)/.oldconfig
+ifeq ($(BR2_MIPS_OABI),y)
+ $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_MIPS_EABI),y)
+ $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_MIPS_ABI64),y)
+ $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_1),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_1\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_2),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_2\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_3),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_3\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_4),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_4\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_32),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_32r2),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_mips_64),y)
+ $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' $(UCLIBC_DIR)/.oldconfig
+endif
+endif
+ifeq ($(UCLIBC_TARGET_ARCH),nios2)
+ /bin/echo "# UCLIBC_FORMAT_FDPIC_ELF is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "UCLIBC_FORMAT_FLAT=y" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FLAT_SEP_DATA is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_SHARED_FLAT is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(UCLIBC_TARGET_ARCH),sh)
+ /bin/echo "# CONFIG_SH2A is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_SH2 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_SH3 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_SH4 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ifeq ($(BR2_sh2a_nofpueb),y)
+ $(SED) 's,# CONFIG_SH2A is not set,CONFIG_SH2A=y,g' $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FDPIC_ELF is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FLAT is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FLAT_SEP_DATA is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_SHARED_FLAT is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_sh2eb),y)
+ $(SED) 's,# CONFIG_SH2 is not set,CONFIG_SH2=y,g' $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FDPIC_ELF is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FLAT is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_FLAT_SEP_DATA is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# UCLIBC_FORMAT_SHARED_FLAT is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_sh3eb),y)
+ $(SED) 's,# CONFIG_SH3 is not set,CONFIG_SH3=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_sh3),y)
+ $(SED) 's,# CONFIG_SH3 is not set,CONFIG_SH3=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_sh4eb),y)
+ $(SED) 's,# CONFIG_SH4 is not set,CONFIG_SH4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_sh4),y)
+ $(SED) 's,# CONFIG_SH4 is not set,CONFIG_SH4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+endif
+ifeq ($(UCLIBC_TARGET_ARCH),sparc)
+ $(SED) 's/^\(CONFIG_[^_]*[_]*SPARC[^=]*\)=.*/# \1 is not set/g' \
+ $(UCLIBC_DIR)/.oldconfig
+ for i in V7 V8 V9 V9B; do echo "# CONFIG_SPARC_$$i is not set"; done \
+ >> $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's/^.*$(UCLIBC_SPARC_TYPE).*/$(UCLIBC_SPARC_TYPE)=y/g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(UCLIBC_TARGET_ARCH),powerpc)
+ifeq ($(BR2_powerpc_8540),y)
+ /bin/echo "# CONFIG_CLASSIC is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "CONFIG_E500=y" >> $(UCLIBC_DIR)/.oldconfig
+else
+ /bin/echo "CONFIG_CLASSIC=y" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_E500 is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+endif
+ifneq ($(UCLIBC_TARGET_ENDIAN),)
+ # The above doesn't work for me, so redo
+ $(SED) 's/.*\(ARCH_$(UCLIBC_NOT_TARGET_ENDIAN)_ENDIAN\).*/# \1 is not set/g' \
+ -e 's/.*\(ARCH_WANTS_$(UCLIBC_NOT_TARGET_ENDIAN)_ENDIAN\).*/# \1 is not set/g' \
+ -e 's/.*\(ARCH_$(UCLIBC_TARGET_ENDIAN)_ENDIAN\).*/\1=y/g' \
+ -e 's/.*\(ARCH_WANTS_$(UCLIBC_TARGET_ENDIAN)_ENDIAN\).*/\1=y/g' \
+ $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_LARGEFILE),y)
+ $(SED) 's,.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=n,g' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/.*UCLIBC_HAS_FOPEN_LARGEFILE_MODE.*/d' $(UCLIBC_DIR)/.oldconfig
+ echo "# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_INET_IPV6),y)
+ $(SED) 's,^.*UCLIBC_HAS_IPV6.*,UCLIBC_HAS_IPV6=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,^.*UCLIBC_HAS_IPV6.*,UCLIBC_HAS_IPV6=n,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_INET_RPC),y)
+ $(SED) 's,^.*UCLIBC_HAS_RPC.*,UCLIBC_HAS_RPC=y,g' \
+ -e 's,^.*UCLIBC_HAS_FULL_RPC.*,UCLIBC_HAS_FULL_RPC=y,g' \
+ -e 's,^.*UCLIBC_HAS_REENTRANT_RPC.*,UCLIBC_HAS_REENTRANT_RPC=y,g' \
+ $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,^.*UCLIBC_HAS_RPC.*,UCLIBC_HAS_RPC=n,g' \
+ -e 's,^.*UCLIBC_HAS_FULL_RPC.*,UCLIBC_HAS_FULL_RPC=n,g' \
+ -e 's,^.*UCLIBC_HAS_REENTRANT_RPC.*,UCLIBC_HAS_REENTRANT_RPC=n,g' \
+ $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_SOFT_FLOAT),y)
+ $(SED) 's,.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=n,g' \
+ -e 's,^[^_]*HAS_FPU.*,HAS_FPU=n,g' \
+ -e 's,.*UCLIBC_HAS_FLOATS.*,UCLIBC_HAS_FLOATS=y,g' \
+ -e 's,.*DO_C99_MATH.*,DO_C99_MATH=y,g' \
+ $(UCLIBC_DIR)/.oldconfig
+ #$(SED) 's,.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=n\nHAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) '/UCLIBC_HAS_FLOATS/d' \
+ -e 's,.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=y\nHAS_FPU=y\nUCLIBC_HAS_FLOATS=y\n,g' \
+ $(UCLIBC_DIR)/.oldconfig
+endif
+ $(SED) '/UCLIBC_HAS_THREADS/d' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/LINUXTHREADS/d' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/LINUXTHREADS_OLD/d' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/PTHREADS_DEBUG_SUPPORT/d' $(UCLIBC_DIR)/.oldconfig
+ $(SED) '/UCLIBC_HAS_THREADS_NATIVE/d' $(UCLIBC_DIR)/.oldconfig
+ifeq ($(BR2_PTHREADS_NONE),y)
+ echo "# UCLIBC_HAS_THREADS is not set" >> $(UCLIBC_DIR)/.oldconfig
+else
+ echo "UCLIBC_HAS_THREADS=y" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_PTHREADS),y)
+ echo "LINUXTHREADS=y" >> $(UCLIBC_DIR)/.oldconfig
+else
+ echo "# LINUXTHREADS is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_PTHREADS_OLD),y)
+ echo "LINUXTHREADS_OLD=y" >> $(UCLIBC_DIR)/.oldconfig
+else
+ echo "# LINUXTHREADS_OLD is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_PTHREADS_NATIVE),y)
+ echo "UCLIBC_HAS_THREADS_NATIVE=y" >> $(UCLIBC_DIR)/.oldconfig
+else
+ echo "# UCLIBC_HAS_THREADS_NATIVE is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_PTHREAD_DEBUG),y)
+ echo "PTHREADS_DEBUG_SUPPORT=y" >> $(UCLIBC_DIR)/.oldconfig
+else
+ echo "# PTHREADS_DEBUG_SUPPORT is not set" >> $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_ENABLE_LOCALE),y)
+ $(SED) 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=y\nUCLIBC_PREGENERATED_LOCALE_DATA=y\nUCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=y\nUCLIBC_HAS_XLOCALE=y\nUCLIBC_HAS_GLIBC_DIGIT_GROUPING=n\n,g' $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=n,g' $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=n,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_USE_WCHAR),y)
+ $(SED) 's,^.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,^.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=n,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_UCLIBC_PROGRAM_INVOCATION),y)
+ $(SED) 's,^.*UCLIBC_HAS_PROGRAM_INVOCATION_NAME.*,UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y,g' $(UCLIBC_DIR)/.oldconfig
+else
+ $(SED) 's,^.*UCLIBC_HAS_PROGRAM_INVOCATION_NAME.*,UCLIBC_HAS_PROGRAM_INVOCATION_NAME=n,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ("$(KERNEL_ARCH)","i386")
+ /bin/echo "# CONFIG_GENERIC_386 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_386 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_486 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_586 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_586MMX is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_686 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_PENTIUMII is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_PENTIUMIII is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_PENTIUM4 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_K6 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_K7 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_ELAN is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_CRUSOE is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_WINCHIPC6 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_WINCHIP2 is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_CYRIXIII is not set" >> $(UCLIBC_DIR)/.oldconfig
+ /bin/echo "# CONFIG_NEHEMIAH is not set" >> $(UCLIBC_DIR)/.oldconfig
+ifeq ($(BR2_x86_i386),y)
+ $(SED) 's,# CONFIG_386 is not set,CONFIG_386=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_i486),y)
+ $(SED) 's,# CONFIG_486 is not set,CONFIG_486=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_i586),y)
+ $(SED) 's,# CONFIG_586 is not set,CONFIG_586=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentium_mmx),y)
+ $(SED) 's,# CONFIG_586MMX is not set,CONFIG_586MMX=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_i686),y)
+ $(SED) 's,# CONFIG_686 is not set,CONFIG_686=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentiumpro),y)
+ $(SED) 's,# CONFIG_686 is not set,CONFIG_686=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentium2),y)
+ $(SED) 's,# CONFIG_PENTIUMII is not set,CONFIG_PENTIUMII=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentium3),y)
+ $(SED) 's,# CONFIG_PENTIUMIII is not set,CONFIG_PENTIUMIII=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentium4),y)
+ $(SED) 's,# CONFIG_PENTIUM4 is not set,CONFIG_PENTIUM4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_pentium_m),y)
+ $(SED) 's,# CONFIG_PENTIUM4 is not set,CONFIG_PENTIUM4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_nocona),y)
+ $(SED) 's,# CONFIG_PENTIUM4 is not set,CONFIG_PENTIUM4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+ifeq ($(BR2_x86_core2),y)
+ $(SED) 's,# CONFIG_PENTIUM4 is not set,CONFIG_PENTIUM4=y,g' $(UCLIBC_DIR)/.oldconfig
+endif
+endif
+
+$(UCLIBC_DIR)/.config: $(UCLIBC_DIR)/.oldconfig
+ cp -f $(UCLIBC_DIR)/.oldconfig $(UCLIBC_DIR)/.config
+ mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/include
+ mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/lib
+ mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/lib
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ HOSTCC="$(HOSTCC)" \
+ oldconfig
+ touch $@
+
+$(UCLIBC_DIR)/.configured: $(LINUX_HEADERS_DIR)/.configured $(UCLIBC_DIR)/.config
+ set -x && $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ HOSTCC="$(HOSTCC)" \
+ headers install_dev
+ # Install the kernel headers to the first stage gcc include dir
+ # if necessary
+ifeq ($(LINUX_HEADERS_IS_KERNEL),y)
+ if [ ! -f $(TOOL_BUILD_DIR)/uClibc_dev/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/* \
+ $(TOOL_BUILD_DIR)/uClibc_dev/usr/include/; \
+ fi
+else
+ if [ ! -f $(STAGING_DIR)/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm \
+ $(TOOL_BUILD_DIR)/uClibc_dev/usr/include/; \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/linux \
+ $(TOOL_BUILD_DIR)/uClibc_dev/usr/include/; \
+ if [ -d $(LINUX_HEADERS_DIR)/include/asm-generic ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm-generic \
+ $(TOOL_BUILD_DIR)/uClibc_dev/usr/include/; \
+ fi; \
+ fi
+endif
+ touch $@
+
+$(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.configured $(gcc_initial) $(LIBFLOAT_TARGET)
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX= \
+ DEVEL_PREFIX=/ \
+ RUNTIME_PREFIX=/ \
+ HOSTCC="$(HOSTCC)" \
+ all
+ touch -c $@
+
+uclibc-menuconfig: host-sed $(UCLIBC_DIR)/.config
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
+ HOSTCC="$(HOSTCC)" \
+ menuconfig && \
+ touch -c $(UCLIBC_DIR)/.config
+
+
+$(STAGING_DIR)/usr/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
+ifneq ($(BR2_TOOLCHAIN_SYSROOT),y)
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX= \
+ DEVEL_PREFIX=$(STAGING_DIR)/ \
+ RUNTIME_PREFIX=$(STAGING_DIR)/ \
+ install_runtime install_dev
+else
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(STAGING_DIR) \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=/ \
+ install_runtime install_dev
+endif
+ # Install the kernel headers to the staging dir if necessary
+ifeq ($(LINUX_HEADERS_IS_KERNEL),y)
+ if [ ! -f $(STAGING_DIR)/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/* \
+ $(STAGING_DIR)/usr/include/; \
+ fi
+else
+ if [ ! -f $(STAGING_DIR)/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm \
+ $(STAGING_DIR)/usr/include/; \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/linux \
+ $(STAGING_DIR)/usr/include/; \
+ if [ -d $(LINUX_HEADERS_DIR)/include/asm-generic ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm-generic \
+ $(STAGING_DIR)/usr/include/; \
+ fi; \
+ fi
+endif
+ # Build the host utils. Need to add an install target...
+ $(MAKE1) -C $(UCLIBC_DIR)/utils \
+ PREFIX=$(STAGING_DIR) \
+ HOSTCC="$(HOSTCC)" \
+ hostutils
+ if [ -f $(UCLIBC_DIR)/utils/ldd.host ]; then \
+ install -c $(UCLIBC_DIR)/utils/ldd.host $(STAGING_DIR)/usr/bin/ldd; \
+ ln -sf ldd $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-ldd; \
+ fi
+ if [ -f $(UCLIBC_DIR)/utils/ldconfig.host ]; then \
+ install -c $(UCLIBC_DIR)/utils/ldconfig.host $(STAGING_DIR)/usr/bin/ldconfig; \
+ ln -sf ldconfig $(STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-ldconfig; \
+ ln -sf ldconfig $(STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-ldconfig; \
+ fi
+ touch -c $@
+
+ifneq ($(TARGET_DIR),)
+$(TARGET_DIR)/lib/libc.so.0: $(STAGING_DIR)/usr/lib/libc.a
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(TARGET_DIR) \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=/ \
+ install_runtime
+ifeq ($(BR2_UCLIBC_VERSION_0_9_28_3),y)
+ifneq ($(BR2_PTHREAD_DEBUG),y)
+ -$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(@D)/libpthread*.so*
+endif
+endif
+ touch -c $@
+
+$(TARGET_DIR)/usr/bin/ldd: $(cross_compiler)
+ $(MAKE1) -C $(UCLIBC_DIR) CC=$(TARGET_CROSS)gcc \
+ CPP=$(TARGET_CROSS)cpp LD=$(TARGET_CROSS)ld \
+ PREFIX=$(TARGET_DIR) utils install_utils
+ifeq ($(strip $(BR2_CROSS_TOOLCHAIN_TARGET_UTILS)),y)
+ mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/target_utils
+ install -c $(TARGET_DIR)/usr/bin/ldd \
+ $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/target_utils/ldd
+endif
+ touch -c $@
+
+UCLIBC_TARGETS=$(TARGET_DIR)/lib/libc.so.0
+endif
+
+uclibc: $(cross_compiler) $(STAGING_DIR)/usr/lib/libc.a $(UCLIBC_TARGETS)
+
+uclibc-source: $(DL_DIR)/$(UCLIBC_SOURCE)
+
+uclibc-unpacked: $(UCLIBC_DIR)/.unpacked
+
+uclibc-config: $(UCLIBC_DIR)/.config
+
+uclibc-oldconfig: $(UCLIBC_DIR)/.oldconfig
+
+uclibc-update: uclibc-config
+ cp -f $(UCLIBC_DIR)/.config $(UCLIBC_CONFIG_FILE)
+
+uclibc-configured: kernel-headers $(UCLIBC_DIR)/.configured
+
+uclibc-configured-source: uclibc-source
+
+uclibc-clean:
+ -$(MAKE1) -C $(UCLIBC_DIR) clean
+ rm -f $(UCLIBC_DIR)/.config
+
+uclibc-dirclean:
+ rm -rf $(UCLIBC_DIR)
+
+uclibc-target-utils:
+#$(TARGET_DIR)/usr/bin/ldd
+
+uclibc-target-utils-source: $(DL_DIR)/$(UCLIBC_SOURCE)
+
+#############################################################
+#
+# uClibc for the target just needs its header files
+# and whatnot installed.
+#
+#############################################################
+
+$(TARGET_DIR)/usr/lib/libc.a: $(STAGING_DIR)/usr/lib/libc.a
+ $(MAKE1) -C $(UCLIBC_DIR) \
+ PREFIX=$(TARGET_DIR) \
+ DEVEL_PREFIX=/usr/ \
+ RUNTIME_PREFIX=/ \
+ install_dev
+ # Install the kernel headers to the target dir if necessary
+ifeq ($(LINUX_HEADERS_IS_KERNEL),y)
+ if [ ! -f $(TARGET_DIR)/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/* \
+ $(TARGET_DIR)/usr/include/; \
+ fi
+else
+ if [ ! -f $(TARGET_DIR)/usr/include/linux/version.h ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm \
+ $(TARGET_DIR)/usr/include/; \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/linux \
+ $(TARGET_DIR)/usr/include/; \
+ if [ -d $(LINUX_HEADERS_DIR)/include/asm-generic ]; then \
+ cp -pLR $(LINUX_HEADERS_DIR)/include/asm-generic \
+ $(TARGET_DIR)/usr/include/; \
+ fi; \
+ fi
+endif
+ touch -c $@
+
+uclibc_target: cross_compiler uclibc $(TARGET_DIR)/usr/lib/libc.a $(TARGET_DIR)/usr/bin/ldd
+
+uclibc_target-clean:
+ rm -rf $(TARGET_DIR)/usr/include \
+ $(TARGET_DIR)/usr/lib/libc.a $(TARGET_DIR)/usr/bin/ldd
+
+uclibc_target-dirclean:
+ rm -rf $(TARGET_DIR)/usr/include
+
+endif
diff --git a/cleopatre/buildroot/toolchain/wget-show-external-deps.sh b/cleopatre/buildroot/toolchain/wget-show-external-deps.sh
new file mode 100755
index 0000000000..20071c05fc
--- /dev/null
+++ b/cleopatre/buildroot/toolchain/wget-show-external-deps.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+# replacement for wget (see BR2_WGET) which simply shows the file name to be
+# downloaded. Used by the external-deps make target.
+
+exec basename ${!#} \ No newline at end of file